Mercurial > libervia-backend
comparison frontends/primitivus/contact_list.py @ 119:ded2431cea5a
Primitivus: chat window / text sending.
Primitivus has now the most basics features \o/
- core: new getVersion method
- primitivus: new debug key (C-d), only work if SàT is in dev version (D in version)
- quick_app: new post_init method, used for automatique task like auto-plug
- primitivus: lists now use genericList (Box) or List (Flow)
- primitivus: List now manage correctly its size
- primitivus: new FocusFrame widget which manage focus changing with 'tab'
- primitivus: advancedEdit now manage 'click' signal
- primitivus: contactList now manager 'change' and 'click' signals
- primitivus: Chat window now working
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 05 Jul 2010 19:13:36 +0800 |
parents | 7c482ecac0ff |
children | 1ca5f254ce41 |
comparison
equal
deleted
inserted
replaced
118:76055a209ed9 | 119:ded2431cea5a |
---|---|
23 from quick_frontend.quick_contact_list import QuickContactList | 23 from quick_frontend.quick_contact_list import QuickContactList |
24 from custom_widgets import Password,List,InputDialog,ConfirmDialog,Alert | 24 from custom_widgets import Password,List,InputDialog,ConfirmDialog,Alert |
25 | 25 |
26 | 26 |
27 class ContactList(urwid.WidgetWrap, QuickContactList): | 27 class ContactList(urwid.WidgetWrap, QuickContactList): |
28 signals = ['click','change'] | |
28 | 29 |
29 def __init__(self, host, CM): | 30 def __init__(self, host, CM, on_click=None, on_change=None, user_data=None): |
30 QuickContactList.__init__(self, CM) | |
31 self.host = host | 31 self.host = host |
32 | 32 |
33 self.list_wid = List([], style=['single'], align='left') | 33 self.list_wid = List([], style=['single','no_first_select'], align='left', on_click=self.__contactClicked, on_change=on_change) |
34 | 34 |
35 #we now build the widget | 35 #we now build the widget |
36 body_content = urwid.SimpleListWalker([self.list_wid]) | 36 body_content = urwid.SimpleListWalker([self.list_wid]) |
37 frame_body = urwid.ListBox(body_content) | 37 frame_body = urwid.ListBox(body_content) |
38 frame = urwid.Frame(frame_body,urwid.AttrMap(urwid.Text(_("Contacts"),align='center'),'title')) | 38 frame = urwid.Frame(frame_body,urwid.AttrMap(urwid.Text(_("Contacts"),align='center'),'title')) |
39 self.main_widget = urwid.LineBox(frame) | 39 self.main_widget = urwid.LineBox(frame) |
40 urwid.WidgetWrap.__init__(self, self.main_widget) | 40 urwid.WidgetWrap.__init__(self, self.main_widget) |
41 if on_click: | |
42 urwid.connect_signal(self, 'click', on_click, user_data) | |
43 if on_change: | |
44 urwid.connect_signal(self, 'change', on_change, user_data) | |
45 QuickContactList.__init__(self, CM) | |
46 | |
47 def __contactClicked(self, list_wid): | |
48 self._emit('click') | |
49 | |
50 def get_contact(self): | |
51 """Return contact currently selected""" | |
52 return self.list_wid.getSelectedValue() | |
41 | 53 |
42 def clear_contacts(self): | 54 def clear_contacts(self): |
43 """clear all the contact list""" | 55 """clear all the contact list""" |
44 self.list_wid.changeValues([]) | 56 self.list_wid.changeValues([]) |
45 | 57 |
46 def replace(self, jid, groups=None): | 58 def replace(self, jid, groups=None): |
47 """add a contact to the list if doesn't exist, else update it""" | 59 """add a contact to the list if doesn't exist, else update it""" |
48 contacts = self.list_wid.getValues() | 60 contacts = self.list_wid.getAllValues() |
49 if jid.short not in contacts: | 61 if jid.short not in contacts: |
50 contacts.append(jid.short) | 62 contacts.append(jid.short) |
51 contacts.sort() | 63 contacts.sort() |
52 self.list_wid.changeValues(contacts) | 64 self.list_wid.changeValues(contacts) |
65 self._emit('change') | |
53 | 66 |
54 def disconnect(self, jid): | 67 def disconnect(self, jid): |
55 """mark a contact disconnected""" | 68 """mark a contact disconnected""" |
69 #self.host.debug() | |
56 self.remove(jid) | 70 self.remove(jid) |
57 | 71 |
58 def remove(self, jid): | 72 def remove(self, jid): |
59 """remove a contact from the list""" | 73 """remove a contact from the list""" |
60 self.list_wid.deleteValue(jid.short) | 74 self.list_wid.deleteValue(jid.short) |