Browse Source

Added a 'message-changed' signal, so grids can signal when the user

selects another message.
master
Julio Biason 14 years ago
parent
commit
dfbc09c041
  1. 16
      mitterlib/ui/helpers/gtk_messagegrid.py
  2. 13
      mitterlib/ui/ui_pygtk.py

16
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):

13
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):

Loading…
Cancel
Save