diff --git a/src/DataViews/GeoView.py b/src/DataViews/GeoView.py
index d3c512dc5..52b13cd4f 100644
--- a/src/DataViews/GeoView.py
+++ b/src/DataViews/GeoView.py
@@ -71,22 +71,22 @@ WEBKIT = 1
MOZIL = 2
URL_SEP = '/'
-WebKit = NOWEB
+TOOLKIT = NOWEB
try:
import webkit
- WebKit = WEBKIT
+ TOOLKIT = WEBKIT
except:
pass
-if WebKit == NOWEB:
+if TOOLKIT == NOWEB:
try:
import gtkmozembed
- WebKit = MOZIL
+ TOOLKIT = MOZIL
except:
pass
#no interfaces present, raise Error so that options for GeoView do not show
-if WebKit == NOWEB :
+if TOOLKIT == NOWEB :
Config.set(Config.GEOVIEW, False)
raise ImportError, 'No GTK html plugin found'
@@ -102,6 +102,25 @@ MOZEMBED_SUBPATH = Utils.get_empty_tempdir('mozembed_gramps')
GEOVIEW_SUBPATH = Utils.get_empty_tempdir('geoview')
NB_MARKERS_PER_PAGE = 200
+#-------------------------------------------------------------------------
+#
+# Functions
+#
+#-------------------------------------------------------------------------
+def _alternate_map():
+ """
+ return the alternate name of the map provider.
+ """
+ if Config.get(Config.GEOVIEW_GOOGLEMAPS):
+ alternate_map = "google"
+ elif Config.get(Config.GEOVIEW_OPENLAYERS):
+ alternate_map = "openlayers"
+ elif Config.get(Config.GEOVIEW_YAHOO):
+ alternate_map = "yahoo"
+ elif Config.get(Config.GEOVIEW_MICROSOFT):
+ alternate_map = "microsoft"
+ return alternate_map
+
#-------------------------------------------------------------------------
#
# Renderer
@@ -177,7 +196,7 @@ class Renderer(object):
"""
raise NotImplementedError
- def page_loaded(self):
+ def page_loaded(self, *args):
"""
The page is completely loaded.
"""
@@ -205,7 +224,7 @@ class RendererWebkit(Renderer):
self.frame = self.window.get_main_frame()
self.frame.connect("load-done", self.page_loaded)
- def page_loaded(self, obj, status):
+ def page_loaded(self, *args):
"""
We just loaded one page in the browser.
Set the button sensitivity
@@ -252,7 +271,7 @@ class RendererMozilla(Renderer):
self.browser = MOZIL
self.handler = self.window.connect("net-stop", self.page_loaded)
- def page_loaded(self, obj):
+ def page_loaded(self, *args):
"""
We just loaded one page in the browser.
Set the button sensitivity
@@ -372,7 +391,7 @@ class HtmlView(PageView.PageView):
contains the interface. This containter will be inserted into
a gtk.Notebook page.
"""
- global WebKit
+ #WebKit
self.box = gtk.VBox(False, 4)
#top widget at the top
self.box.pack_start(self.top_widget(), False, False, 0 )
@@ -387,10 +406,10 @@ class HtmlView(PageView.PageView):
self.table.get_parent().set_shadow_type(gtk.SHADOW_NONE)
self.table.set_row_spacings(1)
self.table.set_col_spacings(0)
- if (WebKit == WEBKIT) :
+ if (TOOLKIT == WEBKIT) :
# We use webkit
self.renderer = RendererWebkit()
- elif (WebKit == MOZIL) :
+ elif (TOOLKIT == MOZIL) :
# We use gtkmozembed
self.renderer = RendererMozilla()
self.table.add(self.renderer.get_window())
@@ -400,7 +419,7 @@ class HtmlView(PageView.PageView):
self.renderer.fct = self.set_button_sensitivity
self.renderer.show_all()
#load a welcome html page
- urlhelp = self.create_start_page()
+ urlhelp = self._create_start_page()
self.open(urlhelp)
return self.box
@@ -554,7 +573,7 @@ class HtmlView(PageView.PageView):
"""
pass
- def create_start_page(self):
+ def _create_start_page(self):
"""
This command creates a default start page, and returns the URL of this
page.
@@ -655,10 +674,10 @@ class GeoView(HtmlView):
able to access the parent container.
"""
self.box.disconnect(self.bootstrap_handler)
- self.box.parent.connect("size-allocate", self.size_request_for_map)
- self.size_request_for_map(widget.parent, event)
+ self.box.parent.connect("size-allocate", self._size_request_for_map)
+ self._size_request_for_map(widget.parent, event)
- def size_request_for_map(self, widget, event, data=None):
+ def _size_request_for_map(self, widget, event, data=None):
"""
We need to resize the map
"""
@@ -669,52 +688,30 @@ class GeoView(HtmlView):
self.external_uri()
if self.need_to_resize != True:
try:
- self.geo_places(self.displaytype)
+ self._geo_places(self.displaytype)
except:
pass
def set_active(self):
"""
- Here when we enter in this view.
+ Set view active when we enter into this view.
"""
self.key_active_changed = self.dbstate.connect('active-changed',
self.goto_active_person)
def set_inactive(self):
"""
- Here when we go to another view.
+ Set view inactive when switching to another view.
"""
HtmlView.set_inactive(self)
self.dbstate.disconnect(self.key_active_changed)
- def get_stock(self):
+ def _change_map(self, usedmap):
"""
- Returns the name of the stock icon to use for the display.
- This assumes that this icon has already been registered with
- GNOME as a stock icon.
- """
- return 'gramps-geo'
-
- def change_map(self, usedmap):
- """
- Ask to the browser to change the current map.
+ Tell the browser to change the current map.
"""
self.renderer.execute_script(
- "javascript:mapstraction.swap('"+usedmap+"','"+usedmap+"')")
-
- def _alternate_map(self):
- """
- return the alternate name of the map provider.
- """
- if Config.get(Config.GEOVIEW_GOOGLEMAPS):
- alternate_map = "google"
- elif Config.get(Config.GEOVIEW_OPENLAYERS):
- alternate_map = "openlayers"
- elif Config.get(Config.GEOVIEW_YAHOO):
- alternate_map = "yahoo"
- elif Config.get(Config.GEOVIEW_MICROSOFT):
- alternate_map = "microsoft"
- return alternate_map
+ "javascript:swap_map('"+usedmap+"','"+usedmap+"')")
def ui_definition(self):
"""
@@ -738,7 +735,7 @@ class GeoView(HtmlView):
- ''' % self._alternate_map()
+ ''' % _alternate_map()
def define_actions(self):
"""
@@ -748,128 +745,129 @@ class GeoView(HtmlView):
HtmlView._define_actions_fw_bw(self)
self.forward_action.set_sensitive(False)
self.back_action.set_sensitive(False)
- self._add_action('OpenStreetMap', 'gramps-openstreetmap',
+ self._add_action('OpenStreetMap', 'gramps-geo-mainmap',
_('_OpenStreetMap'),
- callback=self.select_openstreetmap_map,
+ callback=self._select_openstreetmap_map,
tip=_("Select OpenStreetMap Maps"))
if Config.get(Config.GEOVIEW_GOOGLEMAPS):
- self._add_action('google', 'gramps-alternate-map',
+ self._add_action('google', 'gramps-geo-altmap',
_('_Google Maps'),
- callback=self.select_google_map,
+ callback=self._select_google_map,
tip=_("Select Google Maps."))
elif Config.get(Config.GEOVIEW_OPENLAYERS):
- self._add_action('openlayers', 'gramps-alternate-map',
+ self._add_action('openlayers', 'gramps-geo-altmap',
_('_OpenLayers Maps'),
- callback=self.select_openlayers_map,
+ callback=self._select_openlayers_map,
tip=_("Select OpenLayers Maps."))
elif Config.get(Config.GEOVIEW_YAHOO):
- self._add_action('yahoo', 'gramps-alternate-map',
+ self._add_action('yahoo', 'gramps-geo-altmap',
_('_Yahoo! Maps'),
- callback=self.select_yahoo_map,
+ callback=self._select_yahoo_map,
tip=_("Select Yahoo Maps."))
elif Config.get(Config.GEOVIEW_MICROSOFT):
- self._add_action('microsoft', 'gramps-alternate-map',
+ self._add_action('microsoft', 'gramps-geo-altmap',
_('_Microsoft Maps'),
- callback=self.select_microsoft_map,
+ callback=self._select_microsoft_map,
tip=_("Select Microsoft Maps"))
self._add_action('AllPlacesMaps', gtk.STOCK_HOME, _('_All Places'),
- callback=self.all_places,
- tip=_("Attempt to view all places in the family tree."))
+ callback=self._all_places, tip=_("Attempt to view all places in "
+ "the family tree."))
self._add_action('PersonMaps', 'gramps-person', _('_Person'),
- callback=self.person_places,
- tip=_("Attempt to view all the places where the selected people lived."))
+ callback=self._person_places,
+ tip=_("Attempt to view all the places "
+ "where the selected people lived."))
self._add_action('FamilyMaps', 'gramps-parents-add', _('_Family'),
- callback=self.family_places,
+ callback=self._family_places,
tip=_("Attempt to view places of the selected people's family."))
self._add_action('EventMaps', 'gramps-event', _('_Event'),
- callback=self.event_places,
+ callback=self._event_places,
tip=_("Attempt to view places connected to all events."))
def goto_active_person(self, handle=None):
"""
Here when the GeoView page is loaded
"""
- self.geo_places(self.displaytype)
+ self._geo_places(self.displaytype)
- def all_places(self, hanle=None):
+ def _all_places(self, hanle=None):
"""
Specifies the place for the home person to display with mapstraction.
"""
self.displaytype = "places"
- self.geo_places(self.displaytype)
+ self._geo_places(self.displaytype)
- def person_places(self, handle=None):
+ def _person_places(self, handle=None):
"""
Specifies the person places.
"""
self.displaytype = "person"
- self.geo_places(self.displaytype)
+ self._geo_places(self.displaytype)
- def family_places(self, hanle=None):
+ def _family_places(self, hanle=None):
"""
Specifies the family places to display with mapstraction.
"""
self.displaytype = "family"
- self.geo_places(self.displaytype)
+ self._geo_places(self.displaytype)
- def event_places(self, hanle=None):
+ def _event_places(self, hanle=None):
"""
Specifies all event places to display with mapstraction.
"""
self.displaytype = "event"
- self.geo_places(self.displaytype)
+ self._geo_places(self.displaytype)
- def geo_places(self, displaytype):
+ def _geo_places(self, displaytype):
"""
Specifies the places to display with mapstraction.
"""
self.external_url = False
self.nbmarkers = 0
self.without = 0
- self.createmapstraction(displaytype)
+ self._createmapstraction(displaytype)
self.open(urlparse.urlunsplit(
('file', '',
URL_SEP.join(self.htmlfile.split(os.sep)),
'', '')))
- def select_openstreetmap_map(self,handle):
+ def _select_openstreetmap_map(self, handle):
"""
- Specifies openstreetmap is the default map
+ Make openstreetmap the default map.
"""
self.usedmap = "openstreetmap"
- self.change_map("openstreetmap")
+ self._change_map("openstreetmap")
- def select_openlayers_map(self,handle):
+ def _select_openlayers_map(self, handle):
"""
- Specifies openstreetmap is the default map
+ Make openstreetmap the default map.
"""
self.usedmap = "openlayers"
- self.change_map("openlayers")
+ self._change_map("openlayers")
- def select_google_map(self,handle):
+ def _select_google_map(self, handle):
"""
Specifies google is the default map
"""
self.usedmap = "google"
- self.change_map("google")
+ self._change_map("google")
- def select_yahoo_map(self,handle):
+ def _select_yahoo_map(self, handle):
"""
- Specifies yahoo map is the default map
+ Make yahoo map the default map.
"""
self.usedmap = "yahoo"
- self.change_map("yahoo")
+ self._change_map("yahoo")
- def select_microsoft_map(self,handle):
+ def _select_microsoft_map(self, handle):
"""
- Specifies microsoft is the default map
+ Make microsoft the default map.
"""
self.usedmap = "microsoft"
- self.change_map("microsoft")
+ self._change_map("microsoft")
- def createpageforplaceswithoutcoord(self):
+ def _createpageplaceswithoutcoord(self):
"""
- This command creates a page with the list of all places without coordinates
+ Create a page with the list of all places without coordinates
page.
"""
data = """
@@ -881,11 +879,12 @@ class GeoView(HtmlView):
%(title)s
- %(content)s
+
""" % { 'title' : _('List of places without coordinates'),
'content': _('Here is the list of all places in the family tree'
' for which we have no coordinates.
'
- ' This means no longitude or latitude.')
+ ' This means no longitude or latitude.
'),
+ 'back' : _('Back to prior page')
}
end = """
@@ -899,13 +898,13 @@ class GeoView(HtmlView):
ufd.write("
NB | ")
ufd.write("Gramps ID | Place | ")
for place in self.places:
- ufd.write("%d | %s | %s | "
+ ufd.write("
%d | %s | %s |
\n"
% ( i, place[0], place[1] ))
i += 1
ufd.write(end)
ufd.close()
- def createmapstractionpostheader(self, h3mess, h4mess,
+ def _createmapstractionpostheader(self, h3mess, h4mess,
maxpages, curpage, ftype):
"""
This is needed to add infos to the header.
@@ -928,10 +927,11 @@ class GeoView(HtmlView):
self.yearint = ( self.yearint - ( self.yearint % modulo ) )
if self.yearint == 0:
self.yearint = 10
- self.mapview.write(" var step = %s;\n" % self.yearint)
- self.mapview.write(" \n")
- self.mapview.write(" \n")
- 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 "
"over %d pages of %d markers : " % (self.nbmarkers,
@@ -939,7 +939,8 @@ class GeoView(HtmlView):
self.mapview.write(" %s
\n" % message)
if curpage != 1:
priorfile = os.path.join(GEOVIEW_SUBPATH,
- "GeoV-%c-%05d.html" % (ftype, curpage-1))
+ "GeoV-%c-%05d.html" %
+ (ftype, curpage-1))
priorfile = urlparse.urlunsplit(
('file', '',
URL_SEP.join(priorfile.split(os.sep)),
@@ -956,10 +957,10 @@ class GeoView(HtmlView):
"GeoV-%c-%05d.html" % \
(ftype, page))
nextfile = urlparse.urlunsplit(
- ('file', '',
- URL_SEP.join(nextfile.split(os.sep)),
- '', ''))
- self.mapview.write("
%d" % \
+ ('file', '',
+ URL_SEP.join(nextfile.split(os.sep)),
+ '', ''))
+ self.mapview.write("\n
%d" %
(nextfile, page))
if curpage != maxpages:
nextfile = os.path.join(GEOVIEW_SUBPATH,
@@ -968,7 +969,7 @@ class GeoView(HtmlView):
('file', '',
URL_SEP.join(nextfile.split(os.sep)),
'', ''))
- self.mapview.write("
++" % nextfile)
+ self.mapview.write("\n
++" % nextfile)
else:
self.mapview.write(" ++")
self.mapview.write("\n
\n")
@@ -983,10 +984,9 @@ class GeoView(HtmlView):
self.mapview.write("%d" % \
( filename, self.without ) )
self.mapview.write(" places without coordinates\n" )
- self.createpageforplaceswithoutcoord()
+ self._createpageplaceswithoutcoord()
if self.displaytype != "places":
- self.mapview.write(" \n")
- self.mapview.write("
\n")
+ self.mapview.write(" \n")
self.mapview.write("%s
" % h3mess)
if h4mess:
self.mapview.write("%s
" % h4mess)
+ margin = 10
+ self.mapview.write("\n\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")
- alternatemap = self._alternate_map()
- if alternatemap == "microsoft":
- self.mapview.write(" \n")
+ if self.usedmap == "microsoft":
+ self.mapview.write("\n")
- elif alternatemap == "yahoo":
- self.mapview.write(" \n")
- elif alternatemap == "openlayers":
- self.mapview.write(" \n")
- self.mapview.write(" \n")
elif self.usedmap == "openlayers":
- self.mapview.write("")
- else: # openstreetmap and google
- self.mapview.write(" gmarkers[i].map.")
- self.mapview.write("closeInfoWindow();\n")
- self.mapview.write(" years = val.split(' ');\n")
- self.mapview.write(" for ( j=0; j < years.length; j++) {\n")
- self.mapview.write(" if ( years[j] >= min ) {\n")
- self.mapview.write(" if ( years[j] < max ) {\n")
- self.mapview.write(" gmarkers[i].show();\n")
- self.mapview.write(" }\n")
- self.mapview.write(" }\n")
- self.mapview.write(" }\n")
- self.mapview.write(" }\n")
- self.mapview.write(" }\n")
+ self.mapview.write("\n")
- def createmapstractiontrailer(self):
+ def _createmapstractiontrailer(self):
"""
- Add the last directives for the html page
+ Add the last directives for the html page.
"""
- self.mapview.write(" \n")
+ self.mapview.write(" setcenterandzoom(mapstraction);\n")
+ self.mapview.write(" setmarkers(mapstraction);\n")
+ self.mapview.write(" if ( current_map != \"openstreetmap\") {")
+ self.mapview.write(" swap_map(current_map,current_map);")
+ self.mapview.write(" };\n")
+ self.mapview.write("\n")
+ self.mapview.write("