Geography: simplify popup menu builder
This commit is contained in:
parent
57711d29ae
commit
13bff0de47
@ -401,7 +401,6 @@ class GeoGraphyView(OsmGps, NavigationView):
|
|||||||
title = _('Add cross hair')
|
title = _('Add cross hair')
|
||||||
add_item = Gtk.MenuItem(label=title)
|
add_item = Gtk.MenuItem(label=title)
|
||||||
add_item.connect("activate", self.config_crosshair, event, lat, lon)
|
add_item.connect("activate", self.config_crosshair, event, lat, lon)
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
menu.append(add_item)
|
||||||
|
|
||||||
if config.get("geography.lock"):
|
if config.get("geography.lock"):
|
||||||
@ -411,51 +410,41 @@ class GeoGraphyView(OsmGps, NavigationView):
|
|||||||
add_item = Gtk.MenuItem(label=title)
|
add_item = Gtk.MenuItem(label=title)
|
||||||
add_item.connect("activate", self.config_zoom_and_position,
|
add_item.connect("activate", self.config_zoom_and_position,
|
||||||
event, lat, lon)
|
event, lat, lon)
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
menu.append(add_item)
|
||||||
|
|
||||||
add_item = Gtk.MenuItem(label=_("Add place"))
|
add_item = Gtk.MenuItem(label=_("Add place"))
|
||||||
add_item.connect("activate", self.add_place, event, lat, lon)
|
add_item.connect("activate", self.add_place, event, lat, lon)
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
menu.append(add_item)
|
||||||
|
|
||||||
add_item = Gtk.MenuItem(label=_("Link place"))
|
add_item = Gtk.MenuItem(label=_("Link place"))
|
||||||
add_item.connect("activate", self.link_place, event, lat, lon)
|
add_item.connect("activate", self.link_place, event, lat, lon)
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
menu.append(add_item)
|
||||||
|
|
||||||
add_item = Gtk.MenuItem(label=_("Add place from kml"))
|
add_item = Gtk.MenuItem(label=_("Add place from kml"))
|
||||||
add_item.connect("activate", self.add_place_from_kml, event, lat, lon)
|
add_item.connect("activate", self.add_place_from_kml, event, lat, lon)
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
menu.append(add_item)
|
||||||
|
|
||||||
add_item = Gtk.MenuItem(label=_("Center here"))
|
add_item = Gtk.MenuItem(label=_("Center here"))
|
||||||
add_item.connect("activate", self.set_center, event, lat, lon)
|
add_item.connect("activate", self.set_center, event, lat, lon)
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
menu.append(add_item)
|
||||||
|
|
||||||
# Add specific module menu
|
# Add specific module menu
|
||||||
self.add_specific_menu(menu, event, lat, lon)
|
self.add_specific_menu(menu, event, lat, lon)
|
||||||
# Add a separator line
|
# Add a separator line
|
||||||
add_item = Gtk.SeparatorMenuItem()
|
menu.append(Gtk.SeparatorMenuItem())
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
|
||||||
|
|
||||||
map_name = constants.MAP_TITLE[config.get("geography.map_service")]
|
map_name = constants.MAP_TITLE[config.get("geography.map_service")]
|
||||||
title = _("Replace '%(map)s' by =>") % {'map': map_name}
|
title = _("Replace '%(map)s' by =>") % {'map': map_name}
|
||||||
add_item = Gtk.MenuItem(label=title)
|
add_item = Gtk.MenuItem(label=title)
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
menu.append(add_item)
|
||||||
|
|
||||||
self.changemap = Gtk.Menu()
|
self.changemap = Gtk.Menu()
|
||||||
changemap = self.changemap
|
changemap = self.changemap
|
||||||
changemap.show()
|
|
||||||
add_item.set_submenu(changemap)
|
add_item.set_submenu(changemap)
|
||||||
# show in the map menu all available providers
|
# show in the map menu all available providers
|
||||||
for my_map in constants.MAP_TYPE:
|
for my_map in constants.MAP_TYPE:
|
||||||
changemapitem = Gtk.CheckMenuItem(label=constants.MAP_TITLE[my_map])
|
changemapitem = Gtk.CheckMenuItem(label=constants.MAP_TITLE[my_map])
|
||||||
changemapitem.set_active(constants.MAP_TITLE[my_map] == map_name)
|
changemapitem.set_active(constants.MAP_TITLE[my_map] == map_name)
|
||||||
changemapitem.show()
|
|
||||||
changemapitem.connect("activate", self.change_map, my_map)
|
changemapitem.connect("activate", self.change_map, my_map)
|
||||||
changemap.append(changemapitem)
|
changemap.append(changemapitem)
|
||||||
|
|
||||||
@ -465,7 +454,6 @@ class GeoGraphyView(OsmGps, NavigationView):
|
|||||||
reloadtiles = self.reloadtiles
|
reloadtiles = self.reloadtiles
|
||||||
reloadtiles.connect("activate", self.reload_visible_tiles)
|
reloadtiles.connect("activate", self.reload_visible_tiles)
|
||||||
|
|
||||||
reloadtiles.show()
|
|
||||||
menu.append(reloadtiles)
|
menu.append(reloadtiles)
|
||||||
|
|
||||||
clear_text = _("Clear the '%(map)s' tiles cache.") % {
|
clear_text = _("Clear the '%(map)s' tiles cache.") % {
|
||||||
@ -476,9 +464,8 @@ class GeoGraphyView(OsmGps, NavigationView):
|
|||||||
constants.TILES_PATH[config.get(
|
constants.TILES_PATH[config.get(
|
||||||
"geography.map_service")])
|
"geography.map_service")])
|
||||||
|
|
||||||
clearmap.show()
|
|
||||||
menu.append(clearmap)
|
menu.append(clearmap)
|
||||||
menu.show()
|
menu.show_all()
|
||||||
menu.popup(None, None, None,
|
menu.popup(None, None, None,
|
||||||
None, event.button, event.time)
|
None, event.button, event.time)
|
||||||
return 1
|
return 1
|
||||||
|
@ -648,13 +648,10 @@ class GeoClose(GeoGraphyView):
|
|||||||
"""
|
"""
|
||||||
Add specific entry to the navigation menu.
|
Add specific entry to the navigation menu.
|
||||||
"""
|
"""
|
||||||
add_item = Gtk.SeparatorMenuItem()
|
menu.append(Gtk.SeparatorMenuItem())
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
|
||||||
add_item = Gtk.MenuItem(
|
add_item = Gtk.MenuItem(
|
||||||
label=_("Choose and bookmark the new reference person"))
|
label=_("Choose and bookmark the new reference person"))
|
||||||
add_item.connect("activate", self.select_person)
|
add_item.connect("activate", self.select_person)
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
menu.append(add_item)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -450,26 +450,20 @@ class GeoEvents(GeoGraphyView):
|
|||||||
"""
|
"""
|
||||||
Add specific entry to the navigation menu.
|
Add specific entry to the navigation menu.
|
||||||
"""
|
"""
|
||||||
add_item = Gtk.SeparatorMenuItem()
|
menu.append(Gtk.SeparatorMenuItem())
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
|
||||||
add_item = Gtk.MenuItem(label=_("Show all events"))
|
add_item = Gtk.MenuItem(label=_("Show all events"))
|
||||||
add_item.connect("activate", self.show_all_events, event, lat, lon)
|
add_item.connect("activate", self.show_all_events, event, lat, lon)
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
menu.append(add_item)
|
||||||
add_item = Gtk.MenuItem(label=_("Centering on Place"))
|
add_item = Gtk.MenuItem(label=_("Centering on Place"))
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
menu.append(add_item)
|
||||||
self.itemoption = Gtk.Menu()
|
self.itemoption = Gtk.Menu()
|
||||||
itemoption = self.itemoption
|
itemoption = self.itemoption
|
||||||
itemoption.show()
|
|
||||||
add_item.set_submenu(itemoption)
|
add_item.set_submenu(itemoption)
|
||||||
oldplace = ""
|
oldplace = ""
|
||||||
for mark in self.sort:
|
for mark in self.sort:
|
||||||
if mark[0] != oldplace:
|
if mark[0] != oldplace:
|
||||||
oldplace = mark[0]
|
oldplace = mark[0]
|
||||||
modify = Gtk.MenuItem(label=mark[0])
|
modify = Gtk.MenuItem(label=mark[0])
|
||||||
modify.show()
|
|
||||||
modify.connect("activate", self.goto_place,
|
modify.connect("activate", self.goto_place,
|
||||||
float(mark[3]), float(mark[4]))
|
float(mark[3]), float(mark[4]))
|
||||||
itemoption.append(modify)
|
itemoption.append(modify)
|
||||||
|
@ -831,13 +831,10 @@ class GeoFamClose(GeoGraphyView):
|
|||||||
"""
|
"""
|
||||||
Add specific entry to the navigation menu.
|
Add specific entry to the navigation menu.
|
||||||
"""
|
"""
|
||||||
add_item = Gtk.SeparatorMenuItem()
|
menu.append(Gtk.SeparatorMenuItem())
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
|
||||||
add_item = Gtk.MenuItem(
|
add_item = Gtk.MenuItem(
|
||||||
label=_("Choose and bookmark the new reference family"))
|
label=_("Choose and bookmark the new reference family"))
|
||||||
add_item.connect("activate", self.select_family)
|
add_item.connect("activate", self.select_family)
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
menu.append(add_item)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -577,12 +577,9 @@ class GeoPerson(GeoGraphyView):
|
|||||||
"""
|
"""
|
||||||
Add specific entry to the navigation menu.
|
Add specific entry to the navigation menu.
|
||||||
"""
|
"""
|
||||||
add_item = Gtk.SeparatorMenuItem()
|
menu.append(Gtk.SeparatorMenuItem())
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
|
||||||
add_item = Gtk.MenuItem(label=_("Animate"))
|
add_item = Gtk.MenuItem(label=_("Animate"))
|
||||||
add_item.connect("activate", self.animate, self.sort, 0, 0)
|
add_item.connect("activate", self.animate, self.sort, 0, 0)
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
menu.append(add_item)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -539,27 +539,21 @@ class GeoPlaces(GeoGraphyView):
|
|||||||
"""
|
"""
|
||||||
Add specific entry to the navigation menu.
|
Add specific entry to the navigation menu.
|
||||||
"""
|
"""
|
||||||
add_item = Gtk.SeparatorMenuItem()
|
menu.append(Gtk.SeparatorMenuItem())
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
|
||||||
|
|
||||||
add_item = Gtk.MenuItem(label=_("Show all places"))
|
add_item = Gtk.MenuItem(label=_("Show all places"))
|
||||||
add_item.connect("activate", self.show_all_places, event, lat, lon)
|
add_item.connect("activate", self.show_all_places, event, lat, lon)
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
menu.append(add_item)
|
||||||
add_item = Gtk.MenuItem(label=_("Centering on Place"))
|
add_item = Gtk.MenuItem(label=_("Centering on Place"))
|
||||||
add_item.show()
|
|
||||||
menu.append(add_item)
|
menu.append(add_item)
|
||||||
self.itemoption = Gtk.Menu()
|
self.itemoption = Gtk.Menu()
|
||||||
itemoption = self.itemoption
|
itemoption = self.itemoption
|
||||||
itemoption.show()
|
|
||||||
add_item.set_submenu(itemoption)
|
add_item.set_submenu(itemoption)
|
||||||
oldplace = ""
|
oldplace = ""
|
||||||
for mark in self.sort:
|
for mark in self.sort:
|
||||||
if mark[0] != oldplace:
|
if mark[0] != oldplace:
|
||||||
oldplace = mark[0]
|
oldplace = mark[0]
|
||||||
modify = Gtk.MenuItem(label=mark[0])
|
modify = Gtk.MenuItem(label=mark[0])
|
||||||
modify.show()
|
|
||||||
modify.connect("activate", self.goto_place,
|
modify.connect("activate", self.goto_place,
|
||||||
float(mark[3]), float(mark[4]))
|
float(mark[3]), float(mark[4]))
|
||||||
itemoption.append(modify)
|
itemoption.append(modify)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user