From b72e3aa10064daed79b1ca3f2f60c768ca67dc4a Mon Sep 17 00:00:00 2001 From: Jean-Marie Traissard Date: Sat, 8 Apr 2006 22:47:57 +0000 Subject: [PATCH] Re-add nk's 'Profile, Avatar' menu, make it working --- src/gajim.py | 13 ++++++++----- src/gtkgui.glade | 21 +++++++++++++++++++++ src/roster_window.py | 39 ++++++++++++++++++++++++++++++++++++--- 3 files changed, 65 insertions(+), 8 deletions(-) diff --git a/src/gajim.py b/src/gajim.py index aae0ef5d5..6e34c021f 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -307,14 +307,17 @@ class Interface: self.roster.on_status_changed(account, status) if account in self.show_vcard_when_connect: - jid = gajim.get_jid_from_account(account) - if not self.instances[account]['infos'].has_key(jid): - self.instances[account]['infos'][jid] = \ - vcard.VcardWindow(jid, account, True) - gajim.connections[account].request_vcard(jid) + self.edit_own_details(account) if self.remote_ctrl: self.remote_ctrl.raise_signal('AccountPresence', (status, account)) + def edit_own_details(self, account): + jid = gajim.get_jid_from_account(account) + if not self.instances[account]['infos'].has_key(jid): + self.instances[account]['infos'][jid] = \ + vcard.VcardWindow(jid, account, True) + gajim.connections[account].request_vcard(jid) + def handle_event_notify(self, account, array): # 'NOTIFY' (account, (jid, status, status message, resource, priority, # keyID, timestamp)) diff --git a/src/gtkgui.glade b/src/gtkgui.glade index 4bf464a78..faaa3e745 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -188,6 +188,7 @@ True _Edit True + @@ -236,6 +237,26 @@ + + + True + Profile, Avatar + True + + + + True + gtk-properties + 1 + 0.5 + 0.5 + 0 + 0 + + + + + True diff --git a/src/roster_window.py b/src/roster_window.py index 8c1102fb9..cec515422 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -532,7 +532,11 @@ class RosterWindow: def on_actions_menuitem_activate(self, widget): self.make_menu() - + + def on_edit_menuitem_activate(self, widget): + '''need 'Profile, Avatar' menuitem/submenu''' + self.make_menu() + def on_bookmark_menuitem_activate(self, widget, account, bookmark): self.join_gc_room(account, bookmark['jid'], bookmark['nick'], bookmark['password']) @@ -627,6 +631,7 @@ class RosterWindow: advanced_menuitem = self.xml.get_widget('advanced_menuitem') show_offline_contacts_menuitem = self.xml.get_widget( 'show_offline_contacts_menuitem') + profile_avatar_menuitem = self.xml.get_widget('profile_avatar_menuitem') # destroy old advanced menus for m in self.advanced_menus: @@ -650,12 +655,19 @@ class RosterWindow: self.new_message_menuitem_handler_id) self.new_message_menuitem_handler_id = None + if self.profile_avatar_menuitem_handler_id: + profile_avatar_menuitem.handler_disconnect( + self.profile_avatar_menuitem_handler_id) + self.profile_avatar_menuitem_handler_id = None + + # remove the existing submenus add_new_contact_menuitem.remove_submenu() service_disco_menuitem.remove_submenu() join_gc_menuitem.remove_submenu() new_message_menuitem.remove_submenu() advanced_menuitem.remove_submenu() + profile_avatar_menuitem.remove_submenu() # remove the existing accelerator if self.have_new_message_accel: @@ -672,7 +684,8 @@ class RosterWindow: add_sub_menu = gtk.Menu() disco_sub_menu = gtk.Menu() new_message_sub_menu = gtk.Menu() - + profile_avatar_sub_menu = gtk.Menu() + for account in gajim.connections: if gajim.connections[account].connected <= 1: # if offline or connecting @@ -715,6 +728,15 @@ class RosterWindow: self.on_new_message_menuitem_activate, account) new_message_menuitem.set_submenu(new_message_sub_menu) new_message_sub_menu.show_all() + + # profile, avatar + profile_avatar_item = gtk.MenuItem(_('of account %s') % account, + False) + profile_avatar_sub_menu.append(profile_avatar_item) + profile_avatar_item.connect('activate', + self.on_profile_avatar_menuitem_activate, account) + profile_avatar_menuitem.set_submenu(profile_avatar_sub_menu) + profile_avatar_sub_menu.show_all() elif connected_accounts == 1: # user has only one account for account in gajim.connections: @@ -741,6 +763,12 @@ class RosterWindow: new_message_menuitem.add_accelerator('activate', ag, gtk.keysyms.n, gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) self.have_new_message_accel = True + + # profile, avatar + if not self.profile_avatar_menuitem_handler_id: + self.profile_avatar_menuitem_handler_id = \ + profile_avatar_menuitem.connect('activate', self.\ + on_profile_avatar_menuitem_activate, account) break # No other account connected @@ -750,12 +778,13 @@ class RosterWindow: join_gc_menuitem.set_sensitive(False) add_new_contact_menuitem.set_sensitive(False) service_disco_menuitem.set_sensitive(False) + profile_avatar_menuitem.set_sensitive(False) else: # we have one or more connected accounts new_message_menuitem.set_sensitive(True) join_gc_menuitem.set_sensitive(True) add_new_contact_menuitem.set_sensitive(True) service_disco_menuitem.set_sensitive(True) - + profile_avatar_menuitem.set_sensitive(True) # show the 'manage gc bookmarks' item newitem = gtk.SeparatorMenuItem() # separator gc_sub_menu.append(newitem) @@ -2239,6 +2268,9 @@ _('If "%s" accepts this request you will know his or her status.') % jid) def on_manage_bookmarks_menuitem_activate(self, widget): config.ManageBookmarksWindow() + + def on_profile_avatar_menuitem_activate(self, widget, account): + gajim.interface.edit_own_details(account) def close_all(self, dic): '''close all the windows in the given dictionary''' @@ -3208,6 +3240,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid) self.add_new_contact_handler_id = False self.service_disco_handler_id = False self.new_message_menuitem_handler_id = False + self.profile_avatar_menuitem_handler_id = False self.actions_menu_needs_rebuild = True self.regroup = gajim.config.get('mergeaccounts') if len(gajim.connections) < 2: # Do not merge accounts if only one exists