From 94708849bff81814e63bf4ce04e555fc3015de91 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Sun, 20 Dec 2009 16:43:01 -0200 Subject: [PATCH] Single place to update everything message count related --- mitterlib/ui/ui_pygtk.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index 856ef35..6a21414 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/mitterlib/ui/ui_pygtk.py @@ -241,7 +241,7 @@ class Interface(object): main_window.add(box) main_window.add_accel_group(accelerators) - self._update_tab_count() + self._message_count_updated() return main_window @@ -671,11 +671,19 @@ class Interface(object): return True - def _update_tab_count(self): - """Update the message count in the message tab.""" + def _message_count_updated(self): + """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) self._main_tabs.set_tab_label_text(child, 'Messages (%d)' % (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 # ------------------------------------------------------------ @@ -811,9 +819,7 @@ class Interface(object): """Clear the list of posts from the grid.""" self._grid.get_model().clear() self._new_message_count = 0 - self._update_tab_count() - if self._statusicon: - self._statusicon.set_from_pixbuf(self._images['main']) + self._message_count_updated() return def _delete_message(self, widget, user_data=None): @@ -982,11 +988,7 @@ class Interface(object): message.read = True self._new_message_count -= 1 - self._update_tab_count() - - if self._new_message_count == 0 and self._statusicon: - self._statusicon.set_from_pixbuf(self._images['main']) - + self._message_count_updated() return True # ------------------------------------------------------------ @@ -1025,10 +1027,7 @@ class Interface(object): self._refresh, None) self._new_message_count += len(results) - self._update_tab_count() - if self._new_message_count > 0 and self._statusicon: - self._statusicon.set_from_pixbuf(self._images['new-messages']) - + self._message_count_updated() return def _exception_get_messages(self, widget, exception): @@ -1185,14 +1184,15 @@ class Interface(object): """Call function; displays the interface. This method should appear on every interface.""" - self._main_window = self._create_main_window() - self._main_window.show_all() - if self._options[self.NAMESPACE]['statusicon']: self._statusicon = gtk.StatusIcon() self._statusicon.set_from_pixbuf(self._images['main']) else: self._statusicon = None + + self._main_window = self._create_main_window() + self._main_window.show_all() + self._threads = _ThreadManager() # queue the first fetch