Mercurial > libervia-backend
comparison frontends/src/primitivus/chat.py @ 511:62f7f2403093
Primitivus: present contacts in groups chat can now be clicked
- updated GenericList/List signals to manage change/click fix in urwid-satext
- a click on a nick in a group chat create a private conversation with her, and select this conversation
/!\ history in backend doesn't manage correctly yet the private conversations /!\
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 16 Oct 2012 01:22:40 +0200 |
parents | 886754295efe |
children | fe79a724e6fa |
comparison
equal
deleted
inserted
replaced
510:886754295efe | 511:62f7f2403093 |
---|---|
22 import urwid | 22 import urwid |
23 from urwid_satext import sat_widgets | 23 from urwid_satext import sat_widgets |
24 from urwid_satext.files_management import FileDialog | 24 from urwid_satext.files_management import FileDialog |
25 from sat_frontends.quick_frontend.quick_chat import QuickChat | 25 from sat_frontends.quick_frontend.quick_chat import QuickChat |
26 from sat_frontends.primitivus.card_game import CardGame | 26 from sat_frontends.primitivus.card_game import CardGame |
27 from sat_frontends.quick_frontend.quick_utils import unescapePrivate | 27 from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate |
28 import time | 28 import time |
29 from sat.tools.jid import JID | 29 from sat.tools.jid import JID |
30 | 30 |
31 | 31 |
32 class ChatText(urwid.FlowWidget): | 32 class ChatText(urwid.FlowWidget): |
153 main_widget = self.__getDecoration(self.pile) | 153 main_widget = self.__getDecoration(self.pile) |
154 else: | 154 else: |
155 main_widget = self.pile | 155 main_widget = self.pile |
156 self._w = main_widget | 156 self._w = main_widget |
157 | 157 |
158 def _presentClicked(self, list_wid, clicked_wid): | |
159 assert(self.type == 'group') | |
160 nick = clicked_wid.getValue() | |
161 if nick == self.getUserNick(): | |
162 #We ignore click on our own nick | |
163 return | |
164 #we have a click on a nick, we add the private conversation to the contact_list | |
165 full_jid = JID("%s/%s" % (self.target.short, nick)) | |
166 new_jid = escapePrivate(full_jid) | |
167 if new_jid not in self.host.contact_list: | |
168 self.host.contact_list.add(new_jid) | |
169 | |
170 #now we select the new window | |
171 self.host.contact_list.setFocus(full_jid, True) | |
158 | 172 |
159 def __buildPresentList(self): | 173 def __buildPresentList(self): |
160 self.present_wid = sat_widgets.GenericList([],option_type = sat_widgets.ClickableText) | 174 self.present_wid = sat_widgets.GenericList([],option_type = sat_widgets.ClickableText, on_click=self._presentClicked) |
161 return self.present_wid | 175 return self.present_wid |
162 | 176 |
163 def __appendPresentPanel(self): | 177 def __appendPresentPanel(self): |
164 self.chat_colums.widget_list.append(self.present_panel) | 178 self.chat_colums.widget_list.append(self.present_panel) |
165 self.chat_colums.column_types.append(('weight', 2)) | 179 self.chat_colums.column_types.append(('weight', 2)) |