From 503aebd91906d6db7d5325f6fbd5bcd19f7e5172 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 23 Oct 2009 10:02:45 +0200 Subject: [PATCH] [change window icon according to the content (muc, chat). Fixes #4300 --- src/chat_control.py | 11 +++++++---- src/groupchat_control.py | 2 +- src/message_control.py | 2 +- src/message_window.py | 26 ++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index a393c044a..75ee9ef4a 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -2045,13 +2045,16 @@ class ChatControl(ChatControlBase): label_str = '' + unread + label_str + '' return (label_str, color) - def get_tab_image(self): + def get_tab_image(self, count_unread=True): if self.resource: jid = self.contact.get_full_jid() else: jid = self.contact.jid - num_unread = len(gajim.events.get_events(self.account, jid, - ['printed_' + self.type_id, self.type_id])) + if count_unread: + num_unread = len(gajim.events.get_events(self.account, jid, + ['printed_' + self.type_id, self.type_id])) + else: + num_unread = 0 # Set tab image (always 16x16); unread messages show the 'event' image tab_img = None @@ -2066,7 +2069,7 @@ class ChatControl(ChatControlBase): # For transient contacts contact = self.contact img_16 = gajim.interface.roster.get_appropriate_state_images( - self.contact.jid, icon_name = contact.show) + self.contact.jid, icon_name=contact.show) tab_img = img_16[contact.show] return tab_img diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 65eadadef..811a1afd7 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -535,7 +535,7 @@ class GroupchatControl(ChatControlBase): label_str = unread + label_str return (label_str, color) - def get_tab_image(self): + def get_tab_image(self, count_unread=True): # Set tab image (always 16x16) tab_image = None if gajim.gc_connected[self.account][self.room_jid]: diff --git a/src/message_control.py b/src/message_control.py index 8792a2896..7ee724554 100644 --- a/src/message_control.py +++ b/src/message_control.py @@ -120,7 +120,7 @@ class MessageControl: #return (label_str, None) pass - def get_tab_image(self): + def get_tab_image(self, count_unread=True): # Return a suitable tab image for display. # None clears any current label. return None diff --git a/src/message_window.py b/src/message_window.py index 9e4bc725c..f4bf614a2 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -146,6 +146,7 @@ class MessageWindow(object): else: self.notebook.set_show_tabs(False) self.notebook.set_show_border(gajim.config.get('tabs_border')) + self.show_icon() def change_account_name(self, old_name, new_name): if old_name in self._controls: @@ -417,6 +418,29 @@ class MessageWindow(object): '''When close button is pressed: close a tab''' self.remove_tab(control, self.CLOSE_CLOSE_BUTTON) + def show_icon(self): + window_mode = gajim.interface.msg_win_mgr.mode + icon = None + if window_mode == MessageWindowMgr.ONE_MSG_WINDOW_NEVER: + ctrl = self.get_active_control() + if not ctrl: + return + icon = ctrl.get_tab_image(count_unread=False) + elif window_mode == MessageWindowMgr.ONE_MSG_WINDOW_ALWAYS: + pass # keep default icon + elif window_mode == MessageWindowMgr.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER: + pass # keep default icon + elif window_mode == MessageWindowMgr.ONE_MSG_WINDOW_PERACCT: + pass # keep default icon + elif window_mode == MessageWindowMgr.ONE_MSG_WINDOW_PERTYPE: + if self.type_ == 'gc': + icon = gtkgui_helpers.load_icon('muc_active') + else: + # chat, pm + icon = gtkgui_helpers.load_icon('online') + if icon: + self.window.set_icon(icon.get_pixbuf()) + def show_title(self, urgent=True, control=None): '''redraw the window's title''' if not control: @@ -587,6 +611,8 @@ class MessageWindow(object): else: status_img.set_from_pixbuf(tab_img.get_pixbuf()) + self.show_icon() + def repaint_themed_widgets(self): '''Repaint controls in the window with theme color''' # iterate through controls and repaint