Browse Source

Added a "selected" property with the selected message; changed the

signatures for mark_all_read and clear_posts, since they are not
triggered from widgets anymore.
master
Julio Biason 15 years ago
parent
commit
41340e8009
  1. 34
      mitterlib/ui/helpers/gtk_messagegrid.py

34
mitterlib/ui/helpers/gtk_messagegrid.py

@ -86,6 +86,17 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
self.emit('count-changed', messages) self.emit('count-changed', messages)
return return
@property
def selected(self):
"""Return the selected message or None if there is no selected
message."""
(model, iter) = view.get_selection().get_selected()
if not iter:
return None
data = model.get_value(iter, 0)
return data
def __init__(self, avatar_cache): def __init__(self, avatar_cache):
super(MessageGrid, self).__init__() super(MessageGrid, self).__init__()
@ -212,21 +223,16 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
# Widget callbacks # Widget callbacks
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
def _message_selected(self, view, user_data=None): def _message_selected(self, view, user_data=None):
"""Callback when a row in the list is selected. Mostly, we'll check """Callback when a row in the list is selected."""
if the message is from the logged user and we change de "sensitive" message = self.selected
property of the message actions to reflect what the user can and if not message:
cannot do.""" return 0
(model, iter) = view.get_selection().get_selected() if not message.read:
if not iter:
return
data = model.get_value(iter, 0)
if not data.read:
self.count -= 1 self.count -= 1
data.read = True message.read = True
self.emit('message-changed', data) self.emit('message-changed', message)
return 0 return 0
def _click_message(self, widget, event, user_data=None): def _click_message(self, widget, event, user_data=None):
@ -351,13 +357,13 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
self.count += len(messages) self.count += len(messages)
return return
def clear_posts(self, widget, user_data=None): def clear_posts(self):
"""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.count = 0; self.count = 0;
return return
def mark_all_read(self, widget, user_data=None): def mark_all_read(self):
"""Mark all messages as read.""" """Mark all messages as read."""
model = self._grid.get_model() model = self._grid.get_model()
if len(model) == 0: if len(model) == 0:

Loading…
Cancel
Save