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 15 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 self._reply_message_id = None
return 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 # Widget callback functions
@ -418,16 +433,7 @@ class Interface(object):
self._main_tabs.set_tab_label_text(child, message) self._main_tabs.set_tab_label_text(child, message)
replies = self._main_tabs.get_nth_page(1) replies = self._main_tabs.get_nth_page(1)
title_info = { self._update_title(data, replies.count)
'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: if (data + replies.count) > 0:
self._statusicon.set_from_pixbuf(self._images['new-messages']) self._statusicon.set_from_pixbuf(self._images['new-messages'])
return return
@ -443,15 +449,7 @@ class Interface(object):
self._main_tabs.set_tab_label_text(child, message) self._main_tabs.set_tab_label_text(child, message)
messages = self._main_tabs.get_nth_page(0) messages = self._main_tabs.get_nth_page(0)
title_info = { self._update_title(messages.count, data)
'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: if (data + messages.count) > 0:
self._statusicon.set_from_pixbuf(self._images['new-messages']) self._statusicon.set_from_pixbuf(self._images['new-messages'])
return return
@ -1109,15 +1107,15 @@ class Interface(object):
options.add_option( options.add_option(
group=self.NAMESPACE, group=self.NAMESPACE,
option='window_title', option='window_title',
help='Format string to be used in the title, following ' \ help='Format string to be used in the title. Variables ' \
"Python's string formatting rules. Mitter will " \ 'can be accessed with {variable_name}. Mitter will ' \
'pass a dictionary with:\n' \ 'pass the following variables:\n' \
'"message_count": the number of unread messages,\n' \ '"message_count": the number of unread messages,\n' \
'"message": the translatable word for ' \ '"message": the translatable word for ' \
'"message(s)",\n' \ '"message(s)",\n' \
'"replies_count": the number of unread replies,\n' \ '"replies_count": the number of unread replies,\n' \
'"replies": the translatable word for "replies"', '"replies": the translatable word for "replies"',
metavar='STRING', metavar='STRING',
default='Mitter (%(message_count)d %(message)s, ' \ default='Mitter ({message_count} {message}, ' \
'%(replies_count)d %(replies)s)', '{replies_count} {replies})',
is_cmd_option=False) is_cmd_option=False)

Loading…
Cancel
Save