diff --git a/src/gajim.py b/src/gajim.py index 7f809a8a3..8b563f681 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1128,18 +1128,32 @@ class Interface: # print status in chat window and update status/GPG image if ctrl: - contact = ctrl.contact - contact.show = show - contact.status = status - uf_show = helpers.get_uf_show(show) - if status: - ctrl.print_conversation(_('%s is now %s (%s)') % (nick, uf_show, - status), 'status') + statusCode = array[9] + if '303' in statusCode: + new_nick = array[10] + ctrl.print_conversation(_('%s is now known as %s') % (nick, + new_nick), 'status') + gc_c = gajim.contacts.get_gc_contact(account, room_jid, new_nick) + c = gajim.contacts.contact_from_gc_contact(gc_c) + ctrl.gc_contact = gc_c + ctrl.contact = c + ctrl.draw_banner() + old_jid = room_jid + '/' + nick + new_jid = room_jid + '/' + new_nick + self.msg_win_mgr.change_key(old_jid, new_jid, account) else: - ctrl.print_conversation(_('%s is now %s') % (nick, uf_show), - 'status') - ctrl.parent_win.redraw_tab(ctrl) - ctrl.update_ui() + contact = ctrl.contact + contact.show = show + contact.status = status + uf_show = helpers.get_uf_show(show) + if status: + ctrl.print_conversation(_('%s is now %s (%s)') % (nick, uf_show, + status), 'status') + else: + ctrl.print_conversation(_('%s is now %s') % (nick, uf_show), + 'status') + ctrl.parent_win.redraw_tab(ctrl) + ctrl.update_ui() if self.remote_ctrl: self.remote_ctrl.raise_signal('GCPresence', (account, array)) diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 278ebcbd3..ab002d705 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -251,7 +251,8 @@ class GroupchatControl(ChatControlBase): self.handlers[id] = self.change_subject_menuitem self.history_menuitem = xm.get_widget('history_menuitem') - id = self.history_menuitem.connect('activate', self._on_history_menuitem_activate) + id = self.history_menuitem.connect('activate', + self._on_history_menuitem_activate) self.handlers[id] = self.history_menuitem self.minimize_menuitem = xm.get_widget('minimize_menuitem') @@ -986,7 +987,8 @@ class GroupchatControl(ChatControlBase): self.attention_list.remove(nick) # keep nickname color if nick in self.gc_custom_colors: - self.gc_custom_colors[new_nick] = self.gc_custom_colors[nick] + self.gc_custom_colors[new_nick] = \ + self.gc_custom_colors[nick] # rename vcard / avatar puny_jid = helpers.sanitize_filename(self.room_jid) puny_nick = helpers.sanitize_filename(nick) diff --git a/src/message_window.py b/src/message_window.py index 735374f4b..3a11799f5 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -511,6 +511,16 @@ class MessageWindow: nth_child = notebook.get_nth_page(page_num) return self._widget_to_control(nth_child) + def change_key(self, old_jid, new_jid, acct): + '''Change the key of a control''' + try: + # Check if control exists + ctrl = self._controls[acct][old_jid] + except: + return + self._controls[acct][new_jid] = self._controls[acct][old_jid] + del self._controls[acct][old_jid] + def controls(self): for ctrl_dict in self._controls.values(): for ctrl in ctrl_dict.values(): @@ -801,6 +811,17 @@ class MessageWindowMgr: self._windows[key] = win return win + def change_key(self, old_jid, new_jid, acct): + win = self.get_window(old_jid, acct) + if self.mode == self.ONE_MSG_WINDOW_NEVER: + old_key = acct + old_jid + if old_jid not in self._windows: + return + new_key = acct + new_jid + self._windows[new_key] = self._windows[old_key] + del self._windows[old_key] + win.change_key(old_jid, new_jid, acct) + def _on_window_delete(self, win, event): self.save_state(self._gtk_win_to_msg_win(win)) gajim.interface.save_config()