diff frontends/src/quick_frontend/quick_chat.py @ 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 a9908e751c42
children 19b9d3f8a6c7
line wrap: on
line diff
--- 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]