# HG changeset patch # User Goffi # Date 1350343360 -7200 # Node ID 62f7f24030939a96ae0fe8d9bc2cf3c5fcd6a5b4 # Parent 886754295efe70eac8e480b55c6fe5faf2898e9f 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 /!\ diff -r 886754295efe -r 62f7f2403093 frontends/src/primitivus/chat.py --- 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): diff -r 886754295efe -r 62f7f2403093 frontends/src/primitivus/contact_list.py --- a/frontends/src/primitivus/contact_list.py Thu Oct 11 00:48:35 2012 +0200 +++ b/frontends/src/primitivus/contact_list.py Tue Oct 16 01:22:40 2012 +0200 @@ -73,13 +73,17 @@ return True return False - def setFocus(self, name): - """give focus to the first group or contact with the given name""" + def setFocus(self, name, select=False): + """give focus to the first group or contact wich contain the given name + @param name: name to check + @param select: if True, the contact/group is also clicked""" idx = 0 for widget in self.frame.body.body: try: - if widget.getValue() == name: + if name in widget.getValue(): self.frame.body.set_focus(idx) + if select: + self.__contactClicked(widget, True) return except AttributeError: pass diff -r 886754295efe -r 62f7f2403093 frontends/src/primitivus/profile_manager.py --- a/frontends/src/primitivus/profile_manager.py Thu Oct 11 00:48:35 2012 +0200 +++ b/frontends/src/primitivus/profile_manager.py Tue Oct 16 01:22:40 2012 +0200 @@ -36,7 +36,7 @@ self.login_wid = AdvancedEdit(_('Login:'),align='center') self.pass_wid = Password(_('Password:'),align='center') - self.list_profile = List(profiles, style=['single'], align='center', on_click=self.onProfileChange) + self.list_profile = List(profiles, style=['single'], align='center', on_change=self.onProfileChange) #new & delete buttons buttons = [urwid.Button(_("New"), self.onNewProfile),