def __init__(self, parent): GtkChamplain.Embed.__init__(self) self.set_size_request(640, 480) self.parent = parent self.view = self.get_view() self.view.set_reactive(True) self.view.set_kinetic_mode(True) self.view.set_zoom_level(13) self.view.center_on(36.72341, -4.42428) # TODO: Set to center of default zone self.view.connect('button-release-event', self.mouse_click_cb) scale = Champlain.Scale() scale.connect_view(self.view) self.view.bin_layout_add(scale, Clutter.BinAlignment.START, Clutter.BinAlignment.END) self.points_layer = Champlain.MarkerLayer() self.points_layer.set_selection_mode(Champlain.SelectionMode.SINGLE) self.labels_layer = Champlain.MarkerLayer() # It's important to add points the last. Points are selectable while labels are not # If labels is added later, then you click on some point and it doesn't get selected # because you are really clicking on the label. Looks like an usability bug? self.view.add_layer(self.labels_layer) self.view.add_layer(self.points_layer) self.menu = Gtk.Menu() menuitem1 = Gtk.MenuItem('Create new Guifi.net node here') menuitem1.connect('activate', self.create_new_node) self.menu.append(menuitem1) self.menu.show_all()
def __init__(self): self.window = Gtk.Window() self.window.set_border_width(10) self.window.set_title("GeoClue2 + GTK Python Demo") self.window.connect("destroy", Gtk.main_quit) vbox = Gtk.VBox(False, 10) embed = GtkChamplain.Embed() self.view = embed.get_view() self.view.set_reactive(True) self.view.set_property('kinetic-mode', True) self.view.set_property('zoom-level', 5) scale = Champlain.Scale() scale.connect_view(self.view) self.view.bin_layout_add(scale, Clutter.BinAlignment.START, Clutter.BinAlignment.END) license = self.view.get_license_actor() embed.set_size_request(640, 480) bbox = Gtk.HBox(False, 10) button = Gtk.Button(stock=Gtk.STOCK_ZOOM_IN) button.connect("clicked", self.zoom_in) bbox.add(button) button = Gtk.Button(stock=Gtk.STOCK_ZOOM_OUT) button.connect("clicked", self.zoom_out) bbox.add(button) button = Gtk.ToggleButton(label="Current Location") button.set_active(False) button.connect("toggled", self.get_location) bbox.add(button) self.spinbutton = Gtk.SpinButton.new_with_range(0, 20, 1) self.spinbutton.connect("changed", self.zoom_changed) self.view.connect("notify::zoom-level", self.map_zoom_changed) self.spinbutton.set_value(5) bbox.add(self.spinbutton) button = Gtk.Image() self.view.connect("notify::state", self.view_state_changed, button) bbox.pack_end(button, False, False, 0) vbox.pack_start(bbox, expand=False, fill=False, padding=0) vbox.add(embed) self.window.add(vbox) self.window.show_all()
def make_map(self): embed = GtkChamplain.Embed() self.view = embed.get_view() self.view.set_reactive(True) self.view.set_property('kinetic-mode', True) self.view.set_property('zoom-level', 5) scale = Champlain.Scale() scale.connect_view(self.view) #self.view.bin_layout_add(scale, Clutter.BinAlignment.START, # Clutter.BinAlignment.END) license = self.view.get_license_actor() license.set_extra_text("Do what you want but I am RMFlynn") self.view.center_on(39.739, -104.984) self.marker_layer = Champlain.MarkerLayer() self.view.add_layer(self.marker_layer) self.marker_layer.show() return embed
def __init__(self, controller): self.controller = controller GObject.threads_init() # Glade builder = Gtk.Builder() builder.add_from_file("GeoSVG.glade") self.window = builder.get_object("window") boxes = builder.get_object("boxes") open_btn = builder.get_object("open_btn") self.preview = builder.get_object("preview") self.layers_tree = builder.get_object("layers_tree") self.lim_north = builder.get_object("lim_north") self.lim_south = builder.get_object("lim_south") self.lim_east = builder.get_object("lim_east") self.lim_west = builder.get_object("lim_west") self.rotation = builder.get_object("rotation") self.output = builder.get_object("output") self.last_click = builder.get_object("last_click") replace_north_lim = builder.get_object("replace_north_lim") replace_south_lim = builder.get_object("replace_south_lim") replace_east_lim = builder.get_object("replace_east_lim") replace_west_lim = builder.get_object("replace_west_lim") # Map embed = GtkChamplain.Embed() self.map_view = embed.get_view() self.map_view.set_reactive(True) self.map_view.set_property('kinetic-mode', True) self.map_view.set_property('zoom-level', 16) scale = Champlain.Scale() scale.connect_view(self.map_view) self.map_view.bin_layout_add(scale, Clutter.BinAlignment.START, Clutter.BinAlignment.END) self.map_view.center_on(38.66, -9.20523) boxes.add(embed) # Layers pane self.layers_liststore = Gtk.ListStore(str, bool) self.layers_tree.set_model(self.layers_liststore) column_text = Gtk.TreeViewColumn("Name", Gtk.CellRendererText(), text=0) self.layers_tree.append_column(column_text) renderer_toggle = Gtk.CellRendererToggle() column_toggle = Gtk.TreeViewColumn("Enable", renderer_toggle, active=1) self.layers_tree.append_column(column_toggle) self.window.show_all() # Events renderer_toggle.connect("toggled", self.__on_layer_toggled) self.window.connect("destroy", Gtk.main_quit) open_btn.connect('clicked', self.open_file) self.lim_north.connect('changed', self.__update_north_lim) self.lim_south.connect('changed', self.__update_south_lim) self.lim_east.connect('changed', self.__update_east_lim) self.lim_west.connect('changed', self.__update_west_lim) self.rotation.connect( 'changed', lambda w: self.controller.update_rotation(w.get_value())) self.map_view.connect('button-release-event', self.__on_map_mouse_click, self.map_view) replace_north_lim.connect('clicked', lambda _: self.controller.replace_lim('N')) replace_south_lim.connect('clicked', lambda _: self.controller.replace_lim('S')) replace_east_lim.connect('clicked', lambda _: self.controller.replace_lim('E')) replace_west_lim.connect('clicked', lambda _: self.controller.replace_lim('W')) # Drawn layers self.layers = []
def __init__(self): self.window = Gtk.Window() self.window.set_border_width(10) self.window.set_title("libchamplain Gtk+ demo (python introspection)") self.window.connect("destroy", Gtk.main_quit) vbox = Gtk.VBox(False, 10) embed = GtkChamplain.Embed() self.view = embed.get_view() self.view.set_reactive(True) self.view.connect('button-release-event', self.mouse_click_cb, self.view) self.view.set_property('kinetic-mode', True) self.view.set_property('zoom-level', 5) scale = Champlain.Scale() scale.connect_view(self.view) self.view.bin_layout_add(scale, Clutter.BinAlignment.START, Clutter.BinAlignment.END) license = self.view.get_license_actor() license.set_extra_text("Don't eat cereals with orange juice\nIt tastes bad") self.view.center_on(45.466, -73.75) self.layer = self.create_marker_layer(self.view) self.view.add_layer(self.layer) self.layer.hide_all_markers() self.path_layer = Champlain.PathLayer() # Cheap approx of Highway 10 self.add_node(self.path_layer, 45.4095, -73.3197) self.add_node(self.path_layer, 45.4104, -73.2846) self.add_node(self.path_layer, 45.4178, -73.2239) self.add_node(self.path_layer, 45.4176, -73.2181) self.add_node(self.path_layer, 45.4151, -73.2126) self.add_node(self.path_layer, 45.4016, -73.1926) self.add_node(self.path_layer, 45.3994, -73.1877) self.add_node(self.path_layer, 45.4000, -73.1815) self.add_node(self.path_layer, 45.4151, -73.1218) self.view.add_layer(self.path_layer) embed.set_size_request(640, 480) bbox = Gtk.HBox(False, 10) button = Gtk.Button(stock=Gtk.STOCK_ZOOM_IN) button.connect("clicked", self.zoom_in) bbox.add(button) button = Gtk.Button(stock=Gtk.STOCK_ZOOM_OUT) button.connect("clicked", self.zoom_out) bbox.add(button) button = Gtk.ToggleButton(label="Markers") button.set_active(False) button.connect("toggled", self.toggle_layer) bbox.add(button) combo = Gtk.ComboBox() map_source_factory = Champlain.MapSourceFactory.dup_default() liststore = Gtk.ListStore(str, str) for source in map_source_factory.get_registered(): liststore.append([source.get_id(), source.get_name()]) combo.set_model(liststore) cell = Gtk.CellRendererText() combo.pack_start(cell, False) combo.add_attribute(cell, 'text', 1) combo.connect("changed", self.map_source_changed) combo.set_active(0) bbox.add(combo) self.spinbutton = Gtk.SpinButton.new_with_range(0, 20, 1) self.spinbutton.connect("changed", self.zoom_changed) self.view.connect("notify::zoom-level", self.map_zoom_changed) self.spinbutton.set_value(5) bbox.add(self.spinbutton) button = Gtk.Image() self.view.connect("notify::state", self.view_state_changed, button) bbox.pack_end(button, False, False, 0) vbox.pack_start(bbox, expand=False, fill=False, padding=0) vbox.add(embed) self.window.add(vbox) self.window.show_all()
def on_run(self): if not self.is_active: pres_keys = sorted(self.plugin.config['presets'].keys()) for key in pres_keys: self.preset_liststore.append((key, )) for name in self.plugin.config_default_values: if name == 'presets': continue widget = self.xml.get_object(name) widget.set_text(str(self.plugin.config[name])) map_placeholder = self.xml.get_object('map_placeholder') dependency_bar = self.xml.get_object('dependency_warning') if CHAMPLAIN_AVAILABLE and not self.is_active: map_placeholder.set_no_show_all(True) map_placeholder.hide() dependency_bar.hide() map_box = self.xml.get_object('map_box') map_box.set_size_request(400, -1) embed = GtkChamplain.Embed() self.view = embed.get_view() self.view.set_reactive(True) self.view.set_property('kinetic-mode', True) self.view.set_property('zoom-level', 12) self.view.connect('button-release-event', self.map_clicked, self.view) scale = Champlain.Scale() scale.connect_view(self.view) self.view.add_child(scale) lat = self.plugin.config['lat'] lon = self.plugin.config['lon'] if not self.is_valid_coord(lat, lon): self.lat = self.lon = 0.0 self.xml.get_object('lat').set_text('0.0') self.xml.get_object('lon').set_text('0.0') self.view.center_on(self.lat, self.lon) self.path_to_image = os.path.abspath( gtkgui_helpers.get_icon_path('org.gajim.Gajim', 16)) map_box.pack_start(embed, expand=True, fill=True, padding=0) self.is_active = True self.layer = Champlain.MarkerLayer() texture = Clutter.Texture() texture.set_from_file(self.path_to_image) texture.set_size(32, 32) self.marker = Champlain.Label.new_with_image(texture) self.marker.set_location(self.lat, self.lon) self.marker.set_text(_('Your location')) self.view.add_layer(self.layer) self.layer.add_marker(self.marker) self.markers_is_visible = False self.xml.get_object('lat').connect('changed', self.on_latlon_changed) self.xml.get_object('lon').connect('changed', self.on_latlon_changed) self.layer.animate_in_all_markers() self.contacts_layer = Champlain.MarkerLayer()