Mercurial > libervia-backend
comparison frontends/src/primitivus/chat.py @ 637:3b02554d4c8b
primitivus: chat state implementation
for now chat states are displayed in primitivus surrended text (after the contact's name)
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 08 Sep 2013 19:13:02 +0200 |
parents | c8c07c920e30 |
children | 6821fc06a324 |
comparison
equal
deleted
inserted
replaced
636:7ea6d5a86e58 | 637:3b02554d4c8b |
---|---|
143 present_widget = self.__buildPresentList() | 143 present_widget = self.__buildPresentList() |
144 self.present_panel = sat_widgets.VerticalSeparator(present_widget) | 144 self.present_panel = sat_widgets.VerticalSeparator(present_widget) |
145 self.__appendPresentPanel() | 145 self.__appendPresentPanel() |
146 | 146 |
147 def __getDecoration(self, widget): | 147 def __getDecoration(self, widget): |
148 return sat_widgets.LabelLine(widget, sat_widgets.SurroundedText(unicode(unescapePrivate(self.target)))) | 148 return sat_widgets.LabelLine(widget, self.__getSurrendedText()) |
149 | |
150 def __getSurrendedText(self): | |
151 """Get the text to be displayed as the dialog title.""" | |
152 if not hasattr(self, "surrended_text"): | |
153 self.__setSurrendedText() | |
154 return self.surrended_text | |
155 | |
156 def __setSurrendedText(self, state=None): | |
157 """Set the text to be displayed as the dialog title | |
158 @param stat: chat state of the contact | |
159 """ | |
160 text = unicode(unescapePrivate(self.target)) | |
161 if state: | |
162 text += " (" + state + ")" | |
163 self.surrended_text = sat_widgets.SurroundedText(text) | |
149 | 164 |
150 def showDecoration(self, show=True): | 165 def showDecoration(self, show=True): |
151 """Show/Hide the decoration around the chat window""" | 166 """Show/Hide the decoration around the chat window""" |
152 if show: | 167 if show: |
153 main_widget = self.__getDecoration(self.pile) | 168 main_widget = self.__getDecoration(self.pile) |
154 else: | 169 else: |
155 main_widget = self.pile | 170 main_widget = self.pile |
156 self._w = main_widget | 171 self._w = main_widget |
172 | |
173 def updateChatState(self, state): | |
174 """Update the chat state of the contact. | |
175 @param state: new state to set | |
176 """ | |
177 if (self.type == 'one2one'): | |
178 self.__setSurrendedText(state) | |
179 self.showDecoration() | |
180 self.host.redraw() | |
181 elif (self.type == 'group'): | |
182 # TODO: chat state for groupchat | |
183 pass | |
157 | 184 |
158 def _presentClicked(self, list_wid, clicked_wid): | 185 def _presentClicked(self, list_wid, clicked_wid): |
159 assert(self.type == 'group') | 186 assert(self.type == 'group') |
160 nick = clicked_wid.getValue() | 187 nick = clicked_wid.getValue() |
161 if nick == self.getUserNick(): | 188 if nick == self.getUserNick(): |