Пример #1
0
 def show_loading_message(self, do_show=True):
     if do_show:
         txt = _("Loading, please wait...")
     else:
         txt = ""
     self.labels['loading'].set_markup(txt)
     self.labels['loading'].queue_draw()
     misc.gtk_refresh()
Пример #2
0
 def show_loading_message(self, do_show=True):
     if do_show:
         txt = _("Loading, please wait...")
     else:
         txt = ""
     self.labels['loading'].set_markup(txt)
     self.labels['loading'].queue_draw()
     misc.gtk_refresh()
Пример #3
0
    def __init__(self, app, cmd_line):
        Gtk.ApplicationWindow.__init__(self, title="Cnchi", application=app)

        self._main_window_width = 875
        self._main_window_height = 550

        logging.info("Cnchi installer version %s", info.CNCHI_VERSION)

        self.settings = config.Settings()
        self.ui_dir = self.settings.get('ui')

        if not os.path.exists(self.ui_dir):
            cnchi_dir = os.path.join(os.path.dirname(__file__), './')
            self.settings.set('cnchi', cnchi_dir)

            ui_dir = os.path.join(os.path.dirname(__file__), 'ui/')
            self.settings.set('ui', ui_dir)

            data_dir = os.path.join(os.path.dirname(__file__), 'data/')
            self.settings.set('data', data_dir)

            self.ui_dir = self.settings.get('ui')

        # By default, always try to use local /var/cache/pacman/pkg
        xz_cache = ["/var/cache/pacman/pkg"]

        # Check command line
        if cmd_line.cache and cmd_line.cache not in xz_cache:
            xz_cache.append(cmd_line.cache)

        # Log cache dirs
        for xz in xz_cache:
            logging.debug(
                "Cnchi will use '%s' as a source for cached xz packages",
                xz)

        # Store cache dirs in config
        self.settings.set('xz_cache', xz_cache)

        data_dir = self.settings.get('data')

        # For things we are not ready for users to test
        self.settings.set('z_hidden', cmd_line.z_hidden)

        # Set enabled desktops
        if self.settings.get('z_hidden'):
            self.settings.set("desktops", desktop_info.DESKTOPS_DEV)
        else:
            self.settings.set("desktops", desktop_info.DESKTOPS)

        if cmd_line.environment:
            my_desktop = cmd_line.environment.lower()
            if my_desktop in desktop_info.DESKTOPS:
                self.settings.set('desktop', my_desktop)
                self.settings.set('desktop_ask', False)
                logging.debug(
                    "Cnchi will install the %s desktop environment",
                    my_desktop)

        self.ui = Gtk.Builder()
        path = os.path.join(self.ui_dir, "cnchi.ui")
        self.ui.add_from_file(path)

        self.add(self.ui.get_object("main"))

        self.header_ui = Gtk.Builder()
        path = os.path.join(self.ui_dir, "header.ui")
        self.header_ui.add_from_file(path)
        self.header = self.header_ui.get_object("header")

        self.logo = self.header_ui.get_object("logo")
        path = os.path.join(
            data_dir,
            "images",
            "antergos",
            "antergos-logo-mini2.png")
        self.logo.set_from_file(path)

        # To honor our css
        self.header.set_name("header")
        self.logo.set_name("logo")

        self.main_box = self.ui.get_object("main_box")
        # self.main_box.set_property('width_request', 800)

        self.progressbar = self.ui.get_object("main_progressbar")
        self.progressbar.set_name('process_progressbar')

        self.forward_button = self.header_ui.get_object("forward_button")
        self.backwards_button = self.header_ui.get_object("backwards_button")

        atk_set_image_description(self.forward_button, _("Next step"))
        atk_set_image_description(self.backwards_button, _("Previous step"))

        self.forward_button.set_name('fwd_btn')
        self.forward_button.set_always_show_image(True)

        self.backwards_button.set_name('bk_btn')
        self.backwards_button.set_always_show_image(True)

        # Create a queue. Will be used to report pacman messages
        # (pacman/pac.py) to the main thread (installation/process.py)
        self.callback_queue = multiprocessing.JoinableQueue()

        # This list will have all processes (rankmirrors, autotimezone...)
        self.process_list = []

        if cmd_line.packagelist:
            self.settings.set('alternate_package_list', cmd_line.packagelist)
            logging.info(
                "Using '%s' file as package list",
                self.settings.get('alternate_package_list'))

        self.set_titlebar(self.header)

        # Prepare params dict to pass common parameters to all screens
        self.params = dict()
        self.params['main_window'] = self
        self.params['header'] = self.header
        self.params['ui_dir'] = self.ui_dir
        self.params['forward_button'] = self.forward_button
        self.params['backwards_button'] = self.backwards_button
        self.params['callback_queue'] = self.callback_queue
        self.params['settings'] = self.settings
        self.params['main_progressbar'] = self.progressbar
        self.params['process_list'] = self.process_list

        self.params['checks_are_optional'] = cmd_line.no_check
        self.params['disable_tryit'] = cmd_line.disable_tryit
        self.params['disable_rank_mirrors'] = cmd_line.disable_rank_mirrors

        # Just load the first two screens (the other ones will be loaded later)
        # We do this so the user has not to wait for all the screens to be
        # loaded
        self.pages = dict()
        self.pages["welcome"] = welcome.Welcome(self.params)

        if os.path.exists('/home/antergos/.config/openbox'):
            # In minimal iso, load language screen now
            self.pages["language"] = language.Language(self.params)

            # Fix bugy Gtk window size when using Openbox
            self._main_window_width = 750
            self._main_window_height = 450

        self.connect('delete-event', self.on_exit_button_clicked)
        self.connect('key-release-event', self.on_key_release)

        self.ui.connect_signals(self)
        self.header_ui.connect_signals(self)

        nil, major, minor = info.CNCHI_VERSION.split('.')
        name = 'Cnchi '
        title_string = "{0} {1}.{2}.{3}".format(name, nil, major, minor)
        self.set_title(title_string)
        self.header.set_title(title_string)
        self.header.set_subtitle(_("Antergos Installer"))
        self.header.set_show_close_button(True)
        self.tooltip_string = "{0} {1}.{2}.{3}".format(name, nil, major, minor)
        self.header.forall(self.header_for_all_callback, self.tooltip_string)

        self.set_geometry()

        # Set window icon
        icon_path = os.path.join(
            data_dir,
            "images",
            "antergos",
            "antergos-icon.png")
        self.set_icon_from_file(icon_path)

        # Set the first page to show

        # If minimal iso is detected, skip the welcome page.
        if os.path.exists('/home/antergos/.config/openbox'):
            self.current_page = self.pages["language"]
            self.settings.set('timezone_start', True)
        else:
            self.current_page = self.pages["welcome"]

        self.main_box.add(self.current_page)

        # Use our css file
        style_provider = Gtk.CssProvider()

        style_css = os.path.join(data_dir, "css", "gtk-style.css")

        with open(style_css, 'rb') as css:
            css_data = css.read()

        style_provider.load_from_data(css_data)

        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(), style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_USER
        )

        # Show main window
        self.show_all()

        self.current_page.prepare('forwards')

        # Hide backwards button
        self.backwards_button.hide()

        self.progressbar.set_fraction(0)
        self.progressbar_step = 0

        # Do not hide progress bar for minimal iso as it would break
        # the widget alignment on language page.
        if not os.path.exists('/home/antergos/.config/openbox'):
            # Hide progress bar
            self.progressbar.hide()

        self.set_focus(None)

        misc.gtk_refresh()