Browse Source

Single place to update everything message count related

master
Julio Biason 15 years ago
parent
commit
94708849bf
  1. 36
      mitterlib/ui/ui_pygtk.py

36
mitterlib/ui/ui_pygtk.py

@ -241,7 +241,7 @@ class Interface(object):
main_window.add(box) main_window.add(box)
main_window.add_accel_group(accelerators) main_window.add_accel_group(accelerators)
self._update_tab_count() self._message_count_updated()
return main_window return main_window
@ -671,11 +671,19 @@ class Interface(object):
return True return True
def _update_tab_count(self): def _message_count_updated(self):
"""Update the message count in the message tab.""" """Update the elements in the interface that should change in case of
changes in the message count."""
child = self._main_tabs.get_nth_page(0) child = self._main_tabs.get_nth_page(0)
self._main_tabs.set_tab_label_text(child, 'Messages (%d)' % self._main_tabs.set_tab_label_text(child, 'Messages (%d)' %
(self._new_message_count)) (self._new_message_count))
if self._statusicon:
if self._new_message_count == 0:
self._statusicon.set_from_pixbuf(self._images['main'])
else:
self._statusicon.set_from_pixbuf(self._images['new-messages'])
return return
# ------------------------------------------------------------ # ------------------------------------------------------------
@ -811,9 +819,7 @@ class Interface(object):
"""Clear the list of posts from the grid.""" """Clear the list of posts from the grid."""
self._grid.get_model().clear() self._grid.get_model().clear()
self._new_message_count = 0 self._new_message_count = 0
self._update_tab_count() self._message_count_updated()
if self._statusicon:
self._statusicon.set_from_pixbuf(self._images['main'])
return return
def _delete_message(self, widget, user_data=None): def _delete_message(self, widget, user_data=None):
@ -982,11 +988,7 @@ class Interface(object):
message.read = True message.read = True
self._new_message_count -= 1 self._new_message_count -= 1
self._update_tab_count() self._message_count_updated()
if self._new_message_count == 0 and self._statusicon:
self._statusicon.set_from_pixbuf(self._images['main'])
return True return True
# ------------------------------------------------------------ # ------------------------------------------------------------
@ -1025,10 +1027,7 @@ class Interface(object):
self._refresh, None) self._refresh, None)
self._new_message_count += len(results) self._new_message_count += len(results)
self._update_tab_count() self._message_count_updated()
if self._new_message_count > 0 and self._statusicon:
self._statusicon.set_from_pixbuf(self._images['new-messages'])
return return
def _exception_get_messages(self, widget, exception): def _exception_get_messages(self, widget, exception):
@ -1185,14 +1184,15 @@ class Interface(object):
"""Call function; displays the interface. This method should appear on """Call function; displays the interface. This method should appear on
every interface.""" every interface."""
self._main_window = self._create_main_window()
self._main_window.show_all()
if self._options[self.NAMESPACE]['statusicon']: if self._options[self.NAMESPACE]['statusicon']:
self._statusicon = gtk.StatusIcon() self._statusicon = gtk.StatusIcon()
self._statusicon.set_from_pixbuf(self._images['main']) self._statusicon.set_from_pixbuf(self._images['main'])
else: else:
self._statusicon = None self._statusicon = None
self._main_window = self._create_main_window()
self._main_window.show_all()
self._threads = _ThreadManager() self._threads = _ThreadManager()
# queue the first fetch # queue the first fetch

Loading…
Cancel
Save