comparison frontends/src/primitivus/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 3f0d22565684
children 19b9d3f8a6c7
comparison
equal deleted inserted replaced
1992:d5befe7253aa 1993:981e2abbb56c
63 return self.mess_data.parent 63 return self.mess_data.parent
64 64
65 @property 65 @property
66 def message(self): 66 def message(self):
67 """Return currently displayed message""" 67 """Return currently displayed message"""
68 message = self.mess_data.message 68 return self.mess_data.main_message
69 if self.parent.lang in message:
70 self.selected_lang = self.parent.lang
71 return message[self.parent.lang]
72 try:
73 self.selected_lang = ''
74 return message['']
75 except KeyError:
76 try:
77 lang, mess = message.iteritems().next()
78 self.selected_lang = lang
79 return mess
80 except StopIteration:
81 log.error(u"Can't find message for uid {}".format(self.mess_data.uid))
82 69
83 @message.setter 70 @message.setter
84 def message(self, value): 71 def message(self, value):
85 self.mess_data.message = {'':value} 72 self.mess_data.message = {'':value}
86 self.redraw() 73 self.redraw()
137 else: 124 else:
138 markup.append(('my_nick' if d.own_mess else 'other_nick', u"[{}] ".format(d.nick or ''))) 125 markup.append(('my_nick' if d.own_mess else 'other_nick', u"[{}] ".format(d.nick or '')))
139 126
140 msg = self.message # needed to generate self.selected_lang 127 msg = self.message # needed to generate self.selected_lang
141 128
142 if self.selected_lang: 129 if d.selected_lang:
143 markup.append(("msg_lang", u"[{}] ".format(self.selected_lang))) 130 markup.append(("msg_lang", u"[{}] ".format(d.selected_lang)))
144 131
145 # message body 132 # message body
146 markup.append(msg) 133 markup.append(msg)
147 134
148 return markup 135 return markup