Geography : Adding bookmarks (follow bug 7240)

This commit is contained in:
noirauds 2014-02-19 23:13:20 +01:00
parent 32c312f7d9
commit 16fecf125b
8 changed files with 58 additions and 80 deletions

View File

@ -183,6 +183,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.
@ -231,6 +243,7 @@ class GeoGraphyView(OsmGps, NavigationView):
"""
if self.active:
self.bookmarks.redraw()
self.build_tree()
def can_configure(self):
"""
@ -331,7 +344,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)

View File

@ -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)

View File

@ -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),

View File

@ -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)

View File

@ -167,17 +167,6 @@ class GeoFamily(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 goto_handle(self, handle=None):
"""
Rebuild the tree with the given person handle as the root.

View File

@ -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],

View File

@ -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.

View File

@ -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),