annotate cagou/core/common.py @ 397:54f6a47cc60a

core (common): added a notifications counter on ContactButton and use it in JidSelector: A notifications counter is drawned above avatar if `nofifs` key is present and not empty in `data`. This is used in JidSelector to show counter when necessary with opened chats.
author Goffi <goffi@goffi.org>
date Sun, 09 Feb 2020 23:47:29 +0100
parents 442756495a96
children f7476818f9fb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
348
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
1 #!/usr/bin/env python3
26
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
2
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client
378
4d660b252487 dates update
Goffi <goffi@goffi.org>
parents: 348
diff changeset
4 # Copyright (C) 2016-2020 Jérôme Poisson (goffi@goffi.org)
26
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
5
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
10
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
15
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
18
237
059c5b39032d plugin file sharing: moved common discovery widgets to new core.common_widgets module
Goffi <goffi@goffi.org>
parents: 220
diff changeset
19 """common simple widgets"""
26
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
20
348
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
21 import json
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
22 from functools import partial
134
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
23 from sat.core.i18n import _
348
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
24 from sat.core import log as logging
389
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
25 from kivy.uix.widget import Widget
26
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from kivy.uix.image import Image
134
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
27 from kivy.uix.label import Label
26
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from kivy.uix.behaviors import ButtonBehavior
193
284cb5c467b0 core (common): split JidItem in 3 classes:
Goffi <goffi@goffi.org>
parents: 179
diff changeset
29 from kivy.uix.behaviors import ToggleButtonBehavior
107
f0cf44df8486 JidWidget: first draft
Goffi <goffi@goffi.org>
parents: 26
diff changeset
30 from kivy.uix.boxlayout import BoxLayout
348
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
31 from kivy.uix.scrollview import ScrollView
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
32 from kivy.event import EventDispatcher
322
e2b51663d8b8 core, android: new share widget + added Cagou to "share" menu:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
33 from kivy.metrics import dp
134
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
34 from kivy import properties
389
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
35 from sat_frontends.quick_frontend import quick_chat
348
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
36 from cagou.core.constants import Const as C
107
f0cf44df8486 JidWidget: first draft
Goffi <goffi@goffi.org>
parents: 26
diff changeset
37 from cagou import G
134
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
38
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
39 log = logging.getLogger(__name__)
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
40
312
772c170b47a9 Python3 port:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
41 UNKNOWN_SYMBOL = 'Unknown symbol name'
26
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
42
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
43
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
44 class IconButton(ButtonBehavior, Image):
3efca1b10b2f common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff changeset
45 pass
107
f0cf44df8486 JidWidget: first draft
Goffi <goffi@goffi.org>
parents: 26
diff changeset
46
f0cf44df8486 JidWidget: first draft
Goffi <goffi@goffi.org>
parents: 26
diff changeset
47
322
e2b51663d8b8 core, android: new share widget + added Cagou to "share" menu:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
48 class Avatar(Image):
e2b51663d8b8 core, android: new share widget + added Cagou to "share" menu:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
49 pass
e2b51663d8b8 core, android: new share widget + added Cagou to "share" menu:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
50
e2b51663d8b8 core, android: new share widget + added Cagou to "share" menu:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
51
397
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
52 class NotifLabel(Label):
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
53 pass
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
54
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
55
322
e2b51663d8b8 core, android: new share widget + added Cagou to "share" menu:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
56 class ContactItem(BoxLayout):
348
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
57 """An item from ContactList
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
58
397
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
59 The item will drawn as an icon (JID avatar) with its jid below.
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
60 If "notifs" are present in data, a notification counter will be drawn above the
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
61 avatar.
348
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
62 """
322
e2b51663d8b8 core, android: new share widget + added Cagou to "share" menu:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
63 base_width = dp(150)
397
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
64 avatar_layout = properties.ObjectProperty()
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
65 avatar = properties.ObjectProperty()
322
e2b51663d8b8 core, android: new share widget + added Cagou to "share" menu:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
66 profile = properties.StringProperty()
e2b51663d8b8 core, android: new share widget + added Cagou to "share" menu:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
67 data = properties.DictProperty()
e2b51663d8b8 core, android: new share widget + added Cagou to "share" menu:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
68 jid = properties.StringProperty('')
e2b51663d8b8 core, android: new share widget + added Cagou to "share" menu:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
69
397
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
70 def on_kv_post(self, __):
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
71 if self.data and self.data.get('notifs'):
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
72 notif = NotifLabel(
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
73 pos_hint={"right": 0.8, "y": 0},
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
74 text=str(len(self.data['notifs']))
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
75 )
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
76 self.avatar_layout.add_widget(notif)
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
77
322
e2b51663d8b8 core, android: new share widget + added Cagou to "share" menu:
Goffi <goffi@goffi.org>
parents: 312
diff changeset
78
348
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
79 class ContactButton(ButtonBehavior, ContactItem):
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
80 pass
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
81
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
82
193
284cb5c467b0 core (common): split JidItem in 3 classes:
Goffi <goffi@goffi.org>
parents: 179
diff changeset
83 class JidItem(BoxLayout):
284cb5c467b0 core (common): split JidItem in 3 classes:
Goffi <goffi@goffi.org>
parents: 179
diff changeset
84 bg_color = properties.ListProperty([0.2, 0.2, 0.2, 1])
284cb5c467b0 core (common): split JidItem in 3 classes:
Goffi <goffi@goffi.org>
parents: 179
diff changeset
85 color = properties.ListProperty([1, 1, 1, 1])
256
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
86 jid = properties.StringProperty()
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
87 profile = properties.StringProperty()
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
88 nick = properties.StringProperty()
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
89 avatar = properties.ObjectProperty()
107
f0cf44df8486 JidWidget: first draft
Goffi <goffi@goffi.org>
parents: 26
diff changeset
90
256
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
91 def on_avatar(self, wid, jid_):
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
92 if self.jid and self.profile:
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
93 self.getImage()
107
f0cf44df8486 JidWidget: first draft
Goffi <goffi@goffi.org>
parents: 26
diff changeset
94
256
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
95 def on_jid(self, wid, jid_):
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
96 if self.profile and self.avatar:
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
97 self.getImage()
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
98
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
99 def on_profile(self, wid, profile):
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
100 if self.jid and self.avatar:
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
101 self.getImage()
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
102
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
103 def getImage(self):
107
f0cf44df8486 JidWidget: first draft
Goffi <goffi@goffi.org>
parents: 26
diff changeset
104 host = G.host
f0cf44df8486 JidWidget: first draft
Goffi <goffi@goffi.org>
parents: 26
diff changeset
105 if host.contact_lists[self.profile].isRoom(self.jid.bare):
256
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
106 self.avatar.opacity = 0
ba7b8cb7ddcd common: don't use anymore positional argument in JidItem
Goffi <goffi@goffi.org>
parents: 247
diff changeset
107 self.avatar.source = ""
107
f0cf44df8486 JidWidget: first draft
Goffi <goffi@goffi.org>
parents: 26
diff changeset
108 else:
273
0ef216091f2b core: removed forgotten debugging code
Goffi <goffi@goffi.org>
parents: 256
diff changeset
109 self.avatar.source = (
0ef216091f2b core: removed forgotten debugging code
Goffi <goffi@goffi.org>
parents: 256
diff changeset
110 host.getAvatar(self.jid, profile=self.profile)
0ef216091f2b core: removed forgotten debugging code
Goffi <goffi@goffi.org>
parents: 256
diff changeset
111 or host.getDefaultAvatar(self.jid)
0ef216091f2b core: removed forgotten debugging code
Goffi <goffi@goffi.org>
parents: 256
diff changeset
112 )
134
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
113
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
114
193
284cb5c467b0 core (common): split JidItem in 3 classes:
Goffi <goffi@goffi.org>
parents: 179
diff changeset
115 class JidButton(ButtonBehavior, JidItem):
284cb5c467b0 core (common): split JidItem in 3 classes:
Goffi <goffi@goffi.org>
parents: 179
diff changeset
116 pass
284cb5c467b0 core (common): split JidItem in 3 classes:
Goffi <goffi@goffi.org>
parents: 179
diff changeset
117
284cb5c467b0 core (common): split JidItem in 3 classes:
Goffi <goffi@goffi.org>
parents: 179
diff changeset
118
284cb5c467b0 core (common): split JidItem in 3 classes:
Goffi <goffi@goffi.org>
parents: 179
diff changeset
119 class JidToggle(ToggleButtonBehavior, JidItem):
284cb5c467b0 core (common): split JidItem in 3 classes:
Goffi <goffi@goffi.org>
parents: 179
diff changeset
120 selected_color = properties.ListProperty(C.COLOR_SEC_DARK)
284cb5c467b0 core (common): split JidItem in 3 classes:
Goffi <goffi@goffi.org>
parents: 179
diff changeset
121
284cb5c467b0 core (common): split JidItem in 3 classes:
Goffi <goffi@goffi.org>
parents: 179
diff changeset
122
134
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
123 class Symbol(Label):
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
124 symbol_map = None
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
125 symbol = properties.StringProperty()
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
126
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
127 def __init__(self, **kwargs):
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
128 if self.symbol_map is None:
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
129 with open(G.host.app.expand('{media}/fonts/fontello/config.json')) as f:
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
130 fontello_conf = json.load(f)
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
131 Symbol.symbol_map = {g['css']:g['code'] for g in fontello_conf['glyphs']}
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
132
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
133 super(Symbol, self).__init__(**kwargs)
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
134
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
135 def on_symbol(self, instance, symbol):
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
136 try:
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
137 code = self.symbol_map[symbol]
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
138 except KeyError:
312
772c170b47a9 Python3 port:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
139 log.warning(_("Invalid symbol {symbol}").format(symbol=symbol))
134
1cca97e27a69 core (common): new Symbol widget:
Goffi <goffi@goffi.org>
parents: 126
diff changeset
140 else:
312
772c170b47a9 Python3 port:
Goffi <goffi@goffi.org>
parents: 282
diff changeset
141 self.text = chr(code)
135
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 134
diff changeset
142
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 134
diff changeset
143
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 134
diff changeset
144 class SymbolButton(ButtonBehavior, Symbol):
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 134
diff changeset
145 pass
178
11ff8cd93659 common: new ActionSymbol widget, which use a symbol to show an action
Goffi <goffi@goffi.org>
parents: 145
diff changeset
146
11ff8cd93659 common: new ActionSymbol widget, which use a symbol to show an action
Goffi <goffi@goffi.org>
parents: 145
diff changeset
147
218
30be583dbabc core (common): new SymbolLabel class to have a clickable area with a symbol and a label next to it.
Goffi <goffi@goffi.org>
parents: 193
diff changeset
148 class SymbolLabel(ButtonBehavior, BoxLayout):
30be583dbabc core (common): new SymbolLabel class to have a clickable area with a symbol and a label next to it.
Goffi <goffi@goffi.org>
parents: 193
diff changeset
149 symbol = properties.StringProperty("")
30be583dbabc core (common): new SymbolLabel class to have a clickable area with a symbol and a label next to it.
Goffi <goffi@goffi.org>
parents: 193
diff changeset
150 text = properties.StringProperty("")
30be583dbabc core (common): new SymbolLabel class to have a clickable area with a symbol and a label next to it.
Goffi <goffi@goffi.org>
parents: 193
diff changeset
151 color = properties.ListProperty(C.COLOR_SEC)
30be583dbabc core (common): new SymbolLabel class to have a clickable area with a symbol and a label next to it.
Goffi <goffi@goffi.org>
parents: 193
diff changeset
152 bold = properties.BooleanProperty(True)
30be583dbabc core (common): new SymbolLabel class to have a clickable area with a symbol and a label next to it.
Goffi <goffi@goffi.org>
parents: 193
diff changeset
153 symbol_wid = properties.ObjectProperty()
30be583dbabc core (common): new SymbolLabel class to have a clickable area with a symbol and a label next to it.
Goffi <goffi@goffi.org>
parents: 193
diff changeset
154 label = properties.ObjectProperty()
30be583dbabc core (common): new SymbolLabel class to have a clickable area with a symbol and a label next to it.
Goffi <goffi@goffi.org>
parents: 193
diff changeset
155
30be583dbabc core (common): new SymbolLabel class to have a clickable area with a symbol and a label next to it.
Goffi <goffi@goffi.org>
parents: 193
diff changeset
156
178
11ff8cd93659 common: new ActionSymbol widget, which use a symbol to show an action
Goffi <goffi@goffi.org>
parents: 145
diff changeset
157 class ActionSymbol(Symbol):
11ff8cd93659 common: new ActionSymbol widget, which use a symbol to show an action
Goffi <goffi@goffi.org>
parents: 145
diff changeset
158 pass
179
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
159
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
160
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
161 class ActionIcon(BoxLayout):
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
162 plugin_info = properties.DictProperty()
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
163
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
164 def on_plugin_info(self, instance, plugin_info):
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
165 self.clear_widgets()
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
166 try:
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
167 symbol = plugin_info['icon_symbol']
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
168 except KeyError:
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
169 icon_src = plugin_info['icon_medium']
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
170 icon_wid = Image(source=icon_src, allow_stretch=True)
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
171 self.add_widget(icon_wid)
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
172 else:
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
173 icon_wid = ActionSymbol(symbol=symbol)
7177fe2d9725 common: new ActionIcon widget which display symbol or image icon according to what is specified in plugin_info
Goffi <goffi@goffi.org>
parents: 178
diff changeset
174 self.add_widget(icon_wid)
348
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
175
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
176
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
177 class JidSelector(ScrollView, EventDispatcher):
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
178 layout = properties.ObjectProperty(None)
389
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
179 # list of item to show, can be:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
180 # - a well-known string like:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
181 # * "roster": to show all roster jids
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
182 # * "opened_chats": to show jids of all opened chat widgets
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
183 # - a kivy Widget, which will be added to the layout (notable useful with
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
184 # common_widgets.CategorySeparator)
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
185 # - a callable, which must return an iterable of kwargs for ContactButton
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
186 to_show = properties.ListProperty(['roster'])
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
187 # if True, update() is called automatically when widget is created
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
188 # if False, you'll have to call update() at least once manually
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
189 implicit_update = properties.ObjectProperty(True)
348
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
190
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
191 def __init__(self, **kwargs):
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
192 self.register_event_type('on_select')
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
193 super().__init__(**kwargs)
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
194
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
195 def on_kv_post(self, wid):
389
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
196 if self.implicit_update:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
197 self.update()
348
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
198
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
199 def on_select(self, wid):
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
200 pass
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
201
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
202 def on_parent(self, wid, parent):
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
203 if parent is None:
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
204 log.debug("removing contactsFilled listener")
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
205 G.host.removeListener("contactsFilled", self.onContactsFilled)
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
206 else:
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
207 G.host.addListener("contactsFilled", self.onContactsFilled)
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
208
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
209 def onContactsFilled(self, profile):
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
210 log.debug("onContactsFilled event received")
389
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
211 self.update()
348
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
212
389
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
213 def update(self):
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
214 log.debug("starting update")
348
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
215 self.layout.clear_widgets()
389
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
216 for item in self.to_show:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
217 if isinstance(item, str):
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
218 if item == 'roster':
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
219 self.addRosterItems()
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
220 elif item == 'bookmarks':
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
221 self.addBookmarksItems()
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
222 elif item == 'opened_chats':
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
223 self.addOpenedChatsItems()
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
224 else:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
225 log.error(f'unknown "to_show" magic string {item!r}')
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
226 elif isinstance(item, Widget):
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
227 self.layout.add_widget(item)
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
228 elif callable(item):
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
229 items_kwargs = item()
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
230 for item_kwargs in items_kwargs:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
231 item = ContactButton(**item_kwargs)
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
232 item.bind(on_press=partial(self.dispatch, 'on_select'))
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
233 self.layout.add_widget(item)
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
234 else:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
235 log.error(f"unmanaged to_show item type: {item!r}")
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
236
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
237 def addOpenedChatsItems(self):
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
238 opened_chats = G.host.widgets.getWidgets(
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
239 quick_chat.QuickChat,
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
240 profiles = G.host.profiles)
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
241
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
242 for wid in opened_chats:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
243 contact_list = G.host.contact_lists[wid.profile]
397
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
244 data=contact_list.getItem(wid.target)
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
245 notifs = list(G.host.getNotifs(wid.target, profile=wid.profile))
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
246 if notifs:
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
247 # we shallow copy the dict to have the notification displayed only with
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
248 # opened chats (otherwise, the counter would appear on each other
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
249 # instance of ContactButton for this entity, i.e. in roster too).
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
250 data = data.copy()
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
251 data['notifs'] = notifs
389
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
252 try:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
253 item = ContactButton(
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
254 jid=wid.target,
397
54f6a47cc60a core (common): added a notifications counter on ContactButton and use it in JidSelector:
Goffi <goffi@goffi.org>
parents: 389
diff changeset
255 data=data,
389
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
256 profile=wid.profile,
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
257 )
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
258 except Exception as e:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
259 log.warning(f"Can't add contact {wid.target}: {e}")
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
260 continue
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
261 item.bind(on_press=partial(self.dispatch, 'on_select'))
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
262 self.layout.add_widget(item)
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
263
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
264 def addRosterItems(self):
348
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
265 for profile in G.host.profiles:
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
266 contact_list = G.host.contact_lists[profile]
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
267 for entity_jid in sorted(contact_list.roster):
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
268 item = ContactButton(
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
269 jid=entity_jid,
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
270 data=contact_list.getItem(entity_jid),
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
271 profile=profile,
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
272 )
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
273 item.bind(on_press=partial(self.dispatch, 'on_select'))
38fd457b2158 core (common, share_widget): new JidSelector widget:
Goffi <goffi@goffi.org>
parents: 322
diff changeset
274 self.layout.add_widget(item)
389
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
275
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
276 def addBookmarksItems(self):
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
277 for profile in G.host.profiles:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
278 profile_manager = G.host.profiles[profile]
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
279 try:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
280 bookmarks = profile_manager._bookmarks
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
281 except AttributeError:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
282 log.warning(f"no bookmark in cache for profile {profile}")
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
283 continue
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
284
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
285 contact_list = G.host.contact_lists[profile]
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
286 for entity_jid in bookmarks:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
287 try:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
288 cache = contact_list.getItem(entity_jid)
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
289 except KeyError:
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
290 cache = {}
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
291 item = ContactButton(
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
292 jid=entity_jid,
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
293 data=cache,
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
294 profile=profile,
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
295 )
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
296 item.bind(on_press=partial(self.dispatch, 'on_select'))
442756495a96 core (common): improved flexibility of jid selector:
Goffi <goffi@goffi.org>
parents: 378
diff changeset
297 self.layout.add_widget(item)