Browse Source

Fixed the reply message problem; startign to "expose" the action group

to the whole interface, as the idea is to replace the several actions
around the code to simply call them directly from the action group.
master
Julio Biason 15 years ago
parent
commit
c14b8dfb71
  1. 56
      mitterlib/ui/ui_pygtk.py

56
mitterlib/ui/ui_pygtk.py

@ -205,118 +205,118 @@ class Interface(object):
# The group with all actions; we are going to split them using the # The group with all actions; we are going to split them using the
# definitions inside the XML. # definitions inside the XML.
action_group = gtk.ActionGroup('Mitter') self._action_group = gtk.ActionGroup('Mitter')
# Actions related to the UI elements above # Actions related to the UI elements above
# Top-level menu actions # Top-level menu actions
file_action = gtk.Action('File', _('_File'), _('File'), None) file_action = gtk.Action('File', _('_File'), _('File'), None)
action_group.add_action(file_action) self._action_group.add_action(file_action)
edit_action = gtk.Action('Edit', _('_Edit'), _('Edit'), None) edit_action = gtk.Action('Edit', _('_Edit'), _('Edit'), None)
action_group.add_action(edit_action) self._action_group.add_action(edit_action)
message_action = gtk.Action('Message', _('_Message'), message_action = gtk.Action('Message', _('_Message'),
_('Message related options'), None) _('Message related options'), None)
action_group.add_action(message_action) self._action_group.add_action(message_action)
view_action = gtk.Action('View', _('_View'), _('View'), None) view_action = gtk.Action('View', _('_View'), _('View'), None)
action_group.add_action(view_action) self._action_group.add_action(view_action)
help_action = gtk.Action('Help', _('_Help'), _('Help'), None) help_action = gtk.Action('Help', _('_Help'), _('Help'), None)
action_group.add_action(help_action) self._action_group.add_action(help_action)
# File actions # File actions
quit_action = gtk.Action('Quit', _('_Quit'), quit_action = gtk.Action('Quit', _('_Quit'),
_('Exit Mitter'), gtk.STOCK_QUIT) _('Exit Mitter'), gtk.STOCK_QUIT)
quit_action.connect('activate', self._quit_app) quit_action.connect('activate', self._quit_app)
action_group.add_action_with_accel(quit_action, None) self._action_group.add_action_with_accel(quit_action, None)
# Edit actions # Edit actions
refresh_action = gtk.Action('Refresh', _('_Refresh'), refresh_action = gtk.Action('Refresh', _('_Refresh'),
_('Update the listing'), gtk.STOCK_REFRESH) _('Update the listing'), gtk.STOCK_REFRESH)
refresh_action.connect('activate', self._refresh) refresh_action.connect('activate', self._refresh)
action_group.add_action_with_accel(refresh_action, None) self._action_group.add_action_with_accel(refresh_action, None)
clear_action = gtk.Action('Clear', _('_Clear'), clear_action = gtk.Action('Clear', _('_Clear'),
_('Clear the message list'), gtk.STOCK_CLEAR) _('Clear the message list'), gtk.STOCK_CLEAR)
clear_action.connect('activate', self._clear_posts) clear_action.connect('activate', self._clear_posts)
action_group.add_action_with_accel(clear_action, '<Ctrl>l') self._action_group.add_action_with_accel(clear_action, '<Ctrl>l')
all_read_action = gtk.Action('AllRead', _('_Mark All Read'), all_read_action = gtk.Action('AllRead', _('_Mark All Read'),
_('Mark all messages as read'), gtk.STOCK_APPLY) _('Mark all messages as read'), gtk.STOCK_APPLY)
all_read_action.connect('activate', self._mark_all_read) all_read_action.connect('activate', self._mark_all_read)
action_group.add_action(all_read_action) self._action_group.add_action(all_read_action)
self._update_action = gtk.Action('Update', _('_Update'), self._update_action = gtk.Action('Update', _('_Update'),
_('Update your status'), gtk.STOCK_ADD) _('Update your status'), gtk.STOCK_ADD)
self._update_action.connect('activate', self._update_status) self._update_action.connect('activate', self._update_status)
action_group.add_action_with_accel(self._update_action, self._action_group.add_action_with_accel(self._update_action,
'Return') 'Return')
self._cancel_action = gtk.Action('Cancel', _('_Cancel'), self._cancel_action = gtk.Action('Cancel', _('_Cancel'),
_('Cancel the update'), gtk.STOCK_CANCEL) _('Cancel the update'), gtk.STOCK_CANCEL)
self._cancel_action.connect('activate', self._clear_text) self._cancel_action.connect('activate', self._clear_text)
action_group.add_action_with_accel(self._cancel_action, self._action_group.add_action_with_accel(self._cancel_action,
'Escape') 'Escape')
settings_action = gtk.Action('Settings', _('_Settings'), settings_action = gtk.Action('Settings', _('_Settings'),
_('Settings'), gtk.STOCK_PREFERENCES) _('Settings'), gtk.STOCK_PREFERENCES)
settings_action.connect('activate', self._show_settings) settings_action.connect('activate', self._show_settings)
action_group.add_action(settings_action) self._action_group.add_action(settings_action)
# Message actions # Message actions
new_action = gtk.Action('New', _('_New'), new_action = gtk.Action('New', _('_New'),
_('Post a new message'), gtk.STOCK_ADD) _('Post a new message'), gtk.STOCK_ADD)
new_action.connect('activate', self._new_message) new_action.connect('activate', self._new_message)
action_group.add_action_with_accel(new_action, '<Ctrl>n') self._action_group.add_action_with_accel(new_action, '<Ctrl>n')
self._delete_action = gtk.Action('Delete', _('_Delete'), self._delete_action = gtk.Action('Delete', _('_Delete'),
_('Delete a post'), gtk.STOCK_DELETE) _('Delete a post'), gtk.STOCK_DELETE)
self._delete_action.set_property('sensitive', False) self._delete_action.set_property('sensitive', False)
self._delete_action.connect('activate', self._delete_message) self._delete_action.connect('activate', self._delete_message)
action_group.add_action_with_accel(self._delete_action, 'Delete') self._action_group.add_action_with_accel(self._delete_action, 'Delete')
self._reply_action = gtk.Action('Reply', _('_Reply'), self._reply_action = gtk.Action('Reply', _('_Reply'),
_("Send a response to someone's else message"), _("Send a response to someone's else message"),
gtk.STOCK_REDO) gtk.STOCK_REDO)
self._reply_action.set_property('sensitive', False) self._reply_action.set_property('sensitive', False)
self._reply_action.connect('activate', self._reply_message) self._reply_action.connect('activate', self._reply_message)
action_group.add_action_with_accel(self._reply_action, '<Ctrl>r') self._action_group.add_action_with_accel(self._reply_action, '<Ctrl>r')
self._repost_action = gtk.Action('Repost', _('Re_post'), self._repost_action = gtk.Action('Repost', _('Re_post'),
_("Put someone's else message on your timeline"), _("Put someone's else message on your timeline"),
gtk.STOCK_CONVERT) gtk.STOCK_CONVERT)
self._repost_action.set_property('sensitive', False) self._repost_action.set_property('sensitive', False)
self._repost_action.connect('activate', self._repost_message) self._repost_action.connect('activate', self._repost_message)
action_group.add_action_with_accel(self._repost_action, '<Ctrl>p') self._action_group.add_action_with_accel(self._repost_action, '<Ctrl>p')
self._favorite_action = gtk.Action('Favourite', _('_Favorite'), self._favorite_action = gtk.Action('Favourite', _('_Favorite'),
_('Toggle the favorite status of a message'), _('Toggle the favorite status of a message'),
gtk.STOCK_ABOUT) gtk.STOCK_ABOUT)
self._favorite_action.set_property('sensitive', False) self._favorite_action.set_property('sensitive', False)
self._favorite_action.connect('activate', self._favorite_message) self._favorite_action.connect('activate', self._favorite_message)
action_group.add_action_with_accel(self._favorite_action, '<Ctrl>f') self._action_group.add_action_with_accel(self._favorite_action, '<Ctrl>f')
# view actions # view actions
view_messages_action = gtk.Action('Messages', _('_Messages'), view_messages_action = gtk.Action('Messages', _('_Messages'),
_('Display messages'), None) _('Display messages'), None)
view_messages_action.connect('activate', self._change_tab, 0) view_messages_action.connect('activate', self._change_tab, 0)
action_group.add_action_with_accel(view_messages_action, '<Alt>1') self._action_group.add_action_with_accel(view_messages_action, '<Alt>1')
view_replies_action = gtk.Action('Replies', _('_Replies'), view_replies_action = gtk.Action('Replies', _('_Replies'),
_('Display replies'), None) _('Display replies'), None)
view_replies_action.connect('activate', self._change_tab, 1) view_replies_action.connect('activate', self._change_tab, 1)
action_group.add_action_with_accel(view_replies_action, '<Alt>2') self._action_group.add_action_with_accel(view_replies_action, '<Alt>2')
# Help actions # Help actions
about_action = gtk.Action('About', _('_About'), _('About Mitter'), about_action = gtk.Action('About', _('_About'), _('About Mitter'),
gtk.STOCK_ABOUT) gtk.STOCK_ABOUT)
about_action.connect('activate', self._show_about) about_action.connect('activate', self._show_about)
action_group.add_action(about_action) self._action_group.add_action(about_action)
# definition of the UI # definition of the UI
uimanager = gtk.UIManager() uimanager = gtk.UIManager()
uimanager.insert_action_group(action_group, 0) uimanager.insert_action_group(self._action_group, 0)
uimanager.add_ui_from_string(ui_elements) uimanager.add_ui_from_string(ui_elements)
main_menu = uimanager.get_widget('/MainMenu') main_menu = uimanager.get_widget('/MainMenu')
@ -536,10 +536,13 @@ class Interface(object):
def _reply_message(self, widget, user_data=None): def _reply_message(self, widget, user_data=None):
"""Reply to someone else's message.""" """Reply to someone else's message."""
(grid, _) = self._grids[self._main_tabs.get_current_page()] page = self._main_tabs.get_current_page()
(model, iter) = grid.get_selection().get_selected() grid = self._main_tabs.get_nth_page(page)
message = model.get_value(iter, 0) message = grid.selected
self._update_field.text = self._connection.reply_prefix(message) if not message:
return
self._update_field.text = message.reply_prefix
self._reply_message_id = message self._reply_message_id = message
self._update_field.show(message.author) self._update_field.show(message.author)
return return
@ -952,6 +955,7 @@ class Interface(object):
self._refresh_id = None # The auto-refresh manager. self._refresh_id = None # The auto-refresh manager.
self._refresh() self._refresh()
gtk.main() gtk.main()
return
@classmethod @classmethod
def options(self, options): def options(self, options):

Loading…
Cancel
Save