From 993d72a8c1ff7d3cea852ac0fc763bc67e01cfaa Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Thu, 17 May 2007 12:55:44 +0000 Subject: [PATCH] Fix a bug with receiving Private Messages when roster is minimized, print the number of unread pm in roster, and change icon when a pm is received. --- src/chat_control.py | 8 +++++++- src/common/helpers.py | 4 ++++ src/gajim.py | 4 ++++ src/groupchat_control.py | 6 ++++-- src/roster_window.py | 16 ++++++++++------ 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index 37ad46c72..57ed0ae36 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -827,9 +827,15 @@ class ChatControlBase(MessageControl): room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) groupchat_control = gajim.interface.msg_win_mgr.get_control( room_jid, self.account) + if not groupchat_control and \ + gajim.interface.minimized_controls.has_key(self.account) and \ + room_jid in gajim.interface.minimized_controls[self.account]: + groupchat_control = \ + gajim.interface.minimized_controls[self.account][room_jid] groupchat_control.draw_contact(nick) mw = gajim.interface.msg_win_mgr.get_window(room_jid, self.account) - mw.redraw_tab(groupchat_control) + if mw: + mw.redraw_tab(groupchat_control) else: gajim.interface.roster.draw_contact(jid, self.account) gajim.interface.roster.show_title() diff --git a/src/common/helpers.py b/src/common/helpers.py index a9910be0d..57c609c56 100644 --- a/src/common/helpers.py +++ b/src/common/helpers.py @@ -548,6 +548,10 @@ def get_icon_name_to_show(contact, account = None): if account and gajim.events.get_nb_roster_events(account, contact.get_full_jid()): return 'message' + if account and gajim.interface.minimized_controls.has_key(account) and \ + contact.jid in gajim.interface.minimized_controls[account] and gajim.interface.\ + minimized_controls[account][contact.jid].get_nb_unread_pm() > 0: + return 'message' if contact.jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent return contact.show if contact.sub in ('both', 'to'): diff --git a/src/gajim.py b/src/gajim.py index f65a852e7..c00b8b6c0 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -686,6 +686,10 @@ class Interface: jid = jid.replace('@', '') groupchat_control = self.msg_win_mgr.get_control(jid, account) + if not groupchat_control and \ + gajim.interface.minimized_controls.has_key(account) and \ + jid in gajim.interface.minimized_controls[account]: + groupchat_control = gajim.interface.minimized_controls[account][jid] pm = False if groupchat_control and groupchat_control.type_id == \ message_control.TYPE_GC: diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 99a2d0e0b..ace18561c 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -543,14 +543,16 @@ class GroupchatControl(ChatControlBase): self.room_jid, icon_name = 'message') image = state_images['message'] model[iter][C_IMG] = image - self.parent_win.show_title() - self.parent_win.redraw_tab(self) + if self.parent_win: + self.parent_win.show_title() + self.parent_win.redraw_tab(self) else: self._start_private_message(nick) # Scroll to line self.list_treeview.expand_row(path[0:1], False) self.list_treeview.scroll_to_cell(path) self.list_treeview.set_cursor(path) + gajim.interface.roster.draw_contact(self.room_jid, self.account) def get_contact_iter(self, nick): model = self.list_treeview.get_model() diff --git a/src/roster_window.py b/src/roster_window.py index b10d0874f..c435ecbd3 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -581,13 +581,17 @@ class RosterWindow: name = gobject.markup_escape_text(contact.get_shown_name()) # gets number of unread gc marked messages - nb_unread = len(gajim.events.get_events(account, jid, - ['printed_marked_gc_msg'])) + if gajim.interface.minimized_controls.has_key(account) and \ + jid in gajim.interface.minimized_controls[account]: + nb_unread = len(gajim.events.get_events(account, jid, + ['printed_marked_gc_msg'])) + nb_unread += \ + gajim.interface.minimized_controls[account][jid].get_nb_unread_pm() - if nb_unread == 1: - name = '%s *' % name - elif nb_unread > 1: - name = '%s [%s]' % (name, str(nb_unread)) + if nb_unread == 1: + name = '%s *' % name + elif nb_unread > 1: + name = '%s [%s]' % (name, str(nb_unread)) strike = False if jid in gajim.connections[account].blocked_contacts: