Mercurial > libervia-backend
changeset 500:00d3679976ab
primitivus: keep focus position in contacts list on redraw
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 05 Sep 2012 00:19:32 +0200 |
parents | 28f4ce741ae5 |
children | e9634d2e7b38 |
files | frontends/src/primitivus/contact_list.py |
diffstat | 1 files changed, 15 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/src/primitivus/contact_list.py Tue Sep 04 13:36:14 2012 +0200 +++ b/frontends/src/primitivus/contact_list.py Wed Sep 05 00:19:32 2012 +0200 @@ -45,11 +45,18 @@ urwid.connect_signal(self, 'change', on_change, user_data) QuickContactList.__init__(self, CM) + def _update(self): + """Update display, keep focus""" + widget, position = self.frame.body.get_focus() + self.frame.body = self.__buildList() + if position: + self.frame.body.set_focus(position) + self.host.redraw() + def keypress(self, size, key): if key == "meta s": #user wants to (un)hide contacts' statuses self.show_status = not self.show_status - self.frame.body = self.__buildList() - self.host.redraw() + self._update() return super(ContactList, self).keypress(size, key) def __contains__(self, jid): @@ -70,14 +77,12 @@ def putAlert(self, jid): """Put an alert on the jid to get attention from user (e.g. for new message)""" self.alert_jid.add(jid.short) - self.frame.body = self.__buildList() - self.host.redraw() + self._update() def __groupClicked(self, group_wid): group = self.groups[group_wid.getValue()] group[0] = not group[0] - self.frame.body = self.__buildList() - self.host.redraw() + self._update() self.setFocus(group_wid.getValue()) def __contactClicked(self, contact_wid, selected): @@ -87,8 +92,7 @@ widget.setState(widget.data == self.selected, invisible=True) if self.selected in self.alert_jid: self.alert_jid.remove(self.selected) - self.frame.body = self.__buildList() - self.host.redraw() + self._update() self._emit('click') def __buildContact(self, content, param_contacts): @@ -150,8 +154,7 @@ self.groups={} self.selected = None self.unselectAll() - self.frame.body = self.__buildList() - self.host.redraw() + self._update() def replace(self, jid, groups=[None]): """add a contact to the list if doesn't exist, else update it""" @@ -163,8 +166,7 @@ if not self.groups.has_key(group): self.groups[group] = [True,set()] #[unfold,list_of_contacts] self.groups[group][1].add(jid.short) - self.frame.body = self.__buildList() - self.host.redraw() + self._update() """contacts = self.list_wid.getAllValues() @@ -190,8 +192,7 @@ groups_to_remove.append(group) for group in groups_to_remove: del self.groups[group] - self.frame.body = self.__buildList() - self.host.redraw() + self._update() def add(self, jid, param_groups=[None]): """add a contact to the list"""