Mercurial > libervia-backend
comparison frontends/src/primitivus/contact_list.py @ 736:6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
author | souliane <souliane@mailoo.org> |
---|---|
date | Sat, 23 Nov 2013 10:21:40 +0100 |
parents | f7878ad3c846 |
children | 378af36155c2 |
comparison
equal
deleted
inserted
replaced
735:682933ca304c | 736:6246eb6d64a0 |
---|---|
20 import urwid | 20 import urwid |
21 from urwid_satext import sat_widgets | 21 from urwid_satext import sat_widgets |
22 from sat_frontends.quick_frontend.quick_contact_list import QuickContactList | 22 from sat_frontends.quick_frontend.quick_contact_list import QuickContactList |
23 from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate | 23 from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate |
24 from sat.tools.jid import JID | 24 from sat.tools.jid import JID |
25 | 25 from sat_frontends.primitivus.constants import Const |
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, on_click=None, on_change=None, user_data=None): | 30 def __init__(self, host, on_click=None, on_change=None, user_data=None): |
85 try: | 85 try: |
86 if isinstance(widget, sat_widgets.ClickableText): | 86 if isinstance(widget, sat_widgets.ClickableText): |
87 # contact group | 87 # contact group |
88 value = widget.getValue() | 88 value = widget.getValue() |
89 elif isinstance(widget, sat_widgets.SelectableText): | 89 elif isinstance(widget, sat_widgets.SelectableText): |
90 if widget.data.startswith(const_PRIVATE_PREFIX): | 90 if widget.data.startswith(Const.PRIVATE_PREFIX): |
91 # muc private dialog | 91 # muc private dialog |
92 value = widget.getValue() | 92 value = widget.getValue() |
93 else: | 93 else: |
94 # contact or muc | 94 # contact or muc |
95 value = widget.data | 95 value = widget.data |
135 contacts = list(param_contacts) | 135 contacts = list(param_contacts) |
136 | 136 |
137 widgets = [] #list of built widgets | 137 widgets = [] #list of built widgets |
138 | 138 |
139 for contact in contacts: | 139 for contact in contacts: |
140 if contact.startswith(const_PRIVATE_PREFIX): | 140 if contact.startswith(Const.PRIVATE_PREFIX): |
141 contact_disp = ('alert' if contact in self.alert_jid else "show_normal", unescapePrivate(contact)) | 141 contact_disp = ('alert' if contact in self.alert_jid else "show_normal", unescapePrivate(contact)) |
142 show_icon = '' | 142 show_icon = '' |
143 status = '' | 143 status = '' |
144 else: | 144 else: |
145 jid=JID(contact) | 145 jid=JID(contact) |
150 if show == None: | 150 if show == None: |
151 show = "unavailable" | 151 show = "unavailable" |
152 if (not self.show_disconnected and show == "unavailable" | 152 if (not self.show_disconnected and show == "unavailable" |
153 and not contact in self.alert_jid and contact != self.selected): | 153 and not contact in self.alert_jid and contact != self.selected): |
154 continue | 154 continue |
155 show_icon, show_attr = const_SHOW_ICON.get(show,('','default')) | 155 show_icon, show_attr = Const.PRESENCE.get(show, ('', 'default')) |
156 contact_disp = ('alert' if contact in self.alert_jid else show_attr, nick or name or jid.node or jid.bare) | 156 contact_disp = ('alert' if contact in self.alert_jid else show_attr, nick or name or jid.node or jid.bare) |
157 display = [ show_icon + " " , contact_disp] | 157 display = [ show_icon + " " , contact_disp] |
158 if self.show_status: | 158 if self.show_status: |
159 status_disp = ('status',"\n " + status) if status else "" | 159 status_disp = ('status',"\n " + status) if status else "" |
160 display.append(status_disp) | 160 display.append(status_disp) |