primitivus: contact list enhancement
- primitivus: contact list now display groups and sexy name (instead of bare jid) - primitivus: contact list now show an alert when somebody want to contact you, and its chat window is not on the screen - primitivus: cursor is now visible when going to chat window (useful to go back in logs)
This commit is contained in:
parent
61f6edae54
commit
5f3463b147
1 changed files with 180 additions and 50 deletions
|
|
@ -95,13 +95,31 @@ class SelectableText(urwid.FlowWidget):
|
|||
"""Text which can be selected with space"""
|
||||
signals = ['change']
|
||||
|
||||
def __init__(self, text, align='left'):
|
||||
def __init__(self, text, align='left', header='', select_attr=None, default_attr=None, selected = False, data=None):
|
||||
self.text=unicode(text)
|
||||
self.header=header
|
||||
if data:
|
||||
self.data=data
|
||||
if select_attr:
|
||||
self.selected = select_attr
|
||||
if default_attr:
|
||||
self.default = default_attr
|
||||
self.align = align
|
||||
self.__selected=False
|
||||
self.__selected=selected
|
||||
|
||||
def getValue(self):
|
||||
return self.text
|
||||
|
||||
def setAttribute(self, name, value):
|
||||
"""Change attribut used for rendering widget
|
||||
@param name: one of
|
||||
-default: when not selected
|
||||
-selected: when selected
|
||||
@param value: name of the attribute
|
||||
/!\ the attribute name followed by _focus is used when widget has focus"""
|
||||
assert name in ['default', 'selected']
|
||||
self.__setattr__(name,value)
|
||||
self._invalidate()
|
||||
|
||||
def setState(self, selected, invisible=False):
|
||||
"""Change state
|
||||
|
|
@ -132,15 +150,24 @@ class SelectableText(urwid.FlowWidget):
|
|||
return self.display_widget(size, focus).render(size, focus)
|
||||
|
||||
def display_widget(self, size, focus):
|
||||
attr = 'selected' if self.__selected else 'default'
|
||||
try:
|
||||
select_attr = self.selected
|
||||
except AttributeError:
|
||||
select_attr = 'selected'
|
||||
try:
|
||||
default_attr = self.default
|
||||
except AttributeError:
|
||||
default_attr = 'default'
|
||||
attr = select_attr if self.__selected else default_attr
|
||||
if focus:
|
||||
attr+="_focus"
|
||||
return urwid.Text((attr,self.text), align=self.align)
|
||||
return urwid.Text((attr,self.header+self.text), align=self.align)
|
||||
|
||||
class UnselectableText(SelectableText):
|
||||
class ClickableText(SelectableText):
|
||||
signals = SelectableText.signals + ['click']
|
||||
|
||||
def setState(self, selected, invisible=False):
|
||||
pass
|
||||
self._emit('click')
|
||||
|
||||
class GenericList(urwid.WidgetWrap):
|
||||
signals = ['click','change']
|
||||
|
|
|
|||
Loading…
Reference in a new issue