primitivus: keep focus position in contacts list on redraw
This commit is contained in:
parent
920fe825cd
commit
97420f39d5
1 changed files with 15 additions and 14 deletions
|
|
@ -45,11 +45,18 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
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 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
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 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
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 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
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 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
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 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
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"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue