示例#1
0
    def on_import_clicked(self, widget):
        dialog = Gtk.FileChooserDialog("Please choose a file", self,
            Gtk.FileChooserAction.OPEN,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
             Gtk.STOCK_OPEN, Gtk.ResponseType.OK))

        self.add_filters(dialog)

        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            filename = dialog.get_filename()
            track = GpxTrack(self.view, self.trackstore)
            try:
                track.import_file(filename)
            except:
                print "Import error, could not find %s" % filename
            else:
                track.show()
                track.go_to()
                self.sidebartogglebutton.set_active(True)

        elif response == Gtk.ResponseType.CANCEL:
            print "Cancel clicked"

        dialog.destroy()
示例#2
0
    def on_import_clicked(self, widget):
        dialog = Gtk.FileChooserDialog(_("Open file"), self,
            Gtk.FileChooserAction.OPEN,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
             Gtk.STOCK_OPEN, Gtk.ResponseType.OK))

        self.add_filters(dialog)

        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            filename = dialog.get_filename()
            track = GpxTrack(self.view, self.trackstore)
            try:
                track.import_file(filename)
            except:
                print(_("Import error: Could not find %(file)s" % {'file': filename}))
            else:
                track.show()
                track.go_to()
                self.sidebartogglebutton.set_active(True)

        elif response == Gtk.ResponseType.CANCEL:
            pass

        dialog.destroy()
示例#3
0
    def do_open(self, file_list, file_count, hint):
        self.window = MapWindow(self, self.embed)

        # FIXME: file_list is empty, why?
        # Fetching files from constructor
        for gpx_file in self.files[-file_count:]:
            try:
                g = GpxTrack(self.window.view, self.window.store)
                g.import_file(gpx_file)
            except:
                print("ERROR: %s was not a functional GPX file")
示例#4
0
 def on_drag_data_received(self, window, context, x, y, data, info, time):
     filename = data.get_text().strip()
     track = GpxTrack(self.view, self.trackstore)
     try:
         track.import_file(filename)
     except:
         print "Import error, could not find %s" % filename
     else:
         track.show()
         track.go_to()
         self.sidebartogglebutton.set_active(True)