Mercurial > libervia-desktop-kivy
comparison src/cagou/plugins/plugin_wid_contact_list.py @ 22:74117b733bac
plugin chat: first draft:
- only one 2 one display is handled for now
- own messages are displayed in blue, other ones in gray
- by default we display our own jid (for now)
- to change target, contact in contact widget can be clicked, or a jid can be entered in header input
- disco is called on jid entered in header, if it's a conference a MUCJoin will be called (not implemented yet), else a new chat widget with the jid replace the current one
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 08 Aug 2016 01:07:43 +0200 |
parents | 5c9feaa060a5 |
children | d09bd16dbbe2 |
comparison
equal
deleted
inserted
replaced
21:57bf68eacdb9 | 22:74117b733bac |
---|---|
20 | 20 |
21 from sat.core import log as logging | 21 from sat.core import log as logging |
22 log = logging.getLogger(__name__) | 22 log = logging.getLogger(__name__) |
23 from sat.core.i18n import _ | 23 from sat.core.i18n import _ |
24 from sat_frontends.quick_frontend.quick_contact_list import QuickContactList | 24 from sat_frontends.quick_frontend.quick_contact_list import QuickContactList |
25 from sat_frontends.tools import jid | |
25 from kivy.uix.boxlayout import BoxLayout | 26 from kivy.uix.boxlayout import BoxLayout |
26 from kivy.uix.listview import ListView | 27 from kivy.uix.listview import ListView |
27 from kivy.adapters.listadapter import ListAdapter | 28 from kivy.adapters.listadapter import ListAdapter |
28 from kivy import properties | 29 from kivy import properties |
29 from cagou.core import cagou_widget | 30 from cagou.core import cagou_widget |
47 jid = properties.StringProperty('') | 48 jid = properties.StringProperty('') |
48 | 49 |
49 def __init__(self, **kwargs): | 50 def __init__(self, **kwargs): |
50 BoxLayout.__init__(self, **kwargs) | 51 BoxLayout.__init__(self, **kwargs) |
51 | 52 |
53 def on_touch_down(self, touch): | |
54 if self.collide_point(*touch.pos): | |
55 # XXX: for now clicking on an item launch the corresponding Chat widget | |
56 # behaviour should change in the future | |
57 try: | |
58 # FIXME: Q&D way to get chat plugin, should be replaced by a clean method | |
59 # in host | |
60 plg_infos = [p for p in G.host.getPluggedWidgets() if 'chat' in p['import_name']][0] | |
61 except IndexError: | |
62 log.warning(u"No plugin widget found to display chat") | |
63 else: | |
64 factory = plg_infos['factory'] | |
65 G.host.switchWidget(self, factory(plg_infos, jid.JID(self.jid), profiles=iter(G.host.profiles))) | |
66 | |
67 | |
52 | 68 |
53 class ContactList(QuickContactList, cagou_widget.CagouWidget): | 69 class ContactList(QuickContactList, cagou_widget.CagouWidget): |
54 | 70 |
55 def __init__(self, host, target, profiles): | 71 def __init__(self, host, target, profiles): |
56 QuickContactList.__init__(self, G.host, profiles) | 72 QuickContactList.__init__(self, G.host, profiles) |