コード例 #1
0
ファイル: launcher.py プロジェクト: isaquealves/u-air
    def __init__(self, config):
        self.config=config
        self.lang=self.config.get("lang", "en")
        gtk.Window.__init__(self)
        self.set_resizable(False)
        self.set_title(lt("About", self.lang))
        self.set_size_request(540, 250)
        self.set_border_width(20)
        self.set_position(gtk.WIN_POS_CENTER)
        self.connect("destroy", self.close_window)
        self.fixed = gtk.Fixed()
        self.label_about = gtk.Label(lt("U-Air\n\
---------------------\n\
U-Air allow you to browse upload and download your files, wherever you are.\n\
You forget take any file from home to your friend ? Now its not problem.\n\
You can easly browse your files, upload new and listen MP3 songs.", self.lang))
        self.label_authors=gtk.Label("Authors:")
        self.label_authors.set_text(lt("Authors", self.lang)+":")
        author1="Michal Rosiak <*****@*****.**>"
        author2="Marcin Swierczynski <*****@*****.**>"
        self.label_autor1 = gtk.Label(author1)
        self.label_autor2 = gtk.Label(author2)
        self.fixed.put(self.label_about, 5, 10)
        self.fixed.put(self.label_authors, 5, 120)
        self.fixed.put(self.label_autor1, 10, 150)
        self.fixed.put(self.label_autor2, 10, 180)
        self.add(self.fixed)
        self.show_all()
コード例 #2
0
ファイル: launcher.py プロジェクト: isaquealves/u-air
    def setstatus(self):
        self.config["status"]=bool(check_pidfile())

        #get and save global ip
        gip=get_global_ip_address()
        self.config["global_ip"]=gip
        self.label_public_ip.set_text(lt("Public IP", self.lang)+": "+\
            self.config["global_ip"]+":"+str(self.config["port"]))

        # get and save local IP
        lip=get_local_ip_address()
        self.config["local_ip"]=lip
        self.label_local_ip.set_text(lt("Local IP", self.lang)+": "+\
            self.config["local_ip"]+":"+str(self.config["port"]))

        if self.config["status"]:
            self.label_status.set_text("Status: "+lt("Online", self.lang))
        else:
            self.label_status.set_text("Status: "+lt("Offline", self.lang))
コード例 #3
0
ファイル: launcher.py プロジェクト: isaquealves/u-air
    def __init__(self, config):

        self.config=config
        self.lang=self.config.get("lang", "en")
        gtk.Window.__init__(self)
        self.set_title(lt("Options", self.lang))
        self.set_resizable(False)
        self.set_size_request(300, 250)
        self.set_border_width(20)
        self.set_position(gtk.WIN_POS_CENTER)

        self.connect("destroy", self.close_window)
        self.fixed = gtk.Fixed()
        self.label_set_pass = gtk.Label("Password:"******"Password", self.lang)+":")
        self.entry_set_pass = gtk.Entry()
        self.label_startup = gtk.Label("Load in startup Ubuntu")
        self.label_startup.set_text(lt("Load in startup Ubuntu", self.lang))
        self.check_startup = gtk.CheckButton()
        self.check_startup.set_active(self.config["startup"])
        self.check_startup.connect("toggled", self.entry_checkbox)
        self.label_set_port = gtk.Label("Port:")
        self.label_set_port.set_text(lt("Port", self.lang)+":")
        self.entry_set_port = gtk.Entry()
        self.entry_set_port.set_text(str(self.config["port"]))
        self.label_choose_image = gtk.Label("Choose images folder")
        self.label_choose_image.set_text(lt("Choose images folder", self.lang)+":")
        self.chooser_image_folder = \
            gtk.FileChooserButton(lt("Choose images folder", self.lang))
        self.chooser_image_folder.set_action(
            gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER
            )
        self.chooser_image_folder.set_size_request(150,35)
        self.label_set_language = gtk.Label("Set language:")
        self.label_set_language.set_text(lt("Set language", self.lang)+":")
        self.combo_language = gtk.combo_box_new_text()

        #add languages
        for lang in langs:
            self.combo_language.append_text(lang)
        self.combo_language.set_active(langs.keys().index(\
            self.config["lang"]))

        self.combo_language.connect("changed", self.select_language)
        #get images path
        imgpath=self.config.get("images_path", \
            os.path.expanduser("~/Pictures"))
        self.chooser_image_folder.set_filename(imgpath)
        self.button_save = gtk.Button("Save")
        self.button_save.set_size_request(130, 30)
        self.button_save.connect("clicked", self.onsave)

        self.fixed.put(self.label_set_pass, 10, 5)
        self.fixed.put(self.entry_set_pass, 90, 0)
        #self.fixed.put(self.check_startup, 5, 42)
        #self.fixed.put(self.label_startup, 40, 44)
        self.fixed.put(self.label_set_port, 10, 44)
        self.fixed.put(self.entry_set_port, 90 ,42)
        self.fixed.put(self.label_choose_image, 10, 90)
        self.fixed.put(self.chooser_image_folder, 10, 110)
        self.fixed.put(self.label_set_language, 10, 150)
        self.fixed.put(self.combo_language, 10, 170)
        self.fixed.put(self.button_save, 120, 170)
        self.add(self.fixed)

        self.show_all()
コード例 #4
0
ファイル: launcher.py プロジェクト: isaquealves/u-air
    def __init__(self):
        gtk.Window.__init__(self)
        self.set_title("U-Air Launcher")
        self.set_icon_from_file(ICON_PATH)
        self.set_resizable(False)
        self.set_size_request(440, 320)
        self.set_border_width(20)
        self.set_position(gtk.WIN_POS_CENTER)

        #load config
        self.config=load_config()
        save_config(self.config)

        #www server process
        self.server=None

        #get lang from config
        self.lang=self.config.get("lang", "en")

        #connect close event
        self.connect("destroy", self.close_app)

        self.fixed = gtk.Fixed()

        self.label_status = gtk.Label("Status:")
        self.label_status.set_text(lt("Status", self.lang)+":")

        #local IP label
        self.label_local_ip = gtk.Label("Local IP:")
        label=lt("Local IP", self.lang)+": "+self.config["local_ip"]
        label+=":"+str(self.config["port"])
        self.label_local_ip.set_text(label)

        self.label_public_ip = gtk.Label("Public IP:")
        label=lt("Public IP", self.lang)+": "+self.config["global_ip"]+":"+str(self.config["port"])
        self.label_public_ip.set_text(label)
        self.label_gen_password = gtk.Label("Login password:"******"Login password", self.lang)+":")
        self.label_gen_password_shared = gtk.Label("Shared password:"******"Shared password", self.lang)+":")
        self.label_set_gen_password = gtk.Label("...")
        self.label_set_gen_password_shared = gtk.Label("...")
        self.button_regenerate = gtk.Button("Regenerate password")
        self.button_regenerate.set_label(lt("Regenerate password", self.lang))
        self.button_regenerate.connect("clicked", self.regenerate)

        self.button_start = gtk.Button("Start")
        self.button_start.set_label(lt("Start", self.lang))
        self.button_start.connect("clicked", self.start)
        self.button_start.set_size_request(110, 50)
        self.button_stop = gtk.Button("Stop")
        self.button_stop.set_label(lt("Stop", self.lang))
        self.button_stop.connect("clicked", self.stop)
        self.button_stop.set_size_request(110, 50)

        self.button_options = gtk.Button("Options")
        self.button_options.set_label(lt("Options", self.lang))
        self.button_options.set_size_request(130, 30)
        self.button_options.connect("clicked", self.show_option_window)
        self.button_about = gtk.Button("About")
        self.button_about.set_label(lt("About", self.lang))
        self.button_about.set_size_request(130, 30)
        self.button_about.connect("clicked", self.show_about_window)
        self.button_quit = gtk.Button("Quit")
        self.button_quit.set_label(lt("Quit", self.lang))
        self.button_quit.set_size_request(130, 30)
        self.button_quit.connect("clicked", self.close_app)

        self.img_banner = gtk.Image()
        self.img_banner.set_from_file(os.path.join(ROOT_PATH,
            "static/banner1.png"))

        self.fixed.put(self.img_banner, 0, 0)
        self.fixed.put(self.label_status, 5, 5)
        #self.fixed.put(self.label_local_ip, 3, 130)
        #self.fixed.put(self.label_public_ip, 200 ,130)
        self.fixed.put(self.label_local_ip, 5, 110)
        self.fixed.put(self.label_public_ip, 5 ,130)
        self.fixed.put(self.button_regenerate, 70, 200)

        self.fixed.put(self.button_start, 0, 230)
        self.fixed.put(self.button_stop, 120, 230)

        self.fixed.put(self.label_gen_password, 0, 160)
        self.fixed.put(self.label_set_gen_password, 150, 160)
        self.fixed.put(self.label_gen_password_shared, 0, 180)
        self.fixed.put(self.label_set_gen_password_shared, 150, 180)

        self.fixed.put(self.button_options, 250, 170)
        self.fixed.put(self.button_about, 250, 210)
        self.fixed.put(self.button_quit, 250, 250)
        self.add(self.fixed)
        #show all
        self.show_all()
        #create pictures folder if not exist
        if not os.path.exists(DEFAULT_IMAGES_PATH):
            os.mkdir(DEFAULT_IMAGES_PATH)
        #remove pid file when process not exist
        remove_orphaned_pidfile(check_pidfile())
        #set status
        self.setstatus()
        #update start stop buttons
        self.toggle_start_stop_buttons()
        #generate new login password
        self.gen_login_password()
        self.gen_shared_password()