Esempio n. 1
0
 def __init__(self, list_gui, parent=None):
     gtk.VBox.__init__(self)
     
     self.__parent = parent
     self.list_gui = list_gui
     
     self.update_flag = False
     self.active_tab_flag = True
     
     #Estructura:
     #-------------------vbox1_start---------------
     #-------------------hbox4[halign1-left + halign4-right]-----------------------
     #-------------------vbox1_end----------------
     
     #detallado:
     #-------------------vbox1_start---------------
     #-------------------hbox4_start---------------
     #-------------------halign1_start-------------
     #-------------------hbox1-----------------------(save to field + examine button, left aligned)
     #-------------------halign1_end--------------
     #-------------------halign4_start------------(add links button, etc, right aligned)
     #-------------------halign2_start-------------
     #-------------------hbox2-----------------------
     #-------------------halign2_end--------------
     #-------------------halign4_end--------------
     #-------------------hbox4_end----------------
     #-------------------vbox1_end----------------
     
     #containers-separators.
     #self.vbox no puede ser cambiado en gtk.Dialog. Crear variable vbox y luego meterla en self.vbox.
     vbox1 = gtk.VBox(False, 5) #gtk.VBox(homogeneous=False, spacing=0) homogeneous: mismo espacio cada hijo, spacing: espacio horizontal entre hijos.
     
     #vbox1_start
     #Check links field.
     #-------------------------------------------
     
     scroll = gtk.ScrolledWindow()
     scroll.set_shadow_type(gtk.SHADOW_ETCHED_IN)
     scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     
     self.store = gtk.ListStore(str, bool, str, str, str, str, str)#modelo de columnas. (4 columnas de strings y 1 booleana)
     
     #arma el cuadro con los items
     self.treeView = gtk.TreeView(self.store)
     self.treeView.set_rules_hint(True) #turna el color de los items, creo.
     scroll.add(self.treeView)
     
     #Columns item names.
     col_list = ["hidden_id_item", _("Add"), _("Status"), _("File Name"), _("Host"), _("Size"), _("Status Message")] #podria usar un frozenset, no se si lo soporta cython.
     self.create_columns(col_list)
     
     vbox1.pack_start(scroll)
     
     #Context Menu (pop-up)
     dl_selected_item = (gtk.MenuItem(), _("Download Selected"), self.on_accept)
     recheck_item = (gtk.MenuItem(), _("Re-check"), self.on_recheck)
     clear_item = (gtk.MenuItem(), _("Clear list"), self.on_clear_list)
     
     menu_items = (dl_selected_item, None, recheck_item, clear_item)
     self.ctx_menu = Menu(menu_items) #items selected
     self.treeView.connect("button-press-event", self.on_context_menu)
     
     #Select file field.
     #-------------------------------------------
     #containers-separators.
     hbox1 = gtk.HBox(False, 10) #file field and button examine.
     #gtk.HBox(homogeneous=False, spacing=0) homogeneous: mismo espacio cada hijo, spacing: espacio horizontal entre hijos.
     hbox2 = gtk.HBox(False, 10) #buttons cancel and accept.
     
     #hbox1
     #label_save_to = gtk.Label("Save to:")
     #hbox1.add(label_save_to)
     self.paths_liststore = gtk.ListStore(str)
     cb_entry = gtk.ComboBoxEntry(self.paths_liststore)
     self.entry = cb_entry.child
     self.entry.add_events(gtk.gdk.KEY_RELEASE_MASK)
     self.entry.set_width_chars(35) #entry width
     
     self.paths_list = conf.get_save_dl_paths()
     self.load_save_paths()
     
     if not self.paths_list:
         default_path = cons.DLFOLDER_PATH
     else:
         default_path = self.paths_list[-1]
     
     #.decode(sys.getfilesystemencoding())
     self.entry.set_text(default_path.decode("utf-8")) #default entry path. Cuando cree el ejecutable, se puede crear una ruta al directorio asi: sys.path.append(path)
     hbox1.add(cb_entry)
     
     button = gtk.Button(_("..."))
     button.set_size_request(80, 35)
     button.connect("clicked", self.save_folder)
     hbox1.add(button)
     
     halign1 = gtk.Alignment(0, 0, 0, 0) #horizontal container. left liagment. #vertical container (estara vacio). gtk.Alignment(xalign=0.0, yalign=0.0, xscale=0.0, yscale=0.0)
     #xalign: espacio libre a la izquierda del hijo. 0.0 = sin espacio arriba. 1.0 = todo el espacio arriba.
     #yalign: espacio libre vertical arriba del hijo. 0.0 = sin espacio arriba. 1.0 = todo el espacio arriba.
     halign1.add(hbox1)
     
     down_arrow_image = media.get_image(media.DOWN, media.MEDIUM)
     download_selected_button = gtk.Button()
     download_selected_button.add(down_arrow_image)
     #self.button2.set_size_request(180, 35)
     download_selected_button.connect("clicked", self.on_accept)
     
     add_image = media.get_image(media.ADD, media.MEDIUM)
     add_button = gtk.Button()
     add_button.add(add_image)
     #button.set_size_request(80, 35)
     add_button.connect("clicked", self.on_add_links)
     
     
     icon_down = media.get_image(media.ARROW_DOWN, media.SMALL)
     #icon_down = gtk.image_new_from_file(os.path.join(cons.APP_PATH, "media", "arrow_down9.png"))
     #drop_down_image = gtk.image_new_from_stock(gtk.STOCK_GO_DOWN, gtk.ICON_SIZE_BUTTON)
     drop_down_button = PopupMenuButton(image=icon_down) #gtk.Button()
     drop_down_button.set_size_request(20, 35)
     
     import_item = (gtk.MenuItem(), _("Import Container"), self.on_import_container)
     recheck_item = (gtk.MenuItem(), _("Re-check"), self.on_recheck)
     clear_item = (gtk.MenuItem(), _("Clear list"), self.on_clear_list)
     
     menu_items = (import_item, None, recheck_item, clear_item)
     menu = Menu(menu_items) #items selected
     drop_down_button.set_menu(menu)
     
     #button5 = gtk.Button(_("Re-check"))
     #button5.set_size_request(80, 35)
     #button5.connect("clicked", self.on_recheck)
     
     halign4 = gtk.Alignment(1, 0, 0, 0) #horizontal container. right liagment.
     hbox2.add(download_selected_button)
     hbox2.add(add_button)
     hbox2.add(drop_down_button)
     halign4.add(hbox2)
     
     hbox4 = gtk.HBox(False, 0) #two aligment widgets
     hbox4.add(halign1)
     hbox4.add(halign4)
     
     vbox1.pack_start(hbox4, False, False) #pack_start(child, expand=True, fill=True, padding=0)
     
     #-------------------------------------------
     #vbox1_end
     
     #entry.get_text()
     #checking thread stuff.
     self.cancelled = False #si se cancelo el checkeo, terminar thread.
     #self.th = threading.Thread(group=None, target=self.checking_links, name=None).start() #ckeck links.
     
     self.pack_start(vbox1)
Esempio n. 2
0
    def __init__(self):
        """"""
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        
        self.set_title(cons.APP_TITLE)
        self.set_size_request(MIN_WIDTH, MIN_HEIGHT)
        self.set_position(gtk.WIN_POS_CENTER)
        self.resize(600, 300)
        
        self.config = conf #config.py
        
        #app window position and size
        x, y, w, h = self.config.get_window_settings()
        if gtk.gdk.screen_width() <= w or gtk.gdk.screen_height() <= h:
            self.maximize()
        elif w >= MIN_WIDTH or h >= MIN_HEIGHT:
            self.resize(w, h)
        if x >= 0 and y >= 0:
            self.move(x, y)
        
        #widgets for tabs.
        self.downloads_list_gui = List(parent=self)
        self.downloads_list_gui.treeView.get_selection().connect("changed", self.on_selected)
        self.add_downloads_gui = AddDownloads(self.downloads_list_gui, parent=self)
        self.addons_gui = addons_gui.AddonsManager(self)
        self.preferences = Preferences(self.addons_gui.addons_list)
        self.log_gui = Log()

        self.vbox = gtk.VBox()
        self.add(self.vbox)

        #toolbar. button = ToolButton(icon, label), handler, sensitive.
        #add_download = gtk.ToolButton(gtk.ToolButton(gtk.STOCK_ADD), "Add Download"), self.add_links, True
        stop = (gtk.ToolButton(media.get_image(media.STOP, media.MEDIUM), None), _("Stop Download"), self.stop_download, False) #tuple
        start = (gtk.ToolButton(media.get_image(media.START, media.MEDIUM), None), _("Start Download"), self.start_download, False)
        accounts = (gtk.ToolButton(media.get_image(media.ACCOUNTS, media.MEDIUM), None), _("Accounts"), self.accounts_app, True)
        preferences = (gtk.MenuToolButton(media.get_image(media.PREFERENCES, media.MEDIUM), None), _("Preferences"), self.on_preferences, True)
        about = (gtk.ToolButton(media.get_image(media.ABOUT, media.MEDIUM), None), _("About"), self.about_dlg, True)
        self.stop = stop[WIDGET] #self.stop = gtk.ToolButton(gtk.ToolButton(gtk.STOCK_STOP), "Stop Download"). Para poder cambiar el set_sensitive
        self.start = start[WIDGET]
        self.Toolbar = Toolbar([start, stop, None, accounts, preferences, None, about]) #los botones se agregan al Toolbar en el orden de esta lista. None = separador
        self.vbox.pack_start(self.Toolbar, False)
        
        #menu
        config_preferences = (gtk.MenuItem(), _("Preferences"), self.on_preferences)
        config_about = (gtk.MenuItem(), _("About"), self.about_dlg)
        #addons-menu
        menu_items = [menu_item for menu_item in [addon.get_menu_item() for addon in self.addons_gui.addons_list] if menu_item is not None]
        menu_items.extend([None, config_preferences, config_about])
        menu = Menu(menu_items)
        preferences[WIDGET].set_menu(menu)
        
        #Sessions
        self.load_session()
        
        #tabs (notebooks)
        self.vbox2 = gtk.VBox()
        
        self.notebook = Notebook()
        self.notebook.set_tab_pos(gtk.POS_BOTTOM) #weird butg in gtk+ 2.24.10 on resizing to often (make the app crash).
        self.notebook.set_show_border(False)
        self.notebook.append_page(self.downloads_list_gui, gtk.Label(_("Downloads")))
        self.notebook.append_page(self.add_downloads_gui, gtk.Label(_("Add downloads")))
        [self.notebook.append_page(tab, gtk.Label(addon.name)) for tab, addon in [(addon.get_tab(), addon) for addon in self.addons_gui.addons_list] if tab is not None]
        self.notebook.append_page(self.log_gui, gtk.Label(_("Log")))
        self.notebook.connect("switch-page", self.on_tab_switch)
        
        self.vbox2.pack_start(self.notebook)
        self.vbox.pack_start(self.vbox2)
        
        #status bar
        self.status_bar = StatusBar(self.add_downloads_gui)
        #self.pack_start(self.status_bar, False, False, 0)
        self.vbox.pack_start(self.status_bar, False, False)
        
        #Quit Event
        events.connect(cons.EVENT_QUIT, self.on_close)
        
        #self.connect("destroy", self.on_close) #boton cerrar de la barra de arriba
        self.connect("delete-event", self.on_quit)
        
        self.show_all()
Esempio n. 3
0
    def __init__(self, list_gui, parent=None):
        gtk.VBox.__init__(self)

        self.__parent = parent
        self.list_gui = list_gui

        self.update_flag = False
        self.active_tab_flag = True

        #Estructura:
        #-------------------vbox1_start---------------
        #-------------------hbox4[halign1-left + halign4-right]-----------------------
        #-------------------vbox1_end----------------

        #detallado:
        #-------------------vbox1_start---------------
        #-------------------hbox4_start---------------
        #-------------------halign1_start-------------
        #-------------------hbox1-----------------------(save to field + examine button, left aligned)
        #-------------------halign1_end--------------
        #-------------------halign4_start------------(add links button, etc, right aligned)
        #-------------------halign2_start-------------
        #-------------------hbox2-----------------------
        #-------------------halign2_end--------------
        #-------------------halign4_end--------------
        #-------------------hbox4_end----------------
        #-------------------vbox1_end----------------

        #containers-separators.
        #self.vbox no puede ser cambiado en gtk.Dialog. Crear variable vbox y luego meterla en self.vbox.
        vbox1 = gtk.VBox(
            False, 5
        )  #gtk.VBox(homogeneous=False, spacing=0) homogeneous: mismo espacio cada hijo, spacing: espacio horizontal entre hijos.

        #vbox1_start
        #Check links field.
        #-------------------------------------------

        scroll = gtk.ScrolledWindow()
        scroll.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        self.store = gtk.ListStore(
            str, bool, str, str, str, str,
            str)  #modelo de columnas. (4 columnas de strings y 1 booleana)

        #arma el cuadro con los items
        self.treeView = gtk.TreeView(self.store)
        self.treeView.set_rules_hint(True)  #turna el color de los items, creo.
        scroll.add(self.treeView)

        #Columns item names.
        col_list = [
            "hidden_id_item",
            _("Add"),
            _("Status"),
            _("File Name"),
            _("Host"),
            _("Size"),
            _("Status Message")
        ]  #podria usar un frozenset, no se si lo soporta cython.
        self.create_columns(col_list)

        vbox1.pack_start(scroll)

        #Context Menu (pop-up)
        dl_selected_item = (gtk.MenuItem(), _("Download Selected"),
                            self.on_accept)
        recheck_item = (gtk.MenuItem(), _("Re-check"), self.on_recheck)
        clear_item = (gtk.MenuItem(), _("Clear list"), self.on_clear_list)

        menu_items = (dl_selected_item, None, recheck_item, clear_item)
        self.ctx_menu = Menu(menu_items)  #items selected
        self.treeView.connect("button-press-event", self.on_context_menu)

        #Select file field.
        #-------------------------------------------
        #containers-separators.
        hbox1 = gtk.HBox(False, 10)  #file field and button examine.
        #gtk.HBox(homogeneous=False, spacing=0) homogeneous: mismo espacio cada hijo, spacing: espacio horizontal entre hijos.
        hbox2 = gtk.HBox(False, 10)  #buttons cancel and accept.

        #hbox1
        #label_save_to = gtk.Label("Save to:")
        #hbox1.add(label_save_to)
        self.paths_liststore = gtk.ListStore(str)
        cb_entry = gtk.ComboBoxEntry(self.paths_liststore)
        self.entry = cb_entry.child
        self.entry.add_events(gtk.gdk.KEY_RELEASE_MASK)
        self.entry.set_width_chars(35)  #entry width

        self.paths_list = conf.get_save_dl_paths()
        self.load_save_paths()

        if not self.paths_list:
            default_path = cons.DLFOLDER_PATH
        else:
            default_path = self.paths_list[-1]

        #.decode(sys.getfilesystemencoding())
        self.entry.set_text(
            default_path.decode("utf-8")
        )  #default entry path. Cuando cree el ejecutable, se puede crear una ruta al directorio asi: sys.path.append(path)
        hbox1.add(cb_entry)

        button = gtk.Button(_("..."))
        button.set_size_request(80, 35)
        button.connect("clicked", self.save_folder)
        hbox1.add(button)

        halign1 = gtk.Alignment(
            0, 0, 0, 0
        )  #horizontal container. left liagment. #vertical container (estara vacio). gtk.Alignment(xalign=0.0, yalign=0.0, xscale=0.0, yscale=0.0)
        #xalign: espacio libre a la izquierda del hijo. 0.0 = sin espacio arriba. 1.0 = todo el espacio arriba.
        #yalign: espacio libre vertical arriba del hijo. 0.0 = sin espacio arriba. 1.0 = todo el espacio arriba.
        halign1.add(hbox1)

        down_arrow_image = media.get_image(media.DOWN, media.MEDIUM)
        download_selected_button = gtk.Button()
        download_selected_button.add(down_arrow_image)
        #self.button2.set_size_request(180, 35)
        download_selected_button.connect("clicked", self.on_accept)

        add_image = media.get_image(media.ADD, media.MEDIUM)
        add_button = gtk.Button()
        add_button.add(add_image)
        #button.set_size_request(80, 35)
        add_button.connect("clicked", self.on_add_links)

        icon_down = media.get_image(media.ARROW_DOWN, media.SMALL)
        #icon_down = gtk.image_new_from_file(os.path.join(cons.APP_PATH, "media", "arrow_down9.png"))
        #drop_down_image = gtk.image_new_from_stock(gtk.STOCK_GO_DOWN, gtk.ICON_SIZE_BUTTON)
        drop_down_button = PopupMenuButton(image=icon_down)  #gtk.Button()
        drop_down_button.set_size_request(20, 35)

        import_item = (gtk.MenuItem(), _("Import Container"),
                       self.on_import_container)
        recheck_item = (gtk.MenuItem(), _("Re-check"), self.on_recheck)
        clear_item = (gtk.MenuItem(), _("Clear list"), self.on_clear_list)

        menu_items = (import_item, None, recheck_item, clear_item)
        menu = Menu(menu_items)  #items selected
        drop_down_button.set_menu(menu)

        #button5 = gtk.Button(_("Re-check"))
        #button5.set_size_request(80, 35)
        #button5.connect("clicked", self.on_recheck)

        halign4 = gtk.Alignment(1, 0, 0,
                                0)  #horizontal container. right liagment.
        hbox2.add(download_selected_button)
        hbox2.add(add_button)
        hbox2.add(drop_down_button)
        halign4.add(hbox2)

        hbox4 = gtk.HBox(False, 0)  #two aligment widgets
        hbox4.add(halign1)
        hbox4.add(halign4)

        vbox1.pack_start(
            hbox4, False,
            False)  #pack_start(child, expand=True, fill=True, padding=0)

        #-------------------------------------------
        #vbox1_end

        #entry.get_text()
        #checking thread stuff.
        self.cancelled = False  #si se cancelo el checkeo, terminar thread.
        #self.th = threading.Thread(group=None, target=self.checking_links, name=None).start() #ckeck links.

        self.pack_start(vbox1)