From 2de02b58990434c620f09a6bd460bd9190d648e7 Mon Sep 17 00:00:00 2001 From: Gary Burton Date: Wed, 23 Dec 2009 18:20:44 +0000 Subject: [PATCH] Add an existing place to a map svn: r13896 --- src/plugins/view/geoview.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/plugins/view/geoview.py b/src/plugins/view/geoview.py index 5268b9670..60fee6667 100644 --- a/src/plugins/view/geoview.py +++ b/src/plugins/view/geoview.py @@ -67,6 +67,7 @@ from BasicUtils import name_displayer as _nd from PlaceUtils import conv_lat_lon from gui.views.pageview import PageView from gui.editors import EditPlace +from gui.selectors.selectplace import SelectPlace #------------------------------------------------------------------------- # @@ -322,9 +323,10 @@ class GeoView(HtmlView): self.without_coord_file = os.path.join(GEOVIEW_SUBPATH, "without_coord.html") self.endinit = False - self.signal_map = {'place-add': self._place_added} + self.signal_map = {'place-add': self._place_changed, + 'place-update' : self._place_changed} - def _place_added(self, handle_list): + def _place_changed(self, handle_list): self.displaytype = "places" self._set_lock_unlock(True) self._geo_places() @@ -717,6 +719,7 @@ class GeoView(HtmlView): + @@ -748,6 +751,11 @@ class GeoView(HtmlView): callback=self._add_place, tip=_("Add the location centred on the map as a new place in " "Gramps. Double click the location to centre on the map.")) + self._add_action('LinkPlace', 'gramps-place', + _('_Link Place'), + callback=self._link_place, + tip=_("Link the location centred on the map to a place in " + "Gramps. Double click the location to centre on the map.")) self.lock_action = gtk.ActionGroup(self.title + "/SaveZoom") self.lock_action.add_toggle_actions([ ('SaveZoom', 'gramps-lock', _("_SaveZoom"), "L", @@ -1921,3 +1929,18 @@ class GeoView(HtmlView): EditPlace(self.dbstate, self.uistate, [], new_place) except Errors.WindowActiveError: pass + + def _link_place(self,url): + """ + Link an existing place using longitude and latitude of location centred + on the map + """ + selector = SelectPlace(self.dbstate, self.uistate, []) + place = selector.run() + if place: + place.set_latitude(self.reallatitude) + place.set_longitude(self.reallongitude) + try: + EditPlace(self.dbstate, self.uistate, [], place) + except Errors.WindowActiveError: + pass