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
This commit is contained in:
parent
95e7a74f42
commit
79491a995c
@ -49,7 +49,6 @@ from gramps.gen.ggettext import gettext as _
|
|||||||
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
||||||
from gramps.gen.errors import WindowActiveError
|
from gramps.gen.errors import WindowActiveError
|
||||||
from ..dbguielement import DbGUIElement
|
from ..dbguielement import DbGUIElement
|
||||||
from ..widgets.menutoolbuttonaction import MenuToolButtonAction
|
|
||||||
from ..grampsbar import GrampsBar
|
from ..grampsbar import GrampsBar
|
||||||
from ..configure import ConfigureDialog
|
from ..configure import ConfigureDialog
|
||||||
from gramps.gen.config import config
|
from gramps.gen.config import config
|
||||||
@ -431,16 +430,6 @@ class PageView(DbGUIElement):
|
|||||||
self.action_group.add_actions(self.action_list)
|
self.action_group.add_actions(self.action_list)
|
||||||
if len(self.action_toggle_list) > 0:
|
if len(self.action_toggle_list) > 0:
|
||||||
self.action_group.add_toggle_actions(self.action_toggle_list)
|
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,
|
def _add_action(self, name, stock_icon, label, accel=None, tip=None,
|
||||||
callback=None):
|
callback=None):
|
||||||
|
@ -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
|
|
||||||
|
|
@ -150,7 +150,7 @@ class PlaceBaseView(ListView):
|
|||||||
'<PRIMARY>J' : self.jump,
|
'<PRIMARY>J' : self.jump,
|
||||||
'<PRIMARY>BackSpace' : self.key_delete,
|
'<PRIMARY>BackSpace' : self.key_delete,
|
||||||
})
|
})
|
||||||
|
self.maptoolbtn = None
|
||||||
self.additional_uis.append(self.additional_ui())
|
self.additional_uis.append(self.additional_ui())
|
||||||
|
|
||||||
def navigation_type(self):
|
def navigation_type(self):
|
||||||
@ -161,11 +161,6 @@ class PlaceBaseView(ListView):
|
|||||||
|
|
||||||
def define_actions(self):
|
def define_actions(self):
|
||||||
ListView.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,
|
self._add_action('GotoMap', Gtk.STOCK_JUMP_TO,
|
||||||
_('_Look up with Map Service'),
|
_('_Look up with Map Service'),
|
||||||
callback=self.gotomap,
|
callback=self.gotomap,
|
||||||
@ -175,6 +170,13 @@ class PlaceBaseView(ListView):
|
|||||||
callback=self.filter_editor)
|
callback=self.filter_editor)
|
||||||
self._add_action('QuickReport', None, _("Quick View"), None, None, None)
|
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):
|
def change_page(self):
|
||||||
"""
|
"""
|
||||||
Called by viewmanager at end of realization when arriving on the page
|
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
|
5. store label so it can be changed when selection changes
|
||||||
"""
|
"""
|
||||||
ListView.change_page(self)
|
ListView.change_page(self)
|
||||||
#menutoolbutton actions are stored in PageView class,
|
#menutoolbutton has to be made and added in correct place on toolbar
|
||||||
# obtain the widgets where we need to add to menu
|
if not self.maptoolbtn:
|
||||||
actionservices = self.action_toolmenu['MapsList']
|
self.maptoolbtn = Gtk.MenuToolButton.new_from_stock(Gtk.STOCK_JUMP_TO)
|
||||||
widgets = actionservices.get_proxies()
|
self.maptoolbtn.connect('clicked', self.gotomap)
|
||||||
mmenu = self.__create_maps_menu_actions()
|
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:
|
if not self.mapservicedata:
|
||||||
return
|
return
|
||||||
@ -200,11 +209,12 @@ class PlaceBaseView(ListView):
|
|||||||
#stored val no longer exists, use the first key instead
|
#stored val no longer exists, use the first key instead
|
||||||
self.set_mapservice(list(self.mapservicedata.keys())[0])
|
self.set_mapservice(list(self.mapservicedata.keys())[0])
|
||||||
|
|
||||||
#store all gtk labels to be able to update label on selection change
|
#store all gtk labels to be able to update label on selection change_('Loading...'),
|
||||||
for widget in widgets :
|
widget.set_menu(self.mmenu)
|
||||||
if isinstance(widget, Gtk.MenuToolButton):
|
widget.set_arrow_tooltip_text(_('Select a Map Service'))
|
||||||
widget.set_menu(mmenu)
|
widget.set_tooltip_text(
|
||||||
widget.set_arrow_tooltip_text(actionservices.arrowtooltip)
|
_("Attempt to see selected locations with a Map "
|
||||||
|
"Service (OpenstreetMap, Google Maps, ...)"))
|
||||||
lbl = Gtk.Label(label=self.mapservice_label())
|
lbl = Gtk.Label(label=self.mapservice_label())
|
||||||
lbl.show()
|
lbl.show()
|
||||||
self.mapslistlabel.append(lbl)
|
self.mapslistlabel.append(lbl)
|
||||||
@ -341,7 +351,6 @@ class PlaceBaseView(ListView):
|
|||||||
<toolitem action="Remove"/>
|
<toolitem action="Remove"/>
|
||||||
<toolitem action="Merge"/>
|
<toolitem action="Merge"/>
|
||||||
<separator/>
|
<separator/>
|
||||||
<toolitem action="MapsList"/>
|
|
||||||
</placeholder>
|
</placeholder>
|
||||||
</toolbar>
|
</toolbar>
|
||||||
<popup name="Popup">
|
<popup name="Popup">
|
||||||
|
@ -376,7 +376,6 @@ gramps/gui/widgets/basicentry.py
|
|||||||
gramps/gui/widgets/fanchartdesc.py
|
gramps/gui/widgets/fanchartdesc.py
|
||||||
gramps/gui/widgets/linkbox.py
|
gramps/gui/widgets/linkbox.py
|
||||||
gramps/gui/widgets/menuitem.py
|
gramps/gui/widgets/menuitem.py
|
||||||
gramps/gui/widgets/menutoolbuttonaction.py
|
|
||||||
gramps/gui/widgets/multitreeview.py
|
gramps/gui/widgets/multitreeview.py
|
||||||
gramps/gui/widgets/shortlistcomboentry.py
|
gramps/gui/widgets/shortlistcomboentry.py
|
||||||
gramps/gui/widgets/springseparator.py
|
gramps/gui/widgets/springseparator.py
|
||||||
|
Loading…
Reference in New Issue
Block a user