def __init__(self): Clutter.Box.__init__(self) self.set_layout_manager(Clutter.BinLayout()) self.set_color(Clutter.Color.new(0, 0, 0, 96)) Gst.bind('show-map-coords', self, 'visible') MapView.bin_layout_add(self, START, START) self.get_layout_manager().add(CoordLabel, CENTER, CENTER) MapView.connect('notify::width', lambda *ignore: self.set_size(MapView.get_width(), 30))
('latitude', 'longitude', 'zoom-level')]) if history[-1] != location: history.append(location) Gst.set_history(history[-30:]) def go_back(*ignore): """Return the map view to where the user last set it.""" history = list(Gst.get('history')) lat, lon, zoom = history.pop() if valid_coords(lat, lon): MapView.set_zoom_level(zoom) MapView.center_on(lat, lon) if len(history) > 1: Gst.set_history(history) else: Gst.reset('history') def zoom_button_sensitivity(view, signal, in_sensitive, out_sensitive): """Ensure zoom buttons are only sensitive when they need to be.""" zoom = view.get_zoom_level() out_sensitive(view.get_min_zoom_level() != zoom) in_sensitive( view.get_max_zoom_level() != zoom) for prop in ('latitude', 'longitude', 'zoom-level'): Gst.bind(prop, MapView, prop) MapView.connect('notify::zoom-level', zoom_button_sensitivity, Widgets.zoom_in_button.set_sensitive, Widgets.zoom_out_button.set_sensitive) MapView.connect('realize', remember_location)