Author: asterix
Date: 2007-10-13 16:37:22 +0200 (Sat, 13 Oct 2007)
New Revision: 8903
Modified:
trunk/src/gajim.py
trunk/src/groupchat_control.py
trunk/src/message_window.py
Log:
Follow nick change in private message. fixes #3455
Modified: trunk/src/gajim.py
===================================================================
--- trunk/src/gajim.py 2007-10-11 16:48:28 UTC (rev 8902)
+++ trunk/src/gajim.py 2007-10-13 14:37:22 UTC (rev 8903)
@@ -1128,18 +1128,32 @@
# 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))
Modified: trunk/src/groupchat_control.py
===================================================================
--- trunk/src/groupchat_control.py 2007-10-11 16:48:28 UTC (rev 8902)
+++ trunk/src/groupchat_control.py 2007-10-13 14:37:22 UTC (rev 8903)
@@ -251,7 +251,8 @@
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 @@
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)
Modified: trunk/src/message_window.py
===================================================================
--- trunk/src/message_window.py 2007-10-11 16:48:28 UTC (rev 8902)
+++ trunk/src/message_window.py 2007-10-13 14:37:22 UTC (rev 8903)
@@ -511,6 +511,16 @@
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 @@
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()