Mercurial > libervia-backend
changeset 1993:981e2abbb56c
quick_frontend, primitivus: moved main_message property to quick_frontend
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 10 Jul 2016 12:26:13 +0200 |
parents | d5befe7253aa |
children | a5eb6f6b8db2 |
files | frontends/src/primitivus/chat.py frontends/src/quick_frontend/quick_chat.py |
diffstat | 2 files changed, 20 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/src/primitivus/chat.py Sat Jul 02 20:55:31 2016 +0200 +++ b/frontends/src/primitivus/chat.py Sun Jul 10 12:26:13 2016 +0200 @@ -65,20 +65,7 @@ @property def message(self): """Return currently displayed message""" - message = self.mess_data.message - if self.parent.lang in message: - self.selected_lang = self.parent.lang - return message[self.parent.lang] - try: - self.selected_lang = '' - return message[''] - except KeyError: - try: - lang, mess = message.iteritems().next() - self.selected_lang = lang - return mess - except StopIteration: - log.error(u"Can't find message for uid {}".format(self.mess_data.uid)) + return self.mess_data.main_message @message.setter def message(self, value): @@ -139,8 +126,8 @@ msg = self.message # needed to generate self.selected_lang - if self.selected_lang: - markup.append(("msg_lang", u"[{}] ".format(self.selected_lang))) + if d.selected_lang: + markup.append(("msg_lang", u"[{}] ".format(d.selected_lang))) # message body markup.append(msg)
--- a/frontends/src/quick_frontend/quick_chat.py Sat Jul 02 20:55:31 2016 +0200 +++ b/frontends/src/quick_frontend/quick_chat.py Sun Jul 10 12:26:13 2016 +0200 @@ -80,6 +80,23 @@ except AttributeError: return False + @property + def main_message(self): + """Return currently displayed message""" + if self.parent.lang in self.message: + self.selected_lang = self.parent.lang + return self.message[self.parent.lang] + try: + self.selected_lang = '' + return self.message[''] + except KeyError: + try: + lang, mess = self.message.iteritems().next() + self.selected_lang = lang + return mess + except StopIteration: + log.error(u"Can't find message for uid {}".format(self.mess_data.uid)) + def getNick(self, entity): """Return nick of an entity when possible""" contact_list = self.host.contact_lists[self.profile]