primitivus: chat state implementation

for now chat states are displayed in primitivus surrended text (after the contact's name)
This commit is contained in:
souliane 2013-09-08 19:13:02 +02:00
commit 41375e7bde

View file

@ -145,7 +145,22 @@ class Chat(urwid.WidgetWrap, QuickChat):
self.__appendPresentPanel()
def __getDecoration(self, widget):
return sat_widgets.LabelLine(widget, sat_widgets.SurroundedText(unicode(unescapePrivate(self.target))))
return sat_widgets.LabelLine(widget, self.__getSurrendedText())
def __getSurrendedText(self):
"""Get the text to be displayed as the dialog title."""
if not hasattr(self, "surrended_text"):
self.__setSurrendedText()
return self.surrended_text
def __setSurrendedText(self, state=None):
"""Set the text to be displayed as the dialog title
@param stat: chat state of the contact
"""
text = unicode(unescapePrivate(self.target))
if state:
text += " (" + state + ")"
self.surrended_text = sat_widgets.SurroundedText(text)
def showDecoration(self, show=True):
"""Show/Hide the decoration around the chat window"""
@ -155,6 +170,18 @@ class Chat(urwid.WidgetWrap, QuickChat):
main_widget = self.pile
self._w = main_widget
def updateChatState(self, state):
"""Update the chat state of the contact.
@param state: new state to set
"""
if (self.type == 'one2one'):
self.__setSurrendedText(state)
self.showDecoration()
self.host.redraw()
elif (self.type == 'group'):
# TODO: chat state for groupchat
pass
def _presentClicked(self, list_wid, clicked_wid):
assert(self.type == 'group')
nick = clicked_wid.getValue()