From 1d2380b6d7bcead972efc9412c50c5df4f6a85fa Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 3 Feb 2005 22:21:55 +0000 Subject: [PATCH] more user friendly Add contact window --- plugins/gtkgui/dialogs.py | 61 ++++++++++++ plugins/gtkgui/gtkgui.glade | 187 +++++++++++++++++++++++++++--------- 2 files changed, 202 insertions(+), 46 deletions(-) diff --git a/plugins/gtkgui/dialogs.py b/plugins/gtkgui/dialogs.py index f27c49d6d..97a4c010c 100644 --- a/plugins/gtkgui/dialogs.py +++ b/plugins/gtkgui/dialogs.py @@ -374,16 +374,77 @@ class addContact_Window: self.plugin.roster.req_sub(self, who, txt, self.account) widget.get_toplevel().destroy() + def fill_who(self): + cb = self.xml.get_widget('combobox_agent') + model = cb.get_model() + index = cb.get_active() + str = self.xml.get_widget('entry_login').get_text() + str = str.replace("@", "%") + agent = model[index][1] + if agent: + str += "@" + agent + self.xml.get_widget('entry_who').set_text(str) + + def on_cb_changed(self, widget): + self.fill_who() + + def guess_agent(self): + login = self.xml.get_widget('entry_login').get_text() + cb = self.xml.get_widget('combobox_agent') + model = cb.get_model() + + #If login contains only numbers, it's probably an ICQ number + try: + string.atoi(login) + except: + pass + else: + if 'ICQ' in self.agents: + cb.set_active(self.agents.index('ICQ')) + return + cb.set_active(0) + + def on_entry_login_changed(self, widget): + self.guess_agent() #It changes the cb so automatically call fill_who() + def __init__(self, plugin, account, jid=None): self.plugin = plugin self.account = account self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Add', APP) self.window = self.xml.get_widget('Add') + liststore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) + liststore.append(['Jabber', '']) + self.agents = ['Jabber'] + jid_agents = [] + for j in self.plugin.roster.contacts[account]: + user = self.plugin.roster.contacts[account][j][0] + if 'Agents' in user.groups: + jid_agents.append(j) + for a in jid_agents: + if a.find("aim") > -1: + name = "AIM" + elif a.find("icq") > -1: + name = "ICQ" + elif a.find("msn") > -1: + name = "MSN" + elif a.find("yahoo") > -1: + name = "Yahoo!" + else: + name = a + iter = liststore.append([name, a]) + self.agents.append(name) + cb = self.xml.get_widget('combobox_agent') + cb.set_model(liststore) + cb.set_active(0) + self.fill_who() if jid: self.xml.get_widget('entry_who').set_text(jid) self.xml.signal_connect('gtk_widget_destroy', self.delete_event) self.xml.signal_connect('on_button_sub_clicked', self.on_subscribe) self.xml.signal_connect('on_cancel_clicked', self.on_cancel) + self.xml.signal_connect('on_cb_changed', self.on_cb_changed) + self.xml.signal_connect('on_entry_login_changed', \ + self.on_entry_login_changed) class warning_Window: """Class for warning window : print a warning message""" diff --git a/plugins/gtkgui/gtkgui.glade b/plugins/gtkgui/gtkgui.glade index e6c2df3cb..3f02826bd 100644 --- a/plugins/gtkgui/gtkgui.glade +++ b/plugins/gtkgui/gtkgui.glade @@ -2170,53 +2170,16 @@ on the server. 0 - + True + 3 + 3 False - 0 + 5 + 5 - - True - gtk-redo - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - True - True - - - - - - 145 - 8 - True - Send subscription to : - False - False - GTK_JUSTIFY_RIGHT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - True - - - - - + True True True @@ -2226,11 +2189,143 @@ on the server. True * False + - 0 - True - True + 2 + 3 + 0 + 1 + + + + + + + True + True + False + True + 0 + + True + * + False + + + 2 + 3 + 2 + 3 + + + + + + + True + gtk-add + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 3 + fill + fill + + + + + + True + Login : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + Agent : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 1 + 2 + fill + + + + + + + True + Jabber ID : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + + + + + 2 + 3 + 1 + 2 + fill + fill