comparison frontends/primitivus/contact_list.py @ 124:961e0898271f

primitivus chat window - management of one 2 one / group chat - timestamp displayed - added shortcuts for showing/hiding panels - color used - fixed vcard bug (contact displayed even if not from current profile if vcard changed/not in cache) - added VerticalSeparator widget - *List widgets can now use an other widget than SelectableText - new UnselectableText widget
author Goffi <goffi@goffi.org>
date Thu, 08 Jul 2010 19:47:54 +0800
parents 03d8bcc67182
children 8d611eb9ae48
comparison
equal deleted inserted replaced
123:34766e0cf970 124:961e0898271f
19 along with this program. If not, see <http://www.gnu.org/licenses/>. 19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 """ 20 """
21 21
22 import urwid 22 import urwid
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,LabelLine,SurroundedText 24 import custom_widgets
25 25
26 26
27 class ContactList(urwid.WidgetWrap, QuickContactList): 27 class ContactList(urwid.WidgetWrap, QuickContactList):
28 signals = ['click','change'] 28 signals = ['click','change']
29 29
30 def __init__(self, host, CM, on_click=None, on_change=None, user_data=None): 30 def __init__(self, host, CM, on_click=None, on_change=None, user_data=None):
31 self.host = host 31 self.host = host
32 32
33 self.list_wid = List([], style=['single','no_first_select'], align='left', on_click=self.__contactClicked, on_change=on_change) 33 self.list_wid = custom_widgets.GenericList([], 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 frame_body = self.list_wid
37 frame_body = urwid.ListBox(body_content)
38 frame = urwid.Frame(frame_body) 37 frame = urwid.Frame(frame_body)
39 self.main_widget = LabelLine(frame,SurroundedText(_("Contacts"))) 38 self.main_widget = custom_widgets.LabelLine(frame, custom_widgets.SurroundedText(_("Contacts")))
40 urwid.WidgetWrap.__init__(self, self.main_widget) 39 urwid.WidgetWrap.__init__(self, self.main_widget)
41 if on_click: 40 if on_click:
42 urwid.connect_signal(self, 'click', on_click, user_data) 41 urwid.connect_signal(self, 'click', on_click, user_data)
43 if on_change: 42 if on_change:
44 urwid.connect_signal(self, 'change', on_change, user_data) 43 urwid.connect_signal(self, 'change', on_change, user_data)
45 QuickContactList.__init__(self, CM) 44 QuickContactList.__init__(self, CM)
45
46 def __contains__(self, jid):
47 contacts = self.list_wid.getAllValues()
48 return jid.short in contacts
46 49
47 def __contactClicked(self, list_wid): 50 def __contactClicked(self, list_wid):
48 self._emit('click') 51 self._emit('click')
49 52
50 def get_contact(self): 53 def get_contact(self):
64 self.list_wid.changeValues(contacts) 67 self.list_wid.changeValues(contacts)
65 self._emit('change') 68 self._emit('change')
66 69
67 def disconnect(self, jid): 70 def disconnect(self, jid):
68 """mark a contact disconnected""" 71 """mark a contact disconnected"""
69 #self.host.debug()
70 self.remove(jid) 72 self.remove(jid)
71 73
72 def remove(self, jid): 74 def remove(self, jid):
73 """remove a contact from the list""" 75 """remove a contact from the list"""
74 self.list_wid.deleteValue(jid.short) 76 self.list_wid.deleteValue(jid.short)