Geography: simplify popup menu builder

This commit is contained in:
zradosłav 2021-02-18 22:35:21 +02:00 committed by Nick Hall
parent 57711d29ae
commit 13bff0de47
6 changed files with 7 additions and 41 deletions

View File

@ -401,7 +401,6 @@ class GeoGraphyView(OsmGps, NavigationView):
title = _('Add cross hair')
add_item = Gtk.MenuItem(label=title)
add_item.connect("activate", self.config_crosshair, event, lat, lon)
add_item.show()
menu.append(add_item)
if config.get("geography.lock"):
@ -411,51 +410,41 @@ class GeoGraphyView(OsmGps, NavigationView):
add_item = Gtk.MenuItem(label=title)
add_item.connect("activate", self.config_zoom_and_position,
event, lat, lon)
add_item.show()
menu.append(add_item)
add_item = Gtk.MenuItem(label=_("Add place"))
add_item.connect("activate", self.add_place, event, lat, lon)
add_item.show()
menu.append(add_item)
add_item = Gtk.MenuItem(label=_("Link place"))
add_item.connect("activate", self.link_place, event, lat, lon)
add_item.show()
menu.append(add_item)
add_item = Gtk.MenuItem(label=_("Add place from kml"))
add_item.connect("activate", self.add_place_from_kml, event, lat, lon)
add_item.show()
menu.append(add_item)
add_item = Gtk.MenuItem(label=_("Center here"))
add_item.connect("activate", self.set_center, event, lat, lon)
add_item.show()
menu.append(add_item)
# Add specific module menu
self.add_specific_menu(menu, event, lat, lon)
# Add a separator line
add_item = Gtk.SeparatorMenuItem()
add_item.show()
menu.append(add_item)
menu.append(Gtk.SeparatorMenuItem())
map_name = constants.MAP_TITLE[config.get("geography.map_service")]
title = _("Replace '%(map)s' by =>") % {'map': map_name}
add_item = Gtk.MenuItem(label=title)
add_item.show()
menu.append(add_item)
self.changemap = Gtk.Menu()
changemap = self.changemap
changemap.show()
add_item.set_submenu(changemap)
# show in the map menu all available providers
for my_map in constants.MAP_TYPE:
changemapitem = Gtk.CheckMenuItem(label=constants.MAP_TITLE[my_map])
changemapitem.set_active(constants.MAP_TITLE[my_map] == map_name)
changemapitem.show()
changemapitem.connect("activate", self.change_map, my_map)
changemap.append(changemapitem)
@ -465,7 +454,6 @@ class GeoGraphyView(OsmGps, NavigationView):
reloadtiles = self.reloadtiles
reloadtiles.connect("activate", self.reload_visible_tiles)
reloadtiles.show()
menu.append(reloadtiles)
clear_text = _("Clear the '%(map)s' tiles cache.") % {
@ -476,9 +464,8 @@ class GeoGraphyView(OsmGps, NavigationView):
constants.TILES_PATH[config.get(
"geography.map_service")])
clearmap.show()
menu.append(clearmap)
menu.show()
menu.show_all()
menu.popup(None, None, None,
None, event.button, event.time)
return 1

View File

@ -648,13 +648,10 @@ class GeoClose(GeoGraphyView):
"""
Add specific entry to the navigation menu.
"""
add_item = Gtk.SeparatorMenuItem()
add_item.show()
menu.append(add_item)
menu.append(Gtk.SeparatorMenuItem())
add_item = Gtk.MenuItem(
label=_("Choose and bookmark the new reference person"))
add_item.connect("activate", self.select_person)
add_item.show()
menu.append(add_item)
return

View File

@ -450,26 +450,20 @@ class GeoEvents(GeoGraphyView):
"""
Add specific entry to the navigation menu.
"""
add_item = Gtk.SeparatorMenuItem()
add_item.show()
menu.append(add_item)
menu.append(Gtk.SeparatorMenuItem())
add_item = Gtk.MenuItem(label=_("Show all events"))
add_item.connect("activate", self.show_all_events, event, lat, lon)
add_item.show()
menu.append(add_item)
add_item = Gtk.MenuItem(label=_("Centering on Place"))
add_item.show()
menu.append(add_item)
self.itemoption = Gtk.Menu()
itemoption = self.itemoption
itemoption.show()
add_item.set_submenu(itemoption)
oldplace = ""
for mark in self.sort:
if mark[0] != oldplace:
oldplace = mark[0]
modify = Gtk.MenuItem(label=mark[0])
modify.show()
modify.connect("activate", self.goto_place,
float(mark[3]), float(mark[4]))
itemoption.append(modify)

View File

@ -831,13 +831,10 @@ class GeoFamClose(GeoGraphyView):
"""
Add specific entry to the navigation menu.
"""
add_item = Gtk.SeparatorMenuItem()
add_item.show()
menu.append(add_item)
menu.append(Gtk.SeparatorMenuItem())
add_item = Gtk.MenuItem(
label=_("Choose and bookmark the new reference family"))
add_item.connect("activate", self.select_family)
add_item.show()
menu.append(add_item)
return

View File

@ -577,12 +577,9 @@ class GeoPerson(GeoGraphyView):
"""
Add specific entry to the navigation menu.
"""
add_item = Gtk.SeparatorMenuItem()
add_item.show()
menu.append(add_item)
menu.append(Gtk.SeparatorMenuItem())
add_item = Gtk.MenuItem(label=_("Animate"))
add_item.connect("activate", self.animate, self.sort, 0, 0)
add_item.show()
menu.append(add_item)
return

View File

@ -539,27 +539,21 @@ class GeoPlaces(GeoGraphyView):
"""
Add specific entry to the navigation menu.
"""
add_item = Gtk.SeparatorMenuItem()
add_item.show()
menu.append(add_item)
menu.append(Gtk.SeparatorMenuItem())
add_item = Gtk.MenuItem(label=_("Show all places"))
add_item.connect("activate", self.show_all_places, event, lat, lon)
add_item.show()
menu.append(add_item)
add_item = Gtk.MenuItem(label=_("Centering on Place"))
add_item.show()
menu.append(add_item)
self.itemoption = Gtk.Menu()
itemoption = self.itemoption
itemoption.show()
add_item.set_submenu(itemoption)
oldplace = ""
for mark in self.sort:
if mark[0] != oldplace:
oldplace = mark[0]
modify = Gtk.MenuItem(label=mark[0])
modify.show()
modify.connect("activate", self.goto_place,
float(mark[3]), float(mark[4]))
itemoption.append(modify)