diff --git a/src/chat.py b/src/chat.py index 70f18a042..bb93726fd 100644 --- a/src/chat.py +++ b/src/chat.py @@ -653,6 +653,27 @@ class Chat: clip = gtk.clipboard_get() clip.set_text(text) + def on_start_chat_activate(self, widget, jid): + self.plugin.roster.new_chat_from_jid(self.account, jid) + + def on_join_group_chat_menuitem_activate(self, widget, jid): + server, room = jid.split('@') + if self.plugin.windows[self.account].has_key('join_gc'): + instance = self.plugin.windows[self.account]['join_gc'] + print instance.xml + instance.xml.get_widget('server_entry').set_text(server) + instance.xml.get_widget('room_entry').set_text(room) + self.plugin.windows[self.account]['join_gc'].window.present() + else: + try: + self.plugin.windows[self.account]['join_gc'] = \ + dialogs.JoinGroupchatWindow(self.plugin, self.account, server, room) + except RuntimeError: + pass + + def on_add_to_roster_activate(self, widget, jid): + dialogs.AddNewContactWindow(self.plugin, self.account, jid) + def make_link_menu(self, event, kind, text): xml = gtk.glade.XML(GTKGUI_GLADE, 'chat_context_menu', APP) menu = xml.get_widget('chat_context_menu') @@ -662,9 +683,22 @@ class Chat: childs[1].connect('activate', self.on_open_link_activate, kind, text) childs[2].hide() # copy mail address childs[3].hide() # open mail composer - else: # It's a mail + childs[4].hide() # jid section seperator + childs[5].hide() # start chat + childs[6].hide() # add to roster + else: # It's a mail or a JID childs[2].connect('activate', self.on_copy_link_activate, text) childs[3].connect('activate', self.on_open_link_activate, kind, text) + childs[5].connect('activate', self.on_start_chat_activate, text) + childs[6].connect('activate', + self.on_join_group_chat_menuitem_activate, text) + if self.plugin.roster.contacts[self.account].has_key(text): +#and\#FIXME: check if it's in 'not in the roster' and then don't hide +#not self.plugin.roster.contacts[self.account][text].show == 'not in the roster': + childs[7].hide() + else: + childs[7].connect('activate', self.on_add_to_roster_activate, text) + childs[7].show() childs[0].hide() # copy link location childs[1].hide() # open link in browser diff --git a/src/dialogs.py b/src/dialogs.py index 6123827ab..b258d96ec 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -580,7 +580,7 @@ _('You can not join a group chat unless you are connected.')).get_response() our_jid = gajim.config.get_per('accounts', self.account, 'name') + '@' + \ gajim.config.get_per('accounts', self.account, 'hostname') if len(gajim.connections) > 1: - title = _('Join Groupchat as ') + our_jid + title = _('Join Groupchat as %s') % our_jid else: title = _('Join Groupchat') self.window.set_title(title) @@ -594,7 +594,7 @@ _('You can not join a group chat unless you are connected.')).get_response() self.recently_groupchat = gajim.config.get('recently_groupchat').split() for g in self.recently_groupchat: self.recently_combobox.append_text(g) - if len(self.recently_groupchat): + if len(self.recently_groupchat) and server == '' and room == '': self.recently_combobox.set_active(0) self.xml.get_widget('room_entry').select_region(0, -1) @@ -660,26 +660,7 @@ class NewMessageDialog: _('Contact ID must be of the form "username@servername".')).get_response() return - # use Contact class, new_chat expects it that way - # is it in the roster? - if self.plugin.roster.contacts[self.account].has_key(jid): - user = self.plugin.roster.contacts[self.account][jid][0] - else: - keyID = '' - attached_keys = gajim.config.get_per('accounts', self.account, - 'attached_gpg_keys').split() - if jid in attached_keys: - keyID = attached_keys[attached_keys.index(jid) + 1] - user = Contact(jid = jid, name = jid.split('@')[0], - groups = ['not in the roster'], show = 'not in the roster', - status = 'not in the roster', sub = 'none', keyID = keyID) - self.plugin.roster.contacts[self.account][jid] = [user] - self.plugin.roster.add_user_to_roster(user.jid, self.account) - - if not self.plugin.windows[self.account]['chats'].has_key(jid): - self.plugin.roster.new_chat(user, self.account) - self.plugin.windows[self.account]['chats'][jid].set_active_tab(jid) - self.plugin.windows[self.account]['chats'][jid].window.present() + self.plugin.roster.new_chat_from_jid(self.account, jid) class ChangePasswordDialog: def __init__(self, plugin, account): diff --git a/src/gtkgui.glade b/src/gtkgui.glade index ee13e5a53..b871e0ec3 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -12023,7 +12023,7 @@ JID: whatever@jabber.org True - + True gtk-copy 1 @@ -12043,7 +12043,7 @@ JID: whatever@jabber.org True - + True gtk-jump-to 1 @@ -12063,7 +12063,7 @@ JID: whatever@jabber.org True - + True gtk-copy 1 @@ -12083,7 +12083,7 @@ JID: whatever@jabber.org True - + True gtk-jump-to 1 @@ -12095,6 +12095,73 @@ JID: whatever@jabber.org + + + + True + + + + + + True + _Start Chat + True + + + + True + gtk-jump-to + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + + + True + Join _Group Chat + True + + + + + True + gtk-connect + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + + + True + _Add to Roster + True + + + + True + gtk-add + 1 + 0.5 + 0.5 + 0 + 0 + + + + diff --git a/src/roster_window.py b/src/roster_window.py index f2ec1107b..efa1b31e1 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -1251,6 +1251,26 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response() self.plugin.windows[account]['chats'][user.jid] = \ tabbed_chat_window.TabbedChatWindow(user, self.plugin, account) + def new_chat_from_jid(self, account, jid): + if self.contacts[account].has_key(jid): + user = self.contacts[account][jid][0] + else: + keyID = '' + attached_keys = gajim.config.get_per('accounts', account, + 'attached_gpg_keys').split() + if jid in attached_keys: + keyID = attached_keys[attached_keys.index(jid) + 1] + user = Contact(jid = jid, name = jid.split('@')[0], + groups = ['not in the roster'], show = 'not in the roster', + status = 'not in the roster', sub = 'none', keyID = keyID) + self.contacts[account][jid] = [user] + self.add_user_to_roster(user.jid, account) + + if not self.plugin.windows[account]['chats'].has_key(jid): + self.new_chat(user, account) + self.plugin.windows[account]['chats'][jid].set_active_tab(jid) + self.plugin.windows[account]['chats'][jid].window.present() + def new_room(self, jid, nick, account): if gajim.config.get('usetabbedchat'): if not self.plugin.windows[account]['gc'].has_key('tabbed'):