Browse Source

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

selects another message.
master
Julio Biason 15 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.""" """Custom message grid."""
__gsignals__ = { __gsignals__ = {
"count-changed": ( "count-changed": ( # the number of unread messages changed
gobject.SIGNAL_RUN_LAST, gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE, 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 @property
def count(self): def count(self):
@ -219,12 +224,7 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
self.count -= 1 self.count -= 1
data.read = True data.read = True
self.emit('message-changed', data)
#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 0 return 0
def _click_message(self, widget, event, user_data=None): 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 = ( messages.protected_char = (
self._options[self.NAMESPACE]['protected_char']) self._options[self.NAMESPACE]['protected_char'])
messages.connect('count-changed', self._update_message_count) messages.connect('count-changed', self._update_message_count)
messages.connect('message-changed', self._message_changed)
# replies grid # replies grid
replies = MessageGrid(self._avatars) replies = MessageGrid(self._avatars)
@ -111,6 +112,7 @@ class Interface(object):
replies.protected_char = ( replies.protected_char = (
self._options[self.NAMESPACE]['protected_char']) self._options[self.NAMESPACE]['protected_char'])
replies.connect('count-changed', self._update_replies_count) replies.connect('count-changed', self._update_replies_count)
replies.connect('message-changed', self._message_changed)
self._main_tabs = gtk.Notebook() self._main_tabs = gtk.Notebook()
self._main_tabs.insert_page(messages, gtk.Label('Messages (0)')) self._main_tabs.insert_page(messages, gtk.Label('Messages (0)'))
@ -393,6 +395,16 @@ class Interface(object):
# ------------------------------------------------------------ # ------------------------------------------------------------
# Widget callback functions # 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): def _update_message_count(self, widget, data):
"""Callback from the MessageGrid for messages when the number of """Callback from the MessageGrid for messages when the number of
messages changes.""" messages changes."""
@ -464,7 +476,6 @@ class Interface(object):
child = self._main_tabs.get_nth_page(page) child = self._main_tabs.get_nth_page(page)
child.get_child().grab_focus() # notebook have ScrolledWindows, child.get_child().grab_focus() # notebook have ScrolledWindows,
# TreeViews inside that. # TreeViews inside that.
self._message_selected(child.get_child())
return return
def _quit_app(self, widget=None, user_data=None): def _quit_app(self, widget=None, user_data=None):

Loading…
Cancel
Save