From 79491a995c40d320f32cb0c7925c5e22969c08bd Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Sat, 17 Nov 2012 14:37:40 +0000 Subject: [PATCH] 6171: No icon under Places View for mapservices * old way of menutoolbutton was depreacated, could not find workaround via uimanager, so deprecated uimanager way, must be added by code now svn: r20670 --- gramps/gui/views/pageview.py | 11 --- gramps/gui/widgets/menutoolbuttonaction.py | 87 ---------------------- gramps/plugins/lib/libmapservice.py | 2 +- gramps/plugins/lib/libplaceview.py | 53 +++++++------ po/POTFILES.skip | 1 - 5 files changed, 32 insertions(+), 122 deletions(-) delete mode 100644 gramps/gui/widgets/menutoolbuttonaction.py diff --git a/gramps/gui/views/pageview.py b/gramps/gui/views/pageview.py index 431045cc7..9f2db2d2c 100644 --- a/gramps/gui/views/pageview.py +++ b/gramps/gui/views/pageview.py @@ -49,7 +49,6 @@ from gramps.gen.ggettext import gettext as _ #---------------------------------------------------------------- from gramps.gen.errors import WindowActiveError from ..dbguielement import DbGUIElement -from ..widgets.menutoolbuttonaction import MenuToolButtonAction from ..grampsbar import GrampsBar from ..configure import ConfigureDialog from gramps.gen.config import config @@ -431,16 +430,6 @@ class PageView(DbGUIElement): self.action_group.add_actions(self.action_list) if len(self.action_toggle_list) > 0: self.action_group.add_toggle_actions(self.action_toggle_list) - for action_toolmenu in self.action_toolmenu_list: - self.action_toolmenu[action_toolmenu[0]] = \ - MenuToolButtonAction(action_toolmenu[0], #unique name - action_toolmenu[1], #label - action_toolmenu[2], #tooltip - action_toolmenu[3], #callback - action_toolmenu[4] #arrow tooltip - ) - self.action_group.add_action( - self.action_toolmenu[action_toolmenu[0]]) def _add_action(self, name, stock_icon, label, accel=None, tip=None, callback=None): diff --git a/gramps/gui/widgets/menutoolbuttonaction.py b/gramps/gui/widgets/menutoolbuttonaction.py deleted file mode 100644 index 55d9f3eba..000000000 --- a/gramps/gui/widgets/menutoolbuttonaction.py +++ /dev/null @@ -1,87 +0,0 @@ -# -# Gramps - a GTK+/GNOME based genealogy program -# -# Copyright (C) 2009 Benny Malengier -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -# $Id$ - -"MenuToolButtonAction class." - -__all__ = ["MenuToolButtonAction"] - -#------------------------------------------------------------------------- -# -# Python modules -# -#------------------------------------------------------------------------- -import logging -_LOG = logging.getLogger(".widgets.menutoolbuttonaction") - -#------------------------------------------------------------------------- -# -# GTK modules -# -#------------------------------------------------------------------------- -from gi.repository import GObject -from gi.repository import Gtk - -#------------------------------------------------------------------------- -# -# GRAMPS modules -# -#------------------------------------------------------------------------- - - -#------------------------------------------------------------------------- -# -# MenuToolButtonAction class -# -#------------------------------------------------------------------------- -class MenuToolButtonAction(Gtk.Action): - """MenuToolButton action class. - - (A MenuToolButtonAction with menu item doesn't make any sense, - use for toolbar.) - - """ - __gtype_name__ = "MenuToolButtonAction" - - __gsignals__ = { - 'changed': (GObject.SignalFlags.RUN_FIRST, - None, #return value - ()), # arguments - } - - def __init__(self, name, label, tooltip, callback, arrowtooltip): - """Create a new MenuToolButtonAction instance. - - @param name: the name of the action - @type name: str - @param tooltip: tooltip string - @type tooltip: str - - """ - GObject.GObject.__init__(self, name=name, label=label, tooltip=tooltip, - stock_id=None) -##TODO GTK3: following is deprecated, must be replaced by -## Gtk.MenuToolButton.set_related_action(MenuToolButtonAction) in calling class? -## self.set_tool_item_type(Gtk.MenuToolButton) - if callback: - self.connect('activate', callback) - self.arrowtooltip = arrowtooltip - diff --git a/gramps/plugins/lib/libmapservice.py b/gramps/plugins/lib/libmapservice.py index db258e855..1b0a926b4 100644 --- a/gramps/plugins/lib/libmapservice.py +++ b/gramps/plugins/lib/libmapservice.py @@ -84,7 +84,7 @@ class MapService(): None, None if invalid """ return conv_lat_lon(place.get_latitude(), - place.get_longitude(), format) + place.get_longitude(), format) def calc_url(self): """Base class needs to overwrite this, calculation of the self.path""" diff --git a/gramps/plugins/lib/libplaceview.py b/gramps/plugins/lib/libplaceview.py index eecafa21e..db71ad1b6 100644 --- a/gramps/plugins/lib/libplaceview.py +++ b/gramps/plugins/lib/libplaceview.py @@ -150,7 +150,7 @@ class PlaceBaseView(ListView): 'J' : self.jump, 'BackSpace' : self.key_delete, }) - + self.maptoolbtn = None self.additional_uis.append(self.additional_ui()) def navigation_type(self): @@ -161,11 +161,6 @@ class PlaceBaseView(ListView): def define_actions(self): ListView.define_actions(self) - self._add_toolmenu_action('MapsList', _('Loading...'), - _("Attempt to see selected locations with a Map " - "Service (OpenstreetMap, Google Maps, ...)"), - self.gotomap, - _('Select a Map Service')) self._add_action('GotoMap', Gtk.STOCK_JUMP_TO, _('_Look up with Map Service'), callback=self.gotomap, @@ -175,6 +170,13 @@ class PlaceBaseView(ListView): callback=self.filter_editor) self._add_action('QuickReport', None, _("Quick View"), None, None, None) + def set_inactive(self): + """called by viewmanager when moving away from the page + Here we need to remove the menutoolbutton from the menu + """ + tb = self.uistate.viewmanager.uimanager.get_widget('/ToolBar') + tb.remove(self.maptoolbtn) + def change_page(self): """ Called by viewmanager at end of realization when arriving on the page @@ -186,11 +188,18 @@ class PlaceBaseView(ListView): 5. store label so it can be changed when selection changes """ ListView.change_page(self) - #menutoolbutton actions are stored in PageView class, - # obtain the widgets where we need to add to menu - actionservices = self.action_toolmenu['MapsList'] - widgets = actionservices.get_proxies() - mmenu = self.__create_maps_menu_actions() + #menutoolbutton has to be made and added in correct place on toolbar + if not self.maptoolbtn: + self.maptoolbtn = Gtk.MenuToolButton.new_from_stock(Gtk.STOCK_JUMP_TO) + self.maptoolbtn.connect('clicked', self.gotomap) + self.mmenu = self.__create_maps_menu_actions() + self.maptoolbtn.set_menu(self.mmenu) + self.maptoolbtn.show() + tb = self.uistate.viewmanager.uimanager.get_widget('/ToolBar') + ind = tb.get_item_index(self.uistate.viewmanager.uimanager.get_widget( + '/ToolBar/CommonEdit/Merge')) + tb.insert(self.maptoolbtn, ind+1) + widget = self.maptoolbtn if not self.mapservicedata: return @@ -200,16 +209,17 @@ class PlaceBaseView(ListView): #stored val no longer exists, use the first key instead self.set_mapservice(list(self.mapservicedata.keys())[0]) - #store all gtk labels to be able to update label on selection change - for widget in widgets : - if isinstance(widget, Gtk.MenuToolButton): - widget.set_menu(mmenu) - widget.set_arrow_tooltip_text(actionservices.arrowtooltip) - lbl = Gtk.Label(label=self.mapservice_label()) - lbl.show() - self.mapslistlabel.append(lbl) - widget.set_label_widget(self.mapslistlabel[-1]) - widget.set_stock_id(Gtk.STOCK_JUMP_TO) + #store all gtk labels to be able to update label on selection change_('Loading...'), + widget.set_menu(self.mmenu) + widget.set_arrow_tooltip_text(_('Select a Map Service')) + widget.set_tooltip_text( + _("Attempt to see selected locations with a Map " + "Service (OpenstreetMap, Google Maps, ...)")) + lbl = Gtk.Label(label=self.mapservice_label()) + lbl.show() + self.mapslistlabel.append(lbl) + widget.set_label_widget(self.mapslistlabel[-1]) + widget.set_stock_id(Gtk.STOCK_JUMP_TO) if self.drag_info(): self.list.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, [], @@ -341,7 +351,6 @@ class PlaceBaseView(ListView): - diff --git a/po/POTFILES.skip b/po/POTFILES.skip index b93728cb9..42f5858d9 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -376,7 +376,6 @@ gramps/gui/widgets/basicentry.py gramps/gui/widgets/fanchartdesc.py gramps/gui/widgets/linkbox.py gramps/gui/widgets/menuitem.py -gramps/gui/widgets/menutoolbuttonaction.py gramps/gui/widgets/multitreeview.py gramps/gui/widgets/shortlistcomboentry.py gramps/gui/widgets/springseparator.py