Browse Source

Plugging the 'count-changed' signal.

master
Julio Biason 15 years ago
parent
commit
ee30e44468
  1. 22
      mitterlib/ui/helpers/gtk_messagegrid.py
  2. 24
      mitterlib/ui/ui_pygtk.py

22
mitterlib/ui/helpers/gtk_messagegrid.py

@ -121,7 +121,6 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
self._grid.connect('cursor-changed', self._message_selected)
self._grid.connect('button-press-event', self._click_message)
self._grid.connect('popup-menu', self._message_popup) # Menu button
self._grid.connect('cursor-changed', self._mark_message_read)
self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
self.add(self._grid)
@ -214,7 +213,11 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
(model, iter) = view.get_selection().get_selected()
if not iter:
return
data = model.get_value(iter, 0)
if not data.read:
self.count -= 1
data.read = True
#self._delete_action.set_property('sensitive', data.deletable)
@ -284,21 +287,6 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
return True
def _mark_message_read(self, widget, user_data=None):
"""Mark a message as read when it's selected."""
(path, _) = widget.get_cursor()
if not path:
return True
iter = widget.get_model().get_iter(path)
message = widget.get_model().get_value(iter, 0)
if message.read:
return True
self.count -= 1
return True
def _order_datetime(self, model, iter1, iter2, user_data=None):
"""Used by the ListStore to sort the columns (in our case, "column")
by date."""
@ -358,6 +346,8 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
store.sort_column_changed()
self._grid.thaw_notify()
self._grid.queue_draw()
self.count += len(messages)
return
def clear_posts(self, widget, user_data=None):

24
mitterlib/ui/ui_pygtk.py

@ -98,6 +98,7 @@ class Interface(object):
self._options[self.NAMESPACE]['unfavorite_char'])
messages.protected_char = (
self._options[self.NAMESPACE]['protected_char'])
messages.connect('count-changed', self._update_message_count)
# replies grid
replies = MessageGrid(self._avatars)
@ -109,10 +110,11 @@ class Interface(object):
self._options[self.NAMESPACE]['unfavorite_char'])
replies.protected_char = (
self._options[self.NAMESPACE]['protected_char'])
replies.connect('count-changed', self._update_replies_count)
self._main_tabs = gtk.Notebook()
self._main_tabs.insert_page(messages, gtk.Label('Messages'))
self._main_tabs.insert_page(replies, gtk.Label('Replies'))
self._main_tabs.insert_page(messages, gtk.Label('Messages (0)'))
self._main_tabs.insert_page(replies, gtk.Label('Replies (0)'))
update_box = gtk.VBox()
update_box.set_property('border_width', 2)
@ -391,6 +393,22 @@ class Interface(object):
# ------------------------------------------------------------
# Widget callback functions
# ------------------------------------------------------------
def _update_message_count(self, widget, data):
"""Callback from the MessageGrid for messages when the number of
messages changes."""
child = self._main_tabs.get_nth_page(0)
message = _('Messages (%d)') % (data)
self._main_tabs.set_tab_label_text(child, message)
return
def _update_replies_count(self, widget, data):
"""Callback from the MessageGrid for replies when the number of
messages changes."""
child = self._main_tabs.get_nth_page(1)
message = _('Replies (%d)') % (data)
self._main_tabs.set_tab_label_text(child, message)
return
def _clear_posts(self, widget):
"""Clear the posts in the currently selected tab."""
page = self._main_tabs.get_current_page()
@ -714,8 +732,6 @@ class Interface(object):
### replies callback
def _post_get_replies(self, widget, results):
"""Called after we retrieve the replies."""
_log.debug("%d new replies", len(results))
grid = self._main_tabs.get_nth_page(1)
grid.update(results)

Loading…
Cancel
Save