comparison cagou/core/common.py @ 193:284cb5c467b0

core (common): split JidItem in 3 classes: - JidItem to only view an Entity - JidButton to allow to click - JidToggle to select
author Goffi <goffi@goffi.org>
date Wed, 23 May 2018 18:40:58 +0200
parents 7177fe2d9725
children 30be583dbabc
comparison
equal deleted inserted replaced
192:62198e00a2b7 193:284cb5c467b0
21 21
22 from sat.core.i18n import _ 22 from sat.core.i18n import _
23 from kivy.uix.image import Image 23 from kivy.uix.image import Image
24 from kivy.uix.label import Label 24 from kivy.uix.label import Label
25 from kivy.uix.behaviors import ButtonBehavior 25 from kivy.uix.behaviors import ButtonBehavior
26 from kivy.uix.behaviors import ToggleButtonBehavior
26 from kivy.uix.boxlayout import BoxLayout 27 from kivy.uix.boxlayout import BoxLayout
28 from cagou.core.constants import Const as C
27 from kivy import properties 29 from kivy import properties
28 from cagou import G 30 from cagou import G
29 import json 31 import json
30 from sat.core import log as logging 32 from sat.core import log as logging
31 33
36 38
37 class IconButton(ButtonBehavior, Image): 39 class IconButton(ButtonBehavior, Image):
38 pass 40 pass
39 41
40 42
41 class JidItem(ButtonBehavior, BoxLayout): 43 class JidItem(BoxLayout):
44 bg_color = properties.ListProperty([0.2, 0.2, 0.2, 1])
45 color = properties.ListProperty([1, 1, 1, 1])
42 46
43 def __init__(self, jid, profile, **kwargs): 47 def __init__(self, jid, profile, **kwargs):
44 self.jid = jid 48 self.jid = jid
45 self.profile = profile 49 self.profile = profile
46 self.nick = kwargs.get('nick') 50 self.nick = kwargs.get('nick')
51 if host.contact_lists[self.profile].isRoom(self.jid.bare): 55 if host.contact_lists[self.profile].isRoom(self.jid.bare):
52 wid.opacity = 0 56 wid.opacity = 0
53 return "" 57 return ""
54 else: 58 else:
55 return host.getAvatar(self.jid, profile=self.profile) or host.getDefaultAvatar(self.jid) 59 return host.getAvatar(self.jid, profile=self.profile) or host.getDefaultAvatar(self.jid)
60
61
62 class JidButton(ButtonBehavior, JidItem):
63 pass
64
65
66 class JidToggle(ToggleButtonBehavior, JidItem):
67 selected_color = properties.ListProperty(C.COLOR_SEC_DARK)
56 68
57 69
58 class Symbol(Label): 70 class Symbol(Label):
59 symbol_map = None 71 symbol_map = None
60 symbol = properties.StringProperty() 72 symbol = properties.StringProperty()