GeoView : Better initialization.
Avoid to create the same page several times. Don't create the start page twice now we have Web and Geography views. svn: r13817
This commit is contained in:
parent
69315dc4ba
commit
82d7e93a7c
@ -434,12 +434,12 @@ class GeoView(HtmlView):
|
|||||||
url += '&zoom=%d' % int(self.realzoom)
|
url += '&zoom=%d' % int(self.realzoom)
|
||||||
url += '&lat=%s' % str(self.reallatitude)
|
url += '&lat=%s' % str(self.reallatitude)
|
||||||
url += '&lon=%s' % str(self.reallongitude)
|
url += '&lon=%s' % str(self.reallongitude)
|
||||||
self.open(url)
|
self._openurl(url)
|
||||||
self._create_pages_selection(cpage, int(maxp))
|
self._create_pages_selection(cpage, int(maxp))
|
||||||
self._savezoomandposition()
|
self._savezoomandposition()
|
||||||
# Need to wait the page is loaded to show the markers.
|
# Need to wait the page is loaded to show the markers.
|
||||||
gobject.timeout_add(1500, self._show_selected_places)
|
gobject.timeout_add(1500, self._show_selected_places)
|
||||||
self._erase_placebox_selection()
|
#self._erase_placebox_selection()
|
||||||
|
|
||||||
def _show_selected_places(self):
|
def _show_selected_places(self):
|
||||||
"""
|
"""
|
||||||
@ -459,7 +459,7 @@ class GeoView(HtmlView):
|
|||||||
url = urlparse.urlunsplit( ('file', '',
|
url = urlparse.urlunsplit( ('file', '',
|
||||||
URL_SEP.join(self.without_coord_file.split(os.sep)),
|
URL_SEP.join(self.without_coord_file.split(os.sep)),
|
||||||
'', ''))
|
'', ''))
|
||||||
self.open(url)
|
self._openurl(url)
|
||||||
|
|
||||||
def _entry_selected_place(self, combobox): # pylint: disable-msg=W0612
|
def _entry_selected_place(self, combobox): # pylint: disable-msg=W0612
|
||||||
"""
|
"""
|
||||||
@ -489,7 +489,7 @@ class GeoView(HtmlView):
|
|||||||
url += '&zoom=%d' % int(self.realzoom)
|
url += '&zoom=%d' % int(self.realzoom)
|
||||||
url += '&lat=%s' % str(self.reallatitude)
|
url += '&lat=%s' % str(self.reallatitude)
|
||||||
url += '&lon=%s' % str(self.reallongitude)
|
url += '&lon=%s' % str(self.reallongitude)
|
||||||
self.open(url)
|
self._openurl(url)
|
||||||
(current, maxp ) = self.pages[1].get_label().split('/', 1)
|
(current, maxp ) = self.pages[1].get_label().split('/', 1)
|
||||||
self._create_pages_selection(entry[2], int(maxp))
|
self._create_pages_selection(entry[2], int(maxp))
|
||||||
self._savezoomandposition()
|
self._savezoomandposition()
|
||||||
@ -651,7 +651,7 @@ class GeoView(HtmlView):
|
|||||||
url += '&zoom=%d' % int(self.realzoom)
|
url += '&zoom=%d' % int(self.realzoom)
|
||||||
url += '&lat=%s' % str(self.reallatitude)
|
url += '&lat=%s' % str(self.reallatitude)
|
||||||
url += '&lon=%s' % str(self.reallongitude)
|
url += '&lon=%s' % str(self.reallongitude)
|
||||||
self.open(url)
|
self._openurl(url)
|
||||||
self._savezoomandposition()
|
self._savezoomandposition()
|
||||||
if self.displaytype != "places":
|
if self.displaytype != "places":
|
||||||
# Need to wait the page is loaded to set the markers.
|
# Need to wait the page is loaded to set the markers.
|
||||||
@ -671,7 +671,9 @@ class GeoView(HtmlView):
|
|||||||
year = model.get_value(widget.get_active_iter(), 0)
|
year = model.get_value(widget.get_active_iter(), 0)
|
||||||
except: # pylint: disable-msg=W0704
|
except: # pylint: disable-msg=W0704
|
||||||
pass # pylint: disable-msg=W0702
|
pass # pylint: disable-msg=W0702
|
||||||
if year != "no":
|
if self.last_selected_year == 0:
|
||||||
|
self.last_selected_year = year
|
||||||
|
elif year != "no":
|
||||||
self.last_selected_year = year
|
self.last_selected_year = year
|
||||||
self._call_js_selectmarkers(year)
|
self._call_js_selectmarkers(year)
|
||||||
|
|
||||||
@ -811,6 +813,7 @@ class GeoView(HtmlView):
|
|||||||
self._set_mapstylelabel(self.stylesheet)
|
self._set_mapstylelabel(self.stylesheet)
|
||||||
self._savezoomandposition(500) # every 500 millisecondes
|
self._savezoomandposition(500) # every 500 millisecondes
|
||||||
self.endinit = True
|
self.endinit = True
|
||||||
|
self._geo_places()
|
||||||
|
|
||||||
def __create_styles_menu_actions(self):
|
def __create_styles_menu_actions(self):
|
||||||
"""
|
"""
|
||||||
@ -922,6 +925,8 @@ class GeoView(HtmlView):
|
|||||||
"""
|
"""
|
||||||
Specifies the places to display with mapstraction.
|
Specifies the places to display with mapstraction.
|
||||||
"""
|
"""
|
||||||
|
if not self.endinit:
|
||||||
|
return
|
||||||
if self.nbmarkers > 0 :
|
if self.nbmarkers > 0 :
|
||||||
# While the db is not loaded, we have 0 markers.
|
# While the db is not loaded, we have 0 markers.
|
||||||
self._savezoomandposition()
|
self._savezoomandposition()
|
||||||
@ -929,15 +934,6 @@ class GeoView(HtmlView):
|
|||||||
self.nbplaces = 0
|
self.nbplaces = 0
|
||||||
self.without = 0
|
self.without = 0
|
||||||
self._createmapstraction(self.displaytype)
|
self._createmapstraction(self.displaytype)
|
||||||
self._do_we_need_to_zoom_between_map()
|
|
||||||
url = urlparse.urlunsplit( ('file', '',
|
|
||||||
URL_SEP.join(self.htmlfile.split(os.sep)),
|
|
||||||
'', ''))
|
|
||||||
url += '?map=%s' % self.usedmap
|
|
||||||
url += '&zoom=%d' % int(self.realzoom)
|
|
||||||
url += '&lat=%s' % str(self.reallatitude)
|
|
||||||
url += '&lon=%s' % str(self.reallongitude)
|
|
||||||
self.open(url)
|
|
||||||
|
|
||||||
def _select_openstreetmap_map(self, handle): # pylint: disable-msg=W0613
|
def _select_openstreetmap_map(self, handle): # pylint: disable-msg=W0613
|
||||||
"""
|
"""
|
||||||
@ -1271,7 +1267,15 @@ class GeoView(HtmlView):
|
|||||||
self._createmapstractionpostheader(h4mess, self.nbpages)
|
self._createmapstractionpostheader(h4mess, self.nbpages)
|
||||||
self._createmapstractiontrailer()
|
self._createmapstractiontrailer()
|
||||||
if self.nbpages == 1:
|
if self.nbpages == 1:
|
||||||
self.open(self.htmlfile)
|
self._do_we_need_to_zoom_between_map()
|
||||||
|
url = urlparse.urlunsplit( ('file', '',
|
||||||
|
URL_SEP.join(self.htmlfile.split(os.sep)),
|
||||||
|
'', ''))
|
||||||
|
url += '?map=%s' % self.usedmap
|
||||||
|
url += '&zoom=%d' % int(self.realzoom)
|
||||||
|
url += '&lat=%s' % str(self.reallatitude)
|
||||||
|
url += '&lon=%s' % str(self.reallongitude)
|
||||||
|
self._openurl(url)
|
||||||
self.placebox.set_model(self.plist)
|
self.placebox.set_model(self.plist)
|
||||||
self.placebox.thaw_child_notify()
|
self.placebox.thaw_child_notify()
|
||||||
|
|
||||||
@ -1866,3 +1870,10 @@ class GeoView(HtmlView):
|
|||||||
else:
|
else:
|
||||||
return u'%s%s%s' % (dblp, gcp, delp)
|
return u'%s%s%s' % (dblp, gcp, delp)
|
||||||
|
|
||||||
|
def _openurl(self,url):
|
||||||
|
"""
|
||||||
|
Here, we call really the htmlview and the renderer
|
||||||
|
"""
|
||||||
|
if self.endinit:
|
||||||
|
self.open(url)
|
||||||
|
|
||||||
|
@ -466,7 +466,7 @@ class HtmlView(PageView):
|
|||||||
self.box.pack_start(frame, True, True, 0)
|
self.box.pack_start(frame, True, True, 0)
|
||||||
# this is used to activate the back and forward button
|
# this is used to activate the back and forward button
|
||||||
# from the renderer class.
|
# from the renderer class.
|
||||||
self.renderer.fct = self.set_button_sensitivity
|
self.renderer.fct = lambda: self.set_button_sensitivity
|
||||||
self.renderer.show_all()
|
self.renderer.show_all()
|
||||||
#load a welcome html page
|
#load a welcome html page
|
||||||
urlhelp = self._create_start_page()
|
urlhelp = self._create_start_page()
|
||||||
@ -648,6 +648,9 @@ class HtmlView(PageView):
|
|||||||
'For example: <b>http://gramps-project.org</p>')
|
'For example: <b>http://gramps-project.org</p>')
|
||||||
}
|
}
|
||||||
filename = os.path.join(tmpdir, 'startpage.html')
|
filename = os.path.join(tmpdir, 'startpage.html')
|
||||||
|
# Now we have two views : Web and Geography, we need to create the
|
||||||
|
# startpage only once.
|
||||||
|
if not os.path.exists(filename):
|
||||||
ufd = file(filename, "w+")
|
ufd = file(filename, "w+")
|
||||||
ufd.write(data)
|
ufd.write(data)
|
||||||
ufd.close()
|
ufd.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user