diff --git a/src/Config/_GrampsConfigKeys.py b/src/Config/_GrampsConfigKeys.py
index 53dc0632c..711e6ee4f 100644
--- a/src/Config/_GrampsConfigKeys.py
+++ b/src/Config/_GrampsConfigKeys.py
@@ -208,6 +208,7 @@ GEOVIEW_ZOOM = ('geoview', 'zoom', 1)
GEOVIEW_LATITUDE = ('geoview', 'latitude', 2)
GEOVIEW_LONGITUDE = ('geoview', 'longitude', 2)
GEOVIEW_MAP = ('geoview', 'map', 2)
+GEOVIEW_STYLESHEET = ('geoview', 'stylesheet', 2)
default_value = {
DEFAULT_SOURCE : False,
@@ -368,4 +369,5 @@ default_value = {
GEOVIEW_LATITUDE : "0.0",
GEOVIEW_LONGITUDE : "0.0",
GEOVIEW_MAP : "person",
+ GEOVIEW_STYLESHEET : "",
}
diff --git a/src/DataViews/GeoView.py b/src/DataViews/GeoView.py
index f1787d8ab..4f5ca4ab5 100644
--- a/src/DataViews/GeoView.py
+++ b/src/DataViews/GeoView.py
@@ -56,6 +56,9 @@ import gtk
import gen.lib
import Utils
import Config
+import PageView
+from gui.utils import add_menuitem
+from ReportBase import CSS_FILES
from BasicUtils import name_displayer as _nd
from PlaceUtils import conv_lat_lon
@@ -109,6 +112,7 @@ _HTMLHEADER = '''
This is used to pass messages between javascript and python
+ {css}
+
@@ -477,6 +489,80 @@ class GeoView(HtmlView):
self._add_action('EventMaps', 'gramps-event', _('_Event'),
callback=self._event_places,
tip=_("Attempt to view places connected to all events."))
+ self._add_toolmenu_action('StyleSheet', _('Selecting stylesheet ...'),
+ _("Reload the map with new style."),
+ self.gotostyle,
+ _('Select a StyleSheet'))
+
+ def change_page(self):
+ """
+ Called by viewmanager at end of realization when arriving on the page
+ At this point the Toolbar is created. We need to:
+ 1. get the menutoolbutton
+ 2. add all possible css styles sheet available
+ 3. add the actions that correspond to clicking in this drop down menu
+ 4. set icon and label of the menutoolbutton now that it is realized
+ 5. store label so it can be changed when selection changes
+ """
+ PageView.PageView.change_page(self)
+ #menutoolbutton actions are stored in PageView class,
+ # obtain the widgets where we need to add to menu
+ actionstyles = self.action_toolmenu['StyleSheet']
+ widgets = actionstyles.get_proxies()
+ mmenu = self.__create_styles_menu_actions()
+
+ if not self.stylesheetdata:
+ return
+
+ self.stylesheetlabel = []
+
+ #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)
+ if gtk.pygtk_version >= (2, 12, 0):
+ widget.set_arrow_tooltip_text(actionstyles.arrowtooltip)
+ lbl = gtk.Label(self.mapstyle_label())
+ lbl.show()
+ self.stylesheetlabel.append(lbl)
+ widget.set_label_widget(self.stylesheetlabel[-1])
+ widget.set_stock_id(gtk.STOCK_SELECT_FONT)
+
+ def __create_styles_menu_actions(self):
+ """
+ Function creating a menu and actions that are used as dropdown menu
+ from the menutoolbutton
+ """
+ menu = gtk.Menu()
+ #select the stylesheets to show
+ self.stylesheetdata = {}
+ stylelist = []
+ for style in CSS_FILES:
+ stylelist.append([style[0], style[1]])
+ for i, stylesheet in zip(range(len(stylelist)), stylelist):
+ key = stylesheet[0].replace(' ', '-')
+ add_menuitem(menu, stylesheet[0], stylesheet[1] ,
+ make_callback(self.set_mapstylesheet, stylesheet[1]))
+ self.stylesheetdata[key] = stylesheet[0]
+ return menu
+
+ def mapstyle_label(self):
+ """
+ return the current label for the menutoolbutton
+ """
+ return self.stylesheet
+
+ def set_mapstylesheet(self, obj):
+ """
+ Set the style of the map view
+ """
+ self.stylesheet = obj
+
+ def gotostyle(self, obj):
+ """
+ Change the style of the map view
+ """
+ self._geo_places()
def goto_active_person(self, handle=None):
"""
@@ -598,6 +684,7 @@ class GeoView(HtmlView):
%(title)s
+ %(css)s
@@ -605,7 +692,8 @@ class GeoView(HtmlView):
'content': _('Here is the list of all places in the family tree'
' for which we have no coordinates.
'
' This means no longitude or latitude.'),
- 'back' : _('Back to prior page')
+ 'back' : _('Back to prior page'),
+ 'css' : self._add_stylesheet()
}
end = """
@@ -653,8 +741,8 @@ class GeoView(HtmlView):
self.mapview.write("\n")
self.mapview.write("\n")
self.mapview.write("
\n")
- self.mapview.write("\n")
if maxpages > 1:
message = _("There are %d markers to display. They are split up "
@@ -730,12 +818,12 @@ class GeoView(HtmlView):
self.mapview.write("
\n")
self.mapview.write("\n" % (self.height * 0.74))
self.mapview.write("\n" % \
((self.width - margin*4), (self.height * 0.74 )))
self.mapview.write("\n")
+ self.mapview.write("\n%s" % self._add_stylesheet())
if _alternate_map() == "microsoft":
self.mapview.write("