From 7f5ff6fe098de77329bfd051f2a885287b88a731 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 1 Mar 2005 22:52:22 +0000 Subject: [PATCH] merge vcard window into vcard_information_window --- plugins/gtkgui/config.py | 92 +-- plugins/gtkgui/dialogs.py | 130 +++- plugins/gtkgui/gtkgui.glade | 1158 +---------------------------------- 3 files changed, 114 insertions(+), 1266 deletions(-) diff --git a/plugins/gtkgui/config.py b/plugins/gtkgui/config.py index 1b7a81091..663755c46 100644 --- a/plugins/gtkgui/config.py +++ b/plugins/gtkgui/config.py @@ -37,95 +37,6 @@ import gtkgui GTKGUI_GLADE='plugins/gtkgui/gtkgui.glade' -class vCard_Window: - """Class for window that show vCard information""" - def delete_event(self, widget=None): - """close window""" - del self.plugin.windows[self.account]['infos'][self.jid] - - def on_close(self, widget): - """When Close button is clicked""" - widget.get_toplevel().destroy() - - def set_value(self, entry_name, value): - try: - self.xml.get_widget(entry_name).set_text(value) - except AttributeError, e: - pass - - def set_values(self, vcard): - for i in vcard.keys(): - if type(vcard[i]) == type({}): - for j in vcard[i].keys(): - self.set_value('entry_'+i+'_'+j, vcard[i][j]) - else: - if i == 'DESC': - self.xml.get_widget('textview_DESC').get_buffer().\ - set_text(vcard[i], 0) - else: - self.set_value('entry_'+i, vcard[i]) - - def add_to_vcard(self, vcard, entry, txt): - """Add an information to the vCard dictionary""" - entries = string.split(entry, '_') - loc = vcard - while len(entries) > 1: - if not loc.has_key(entries[0]): - loc[entries[0]] = {} - loc = loc[entries[0]] - del entries[0] - loc[entries[0]] = txt - return vcard - - def make_vcard(self): - """make the vCard dictionary""" - entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_USERID', 'URL', 'TEL_NUMBER',\ - 'ADR_STREET', 'ADR_EXTADR', 'ADR_LOCALITY', 'ADR_REGION', 'ADR_PCODE',\ - 'ADR_CTRY', 'ORG_ORGNAME', 'ORG_ORGUNIT', 'TITLE', 'ROLE'] - vcard = {} - for e in entries: - txt = self.xml.get_widget('entry_'+e).get_text() - if txt != '': - vcard = self.add_to_vcard(vcard, e, txt) - buf = self.xml.get_widget('textview_DESC').get_buffer() - start_iter = buf.get_start_iter() - end_iter = buf.get_end_iter() - txt = buf.get_text(start_iter, end_iter, 0) - if txt != '': - vcard['DESC']= txt - return vcard - - def on_retrieve(self, widget): - if self.plugin.connected[self.account]: - self.plugin.send('ASK_VCARD', self.account, self.jid) - else: - warning_dialog(_("You must be connected to get your informations")) - - def on_publish(self, widget): - if not self.plugin.connected[self.account]: - warning_dialog(_("You must be connected to publish your informations")) - return - vcard = self.make_vcard() - nick = '' - if vcard.has_key('NICKNAME'): - nick = vcard['NICKNAME'] - if nick == '': - nick = self.plugin.accounts[self.account]['name'] - self.plugin.nicks[self.account] = nick - self.plugin.send('VCARD', self.account, vcard) - - def __init__(self, jid, plugin, account): - self.xml = gtk.glade.XML(GTKGUI_GLADE, 'vcard', APP) - self.window = self.xml.get_widget('vcard') - self.jid = jid - self.plugin = plugin - self.account = account - - self.xml.signal_connect('gtk_widget_destroy', self.delete_event) - self.xml.signal_connect('on_close_clicked', self.on_close) - self.xml.signal_connect('on_retrieve_clicked', self.on_retrieve) - self.xml.signal_connect('on_publish_clicked', self.on_publish) - class preferences_window: """Class for Preferences window""" def delete_event(self, widget): @@ -1050,7 +961,8 @@ class accountpreferences_window: jid = self.xml.get_widget('jid_entry').get_text() if self.plugin.connected[self.account]: self.plugin.windows[self.account]['infos'][jid] = \ - vCard_Window(jid, self.plugin, self.account) + infoUser_Window(jid, self.plugin, self.account, True) +# vCard_Window(jid, self.plugin, self.account) self.plugin.send('ASK_VCARD', self.account, jid) else: warning_dialog(_('You must be connected to get your informations')) diff --git a/plugins/gtkgui/dialogs.py b/plugins/gtkgui/dialogs.py index 1049385a3..cae4c52fb 100644 --- a/plugins/gtkgui/dialogs.py +++ b/plugins/gtkgui/dialogs.py @@ -36,10 +36,13 @@ class infoUser_Window: """Class for user's information window""" def on_user_information_window_destroy(self, widget=None): """close window""" - del self.plugin.windows[self.account]['infos'][self.user.jid] + del self.plugin.windows[self.account]['infos'][self.jid] def on_close_button_clicked(self, widget): """Save user's informations and update the roster on the Jabber server""" + if self.vcard: + widget.get_toplevel().destroy() + return #update user.name if it's not "" name_entry = self.xml.get_widget('nickname_entry') new_name = name_entry.get_text() @@ -87,41 +90,122 @@ class infoUser_Window: else: self.set_value(i+'_entry', vcard[i]) - def __init__(self, user, plugin, account): - self.xml = gtk.glade.XML(GTKGUI_GLADE, 'user_information_window', APP) - self.window = self.xml.get_widget('user_information_window') - self.plugin = plugin - self.user = user - self.account = account - - self.xml.get_widget('nickname_label').set_text(user.name) - self.xml.get_widget('jid_label').set_text(user.jid) - self.xml.get_widget('subscription_label').set_text(user.sub) - if user.ask: - self.xml.get_widget('ask_label').set_text(user.ask) + def fill_jabber_page(self): + self.xml.get_widget('nickname_label').set_text(self.user.name) + self.xml.get_widget('jid_label').set_text(self.user.jid) + self.xml.get_widget('subscription_label').set_text(self.user.sub) + if self.user.ask: + self.xml.get_widget('ask_label').set_text(self.user.ask) else: self.xml.get_widget('ask_label').set_text('None') - self.xml.get_widget('nickname_entry').set_text(user.name) - account_info = self.plugin.accounts[account] + self.xml.get_widget('nickname_entry').set_text(self.user.name) + account_info = self.plugin.accounts[self.account] log = 1 if account_info.has_key('no_log_for'): - if user.jid in account_info['no_log_for'].split(' '): + if self.user.jid in account_info['no_log_for'].split(' '): log = 0 self.xml.get_widget('log_checkbutton').set_active(log) - resources = user.resource + ' (' + str(user.priority) + ')' - if not user.status: + resources = self.user.resource + ' (' + str(self.user.priority) + ')' + if not self.user.status: user.status = '' - stats = user.show + ' : ' + user.status - for u in self.plugin.roster.contacts[account][user.jid]: - if u.resource != user.resource: + stats = self.user.show + ' : ' + self.user.status + for u in self.plugin.roster.contacts[self.account][self.user.jid]: + if u.resource != self.user.resource: resources += '\n' + u.resource + ' (' + str(u.priority) + ')' if not u.status: u.status = '' stats += '\n' + u.show + ' : ' + u.status self.xml.get_widget('resource_label').set_text(resources) self.xml.get_widget('status_label').set_text(stats) - plugin.send('ASK_VCARD', account, self.user.jid) - + plugin.send('ASK_VCARD', self.account, self.user.jid) + + def add_to_vcard(self, vcard, entry, txt): + """Add an information to the vCard dictionary""" + entries = string.split(entry, '_') + loc = vcard + while len(entries) > 1: + if not loc.has_key(entries[0]): + loc[entries[0]] = {} + loc = loc[entries[0]] + del entries[0] + loc[entries[0]] = txt + return vcard + + def make_vcard(self): + """make the vCard dictionary""" + entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_USERID', 'URL', 'TEL_NUMBER',\ + 'ADR_STREET', 'ADR_EXTADR', 'ADR_LOCALITY', 'ADR_REGION', 'ADR_PCODE',\ + 'ADR_CTRY', 'ORG_ORGNAME', 'ORG_ORGUNIT', 'TITLE', 'ROLE'] + vcard = {} + for e in entries: + txt = self.xml.get_widget(e+'_entry').get_text() + if txt != '': + vcard = self.add_to_vcard(vcard, e, txt) + buffer = self.xml.get_widget('DESC_textview').get_buffer() + start_iter = buffer.get_start_iter() + end_iter = buffer.get_end_iter() + txt = buffer.get_text(start_iter, end_iter, 0) + if txt != '': + vcard['DESC'] = txt + return vcard + + def on_publish_button_clicked(self, widget): + if not self.plugin.connected[self.account]: + warning_dialog(_("You must be connected to publish your informations")) + return + vcard = self.make_vcard() + nick = '' + if vcard.has_key('NICKNAME'): + nick = vcard['NICKNAME'] + if nick == '': + nick = self.plugin.accounts[self.account]['name'] + self.plugin.nicks[self.account] = nick + self.plugin.send('VCARD', self.account, vcard) + + def on_retrieve_button_clicked(self, widget): + if self.plugin.connected[self.account]: + self.plugin.send('ASK_VCARD', self.account, self.jid) + else: + warning_dialog(_('You must be connected to get your informations')) + + def change_to_vcard(self): + self.xml.get_widget('information_notebook').remove_page(0) + self.xml.get_widget('nickname_label').set_text('Personal details') + information_hbuttonbox = self.xml.get_widget('information_hbuttonbox') + #publish button + button = gtk.Button(stock=gtk.STOCK_GOTO_TOP) + button.get_children()[0].get_children()[0].get_children()[1].\ + set_text('Publish') + button.connect('clicked', self.on_publish_button_clicked) + button.show_all() + information_hbuttonbox.pack_start(button) + #retrieve button + button = gtk.Button(stock=gtk.STOCK_GOTO_BOTTOM) + button.get_children()[0].get_children()[0].get_children()[1].\ + set_text('Retrieve') + button.connect('clicked', self.on_retrieve_button_clicked) + button.show_all() + information_hbuttonbox.pack_start(button) + #close button at the end + button = self.xml.get_widget('close_button') + information_hbuttonbox.reorder_child(button, 2) + + #the user variable is the jid if vcard is true + def __init__(self, user, plugin, account, vcard=False): + self.xml = gtk.glade.XML(GTKGUI_GLADE, 'vcard_information_window', APP) + self.window = self.xml.get_widget('vcard_information_window') + self.plugin = plugin + self.user = user #don't use it is vcard is true + self.account = account + self.vcard = vcard + + if vcard: + self.jid = user + self.change_to_vcard() + else: + self.jid = user.jid + self.fill_jabber_page() + self.xml.signal_autoconnect(self) class passphrase_Window: diff --git a/plugins/gtkgui/gtkgui.glade b/plugins/gtkgui/gtkgui.glade index e138752a0..2fc446dae 100644 --- a/plugins/gtkgui/gtkgui.glade +++ b/plugins/gtkgui/gtkgui.glade @@ -5480,7 +5480,7 @@ Custom - + 5 True Information @@ -5524,7 +5524,7 @@ Custom - + True True True @@ -6761,11 +6761,11 @@ Custom - - 6 + + 5 True GTK_BUTTONBOX_END - 0 + 15 @@ -6790,1154 +6790,6 @@ Custom - - 5 - True - Personal Details - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_NORMAL - GDK_GRAVITY_NORTH_WEST - - - - True - False - 0 - - - - 3 - True - True - True - True - GTK_POS_TOP - False - False - - - - 5 - True - 6 - 2 - False - 6 - 15 - - - - True - Name - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - Nickname - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - Birthday - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - - True - E-Mail - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - - True - Homepage - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 4 - 5 - fill - - - - - - - True - Phone # - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 5 - 6 - fill - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 0 - 1 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 1 - 2 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 2 - 3 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 3 - 4 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 4 - 5 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 5 - 6 - - - - - - False - True - - - - - - True - General - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - 5 - True - 6 - 2 - False - 6 - 15 - - - - True - Street - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - City - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - - True - State - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - - True - Postal Code - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 4 - 5 - fill - - - - - - - True - Country - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 5 - 6 - fill - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 0 - 1 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 1 - 2 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 2 - 3 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 3 - 4 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 4 - 5 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 5 - 6 - - - - - - False - True - - - - - - True - Location - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - 5 - True - 4 - 2 - False - 6 - 15 - - - - True - Company - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - Department - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - Position - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - - True - Role - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 0 - 1 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 1 - 2 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 2 - 3 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 3 - 4 - - - - - - False - True - - - - - - True - Work - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - 5 - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - True - GTK_JUSTIFY_LEFT - GTK_WRAP_NONE - True - 0 - 0 - 0 - 0 - 0 - 0 - - - - - - False - True - - - - - - True - About - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_END - 15 - - - - True - True - True - GTK_RELIEF_NORMAL - True - - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-goto-top - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Publish - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - - - - - - - True - True - True - GTK_RELIEF_NORMAL - True - - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-goto-bottom - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Retrieve - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - - - - - - - True - True - True - GTK_RELIEF_NORMAL - True - - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-close - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Close - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - - - - - - 4 - False - True - - - - - - True Log