def test_gsettings(self): """Make sure that GSettings is storing data correctly.""" app.gst.reset('history') self.assertEqual(gst_get('history')[0], (34.5, 15.8, 2)) map_view.center_on(12.3, 45.6) self.assertEqual(app.gst.get_double('latitude'), 12.3) self.assertEqual(app.gst.get_double('longitude'), 45.6) map_view.zoom_in() map_view.emit('realize') self.assertEqual(list(gst_get('history')), [(34.5, 15.8, 2), (12.3, 45.6, 3)]) map_view.set_map_source(MAP_SOURCES['osm-cyclemap']) self.assertEqual(app.gst.get_string('map-source-id'), 'osm-cyclemap')
def map_source_menu(): """Load the predefined map sources into a menu the user can use.""" radio_group = [] map_menu = get_obj('map_source_menu') last_source = gst.get_string('map-source-id') gst.bind_with_convert('map-source-id', map_view, 'map-source', MAP_SOURCES.get, lambda x: x.get_id()) menu_item_clicked = (lambda item, mapid: item.get_active() and map_view.set_map_source(MAP_SOURCES[mapid])) for i, source_id in enumerate(sorted(MAP_SOURCES.keys())): source = MAP_SOURCES[source_id] menu_item = Gtk.RadioMenuItem.new_with_label(radio_group, source.get_name()) radio_group.append(menu_item) if last_source == source_id: menu_item.set_active(True) menu_item.connect('activate', menu_item_clicked, source_id) map_menu.attach(menu_item, 0, 1, i, i+1) map_menu.show_all()