From 6168f74353abf316a9495252334d6676a1700e64 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Thu, 8 Apr 2010 07:50:42 -0300 Subject: [PATCH] Trying to make the window title string configurable, but having issues with ConfigOpt trying to save it back. --- mitterlib/ui/ui_pygtk.py | 43 +++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index 374fc5b..9028c0b 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/mitterlib/ui/ui_pygtk.py @@ -418,12 +418,14 @@ class Interface(object): self._main_tabs.set_tab_label_text(child, message) 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) - - title = 'Mitter (%s, %s)' % (messages_title, replies_title) + title_info = { + 'message_count': data, + 'message': N_('message', 'messages', data), + 'replies_count': replies.count, + 'replies': N_('reply', 'replies', replies.count) + } + + title = self._options[self.NAMESPACE]['window_title'] % (title_info) self._main_window.set_title(title) if (data + replies.count) > 0: @@ -441,12 +443,14 @@ class Interface(object): self._main_tabs.set_tab_label_text(child, message) 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) - - title = 'Mitter (%s, %s)' % (messages_title, replies_title) + title_info = { + 'message_count': messages.count, + 'message': N_('message', 'messages', messages.count), + 'replies_count': data, + 'replies': N_('reply', 'replies', data) + } + + title = self._options[self.NAMESPACE]['window_title'] % (title_info) self._main_window.set_title(title) if (data + messages.count) > 0: self._statusicon.set_from_pixbuf(self._images['new-messages']) @@ -1102,3 +1106,18 @@ class Interface(object): metavar='CHAR', default=_('(protected)'), is_cmd_option=False) + options.add_option( + group=self.NAMESPACE, + option='window_title', + help='Format string to be used in the title, following ' \ + "Python's string formatting rules. Mitter will " \ + 'pass a dictionary with:\n' \ + '"message_count": the number of unread messages,\n' \ + '"message": the translatable word for ' \ + '"message(s)",\n' \ + '"replies_count": the number of unread replies,\n' \ + '"replies": the translatable word for "replies"', + metavar='STRING', + default='Mitter (%(message_count)d %(message)s, ' \ + '%(replies_count)d %(replies)s)', + is_cmd_option=False) \ No newline at end of file