Mercurial > libervia-backend
comparison frontends/src/primitivus/contact_list.py @ 1183:f36d7068a44b
Primitivus: fixed focus in ContactList:
current behavious is temporary and will need to be rethinked a bit: if FOCUS_SWITCH is pressed, the focus change on top widget, if FOCUS_UP/DOWN is pressed, focus will throught contact list.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 08 Sep 2014 18:14:51 +0200 |
parents | c0f15e52695a |
children | 03661d1b216a |
comparison
equal
deleted
inserted
replaced
1182:4be53c14845e | 1183:f36d7068a44b |
---|---|
24 from sat_frontends.quick_frontend.quick_utils import unescapePrivate | 24 from sat_frontends.quick_frontend.quick_utils import unescapePrivate |
25 from sat_frontends.tools.jid import JID | 25 from sat_frontends.tools.jid import JID |
26 from sat_frontends.primitivus.status import StatusBar | 26 from sat_frontends.primitivus.status import StatusBar |
27 from sat_frontends.primitivus.constants import Const | 27 from sat_frontends.primitivus.constants import Const |
28 from sat_frontends.primitivus.keys import action_key_map as a_key | 28 from sat_frontends.primitivus.keys import action_key_map as a_key |
29 from sat.core import log as logging | |
30 log = logging.getLogger(__name__) | |
29 | 31 |
30 | 32 |
31 class ContactList(urwid.WidgetWrap, QuickContactList): | 33 class ContactList(urwid.WidgetWrap, QuickContactList): |
32 signals = ['click','change'] | 34 signals = ['click','change'] |
33 | 35 |
40 self.show_status = False | 42 self.show_status = False |
41 self.show_disconnected = False | 43 self.show_disconnected = False |
42 | 44 |
43 #we now build the widget | 45 #we now build the widget |
44 self.host.status_bar = StatusBar(host) | 46 self.host.status_bar = StatusBar(host) |
45 self.frame = urwid.Frame(self.__buildList(), None, self.host.status_bar) | 47 self.frame = sat_widgets.FocusFrame(self.__buildList(), None, self.host.status_bar) |
46 self.main_widget = sat_widgets.LabelLine(self.frame, sat_widgets.SurroundedText(_("Contacts"))) | 48 self.main_widget = sat_widgets.LabelLine(self.frame, sat_widgets.SurroundedText(_("Contacts"))) |
47 urwid.WidgetWrap.__init__(self, self.main_widget) | 49 urwid.WidgetWrap.__init__(self, self.main_widget) |
48 if on_click: | 50 if on_click: |
49 urwid.connect_signal(self, 'click', on_click, user_data) | 51 urwid.connect_signal(self, 'click', on_click, user_data) |
50 if on_change: | 52 if on_change: |
63 | 65 |
64 def update_jid(self, jid): | 66 def update_jid(self, jid): |
65 self.update() | 67 self.update() |
66 | 68 |
67 def keypress(self, size, key): | 69 def keypress(self, size, key): |
70 # FIXME: we have a temporary behaviour here: FOCUS_SWITCH change focus globally in the parent, | |
71 # and FOCUS_UP/DOWN is transwmitter to parent if we are respectively on the first or last element | |
72 if key in sat_widgets.FOCUS_KEYS: | |
73 if (key == a_key['FOCUS_SWITCH'] or (key == a_key['FOCUS_UP'] and self.frame.focus_position == 'body') or | |
74 (key == a_key['FOCUS_DOWN'] and self.frame.focus_position == 'footer')): | |
75 return key | |
68 if key == a_key['STATUS_HIDE']: #user wants to (un)hide contacts' statuses | 76 if key == a_key['STATUS_HIDE']: #user wants to (un)hide contacts' statuses |
69 self.show_status = not self.show_status | 77 self.show_status = not self.show_status |
70 self.update() | 78 self.update() |
71 elif key == a_key['DISCONNECTED_HIDE']: #user wants to (un)hide disconnected contacts | 79 elif key == a_key['DISCONNECTED_HIDE']: #user wants to (un)hide disconnected contacts |
72 self.show_disconnected = not self.show_disconnected | 80 self.show_disconnected = not self.show_disconnected |