From c14b8dfb7147f42d870971e591a31ea397653171 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 5 Apr 2010 12:26:08 -0300 Subject: [PATCH] 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. --- mitterlib/ui/ui_pygtk.py | 56 +++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index 64d5505..77e641f 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/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 # definitions inside the XML. - action_group = gtk.ActionGroup('Mitter') + self._action_group = gtk.ActionGroup('Mitter') # Actions related to the UI elements above # Top-level menu actions 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) - action_group.add_action(edit_action) + self._action_group.add_action(edit_action) message_action = gtk.Action('Message', _('_Message'), _('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) - action_group.add_action(view_action) + self._action_group.add_action(view_action) help_action = gtk.Action('Help', _('_Help'), _('Help'), None) - action_group.add_action(help_action) + self._action_group.add_action(help_action) # File actions quit_action = gtk.Action('Quit', _('_Quit'), _('Exit Mitter'), gtk.STOCK_QUIT) 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 refresh_action = gtk.Action('Refresh', _('_Refresh'), _('Update the listing'), gtk.STOCK_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 the message list'), gtk.STOCK_CLEAR) clear_action.connect('activate', self._clear_posts) - action_group.add_action_with_accel(clear_action, 'l') + self._action_group.add_action_with_accel(clear_action, 'l') all_read_action = gtk.Action('AllRead', _('_Mark All Read'), _('Mark all messages as read'), gtk.STOCK_APPLY) 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'), _('Update your status'), gtk.STOCK_ADD) 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') self._cancel_action = gtk.Action('Cancel', _('_Cancel'), _('Cancel the update'), gtk.STOCK_CANCEL) 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') settings_action = gtk.Action('Settings', _('_Settings'), _('Settings'), gtk.STOCK_PREFERENCES) settings_action.connect('activate', self._show_settings) - action_group.add_action(settings_action) + self._action_group.add_action(settings_action) # Message actions new_action = gtk.Action('New', _('_New'), _('Post a new message'), gtk.STOCK_ADD) new_action.connect('activate', self._new_message) - action_group.add_action_with_accel(new_action, 'n') + self._action_group.add_action_with_accel(new_action, 'n') self._delete_action = gtk.Action('Delete', _('_Delete'), _('Delete a post'), gtk.STOCK_DELETE) self._delete_action.set_property('sensitive', False) 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'), _("Send a response to someone's else message"), gtk.STOCK_REDO) self._reply_action.set_property('sensitive', False) self._reply_action.connect('activate', self._reply_message) - action_group.add_action_with_accel(self._reply_action, 'r') + self._action_group.add_action_with_accel(self._reply_action, 'r') self._repost_action = gtk.Action('Repost', _('Re_post'), _("Put someone's else message on your timeline"), gtk.STOCK_CONVERT) self._repost_action.set_property('sensitive', False) self._repost_action.connect('activate', self._repost_message) - action_group.add_action_with_accel(self._repost_action, 'p') + self._action_group.add_action_with_accel(self._repost_action, 'p') self._favorite_action = gtk.Action('Favourite', _('_Favorite'), _('Toggle the favorite status of a message'), gtk.STOCK_ABOUT) self._favorite_action.set_property('sensitive', False) self._favorite_action.connect('activate', self._favorite_message) - action_group.add_action_with_accel(self._favorite_action, 'f') + self._action_group.add_action_with_accel(self._favorite_action, 'f') # view actions view_messages_action = gtk.Action('Messages', _('_Messages'), _('Display messages'), None) view_messages_action.connect('activate', self._change_tab, 0) - action_group.add_action_with_accel(view_messages_action, '1') + self._action_group.add_action_with_accel(view_messages_action, '1') view_replies_action = gtk.Action('Replies', _('_Replies'), _('Display replies'), None) view_replies_action.connect('activate', self._change_tab, 1) - action_group.add_action_with_accel(view_replies_action, '2') + self._action_group.add_action_with_accel(view_replies_action, '2') # Help actions about_action = gtk.Action('About', _('_About'), _('About Mitter'), gtk.STOCK_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 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) main_menu = uimanager.get_widget('/MainMenu') @@ -536,10 +536,13 @@ class Interface(object): def _reply_message(self, widget, user_data=None): """Reply to someone else's message.""" - (grid, _) = self._grids[self._main_tabs.get_current_page()] - (model, iter) = grid.get_selection().get_selected() - message = model.get_value(iter, 0) - self._update_field.text = self._connection.reply_prefix(message) + page = self._main_tabs.get_current_page() + grid = self._main_tabs.get_nth_page(page) + message = grid.selected + if not message: + return + + self._update_field.text = message.reply_prefix self._reply_message_id = message self._update_field.show(message.author) return @@ -952,6 +955,7 @@ class Interface(object): self._refresh_id = None # The auto-refresh manager. self._refresh() gtk.main() + return @classmethod def options(self, options):