Tidy up quick report and webconnect menu code (fix Gtk3 bug)

svn: r20390
This commit is contained in:
Nick Hall 2012-09-14 22:44:32 +00:00
parent 7c1e29aa60
commit ebf197ad8e
13 changed files with 46 additions and 158 deletions

View File

@ -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):
"""

View File

@ -241,12 +241,8 @@ class BasePersonView(ListView):
<menuitem action="Remove"/>
<menuitem action="Merge"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
<menu name="WebConnect" action="WebConnect">
<menuitem action="Dummy"/>
</menu>
<menu name="QuickReport" action="QuickReport"/>
<menu name="WebConnect" action="WebConnect"/>
</popup>
</ui>'''
@ -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):
"<PRIMARY>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),
])

View File

@ -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):
<menuitem action="Remove"/>
<menuitem action="Merge"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
<menu name="QuickReport" action="QuickReport"/>
<separator/>
<menuitem action="GotoMap"/>
</popup>
</ui>'''
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())

View File

@ -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):
<menuitem action="Remove"/>
<menuitem action="Merge"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
<menu name="QuickReport" action="QuickReport"/>
</popup>
</ui>'''
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

View File

@ -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):
<menuitem action="Remove"/>
<menuitem action="Merge"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
<menu name="QuickReport" action="QuickReport"/>
</popup>
</ui>'''
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

View File

@ -208,9 +208,7 @@ class EventView(ListView):
<menuitem action="Remove"/>
<menuitem action="Merge"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
<menu name="QuickReport" action="QuickReport"/>
</popup>
</ui>'''
@ -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.

View File

@ -191,9 +191,7 @@ class FamilyView(ListView):
<menuitem action="MakeFatherActive"/>
<menuitem action="MakeMotherActive"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
<menu name="QuickReport" action="QuickReport"/>
</popup>
</ui>'''
@ -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

View File

@ -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):
<menuitem action="Remove"/>
<menuitem action="Merge"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
<menu name="QuickReport" action="QuickReport"/>
</popup>
</ui>'''
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:

View File

@ -195,25 +195,15 @@ class NoteView(ListView):
<menuitem action="Remove"/>
<menuitem action="Merge"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
</popup>
<menu name="QuickReport" action="QuickReport"/>
</popup>
</ui>'''
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):
"""

View File

@ -155,12 +155,8 @@ class PersonTreeView(BasePersonView):
<menuitem action="Remove"/>
<menuitem action="Merge"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
<menu name="WebConnect" action="WebConnect">
<menuitem action="Dummy"/>
</menu>
<menu name="QuickReport" action="QuickReport"/>
<menu name="WebConnect" action="WebConnect"/>
</popup>
</ui>'''

View File

@ -184,9 +184,7 @@ class PlaceTreeView(PlaceBaseView):
<menuitem action="Remove"/>
<menuitem action="Merge"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
<menu name="QuickReport" action="QuickReport"/>
<separator/>
<menuitem action="GotoMap"/>
</popup>

View File

@ -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):
<menuitem action="Remove"/>
<menuitem action="Merge"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
<menu name="QuickReport" action="QuickReport"/>
</popup>
</ui>'''
@ -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.

View File

@ -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):
<menuitem action="Remove"/>
<menuitem action="Merge"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
<menu name="QuickReport" action="QuickReport"/>
</popup>
</ui>'''
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())