From ebf197ad8ec6b02fea6a05dcede01736044c1244 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Fri, 14 Sep 2012 22:44:32 +0000 Subject: [PATCH] Tidy up quick report and webconnect menu code (fix Gtk3 bug) svn: r20390 --- src/gui/views/listview.py | 64 ++++++++++++++-------------- src/plugins/lib/libpersonview.py | 16 +------ src/plugins/lib/libplaceview.py | 12 +----- src/plugins/view/citationlistview.py | 12 +----- src/plugins/view/citationtreeview.py | 12 +----- src/plugins/view/eventview.py | 13 +----- src/plugins/view/familyview.py | 12 +----- src/plugins/view/mediaview.py | 12 +----- src/plugins/view/noteview.py | 14 +----- src/plugins/view/persontreeview.py | 8 +--- src/plugins/view/placetreeview.py | 4 +- src/plugins/view/repoview.py | 13 +----- src/plugins/view/sourceview.py | 12 +----- 13 files changed, 46 insertions(+), 158 deletions(-) diff --git a/src/gui/views/listview.py b/src/gui/views/listview.py index d3ee7e67f..bcf8d51c0 100644 --- a/src/gui/views/listview.py +++ b/src/gui/views/listview.py @@ -802,48 +802,46 @@ class ListView(NavigationView): return True elif gui.utils.is_right_click(event): menu = self.uistate.uimanager.get_widget('/Popup') - #construct quick reports if needed - if menu and self.QR_CATEGORY > -1 : + if menu: + # Quick Reports qr_menu = self.uistate.uimanager.\ - get_widget('/Popup/QuickReport').get_submenu() - if qr_menu : - self.uistate.uimanager.\ - get_widget('/Popup/QuickReport').set_submenu(None) - reportactions = [] - if menu and self.get_active(): - (ui, reportactions) = create_quickreport_menu( + get_widget('/Popup/QuickReport') + if qr_menu and self.QR_CATEGORY > -1 : + (ui, qr_actions) = create_quickreport_menu( self.QR_CATEGORY, self.dbstate, self.uistate, self.first_selected()) - if len(reportactions) > 1 : - qr_menu = Gtk.Menu() - for action in reportactions[1:] : - add_menuitem(qr_menu, action[2], None, action[5]) - self.uistate.uimanager.get_widget('/Popup/QuickReport').\ - set_submenu(qr_menu) - if menu and self.get_active(): - popup = self.uistate.uimanager.get_widget('/Popup/WebConnect') - if popup: - qr_menu = popup.get_submenu() - webconnects = [] - if qr_menu: - popup.set_submenu(None) - webconnects = create_web_connect_menu( - self.dbstate, - self.uistate, - self.navigation_type(), - self.first_selected()) - if len(webconnects) > 1 : - qr_menu = Gtk.Menu() - for action in webconnects[1:] : - add_menuitem(qr_menu, action[2], None, action[5]) - popup.set_submenu(qr_menu) - if menu: + self.__build_menu(qr_menu, qr_actions) + + # Web Connects + web_menu = self.uistate.uimanager.\ + get_widget('/Popup/WebConnect') + if web_menu: + web_actions = create_web_connect_menu( + self.dbstate, + self.uistate, + self.navigation_type(), + self.first_selected()) + self.__build_menu(web_menu, web_actions) + menu.popup(None, None, None, None, event.button, event.time) return True return False + + def __build_menu(self, menu, actions): + """ + Build a submenu for quick reports and web connects + """ + if self.get_active() and len(actions) > 1: + sub_menu = Gtk.Menu() + for action in actions[1:]: + add_menuitem(sub_menu, action[2], None, action[5]) + menu.set_submenu(sub_menu) + menu.show() + else: + menu.hide() def _key_press(self, obj, event): """ diff --git a/src/plugins/lib/libpersonview.py b/src/plugins/lib/libpersonview.py index f64f7ad99..d49a96b6e 100644 --- a/src/plugins/lib/libpersonview.py +++ b/src/plugins/lib/libpersonview.py @@ -241,12 +241,8 @@ class BasePersonView(ListView): - - - - - - + + ''' @@ -324,13 +320,6 @@ class BasePersonView(ListView): self.uistate.set_busy_cursor(False) - def dummy_report(self, obj): - """ For the xml UI definition of popup to work, the submenu - Quick Report must have an entry in the xml - As this submenu will be dynamically built, we offer a dummy action - """ - pass - def define_actions(self): """ Required define_actions function for PageView. Builds the action @@ -357,7 +346,6 @@ class BasePersonView(ListView): "Return", self.EDIT_MSG, self.edit), ('QuickReport', None, _("Quick View"), None, None, None), ('WebConnect', None, _("Web Connection"), None, None, None), - ('Dummy', None, ' ', None, None, self.dummy_report), ]) diff --git a/src/plugins/lib/libplaceview.py b/src/plugins/lib/libplaceview.py index 8296f361d..9a3dad9ab 100644 --- a/src/plugins/lib/libplaceview.py +++ b/src/plugins/lib/libplaceview.py @@ -174,7 +174,6 @@ class PlaceBaseView(ListView): self._add_action('FilterEdit', None, _('Place Filter Editor'), callback=self.filter_editor) self._add_action('QuickReport', None, _("Quick View"), None, None, None) - self._add_action('Dummy', None, ' ', None, None, self.dummy_report) def change_page(self): """ @@ -354,21 +353,12 @@ class PlaceBaseView(ListView): - - - + ''' - def dummy_report(self, obj): - """ For the xml UI definition of popup to work, the submenu - Quick Report must have an entry in the xml - As this submenu will be dynamically built, we offer a dummy action - """ - pass - def add(self, obj): try: EditPlace(self.dbstate, self.uistate, [], gen.lib.Place()) diff --git a/src/plugins/view/citationlistview.py b/src/plugins/view/citationlistview.py index 7b047cf58..6553a6a52 100644 --- a/src/plugins/view/citationlistview.py +++ b/src/plugins/view/citationlistview.py @@ -181,7 +181,6 @@ class CitationListView(ListView): self._add_action('FilterEdit', None, _('Citation Filter Editor'), callback=self.filter_editor,) self._add_action('QuickReport', None, _("Quick View"), None, None, None) - self._add_action('Dummy', None, ' ', None, None, self.dummy_report) self._add_action_group(self.edit_action) self._add_action_group(self.all_action) @@ -244,19 +243,10 @@ class CitationListView(ListView): - - - + ''' - def dummy_report(self, obj): - """ For the xml UI definition of popup to work, the submenu - Quick Report must have an entry in the xml - As this submenu will be dynamically built, we offer a dummy action - """ - pass - def add(self, obj): """ add: Add a new citation and a new source (this can also be done diff --git a/src/plugins/view/citationtreeview.py b/src/plugins/view/citationtreeview.py index 546adc0b6..678c25e35 100644 --- a/src/plugins/view/citationtreeview.py +++ b/src/plugins/view/citationtreeview.py @@ -294,7 +294,6 @@ class CitationTreeView(ListView): self._add_action('FilterEdit', None, _('Citation Filter Editor'), callback=self.filter_editor,) self._add_action('QuickReport', None, _("Quick View"), None, None, None) - self._add_action('Dummy', None, ' ', None, None, self.dummy_report) self._add_action_group(self.edit_action) self._add_action_group(self.all_action) @@ -367,19 +366,10 @@ class CitationTreeView(ListView): - - - + ''' - def dummy_report(self, obj): - """ For the xml UI definition of popup to work, the submenu - Quick Report must have an entry in the xml - As this submenu will be dynamically built, we offer a dummy action - """ - pass - def add_source(self, obj): """ add_source: Add a new source (this is also available from the diff --git a/src/plugins/view/eventview.py b/src/plugins/view/eventview.py index 86e650737..bf9c7fefe 100644 --- a/src/plugins/view/eventview.py +++ b/src/plugins/view/eventview.py @@ -208,9 +208,7 @@ class EventView(ListView): - - - + ''' @@ -220,8 +218,6 @@ class EventView(ListView): callback=self.filter_editor,) self._add_action('QuickReport', None, _("Quick View"), None, None, None) - self._add_action('Dummy', None, - ' ', None, None, self.dummy_report) def get_handle_from_gramps_id(self, gid): obj = self.dbstate.db.get_event_from_gramps_id(gid) @@ -278,13 +274,6 @@ class EventView(ListView): else: MergeEvent(self.dbstate, self.uistate, mlist[0], mlist[1]) - def dummy_report(self, obj): - """ For the xml UI definition of popup to work, the submenu - Quick Report must have an entry in the xml - As this submenu will be dynamically built, we offer a dummy action - """ - pass - def get_default_gramplets(self): """ Define the default gramplets for the sidebar and bottombar. diff --git a/src/plugins/view/familyview.py b/src/plugins/view/familyview.py index 8cd3fc1dd..f92e6b96a 100644 --- a/src/plugins/view/familyview.py +++ b/src/plugins/view/familyview.py @@ -191,9 +191,7 @@ class FamilyView(ListView): - - - + ''' @@ -212,7 +210,6 @@ class FamilyView(ListView): ('MakeMotherActive', Gtk.STOCK_APPLY, _("Make Mother Active Person"), None, None, self._make_mother_active), ('QuickReport', None, _("Quick View"), None, None, None), - ('Dummy', None, ' ', None, None, self.dummy_report), ]) self._add_action_group(self.all_action) @@ -308,13 +305,6 @@ class FamilyView(ListView): if family: self.uistate.set_active(family.mother_handle, 'Person') - def dummy_report(self, obj): - """ For the xml UI definition of popup to work, the submenu - Quick Report must have an entry in the xml - As this submenu will be dynamically built, we offer a dummy action - """ - pass - def drag_info(self): """ Indicate that the drag type is a FAMILY_LINK diff --git a/src/plugins/view/mediaview.py b/src/plugins/view/mediaview.py index bf7ad895e..fdc11b6f4 100644 --- a/src/plugins/view/mediaview.py +++ b/src/plugins/view/mediaview.py @@ -227,7 +227,6 @@ class MediaView(ListView): callback=self.open_containing_folder) self._add_action('QuickReport', None, _("Quick View"), None, None, None) - self._add_action('Dummy', None, ' ', None, None, self.dummy_report) def set_active(self): """ @@ -329,19 +328,10 @@ class MediaView(ListView): - - - + ''' - def dummy_report(self, obj): - """ For the xml UI definition of popup to work, the submenu - Quick Report must have an entry in the xml - As this submenu will be dynamically built, we offer a dummy action - """ - pass - def add(self, obj): """Add a new media object to the media list""" try: diff --git a/src/plugins/view/noteview.py b/src/plugins/view/noteview.py index 15177b254..6cc20311f 100644 --- a/src/plugins/view/noteview.py +++ b/src/plugins/view/noteview.py @@ -195,25 +195,15 @@ class NoteView(ListView): - - - - + + ''' - def dummy_report(self, obj): - """ For the xml UI definition of popup to work, the submenu - Quick Report must have an entry in the xml - As this submenu will be dynamically built, we offer a dummy action - """ - pass - def define_actions(self): ListView.define_actions(self) self._add_action('FilterEdit', None, _('Note Filter Editor'), callback=self.filter_editor,) self._add_action('QuickReport', None, _("Quick View"), None, None, None) - self._add_action('Dummy', None, ' ', None, None, self.dummy_report) def set_active(self): """ diff --git a/src/plugins/view/persontreeview.py b/src/plugins/view/persontreeview.py index a9b9bad23..0ec0cead6 100644 --- a/src/plugins/view/persontreeview.py +++ b/src/plugins/view/persontreeview.py @@ -155,12 +155,8 @@ class PersonTreeView(BasePersonView): - - - - - - + + ''' diff --git a/src/plugins/view/placetreeview.py b/src/plugins/view/placetreeview.py index 75be81d97..bf1357694 100644 --- a/src/plugins/view/placetreeview.py +++ b/src/plugins/view/placetreeview.py @@ -184,9 +184,7 @@ class PlaceTreeView(PlaceBaseView): - - - + diff --git a/src/plugins/view/repoview.py b/src/plugins/view/repoview.py index 6be7e81e6..9a75bef3b 100644 --- a/src/plugins/view/repoview.py +++ b/src/plugins/view/repoview.py @@ -151,8 +151,6 @@ class RepositoryView(ListView): callback=self.filter_editor,) self._add_action('QuickReport', None, _("Quick View"), None, None, None) - self._add_action('Dummy', None, - ' ', None, None, self.dummy_report) def get_stock(self): return 'gramps-repository' @@ -209,9 +207,7 @@ class RepositoryView(ListView): - - - + ''' @@ -262,13 +258,6 @@ class RepositoryView(ListView): else: return None - def dummy_report(self, obj): - """ For the xml UI definition of popup to work, the submenu - Quick Report must have an entry in the xml - As this submenu will be dynamically built, we offer a dummy action - """ - pass - def get_default_gramplets(self): """ Define the default gramplets for the sidebar and bottombar. diff --git a/src/plugins/view/sourceview.py b/src/plugins/view/sourceview.py index e6eb7efdd..2e3081976 100644 --- a/src/plugins/view/sourceview.py +++ b/src/plugins/view/sourceview.py @@ -137,7 +137,6 @@ class SourceView(ListView): self._add_action('FilterEdit', None, _('Source Filter Editor'), callback=self.filter_editor,) self._add_action('QuickReport', None, _("Quick View"), None, None, None) - self._add_action('Dummy', None, ' ', None, None, self.dummy_report) def get_stock(self): return 'gramps-source' @@ -194,19 +193,10 @@ class SourceView(ListView): - - - + ''' - def dummy_report(self, obj): - """ For the xml UI definition of popup to work, the submenu - Quick Report must have an entry in the xml - As this submenu will be dynamically built, we offer a dummy action - """ - pass - def add(self, obj): EditSource(self.dbstate, self.uistate, [], gen.lib.Source())