Mercurial > libervia-backend
changeset 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 | 862c0d6ab974 |
files | frontends/src/primitivus/chat.py frontends/src/primitivus/contact_list.py frontends/src/primitivus/profile_manager.py |
diffstat | 3 files changed, 24 insertions(+), 6 deletions(-) [+] |
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):
--- 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
--- 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),