diff 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
line wrap: on
line diff
--- a/frontends/src/primitivus/chat.py	Thu Oct 11 00:48:35 2012 +0200
+++ b/frontends/src/primitivus/chat.py	Tue Oct 16 01:22:40 2012 +0200
@@ -24,7 +24,7 @@
 from urwid_satext.files_management import FileDialog
 from sat_frontends.quick_frontend.quick_chat import QuickChat
 from sat_frontends.primitivus.card_game import CardGame
-from sat_frontends.quick_frontend.quick_utils import unescapePrivate
+from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate
 import time
 from sat.tools.jid  import JID
 
@@ -155,9 +155,23 @@
             main_widget = self.pile
         self._w = main_widget
 
+    def _presentClicked(self, list_wid, clicked_wid):
+        assert(self.type == 'group')
+        nick = clicked_wid.getValue()
+        if nick == self.getUserNick():
+            #We ignore click on our own nick
+            return
+        #we have a click on a nick, we add the private conversation to the contact_list
+        full_jid = JID("%s/%s" % (self.target.short, nick))
+        new_jid = escapePrivate(full_jid)
+        if new_jid not in self.host.contact_list:
+            self.host.contact_list.add(new_jid)
+
+        #now we select the new window
+        self.host.contact_list.setFocus(full_jid, True)
 
     def __buildPresentList(self):
-        self.present_wid = sat_widgets.GenericList([],option_type = sat_widgets.ClickableText)
+        self.present_wid = sat_widgets.GenericList([],option_type = sat_widgets.ClickableText, on_click=self._presentClicked)
         return self.present_wid
    
     def __appendPresentPanel(self):