From 0e928d6b81516b126d48f4576b677c937dea788f Mon Sep 17 00:00:00 2001 From: Serge Noiraud Date: Thu, 2 Sep 2010 17:05:00 +0000 Subject: [PATCH] GeoView : adapt geoview to the new gui. Resizing problem. It currently works correctly with gecko. webkit doesn't work in a Hpane widget ( filter, status bar, ... ) svn: r15848 --- src/data/GeoView.css | 2 - src/mapstraction/mxn.googlev3.core.js | 17 +++++-- src/plugins/view/geoview.py | 72 +++++++++++++++++++-------- src/plugins/view/htmlrenderer.py | 1 + 4 files changed, 64 insertions(+), 28 deletions(-) diff --git a/src/data/GeoView.css b/src/data/GeoView.css index 218b84f9c..3f64f387a 100644 --- a/src/data/GeoView.css +++ b/src/data/GeoView.css @@ -37,8 +37,6 @@ This file was created for GeoView usage. { margin-left:auto; margin-right:auto; - min-height:100px; - min-width: 100px; } /* InfoWindow */ diff --git a/src/mapstraction/mxn.googlev3.core.js b/src/mapstraction/mxn.googlev3.core.js index 80c0e3ce4..57690a5e2 100644 --- a/src/mapstraction/mxn.googlev3.core.js +++ b/src/mapstraction/mxn.googlev3.core.js @@ -320,11 +320,16 @@ Mapstraction: { addCrosshair: function(Cross, crosshairSize, divid) { var map = this.maps[this.api]; - if ( map.init == true ) { - cross=document.getElementById("Googlev3_Control_CrossHair"); - cross.style.visibility = 'visible'; - return map.crosshair; - }; + //if ( map.init == true ) { + // cross=document.getElementById("Googlev3_Control_CrossHair"); + // cross.style.visibility = 'visible'; + // return map.crosshair; + //}; + if (map.crosshair) { + map.crosshair.remove(); + map.ctlui.remove(); + map.divui.remove(); + }; var container = map.getDiv(); map.divid=divid; // Create a div to hold the control. @@ -354,6 +359,8 @@ Mapstraction: { controlUI.appendChild(crosshair); container.appendChild(controlDiv); map.crosshair=crosshair; + map.ctlui=controlUI; + map.divui=controlDiv; map.init = true; return controlDiv; }, diff --git a/src/plugins/view/geoview.py b/src/plugins/view/geoview.py index 5126dbf5d..648ca49fc 100644 --- a/src/plugins/view/geoview.py +++ b/src/plugins/view/geoview.py @@ -267,12 +267,6 @@ _HTMLTRAILER = '''\ setcenterandzoom(mapstraction,uzoom,ulat,ulon); savezoomandposition(mapstraction); mapstraction.enableScrollWheelZoom(); - window.onresize=function() { - winheight=window.innerHeight-16; - winwidth='100%'; - mapstraction.resizeTo(winwidth,winheight+'px'); - setcenterandzoom(mapstraction,uzoom,ulat,ulon); - }; @@ -555,11 +549,7 @@ class GeoView(HtmlView): self.renderer.execute_script("javascript:addcrosshair('%d','%s','geo-map')" % (self._config.get("preferences.crosshair"), self.crosspath) ) - _LOG.debug("resize : %dpx" % self.height ) - self.renderer.execute_script("javascript:mapstraction.resizeTo" - "('100%%','%dpx');" - % ( self.height - self.header_size - 4 ) ) - self.renderer.execute_script("javascript:setcenter(point,uzoom)") + self._size_request_for_map(self.box, None) pass def geoview_options(self, configdialog): @@ -831,6 +821,7 @@ class GeoView(HtmlView): if self.last_selected_year == r_year[0]: self.yearsbox.set_active(index) self._call_js_selectmarkers(r_year[0]) + self._size_request_for_map(self.box, None) def _show_places_without_coord(self, widget): # pylint: disable-msg=W0613 """ @@ -890,6 +881,7 @@ class GeoView(HtmlView): if self.javascript_ready: self.renderer.execute_script("javascript:placeclick('%d')" % marker_index) + self._size_request_for_map(self.box, None) def _erase_placebox_selection(self, arg): # pylint: disable-msg=W0613 @@ -928,18 +920,45 @@ class GeoView(HtmlView): self.pages_selection.hide() self.nocoord.hide() self.box.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): # pylint: disable-msg=W0613 """ We need to resize the map """ - gws = widget.get_allocation() - self.width = gws.width - 20 - self.height = gws.height - self.header_size = self.box1.get_allocation().height + 20 - _LOG.debug("Resize to width=%d and height=%d" % (self.width, self.height)) + if not self.javascript_ready: + return + # VBox -> NoteBook -> HPaned -> HBox + # We need to get the HBox size. + gws = widget.parent.parent.parent.get_allocation() + width = gws.width - ( 6 * 4 ) + # We need to get the gramps size (gtk.window). + gws = widget.parent.parent.parent.parent.get_allocation() + gheight = gws.height + tgws = widget.parent.parent.get_allocation() + # We need to get the HPaned size. + self.header_size = self.box1.get_allocation().height # + 20 + self.height = tgws.height - self.header_size - ( 7 * 4 ) + if config.get('interface.view'): + self.pane = widget.parent.parent.get_position() + _LOG.debug("Pane width=%d" % self.pane ) + # strange resize when self.pane < 135 + self.pane = 140 if self.pane < 140 else self.pane + self.width = width - self.pane - ( 2 * 4 ) + else: + self.width = width - ( 2 * 4 ) + if config.get('interface.filter'): + self.width -= self.filter.get_allocation().width + if self.javascript_ready: + _LOG.debug("New size : width=%d and height=%d" % + (self.width, self.height)) + self.renderer.execute_script("javascript:mapstraction.resizeTo" + "('%dpx','%dpx');" + % (self.width, self.height) ) + self.renderer.execute_script( + "javascript:setcenterandzoom(mapstraction,uzoom," + "ulat,ulon)") + self.frames.set_size_request(self.width+4, self.height+4) if not self.uistate.get_active('Person'): return self.external_uri() @@ -1068,10 +1087,11 @@ class GeoView(HtmlView): if self.displaytype != "places": # Need to wait the page is loaded to set the markers and crosshair. gobject.timeout_add(1500, self._set_markers_and_crosshair_on_page, - self.last_year) + self.last_year) else: # Need to wait the page is loaded to set the crosshair. - gobject.timeout_add(1500, self.config_crosshair , False, False, False, False) + gobject.timeout_add(1500, self.config_crosshair, + False, False, False, False) def _set_markers_and_crosshair_on_page(self, widget): """ @@ -1710,8 +1730,8 @@ class GeoView(HtmlView): self.years.show() self.mapview.write( '
\n' - % ((self.height - self.header_size), '100%' ) + + 'height: %dpx; width: %dpx; " >\n' + % ( self.height, self.width ) + '