From e5f5da185727bdf2eea20ca856e86532d713bec3 Mon Sep 17 00:00:00 2001 From: noirauds Date: Fri, 14 Feb 2014 16:23:43 +0100 Subject: [PATCH] Geography : Adding bookmarks (follow bug 7240) --- gramps/plugins/lib/maps/geography.py | 15 ++++++++++++++- gramps/plugins/view/geoclose.py | 19 +++++++------------ gramps/plugins/view/geoevents.py | 23 ++++++++++++----------- gramps/plugins/view/geofamclose.py | 19 +++++++------------ gramps/plugins/view/geofamily.py | 12 ------------ gramps/plugins/view/geomoves.py | 17 ++++++----------- gramps/plugins/view/geoperson.py | 11 ----------- gramps/plugins/view/geoplaces.py | 23 ++++++++++++----------- 8 files changed, 58 insertions(+), 81 deletions(-) diff --git a/gramps/plugins/lib/maps/geography.py b/gramps/plugins/lib/maps/geography.py index c7c2b8683..242528335 100644 --- a/gramps/plugins/lib/maps/geography.py +++ b/gramps/plugins/lib/maps/geography.py @@ -184,6 +184,18 @@ class GeoGraphyView(OsmGps, NavigationView): pathu = path.encode(glocale.getfilesystemencoding()) self.geo_othermap[ident] = cairo.ImageSurface.create_from_png(pathu) + def add_bookmark(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): """ Called when the page changes. @@ -232,6 +244,7 @@ class GeoGraphyView(OsmGps, NavigationView): """ if self.active: self.bookmarks.redraw() + self.build_tree() def can_configure(self): """ @@ -332,7 +345,7 @@ class GeoGraphyView(OsmGps, NavigationView): # Add specific module menu self.add_specific_menu(menu, event, lat, lon) # Add a separator line - add_item = Gtk.MenuItem(label=None) + add_item = Gtk.MenuItem() add_item.show() menu.append(add_item) diff --git a/gramps/plugins/view/geoclose.py b/gramps/plugins/view/geoclose.py index 99ab6b9ff..68063ab8e 100644 --- a/gramps/plugins/view/geoclose.py +++ b/gramps/plugins/view/geoclose.py @@ -150,6 +150,7 @@ class GeoClose(GeoGraphyView): self.minyear = 9999 self.maxyear = 0 self.refperson = None + self.refperson_bookmark = None self.nbplaces = 0 self.nbmarkers = 0 self.sort = [] @@ -196,17 +197,6 @@ class GeoClose(GeoGraphyView): """ return 'Person' - def add_bookmark(self, obj): - mlist = self.selected_handles() - if mlist: - self.bookmarks.add(mlist[0]) - 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 goto_handle(self, handle=None): """ Rebuild the tree with the given person handle as the root. @@ -240,6 +230,9 @@ class GeoClose(GeoGraphyView): else: self.message_layer.add_message(_("The other person is unknown")) 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) else: self.message_layer.add_message(_("You must choose one reference person.")) self.message_layer.add_message(_("Go to the person view and select " @@ -303,6 +296,8 @@ class GeoClose(GeoGraphyView): """ self.track = [] self.skip_list = [] + self.refperson = None + self.refperson_bookmark = None SelectPerson = SelectorFactory('Person') sel = SelectPerson(self.dbstate, self.uistate, self.track, _("Select the person which will be our reference."), @@ -553,7 +548,7 @@ class GeoClose(GeoGraphyView): add_item = Gtk.MenuItem() add_item.show() menu.append(add_item) - add_item = Gtk.MenuItem(label=_("Choose the reference person")) + add_item = Gtk.MenuItem(label=_("Choose and bookmark the new reference person")) add_item.connect("activate", self.selectPerson) add_item.show() menu.append(add_item) diff --git a/gramps/plugins/view/geoevents.py b/gramps/plugins/view/geoevents.py index f607f46f6..e8c13c9ee 100644 --- a/gramps/plugins/view/geoevents.py +++ b/gramps/plugins/view/geoevents.py @@ -168,17 +168,6 @@ class GeoEvents(GeoGraphyView): """ return 'Event' - def add_bookmark(self, obj): - mlist = self.selected_handles() - if mlist: - self.bookmarks.add(mlist[0]) - 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 goto_handle(self, handle=None): """ Rebuild the tree with the given events handle as the root. @@ -343,6 +332,12 @@ class GeoEvents(GeoGraphyView): center.connect("activate", self.center_here, event, lat, lon, prevmark) itemoption.append(center) + evt = self.dbstate.db.get_event_from_gramps_id(mark[10]) + hdle = evt.get_handle() + bookm = Gtk.MenuItem(label=_("Bookmark this event")) + bookm.show() + bookm.connect("activate", self.add_bookmark, hdle) + itemoption.append(bookm) if mark[0] != oldplace: message = "%s :" % mark[0] self.add_place_bubble_message(event, lat, lon, @@ -369,6 +364,12 @@ class GeoEvents(GeoGraphyView): center.show() center.connect("activate", self.center_here, event, lat, lon, prevmark) itemoption.append(center) + evt = self.dbstate.db.get_event_from_gramps_id(mark[10]) + hdle = evt.get_handle() + bookm = Gtk.MenuItem(label=_("Bookmark this event")) + bookm.show() + bookm.connect("activate", self.add_bookmark, hdle) + itemoption.append(bookm) menu.popup(None, None, lambda menu, data: (event.get_root_coords()[0], event.get_root_coords()[1], True), diff --git a/gramps/plugins/view/geofamclose.py b/gramps/plugins/view/geofamclose.py index e0d2971f3..763c5ba37 100644 --- a/gramps/plugins/view/geofamclose.py +++ b/gramps/plugins/view/geofamclose.py @@ -148,6 +148,7 @@ class GeoFamClose(GeoGraphyView): self.minyear = 9999 self.maxyear = 0 self.reffamily = None + self.reffamily_bookmark = None self.nbplaces = 0 self.nbmarkers = 0 self.sort = [] @@ -194,17 +195,6 @@ class GeoFamClose(GeoGraphyView): """ return 'Family' - def add_bookmark(self, obj): - mlist = self.selected_handles() - if mlist: - self.bookmarks.add(mlist[0]) - 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 family_label(self,family): if family is None: return "Unknown" @@ -263,6 +253,9 @@ class GeoFamClose(GeoGraphyView): self.message_layer.add_message(_("The other family : %s" % self.family_label(f1))) else: 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) else: self.message_layer.add_message(_("You must choose one reference family.")) self.message_layer.add_message(_("Go to the family view and select " @@ -293,6 +286,8 @@ class GeoFamClose(GeoGraphyView): """ self.track = [] self.skip_list = [] + self.ref_family = None + self.reffamily_bookmark = None selectFamily = SelectorFactory('Family') sel = selectFamily(self.dbstate, self.uistate) self.reffamily = sel.run() @@ -696,7 +691,7 @@ class GeoFamClose(GeoGraphyView): add_item = Gtk.MenuItem() add_item.show() menu.append(add_item) - add_item = Gtk.MenuItem(label=_("Choose the reference family")) + add_item = Gtk.MenuItem(label=_("Choose and bookmark the new reference family")) add_item.connect("activate", self.selectFamily) add_item.show() menu.append(add_item) diff --git a/gramps/plugins/view/geofamily.py b/gramps/plugins/view/geofamily.py index 6619dddfd..22dc7a2dc 100644 --- a/gramps/plugins/view/geofamily.py +++ b/gramps/plugins/view/geofamily.py @@ -167,18 +167,6 @@ class GeoFamily(GeoGraphyView): """ return 'Family' - def add_bookmark(self, obj): - mlist = self.selected_handles() - print mlist - if mlist: - self.bookmarks.add(mlist[0]) - 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 goto_handle(self, handle=None): """ Rebuild the tree with the given person handle as the root. diff --git a/gramps/plugins/view/geomoves.py b/gramps/plugins/view/geomoves.py index 7f7dbf762..b74998863 100644 --- a/gramps/plugins/view/geomoves.py +++ b/gramps/plugins/view/geomoves.py @@ -198,17 +198,6 @@ class GeoMoves(GeoGraphyView): """ return 'Person' - def add_bookmark(self, obj): - mlist = self.selected_handles() - if mlist: - self.bookmarks.add(mlist[0]) - 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 goto_handle(self, handle=None): """ Rebuild the tree with the given family handle as reference. @@ -614,6 +603,12 @@ class GeoMoves(GeoGraphyView): center.connect("activate", self.center_here, event, lat, lon, prevmark) itemoption.append(center) + person = self.dbstate.db.get_person_from_gramps_id(mark[8]) + hdle = person.get_handle() + bookm = Gtk.MenuItem(label=_("Bookmark this person")) + bookm.show() + bookm.connect("activate", self.add_bookmark, hdle) + itemoption.append(bookm) menu.show() menu.popup(None, None, lambda menu, data: (event.get_root_coords()[0], diff --git a/gramps/plugins/view/geoperson.py b/gramps/plugins/view/geoperson.py index ef995e33d..e8a3c030e 100644 --- a/gramps/plugins/view/geoperson.py +++ b/gramps/plugins/view/geoperson.py @@ -197,17 +197,6 @@ class GeoPerson(GeoGraphyView): """ return 'Person' - def add_bookmark(self, obj): - mlist = self.selected_handles() - if mlist: - self.bookmarks.add(mlist[0]) - 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 goto_handle(self, handle=None): """ Rebuild the tree with the given person handle as the root. diff --git a/gramps/plugins/view/geoplaces.py b/gramps/plugins/view/geoplaces.py index 1df4eeb50..39aac72f4 100644 --- a/gramps/plugins/view/geoplaces.py +++ b/gramps/plugins/view/geoplaces.py @@ -168,17 +168,6 @@ class GeoPlaces(GeoGraphyView): """ return 'Place' - def add_bookmark(self, obj): - mlist = self.selected_handles() - if mlist: - self.bookmarks.add(mlist[0]) - 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 goto_handle(self, handle=None): """ Rebuild the tree with the given places handle as the root. @@ -341,6 +330,12 @@ class GeoPlaces(GeoGraphyView): center.connect("activate", self.center_here, event, lat, lon, prevmark) itemoption.append(center) + place = self.dbstate.db.get_place_from_gramps_id(mark[9]) + hdle = place.get_handle() + bookm = Gtk.MenuItem(label=_("Bookmark this place")) + bookm.show() + bookm.connect("activate", self.add_bookmark, hdle) + itemoption.append(bookm) message = "%s" % mark[0] prevmark = mark add_item = Gtk.MenuItem(label=message) @@ -359,6 +354,12 @@ class GeoPlaces(GeoGraphyView): center.show() center.connect("activate", self.center_here, event, lat, lon, prevmark) itemoption.append(center) + place = self.dbstate.db.get_place_from_gramps_id(mark[9]) + hdle = place.get_handle() + bookm = Gtk.MenuItem(label=_("Bookmark this place")) + bookm.show() + bookm.connect("activate", self.add_bookmark, hdle) + itemoption.append(bookm) menu.popup(None, None, lambda menu, data: (event.get_root_coords()[0], event.get_root_coords()[1], True),