Ejemplo n.º 1
0
    def __init__(self):
        self.asst = gtk.Assistant()
        self.asst.set_title(_('Debian Live Magic'))
        self.asst.set_default_size(640, 480)
        self.asst.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
        self.asst.set_position(gtk.WIN_POS_CENTER)

        self.asst.connect('apply', self.controller.on_wizard_apply)
        self.asst.connect('cancel', self.controller.on_wizard_cancel)

        def add_about_button():
            label = gtk.Label(_('About'))
            label.show()

            image = gtk.Image()
            image.set_from_stock(gtk.STOCK_ABOUT, gtk.ICON_SIZE_BUTTON)
            image.show()

            vbox = gtk.HBox(spacing=4)
            vbox.add(label)
            vbox.add(image)
            vbox.show()

            btn = gtk.Button()
            btn.add(vbox)
            btn.connect('clicked', self.controller.on_about_request)
            btn.show()

            self.asst.add_action_widget(btn)
        add_about_button()

        # Load paages from Glade resource file.
        notebook = self['notebook_wizard']
        page_types = [gtk.ASSISTANT_PAGE_INTRO] + \
            [gtk.ASSISTANT_PAGE_CONTENT] * (notebook.get_n_pages() - 2) + \
            [gtk.ASSISTANT_PAGE_CONFIRM]

        hide_distribution = False
        try:
            f = open('/etc/debian_version')
            if f.read(3) == "5.0":
                hide_distribution = True
            f.close()
        except:
            pass

        for i in range(notebook.get_n_pages()):
            if i == 2 and hide_distribution:
                # Hide distribution when running Lenny as stable.
                continue

            if i == 5 and self.controller.get_host_architecture() != 'amd64':
                # Only show architecture page if using amd64
                continue

            page = notebook.get_nth_page(i)
            page.unparent()
            self.asst.append_page(page)
            self.asst.set_page_complete(page, True)
            self.asst.set_page_type(page, page_types[i])

            self.asst.set_page_title(page, notebook.get_tab_label_text(page))

        c = self['combobox_mirror']
        c.prepend_text(get_mirror())
        c.set_active(0)

        c = self['combo_net_root_filesystem']
        c.append_text('NFS')
        c.append_text('CIFS')
        c.set_active(0)

        c = self['combo_locale']
        c.set_active(0)
        match = os.environ.get('LANG', 'en_US.UTF-8')
        found = False
        for idx, locale in enumerate(self.controller.get_locales()):
            c.append_text(locale)

            if found:
                continue

            if locale.replace('-', '_') == match.replace('-', '_'):
                c.set_active(idx)
                found = True
            elif match.startswith(locale):
                c.set_active(idx)

        c = self['combo_keyboard']
        match = None

        try:
            kv = KeyVar('/etc/default', 'console-setup', {}, filename='/etc/default/console-setup')
            match = kv.get('XKBLAYOUT')
        except IOError:
            pass

        pat = re.compile(r'\s*Option\s*"XkbLayout"\s*"([^"]+)"')
        try:
            xorgconf = file('/etc/X11/xorg.conf')
            for line in xorgconf:
                m = pat.match(line)
                if m:
                    match = m.group(1)
        except IOError:
            pass

        if match is None:
            match = "us"
        elif match == 'gb':
            match = 'uk'

        for idx, layout in enumerate(self.controller.get_keyboard_layouts()):
            code, name = layout
            c.append_text('%s (%s)' % (name, code.upper()))
            if code == match:
                c.set_active(idx)

        server = '192.168.1.1'
        path = '/srv/debian-live'
        try:
            kv = KeyVar('/etc/live', 'build.conf', {}, filename='/etc/live/build.conf')
            server = kv.get('LB_NET_ROOT_SERVER', server)
            path = kv.get('LB_NET_ROOT_PATH', path)
        except IOError:
            pass
        self['entry_net_root_server'].set_text(server)
        self['entry_net_root_path'].set_text(path)

        f = self['filechooser_build_directory']
        f.set_uri(self.controller.get_homedir())
Ejemplo n.º 2
0
    def __init__(self):
        self.asst = gtk.Assistant()
        self.asst.set_title(_('Debian Live Magic'))
        self.asst.set_default_size(640, 480)
        self.asst.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
        self.asst.set_position(gtk.WIN_POS_CENTER)

        self.asst.connect('apply', self.controller.on_wizard_apply)
        self.asst.connect('cancel', self.controller.on_wizard_cancel)

        def add_about_button():
            label = gtk.Label(_('About'))
            label.show()

            image = gtk.Image()
            image.set_from_stock(gtk.STOCK_ABOUT, gtk.ICON_SIZE_BUTTON)
            image.show()

            vbox = gtk.HBox(spacing=4)
            vbox.add(label)
            vbox.add(image)
            vbox.show()

            btn = gtk.Button()
            btn.add(vbox)
            btn.connect('clicked', self.controller.on_about_request)
            btn.show()

            self.asst.add_action_widget(btn)

        add_about_button()

        # Load paages from Glade resource file.
        notebook = self['notebook_wizard']
        page_types = [gtk.ASSISTANT_PAGE_INTRO] + \
            [gtk.ASSISTANT_PAGE_CONTENT] * (notebook.get_n_pages() - 2) + \
            [gtk.ASSISTANT_PAGE_CONFIRM]

        hide_distribution = False
        try:
            f = open('/etc/debian_version')
            if f.read(3) == "5.0":
                hide_distribution = True
            f.close()
        except:
            pass

        for i in range(notebook.get_n_pages()):
            if i == 2 and hide_distribution:
                # Hide distribution when running Lenny as stable.
                continue

            if i == 5 and self.controller.get_host_architecture() != 'amd64':
                # Only show architecture page if using amd64
                continue

            page = notebook.get_nth_page(i)
            page.unparent()
            self.asst.append_page(page)
            self.asst.set_page_complete(page, True)
            self.asst.set_page_type(page, page_types[i])

            self.asst.set_page_title(page, notebook.get_tab_label_text(page))

        c = self['combobox_mirror']
        c.prepend_text(get_mirror())
        c.set_active(0)

        c = self['combo_net_root_filesystem']
        c.append_text('NFS')
        c.append_text('CIFS')
        c.set_active(0)

        c = self['combo_locale']
        c.set_active(0)
        match = os.environ.get('LANG', 'en_US.UTF-8')
        found = False
        for idx, locale in enumerate(self.controller.get_locales()):
            c.append_text(locale)

            if found:
                continue

            if locale.replace('-', '_') == match.replace('-', '_'):
                c.set_active(idx)
                found = True
            elif match.startswith(locale):
                c.set_active(idx)

        c = self['combo_keyboard']
        match = None

        try:
            kv = KeyVar('/etc/default',
                        'console-setup', {},
                        filename='/etc/default/console-setup')
            match = kv.get('XKBLAYOUT')
        except IOError:
            pass

        pat = re.compile(r'\s*Option\s*"XkbLayout"\s*"([^"]+)"')
        try:
            xorgconf = file('/etc/X11/xorg.conf')
            for line in xorgconf:
                m = pat.match(line)
                if m:
                    match = m.group(1)
        except IOError:
            pass

        if match is None:
            match = "us"
        elif match == 'gb':
            match = 'uk'

        for idx, layout in enumerate(self.controller.get_keyboard_layouts()):
            code, name = layout
            c.append_text('%s (%s)' % (name, code.upper()))
            if code == match:
                c.set_active(idx)

        server = '192.168.1.1'
        path = '/srv/debian-live'
        try:
            kv = KeyVar('/etc/default',
                        'live-helper', {},
                        filename='/etc/default/live-helper')
            server = kv.get('LH_NET_ROOT_SERVER', server)
            path = kv.get('LH_NET_ROOT_PATH', path)
        except IOError:
            pass
        self['entry_net_root_server'].set_text(server)
        self['entry_net_root_path'].set_text(path)

        f = self['filechooser_build_directory']
        f.set_uri(self.controller.get_homedir())