def __init__(self, coord, kmx, kmy, layer, conf):
        self.layers = []

        def _zoom(zoom0, zoom1):
            out_hbox = gtk.HBox(False, 50)
            out_hbox.set_border_width(10)
            in_hbox = gtk.HBox(False, 20)
            in_hbox.pack_start(lbl("min:"), False)
            self.s_zoom0 = SpinBtn(zoom0)
            self.s_zoom0.set_digits(0)
            in_hbox.pack_start(self.s_zoom0)
            out_hbox.pack_start(in_hbox)

            in_hbox = gtk.HBox(False, 20)
            in_hbox.pack_start(lbl("max:"), False)
            self.s_zoom1 = SpinBtn(zoom1)
            self.s_zoom1.set_digits(0)
            in_hbox.pack_start(self.s_zoom1)
            out_hbox.pack_start(in_hbox)
            hbox = gtk.HBox()
            hbox.set_border_width(10)
            hbox.pack_start(myFrame(" Zoom ", out_hbox, 0))
            return hbox

        def _center(lat0, lon0):
            vbox = gtk.VBox(False, 5)
            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("latitude:"))
            self.e_lat0 = myEntry("%.6f" % lat0, 15, False)
            hbox.pack_start(self.e_lat0, False)
            vbox.pack_start(hbox)

            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("longitude:"))
            self.e_lon0 = myEntry("%.6f" % lon0, 15, False)
            hbox.pack_start(self.e_lon0, False)
            vbox.pack_start(hbox)
            return myFrame(" Center ", vbox)

        def _area(kmx, kmy):
            vbox = gtk.VBox(False, 5)
            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("width:"))
            self.e_kmx = myEntry("%.6g" % kmx, 10, False)
            hbox.pack_start(self.e_kmx, False)
            vbox.pack_start(hbox)

            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("height:"))
            self.e_kmy = myEntry("%.6g" % kmy, 10, False)
            hbox.pack_start(self.e_kmy, False)
            vbox.pack_start(hbox)
            return myFrame(" Area (km) ", vbox)

        def download_rclick(self, event, menu):
            if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
                menu.popup(None, None, None, event.button, event.time)

        def rclick_menu(active_layer, map_serv):
            menu = gtk.Menu()
            for layer in range(len(LAYER_NAMES)):
                self.layers.append(gtk.CheckMenuItem(LAYER_NAMES[layer]))
                if layer == active_layer:
                    self.layers[-1].set_active(True)
                else:
                    self.layers[-1].set_sensitive(layer in MAP_SERVICES[map_serv]['layers'])
                menu.append(self.layers[-1])
            menu.show_all()
            return menu

        def _buttons(strFolder, layer, conf):
            hbbox = gtk.HButtonBox()
            hbbox.set_border_width(10)
            hbbox.set_layout(gtk.BUTTONBOX_SPREAD)
            menu = rclick_menu(layer, MAP_SERVERS.index(conf.map_service))
            gtk.stock_add([(gtk.STOCK_HARDDISK, "_Download", 0, 0, "")])
            self.b_download = gtk.Button(stock=gtk.STOCK_HARDDISK)
            self.b_download.connect('clicked', self.start_download, strFolder)
            self.b_download.connect('event', download_rclick, menu)
            hbbox.pack_start(self.b_download)

            hbox = gtk.HBox()
            gtk.stock_add([(gtk.STOCK_UNDELETE, "", 0, 0, "")])
            self.b_open = gtk.Button(stock=gtk.STOCK_UNDELETE)
            self.b_open.connect('clicked', self.do_open, strFolder)
            hbox.pack_start(self.b_open, padding=25)
            if isdir(fldDown):
                hbbox.pack_start(hbox)

            self.b_pause = gtk.Button(stock='gtk-media-pause')
            self.b_pause.connect('clicked', self.do_pause)
            self.b_pause.set_sensitive(False)

            hbbox.pack_start(self.b_pause)
            return hbbox

        fldDown = join(conf.init_path, 'download')
        print "DLWindow(", coord, kmx, kmy, layer, ')'
        self.conf = conf
        kmx = mapUtils.nice_round(kmx)
        kmy = mapUtils.nice_round(kmy)
        gtk.Window.__init__(self)
        lat0 = coord[0]
        lon0 = coord[1]
        zoom0 = max(MAP_MIN_ZOOM_LEVEL, coord[2] - 3)
        zoom1 = min(MAP_MAX_ZOOM_LEVEL, coord[2] + 1)

        vbox = gtk.VBox(False)
        hbox = gtk.HBox(False, 10)
        hbox.pack_start(_center(lat0, lon0))
        hbox.pack_start(_area(kmx, kmy))
        vbox.pack_start(hbox)
        vbox.pack_start(_zoom(zoom0, zoom1))
        vbox.pack_start(_buttons(fldDown, layer, conf))

        self.pbar = gtk.ProgressBar()
        self.pbar.set_text(" ")
        vbox.pack_start(self.pbar)
        self.add(vbox)

        self.set_title("GMapCatcher download")
        self.set_border_width(10)
        ico = mapPixbuf.ico()
        if ico:
            self.set_icon(ico)

        self.complete = []
        self.processing = False
        self.gmap = None
        self.downloader = None
        self.connect('delete-event', self.on_delete)
        self.connect('key-press-event', self.key_press)
        self.show_all()
Example #2
0
    def __init__(self, coord, kmx, kmy, layer, conf, force_update):
        self.layers = []

        def _zoom(zoom0, zoom1):
            out_hbox = gtk.HBox(False, 50)
            out_hbox.set_border_width(10)
            in_hbox = gtk.HBox(False, 20)
            in_hbox.pack_start(lbl("min:"), False)
            self.s_zoom0 = SpinBtn(zoom0)
            self.s_zoom0.set_digits(0)
            in_hbox.pack_start(self.s_zoom0)
            out_hbox.pack_start(in_hbox)

            in_hbox = gtk.HBox(False, 20)
            in_hbox.pack_start(lbl("max:"), False)
            self.s_zoom1 = SpinBtn(zoom1)
            self.s_zoom1.set_digits(0)
            in_hbox.pack_start(self.s_zoom1)
            out_hbox.pack_start(in_hbox)
            hbox = gtk.HBox()
            hbox.set_border_width(10)
            hbox.pack_start(myFrame(" Zoom ", out_hbox, 0))
            return hbox

        def _center(lat0, lon0):
            vbox = gtk.VBox(False, 5)
            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("latitude:"))
            self.e_lat0 = myEntry("%.6f" % lat0, 15, False)
            hbox.pack_start(self.e_lat0, False)
            vbox.pack_start(hbox)

            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("longitude:"))
            self.e_lon0 = myEntry("%.6f" % lon0, 15, False)
            hbox.pack_start(self.e_lon0, False)
            vbox.pack_start(hbox)
            return myFrame(" Center ", vbox)

        def _area(kmx, kmy):
            vbox = gtk.VBox(False, 5)
            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("width:"))
            self.e_kmx = myEntry("%.6g" % kmx, 10, False)
            hbox.pack_start(self.e_kmx, False)
            vbox.pack_start(hbox)

            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("height:"))
            self.e_kmy = myEntry("%.6g" % kmy, 10, False)
            hbox.pack_start(self.e_kmy, False)
            vbox.pack_start(hbox)
            return myFrame(" Area (km) ", vbox)

        def download_rclick(self, event, menu):
            if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
                menu.popup(None, None, None, event.button, event.time)

        def rclick_menu(active_layer, map_serv):
            menu = gtk.Menu()
            for layer in range(len(LAYER_NAMES)):
                self.layers.append(gtk.CheckMenuItem(LAYER_NAMES[layer]))
                if layer == active_layer:
                    self.layers[-1].set_active(True)
                else:
                    self.layers[-1].set_sensitive(
                        layer in MAP_SERVICES[map_serv]['layers'])
                menu.append(self.layers[-1])
            menu.show_all()
            return menu

        def _buttons(strFolder, layer, conf):
            hbbox = gtk.HButtonBox()
            hbbox.set_border_width(10)
            hbbox.set_layout(gtk.BUTTONBOX_SPREAD)
            menu = rclick_menu(layer, MAP_SERVERS.index(conf.map_service))
            gtk.stock_add([(gtk.STOCK_HARDDISK, "_Download", 0, 0, "")])
            self.b_download = gtk.Button(stock=gtk.STOCK_HARDDISK)
            self.b_download.connect('clicked', self.start_download, strFolder)
            self.b_download.connect('event', download_rclick, menu)
            hbbox.pack_start(self.b_download)

            hbox = gtk.HBox()
            gtk.stock_add([(gtk.STOCK_UNDELETE, "", 0, 0, "")])
            self.b_open = gtk.Button(stock=gtk.STOCK_UNDELETE)
            self.b_open.connect('clicked', self.do_open, strFolder)
            hbox.pack_start(self.b_open, padding=25)
            if isdir(fldDown):
                hbbox.pack_start(hbox)

            self.b_pause = gtk.Button(stock='gtk-media-pause')
            self.b_pause.connect('clicked', self.do_pause)
            self.b_pause.set_sensitive(False)

            hbbox.pack_start(self.b_pause)
            return hbbox

        fldDown = join(conf.init_path, 'download')
        print "DLWindow(", coord, kmx, kmy, layer, ')'
        self.conf = conf
        self.force_update = force_update
        kmx = mapUtils.nice_round(kmx)
        kmy = mapUtils.nice_round(kmy)
        gtk.Window.__init__(self)
        lat0 = coord[0]
        lon0 = coord[1]
        zoom0 = max(MAP_MIN_ZOOM_LEVEL, coord[2] - 3)
        zoom1 = min(MAP_MAX_ZOOM_LEVEL, coord[2] + 1)

        vbox = gtk.VBox(False)
        hbox = gtk.HBox(False, 10)
        hbox.pack_start(_center(lat0, lon0))
        hbox.pack_start(_area(kmx, kmy))
        vbox.pack_start(hbox)
        vbox.pack_start(_zoom(zoom0, zoom1))
        vbox.pack_start(_buttons(fldDown, layer, conf))

        self.pbar = gtk.ProgressBar()
        self.pbar.set_text(" ")
        vbox.pack_start(self.pbar)
        self.add(vbox)

        self.set_title("GMapCatcher download")
        self.set_border_width(10)
        ico = mapPixbuf.ico()
        if ico:
            self.set_icon(ico)

        self.complete = []
        self.processing = False
        self.gmap = None
        self.downloader = None
        self.connect('delete-event', self.on_delete)
        self.connect('key-press-event', self.key_press)
        self.show_all()
Example #3
0
    def __init__(self, mapServ, coord, kmx, kmy, layer, conf):

        def _zoom(zoom0, zoom1):
            out_hbox = gtk.HBox(False, 50)
            out_hbox.set_border_width(10)
            in_hbox = gtk.HBox(False, 20)
            in_hbox.pack_start(lbl("min:"), False)
            self.s_zoom0 = SpinBtn(zoom0)
            self.s_zoom0.set_digits(0)
            in_hbox.pack_start(self.s_zoom0)
            out_hbox.pack_start(in_hbox)

            in_hbox = gtk.HBox(False, 20)
            in_hbox.pack_start(lbl("max:"), False)
            self.s_zoom1 = SpinBtn(zoom1)
            self.s_zoom1.set_digits(0)
            in_hbox.pack_start(self.s_zoom1)
            out_hbox.pack_start(in_hbox)
            hbox = gtk.HBox()
            hbox.set_border_width(10)
            hbox.pack_start(myFrame(" Zoom ", out_hbox, 0))
            return hbox

        def _custom_path():
            def repository_type_combo(repos_type_id):
                self.cmb_repos_type = gtk.combo_box_new_text()
                for strMode in REPOS_TYPE:
                    self.cmb_repos_type.append_text(strMode)
                self.cmb_repos_type.set_active(repos_type_id)
                return self.cmb_repos_type

            def get_folder(button):
                #if os.path.isdir(self.entry_custom_path.get_text()):
                #    dir = self.entry_custom_path
                #else:
                #    dir = None
                folderName = FolderChooser()
                if folderName:
                    self.entry_custom_path.set_text(folderName)

            vbox = gtk.VBox(False, 5)
            vbox.set_border_width(5)
            hbox = gtk.HBox(False, 10)
            self.entry_custom_path = gtk.Entry()
            self.entry_custom_path.set_text(EXWindow.configpath)
            repository_type_combo(EXWindow.repostype_id)
            hbox.pack_start(self.cmb_repos_type, False)
            hbox.pack_start(self.entry_custom_path)
            button = gtk.Button(" ... ")
            button.connect('clicked', get_folder)
            hbox.pack_start(button, False)
            vbox.pack_start(hbox)

            hbox = gtk.HBox(False, 10)
            self.cb_overwrite_destination = gtk.CheckButton("Overwrite existing tiles in destination repository")
            hbox.pack_start(self.cb_overwrite_destination)
            vbox.pack_start(hbox)

            return myFrame(" Destination repository for export ", vbox)

        def _center(lat0, lon0):
            vbox = gtk.VBox(False, 5)
            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("latitude:"))
            self.e_lat0 = myEntry("%.6f" % lat0, 15, False)
            hbox.pack_start(self.e_lat0, False)
            vbox.pack_start(hbox)

            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("longitude:"))
            self.e_lon0 = myEntry("%.6f" % lon0, 15, False)
            hbox.pack_start(self.e_lon0, False)
            vbox.pack_start(hbox)
            return myFrame(" Center ", vbox)

        def _area(kmx, kmy):
            vbox = gtk.VBox(False, 5)
            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("width:"))
            self.e_kmx = myEntry("%.6g" % kmx, 10, False)
            hbox.pack_start(self.e_kmx, False)
            vbox.pack_start(hbox)

            hbox = gtk.HBox(False, 10)
            hbox.pack_start(lbl("height:"))
            self.e_kmy = myEntry("%.6g" % kmy, 10, False)
            hbox.pack_start(self.e_kmy, False)
            vbox.pack_start(hbox)
            return myFrame(" Area (km) ", vbox)

        def _buttons():
            hbbox = gtk.HButtonBox()
            hbbox.set_border_width(10)
            hbbox.set_layout(gtk.BUTTONBOX_SPREAD)

            self.b_export = gtk.Button("Export")
            self.b_export.connect('clicked', self.on_b_export_clicked, self)
            hbbox.pack_start(self.b_export)

            self.b_stop = gtk.Button(stock='gtk-media-stop')
            self.b_stop.connect('clicked', self.on_b_stop_clicked)
            self.b_stop.set_sensitive(False)

            hbbox.pack_start(self.b_stop)
            return hbbox

        self.mapServ = mapServ
        self.conf = conf
        kmx = mapUtils.nice_round(kmx)
        kmy = mapUtils.nice_round(kmy)
        self.layer = layer
        gtk.Window.__init__(self)
        lat0 = coord[0]
        lon0 = coord[1]
        zoom0 = max(MAP_MIN_ZOOM_LEVEL, coord[2] - 3)
        zoom1 = min(MAP_MAX_ZOOM_LEVEL, coord[2] + 1)

        vbox = gtk.VBox(False)
        hbox = gtk.HBox(False, 10)
        hbox.pack_start(_center(lat0, lon0))
        hbox.pack_start(_area(kmx, kmy))
        vbox.pack_start(hbox)
        vbox.pack_start(_zoom(zoom0, zoom1))
        vbox.pack_start(_custom_path())
        vbox.pack_start(_buttons())

        self.pbar = gtk.ProgressBar()
        self.pbar.set_text("...")
        vbox.pack_start(self.pbar)
        self.add(vbox)

        self.set_title("GMapCatcher export")
        self.set_border_width(10)
        ico = mapPixbuf.ico()
        if ico:
            self.set_icon(ico)

        self.complete = []
        self.processing = False
        self.gmap = None
        self.downloader = None
        self.connect('delete-event', self.on_delete)
        self.connect('key-press-event', self.key_press)
        self.show_all()

        self.transfer_thread = None