Mercurial > libervia-desktop-kivy
annotate src/cagou/plugins/plugin_wid_contact_list.py @ 15:56838ad5c84b
files reorganisation, cagou is now launched with python2 cagou.py in src/
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 09 Jul 2016 17:24:01 +0200 |
parents | src/plugin_wid_contact_list.py@21a432afd06d |
children | ba14b596b90e |
rev | line source |
---|---|
9 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client | |
5 # Copyright (C) 2016 Jérôme Poisson (goffi@goffi.org) | |
6 | |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
17 # You should have received a copy of the GNU Affero General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 | |
21 from sat.core import log as logging | |
22 log = logging.getLogger(__name__) | |
14 | 23 from sat.core.i18n import _ |
9 | 24 from sat_frontends.quick_frontend.quick_contact_list import QuickContactList |
25 from kivy.uix.boxlayout import BoxLayout | |
26 from kivy.uix.listview import ListView | |
27 from kivy.adapters.listadapter import ListAdapter | |
28 from kivy import properties | |
15
56838ad5c84b
files reorganisation, cagou is now launched with python2 cagou.py in src/
Goffi <goffi@goffi.org>
parents:
14
diff
changeset
|
29 from cagou.core import cagou_widget |
56838ad5c84b
files reorganisation, cagou is now launched with python2 cagou.py in src/
Goffi <goffi@goffi.org>
parents:
14
diff
changeset
|
30 from cagou.core import image |
9 | 31 |
32 | |
14 | 33 PLUGIN_INFO = { |
34 "name": _(u"contacts"), | |
35 "main": "ContactList", | |
36 "description": _(u"list of contacts"), | |
37 } | |
38 | |
39 | |
9 | 40 class Avatar(image.Image): |
41 pass | |
42 | |
43 | |
44 class ContactItem(BoxLayout): | |
45 data = properties.DictProperty() | |
46 jid = properties.StringProperty('') | |
47 | |
48 def __init__(self, **kwargs): | |
49 BoxLayout.__init__(self, **kwargs) | |
50 | |
51 | |
15
56838ad5c84b
files reorganisation, cagou is now launched with python2 cagou.py in src/
Goffi <goffi@goffi.org>
parents:
14
diff
changeset
|
52 class ContactList(QuickContactList, cagou_widget.CagouWidget): |
9 | 53 |
54 def __init__(self, host, target, profiles): | |
55 QuickContactList.__init__(self, host, profiles) | |
15
56838ad5c84b
files reorganisation, cagou is now launched with python2 cagou.py in src/
Goffi <goffi@goffi.org>
parents:
14
diff
changeset
|
56 cagou_widget.CagouWidget.__init__(self, host) |
9 | 57 self.adapter = ListAdapter(data={}, |
58 cls=ContactItem, | |
59 args_converter=self.contactDataConverter, | |
60 selection_mode='multiple', | |
61 allow_empty_selection=True, | |
62 ) | |
63 self.add_widget(ListView(adapter=self.adapter)) | |
64 self.update() | |
65 | |
66 def contactDataConverter(self, idx, bare_jid): | |
67 return {"jid": bare_jid, "data": self._items_cache[bare_jid]} | |
68 | |
69 def update(self, entities=None, type_=None, profile=None): | |
70 log.info("update: %s %s %s" % (entities, type_, profile)) | |
71 # FIXME: for now we update on each event | |
72 # if entities is None and type_ is None: | |
73 self._items_cache = self.items | |
74 self.adapter.data = self.items_sorted | |
75 |