From 36c03a0a530220ea5cc253e6475be1b4ab50f7ea Mon Sep 17 00:00:00 2001 From: SNoiraud Date: Thu, 19 Mar 2015 19:32:34 +0100 Subject: [PATCH] geography: bug8450: Attempting to add a bookmark causes an error. --- gramps/plugins/lib/maps/geography.py | 13 +++++++++++++ gramps/plugins/view/geoclose.py | 2 +- gramps/plugins/view/geoevents.py | 4 ++-- gramps/plugins/view/geofamclose.py | 2 +- gramps/plugins/view/geomoves.py | 2 +- gramps/plugins/view/geoplaces.py | 4 ++-- 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/gramps/plugins/lib/maps/geography.py b/gramps/plugins/lib/maps/geography.py index 587326d65..db3be98c7 100644 --- a/gramps/plugins/lib/maps/geography.py +++ b/gramps/plugins/lib/maps/geography.py @@ -191,6 +191,19 @@ class GeoGraphyView(OsmGps, NavigationView): _("Could Not Set a Bookmark"), _("A bookmark could not be set because " "no one was selected.")) + + + def add_bookmark_from_popup(self, menu, handle): + if handle: + self.uistate.set_active(handle, self.navigation_type()) + self.bookmarks.add(handle) + self.bookmarks.redraw() + else: + from gramps.gui.dialog import WarningDialog + WarningDialog( + _("Could Not Set a Bookmark"), + _("A bookmark could not be set because " + "no one was selected.")) def change_page(self): """ diff --git a/gramps/plugins/view/geoclose.py b/gramps/plugins/view/geoclose.py index a259d9110..2755b6d98 100644 --- a/gramps/plugins/view/geoclose.py +++ b/gramps/plugins/view/geoclose.py @@ -232,7 +232,7 @@ class GeoClose(GeoGraphyView): self._createmap(self.refperson, color, self.place_list_ref, True) if self.refperson_bookmark is None: self.refperson_bookmark = self.refperson.get_handle() - self.add_bookmark(None, self.refperson_bookmark) + self.add_bookmark_from_popup(None, self.refperson_bookmark) else: self.message_layer.add_message(_("You must choose one reference person.")) self.message_layer.add_message(_("Go to the person view and select " diff --git a/gramps/plugins/view/geoevents.py b/gramps/plugins/view/geoevents.py index fe0453f6a..7d001a37f 100644 --- a/gramps/plugins/view/geoevents.py +++ b/gramps/plugins/view/geoevents.py @@ -335,7 +335,7 @@ class GeoEvents(GeoGraphyView): hdle = evt.get_handle() bookm = Gtk.MenuItem(label=_("Bookmark this event")) bookm.show() - bookm.connect("activate", self.add_bookmark, hdle) + bookm.connect("activate", self.add_bookmark_from_popup, hdle) itemoption.append(bookm) if mark[0] != oldplace: message = "%s :" % mark[0] @@ -367,7 +367,7 @@ class GeoEvents(GeoGraphyView): hdle = evt.get_handle() bookm = Gtk.MenuItem(label=_("Bookmark this event")) bookm.show() - bookm.connect("activate", self.add_bookmark, hdle) + bookm.connect("activate", self.add_bookmark_from_popup, hdle) itemoption.append(bookm) menu.popup(None, None, lambda menu, data: (event.get_root_coords()[0], diff --git a/gramps/plugins/view/geofamclose.py b/gramps/plugins/view/geofamclose.py index 296551c91..e0ba244a7 100644 --- a/gramps/plugins/view/geofamclose.py +++ b/gramps/plugins/view/geofamclose.py @@ -255,7 +255,7 @@ class GeoFamClose(GeoGraphyView): self.message_layer.add_message(_("The other family : %s" % _("Unknown"))) if self.reffamily_bookmark is None: self.reffamily_bookmark = self.reffamily.get_handle() - self.add_bookmark(None, self.reffamily_bookmark) + self.add_bookmark_from_popup(None, self.reffamily_bookmark) else: self.message_layer.add_message(_("You must choose one reference family.")) self.message_layer.add_message(_("Go to the family view and select " diff --git a/gramps/plugins/view/geomoves.py b/gramps/plugins/view/geomoves.py index 7b529c037..5f05d163b 100644 --- a/gramps/plugins/view/geomoves.py +++ b/gramps/plugins/view/geomoves.py @@ -607,7 +607,7 @@ class GeoMoves(GeoGraphyView): hdle = person.get_handle() bookm = Gtk.MenuItem(label=_("Bookmark this person")) bookm.show() - bookm.connect("activate", self.add_bookmark, hdle) + bookm.connect("activate", self.add_bookmark_from_popup, hdle) itemoption.append(bookm) menu.show() menu.popup(None, None, diff --git a/gramps/plugins/view/geoplaces.py b/gramps/plugins/view/geoplaces.py index b4a6bc93d..e3d05a107 100644 --- a/gramps/plugins/view/geoplaces.py +++ b/gramps/plugins/view/geoplaces.py @@ -333,7 +333,7 @@ class GeoPlaces(GeoGraphyView): hdle = place.get_handle() bookm = Gtk.MenuItem(label=_("Bookmark this place")) bookm.show() - bookm.connect("activate", self.add_bookmark, hdle) + bookm.connect("activate", self.add_bookmark_from_popup, hdle) itemoption.append(bookm) message = "%s" % mark[0] prevmark = mark @@ -357,7 +357,7 @@ class GeoPlaces(GeoGraphyView): hdle = place.get_handle() bookm = Gtk.MenuItem(label=_("Bookmark this place")) bookm.show() - bookm.connect("activate", self.add_bookmark, hdle) + bookm.connect("activate", self.add_bookmark_from_popup, hdle) itemoption.append(bookm) menu.popup(None, None, lambda menu, data: (event.get_root_coords()[0],