diff --git a/src/chat.py b/src/chat.py index f094634ee..16169cc0a 100644 --- a/src/chat.py +++ b/src/chat.py @@ -24,6 +24,7 @@ import gobject import time import dialogs import history_window +import gtkgui_helpers try: import gtkspell @@ -157,6 +158,7 @@ class Chat: title += ' (' + _('account: ') + self.account + ')' self.window.set_title(title) + gtkgui_helpers.set_unset_urgency_hint(self.window, unread) def redraw_tab(self, jid): """redraw the label of the tab""" @@ -241,6 +243,13 @@ class Chat: self.show_title() if self.plugin.systray_enabled: self.plugin.systray.remove_jid(jid, self.account) + + '''TC/GC window received focus, so if we had urgency REMOVE IT + NOTE: we do not have to read the message (it maybe in a bg tab) + to remove urgency hint so this functions does that''' + if gtk.gtk_version >= (2, 8, 0) and gtk.pygtk_version >= (2, 8, 0): + if widget.props.urgency_hint: + widget.props.urgency_hint = False def on_compact_view_menuitem_activate(self, widget): isactive = widget.get_active() diff --git a/src/gtkgui.glade b/src/gtkgui.glade index c2a7c13ef..556bfcccb 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -21,6 +21,7 @@ GDK_GRAVITY_NORTH_WEST True + diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py index ad9f07f63..3251defa9 100644 --- a/src/gtkgui_helpers.py +++ b/src/gtkgui_helpers.py @@ -167,7 +167,7 @@ def autodetect_browser_mailer(): gajim.config.set('openwith', 'custom') def move_window(window, x, y): - ''' moves the window but also checks if out of screen ''' + '''moves the window but also checks if out of screen''' if x < 0: x = 0 if y < 0: @@ -175,10 +175,18 @@ def move_window(window, x, y): window.move(x, y) def resize_window(window, w, h): - ''' resizes window but also checks if huge window or negative values ''' + '''resizes window but also checks if huge window or negative values''' if w > screen_w: w = screen_w if h > screen_h: h = screen_h window.resize(abs(w), abs(h)) +def set_unset_urgency_hint(window, unread_messages_no): + '''sets/unsets urgency hint in window argument + depending if we have unread messages or not''' + if gtk.gtk_version >= (2, 8, 0) and gtk.pygtk_version >= (2, 8, 0): + if unread_messages_no > 0: + window.props.urgency_hint = True + else: + window.props.urgency_hint = False diff --git a/src/roster_window.py b/src/roster_window.py index 2e9a4b7b3..b8c4349ea 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -1525,6 +1525,14 @@ _('If "%s" accepts this request you will know his status.') %jid) self.quit_gtkgui_plugin() return True # do NOT destory the window + def on_roster_window_focus_in_event(self, widget, event): + '''roster received focus, so if we had urgency REMOVE IT + NOTE: we do not have to read the message to remove urgency + so this functions does that''' + if gtk.gtk_version >= (2, 8, 0) and gtk.pygtk_version >= (2, 8, 0): + if widget.props.urgency_hint: + widget.props.urgency_hint = False + def quit_gtkgui_plugin(self): '''When we quit the gtk plugin : tell that to the core and exit gtk''' @@ -2028,10 +2036,12 @@ _('If "%s" accepts this request you will know his status.') %jid) if change_title_allowed: start = '' if self.nb_unread > 1: - start = '[' + unicode(self.nb_unread) + '] ' + start = '[' + str(self.nb_unread) + '] ' elif self.nb_unread == 1: start = '* ' self.window.set_title(start + 'Gajim') + + gtkgui_helpers.set_unset_urgency_hint(self.window, self.nb_unread) def __init__(self, plugin): self.xml = gtk.glade.XML(GTKGUI_GLADE, 'roster_window', APP) diff --git a/src/tabbed_chat_window.py b/src/tabbed_chat_window.py index 152a25fa6..1dfdac534 100644 --- a/src/tabbed_chat_window.py +++ b/src/tabbed_chat_window.py @@ -55,7 +55,7 @@ class TabbedChatWindow(chat.Chat): self.dnd_list = [ ( 'text/uri-list', 0, self.TARGET_TYPE_URI_LIST ) ] self.new_tab(user) self.show_title() - + # NOTE: if it not a window event, connect in new_tab function signal_dict = { 'on_tabbed_chat_window_destroy': self.on_tabbed_chat_window_destroy,