From 2b38921991a95b6775c3bdc7a663f31f5bbea7cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zrados=C5=82av?= Date: Thu, 18 Feb 2021 22:20:12 +0200 Subject: [PATCH 1/4] Geography: Change Gtk.MenuItem to Gtk.CheckMenuItem for map providers --- gramps/plugins/lib/maps/geography.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gramps/plugins/lib/maps/geography.py b/gramps/plugins/lib/maps/geography.py index 9a2a5fe6f..de3ece986 100644 --- a/gramps/plugins/lib/maps/geography.py +++ b/gramps/plugins/lib/maps/geography.py @@ -453,7 +453,8 @@ class GeoGraphyView(OsmGps, NavigationView): add_item.set_submenu(changemap) # show in the map menu all available providers for my_map in constants.MAP_TYPE: - changemapitem = Gtk.MenuItem(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.show() changemapitem.connect("activate", self.change_map, my_map) changemap.append(changemapitem) From 57711d29ae4157eef2f2c1b60e79ad8f00672885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zrados=C5=82av?= Date: Thu, 18 Feb 2021 22:30:25 +0200 Subject: [PATCH 2/4] Geography: Use Gtk.SeparatorMenuItem instead of empty Gtk.MenuItem --- gramps/plugins/lib/maps/geography.py | 2 +- gramps/plugins/view/geoclose.py | 2 +- gramps/plugins/view/geoevents.py | 2 +- gramps/plugins/view/geofamclose.py | 2 +- gramps/plugins/view/geoperson.py | 2 +- gramps/plugins/view/geoplaces.py | 3 ++- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gramps/plugins/lib/maps/geography.py b/gramps/plugins/lib/maps/geography.py index de3ece986..6492a801d 100644 --- a/gramps/plugins/lib/maps/geography.py +++ b/gramps/plugins/lib/maps/geography.py @@ -437,7 +437,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() + add_item = Gtk.SeparatorMenuItem() add_item.show() menu.append(add_item) diff --git a/gramps/plugins/view/geoclose.py b/gramps/plugins/view/geoclose.py index b22152928..09ea12864 100644 --- a/gramps/plugins/view/geoclose.py +++ b/gramps/plugins/view/geoclose.py @@ -648,7 +648,7 @@ class GeoClose(GeoGraphyView): """ Add specific entry to the navigation menu. """ - add_item = Gtk.MenuItem() + add_item = Gtk.SeparatorMenuItem() add_item.show() menu.append(add_item) add_item = Gtk.MenuItem( diff --git a/gramps/plugins/view/geoevents.py b/gramps/plugins/view/geoevents.py index 479565c15..22894aac9 100644 --- a/gramps/plugins/view/geoevents.py +++ b/gramps/plugins/view/geoevents.py @@ -450,7 +450,7 @@ class GeoEvents(GeoGraphyView): """ Add specific entry to the navigation menu. """ - add_item = Gtk.MenuItem() + add_item = Gtk.SeparatorMenuItem() add_item.show() menu.append(add_item) add_item = Gtk.MenuItem(label=_("Show all events")) diff --git a/gramps/plugins/view/geofamclose.py b/gramps/plugins/view/geofamclose.py index 739a3b517..8bc73e3b5 100644 --- a/gramps/plugins/view/geofamclose.py +++ b/gramps/plugins/view/geofamclose.py @@ -831,7 +831,7 @@ class GeoFamClose(GeoGraphyView): """ Add specific entry to the navigation menu. """ - add_item = Gtk.MenuItem() + add_item = Gtk.SeparatorMenuItem() add_item.show() menu.append(add_item) add_item = Gtk.MenuItem( diff --git a/gramps/plugins/view/geoperson.py b/gramps/plugins/view/geoperson.py index ec42546bd..1529e9c5e 100644 --- a/gramps/plugins/view/geoperson.py +++ b/gramps/plugins/view/geoperson.py @@ -577,7 +577,7 @@ class GeoPerson(GeoGraphyView): """ Add specific entry to the navigation menu. """ - add_item = Gtk.MenuItem() + add_item = Gtk.SeparatorMenuItem() add_item.show() menu.append(add_item) add_item = Gtk.MenuItem(label=_("Animate")) diff --git a/gramps/plugins/view/geoplaces.py b/gramps/plugins/view/geoplaces.py index 48d74da52..55dae1798 100644 --- a/gramps/plugins/view/geoplaces.py +++ b/gramps/plugins/view/geoplaces.py @@ -539,9 +539,10 @@ class GeoPlaces(GeoGraphyView): """ Add specific entry to the navigation menu. """ - add_item = Gtk.MenuItem() + add_item = Gtk.SeparatorMenuItem() add_item.show() menu.append(add_item) + add_item = Gtk.MenuItem(label=_("Show all places")) add_item.connect("activate", self.show_all_places, event, lat, lon) add_item.show() From 13bff0de47e3f88bb51f9654344b89a6147a75be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zrados=C5=82av?= Date: Thu, 18 Feb 2021 22:35:21 +0200 Subject: [PATCH 3/4] Geography: simplify popup menu builder --- gramps/plugins/lib/maps/geography.py | 17 ++--------------- gramps/plugins/view/geoclose.py | 5 +---- gramps/plugins/view/geoevents.py | 8 +------- gramps/plugins/view/geofamclose.py | 5 +---- gramps/plugins/view/geoperson.py | 5 +---- gramps/plugins/view/geoplaces.py | 8 +------- 6 files changed, 7 insertions(+), 41 deletions(-) diff --git a/gramps/plugins/lib/maps/geography.py b/gramps/plugins/lib/maps/geography.py index 6492a801d..72bc29140 100644 --- a/gramps/plugins/lib/maps/geography.py +++ b/gramps/plugins/lib/maps/geography.py @@ -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 diff --git a/gramps/plugins/view/geoclose.py b/gramps/plugins/view/geoclose.py index 09ea12864..02cba62f8 100644 --- a/gramps/plugins/view/geoclose.py +++ b/gramps/plugins/view/geoclose.py @@ -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 diff --git a/gramps/plugins/view/geoevents.py b/gramps/plugins/view/geoevents.py index 22894aac9..3effc56b9 100644 --- a/gramps/plugins/view/geoevents.py +++ b/gramps/plugins/view/geoevents.py @@ -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) diff --git a/gramps/plugins/view/geofamclose.py b/gramps/plugins/view/geofamclose.py index 8bc73e3b5..f7c40b8da 100644 --- a/gramps/plugins/view/geofamclose.py +++ b/gramps/plugins/view/geofamclose.py @@ -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 diff --git a/gramps/plugins/view/geoperson.py b/gramps/plugins/view/geoperson.py index 1529e9c5e..6d3ea1abe 100644 --- a/gramps/plugins/view/geoperson.py +++ b/gramps/plugins/view/geoperson.py @@ -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 diff --git a/gramps/plugins/view/geoplaces.py b/gramps/plugins/view/geoplaces.py index 55dae1798..1cf722d86 100644 --- a/gramps/plugins/view/geoplaces.py +++ b/gramps/plugins/view/geoplaces.py @@ -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) From 255d4e49977166b04f3db92c964712d331609f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zrados=C5=82av?= Date: Thu, 18 Feb 2021 22:44:54 +0200 Subject: [PATCH 4/4] Geography: remove redundant class members --- gramps/plugins/lib/maps/geography.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/gramps/plugins/lib/maps/geography.py b/gramps/plugins/lib/maps/geography.py index 72bc29140..9ac4e0afc 100644 --- a/gramps/plugins/lib/maps/geography.py +++ b/gramps/plugins/lib/maps/geography.py @@ -183,7 +183,6 @@ class GeoGraphyView(OsmGps, NavigationView): self.place_list_ref = [] self.select_fct = None self.geo_mainmap = None - self.reloadtiles = None theme = Gtk.IconTheme.get_default() self.geo_mainmap = theme.load_surface('gramps-geo-mainmap', 48, 1, None, 0) @@ -208,8 +207,6 @@ class GeoGraphyView(OsmGps, NavigationView): self.menu = None self.mark = None self.path_entry = None - self.changemap = None - self.clearmap = None self.nbplaces = 0 self.nbmarkers = 0 self.place_without_coordinates = [] @@ -438,8 +435,7 @@ class GeoGraphyView(OsmGps, NavigationView): add_item = Gtk.MenuItem(label=title) menu.append(add_item) - self.changemap = Gtk.Menu() - changemap = self.changemap + changemap = Gtk.Menu() add_item.set_submenu(changemap) # show in the map menu all available providers for my_map in constants.MAP_TYPE: @@ -449,17 +445,15 @@ class GeoGraphyView(OsmGps, NavigationView): changemap.append(changemapitem) reload_text = _("Reload all visible tiles for '%(map)s'.") % { - 'map': map_name} - self.reloadtiles = Gtk.MenuItem(label=reload_text) - reloadtiles = self.reloadtiles + 'map' : map_name} + reloadtiles = Gtk.MenuItem(label=reload_text) reloadtiles.connect("activate", self.reload_visible_tiles) menu.append(reloadtiles) clear_text = _("Clear the '%(map)s' tiles cache.") % { - 'map': map_name} - self.clearmap = Gtk.MenuItem(label=clear_text) - clearmap = self.clearmap + 'map' : map_name} + clearmap = Gtk.MenuItem(label=clear_text) clearmap.connect("activate", self.clear_map, constants.TILES_PATH[config.get( "geography.map_service")])