コード例 #1
0
class upgrade_confirm_dialog(Dialog):

    def __init__(self, parent, to_upgrade, icon):

        Dialog.__init__(self, _("Confirm Upgrade"), parent,
                        DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT,
                        (STOCK_OK, RESPONSE_ACCEPT,
                         STOCK_CANCEL, RESPONSE_REJECT))

        self.set_icon(pixbuf_new_from_file(icon))
        self._setup_tree(to_upgrade)
        self._setup_layout()
        
    def _setup_tree(self, pacs):
        self.model = ListStore(str, str, str)

        for pac in pacs:
            self.model.append(["yellow", pac.name, pac.version])
            continue

        self.tree = TreeView()
        self.tree.insert_column_with_attributes(-1, "", CellRendererPixbuf(),
                                                stock_id = 0)
        self.tree.insert_column_with_attributes(-1, "Package",
                                                CellRendererText(), text = 1)
        self.tree.insert_column_with_attributes(-1, "Version",
                                                CellRendererText(), text = 2)

        self.tree.set_model(self.model)
        self.tree.show()

    def _setup_layout(self):

        self.label = Label(_("Are you sure yo want to upgrade those packages?\n"))
        self.label.show()

        self.set_default_size (300, 300)

        scr = ScrolledWindow()
        scr.set_policy("automatic", "automatic")
        scr.add(self.tree)
        scr.show()
        
        self.vbox.pack_start(self.label, False, False, 0)
        self.vbox.pack_start(scr, True, True, 0)

    def run(self):
        retcode = Dialog.run(self)
        self.destroy()

        if retcode == RESPONSE_ACCEPT:
            return True
        else:
            return False
コード例 #2
0
class upgrade_dialog(Window):

    def __init__(self, to_upgrade, icon):

        Window.__init__(self, WINDOW_TOPLEVEL)
        self.set_property("skip-taskbar-hint", True)
        self.set_property("modal", True)
        self.set_property("destroy-with-parent", True)
        self.set_position(WIN_POS_CENTER)
        self.set_default_size (300, 300)

        self.set_icon(pixbuf_new_from_file(icon))
        self._setup_tree(to_upgrade)
        self._setup_layout()

    def _setup_layout(self):
        self.vbox = VBox(False, 0)
        self.vbox.show()

        self.terminal = terminal()
        self.terminal.connect("child-exited", lambda _: self.close_button.show())
        
        self.expander = expander_new_with_mnemonic(_("_Terminal"))
        self.expander.set_expanded(False)
        self.expander.add(self.terminal)
        self.expander.show_all()
        
        self.close_button = Button(stock=STOCK_CLOSE)
        self.close_button.connect("clicked", lambda _: self.destroy())

        scr = ScrolledWindow()
        scr.set_policy ("automatic", "automatic")
        scr.add (self.tree)
        scr.show()

        vpaned = VPaned()
        vpaned.add1(scr)
        vpaned.add2(self.expander)
        vpaned.set_position (260)
        vpaned.show()

        self.vbox.pack_start(vpaned, True, True, 0)
        self.vbox.pack_start(self.close_button, False, False, 0)

        self.add(self.vbox)
        return

    def _setup_tree(self, pacs):
        self.model = ListStore(str, str, str)

        for pac in pacs:
            self.model.append(["yellow", pac.name, pac.version])
            continue

        self.tree = TreeView()
        self.tree.show()

        self.tree.insert_column_with_attributes(-1, "", CellRendererPixbuf(),
                                                stock_id = 0)
        self.tree.insert_column_with_attributes(-1, "Package",
                                                CellRendererText(), text = 1)
        self.tree.insert_column_with_attributes(-1, "Version",
                                                CellRendererText(), text = 2)

        self.tree.set_model(self.model)
        return
    
    def run(self):
        self.show()
        self.terminal.do_upgrade()
コード例 #3
0
class BoKeepConfigDialog(object):
    """GUI for configuring BoKeep."""
    
    config_path = None
    config = None
    
    def __init__(self,
                 db_path, db_access_method,
                 config_path, config,
                 error_msg=None):
        self.config_path = config_path
        self.config = config
        
        load_glade_file_get_widgets_and_connect_signals(
            get_main_window_glade_file(), "bokeep_config_dialog",
            self, self)
        self.selection_change_lock = True

        self.state = BoKeepConfigGuiState(
            error_msg, self.__force_config_on_newly_created_plugin)
        self.books_tv = TreeView(self.state.book_liststore)
        self.books_tv.append_column(
                TreeViewColumn("Book", CellRendererText(), text=0 ) )
        self.books_tv.get_selection().connect(
            "changed", self.on_book_selection_change)
        self.books_window.add(self.books_tv)
        self.books_tv.show()
        self.plugins_tv = TreeView(self.state.frontend_plugin_liststore)
        self.plugins_tv.append_column(
            TreeViewColumn("Plugin", CellRendererText(), text=0) )
        crt = CellRendererToggle()
        crt.set_radio(False)
        self.plugins_tv.append_column(
            TreeViewColumn("Enabled", crt, active=1) )
        self.plugins_window.add(self.plugins_tv)
        self.plugins_tv.show()
        self.plugin_directories_button.connect('clicked',
                            self.__on_plugin_directories_button_click)

        self.__populate_possible_plugins()

        self.db_path_label.set_text(db_path)
        if db_path != None:
            self.do_action(DB_ENTRY_CHANGE, (db_path, db_access_method))
            self.do_action(DB_PATH_CHANGE)
        
        if db_access_method == ZODB_CONFIG_FILESTORAGE:
            self.filestorage_radio.set_active(True)
        elif db_access_method == ZODB_CONFIG_ZCONFIG:
            self.zconfig_radio.set_active(True)

        if error_msg == None:
            error_msg = ""
        self.message_label.set_label(error_msg)

        self.set_sensitivities()
        self.selection_change_lock = False
        self.backend_entry_lock = False
        
    def __populate_possible_plugins(self):
        """Populates the GUI with the possible front and backend plugins."""
        
        available_plugin_liststore = ListStore(str)
        for plugin_name in get_available_frontend_plugins():
            available_plugin_liststore.append([plugin_name])
        self.plugin_add_entry_combo.set_model(available_plugin_liststore)
        self.plugin_add_entry_combo.set_text_column(0)

        available_backend_plugin_liststore = ListStore(str)
        for backend_plugin_name in get_available_backend_plugins():
            available_backend_plugin_liststore.append([backend_plugin_name])
        self.backend_plugin_entry_combo.set_model(available_backend_plugin_liststore)
        self.backend_plugin_entry_combo.set_text_column(0)

    def do_action(self, action, arg=None):
        """Passes on an action to BoKeepConfigGuiState and gui is then
        updated after to reflect the effects of that action by examining
        where that state machine is at after the action.
        """
        
        try:
            self.state.do_action(action, arg)
        except FrontendPluginImportError, err:
            backend_plugin_entry = self.backend_plugin_entry_combo.child
            backend_plugin_name = backend_plugin_entry.get_text()
            if backend_plugin_name in err.plugin_names:
                self.backend_plugin_entry_combo.child.set_text(
                        self.state.data[BOOK].get_backend_plugin_name() )
                err.plugin_names.remove(backend_plugin_name)

            frontend_plugins = {}
            for name, enabled in self.state.frontend_plugin_liststore:
                frontend_plugins[name] = (name, enabled)

            for err_plugin_name in err.plugin_names:
                del frontend_plugins[err_plugin_name]

            self.state.frontend_plugin_liststore.clear()
            for valid_plugin_name, enabled in frontend_plugins.values():
                self.state.frontend_plugin_liststore.append((valid_plugin_name, enabled))

            error_dialog = MessageDialog(self.bokeep_config_dialog, DIALOG_MODAL, 
                           MESSAGE_ERROR, BUTTONS_OK, str(err))
            error_dialog.run()
            error_dialog.destroy()
            # raises last exception that had been caught, in above
            # except clause, err
            raise