From 928af2fa9c2bd8df111a77171816bb3dd5b8b974 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Mon, 25 Apr 2005 20:16:25 +0000 Subject: [PATCH] when we right click on a contact that is not in the roster, there is 'add to roster' in the menu (fix ticket #55) --- src/roster_window.py | 52 +++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/src/roster_window.py b/src/roster_window.py index 6de6de993..7531831f4 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -475,21 +475,27 @@ class Roster_window: item = gtk.MenuItem(_('Edit groups')) menu.append(item) item.connect('activate', self.on_edit_groups, user, account) - item = gtk.MenuItem() - menu.append(item) - item = gtk.MenuItem(_('Subscription')) - menu.append(item) - - sub_menu = gtk.Menu() - item.set_submenu(sub_menu) - item = gtk.MenuItem(_('Resend authorization to')) - sub_menu.append(item) - item.connect('activate', self.authorize, jid, account) - item = gtk.MenuItem(_('Rerequest authorization from')) - sub_menu.append(item) - item.connect('activate', self.req_sub, jid, - _('I would like to add you to my contact list.'), account) - + item = gtk.MenuItem() + menu.append(item) + item = gtk.MenuItem(_('Subscription')) + menu.append(item) + + sub_menu = gtk.Menu() + item.set_submenu(sub_menu) + item = gtk.MenuItem(_('Resend authorization to')) + sub_menu.append(item) + item.connect('activate', self.authorize, jid, account) + item = gtk.MenuItem(_('Rerequest authorization from')) + sub_menu.append(item) + item.connect('activate', self.req_sub, jid, + _('I would like to add you to my contact list.'), account) + else: + item = gtk.MenuItem() + menu.append(item) + item = gtk.MenuItem(_('Add to roster')) + menu.append(item) + item.connect('activate', self.on_add_to_roster, user, account) + item = gtk.MenuItem(_('Remove')) menu.append(item) item.connect('activate', self.on_req_usub, user, account) @@ -616,6 +622,9 @@ class Roster_window: menu.popup(None, None, None, event.button, event.time) menu.show_all() menu.reposition() + + def on_add_to_roster(self, widget, user, account): + dialogs.Add_new_contact_window(self.plugin, account, user.jid) def authorize(self, widget, jid, account): '''Authorize a user''' @@ -626,13 +635,20 @@ class Roster_window: if not pseudo: pseudo = jid gajim.connections[account].request_subscription(jid, txt) + if not group: + group = 'General' if not self.contacts[account].has_key(jid): - if not group: - group = 'General' user1 = User(jid, pseudo, [group], 'requested', 'requested', 'none', 'subscribe', '', 0, '') self.contacts[account][jid] = [user1] - self.add_user_to_roster(jid, account) + else: + user1 = self.contacts[account][jid][0] + if not 'not in the roster' in user1.groups: + return + user1.groups = [group] + user1.name = pseudo + self.remove_user(user1, account) + self.add_user_to_roster(jid, account) def on_roster_treeview_key_press_event(self, widget, event): '''when a key is pressed in the treeviews'''