From 0071b5de4b4b88ae1b73694557e0d1e4867c2fa7 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Wed, 7 Apr 2010 10:02:31 -0300 Subject: [PATCH] show the number of messages and replies in the title (idea by renatux) --- THANKS | 3 ++- mitterlib/ui/ui_pygtk.py | 43 +++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/THANKS b/THANKS index e79ba97..de3c5d6 100644 --- a/THANKS +++ b/THANKS @@ -11,6 +11,7 @@ Many thanks to: - Kristian Rietveld, who posted a solution to the auto-word-wrap GtkTreeView (http://lists-archives.org/gtk/06637-tree-view-cell-size-negotiation.html) - Wiennat for the retweet patch. -- 3knirokfier for the favourite patch (although we went to a different route) - The guys from Paraiso Linux (http://paraisolinux.com) for the awesome new logo. +- Renato Covarrubias, for the patch to display the number of messages and + replies in the window title diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index def3250..374fc5b 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/mitterlib/ui/ui_pygtk.py @@ -351,7 +351,8 @@ class Interface(object): '"Wiennat"', 'Philip Reynolds', 'Greg McIntyre', - '"Alexander"']) + '"Alexander"', + 'Renato Covarrubias']) if self._images['logo']: about_window.set_logo(self._images['logo']) about_window.run() @@ -411,19 +412,24 @@ class Interface(object): messages changes.""" child = self._main_tabs.get_nth_page(0) message = _('Messages (%d)') % (data) + # do this specially for tabs since it seems really slow to update the + # text (at least, on my computer); so we update only the required tab, + # not both (even if we get both values here.) self._main_tabs.set_tab_label_text(child, message) - if data > 0: - _log.debug('We have new messages, changing status icon') - self._statusicon.set_from_pixbuf(self._images['new-messages']) - return + replies = self._main_tabs.get_nth_page(1) + messages_title = ('%d ' + + N_('message', 'messages', data)) % (data) + replies_title = ('%d ' + + N_('reply', 'replies', replies.count)) % (replies.count) - child = self._main_tabs.get_nth_page(1) - if child.count > 0: - _log.debug('Replies have messages, not changing status icon') + title = 'Mitter (%s, %s)' % (messages_title, replies_title) + self._main_window.set_title(title) + + if (data + replies.count) > 0: + self._statusicon.set_from_pixbuf(self._images['new-messages']) return - _log.debug('No messages or replies, changing status icon') self._statusicon.set_from_pixbuf(self._images['icon']) return @@ -434,17 +440,18 @@ class Interface(object): message = _('Replies (%d)') % (data) self._main_tabs.set_tab_label_text(child, message) - if data > 0: - _log.debug('We have new replies, changing status icon') - self._statusicon.set_from_pixbuf(self._images['new-messages']) - return + messages = self._main_tabs.get_nth_page(0) + messages_title = ('%d ' + + N_('message', 'messages', messages.count)) % (messages.count) + replies_title = ('%d ' + + N_('reply', 'replies', data)) % (data) - child = self._main_tabs.get_nth_page(0) - if child.count > 0: - _log.debug('Messages have new messages, not changing status icon') + title = 'Mitter (%s, %s)' % (messages_title, replies_title) + self._main_window.set_title(title) + if (data + messages.count) > 0: + self._statusicon.set_from_pixbuf(self._images['new-messages']) return - _log.debug('No messages or replies, changing status icon') self._statusicon.set_from_pixbuf(self._images['icon']) return @@ -1094,4 +1101,4 @@ class Interface(object): 'protected/private.', metavar='CHAR', default=_('(protected)'), - is_cmd_option=False) \ No newline at end of file + is_cmd_option=False)