Browse Source

Using a custom filter for the title, to fix the problem with ConfigOpt

and Mitter getting confused about formating strings.
master
Julio Biason 14 years ago
parent
commit
12ad096374
  1. 48
      mitterlib/ui/ui_pygtk.py

48
mitterlib/ui/ui_pygtk.py

@ -390,6 +390,21 @@ class Interface(object):
self._reply_message_id = None
return
def _update_title(self, messages, replies):
"""Update the window title with the information about the number of
unread messages and unread replies."""
title_info = {
'message_count': str(messages),
'message': N_('message', 'messages', messages),
'replies_count': str(replies),
'replies': N_('reply', 'replies', replies)
}
mask = self._options[self.NAMESPACE]['window_title']
for variable in title_info:
mask = mask.replace('{' + variable + '}', title_info[variable])
self._main_window.set_title(mask)
return
# ------------------------------------------------------------
# Widget callback functions
@ -418,16 +433,7 @@ class Interface(object):
self._main_tabs.set_tab_label_text(child, message)
replies = self._main_tabs.get_nth_page(1)
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)
self._update_title(data, replies.count)
if (data + replies.count) > 0:
self._statusicon.set_from_pixbuf(self._images['new-messages'])
return
@ -443,15 +449,7 @@ class Interface(object):
self._main_tabs.set_tab_label_text(child, message)
messages = self._main_tabs.get_nth_page(0)
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)
self._update_title(messages.count, data)
if (data + messages.count) > 0:
self._statusicon.set_from_pixbuf(self._images['new-messages'])
return
@ -1109,15 +1107,15 @@ class Interface(object):
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' \
help='Format string to be used in the title. Variables ' \
'can be accessed with {variable_name}. Mitter will ' \
'pass the following variables:\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)
default='Mitter ({message_count} {message}, ' \
'{replies_count} {replies})',
is_cmd_option=False)

Loading…
Cancel
Save