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

Loading…
Cancel
Save