Mercurial > libervia-backend
changeset 1979:70e83ca721c8
primitivus (chat): fixed timestamp/nick (un)hiding + new redraw and printMessages methods
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 28 Jun 2016 18:29:56 +0200 |
parents | 8156f2116dc9 |
children | 2a85c818751a |
files | frontends/src/primitivus/chat.py |
diffstat | 1 files changed, 26 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/src/primitivus/chat.py Tue Jun 28 18:27:02 2016 +0200 +++ b/frontends/src/primitivus/chat.py Tue Jun 28 18:29:56 2016 +0200 @@ -81,7 +81,7 @@ @message.setter def message(self, value): self.mess_data.message = {'':value} - self._w.set_text(self.markup) + self.redraw() @property def type(self): @@ -90,6 +90,9 @@ except AttributeError: return C.MESS_TYPE_INFO + def redraw(self): + self._w.set_text(self.markup) + def selectable(self): return True @@ -241,12 +244,10 @@ self._appendOccupantsPanel() elif key == a_key['TIMESTAMP_HIDE']: # user wants to (un)hide timestamp self.show_timestamp = not self.show_timestamp - for wid in self.mess_walker: - wid._invalidate() + self.redraw() elif key == a_key['SHORT_NICKNAME']: # user wants to (not) use short nick self.show_short_nick = not self.show_short_nick - for wid in self.mess_walker: - wid._invalidate() + self.redraw() elif key == a_key['SUBJECT_SWITCH']: # user wants to (un)hide group's subject or change its apperance if self.subject: self.show_title = (self.show_title + 1) % 3 @@ -313,9 +314,7 @@ lang = args[0][5:].strip() self.filters.append(lambda mess_data: lang in mess_data.message) - del self.mess_walker[:] - for message in self.messages.itervalues(): - self.appendMessage(message) + self.printMessages() def presenceListener(self, entity, show, priority, statuses, profile): """Update entity's presence status @@ -476,6 +475,24 @@ ## Messages + def printMessages(self, clear=True): + """generate message widgets + + @param clear(bool): clear message before printing if true + """ + if clear: + del self.mess_walker[:] + for message in self.messages.itervalues(): + self.appendMessage(message) + + def redraw(self): + """redraw all messages""" + for w in self.mess_walker: + try: + w.redraw() + except AttributeError: + pass + def updateHistory(self, size=C.HISTORY_LIMIT_DEFAULT, search='', profile='@NONE@'): del self.mess_walker[:] if search: @@ -485,8 +502,7 @@ def _onHistoryPrinted(self): """Refresh or scroll down the focus after the history is printed""" - for message in self.messages.itervalues(): - self.appendMessage(message) + self.printMessages(clear=False) super(Chat, self)._onHistoryPrinted() def onPrivateCreated(self, widget):