Mercurial > libervia-desktop-kivy
diff src/cagou/core/common.py @ 107:f0cf44df8486
JidWidget: first draft
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 15 Jan 2017 21:21:22 +0100 |
parents | 3efca1b10b2f |
children |
line wrap: on
line diff
--- a/src/cagou/core/common.py Sun Jan 15 21:21:20 2017 +0100 +++ b/src/cagou/core/common.py Sun Jan 15 21:21:22 2017 +0100 @@ -21,7 +21,26 @@ from kivy.uix.image import Image from kivy.uix.behaviors import ButtonBehavior +from kivy.uix.boxlayout import BoxLayout +from cagou import G class IconButton(ButtonBehavior, Image): pass + + +class JidWidget(ButtonBehavior, BoxLayout): + + def __init__(self, jid, profile, **kwargs): + self.jid = jid + self.profile = profile + self.nick = kwargs.get('nick') + super(JidWidget, self).__init__(**kwargs) + + def getImage(self, wid): + host = G.host + if host.contact_lists[self.profile].isRoom(self.jid.bare): + wid.opacity = 0 + return "" + else: + return host.getAvatar(self.jid, profile=self.profile) or host.getDefaultAvatar(self.jid)