From f4b5710959ce141c579276a3dc8cabcadb2d56f3 Mon Sep 17 00:00:00 2001
From: Serge Noiraud
Date: Mon, 24 Aug 2009 20:17:05 +0000
Subject: [PATCH] GeoView : Fix of issues 3150, 3152 for 3.1 branch (path
problem on windows)
svn: r13114
---
src/DataViews/GeoView.py | 73 +++++++++++++++++++++++++++++-----------
1 file changed, 54 insertions(+), 19 deletions(-)
diff --git a/src/DataViews/GeoView.py b/src/DataViews/GeoView.py
index 51f3367e1..d3c512dc5 100644
--- a/src/DataViews/GeoView.py
+++ b/src/DataViews/GeoView.py
@@ -3,7 +3,9 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
-# Copyright (C) 2007-2008 Serge Noiraud
+# Copyright (C) 2007-2009 Serge Noiraud
+# Copyright (C) 2009 Helge GRAMPS
+# Copyright (C) 2009 Josip
# Copyright (C) 2008 Benny Malengier
#
# This program is free software; you can redistribute it and/or modify
@@ -67,6 +69,7 @@ from PlaceUtils import conv_lat_lon
NOWEB = 0
WEBKIT = 1
MOZIL = 2
+URL_SEP = '/'
WebKit = NOWEB
try:
@@ -290,7 +293,9 @@ class RendererMozilla(Renderer):
proxy = os.environ['http_proxy']
if proxy:
host_port = None
- prefs = open(MOZEMBED_SUBPATH+"/prefs.js", "w+")
+ prefs = open(os.path.join(MOZEMBED_SUBPATH,
+ "prefs.js"),
+ "w+")
parts = urlparse.urlparse(proxy)
if not parts[0] or parts[0] == 'http':
host_port = parts[1]
@@ -331,7 +336,7 @@ class RendererMozilla(Renderer):
prefs.close()
except:
try: # trying to remove pref.js in case of proxy change.
- os.remove(MOZEMBED_SUBPATH+"/prefs.js")
+ os.remove(os.path.join(MOZEMBED_SUBPATH, "prefs.js"))
except:
pass
pass # We don't use a proxy or the http_proxy variable is not set.
@@ -574,11 +579,14 @@ class HtmlView(PageView.PageView):
' page\n
\n'
'For example: http://gramps-project.org
')
}
- filename = os.path.join(tmpdir, 'startpage')
+ filename = os.path.join(tmpdir, 'startpage.html')
ufd = file(filename, "w+")
ufd.write(data)
ufd.close()
- return 'file://'+filename
+ return urlparse.urlunsplit(('file', '',
+ URL_SEP.join(filename.split(os.sep)),
+ '', ''))
+
#-------------------------------------------------------------------------
#
@@ -819,7 +827,10 @@ class GeoView(HtmlView):
self.nbmarkers = 0
self.without = 0
self.createmapstraction(displaytype)
- self.open("file://"+self.htmlfile)
+ self.open(urlparse.urlunsplit(
+ ('file', '',
+ URL_SEP.join(self.htmlfile.split(os.sep)),
+ '', '')))
def select_openstreetmap_map(self,handle):
"""
@@ -927,8 +938,12 @@ class GeoView(HtmlView):
maxpages, NB_MARKERS_PER_PAGE))
self.mapview.write(" %s
\n" % message)
if curpage != 1:
- priorfile = GEOVIEW_SUBPATH+"/GeoV-%c-%05d.html" % \
- (ftype, curpage-1)
+ priorfile = os.path.join(GEOVIEW_SUBPATH,
+ "GeoV-%c-%05d.html" % (ftype, curpage-1))
+ priorfile = urlparse.urlunsplit(
+ ('file', '',
+ URL_SEP.join(priorfile.split(os.sep)),
+ '', ''))
self.mapview.write("
--" % priorfile)
else:
self.mapview.write(" --")
@@ -937,22 +952,36 @@ class GeoView(HtmlView):
self.mapview.write(" %d" % page)
else:
if ( page < curpage + 11 ) and ( page > curpage - 11 ):
- nextfile = GEOVIEW_SUBPATH+"/GeoV-%c-%05d.html" % \
- (ftype, page)
+ nextfile = os.path.join(GEOVIEW_SUBPATH,
+ "GeoV-%c-%05d.html" % \
+ (ftype, page))
+ nextfile = urlparse.urlunsplit(
+ ('file', '',
+ URL_SEP.join(nextfile.split(os.sep)),
+ '', ''))
self.mapview.write("
%d" % \
(nextfile, page))
if curpage != maxpages:
- nextfile = GEOVIEW_SUBPATH+"/GeoV-%c-%05d.html" % \
- (ftype, curpage+1)
+ nextfile = os.path.join(GEOVIEW_SUBPATH,
+ "GeoV-%c-%05d.html" % (ftype, curpage+1))
+ nextfile = urlparse.urlunsplit(
+ ('file', '',
+ URL_SEP.join(nextfile.split(os.sep)),
+ '', ''))
self.mapview.write("
++" % nextfile)
else:
self.mapview.write(" ++")
self.mapview.write("\n
\n")
if self.without != 0:
- self.without_coord_file = GEOVIEW_SUBPATH+"/without_coord.html"
+ self.without_coord_file = os.path.join(GEOVIEW_SUBPATH,
+ "without_coord.html")
self.mapview.write("