From ab8bc3cdddb132ebdd09f3981016cfbedf046ac4 Mon Sep 17 00:00:00 2001 From: Goffi Date: Mon, 8 Sep 2014 18:14:51 +0200 Subject: [PATCH] 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. --- frontends/src/primitivus/contact_list.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontends/src/primitivus/contact_list.py b/frontends/src/primitivus/contact_list.py index b3d078f1..0845cbfd 100644 --- a/frontends/src/primitivus/contact_list.py +++ b/frontends/src/primitivus/contact_list.py @@ -26,6 +26,8 @@ from sat_frontends.tools.jid import JID from sat_frontends.primitivus.status import StatusBar from sat_frontends.primitivus.constants import Const from sat_frontends.primitivus.keys import action_key_map as a_key +from sat.core import log as logging +log = logging.getLogger(__name__) class ContactList(urwid.WidgetWrap, QuickContactList): @@ -42,7 +44,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList): #we now build the widget self.host.status_bar = StatusBar(host) - self.frame = urwid.Frame(self.__buildList(), None, self.host.status_bar) + self.frame = sat_widgets.FocusFrame(self.__buildList(), None, self.host.status_bar) self.main_widget = sat_widgets.LabelLine(self.frame, sat_widgets.SurroundedText(_("Contacts"))) urwid.WidgetWrap.__init__(self, self.main_widget) if on_click: @@ -65,6 +67,12 @@ class ContactList(urwid.WidgetWrap, QuickContactList): self.update() def keypress(self, size, key): + # FIXME: we have a temporary behaviour here: FOCUS_SWITCH change focus globally in the parent, + # and FOCUS_UP/DOWN is transwmitter to parent if we are respectively on the first or last element + if key in sat_widgets.FOCUS_KEYS: + if (key == a_key['FOCUS_SWITCH'] or (key == a_key['FOCUS_UP'] and self.frame.focus_position == 'body') or + (key == a_key['FOCUS_DOWN'] and self.frame.focus_position == 'footer')): + return key if key == a_key['STATUS_HIDE']: #user wants to (un)hide contacts' statuses self.show_status = not self.show_status self.update()