def init(self):
     self.window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
     self.window.connect("destroy", Gtk.main_quit)
     self.widget = GtkChamplain.Embed()
     self.widget.set_size_request(640, 480)
     self.view = self.widget.get_view()
     self.view.center_on(self.lat, self.lng)
     self.view.set_reactive(True)
     self.view.set_property('kinetic-mode', True)
     self.view.set_property('zoom-level', 10)
     self.boxContainer = Gtk.HBox(False, 10)
     self.inputContianer=Gtk.VBox(False, 10)
     self.buttonInit()
     self.prepareListModel()
     self.initSrcTextView()
     self.initDestTextView()
     self.tableView()
     self.inputContianer.pack_start(self.srcTextView, fill=False,expand=False, padding=0)
     self.inputContianer.pack_start(self.destTextView, fill=False,expand=False, padding=0)
     self.inputContianer.pack_start(self.submit, fill=False,expand=False, padding=0)
     self.inputContianer.pack_start(self.table, fill=False,expand=False, padding=0)
     self.boxContainer.pack_start(self.inputContianer, fill=False, expand=False, padding=0)
     self.boxContainer.add(self.widget)
     self.window.add(self.boxContainer)
     #self.window.add(self.widget)
     self.window.show_all()
Exemplo n.º 2
0
    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()
Exemplo n.º 3
0
    def __init__(self):
        GtkClutter.init([])

        window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
        window.connect("destroy", Gtk.main_quit)
        window.connect("key-press-event", self.on_key_press)

        self.widget = GtkChamplain.Embed()
        self.widget.set_size_request(640, 480)
        self.view = self.widget.get_view()

        window.add(self.widget)
        window.show_all()
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
                                                  Champlain.ImageRenderer())

    source_chain = Champlain.MapSourceChain()
    # tile is retrieved in this order:
    # memory_cache -> file_cache -> tile_source -> error_source
    # the first source that contains the tile returns it
    source_chain.push(error_source)
    source_chain.push(tile_source)
    source_chain.push(file_cache)
    source_chain.push(memory_cache)

    return source_chain


GtkClutter.init([])

window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
window.connect("destroy", Gtk.main_quit)

widget = GtkChamplain.Embed()
widget.set_size_request(640, 480)

view = widget.get_view()

view.set_map_source(create_cached_source())

window.add(widget)
window.show_all()

Gtk.main()
Exemplo n.º 6
0
    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 = []
Exemplo n.º 7
0
    def __init__(self, app):
        Gtk.ApplicationWindow.__init__(self,
                                       title="GeoCaching App",
                                       application=app)
        self.set_title('Geocaching App')
        self.set_default_size(400, 650)
        self.connect('destroy', self.cleanup)

        self.set_icon_from_file(ICON_FILE)

        header = Gtk.HeaderBar(title="Geocaching App")
        header.set_show_close_button(False)
        self.set_titlebar(header)

        button = Gtk.MenuButton()
        header.pack_end(button)

        menumodel = Gio.Menu()
        menumodel.append("Download", "win.download")
        # menumodel.append("About", "win.about")
        menumodel.append("Quit", "win.quit")
        button.set_menu_model(menumodel)

        download_action = Gio.SimpleAction.new("download", None)
        download_action.connect("activate", self.download_callback)
        self.add_action(download_action)

        # about_action = Gio.SimpleAction.new("about", None)
        # about_action.connect("activate", self.about_callback)
        # self.add_action(about_action)

        quit_action = Gio.SimpleAction.new("quit", None)
        quit_action.connect("activate", self.quit_callback)
        self.add_action(quit_action)

        self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
        self.add(self.vbox)

        if os.path.exists(files.userFile('lastPosition.json')):
            with open(files.userFile('lastPosition.json')) as lastone:
                lastposition = json.loads(lastone.read())
                print(lastposition)
                app.lat = lastposition['lat']
                app.lon = lastposition['lon']
                app.zoom = lastposition['zoom']

        bbox = Gtk.HBox(homogeneous=False, spacing=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)

        self.osmmap = GtkChamplain.Embed()
        self.osmmap.set_size_request(200, 200)
        self.view = self.osmmap.get_view()
        self.view.set_map_source(self.create_cached_source())

        self.view.center_on(app.lat, app.lon)
        self.view.set_property('zoom-level', app.zoom)

        self.vbox.add(bbox)
        self.vbox.add(self.osmmap)

        self.view.connect("notify::zoom-level", self.map_zoom_changed)
        self.view.connect("notify::state", self.map_state_changed)

        self.layer = self.create_marker_layer(self.view)
        self.view.add_layer(self.layer)

        self.display_markers()

        self.label3 = Gtk.Label()
        self.vbox.add(self.label3)

        signal.signal(signal.SIGHUP, self.alarm_handler)
Exemplo n.º 8
0
    def __init__(self, activity):
        Gtk.Box.__init__(self)

        self.set_orientation(Gtk.Orientation.VERTICAL)
        self.get_style_context().add_class('view')
        self.get_style_context().add_class('contacts-main-view')

        self.activity = activity

        self.infobar = UploadInfoBar()
        self.pack_start(self.infobar, False, False, 0)

        grid = Gtk.Grid()
        grid.set_row_spacing(12)
        grid.set_column_spacing(16)
        grid.set_orientation(Gtk.Orientation.VERTICAL)
        grid.set_hexpand(True)
        grid.set_vexpand(True)
        grid.set_property('margin', 24)
        self.pack_start(grid, True, True, 0)

        image = Gtk.Image()
        activity.set_image_from_sport(image, Gtk.IconSize.DIALOG)
        grid.attach(image, 0, 0, 1, 1)

        label = Gtk.Label('')
        label.set_hexpand(True)
        label.set_halign(Gtk.Align.START)
        label.set_valign(Gtk.Align.CENTER)
        label.set_margin_left(6)
        label.set_property('xalign', 0.0)
        grid.attach(label, 1, 0, 1, 1)
        self.distance_label = label

        label = Gtk.Label('')
        label.set_hexpand(True)
        label.set_halign(Gtk.Align.START)
        label.set_valign(Gtk.Align.CENTER)
        label.set_property('xalign', 0.0)
        grid.attach(label, 2, 0, 1, 1)
        self.elapsed_time_label = label

        label = Gtk.Label('')
        label.set_hexpand(True)
        label.set_halign(Gtk.Align.START)
        label.set_valign(Gtk.Align.CENTER)
        label.set_margin_left(6)
        label.set_property('xalign', 0.0)
        grid.attach(label, 1, 1, 1, 1)
        self.elevation_label = label

        label = Gtk.Label('')
        label.set_hexpand(True)
        label.set_halign(Gtk.Align.START)
        label.set_valign(Gtk.Align.CENTER)
        label.set_property('xalign', 0.0)
        grid.attach(label, 2, 1, 1, 1)
        self.moving_time_label = label

        # map overlay
        self.embed = GtkChamplain.Embed()
        grid.attach(self.embed, 0, 2, 3, 1)
        self.embed.show_all()

        # action bar
        bar = Gtk.ActionBar()
        self.pack_start(bar, False, False, 0)

        self.upload_button = Gtk.Button('Upload to Strava')
        self.strava_id_updated_cb(None, None)
        bar.pack_end(self.upload_button)
        self.upload_button.connect('clicked', self.upload_view_clicked_cb)
        self.activity.connect('strava-id-updated', self.strava_id_updated_cb)

        # once parsed fill in the blanks
        self.fill_details()
Exemplo n.º 9
0
    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()
Exemplo n.º 10
0
    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()