diff --git a/mitterlib/ui/helpers/gtk_messagegrid.py b/mitterlib/ui/helpers/gtk_messagegrid.py index 2a3a1b6..58f48c6 100644 --- a/mitterlib/ui/helpers/gtk_messagegrid.py +++ b/mitterlib/ui/helpers/gtk_messagegrid.py @@ -62,10 +62,15 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject): """Custom message grid.""" __gsignals__ = { - "count-changed": ( + "count-changed": ( # the number of unread messages changed gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, - (gobject.TYPE_INT, ))} # The exception + (gobject.TYPE_INT, )), + 'message-changed': ( # the selected message changed + gobject.SIGNAL_RUN_LAST, + gobject.TYPE_NONE, + (gobject.TYPE_PYOBJECT, )) + } @property def count(self): @@ -219,12 +224,7 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject): self.count -= 1 data.read = True - - #self._delete_action.set_property('sensitive', data.deletable) - #self._reply_action.set_property('sensitive', data.replyable) - #self._repost_action.set_property('sensitive', data.repostable) - #self._favorite_action.set_property('sensitive', data.favoritable) - + self.emit('message-changed', data) return 0 def _click_message(self, widget, event, user_data=None): diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index 96720e3..4d61426 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/mitterlib/ui/ui_pygtk.py @@ -99,6 +99,7 @@ class Interface(object): messages.protected_char = ( self._options[self.NAMESPACE]['protected_char']) messages.connect('count-changed', self._update_message_count) + messages.connect('message-changed', self._message_changed) # replies grid replies = MessageGrid(self._avatars) @@ -111,6 +112,7 @@ class Interface(object): replies.protected_char = ( self._options[self.NAMESPACE]['protected_char']) replies.connect('count-changed', self._update_replies_count) + replies.connect('message-changed', self._message_changed) self._main_tabs = gtk.Notebook() self._main_tabs.insert_page(messages, gtk.Label('Messages (0)')) @@ -393,6 +395,16 @@ class Interface(object): # ------------------------------------------------------------ # Widget callback functions # ------------------------------------------------------------ + def _message_changed(self, widget, data): + """Callback from the MesageGrids when the selected message changes.""" + _log.debug('Message changed to: %s', (data.message)) + self._delete_action.set_property('sensitive', data.deletable) + self._reply_action.set_property('sensitive', data.replyable) + self._repost_action.set_property('sensitive', data.repostable) + self._favorite_action.set_property('sensitive', data.favoritable) + + return + def _update_message_count(self, widget, data): """Callback from the MessageGrid for messages when the number of messages changes.""" @@ -464,7 +476,6 @@ class Interface(object): child = self._main_tabs.get_nth_page(page) child.get_child().grab_focus() # notebook have ScrolledWindows, # TreeViews inside that. - self._message_selected(child.get_child()) return def _quit_app(self, widget=None, user_data=None):