Example #1
0
class InstallClass(personal_desktop.InstallClass):
    # name has underscore used for mnemonics, strip if you dont need it
    id = "workstation"
    name = N_("_Workstation")
    pixmap = "workstation.png"
    description = N_("This option installs a graphical desktop "
                     "environment with tools for software "
                     "development and system administration. ")

    pkgstext = N_("\tDesktop shell (GNOME)\n"
                  "\tOffice suite (OpenOffice.org)\n"
                  "\tWeb browser (Mozilla) \n"
                  "\tEmail (Evolution)\n"
                  "\tInstant messaging\n"
                  "\tSound and video applications\n"
                  "\tGames\n"
                  "\tSoftware Development Tools\n"
                  "\tAdministration Tools\n")

    sortPriority = 2
    showLoginChoice = 0

    def setGroupSelection(self, grpset, intf):
        personal_desktop.InstallClass.setGroupSelection(self, grpset, intf)
        grpset.selectGroup("emacs")
        grpset.selectGroup("gnome-software-development")
        grpset.selectGroup("x-software-development")
        grpset.selectGroup("development-tools")

    def __init__(self, expert):
        personal_desktop.InstallClass.__init__(self, expert)
Example #2
0
    def __init__(self, driveorder, diskset):
        self.driveOrder = driveorder
        self.diskset = diskset

        hbox = gtk.HBox(False, 5)

        # different widget for this maybe?
        self.driveOrderStore = gtk.ListStore(gobject.TYPE_STRING,
                                             gobject.TYPE_STRING,
                                             gobject.TYPE_STRING)
        sw = gtk.ScrolledWindow()
        sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)

        self.driveOrderView = gtk.TreeView(self.driveOrderStore)
        i = 0
        for columnName in [N_("Drive"), N_("Size"), N_("Model")]:
            renderer = gtk.CellRendererText()
            column = gtk.TreeViewColumn(columnName, renderer, text=i)
            i = i + 1
            column.set_clickable(False)
            self.driveOrderView.append_column(column)

        self.driveOrderView.set_rules_hint(False)
        self.driveOrderView.set_headers_visible(False)
        self.driveOrderView.set_enable_search(False)

        self.makeDriveOrderStore()

        sw.add(self.driveOrderView)
        self.driveOrderView.set_size_request(375, 80)
        hbox.pack_start(sw, False)

        arrowbox = gtk.VBox(False, 5)
        arrowButton = gtk.Button()
        arrow = gtk.Arrow(gtk.ARROW_UP, gtk.SHADOW_ETCHED_IN)
        arrowButton.add(arrow)
        arrowButton.connect("clicked", self.arrowClicked, gtk.ARROW_UP)
        arrowbox.pack_start(arrowButton, False)

        spacer = gtk.Label("")
        spacer.set_size_request(10, 1)
        arrowbox.pack_start(spacer, False)

        arrowButton = gtk.Button()
        arrow = gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_ETCHED_IN)
        arrowButton.add(arrow)
        arrowButton.connect("clicked", self.arrowClicked, gtk.ARROW_DOWN)
        arrowbox.pack_start(arrowButton, False)

        alignment = gtk.Alignment()
        alignment.set(0, 0.5, 0, 0)
        alignment.add(arrowbox)
        hbox.pack_start(alignment, False)

        self.widget = hbox
Example #3
0
class UpgradeConfirmWindow(ConfirmWindow):
    windowTitle = N_("About to Upgrade")
    htmlTag = "aboutupgrade"

    def getNext(self):
        if self.id.methodstr.startswith("cdrom://") and (
                self.id.instClass.name
                and self.id.instClass.name != "kickstart"):
            rc = presentRequiredMediaMessage(self.intf, self.id.grpset)

            if rc == 0:
                rc2 = self.intf.messageWindow(
                    _("Reboot?"),
                    _("The system will be rebooted now."),
                    type="custom",
                    custom_icon="warning",
                    custom_buttons=[_("_Back"), _("_Reboot")])
                if rc2 == 1:
                    sys.exit(0)
                else:
                    raise gui.StayOnScreen

    def getScreen(self, intf, id):
        self.intf = intf
        self.id = id
        return ConfirmWindow.getScreen(
            self,
            _("Click next to begin upgrade of %s.") % (productName, ),
            _("A complete log of the upgrade can be found in "
              "the file '%s' after rebooting your system.") %
            (u'\uFEFF/\uFEFFroot\uFEFF/\uFEFFupgrade\uFEFF.\uFEFFlog', ))
Example #4
0
class InstallClass(baseclass):
    name = N_("Upgrade Existing System")
    pixmap = "upgrade.png"
    sortPriority = 999999

    parentClass = (_("Upgrade"), "upgrade.png")

    def requiredDisplayMode(self):
        return 't'

    def setSteps(self, dispatch):
        dispatch.setStepList(
            "language", "keyboard", "welcome", "installtype", "regkey",
            "findrootparts", "findinstall", "partitionobjinit", "upgrademount",
            "upgrademigfind", "upgrademigratefs", "upgradecontinue",
            "reposetup", "upgbootloader", "reipl", "checkdeps", "dependencies",
            "confirmupgrade", "postselection", "install", "migratefilesystems",
            "preinstallconfig", "installpackages", "postinstallconfig",
            "instbootloader", "dopostaction", "writeregkey", "methodcomplete",
            "copylogs", "complete")

        if rhpl.getArch() != "i386" and rhpl.getArch() != "x86_64":
            dispatch.skipStep("bootloader")
            dispatch.skipStep("bootloaderadvanced")

        if rhpl.getArch() != "i386" and rhpl.getArch() != "x86_64":
            dispatch.skipStep("upgbootloader")

    def setInstallData(self, anaconda):
        baseclass.setInstallData(self, anaconda)
        anaconda.id.setUpgrade(True)

    def __init__(self, expert):
        baseclass.__init__(self, expert)
Example #5
0
class InstallConfirmWindow(ConfirmWindow):
    windowTitle = N_("About to Install")
    htmlTag = "aboutinstall"

    def getNext(self):
        if self.id.methodstr.startswith("cdrom://") and (
                self.id.instClass.name
                and self.id.instClass.name != "kickstart"):
            rc = presentRequiredMediaMessage(self.intf, self.id.grpset)

            if rc == 0:
                rc2 = self.intf.messageWindow(
                    _("Reboot?"),
                    _("The system will be rebooted now."),
                    type="custom",
                    custom_icon="warning",
                    custom_buttons=[_("_Back"), _("_Reboot")])
                if rc2 == 1:
                    sys.exit(0)
                else:
                    raise gui.StayOnScreen

    def getScreen(self, intf, id):
        self.intf = intf
        self.id = id

        return ConfirmWindow.getScreen(
            self,
            _("Click next to begin installation of %s.") % (productName, ),
            _("A complete log of the installation can be found in "
              "the file '%s' after rebooting your system.\n\n"
              "A kickstart file containing the installation options "
              "selected can be found in the file '%s' after rebooting the "
              "system.") % (u'/root/install.log', '/root/anaconda-ks.cfg'))
Example #6
0
class InstallClass(BaseInstallClass):
    # name has underscore used for mnemonics, strip if you dont need it
    id = "personal desktop"
    name = N_("_Personal Desktop")
    pixmap = "workstation.png"
    _description = N_("Perfect for personal computers or laptops, select this "
                      "installation type to install a graphical desktop "
                      "environment and create a system ideal for home "
                      "or desktop use.")

    pkgstext = N_("\tDesktop shell (GNOME)\n"
                  "\tOffice suite (OpenOffice.org)\n"
                  "\tWeb browser \n"
                  "\tEmail (Evolution)\n"
                  "\tInstant messaging\n"
                  "\tSound and video applications\n"
                  "\tGames\n")

    showLoginChoice = 0
    sortPriority = 1
    hidden = 1

    def setSteps(self, dispatch):
        BaseInstallClass.setSteps(self, dispatch)
        dispatch.skipStep("partition")
        dispatch.skipStep("desktopchoice", skip=0)
        dispatch.skipStep("package-selection", skip=1)

    def setGroupSelection(self, anaconda):
        BaseInstallClass.__init__(self, anaconda.backend)

        anaconda.backend.unselectAll()

        anaconda.backend.selectGroup("workstation-common", asMeta=1)
        anaconda.backend.selectGroup("gnome-desktop")
        anaconda.backend.selectGroup("compat-arch-support",
                                     asMeta=1,
                                     missingOk=1)

    def setInstallData(self, anaconda):
        BaseInstallClass.setInstallData(self, anaconda)
        BaseInstallClass.setDefaultPartitioning(self, anaconda.id.partitions,
                                                CLEARPART_TYPE_LINUX)

    def __init__(self, expert):
        BaseInstallClass.__init__(self, expert)
class CongratulationWindow (InstallWindow):		

    windowTitle = N_("Congratulations")

    def __init__ (self, ics):
	InstallWindow.__init__(self, ics)

        ics.setPrevEnabled(False)

        # force buttonbar on in case release notes viewer is running
        ics.cw.mainxml.get_widget("buttonBar").set_sensitive(True)

        # this mucks around a bit, but it's the weird case and it's
        # better than adding a lot of complication to the normal
	ics.cw.mainxml.get_widget("nextButton").hide()

	self.rebootButton = ics.cw.mainxml.get_widget("rebootButton")
	self.rebootButton.show()
	self.rebootButton.grab_focus()

    def getNext(self):
	# XXX - copy any screenshots over
	gui.copyScreenshots()

    # CongratulationWindow tag=NA
    def getScreen (self, anaconda):
        hbox = gtk.HBox (False, 5)
        
        pix = gui.readImageFromFile ("done.png")
        if pix:
            a = gtk.Alignment ()
            a.add (pix)
            a.set (0.5, 0.5, 1.0, 1.0)
	    a.set_size_request(200, -1)
            hbox.pack_start (a, False, False, 36)

        bootstr = ""
        if rhpl.getArch() in ['s390', 's390x']:
            floppystr = ""
            if not anaconda.canReIPL:
                self.rebootButton.set_label(_("Shutdown"))
            if not anaconda.reIPLMessage is None:
                floppystr = anaconda.reIPLMessage

        else:
            floppystr = _("Remove any media used during the installation "
                          "process and press the \"Reboot\" button to "
                          "reboot your system."
                          "\n\n")

        txt = _("Congratulations, the installation is complete.\n\n"
                "%s%s") %(floppystr, bootstr)
	label = gui.WrappingLabel(txt)

        hbox.pack_start (label, True, True)

        gtk.gdk.beep()
        return hbox
Example #8
0
class CongratulationWindow (InstallWindow):		

    windowTitle = N_("Congratulations")

    def __init__ (self, ics):
	InstallWindow.__init__(self, ics)

        ics.setPrevEnabled(gtk.FALSE)
        ics.setNextButton(gtk.STOCK_QUIT, _("Reboo_t"))
        ics.setHelpButtonEnabled(gtk.FALSE)
        ics.setHelpEnabled(gtk.FALSE)
	ics.setGrabNext(1)

    def getNext(self):
	# XXX - copy any screenshots over
	gui.copyScreenshots()

    # CongratulationWindow tag=NA
    def getScreen (self):
        self.ics.setHelpEnabled (gtk.FALSE)

        hbox = gtk.HBox (gtk.FALSE, 5)
        
        pix = self.ics.readPixmap ("done.png")
        if pix:
            a = gtk.Alignment ()
            a.add (pix)
            a.set (0.5, 0.5, 1.0, 1.0)
	    a.set_size_request(200, -1)
            hbox.pack_start (a, gtk.FALSE, gtk.FALSE, 36)

        bootstr = ""
        if iutil.getArch() == "s390":
            floppystr = ""
        else:
            floppystr = _("Remove any installation media (diskettes or "
                          "CD-ROMs) used during the installation process "
                          "and press the \"Reboot\" button to reboot your "
                          "system."
                          "\n\n")

        txt = _("Congratulations, the installation is complete.\n\n"
                "%s%s") %(floppystr, bootstr)
        foo = _("For information on Errata (updates and bug fixes), visit:\n"
                "\thttp://www.redhat.com/errata/\n\n"
                "For information on automatic updates through Red Hat "
                "Network, visit:\n"
                "\thttp://rhn.redhat.com/\n\n"
                "For information on using and configuring the system, visit:\n"
                "\thttp://www.redhat.com/docs/\n"
                "\thttp://www.redhat.com/apps/support/\n\n"
                "To register the product for support, visit:\n"
                "\thttp://www.redhat.com/apps/activate/\n\n")

	label = gui.WrappingLabel(txt)

        hbox.pack_start (label, gtk.TRUE, gtk.TRUE)
        return hbox
    def getScreen(self, anaconda):

        self.fsset = anaconda.id.fsset
        self.migent = self.fsset.getMigratableEntries()

        box = gtk.VBox(False, 5)
        box.set_border_width(5)

        text = N_("This release of %s supports "
                  "the ext3 journalling file system.  It has several "
                  "benefits over the ext2 file system traditionally shipped "
                  "in %s.  It is possible to migrate the ext2 "
                  "formatted partitions to ext3 without data loss.\n\n"
                  "Which of these partitions would you like to migrate?" %
                  (productName, productName))

        label = gtk.Label(_(text))
        label.set_alignment(0.5, 0.0)
        label.set_size_request(400, -1)
        label.set_line_wrap(True)
        box.pack_start(label, False)

        cbox = gtk.VBox(False, 5)
        self.cbs = []
        for entry in self.migent:
            if rhpl.getArch() == "ia64" \
                    and entry.getMountPoint() == "/boot/efi":
                continue
            if entry.fsystem.getName() != entry.origfsystem.getName():
                migrating = 1
            else:
                migrating = 0

            cb = gtk.CheckButton(
                "/dev/%s - %s - %s" %
                (entry.device.getDevice(), entry.origfsystem.getName(),
                 entry.mountpoint))
            cb.set_active(migrating)
            cbox.pack_start(cb, False)

            self.cbs.append((cb, entry))

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        sw.add_with_viewport(cbox)
        sw.set_size_request(-1, 175)

        viewport = sw.get_children()[0]
        viewport.set_shadow_type(gtk.SHADOW_IN)

        a = gtk.Alignment(0.25, 0.5)
        a.add(sw)

        box.pack_start(a, True)

        a = gtk.Alignment(0.5, 0.5)
        a.add(box)
        return a
Example #10
0
class InstallClass(BaseInstallClass):
    # name has underscore used for mnemonics, strip if you dont need it
    id = "fedora"
    name = N_("_Fedora")
    _description = N_("The default installation of %s includes a set of "
                      "software applicable for general internet usage. "
                      "What additional tasks would you like your system "
                      "to include support for?")
    _descriptionFields = (productName, )
    sortPriority = 10000
    if productName.startswith("Red Hat Enterprise") or 1:
        hidden = 1

    tasks = [(N_("Office and Productivity"),
              ["graphics", "office", "games", "sound-and-video"]),
             (
                 N_("Software Development"),
                 [
                     "development-libs", "development-tools",
                     "gnome-software-development", "x-software-development"
                 ],
             ), (N_("Web server"), ["web-server"])]

    repos = {
        "Fedora Extras":
        ("http://download.fedora.redhat.com/pub/fedora/linux/extras/development/%s"
         % (rpmUtils.arch.getBaseArch(), ), None)
    }

    def setInstallData(self, anaconda):
        BaseInstallClass.setInstallData(self, anaconda)
        BaseInstallClass.setDefaultPartitioning(self, anaconda.id.partitions,
                                                CLEARPART_TYPE_LINUX)

    def setGroupSelection(self, anaconda):
        grps = anaconda.backend.getDefaultGroups(anaconda)
        map(lambda x: anaconda.backend.selectGroup(x), grps)

    def setSteps(self, dispatch):
        BaseInstallClass.setSteps(self, dispatch)
        dispatch.skipStep("partition")

    def __init__(self, expert):
        BaseInstallClass.__init__(self, expert)
Example #11
0
    def setPackageStatus(self, state, amount):
        if self.pkgstatus is None:
            return

        if state == "downloading":
            msgstr = N_("Downloading %s") % (amount, )
        else:
            msgstr = state
        self.pkgstatus.set_text(msgstr)
        self.processEvents()
Example #12
0
class InstallClass(BaseInstallClass):
    # name has underscore used for mnemonics, strip if you dont need it
    id = "custom"
    name = N_("_Custom")
    pixmap = "custom.png"
    description = N_("Select this installation type to gain complete "
                     "control over the installation process, including "
                     "software package selection and partitioning.")
    sortPriority = 10000
    showLoginChoice = 1
    showMinimal = 1

    def setInstallData(self, id):
        BaseInstallClass.setInstallData(self, id)
        BaseInstallClass.setDefaultPartitioning(self, id.partitions,
                                                CLEARPART_TYPE_LINUX)

    def __init__(self, expert):
        BaseInstallClass.__init__(self, expert)
Example #13
0
    def __init__(self, compsxml, hdrlist):
        self.hdrlist = hdrlist
        self.compsxml = compsxml
        self.groups = {}

        for xmlgrp in compsxml.groups.values():
            group = Group(self, xmlgrp)
            self.groups[xmlgrp.id] = group

        # build up an Everything group
        everything = rhpl.comps.Group(self.compsxml)
        everything.name = N_("Everything")
        everything.id = "everything"
        everything.description = EVERYTHING_DESCRIPTION

        multiarch = rhpl.arch.getMultiArchInfo()
        if multiarch is not None:
            (comp, best, biarch) = multiarch
        for pkgname in hdrlist.pkgnames.keys():
            if EverythingExclude.has_key(pkgname):
                continue

            mainnevra = hdrlist.getBestNevra(pkgname, prefArch=None)
            if mainnevra is None:
                continue

            everything.packages[mainnevra] = (u"mandatory", mainnevra)
            if multiarch is not None:
                # get the main and the biarch version of this package
                # for everything group
                secnevra = hdrlist.getBestNevra(pkgname, prefArch=biarch)
                if mainnevra != secnevra and secnevra is not None:
                    everything.packages[secnevra] = (u"mandatory", secnevra)

        self.compsxml.groups["Everything"] = everything
        self.groups["everything"] = Group(self, everything)

        # have to do includes and metagroups in a second pass so that
        # we can make sure the group is defined.
        for xmlgrp in compsxml.groups.values():
            group = self.groups[xmlgrp.id]
            for id in xmlgrp.groups.keys():
                if not self.groups.has_key(id):
                    log("%s references component %s which doesn't exist" %
                        (xmlgrp.id, id))
                    continue
                group.addGroupRequires(id)

            for id in xmlgrp.metapkgs.keys():
                if not self.groups.has_key(id):
                    log("%s references component %s which doesn't exist" %
                        (xmlgrp.id, id))
                    continue
                group.addMetaPkg(xmlgrp.metapkgs[id])
Example #14
0
class UpgradeConfirmWindow(ConfirmWindow):
    windowTitle = N_("About to Upgrade")

    def getScreen(self, anaconda):
        self.anaconda = anaconda

        return ConfirmWindow.getScreen(
            self,
            _("Click next to begin upgrade of %s.") % (productName, ),
            _("A complete log of the upgrade can be found in "
              "the file '%s' after rebooting your system.") %
            (u'/root/upgrade.log', ))
Example #15
0
class InstallConfirmWindow(ConfirmWindow):
    windowTitle = N_("About to Install")

    def getScreen(self, anaconda):
        self.anaconda = anaconda

        return ConfirmWindow.getScreen(
            self,
            _("Click next to begin installation of %s.") % (productName, ),
            _("A complete log of the installation can be found in "
              "the file '%s' after rebooting your system.\n\n"
              "A kickstart file containing the installation options "
              "selected can be found in the file '%s' after rebooting the "
              "system.") % (u'/root/install.log', '/root/anaconda-ks.cfg'))
class UpgradeBootloaderWindow(InstallWindow):
    windowTitle = N_("Upgrade Boot Loader Configuration")
    htmlTag = "bl-upgrade"

    def getPrev(self):
        pass

    def getNext(self):
        if self.nobl_radio.get_active():
            self.dispatch.skipStep("bootloadersetup", skip=1)
            self.dispatch.skipStep("bootloader", skip=1)
            self.dispatch.skipStep("bootloaderadvanced", skip=1)
            self.dispatch.skipStep("instbootloader", skip=1)
        elif self.newbl_radio.get_active():
            self.dispatch.skipStep("bootloadersetup", skip=0)
            self.dispatch.skipStep("bootloader", skip=0)
            self.dispatch.skipStep("bootloaderadvanced", skip=0)
            self.dispatch.skipStep("instbootloader", skip=0)
            self.bl.doUpgradeOnly = 0
        else:
            self.dispatch.skipStep("bootloadersetup", skip=0)
            self.dispatch.skipStep("bootloader", skip=1)
            self.dispatch.skipStep("bootloaderadvanced", skip=1)
            self.dispatch.skipStep("instbootloader", skip=0)
            self.bl.doUpgradeOnly = 1

            if self.type == "GRUB":
                self.bl.useGrubVal = 1
            else:
                self.bl.useGrubVal = 0
            self.bl.setDevice(self.bootDev)

    def getScreen(self, dispatch, bl):
        self.dispatch = dispatch
        self.bl = bl
        self.intf = dispatch.intf

        (self.type, self.bootDev) = \
                    checkbootloader.getBootloaderTypeAndBoot(dispatch.instPath)

        self.update_radio = gtk.RadioButton(
            None, _("_Update boot loader configuration"))
        updatestr = _("This will update your current boot loader.")

        if self.type is not None and self.bootDev is not None:
            current = _(
                "The installer has detected the %s boot loader "
                "currently installed on %s.") % (self.type, self.bootDev)
            self.update_label = gtk.Label(
                "%s  %s" % (updatestr, _("This is the recommended option.")))
            self.update_radio.set_active(gtk.FALSE)
            update = 1
        else:
            current = _("The installer is unable to detect the boot loader "
                        "currently in use on your system.")
            self.update_label = gtk.Label("%s" % (updatestr, ))
            self.update_radio.set_sensitive(gtk.FALSE)
            self.update_label.set_sensitive(gtk.FALSE)
            update = 0

        self.newbl_radio = gtk.RadioButton(
            self.update_radio, _("_Create new boot loader "
                                 "configuration"))
        self.newbl_label = gtk.Label(
            _("This will let you create a "
              "new boot loader configuration.  If "
              "you wish to switch boot loaders, you "
              "should choose this."))

        self.newbl_radio.set_active(gtk.FALSE)
        self.nobl_radio = gtk.RadioButton(self.update_radio,
                                          _("_Skip boot loader updating"))
        self.nobl_label = gtk.Label(
            _("This will make no changes to boot "
              "loader configuration.  If you are "
              "using a third party boot loader, you "
              "should choose this."))
        self.nobl_radio.set_active(gtk.FALSE)

        for label in [self.update_label, self.nobl_label, self.newbl_label]:
            label.set_alignment(0.8, 0)
            label.set_size_request(275, -1)
            label.set_line_wrap(gtk.TRUE)

        str = _("What would you like to do?")
        # if they have one, the default is to update, otherwise the
        # default is to not touch anything
        if update == 1:
            default = self.update_radio
        else:
            default = self.nobl_radio

        if not dispatch.stepInSkipList("bootloader"):
            self.newbl_radio.set_active(gtk.TRUE)
        elif dispatch.stepInSkipList("instbootloader"):
            self.nobl_radio.set_active(gtk.TRUE)
        else:
            default.set_active(gtk.TRUE)

        box = gtk.VBox(gtk.FALSE, 5)

        label = gtk.Label(current)
        label.set_line_wrap(gtk.TRUE)
        label.set_alignment(0.5, 0.0)
        label.set_size_request(300, -1)
        label2 = gtk.Label(str)
        label2.set_line_wrap(gtk.TRUE)
        label2.set_alignment(0.5, 0.0)
        label2.set_size_request(300, -1)

        box.pack_start(label, gtk.FALSE)
        box.pack_start(label2, gtk.FALSE, padding=10)

        box.pack_start(self.update_radio, gtk.FALSE)
        box.pack_start(self.update_label, gtk.FALSE)
        box.pack_start(self.nobl_radio, gtk.FALSE)
        box.pack_start(self.nobl_label, gtk.FALSE)
        box.pack_start(self.newbl_radio, gtk.FALSE)
        box.pack_start(self.newbl_label, gtk.FALSE)

        a = gtk.Alignment(0.2, 0.1)
        a.add(box)

        return a
Example #17
0
class XConfigWindow(InstallWindow):

    htmlTag = "xconf"
    windowTitle = N_("Graphical Interface (X) Configuration")

    def __init__(self, ics):
        InstallWindow.__init__(self, ics)
        ics.setPrevEnabled(gtk.FALSE)
        self.ics = ics

    def getNext(self):
        if self.skip.get_active():
            self.dispatch.skipStep("monitor")
            self.dispatch.skipStep("xcustom")
            self.dispatch.skipStep("writexconfig")
            self.xsetup.skipx = 1

            return None
        else:
            self.dispatch.skipStep("monitor", skip=0)
            self.dispatch.skipStep("xcustom", skip=0)
            self.dispatch.skipStep("writexconfig", skip=0)
            self.xsetup.skipx = 0

# if ppc then we bail now, you cant selected videocard for ppc
        if iutil.getArch() == "ppc":
            return None

        # set videocard type (assuming we're working with PRIMARY card)
        if self.currentCard:
            try:
                selected = self.cards[self.currentCard]
            except:
                self.intf.messageWindow(
                    _("Unknown video card"),
                    _("An error has occurred selecting "
                      "the video card %s. Please report "
                      "this error to bugzilla.redhat.com.") % self.currentCard)
                raise gui.StayOnScreen

            primary_card = self.videocard.primaryCard()
            primary_card.setCardData(selected)
            primary_card.setDevID(selected["NAME"])
            primary_card.setDescription(selected["NAME"])

            # pull out resolved version of card data
            card_data = primary_card.getCardData()
            if (card_data.has_key("DRIVER")
                    and not card_data.has_key("UNSUPPORTED")):
                server = "Xorg"
            else:
                server = "XF86_" + card_data["SERVER"]

            primary_card.setXServer(server)
        else:
            selected = None

        # see if they actually picked a card, otherwise keep going
        if selected == None:
            self.intf.messageWindow(
                _("Unspecified video card"),
                _("You need to pick a video card before "
                  "X configuration can continue.  If you "
                  "want to skip X configuration entirely "
                  "choose the 'Skip X Configuration' button."))
            raise gui.StayOnScreen

        # sniff out the selected ram size
        menu = self.ramOption.get_menu().get_active()
        index = 0
        for menu_item in self.ramOption.get_menu().get_children():
            if menu_item == menu:
                break
            index = index + 1

        vidram = self.videocard.possible_ram_sizes()[index]

        # lots of duplication here complicated by factor we have a
        # videocard object as part of instdata and in xhwstate!!
        # need to consolidate
        try:
            self.videocard.primaryCard().setVideoRam(str(vidram))
            self.xsetup.xhwstate.set_videocard_ram(vidram)
            cardname = self.videocard.primaryCard().cardData["NAME"]
            self.xsetup.xhwstate.set_videocard_name(cardname)
            self.xsetup.xhwstate.set_videocard_card(cardname)
        except:
            log(
                "videocard-getNext: could not determine cardname for primary card %s",
                self.videocard.primaryCard())
        return None

    def skipToggled(self, widget, *args):
        if not self.force_ppc_fb:
            self.configbox.set_sensitive(not widget.get_active())

    def selectCardType(self, selection, *args):
        if self.ignoreEvents:
            return

        (model, iter) = selection.get_selected()
        if iter:
            self.currentCard = model.get_value(iter, 0)
        else:
            print "unknown error in selectCardType!"

    def restorePressed(self, button):
        self.currentCard = self.probedCard
        self.currentMem = self.probedMem
        self.setCurrent(self.probedCard, self.probedMem)

    def desktopCb(self, widget, desktop):
        self.newDesktop = desktop

    def cardviewSelectCb(self, path):
        # XXX 01/09/2002 - work around broken gtkwidget, fix when jrb fixes
        if len(path) == 1:
            if self.lastvalidselection:
                self.ignoreEvents = 1
                selection = self.cardview.get_selection()
                if not selection.path_is_selected(self.lastvalidselection):
                    selection.select_path(self.lastvalidselection)
                self.ignoreEvents = 0
            return 0

        self.lastvalidselection = path

        return 1

    def setCurrent(self, cardname, currentMem, recenter=1):
        self.ignoreEvents = 1
        self.currentCard = cardname

        parent = None
        iter = self.cardstore.get_iter_first()
        # iterate over the list, looking for the current mouse selection
        while iter:
            # if this is a parent node, get the first child and iter over them
            if self.cardstore.iter_has_child(iter):
                parent = iter
                iter = self.cardstore.iter_children(parent)
                continue
            # if it's not a parent node and the mouse matches, select it.
            elif self.cardstore.get_value(iter, 0) == cardname:
                path = self.cardstore.get_path(parent)
                self.cardview.expand_row(path, gtk.TRUE)
                selection = self.cardview.get_selection()
                selection.unselect_all()
                selection.select_iter(iter)
                path = self.cardstore.get_path(iter)
                col = self.cardview.get_column(0)
                self.cardview.set_cursor(path, col, gtk.FALSE)
                if recenter:
                    self.cardview.scroll_to_cell(path, col, gtk.TRUE, 0.0, 0.5)
                break
            # get the next row.
            iter = self.cardstore.iter_next(iter)
            # if there isn't a next row and we had a parent, go to the node
            # after the parent we've just gotten the children of.
            if not iter and parent:
                parent = self.cardstore.iter_next(parent)
                iter = parent

        #--Some video cards don't return exact numbers, so do some hacks
        try:
            vidRam = string.atoi(currentMem)
        except:
            vidRam = 1024

        count = self.videocard.index_closest_ram_size(vidRam)
        self.ramOption.remove_menu()
        self.ramMenu.set_active(count)
        self.ramOption.set_menu(self.ramMenu)

        self.ignoreEvents = 0

    # XConfigWindow tag="xconf"
    def getScreen(self, dispatch, xsetup, videocard, intf):
        self.ics.setHelpEnabled(gtk.TRUE)

        self.dispatch = dispatch
        self.videocard = videocard
        self.xsetup = xsetup
        self.intf = intf

        self.lastvalidselection = None

        box = gtk.VBox(gtk.FALSE, 0)
        box.set_border_width(0)

        self.autoBox = gtk.VBox(gtk.FALSE, 5)

        self.force_ppc_fb = 0
        arch = iutil.getArch()
        # we can only probe video ram on i386
        # and we force frame buffer on ppc currently
        if arch == "ppc":
            label = makeFormattedLabel(
                _("Your system will be setup to "
                  "use the frame buffer driver for "
                  "the X Window System.  If you do "
                  "not want to setup the X Window "
                  "System, choose "
                  "'Skip X Configuration' below."))
            box.pack_start(label, gtk.FALSE, gtk.FALSE)
            self.force_ppc_fb = 1
        elif arch != "i386":
            label = makeFormattedLabel(
                _("Your video ram size can not be "
                  "autodetected.  Choose your video "
                  "ram size from the choices below:"))
            box.pack_start(label, gtk.FALSE)
        else:
            self.autoBox = gtk.VBox(gtk.FALSE, 5)

            label = makeFormattedLabel(
                _("In most cases, the video hardware "
                  "can be automatically detected. "
                  "If the detected settings are not "
                  "correct for the hardware, select "
                  "the right settings."))
            self.autoBox.pack_start(label, gtk.FALSE)

            box.pack_start(self.autoBox, gtk.FALSE)

# load in card database
        self.cards = self.videocard.cardsDB()
        cards = self.cards.keys()
        cards.sort()

        other_cards = copy.copy(cards)
        self.currentCard = None
        self.probedCard = None
        if self.videocard.primaryCard():
            carddata = self.videocard.primaryCard().getCardData(dontResolve=1)
            if carddata:
                self.currentCard = carddata["NAME"]
            else:
                self.currentCard = None

            carddata = self.videocard.primaryCard(useProbed=1).getCardData()
            if carddata:
                self.probedCard = carddata["NAME"]
            else:
                self.probedCard = None

# load images of videocard
        fn = self.ics.findPixmap("videocard.png")
        p = gtk.gdk.pixbuf_new_from_file(fn)
        if p:
            self.videocard_p, self.videocard_b = p.render_pixmap_and_mask()

        # Videocard selection tree - preset 'Generic' and 'Other' nodes
        self.cardstore = gtk.TreeStore(gobject.TYPE_STRING,
                                       gobject.TYPE_STRING)

        toplevels = {}

        # add "Generic" in before "Other" if supporting XFree86 3.x
        # Note other changes in videocard.py and elsewhere required to support
        # XFree86 3.x again
        manufacturers = ["Other"] + self.videocard.manufacturerDB()
        for man in manufacturers:
            toplevels[man] = self.cardstore.append(None)
            self.cardstore.set_value(toplevels[man], 0, man)

# now go through cards and matchup with manufacturers
        for card in cards:
            temp = string.lower(card)

            for man in manufacturers:
                if string.lower(man) == temp[:len(man)]:
                    parent = toplevels.get(man)
                    iter = self.cardstore.append(parent)
                    self.cardstore.set_value(iter, 0, card)
                    other_cards.remove(card)

        # now add cards not categorized into above manufacturers
        for card in other_cards:
            parent = toplevels.get("Other")
            iter = self.cardstore.append(parent)
            self.cardstore.set_value(iter, 0, card)

        self.cardview = gtk.TreeView(self.cardstore)
        self.cardview.set_property("headers-visible", gtk.FALSE)
        col = gtk.TreeViewColumn(None, gtk.CellRendererText(), text=0)
        self.cardview.append_column(col)
        selection = self.cardview.get_selection()
        selection.connect("changed", self.selectCardType)
        selection.set_select_function(self.cardviewSelectCb)

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)
        sw.add(self.cardview)

        # only show this option on non-ppc
        if not self.force_ppc_fb:
            box.pack_start(sw, gtk.TRUE)

        #Memory configuration menu
        hbox = gtk.HBox()
        hbox.set_border_width(3)

        label = gui.MnemonicLabel(_("_Video card RAM: "))

        self.ramOption = gtk.OptionMenu()
        label.set_mnemonic_widget(self.ramOption)
        self.ramOption.set_size_request(40, 20)
        self.ramMenu = gtk.Menu()

        for mem in self.videocard.possible_ram_sizes():
            if mem < 1000:
                tag = "%d KB" % (mem)
            else:
                tag = "%d MB" % (mem / 1024)

            memitem = gtk.MenuItem(tag)
            self.ramMenu.add(memitem)

        hbox.pack_start(label, gtk.FALSE)
        hbox.pack_start(self.ramOption, gtk.TRUE, gtk.TRUE, 25)

        self.ramOption.set_menu(self.ramMenu)

        # only show this option on non-ppc
        if not self.force_ppc_fb:
            box.pack_start(hbox, gtk.FALSE)

        restore = gtk.Button(_("Restore _original values"))
        restore.connect("clicked", self.restorePressed)
        hbox.pack_start(restore, gtk.FALSE, 25)

        self.skip = gtk.CheckButton(_("_Skip X configuration"))
        self.skip.connect("toggled", self.skipToggled)

        hbox = gtk.HBox(gtk.TRUE, 5)

        self.topbox = gtk.VBox(gtk.FALSE, 5)
        self.topbox.set_border_width(5)
        if self.force_ppc_fb:
            # tweak packing
            self.topbox.pack_start(box, gtk.FALSE, gtk.FALSE)
            self.topbox.pack_start(self.skip, gtk.FALSE, gtk.FALSE)
        else:
            self.topbox.pack_start(box, gtk.TRUE, gtk.TRUE)
            self.topbox.pack_start(self.skip, gtk.FALSE)

        self.configbox = box

        self.skip.set_active(self.dispatch.stepInSkipList("monitor"))

        # set state
        self.ignoreEvents = 0
        self.currentMem = self.videocard.primaryCard(useProbed=0).getVideoRam()
        self.probedMem = self.videocard.primaryCard(useProbed=1).getVideoRam()
        self.setCurrent(self.currentCard, self.currentMem)

        setupTreeViewFixupIdleHandler(self.cardview, self.cardstore)

        return self.topbox
Example #18
0
class XCustomWindow(InstallWindow):

    htmlTag = "xcustom"
    windowTitle = N_("Customize Graphical Configuration")

    def __init__(self, ics):
        InstallWindow.__init__(self, ics)
        self.ics.setNextEnabled(gtk.TRUE)

    def getPrev(self):
        # restore settings
        self.xsetup.xhwstate.set_resolution(self.origres)
        self.xsetup.xhwstate.set_colordepth(self.origdepth)
        return None

    def getNext(self):

        self.xsetup.xhwstate.set_colordepth(self.selectedDepth)
        self.xsetup.xhwstate.set_resolution(self.selectedRes)

        if ENABLE_DESKTOP_CHOICE:
            self.desktop.setDefaultDesktop(self.newDesktop)

# if we gave them a choice on login style then store it
# otherwise we're just using default setup by
# packages.py::handleX11Packages()
        if self.instClass.showLoginChoice:
            if self.text.get_active():
                rl = 3
            elif self.graphical.get_active():
                rl = 5

            self.desktop.setDefaultRunLevel(rl)

    def testPressed(self, widget, *args):
        log("Somehow X test was attempted")
        return

    def numCompare(self, first, second):
        if first > second:
            return 1
        elif first < second:
            return -1
        return 0

    def depth_cb(self, widget):
        self.ignore_res_cb = 1
        loc = self.depth_optionmenu.get_history()

        if self.selectedDepth == self.avail_depth[loc]:
            self.ignore_res_cb = 0
            return

        self.selectedDepth = self.avail_depth[loc]
        self.xsetup.xhwstate.set_colordepth(self.selectedDepth)

        # now we set color depth, read out what modes are now supported
        self.selectedRes = self.xsetup.xhwstate.get_resolution()
        self.avail_res = self.xsetup.xhwstate.available_resolutions()

        self.create_res_optionmenu()

        if self.selectedRes not in self.avail_res:
            self.selectedRes = self.avail_res[-1]

        self.currentRes = self.avail_res.index(self.selectedRes)
        self.res_optionmenu.set_history(self.currentRes)
        self.ignore_res_cb = 0

    def res_cb(self, widget):
        if self.ignore_res_cb:
            return

        newres = self.res_optionmenu.get_history()
        if self.currentRes == newres:
            return

        self.currentRes = newres
        self.selectedRes = self.avail_res[self.currentRes]
        self.xsetup.xhwstate.set_resolution(self.selectedRes)

        self.swap_monitor(self.currentRes)

    def create_res_optionmenu(self):
        if self.res_optionmenu is None:
            self.res_optionmenu = gtk.OptionMenu()

        if self.res_menu is not None:
            self.res_optionmenu.remove_menu()

        self.res_menu = gtk.Menu()

        for r in self.avail_res:
            item = gtk.MenuItem(r)
            item.show()
            self.res_menu.add(item)

        self.res_optionmenu.set_menu(self.res_menu)

    def load_monitor_preview_pixmap(self, file):
        if self.monitor_align:
            self.hbox.remove(self.monitor_align)

        pix = self.ics.readPixmap(file)
        if pix:
            self.monitor_align = gtk.Alignment()
            self.monitor_align.add(pix)
            self.monitor_align.set(0.5, 0.5, 1.0, 1.0)
            self.hbox.pack_start(self.monitor_align, gtk.TRUE, gtk.TRUE)
        self.hbox.show_all()

    def swap_monitor(self, num):
        def find_monitor_pixmaps():
            files = []

            pixmaps1 = glob.glob("/usr/share/anaconda/pixmaps/monitor_*")
            pixmaps2 = glob.glob("pixmaps/monitor_*")
            if len(pixmaps1) < len(pixmaps2):
                files = pixmaps2
            else:
                files = pixmaps1

            pixmaps = []
            for pixmap in files:
                pixmaps.append(pixmap[string.find(pixmap, "monitor_"):])

            pixmaps.sort()
            return pixmaps

        if self.monitor_pixmaps == None:
            self.monitor_pixmaps = find_monitor_pixmaps()

        try:
            self.load_monitor_preview_pixmap(self.monitor_pixmaps[num])
        except:
            log("Unable to load monitor preview #%s", num)

    def display_desktop_pixmap(self, desktop):
        self.vbox4.destroy()
        self.vbox4 = gtk.VBox()

        if desktop == "GNOME":
            pix = self.ics.readPixmap("gnome.png")
        elif desktop == "KDE":
            pix = self.ics.readPixmap("kde.png")
        else:
            pix = None

        if pix:
            a = gtk.Alignment()
            a.add(pix)
            a.set(0.5, 0.5, 1.0, 1.0)
            self.vbox4.pack_start(a, gtk.TRUE, gtk.TRUE)

        self.hbox4.pack_start(self.vbox4)
        self.hbox4.show_all()

    def desktop_cb(self, widget, desktop):
        self.newDesktop = desktop

        self.display_desktop_pixmap(desktop)

    # XCustomWindow tag="xcustom"
    def getScreen(self, xsetup, monitor, videocard, desktop, grpset, instClass,
                  instPath):

        self.xsetup = xsetup
        self.monitor = monitor
        self.videocard = videocard
        self.desktop = desktop
        self.instClass = instClass

        # dont do anything on ppc - we want to use default fb setting
        if iutil.getArch() != "ppc":
            if not xsetup.imposed_sane_default:
                xsetup.xhwstate.choose_sane_default()
                xsetup.imposed_sane_default = 1

# save so we can restore if necessary going back
        self.origres = self.xsetup.xhwstate.get_resolution()
        self.origdepth = self.xsetup.xhwstate.get_colordepth()

        self.instPath = instPath

        # create toplevel packing structure
        self.box = gtk.VBox(gtk.FALSE)
        self.box.set_border_width(5)

        # hbox and alignment used for monitor preview area
        # list of pixmaps for monitor preview
        self.monitor_pixmaps = None
        self.hbox = gtk.HBox(gtk.FALSE, 5)
        self.monitor_align = None
        self.desktop_align = None
        self.load_monitor_preview_pixmap("monitor.png")
        self.box.pack_start(self.hbox)

        hbox1 = gtk.HBox(gtk.FALSE, 5)
        hbox3 = gtk.HBox(gtk.FALSE, 5)
        hbox4 = gtk.HBox(gtk.FALSE, 5)

        frame1 = gtk.Frame(_("_Color Depth:"))
        frame1.get_label_widget().set_property("use-underline", gtk.TRUE)
        frame1.set_shadow_type(gtk.SHADOW_NONE)
        frame1.set_border_width(10)
        hbox1.pack_start(frame1, gtk.TRUE, gtk.FALSE, 0)

        # determine video modes available for this card/monitor combo
        self.avail_depth = self.xsetup.xhwstate.available_color_depths()

        self.depth_list = [(_("256 Colors (8 Bit)")),
                           (_("High Color (16 Bit)")),
                           (_("True Color (24 Bit)"))]
        self.bit_depth = [8, 16, 24]

        # create option menu for bit depth
        self.depth_optionmenu = gtk.OptionMenu()
        self.depth_menu = gtk.Menu()

        for i in range(0, len(self.depth_list)):
            if self.bit_depth[i] in self.avail_depth:
                d = self.depth_list[i]
                item = gtk.MenuItem(d)
                item.show()
                self.depth_menu.add(item)

        self.depth_optionmenu.set_menu(self.depth_menu)

        frame1.add(self.depth_optionmenu)
        frame1.get_label_widget().set_mnemonic_widget(self.depth_optionmenu)

        # now we do screen resolution
        frame2 = gtk.Frame(_("_Screen Resolution:"))
        frame2.get_label_widget().set_property("use-underline", gtk.TRUE)
        frame2.set_shadow_type(gtk.SHADOW_NONE)
        frame2.set_border_width(10)
        hbox1.pack_start(frame2, gtk.TRUE, gtk.FALSE, 2)

        self.avail_res = self.xsetup.xhwstate.available_resolutions()

        self.res_optionmenu = None
        self.res_menu = None
        self.create_res_optionmenu()

        frame2.add(self.res_optionmenu)
        frame2.get_label_widget().set_mnemonic_widget(self.res_optionmenu)

        # apply current configuration to UI
        self.selectedDepth = self.xsetup.xhwstate.get_colordepth()
        self.selectedRes = self.xsetup.xhwstate.get_resolution()

        if self.selectedDepth not in self.avail_depth:
            self.selectedDepth = self.avail_depth[-1]

        idx = self.avail_depth.index(self.selectedDepth)
        self.depth_optionmenu.set_history(idx)

        if self.selectedRes not in self.avail_res:
            self.selectedRes = self.avail_res[-1]

        self.currentRes = self.avail_res.index(self.selectedRes)
        self.res_optionmenu.set_history(self.currentRes)
        self.swap_monitor(self.currentRes)

        self.depth_optionmenu.connect("changed", self.depth_cb)
        self.ignore_res_cb = 0
        self.res_optionmenu.connect("changed", self.res_cb)

        self.box.pack_start(hbox1, gtk.FALSE)

        #--If both KDE and GNOME are selected
        if grpset:
            gnomeSelected = (grpset.hdrlist.has_key('gnome-session')
                             and grpset.hdrlist['gnome-session'].isSelected())
            kdeSelected = (grpset.hdrlist.has_key('kdebase')
                           and grpset.hdrlist['kdebase'].isSelected())
        else:
            gnomeSelected = 0
            kdeSelected = 0

        self.newDesktop = ""
        self.origDesktop = self.desktop.getDefaultDesktop()

        if (ENABLE_DESKTOP_CHOICE) and (gnomeSelected or kdeSelected):
            hsep = gtk.HSeparator()
            self.box.pack_start(hsep)

            if gnomeSelected and kdeSelected:
                frame3 = gtk.Frame(
                    _("Please choose your default desktop environment:"))
            else:
                frame3 = gtk.Frame(_("Your desktop environment is:"))

            frame3.set_shadow_type(gtk.SHADOW_NONE)
            hbox3.pack_start(frame3, gtk.TRUE, gtk.FALSE, 2)

            self.hbox4 = gtk.HBox()
            frame3.add(self.hbox4)

            # need to have this around so self.display_desktop_pixmap()
            # will work later. (messy)
            self.vbox4 = gtk.VBox()

            if gnomeSelected and kdeSelected:
                vbox3 = gtk.VBox()

                gnome_radio = gtk.RadioButton(None, (_("GNO_ME")))
                vbox3.pack_start(gnome_radio, gtk.TRUE, gtk.FALSE, 2)
                kde_radio = gtk.RadioButton(gnome_radio, (_("_KDE")))
                vbox3.pack_start(kde_radio, gtk.TRUE, gtk.FALSE, 2)

                self.hbox4.pack_start(vbox3)

                self.hbox4.pack_start(self.vbox4)

                #--Set the desktop GUI widget to what the user has selected
                if self.origDesktop == "GNOME":
                    gnome_radio.set_active(gtk.TRUE)
                    self.display_desktop_pixmap("GNOME")
                elif self.origDesktop == "KDE":
                    kde_radio.set_active(gtk.TRUE)
                    self.display_desktop_pixmap("KDE")

                gnome_radio.connect("clicked", self.desktop_cb, "GNOME")
                kde_radio.connect("clicked", self.desktop_cb, "KDE")
            else:
                self.hbox4.pack_start(gtk.Label(self.origDesktop))
                self.display_desktop_pixmap(self.origDesktop)

            self.box.pack_start(hbox3, gtk.FALSE, gtk.TRUE, 2)
        else:
            gnome_radio = None
            kde_radio = None

        hsep = gtk.HSeparator()
        self.box.pack_start(hsep)

        # see if we should allow them to choose graphical or text login
        if self.instClass.showLoginChoice:
            frame4 = gtk.Frame(_("Please choose your login type:"))
            frame4.set_shadow_type(gtk.SHADOW_NONE)
            hbox4.pack_start(frame4, gtk.TRUE, gtk.FALSE, 2)

            self.hbox5 = gtk.HBox(gtk.TRUE, 2)
            frame4.add(self.hbox5)

            self.text = gtk.RadioButton(None, (_("_Text")))
            self.graphical = gtk.RadioButton(self.text, (_("_Graphical")))

            self.runLevel = self.desktop.getDefaultRunLevel()

            if self.runLevel == 3:
                self.text.set_active(gtk.TRUE)
            elif self.runLevel == 5:
                self.graphical.set_active(gtk.TRUE)

            self.hbox5.pack_start(self.graphical, gtk.FALSE, 2)
            self.hbox5.pack_start(self.text, gtk.FALSE, 2)

            self.box.pack_start(hbox4, gtk.FALSE, gtk.TRUE, 2)

        return self.box
Example #19
0
class MonitorWindow(InstallWindow):
    windowTitle = N_("Monitor Configuration")
    htmlTag = ("monitor")

    def __init__(self, ics):
        InstallWindow.__init__(self, ics)
        self.ics.setNextEnabled(gtk.FALSE)
        self.ics.setPrevEnabled(gtk.TRUE)

    def getNext(self):
        if self.currentMonitor:
            monHoriz = string.replace(self.hEntry.get_text(), " ", "")
            monVert = string.replace(self.vEntry.get_text(), " ", "")

            if self.currentMonitor[:len(ddc_monitor_string
                                        )] == ddc_monitor_string:
                idname = "DDCPROBED"
                monname = self.currentMonitor[len(ddc_monitor_string) + 3:]
            elif self.currentMonitor == unprobed_monitor_string:
                idname = "Unprobed Monitor"
                monname = "Unprobed Monitor"
            else:
                idname = self.currentMonitor
                monname = self.currentMonitor

# warn user their monitor type is unprobed
            if idname == "Unprobed Monitor":
                rc = self.intf.messageWindow(
                    _("Monitor Unspecified"),
                    _("You have not selected a monitor type.  It is "
                      "recommended you choose the closest matching "
                      "model in order to have the highest possible "
                      "display quality."),
                    type="custom",
                    custom_buttons=[_("_Proceed"),
                                    _("_Choose monitor type")],
                    custom_icon="warning")
                if rc:
                    raise gui.StayOnScreen

# XXX - this is messed up - we set the monitor object in instdata
#       to the current values, then we have to push it into the
#       xhwstate as well.  Need to join this operation somehow.
            self.monitor.setSpecs(monHoriz, monVert, id=idname, name=monname)

            # shove into hw state object, force it to recompute available modes
            self.xsetup.xhwstate.monitor = self.monitor
            self.xsetup.xhwstate.set_monitor_name(self.currentMonitor)
            self.xsetup.xhwstate.set_hsync(monHoriz)
            self.xsetup.xhwstate.set_vsync(monVert)
            self.xsetup.xhwstate.recalc_mode()

        return None

    def setSyncField(self, field, value):
        self.ignoreEntryChanges = 1
        if value:
            field.set_text(value)
        else:
            field.set_text("")
        self.ignoreEntryChanges = 0

    def enableIfSyncsValid(self, entry, other):
        aval = entry.get_text()
        bval = other.get_text()
        if isValidSyncRange(aval) and isValidSyncRange(bval):
            self.ics.setNextEnabled(gtk.TRUE)
        else:
            self.ics.setNextEnabled(gtk.FALSE)

    def setCurrent(self, monitorname, recenter=1):
        self.ignoreEvents = 1
        self.currentMonitor = monitorname

        parent = None
        iter = self.monitorstore.get_iter_first()

        # iterate over the list, looking for the current monitor selection
        while iter:
            # if this is a parent node, get the first child and iter over them
            if self.monitorstore.iter_has_child(iter):
                parent = iter
                iter = self.monitorstore.iter_children(parent)
                continue
            # if it's not a parent node and the mouse matches, select it.
            elif self.monitorstore.get_value(iter, 0) == monitorname:
                path = self.monitorstore.get_path(parent)
                self.monitorview.expand_row(path, gtk.TRUE)
                selection = self.monitorview.get_selection()
                selection.unselect_all()
                selection.select_iter(iter)
                path = self.monitorstore.get_path(iter)
                col = self.monitorview.get_column(0)
                self.monitorview.set_cursor(path, col, gtk.FALSE)
                if recenter:
                    self.monitorview.scroll_to_cell(path, col, gtk.TRUE, 0.0,
                                                    0.5)
                break
            # get the next row.
            iter = self.monitorstore.iter_next(iter)

            # if there isn't a next row and we had a parent, go to the node
            # after the parent we've just gotten the children of.
            if not iter and parent:
                parent = self.monitorstore.iter_next(parent)
                iter = parent

        # set sync rates
        if monitorname == self.origMonitorName:
            hsync = self.origHsync
            vsync = self.origVsync
        elif monitorname[:len(ddc_monitor_string)] == ddc_monitor_string:
            hsync = self.ddcmon[2]
            vsync = self.ddcmon[3]
        elif monitorname == unprobed_monitor_string:
            hsync = "31.5"
            vsync = "50-61"


#	    hsync = self.ddcmon[2]
#	    vsync = self.ddcmon[3]
        else:
            monname = self.monitorstore.get_value(iter, 0)
            rc = self.monitor.lookupMonitorByName(monname)
            if rc:
                (model, eisa, vsync, hsync) = rc
            else:
                # no match for model ACK!
                print "Could not find match for monitor %s in list!" % monname
                print "How could this happen?"

                # use 640x480 to be safe
                hsync = "31.5"
                vsync = "50-61"

        self.setSyncField(self.hEntry, hsync)
        self.setSyncField(self.vEntry, vsync)
        self.enableIfSyncsValid(self.hEntry, self.vEntry)

        self.ignoreEvents = 0

    def selectMonitorType(self, selection, *args):
        if self.ignoreEvents:
            return

        (monxxx, iter) = selection.get_selected()
        if iter:
            monid = monxxx.get_value(iter, 0)

            self.setCurrent(monid, recenter=0)
        else:
            print "unknown error in selectMonitorType!"

    def monitorviewSelectCb(self, path):
        # XXX 01/09/2002 - work around broken gtkwidget, fix when jrb fixes
        if len(path) == 1:
            if self.lastvalidselection:
                self.ignoreEvents = 1
                selection = self.monitorview.get_selection()
                if not selection.path_is_selected(self.lastvalidselection):
                    selection.select_path(self.lastvalidselection)
                self.ignoreEvents = 0
            return 0

        self.lastvalidselection = path

        return 1

    def resetCb(self, data):
        # if we have a ddc probe value, reset to that
        if self.ddcmon:
            self.setCurrent(ddc_monitor_string + " - " + self.ddcmon[1])
        else:
            self.setCurrent(unprobed_monitor_string)

        self.setSyncField(self.hEntry, self.origHsync)
        self.setSyncField(self.vEntry, self.origVsync)

        self.enableIfSyncsValid(self.hEntry, self.vEntry)

        self.currentMonitor = self.origMonitorName

    def insertCb(self, pos, text, len, data, entrys):
        if self.ignoreEntryChanges:
            return

        (entry, other) = entrys
        list = [
            "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", " ", ".",
            ","
        ]
        if not (text[:1] in list):
            entry.emit_stop_by_name("insert-text")

        self.enableIfSyncsValid(entry, other)

    def changedCb(self, data, entrys):
        if self.ignoreEntryChanges:
            return

        (entry, other) = entrys
        self.enableIfSyncsValid(entry, other)

    def getScreen(self, xsetup, monitor, intf):

        self.intf = intf
        self.xsetup = xsetup
        self.monitor = monitor

        # some flags to let us know when to ignore callbacks we caused
        self.ignoreEntryChanges = 0
        self.ignoreEvents = 0

        self.lastvalidselection = None

        box = gtk.VBox(gtk.FALSE, 5)

        label = makeFormattedLabel(
            _("In most cases, the monitor can be "
              "automatically detected. If the "
              "detected settings are not correct "
              "for the monitor, select the right "
              "settings."))
        box.pack_start(label, gtk.FALSE)

        # Monitor selection tree
        self.monitorstore = gtk.TreeStore(gobject.TYPE_STRING,
                                          gobject.TYPE_STRING)
        self.hEntry = gtk.Entry()
        self.vEntry = gtk.Entry()

        fn = self.ics.findPixmap("monitor-small.png")
        p = gtk.gdk.pixbuf_new_from_file(fn)
        if p:
            self.monitor_p, self.monitor_b = p.render_pixmap_and_mask()

    # load monitor list and insert into tree
        self.origMonitorID = self.monitor.getMonitorID()
        self.origMonitorName = self.monitor.getMonitorName()
        if not self.origMonitorName:
            self.origMonitorName = self.origMonitorID

        self.origHsync = self.monitor.getMonitorHorizSync()
        self.origVsync = self.monitor.getMonitorVertSync()

        monitorslist = self.monitor.monitorsDB()
        keys = monitorslist.keys()
        keys.sort()

        # treat Generic monitors special
        idx = 0
        for man in ["Generic LCD Display", "Generic CRT Display", "Generic"]:
            if man in keys:
                keys.remove(man)
                keys.insert(idx, man)
                idx += 1

        self.currentMonitor = None
        toplevels = {}

        # Insert DDC probed monitor if it had no match in database
        # or otherwise if we did not detect a monitor at all
        #--Add a category for a DDC probed monitor if a DDC monitor was probed
        self.ddcmon = self.monitor.getDDCProbeResults()
        if self.ddcmon:
            title = ddc_monitor_string
            monentry = title + " - " + self.ddcmon[1]
        else:
            title = unprobed_monitor_string
            monentry = title

        man = title
        toplevels[man] = self.monitorstore.append(None)
        self.monitorstore.set_value(toplevels[man], 0, title)
        iter = self.monitorstore.append(toplevels[man])
        self.monitorstore.set_value(iter, 0, monentry)

        # set as current monitor if necessary
        if self.origMonitorID == "DDCPROBED" or self.origMonitorID == "Unprobed Monitor":
            self.currentMonitor = monentry
            self.origMonitorName = monentry

        # now insert rest of monitors, unless we match the ddc probed id
        for man in keys:
            models = monitorslist[man]
            if man in [
                    "Generic LCD Display", "Generic CRT Display", "Generic"
            ]:
                title = _(man)
        # dont sort generic, present in order in file
            else:
                title = man
                models.sort()

            toplevels[man] = self.monitorstore.append(None)
            self.monitorstore.set_value(toplevels[man], 0, man)

            previous_monitor = ""
            for amonitor in models:
                if previous_monitor != "":
                    if amonitor[0] == previous_monitor:
                        continue

                if self.ddcmon and string.upper(
                        self.ddcmon[0]) == string.upper(amonitor[1]):
                    continue

                previous_monitor = amonitor[0]
                iter = self.monitorstore.append(toplevels[man])
                self.monitorstore.set_value(iter, 0, amonitor[0])

                if amonitor[0] == self.monitor.getMonitorID():
                    self.currentMonitor = amonitor[0]

        self.monitorview = gtk.TreeView(self.monitorstore)
        self.monitorview.set_property("headers-visible", gtk.FALSE)
        col = gtk.TreeViewColumn(None, gtk.CellRendererText(), text=0)
        self.monitorview.append_column(col)

        sw = gtk.ScrolledWindow()
        sw.add(self.monitorview)
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)
        box.pack_start(sw, gtk.TRUE, gtk.TRUE)

        self.setCurrent(self.currentMonitor)
        selection = self.monitorview.get_selection()
        selection.connect("changed", self.selectMonitorType)
        selection.set_select_function(self.monitorviewSelectCb)

        self.hEntry.connect("insert_text", self.insertCb,
                            (self.hEntry, self.vEntry))
        self.vEntry.connect("insert_text", self.insertCb,
                            (self.vEntry, self.hEntry))

        self.hEntry.connect("changed", self.changedCb,
                            (self.hEntry, self.vEntry))
        self.vEntry.connect("changed", self.changedCb,
                            (self.vEntry, self.hEntry))

        self.reset = gtk.Button(_("Restore _original values"))
        self.reset.connect("clicked", self.resetCb)
        align = gtk.Alignment

        align = gtk.Alignment(1, 0.5)
        align.add(self.reset)

        synctable = gtk.Table(2, 4, gtk.FALSE)
        hlabel = gui.MnemonicLabel(_("Hori_zontal Sync:"))
        hlabel.set_alignment(0, 0.5)
        hlabel.set_mnemonic_widget(self.hEntry)
        vlabel = gui.MnemonicLabel(_("_Vertical Sync:"))
        vlabel.set_alignment(0, 0.5)
        vlabel.set_mnemonic_widget(self.vEntry)

        self.hEntry.set_size_request(80, -1)
        self.vEntry.set_size_request(80, -1)

        hz = gtk.Label(_("kHz"))
        hz.set_alignment(0, 0.5)

        khz = gtk.Label(_("Hz"))
        khz.set_alignment(0, 0.5)

        synctable.attach(hlabel, 0, 1, 0, 1, gtk.SHRINK, gtk.FILL, 5)
        synctable.attach(self.hEntry, 1, 2, 0, 1, gtk.SHRINK)
        synctable.attach(hz, 2, 3, 0, 1, gtk.FILL, gtk.FILL, 5)
        synctable.attach(vlabel, 0, 1, 1, 2, gtk.SHRINK, gtk.FILL, 5)
        synctable.attach(self.vEntry, 1, 2, 1, 2, gtk.SHRINK)
        synctable.attach(khz, 2, 3, 1, 2, gtk.FILL, gtk.FILL, 5)
        synctable.attach(align, 3, 4, 1, 2)

        box.pack_start(synctable, gtk.FALSE, gtk.FALSE)

        setupTreeViewFixupIdleHandler(self.monitorview, self.monitorstore)

        return box
Example #20
0
 def __init__ (self, ics):
     InstallWindow.__init__ (self, ics)
     self.ics.setTitle ("z/IPL")
     self.ics.windowTitle = N_("z/IPL Boot Loader Configuration")
Example #21
0
class WelcomeWindow(InstallWindow):

    windowTitle = N_("Welcome to Rocks")

    def displayBrowser(self):

        url = 'http://127.0.0.1'
        url += '/tmp/updates/opt/rocks/screens/getrolls.html'

        os.system('/opt/rocks/firerox/firefox ' + url +
                  ' > /tmp/firerox.debug 2>&1')

        return

    def displayXterm(self):
        #
        # bring up and xterm that we can use for debugging
        #
        os.system('/tmp/updates/usr/bin/xterm ' + '> /tmp/xterm.debug 2>&1')
        return

    def regenerateKickstartFile(self):
        import rocks.util

        nativearch = rocks.util.getNativeArch()

        cmd = '/opt/rocks/bin/rocks report distro'
        for line in os.popen(cmd).readlines():
            distrodir = line[:-1]

        os.chdir('%s/rocks-dist/%s/build' % (distrodir, nativearch))

        #
        # root of the tree
        #
        file = open('/proc/cmdline', 'r')
        args = string.split(file.readline())
        file.close()

        rootnode = 'root'
        if 'build' in args:
            for arg in args:
                a = arg.split('=')
                if len(a) > 1 and a[0] == 'appliance':
                    rootnode = a[1]
                    break

        os.environ['PYTHONPATH'] = ''

        cmd = '/opt/rocks/bin/rocks list node xml %s ' % (rootnode)
        cmd += 'attrs="/tmp/site.attrs" 2> /dev/null'
        cmd += '| /opt/rocks/bin/rocks list host profile '
        cmd += '| /opt/rocks/bin/rocks list host installfile '
        cmd += 'section=kickstart > '
        cmd += '/tmp/ks.cfg 2> /tmp/ks.cfg.debug'
        os.system(cmd)

        return

    def restartAnaconda(self):
        os.system('killall mini-wm')
        os.system('killall Xorg')
        sys.exit(0)

    def lightsOut(self):
        import rocks.installcgi
        import rocks.roll

        installcgi = rocks.installcgi.InstallCGI()
        generator = rocks.roll.Generator()

        generator.parse('/tmp/rolls.xml')
        rollList = generator.rolls

        os.environ['PYTHONPATH'] = '/tmp/updates/usr/share/createrepo'
        for roll in rollList:
            installcgi.getKickstartFiles(roll)

        installcgi.rebuildDistro(rollList)

        return

    def __init__(self, ics):
        InstallWindow.__init__(self, ics)
        ics.setGrabNext(1)

        if not os.path.exists('/tmp/site.attrs'):
            #
            # run the browser to select the rolls and
            # to build the /tmp/site.attrs file
            #
            self.displayBrowser()
        elif os.path.exists('/tmp/rolls.xml'):
            #
            # if /tmp/site.attrs exists and if /tmp/rolls.xml
            # exists, then this is a 'lights out'
            # install -- go get the roll-*-kickstart files
            #
            self.lightsOut()

        file = open('/proc/cmdline', 'r')
        args = string.split(file.readline())
        file.close()
        for arg in args:
            if arg.count('xterm'):
                self.displayXterm()

        #
        # this will ensure that this screen is *not* called
        # again when anaconda is restarted
        #
        os.system('touch /tmp/rocks-skip-welcome')

        self.regenerateKickstartFile()

        #
        # after rebuilding the kickstart file, stop this
        # version of anaconda and let the anaconda script
        # in ekv restart it.
        #
        self.restartAnaconda()

        return

    def getScreen(self, configFileData):
        import gtk

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_NONE)

        image = configFileData["WelcomeScreen"]
        pix = self.ics.readPixmapDithered(image)

        if pix:
            box = gtk.EventBox()
            box.add(pix)
            frame.add(box)

        return frame
Example #22
0
class MainBootloaderWindow(InstallWindow):
    windowTitle = N_("Boot Loader Configuration")
    htmlTag = "bootloader"

    def __init__(self, ics):
        InstallWindow.__init__(self, ics)
        self.parent = ics.getICW().window

    def getPrev(self):
        pass

    def getNext(self):
        # go ahead and set the device even if we already knew it
        # since that won't change anything
        self.bl.setDevice(self.bldev)

        if self.blname is None:
            # if we're not installing a boot loader, don't show the second
            # screen and don't worry about other options
            self.dispatch.skipStep("instbootloader", skip=1)
            self.dispatch.skipStep("bootloaderadvanced", skip=1)

            # kind of a hack...
            self.bl.defaultDevice = None
            return
        else:
            self.dispatch.skipStep("instbootloader", skip=0)
            if self.blname == "GRUB":
                self.bl.setUseGrub(1)
            else:
                self.bl.setUseGrub(0)

        # set the password
        self.bl.setPassword(self.blpass.getPassword(), isCrypted=0)

        # set the bootloader images based on what's in our list
        self.oslist.setBootloaderImages()

        if self.advanced.get_active():
            self.dispatch.skipStep("bootloaderadvanced", skip=0)
        else:
            self.dispatch.skipStep("bootloaderadvanced", skip=1)

    def changeBootloaderCallback(self, *args):
        dialog = gtk.Dialog(_("Change Boot Loader"), self.parent)
        dialog.add_button('gtk-cancel', 2)
        dialog.add_button('gtk-ok', 1)
        dialog.set_position(gtk.WIN_POS_CENTER)
        gui.addFrame(dialog)
        radio_vbox = self.setupChooseBootloaderRadioBox()

        dialog.vbox.pack_start(radio_vbox)
        dialog.show_all()

        blname = self.blname
        while 1:
            rc = dialog.run()
            if rc == 2:
                break

            if self.none_radio.get_active() == gtk.TRUE:
                newrc = self.intf.messageWindow(_("Warning"),
                                                _("You have selected not to "
                                                  "install a boot loader on "
                                                  "your system.  You will "
                                                  "have to create a boot "
                                                  "disk to boot your system "
                                                  "with this option.\n\n"
                                                  "Would you like to "
                                                  "continue and not install "
                                                  "a boot loader?"),
                                                type="custom",
                                                custom_buttons=[
                                                    _("Cancel"),
                                                    _("C_ontinue with no boot "
                                                      "loader")
                                                ])
                if newrc != 1:
                    continue
                blname = None
            elif ((self.lilo_radio is not None)
                  and (self.lilo_radio.get_active() == gtk.TRUE)):
                blname = "LILO"
            else:
                blname = "GRUB"
            break

        dialog.destroy()

        if rc != 2:
            self.blname = blname
        self.updateBootLoaderLabel()
        if blname is not None:
            self.oslist.changeBootLoader(blname)
        return rc

    def setupChooseBootloaderRadioBox(self):
        radio_vbox = gtk.VBox(gtk.FALSE, 2)
        radio_vbox.set_border_width(5)

        label = gui.WrappingLabel(
            _("Please select the boot loader that "
              "the computer will use.  GRUB is the "
              "default boot loader. However, if you "
              "do not wish to overwrite your current "
              "boot loader, select \"Do not install "
              "a boot loader.\"  "))
        label.set_alignment(0.0, 0.0)

        self.grub_radio = gtk.RadioButton(None, (_("Use _GRUB as the "
                                                   "boot loader")))
        if bootloader.showLilo:
            self.lilo_radio = gtk.RadioButton(self.grub_radio,
                                              (_("Use _LILO as the boot "
                                                 "loader")))
        else:
            self.lilo_radio = None
        self.none_radio = gtk.RadioButton(self.grub_radio, (_("_Do not "
                                                              "install a "
                                                              "boot loader")))

        radio_vbox.pack_start(label, gtk.FALSE)
        radio_vbox.pack_start(self.grub_radio, gtk.FALSE)
        if self.lilo_radio:
            radio_vbox.pack_start(self.lilo_radio, gtk.FALSE)
        radio_vbox.pack_start(self.none_radio, gtk.FALSE)

        if self.blname is None:
            self.none_radio.set_active(gtk.TRUE)
        elif self.lilo_radio is not None and self.blname == "LILO" and iutil.getArch(
        ) == "i386":
            self.lilo_radio.set_active(gtk.TRUE)
        else:
            self.grub_radio.set_active(gtk.TRUE)

        return radio_vbox

    def updateBootLoaderLabel(self):
        if self.blname is not None:
            self.bllabel.set_text(
                _("The %s boot loader will be "
                  "installed on /dev/%s.") % (self.blname, self.bldev))
            active = gtk.TRUE
        else:
            self.bllabel.set_text(_("No boot loader will be installed."))
            active = gtk.FALSE

        for widget in [
                self.oslist.getWidget(),
                self.blpass.getWidget(), self.advanced
        ]:
            widget.set_sensitive(active)

    def getScreen(self, dispatch, bl, fsset, diskSet):
        self.dispatch = dispatch
        self.bl = bl
        self.intf = dispatch.intf

        if self.bl.getPassword():
            self.usePass = 1
            self.password = self.bl.getPassword()
        else:
            self.usePass = 0
            self.password = None

        thebox = gtk.VBox(gtk.FALSE, 10)
        spacer = gtk.Label("")
        spacer.set_size_request(10, 1)
        thebox.pack_start(spacer, gtk.FALSE)

        if self.bl.useGrub():
            self.blname = "GRUB"
        else:
            self.blname = "LILO"
        # XXX this is kind of ugly
        if self.dispatch.stepInSkipList("instbootloader"):
            self.blname = None

        # make sure we get a valid device to say we're installing to
        if bl.getDevice() is not None:
            self.bldev = bl.getDevice()
        else:
            # we don't know what it is yet... if mbr is possible, we want
            # it, else we want the boot dev
            choices = fsset.bootloaderChoices(diskSet, self.bl)
            if choices.has_key('mbr'):
                self.bldev = choices['mbr'][0]
            else:
                self.bldev = choices['boot'][0]

        self.bllabel = gui.WrappingLabel("")

        self.bllabel.set_alignment(0.0, 0.5)

        hbox = gtk.HBox(gtk.FALSE, 10)
        hbox.pack_start(self.bllabel, gtk.FALSE)

        button = gtk.Button(_("_Change boot loader"))
        hbox.pack_start(button, gtk.FALSE)
        button.connect("clicked", self.changeBootloaderCallback)

        alignment = gtk.Alignment()
        alignment.set(0.1, 0, 0, 0)
        alignment.add(hbox)

        thebox.pack_start(alignment, gtk.FALSE)

        spacer = gtk.Label("")
        spacer.set_size_request(10, 1)
        thebox.pack_start(spacer, gtk.FALSE)

        # configure the systems available to boot from the boot loader
        self.oslist = OSBootWidget(bl, fsset, diskSet, self.parent, self.intf,
                                   self.blname)
        thebox.pack_start(self.oslist.getWidget(), gtk.FALSE)

        thebox.pack_start(gtk.HSeparator(), gtk.FALSE)

        # control whether or not there's a boot loader password and what it is
        self.blpass = BootloaderPasswordWidget(bl, self.parent, self.intf)
        thebox.pack_start(self.blpass.getWidget(), gtk.FALSE)

        thebox.pack_start(gtk.HSeparator(), gtk.FALSE)

        # check box to control showing the advanced screen
        self.advanced = gtk.CheckButton(
            _("Configure advanced boot loader "
              "_options"))
        if dispatch.stepInSkipList("bootloaderadvanced"):
            self.advanced.set_active(gtk.FALSE)
        else:
            self.advanced.set_active(gtk.TRUE)

        thebox.pack_start(self.advanced, gtk.FALSE)

        # finally, update the label and activate widgets appropriately
        self.updateBootLoaderLabel()

        return thebox
Example #23
0
class IndividualPackageSelectionWindow (InstallWindow):

    windowTitle = N_("Individual Package Selection")
    htmlTag = "sel-indiv"

    def build_packagelists(self, groups):
        toplevels = {}
        self.packageGroupStore = gtk.TreeStore(gobject.TYPE_STRING,
                                               gobject.TYPE_STRING)

        keys = groups.keys()
        keys.sort()

        # allpkgs is the special toplevel group
        keys.remove("allpkgs")
        allpkg = self.packageGroupStore.append(None)
        self.packageGroupStore.set_value(allpkg, 0, _("All Packages"))
        self.packageGroupStore.set_value(allpkg, 1, "allpkgs")

        # go through and make parent nodes for all of the groups
        for key in keys:
            fields = string.split(key, '/')
            main = fields[0]
            if len(fields) > 1:
                subgroup = fields[1]
            
            if toplevels.has_key(main):
                continue

            iter = self.packageGroupStore.append(allpkg)
            self.packageGroupStore.set_value(iter, 0, main)
            self.packageGroupStore.set_value(iter, 1, main)
            toplevels[main] = iter

        # now make the children
        for key in keys:
            fields = string.split(key, '/')
            main = fields[0]
            if len(fields) > 1:
                subgroup = fields[1]
            else:
                continue
            
            if not toplevels.has_key(main):
                raise RuntimeError, "Got unexpected key building tree"

            parent = toplevels[main]
            iter = self.packageGroupStore.append(parent)
            self.packageGroupStore.set_value(iter, 0, subgroup)
            self.packageGroupStore.set_value(iter, 1,
                                             "%s/%s" % (main, subgroup))


    def add_packages(self, packages):
        """Adds the packages provided (list of headers) to the package
           list"""
        SHOW_WATCH_MIN = 200
        if len(packages) > SHOW_WATCH_MIN:
            cw = self.ics.getICW()
            cw.busyCursorPush()
        
        for header in packages:
            name = header[rpm.RPMTAG_NAME]
            size = header[rpm.RPMTAG_SIZE]

            # get size in MB
            size = size / (1024 * 1024)

            # don't show as < 1 MB
            if size < 1:
                size = 1
                    
            self.packageList.append_row((name, size), header.isSelected())
        

	### XXX Hack to get around fact treeview doesn't seem to resort
	###     when data is store is changed. By jostling it we can make it
	self.packageList.store.set_sort_column_id(self.sort_id, not self.sort_order)
	self.packageList.store.set_sort_column_id(self.sort_id, self.sort_order)
        if len(packages) > SHOW_WATCH_MIN:
            cw.busyCursorPop()

    def select_group(self, selection):
        (model, iter) = selection.get_selected()
        if iter:
            currentGroup = model.get_value(iter, 1)

            self.packageList.clear()

            if not self.flat_groups.has_key(currentGroup):
                self.selectAllButton.set_sensitive(gtk.FALSE)
                self.unselectAllButton.set_sensitive(gtk.FALSE)
                return

            self.selectAllButton.set_sensitive(gtk.TRUE)
            self.unselectAllButton.set_sensitive(gtk.TRUE)
            
            packages = self.flat_groups[currentGroup]
            self.add_packages(packages)
            

    def toggled_package(self, data, row):
        row = int(row)
        package = self.packageList.get_text(row, 1)

        if not self.pkgs.has_key(package):
            raise RuntimeError, "Toggled a non-existent package %s" % (package)

        val = self.packageList.get_active(row)
        if val:
            self.pkgs[package].select()
        else:
            self.pkgs[package].unselect()

        self.updateSize()

	# if they hit space bar stop that event from happening
	self.ignoreKeypress = (package, val)
	

    def select_package(self, selection):
        (model, iter) = selection.get_selected()
        if iter:
            package = model.get_value(iter, 1)

            if not self.pkgs.has_key(package):
                raise RuntimeError, "Selected a non-existent package %s" % (package)

            buffer = self.packageDesc.get_buffer()
            description = self.get_rpm_desc(self.pkgs[package])
	    try:
		version = self.pkgs[package][rpm.RPMTAG_VERSION]
	    except:
		version = None

	    if version:
		outtext = _("Package: %s\nVersion: %s\n") % (package, version ) + description
	    else:
		outtext =description
		
            buffer.set_text(outtext)
        else:
            buffer = self.packageDesc.get_buffer()
            buffer.set_text("")
        

    def get_rpm_desc (self, header):
        desc = replace (header[rpm.RPMTAG_DESCRIPTION], "\n\n", "\x00")
        desc = replace (desc, "\n", " ")
        desc = replace (desc, "\x00", "\n\n")
        return desc

    def make_group_list(self, grpset, displayBase = 0):
        """Go through all of the headers and get group names, placing
           packages in the dictionary.  Also have in the upper level group"""
        
        groups = {}

        # special group for listing all of the packages (aka old flat view)
        groups["allpkgs"] = []
        
        for key in grpset.hdrlist.pkgs.keys():
            header = grpset.hdrlist.pkgs[key]

            group = header[rpm.RPMTAG_GROUP]
	    hier = string.split(group, '/')
            toplevel = hier[0]

            # make sure the dictionary item exists for group and toplevel
            # note that if group already exists, toplevel must also exist
            if not groups.has_key (group):
                groups[group] = []

                if not groups.has_key(toplevel):
                    groups[toplevel] = []

            # don't display package if it is in the Base group
            if not grpset.groups["core"].includesPackage(header) or displayBase:
                groups[group].append(header)
		if len(hier) > 1:
		    groups[toplevel].append(header)
                groups["allpkgs"].append(header)

        return groups
        

    def select_all (self, rownum, select_all):
        for row in range(self.packageList.num_rows):
            package = self.packageList.get_text(row, 1)
            if not self.pkgs.has_key(package):
                raise RuntimeError, "Attempt to toggle non-existent package"

            if select_all:
                self.pkgs[package].select()
            else:
                self.pkgs[package].unselect()
            self.packageList.set_active(row, select_all)

        self.updateSize()


    def updateSize(self):
        text = _("Total install size: %s") % (self.grpset.sizeStr(),)
        self.totalSizeLabel.set_text(text)


    # FIXME -- if this is kept instead of the All Packages in the tree
    # it needs to properly handle keeping the tree expanded to the same
    # state as opposed to having it default back to collapsed and no
    # selection; I personally like the All Packages in the tree better
    # but that seems to look weird with gtk 1.3.11
    def changePkgView(self, widget):
        if self.treeRadio.get_active():
            packages = []

            self.packageTreeView.set_model(self.packageGroupStore)
            self.packageTreeView.expand_all()            
        else:
            # cache the full package list
            if not self.allPkgs:
                self.allPkgs = []
                for pkg in self.pkgs.values():
                    if not self.grpset.groups["core"].includesPackage(pkg):
                        self.allPkgs.append(pkg)
            packages = self.allPkgs
            self.packageTreeView.set_model(gtk.ListStore(gobject.TYPE_STRING))


        self.packageList.clear()
        self.add_packages(packages)

    ### XXX Hack to get around fact treeview doesn't seem to resort
    ###     Have to keep up with sort state when user changes it
    def colClickedCB(self, widget, val):
	self.sort_id = widget.get_sort_column_id()
	self.sort_order = widget.get_sort_order()

    def keypressCB(self, widget, val):
	if val.keyval == gtk.keysyms.space:
	    selection = self.packageList.get_selection()
	    (model, iter) = selection.get_selected()
	    if iter:
		self.select_package(selection)
		package = self.packageList.store.get_value(iter, 1)
		val = self.packageList.store.get_value(iter, 0)

		# see if we just got this because of focus being on
		# checkbox toggle and they hit space bar
		if self.ignoreKeypress:
		    if (package, val) == self.ignoreKeypress:
			self.ignoreKeypress = None
			return gtk.TRUE
		    else:
			# didnt match for some reason, lets plow ahead
			self.ignoreKeypress = None
		
		self.packageList.store.set_value(iter, 0, not val)

		if not val:
		    self.pkgs[package].select()
		else:
		    self.pkgs[package].unselect()

		self.updateSize()
                return gtk.TRUE

	return gtk.FALSE
	    
		
    # IndividualPackageSelectionWindow tag="sel-indiv"
    def getScreen (self, grpset):
        self.grpset = grpset
        self.pkgs = self.grpset.hdrlist
        self.allPkgs = None
        
        self.packageTreeView = gtk.TreeView()

        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn('Groups', renderer, text=0)
        column.set_clickable(gtk.TRUE)
        self.packageTreeView.append_column(column)
        self.packageTreeView.set_headers_visible(gtk.FALSE)
        self.packageTreeView.set_rules_hint(gtk.FALSE)
        self.packageTreeView.set_enable_search(gtk.FALSE)
        
        self.flat_groups = self.make_group_list(grpset)
        self.build_packagelists(self.flat_groups)

        selection = self.packageTreeView.get_selection()
        selection.connect("changed", self.select_group)

        self.packageTreeView.set_model(self.packageGroupStore)
        self.packageTreeView.expand_all()
        
        self.sw = gtk.ScrolledWindow ()
        self.sw.set_policy (gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.sw.set_shadow_type(gtk.SHADOW_IN)
        self.sw.add(self.packageTreeView)
        
        packageHBox = gtk.HBox()

        self.leftVBox = gtk.VBox(gtk.FALSE)

        # FIXME should these stay or go?
        # tree/flat radio buttons... 
        optionHBox = gtk.HBox()
        self.treeRadio = gtk.RadioButton(None, (_("_Tree View")))
        self.treeRadio.connect("clicked", self.changePkgView)
        self.flatRadio = gtk.RadioButton(self.treeRadio, (_("_Flat View")))
        optionHBox.pack_start(self.treeRadio)
        optionHBox.pack_start(self.flatRadio)
        self.leftVBox.pack_start(optionHBox, gtk.FALSE)
        
        self.leftVBox.pack_start(self.sw, gtk.TRUE)
        packageHBox.pack_start(self.leftVBox, gtk.FALSE)

        self.packageList = PackageCheckList(2)
        self.packageList.checkboxrenderer.connect("toggled",
						  self.toggled_package)

        self.packageList.set_enable_search(gtk.TRUE)

        self.sortType = "Package"
        self.packageList.set_column_title (1, (_("_Package")))
        self.packageList.set_column_sizing (1, gtk.TREE_VIEW_COLUMN_GROW_ONLY)
        self.packageList.set_column_title (2, (_("_Size (MB)")))
        self.packageList.set_column_sizing (2, gtk.TREE_VIEW_COLUMN_GROW_ONLY)
        self.packageList.set_headers_visible(gtk.TRUE)

        self.packageList.set_column_min_width(0, 16)
        self.packageList.set_column_clickable(0, gtk.FALSE)
        
        self.packageList.set_column_clickable(1, gtk.TRUE)
        self.packageList.set_column_sort_id(1, 1)
        self.packageList.set_column_clickable(2, gtk.TRUE)
        self.packageList.set_column_sort_id(2, 2)

	sort_id = 1
	sort_order = 0
	self.packageList.store.set_sort_column_id(sort_id, sort_order)

	### XXX Hack to keep up with state of sorting
	###     Remove when treeview is fixed
	self.sort_id = sort_id
	self.sort_order = sort_order
	col = self.packageList.get_column(1)
	col.connect("clicked", self.colClickedCB, None)
	col = self.packageList.get_column(2)
	col.connect("clicked", self.colClickedCB, None)

        selection = self.packageList.get_selection()
        selection.connect("changed", self.select_package)

	self.packageList.connect("key-release-event", self.keypressCB)
	self.ignoreKeypress = None

        self.packageListSW = gtk.ScrolledWindow ()
        self.packageListSW.set_border_width (5)
        self.packageListSW.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.packageListSW.set_shadow_type(gtk.SHADOW_IN)
        self.packageListSW.add(self.packageList)

        self.packageListVAdj = self.packageListSW.get_vadjustment ()
        self.packageListSW.set_vadjustment(self.packageListVAdj)
        self.packageListHAdj = self.packageListSW.get_hadjustment () 
        self.packageListSW.set_hadjustment(self.packageListHAdj)

        packageHBox.pack_start (self.packageListSW)

        descVBox = gtk.VBox ()        
        descVBox.pack_start (gtk.HSeparator (), gtk.FALSE, padding=2)

        hbox = gtk.HBox ()
        bb = gtk.HButtonBox ()
        bb.set_layout (gtk.BUTTONBOX_END)

        self.totalSizeLabel = gtk.Label (_("Total size: "))
        hbox.pack_start (self.totalSizeLabel, gtk.FALSE, gtk.FALSE, 0)

        self.selectAllButton = gtk.Button (_("Select _all in group"))
        bb.pack_start (self.selectAllButton, gtk.FALSE)
        self.selectAllButton.connect ('clicked', self.select_all, 1)

        self.unselectAllButton = gtk.Button(_("_Unselect all in group"))
        bb.pack_start(self.unselectAllButton, gtk.FALSE)
        self.unselectAllButton.connect ('clicked', self.select_all, 0)
        
        hbox.pack_start (bb)

        self.selectAllButton.set_sensitive (gtk.FALSE)
        self.unselectAllButton.set_sensitive (gtk.FALSE)

        descVBox.pack_start (hbox, gtk.FALSE)

        descSW = gtk.ScrolledWindow ()
        descSW.set_border_width (5)
        descSW.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        descSW.set_shadow_type(gtk.SHADOW_IN)

        self.packageDesc = gtk.TextView()

        buffer = gtk.TextBuffer(None)
        self.packageDesc.set_buffer(buffer)
        self.packageDesc.set_editable(gtk.FALSE)
        self.packageDesc.set_cursor_visible(gtk.FALSE)
        self.packageDesc.set_wrap_mode(gtk.WRAP_WORD)
        descSW.add (self.packageDesc)
        descSW.set_size_request (-1, 100)

        descVBox.pack_start (descSW)

        vbox = gtk.VBox ()
        vbox.pack_start (packageHBox)
        vbox.pack_start (descVBox, gtk.FALSE)

	self.updateSize()

        return vbox
Example #24
0
class PackageSelectionWindow (InstallWindow):
    windowTitle = N_("Package Group Selection")
    htmlTag = "sel-group"

    def __init__ (self, ics):
	InstallWindow.__init__ (self, ics)
        self.ics = ics
        self.ics.setNextEnabled (1)
        self.files_found = "gtk.FALSE"
        
    def getPrev (self):
	self.grpset.setSelectionState(self.origSelection)

    def getNext (self):
	if self.individualPackages.get_active():
	    self.dispatch.skipStep("indivpackage", skip = 0)
	else:
	    self.dispatch.skipStep("indivpackage")

	# jsut to be sure if we come back
	self.savedStateDict = {}
	self.savedStateFlag = 0

        return None

    def setSize(self):
        self.sizelabel.set_text (_("Total install size: %s") % 
					self.grpset.sizeStr())

    # given a value, set all components except Everything and Base to
    # that value.  Handles restoring state if it exists
    def setComponentsSensitive(self, comp, value):
	tmpval = self.ignoreComponentToggleEvents
	self.ignoreComponentToggleEvents = 1
	for (cb, lbl, al, ebutton, cbox, cbox2, cbcomp) in self.checkButtons:
	    if cbcomp.id == comp.id:
		continue

	    if value:
		if cbcomp.id not in ["everything", "base"]:
#		    print "restoring checkbutton for ",cbcomp.name," at state ",self.savedStateDict[cbcomp.name]
		    if self.savedStateFlag and self.savedStateDict[cbcomp.id]:
			cb.set_active(1)
		    else:
			cb.set_active(0)
		else:
		    cb.set_active(0)
	    else:
		cb.set_active(0)

	    if cb.get_active():
		if ebutton:
		    al.add(ebutton)
		    al.show_all()
	    else:
		if ebutton:
		    if ebutton in al.get_children():
			al.remove(ebutton)

	    if lbl:
		self.setCompCountLabel(cbcomp, lbl)
	    if cbox:
		cbox.set_sensitive(value)
	    if cbox2:
		cbox2.set_sensitive(value)

	self.ignoreComponentToggleEvents = tmpval

    def componentToggled(self, widget, data):
        cw = self.ics.getICW()
	(comp, lbl, count, al, ebutton) = data
	newstate = widget.get_active()
	if self.ignoreComponentToggleEvents:
	    return

        cw.busyCursorPush()
        # turn on all the comps we selected
	if newstate:
            if ebutton:
                al.add(ebutton)
                al.show_all()
	    comp.select ()
	else:
            if ebutton in al.get_children():
                al.remove(ebutton)

	    # dont turn off Base, and if we're turning off everything
	    # we need to be sure language support stuff is on
	    if comp.id != "base":
		comp.unselect ()
		if comp.id == "everything":
		    packages.selectLanguageSupportGroups(self.grpset, self.langSupport)

        if count:
            self.setCompCountLabel(comp, count)

        if comp.id == "everything" or comp.id == "base":
	    
	    self.ignoreComponentToggleEvents = 1
	    # save state of buttons if they hit everything or minimal
#	    print "entered, savedstateflag = ",self.savedStateFlag
	    if not self.savedStateFlag and newstate:
		self.savedStateDict = {}
		self.savedStateFlag = 1
		savestate = 1
	    else:
		savestate = 0

	    for c in self.grpset.groups.values():
		if c.id in ["everything", "base"]:
		    continue
		
		if newstate:
			sel = c.isSelected(justManual = 1)
#			print "saving ",c.name," at state ",sel
			if savestate:
			    self.savedStateDict[c.id] = sel
			if sel:
			    c.unselect()
		else:
#		    print "restoring ",c.name," at state ",self.savedStateDict[c.name]
		    if self.savedStateFlag and self.savedStateDict[c.id]:
			c.select()

	    # turn on lang support if we're minimal and enabling
	    if comp.id == "base" and newstate:
		packages.selectLanguageSupportGroups(self.grpset, self.langSupport)

	    self.setComponentsSensitive(comp, not newstate)

	    self.ignoreComponentToggleEvents = 0
	else:
	    self.savedStateDict = {}
	    self.savedStateFlag = 0

	# after all this we need to recompute total size
	self.setSize()
        cw.busyCursorPop()

    def pkgGroupMemberToggled(self, widget, data):
	(comp, sizeLabel, pkg) = data
	(ptype, sel) = comp.packageInfo()[pkg]

	# dont select or unselect if its already in that state
	if widget.get_active():
            if sel not in ON_STATES:
                comp.selectPackage(pkg)
	    else:
		log("%s already selected, not selecting!" %(pkg,))
	else:
            if sel in ON_STATES:
                comp.unselectPackage(pkg)
	    else:
		log("%s already unselected, not unselecting!" %(pkg,))

	if sizeLabel:
	    self.setDetailSizeLabel(comp, sizeLabel)

    # have to do magic to handle 'Minimal'
    def setCheckButtonState(self, cb, comp):
	state = 0
	if comp.id != "base":
	    state = comp.isSelected(justManual = 1)	    
	    cb.set_active (state)
	else:
	    state = 1
	    for c in self.grpset.groups.values():
		# ignore base and langsupport files pulled in by 'minimal'
		if c.id == "base" or self.grpset.groups[c.id].langonly is not None:
		    continue
		
		if c.isSelected(justManual = 1):
		    state = 0
		    break

	    cb.set_active (state)

	return state
	
    def getStats(self, comp):
        # FIXME: metapkgs
#	allpkgs = comp.packageInfo().keys() + comp.metapackagesFullInfo().keys()
	allpkgs = comp.packageInfo()
	
	if comp.id == "everything":
	    total = len(allpkgs.keys())
	    if comp.isSelected(justManual = 1):
		selected = total
	    else:
		selected = 0
	    return (selected, total)
	
	total = 0
	selected = 0
	for pkg in allpkgs.values():
	    total = total + 1
	    (ptype, sel) = pkg
            if sel in ON_STATES:
		selected = selected + 1

        return (selected, total)

    def setDetailSizeLabel(self, comp, sizeLabel):
        text = _("Total install size: %s") % (self.grpset.sizeStr(),)
	sizeLabel.set_text(text)

    def setCompLabel(self, comp, label):
        if comp.id == "base":
	    nm = _("Minimal")
	else:
	    nm = comp.name
	label.set_markup("<b>%s</b>" % (nm,))

    def setCompCountLabel(self, comp, label):
	(selpkg, totpkg) = self.getStats(comp)
        if not comp.isSelected(justManual = 1):
            selpkg = 0

	if comp.id == "everything" or comp.id == "base":
	    txt = ""
	else:
	    txt = "<b>[%d/%d]</b>" % (selpkg, totpkg)
	    
	label.set_markup(txt)

    def editDetails(self, button, data):
	# do all magic for packages and metapackages
	def getDescription(obj, comp):
            if self.grpset.hdrlist.pkgs.has_key(obj):
                obj = self.grpset.hdrlist.pkgs[obj]
            elif self.grpset.groups.has_key(obj):
                obj = self.grpset.groups[obj]
            basedesc = obj.getDescription()

	    if basedesc is not None:
		desc = replace (basedesc, "\n\n", "\x00")
		desc = replace (desc, "\n", " ")
		desc = replace (desc, "\x00", "\n\n")
	    else:
		desc = ""
	    return "%s - %s" % (obj.name, desc)

	# pull out member sorted by name
	def getNextMember(goodpkgs, comp, domandatory = 0):
	    curpkg = None
	    for pkg in goodpkgs:
		if domandatory:
		    (ptype, sel) = comp.packageInfo()[pkg]
		    if ptype != PKGTYPE_MANDATORY:
			continue

		foundone = 1
		if curpkg is not None:
		    if pkg < curpkg:
			curpkg = pkg
		else:
		    curpkg = pkg

	    return curpkg


	#
	# START OF editDetails
	#
	# backup state
	(comp, hdrlbl, countlbl, compcb) = data
	origpkgselection = {}
	for (pkg, val) in comp.packageInfo().items():
	    origpkgselection[pkg] = val
	    
        self.dialog = gtk.Dialog(_("Details for '%s'") % (comp.name,))
        gui.addFrame(self.dialog)
        self.dialog.add_button('gtk-cancel', 2)
        self.dialog.add_button('gtk-ok', 1)
        self.dialog.set_position(gtk.WIN_POS_CENTER)

        mainvbox = self.dialog.vbox

	lblhbox = gtk.HBox(gtk.FALSE)
        lbl = gtk.Label(_("A package group can have both Base and "
                          "Optional package members.  Base packages "
                          "are always selected as long as the package group "
			  "is selected.\n\nSelect the optional packages "
			  "to be installed:"))
        lbl.set_line_wrap(gtk.TRUE)
	lbl.set_size_request(475, -1)
	lbl.set_alignment(0.0, 0.5)
	lblhbox.pack_start(lbl, gtk.TRUE, gtk.TRUE)

	fn = self.ics.findPixmap("package-selection.png")
	if not fn:
	    pix = None
	else:
	    rawpix = gtk.gdk.pixbuf_new_from_file(fn)
	    pix = gtk.Image()
	    pix.set_from_pixbuf(rawpix)

	if pix is not None:
	    al = gtk.Alignment(0.0, 0.0)
	    al.add(pix)
	    lblhbox.pack_start(al, gtk.FALSE, gtk.FALSE)
	    
        mainvbox.pack_start(lblhbox, gtk.FALSE, gtk.FALSE)

        cbvbox = gtk.VBox(gtk.FALSE)
	cbvbox.set_border_width(5)
	
	# will pack this last, need to create it for toggle callback below
        sizeLabel = gtk.Label("")
	self.setDetailSizeLabel(comp, sizeLabel)

        goodpkgs = comp.packageInfo().keys()
        # FIXME
#        goodpkgs = comp.packagesFullInfo().keys() + comp.metapackagesFullInfo().keys()


	# first show default members, if any
	haveBase = 0
	next = getNextMember(goodpkgs, comp, domandatory = 1)
	if next is not None:
	    haveBase = 1
	    lbl = gtk.Label("")
	    lbl.set_markup("<b>%s</b>" % (_("Base Packages"),))
	    lbl.set_alignment(0.0, 0.0)
	    cbvbox.pack_start(lbl, gtk.FALSE, gtk.FALSE);
	    while 1:
		next = getNextMember(goodpkgs, comp, domandatory = 1)
		if next is None:
		    break

		goodpkgs.remove(next)
		desc = getDescription(next, comp)
		lbl = gtk.Label(desc)
		lbl.set_alignment(0.0, 0.0)
		lbl.set_property("use-underline", gtk.FALSE)

		thbox = gtk.HBox(gtk.FALSE)
		chbox = gtk.HBox(gtk.FALSE)
		chbox.set_size_request(10,-1)
		thbox.pack_start(chbox, gtk.FALSE, gtk.FALSE)
		thbox.pack_start(lbl, gtk.TRUE, gtk.TRUE)

		cbvbox.pack_start(thbox, gtk.FALSE, gtk.FALSE)

	# now the optional parts, if any
	next = getNextMember(goodpkgs, comp, domandatory = 0)
	if next is not None:
	    spacer = gtk.Fixed()
	    spacer.set_size_request(-1, 10)
	    cbvbox.pack_start(spacer, gtk.FALSE, gtk.FALSE)
	    
	    lbl = gtk.Label("")
	    lbl.set_markup("<b>%s</b>" % (_("Optional Packages"),))
	    lbl.set_alignment(0.0, 0.0)
	    cbvbox.pack_start(lbl, gtk.FALSE, gtk.FALSE)
	    while 1:
		next = getNextMember(goodpkgs, comp, domandatory = 0)
		if next is None:
		    break

		goodpkgs.remove(next)

		desc = getDescription(next, comp)
		lbl = gtk.Label(desc)
		lbl.set_alignment(0.0, 0.0)
		lbl.set_property("use-underline", gtk.FALSE)
		cb = gtk.CheckButton()
		cb.add(lbl)
		(ptype, sel) = comp.packageInfo()[next]
		cb.set_active((sel in ON_STATES))
		cb.connect("toggled", self.pkgGroupMemberToggled,
			   (comp, sizeLabel, next))

		thbox = gtk.HBox(gtk.FALSE)
		chbox = gtk.HBox(gtk.FALSE)
		chbox.set_size_request(10,-1)
		thbox.pack_start(chbox, gtk.FALSE, gtk.FALSE)
		thbox.pack_start(cb, gtk.TRUE, gtk.TRUE)

		cbvbox.pack_start(thbox, gtk.FALSE, gtk.FALSE)

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        wrapper = gtk.VBox (gtk.FALSE, 0)
        wrapper.pack_start (cbvbox, gtk.FALSE)
        
        sw.add_with_viewport (wrapper)
        viewport = sw.get_children()[0]
        viewport.set_shadow_type (gtk.SHADOW_IN)
	viewport.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse ("white"))
        cbvbox.set_focus_hadjustment(sw.get_hadjustment ())
        cbvbox.set_focus_vadjustment(sw.get_vadjustment ())
        
        mainvbox.pack_start(sw, gtk.TRUE, gtk.TRUE, 10)

        mainvbox.pack_start(sizeLabel, gtk.FALSE, gtk.FALSE)
                            
        self.dialog.set_size_request(550, 420)
        self.dialog.show_all()

	while 1:
	    rc = self.dialog.run()

	    # they hit cancel, restore original state and quit
	    if rc == 2:
		allpkgs = comp.packageInfo().keys()
		for pkg in allpkgs:
		    (ptype, sel) = comp.packageInfo()[pkg]
		    (optype, osel) = origpkgselection[pkg]

                    if (osel == sel):
                        pass
                    elif (osel not in OFF_STATES) and (sel not in ON_STATES):
                        comp.selectPackage(pkg)
                    elif (osel not in ON_STATES) and (sel not in OFF_STATES):
                        comp.unselectPackage(pkg)
	    break
	
        self.dialog.destroy()
	self.setSize()

	if countlbl:
	    self.setCompCountLabel(comp, countlbl)

	(selpkg, totpkg) = self.getStats(comp)
	if selpkg < 1:
	    if compcb:
		compcb.set_active(0)
        return

    def focusIdleHandler(self, data):
	if not self.needToFocus:
	    return

	if self.scrolledWindow is None:
	    return

	vadj = self.scrolledWindow.get_vadjustment()
	swmin = vadj.lower
	swmax = vadj.upper
	pagesize = vadj.page_size
	curval = vadj.get_value()

	self.scrolledWindow.get_vadjustment().set_value(swmax-pagesize)

	if self.idleid is not None:
	    gtk.idle_remove(self.idleid)

	self.idleid = None
	self.needToFocus = 0
	
	

    def getScreen(self, grpset, langSupport, instClass, dispatch):

    # PackageSelectionWindow tag="sel-group"
        ICON_SIZE = 32
        
	self.grpset = grpset
	self.langSupport = langSupport
	self.dispatch = dispatch

	self.origSelection = self.grpset.getSelectionState()

        self.checkButtons = []

	# used to save buttons state if they hit everything or minimal
	self.savedStateDict = {}
	self.savedStateFlag = 0
	self.ignoreComponentToggleEvents = 0

	(parlist, pardict) = orderPackageGroups(self.grpset)

        topbox = gtk.VBox(gtk.FALSE, 3)
        topbox.set_border_width(3)
        
        checkGroup = gtk.SizeGroup(gtk.SIZE_GROUP_BOTH)
        countGroup = gtk.SizeGroup(gtk.SIZE_GROUP_BOTH)
        detailGroup = gtk.SizeGroup(gtk.SIZE_GROUP_BOTH)

        minimalActive = 0
	minimalComp = None
	minimalCB = None
	everythingActive = 0
	everythingComp = None
	everythingCB = None
	for par in parlist:
            # don't show the top-level if there aren't any groups in it
            if len(pardict[par]) == 0:
                continue
            
            # set the background to our selection color
	    eventBox = gtk.EventBox()
	    eventBox.modify_bg(gtk.STATE_NORMAL,
                               gtk.gdk.color_parse("#727fb2"))
	    lbl = gtk.Label("")
	    lbl.set_markup("<span foreground='white'><big><b>"
                           "%s</b></big></span>" % (par,))
	    lbl.set_alignment(0.0, 0.0)
            pad = gtk.Alignment(0.0, 0.0)
            pad.add(lbl)
            pad.set_border_width(3)
            eventBox.add(pad)
            topbox.pack_start(eventBox)

	    for comp in pardict[par]:
		if comp.hidden:
                    if comp.id != "base":
			continue
		    else:
			if not instClass.showMinimal:
			    continue
			
		pixname = string.lower(comp.id) + ".png"
		fn = self.ics.findPixmap("comps/"+pixname)
		if not fn:
		    log("could not load pix: %s " %(pixname,))
		    pix = None
		else:
		    rawpix = gtk.gdk.pixbuf_new_from_file(fn)
		    sclpix = rawpix.scale_simple(ICON_SIZE, ICON_SIZE,
						 gtk.gdk.INTERP_BILINEAR)
		    pix = gtk.Image()
		    pix.set_from_pixbuf(sclpix)

                compbox = gtk.HBox(gtk.FALSE, 5)                

                spacer = gtk.Fixed()
                spacer.set_size_request(30, -1)
                compbox.pack_start(spacer, gtk.FALSE, gtk.FALSE)

		# create check button and edit button
		# make the comps title + edit button
		hdrlabel=gtk.Label("")
		hdrlabel.set_alignment (0.0, 0.5)
		self.setCompLabel(comp, hdrlabel)

		checkButton = gtk.CheckButton()
		checkButton.add(hdrlabel)
                checkGroup.add_widget(checkButton)
                compbox.pack_start(checkButton)

		count=gtk.Label("")
		count.set_alignment (1.0, 0.5)
		self.setCompCountLabel(comp, count)
                countGroup.add_widget(count)
                compbox.pack_start(count, gtk.FALSE, gtk.FALSE)

                spacer = gtk.Fixed()
                spacer.set_size_request(15, -1)
                compbox.pack_start(spacer, gtk.FALSE, gtk.FALSE)
                
                buttonal = gtk.Alignment(0.5, 0.5)
                detailGroup.add_widget(buttonal)
                compbox.pack_start(buttonal, gtk.FALSE, gtk.FALSE)

		# now make the url looking button for details
		if comp.id != "everything" and comp.id != "base":
		    nlbl = gtk.Label("")
                    selected = comp.isSelected(justManual = 1)
                    nlbl.set_markup('<span foreground="#3030c0"><u>'
                                    '%s</u></span>' % (_('Details'),))
		    editbutton = gtk.Button()
		    editbutton.add(nlbl)
		    editbutton.set_relief(gtk.RELIEF_NONE)
		    editbutton.connect("clicked", self.editDetails,
				       (comp, hdrlabel, count, checkButton))
                    if comp.isSelected(justManual = 1):
                        buttonal.add(editbutton)
		else:
		    editbutton = None

                topbox.pack_start(compbox)

                detailbox = gtk.HBox(gtk.FALSE)

                spacer = gtk.Fixed()
                spacer.set_size_request(45, -1)
                detailbox.pack_start(spacer, gtk.FALSE, gtk.FALSE)
                
		# icon
		if pix is not None:
		    al = gtk.Alignment(0.5, 0.5)
		    al.add(pix)
                    detailbox.pack_start(al, gtk.FALSE, gtk.FALSE, 10)
                    
		# add description if it exists
		descr = getGroupDescription(comp)
		if descr is not None:
		    label=gtk.Label("")
		    label.set_alignment (0.0, 0.0)
		    label.set_line_wrap(gtk.TRUE)

                    if  gtk.gdk.screen_width() > 640:
                        wraplen = 350
                    else:
                        wraplen = 250

		    label.set_size_request(wraplen, -1)
		    label.set_markup("%s" % (_(descr),))
                    detailbox.pack_start(label, gtk.TRUE)
                topbox.pack_start(detailbox)

		state = self.setCheckButtonState(checkButton, comp)
                if comp.id == "base":
		    minimalActive = state
		    minimalComp = comp
		    minimalCB = checkButton
		elif comp.id == "everything":
		    everythingActive = state
		    everythingComp = comp
		    everythingCB = checkButton
		    
		checkButton.connect('toggled', self.componentToggled,
				    (comp, hdrlabel, count, buttonal,
                                     editbutton))
		self.checkButtons.append ((checkButton, count, buttonal, editbutton, compbox, detailbox, comp))

            # add some extra space to the end of each group
            spacer = gtk.Fixed()
            spacer.set_size_request(-1, 3)
            topbox.pack_start(spacer, gtk.FALSE, gtk.FALSE)

	# hack to make everything and minimal act right
        sw = gtk.ScrolledWindow()
        sw.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        viewport = gtk.Viewport(sw.get_hadjustment(), sw.get_vadjustment())
        sw.add(viewport)
        viewport.add(topbox)
        viewport.set_property('shadow-type', gtk.SHADOW_IN)
	viewport.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
        topbox.set_focus_hadjustment(sw.get_hadjustment())
        topbox.set_focus_vadjustment(sw.get_vadjustment())

	# save so we can scrfoll if needed
	self.scrolledWindow = sw
	self.needToFocus = 0

	# if special case we do things a little differently
	if minimalActive:
	    self.setComponentsSensitive(minimalComp, 0)
	    sw.set_focus_child(minimalCB)
	    self.needToFocus = 1
	elif everythingActive:
	    self.setComponentsSensitive(everythingComp, 0)
	    sw.set_focus_child(everythingCB)
	    self.needToFocus = 1

	if self.needToFocus:
	    self.idleid = gtk.idle_add(self.focusIdleHandler, None)

	# pack rest of screen
        hbox = gtk.HBox (gtk.FALSE, 5)

        self.individualPackages = gtk.CheckButton (
		_("_Select individual packages"))
        self.individualPackages.set_active (
		not dispatch.stepInSkipList("indivpackage"))
#        hbox.pack_start (self.individualPackages, gtk.FALSE)

        self.sizelabel = gtk.Label ("")
        self.setSize()
        hbox.pack_start (self.sizelabel, gtk.TRUE)
        
        vbox = gtk.VBox (gtk.FALSE, 5)
        vbox.pack_start (sw, gtk.TRUE)
        vbox.pack_start (hbox, gtk.FALSE)
        vbox.set_border_width (5)

        return vbox
Example #25
0
class UpgradeExamineWindow (InstallWindow):		

    windowTitle = N_("Upgrade Examine")
    htmlTag = "upgradeexamine"

    def getNext (self):
	if self.doupgrade:
            # set the install class to be an upgrade
            c = UpgradeClass(flags.expert)
            c.setSteps(self.dispatch)
            c.setInstallData(self.id)

	    rootfs = self.parts[self.upgradeoption.get_history()]
            self.id.upgradeRoot = [(rootfs[0], rootfs[1])]
            self.id.rootParts = self.parts

            if self.individualPackages is not None and self.individualPackages.get_active():
                self.dispatch.skipStep("indivpackage", skip = 0)
            else:
                self.dispatch.skipStep("indivpackage")
            self.dispatch.skipStep("installtype", skip = 1)
        else:
            self.dispatch.skipStep("installtype", skip = 0)

        return None

    def createUpgradeOption(self):
	r = pixmapRadioButtonGroup()
	r.addEntry(UPGRADE_STR,
                   _("_Upgrade an existing installation"),
		   pixmap=self.ics.readPixmap("upgrade.png"),
		   descr=_("Choose this option if you would like "
                           "to upgrade your existing %s system.  "
                           "This option will preserve the "
                           "existing data on your drives.") %(productName,))
        
	r.addEntry(REINSTALL_STR,
                   _("_Install %s") %(productName,),
		   pixmap=self.ics.readPixmap("install.png"),
		   descr=_("Choose this option to freshly install your system. "                           "Existing software and data may be overwritten "
			   "depending on your configuration choices."))        
	return r

    def upgradeOptionsSetSensitivity(self, state):
	self.uplabel.set_sensitive(state)
	self.upgradeoption.set_sensitive(state)
	if self.individualPackages is not None:
	    self.individualPackages.set_sensitive(state)

    def optionToggled(self, widget, name):
	if name == UPGRADE_STR:
	    self.upgradeOptionsSetSensitivity(widget.get_active())

	    self.doupgrade = widget.get_active()

    #UpgradeExamineWindow tag = "upgrade"
    def getScreen (self, dispatch, intf, id, chroot):
        self.dispatch = dispatch
        self.intf = intf
        self.id = id
        self.chroot = chroot

	self.doupgrade = dispatch.stepInSkipList("installtype")
        self.parts = self.id.rootParts 

        vbox = gtk.VBox (gtk.FALSE, 10)
	vbox.set_border_width (8)

	r = self.createUpgradeOption()
	b = r.render()
	if self.doupgrade:
	    r.setCurrent(UPGRADE_STR)
	else:
	    r.setCurrent(REINSTALL_STR)

	r.setToggleCallback(self.optionToggled)
	box = gtk.VBox (gtk.FALSE)
        box.pack_start(b, gtk.FALSE)

        vbox.pack_start (box, gtk.FALSE)
        self.root = self.parts[0]

#
# lets remove this seemingly useless option - clutters display
#
#        self.individualPackages = gtk.CheckButton (_("_Customize packages to be "
#                                                    "upgraded"))
#        self.individualPackages.set_active (not dispatch.stepInSkipList("indivpackage"))
#	ipbox = gtk.HBox(gtk.FALSE)
#	crackhbox = gtk.HBox(gtk.FALSE)
#	crackhbox.set_size_request(70, -1)
#	ipbox.pack_start(crackhbox, gtk.FALSE, gtk.FALSE)
#	ipbox.pack_start(self.individualPackages, gtk.TRUE, gtk.TRUE)
#	r.packWidgetInEntry(UPGRADE_STR, ipbox)
        self.individualPackages = None


	# hack hack hackity hack
	upboxtmp = gtk.VBox(gtk.FALSE, 5)
	uplabelstr = _("The following installed system will be upgraded:")
	self.uplabel = gtk.Label(uplabelstr)
	self.uplabel.set_alignment(0.0, 0.0)
	self.upgradeoption = gtk.OptionMenu()
	self.upgradeoptionmenu = gtk.Menu()
	for (part, filesystem, desc) in self.parts:
	    if (desc is None) or len(desc) < 1:
		desc = _("Unknown Linux system")
	    if part[:5] != "/dev/":
		devname = "/dev/" + part
	    else:
		devname = part
            item = gtk.MenuItem("")
	    itemlabel = item.get_children()[0]
	    itemlabel.set_markup("<small>%s (%s)</small>" %(desc, devname))
	    item.show()
	    self.upgradeoptionmenu.add(item)

	self.upgradeoption.set_menu(self.upgradeoptionmenu)
	upboxtmp.pack_start(self.uplabel)

	# more indentation
	box1 = gtk.HBox(gtk.FALSE)
	crackhbox = gtk.HBox(gtk.FALSE)
	crackhbox.set_size_request(35, -1)
	box1.pack_start(crackhbox, gtk.FALSE, gtk.FALSE)
	box1.pack_start(self.upgradeoption, gtk.FALSE, gtk.FALSE)
	upboxtmp.pack_start(box1, gtk.FALSE, gtk.FALSE)
#	upboxtmp.pack_start(self.upgradeoption, gtk.FALSE, gtk.FALSE)

	# hack indent it
	upbox = gtk.HBox(gtk.FALSE)

	crackhbox = gtk.HBox(gtk.FALSE)
	crackhbox.set_size_request(70, -1)

	upbox.pack_start(crackhbox, gtk.FALSE, gtk.FALSE)
#	upbox.pack_start(upboxtmp, gtk.TRUE, gtk.TRUE)
	upbox.pack_start(upboxtmp, gtk.FALSE, gtk.FALSE)

	# all done phew
	r.packWidgetInEntry(UPGRADE_STR, upbox)

	# set default
	if self.doupgrade:
	    idx = 0
	    for p in self.parts:
		if self.id.upgradeRoot[0][0] == p[0]:
		    self.upgradeoption.set_history(idx)
		    break
		idx = idx + 1

	self.upgradeOptionsSetSensitivity(self.doupgrade)

        return vbox
Example #26
0
class LanguageWindow(InstallWindow):

    windowTitle = N_("Language Selection")

    def __init__(self, ics):
        InstallWindow.__init__(self, ics)

    def getNext(self):
        (model, iter) = self.listView.get_selection().get_selected()
        assert iter, "No selection found on language list!"
        choice = self.listStore.get_value(iter, 1)
        self.lang = self.instLang.getNickByName(choice)

        self.instLang.setRuntimeLanguage(self.lang)
        self.instLang.setDefault(self.lang)
        self.ics.getICW().setLanguage()

        # Need to reload the release notes file in case we've changed languages
        self.ics.getICW().rnv.load()

        return None

    def listScroll(self, widget, *args):
        # recenter the list
        (model, iter) = self.listView.get_selection().get_selected()
        if iter is None:
            return

        path = self.listStore.get_path(iter)
        col = self.listView.get_column(0)
        self.listView.scroll_to_cell(path, col, True, 0.5, 0.5)
        self.listView.set_cursor(path, col, False)

    # LanguageWindow tag="lang"
    def getScreen(self, anaconda):
        self.running = 0
        mainBox = gtk.VBox(False, 10)

        hbox = gtk.HBox(False, 5)
        pix = gui.readImageFromFile("gnome-globe.png")
        if pix:
            a = gtk.Alignment()
            a.add(pix)
            hbox.pack_start(a, False)

        label = gtk.Label(
            _("What language would you like to use during the "
              "installation process?"))
        label.set_line_wrap(True)
        label.set_size_request(350, -1)
        hbox.pack_start(label, False)

        self.instLang = anaconda.id.instLanguage

        self.listStore = gtk.ListStore(gobject.TYPE_STRING,
                                       gobject.TYPE_STRING,
                                       gobject.TYPE_STRING)

        for locale in self.instLang.available():
            iter = self.listStore.append()
            nick = self.instLang.getNickByName(locale)
            lang = '%s (<span lang="%s">%s</span>)' % (_(locale), "%s" % (
                nick.split('.')[0], ), self.instLang.getNativeLangName(locale))
            self.listStore.set_value(iter, 0, lang)
            self.listStore.set_value(iter, 1, locale)
            self.listStore.set_value(iter, 2, _(locale))

        self.listStore.set_sort_column_id(2, gtk.SORT_ASCENDING)

        self.listView = gtk.TreeView(self.listStore)
        col = gtk.TreeViewColumn(None, gtk.CellRendererText(), markup=0)
        self.listView.append_column(col)
        self.listView.set_property("headers-visible", False)

        current = self.instLang.getLangNameByNick(self.instLang.getCurrent())
        iter = self.listStore.get_iter_first()
        while iter:
            if self.listStore.get_value(iter, 1) == current:
                selection = self.listView.get_selection()
                selection.unselect_all()
                selection.select_iter(iter)
                break
            iter = self.listStore.iter_next(iter)
        self.listView.connect("size-allocate", self.listScroll)

        sw = gtk.ScrolledWindow()
        sw.set_border_width(5)
        sw.set_shadow_type(gtk.SHADOW_IN)
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        sw.add(self.listView)

        setupTreeViewFixupIdleHandler(self.listView, self.listStore)

        mainBox.pack_start(hbox, False, False, 10)
        mainBox.pack_start(sw, True, True)

        self.running = 1

        return mainBox
Example #27
0
class AuthWindow (InstallWindow):

    htmlTag = "authconf"
    windowTitle = N_("Authentication Configuration")

    def setSensitivities (self, *args):
	if (not self.nis.get_active()):
	    self.nisDomain.set_sensitive (gtk.FALSE)
	    self.nisBroadcast.set_sensitive (gtk.FALSE)
	    self.nisServer.set_sensitive (gtk.FALSE)
	    self.nisDomainLabel.set_sensitive (gtk.FALSE)
	    self.nisServerLabel.set_sensitive (gtk.FALSE)
	else:
	    self.nisDomain.set_sensitive (gtk.TRUE)
	    self.nisDomainLabel.set_sensitive (gtk.TRUE)
	    self.nisBroadcast.set_sensitive (gtk.TRUE)

	    if (self.nisBroadcast.get_active()):
		self.nisServerLabel.set_sensitive (gtk.FALSE)
		self.nisServer.set_sensitive (gtk.FALSE)
	    else:
		self.nisServerLabel.set_sensitive (gtk.TRUE)
		self.nisServer.set_sensitive (gtk.TRUE)

        ldapactive = self.ldap.get_active()
        self.ldapServerLabel.set_sensitive (ldapactive)
        self.ldapServer.set_sensitive (ldapactive)
        self.ldapBasednLabel.set_sensitive (ldapactive)
        self.ldapBasedn.set_sensitive (ldapactive)
        self.ldapTLS.set_sensitive (ldapactive)

        krb5active = self.krb5.get_active()
        self.krb5RealmLabel.set_sensitive (krb5active)
        self.krb5Realm.set_sensitive (krb5active)
        self.krb5KdcLabel.set_sensitive (krb5active)
        self.krb5Kdc.set_sensitive (krb5active)
        self.krb5AdminLabel.set_sensitive (krb5active)
        self.krb5Admin.set_sensitive (krb5active)

        sambaactive = self.samba.get_active()
        self.sambaLabel1.set_sensitive(sambaactive)
        self.sambaLabel2.set_sensitive(sambaactive)
        self.sambaServer.set_sensitive(sambaactive)
        self.sambaWorkgroup.set_sensitive(sambaactive)

    def getNext(self):
	if not self.__dict__.has_key("md5"):
	    return None

        self.auth.useMD5 = self.md5.get_active ()
        self.auth.useShadow = self.shadow.get_active ()

        self.auth.useNIS = self.nis.get_active ()
        self.auth.nisuseBroadcast = self.nisBroadcast.get_active ()
        self.auth.nisDomain = self.nisDomain.get_text ()
        self.auth.nisServer = self.nisServer.get_text ()

        self.auth.useLdap = self.ldap.get_active ()
        self.auth.useLdapauth = self.ldap.get_active ()
        self.auth.ldapServer = self.ldapServer.get_text ()
        self.auth.ldapBasedn = self.ldapBasedn.get_text ()
        self.auth.ldapTLS = self.ldapTLS.get_active ()

        self.auth.useKrb5 = self.krb5.get_active ()
        self.auth.krb5Realm = self.krb5Realm.get_text ()
        self.auth.krb5Kdc = self.krb5Kdc.get_text ()
        self.auth.krb5Admin = self.krb5Admin.get_text ()

        self.auth.useSamba = self.samba.get_active ()
        self.auth.sambaServer = self.sambaServer.get_text()
        self.auth.sambaWorkgroup = self.sambaWorkgroup.get_text()

    def getScreen (self, auth):
	self.auth = auth

        box = gtk.VBox (gtk.FALSE, 10)

        nb = gtk.Notebook ()

        self.md5 = gtk.CheckButton (_("Enable _MD5 passwords"))
        self.shadow = gtk.CheckButton (_("Enable shado_w passwords"))

        # nis
        self.nis = gtk.CheckButton (_("Enable N_IS"))
        self.nisBroadcast = gtk.CheckButton (_("Use _broadcast to find NIS server"))
        self.nisDomain = gtk.Entry ()
        self.nisServer = gtk.Entry ()

        self.md5.set_active (self.auth.useMD5)
        self.shadow.set_active (self.auth.useShadow)

        self.nis.set_active (self.auth.useNIS)
        self.nisDomain.set_text (self.auth.nisDomain)
        self.nisBroadcast.set_active (self.auth.nisuseBroadcast)
        self.nisServer.set_text (self.auth.nisServer )

        self.nisDomainLabel = gui.MnemonicLabel (_("NIS _Domain: "))
        self.nisDomainLabel.set_alignment (0, 0)
        self.nisDomainLabel.set_mnemonic_widget(self.nisDomain)
        self.nisServerLabel = gui.MnemonicLabel (_("NIS _Server: "))
        self.nisServerLabel.set_alignment (0, 0)
        self.nisServerLabel.set_mnemonic_widget(self.nisServer)

        self.nis.connect ("toggled", self.setSensitivities)
        self.nisBroadcast.connect ("toggled", self.setSensitivities)

        a = gtk.Alignment (0, 0)
        a.add (self.nisBroadcast)

        nistable = gtk.Table (10, 4, gtk.FALSE)
        nistable.attach (self.nis, 0, 10, 0, 1, gtk.FILL, gtk.SHRINK, 0.0, 0.5)

	spacer = gtk.Label("")
	spacer.set_size_request(10, 1)
        nistable.attach (spacer, 0, 1, 1, 2, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5)
        
        nistable.attach (self.nisDomainLabel, 2, 3, 1, 2, gtk.FILL, gtk.SHRINK, 0.0, 0.5)
        nistable.attach (self.nisDomain, 3, 15, 1, 2, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5)
        nistable.attach (a, 2, 10, 2, 3, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5)
        nistable.attach (self.nisServerLabel, 2, 5, 3, 4, gtk.FILL, gtk.SHRINK, 0.0, 0.5)
        nistable.attach (self.nisServer, 3, 10, 3, 4, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5)

        # ldap
        self.ldap = gtk.CheckButton (_("Enable _LDAP"))
        self.ldapServer = gtk.Entry ()
        self.ldapBasedn = gtk.Entry ()
        self.ldapTLS = gtk.CheckButton (_("Use _TLS lookups"))
        self.ldapServerLabel = gui.MnemonicLabel (_("LDAP _Server:"))
        self.ldapServerLabel.set_alignment (0, 0)
        self.ldapServerLabel.set_mnemonic_widget(self.ldapServer)
        self.ldapBasednLabel = gui.MnemonicLabel (_("LDAP _Base DN:"))
        self.ldapBasednLabel.set_alignment (0, 0)
        self.ldapBasednLabel.set_mnemonic_widget(self.ldapBasedn)

	# restore ldap settings
        self.ldap.set_active (self.auth.useLdap)
	self.ldapServer.set_text (self.auth.ldapServer)
        self.ldapBasedn.set_text (self.auth.ldapBasedn)
         
        ldaptable = gtk.Table (10, 4, gtk.FALSE)

        ldaptable.attach (self.ldap, 0, 10, 0, 1, gtk.FILL, gtk.SHRINK, 0.0, 0.5)

	spacer = gtk.Label("")
	spacer.set_size_request(10, 1)
        ldaptable.attach (spacer, 0, 1, 1, 2, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5)
        ldaptable.attach (self.ldapServerLabel, 2, 3, 1, 2, gtk.FILL, gtk.SHRINK, 0.0, 0.5)
        ldaptable.attach (self.ldapServer, 3, 10, 1, 2, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5)

        ldaptable.attach (self.ldapBasednLabel, 2, 3, 2, 3, gtk.FILL, gtk.SHRINK, 0.0, 0.5)
        ldaptable.attach (self.ldapBasedn, 3, 10, 2, 3, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5)
        a = gtk.Alignment (0, 0)
        a.add (self.ldapTLS)
        ldaptable.attach (a, 2, 3, 3, 4, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5) 
        
        self.ldap.connect ("toggled", self.setSensitivities)

        # krb5
        self.krb5 = gtk.CheckButton (_("Enable _Kerberos"))
        self.krb5Realm = gtk.Entry ()
        self.krb5Kdc = gtk.Entry ()
        self.krb5Admin = gtk.Entry ()
        self.krb5RealmLabel = gui.MnemonicLabel (_("R_ealm:"))
        self.krb5RealmLabel.set_alignment (0, 0)
        self.krb5RealmLabel.set_mnemonic_widget(self.krb5Realm)        
        self.krb5KdcLabel = gui.MnemonicLabel (_("K_DC:"))
        self.krb5KdcLabel.set_alignment (0, 0)
        self.krb5KdcLabel.set_mnemonic_widget(self.krb5Kdc)
        self.krb5AdminLabel = gui.MnemonicLabel (_("_Admin Server:"))
        self.krb5AdminLabel.set_alignment (0, 0)
        self.krb5AdminLabel.set_mnemonic_widget(self.krb5Admin)

        # restore krb5 settings
        self.krb5.set_active (self.auth.useKrb5)
        self.krb5Realm.set_text (self.auth.krb5Realm)
        self.krb5Kdc.set_text (self.auth.krb5Kdc)
        self.krb5Admin.set_text (self.auth.krb5Admin)
        
        krb5table = gtk.Table (10, 4, gtk.FALSE)

        krb5table.attach (self.krb5, 0, 10, 0, 1, gtk.FILL, gtk.SHRINK, 0.0, 0.5)

	spacer = gtk.Label("")
	spacer.set_size_request(10, 1)
        krb5table.attach (spacer, 0, 1, 1, 2, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5)
        krb5table.attach (self.krb5RealmLabel, 2, 3, 1, 2, gtk.FILL, gtk.SHRINK, 0.0, 0.5)
        krb5table.attach (self.krb5Realm, 3, 10, 1, 2, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5)

        krb5table.attach (self.krb5KdcLabel, 2, 3, 2, 3, gtk.FILL, gtk.SHRINK, 0.0, 0.5)
        krb5table.attach (self.krb5Kdc, 3, 10, 2, 3, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5)

        krb5table.attach (self.krb5AdminLabel, 2, 3, 3, 4, gtk.FILL, gtk.SHRINK, 0.0, 0.5)
        krb5table.attach (self.krb5Admin, 3, 10, 3, 4, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5)

        self.krb5.connect ("toggled", self.setSensitivities)

        # samba
        self.samba = gtk.CheckButton (_("Enable SMB _Authentication"))
        self.sambaServer = gtk.Entry ()
        self.sambaWorkgroup = gtk.Entry ()
        self.sambaLabel1 = gui.MnemonicLabel (_("SMB _Server:"))
        self.sambaLabel1.set_alignment (0, 0)
        self.sambaLabel1.set_mnemonic_widget(self.sambaServer)
        self.sambaLabel2 = gui.MnemonicLabel (_("SMB Work_group:"))
        self.sambaLabel2.set_alignment (0, 0)
        self.sambaLabel2.set_mnemonic_widget(self.sambaWorkgroup)

 	# restore ldap settings
        self.samba.set_active (self.auth.useSamba)
 	self.sambaServer.set_text (self.auth.sambaServer)
        self.sambaWorkgroup.set_text (self.auth.sambaWorkgroup)
         
        sambatable = gtk.Table (10, 3, gtk.FALSE)

        sambatable.attach (self.samba, 0, 10, 0, 1, gtk.FILL, gtk.SHRINK, 0.0, 0.5)

        spacer = gtk.Label("")
        spacer.set_size_request(10, 1)
        sambatable.attach (spacer, 0, 1, 1, 2, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5)
        sambatable.attach (self.sambaLabel1, 2, 3, 1, 2, gtk.FILL, gtk.SHRINK, 0.0, 0.5)
        sambatable.attach (self.sambaServer, 3, 10, 1, 2, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5)

        sambatable.attach (self.sambaLabel2, 2, 3, 2, 3, gtk.FILL, gtk.SHRINK, 0.0, 0.5)
        sambatable.attach (self.sambaWorkgroup, 3, 10, 2, 3, gtk.SHRINK, gtk.SHRINK, 0.0, 0.5)
        
        self.samba.connect ("toggled", self.setSensitivities)

# pack everything

	self.setSensitivities()

        nisLabel = gtk.Label (_("NIS"))
        ldapLabel = gtk.Label (_("LDAP"))
        krb5Label = gtk.Label (_("Kerberos 5"))
        sambaLabel = gtk.Label (_("SMB"))

        nb.append_page(nistable, nisLabel)
        nb.append_page(ldaptable, ldapLabel)
        nb.append_page(krb5table, krb5Label)
        nb.append_page(sambatable, sambaLabel)


        box.pack_start (self.md5, gtk.FALSE)
        box.pack_start (self.shadow, gtk.FALSE)
        box.pack_start (nb, gtk.TRUE)
        
	box.set_border_width (5)
        
        return box
Example #28
0
class AccountWindow (InstallWindow):

    windowTitle = N_("Set Root Password")

    def getNext (self):
        def passwordError():
            self.pw.set_text("")
            self.confirm.set_text("")
            self.pw.grab_focus()            
            raise gui.StayOnScreen
            
	if not self.__dict__.has_key("pw"): return None

        # check if we already have a crypted password from kickstart
        if self.rootPassword["isCrypted"]: return None

        pw = self.pw.get_text()
        confirm = self.confirm.get_text()

        if not pw or not confirm:
            self.intf.messageWindow(_("Error with Password"),
                                    _("You must enter your root password "
                                      "and confirm it by typing it a second "
                                      "time to continue."),
                                    custom_icon="error")
            passwordError()

        if pw != confirm:
            self.intf.messageWindow(_("Error with Password"),
                                    _("The passwords you entered were "
                                      "different.  Please try again."),
                                    custom_icon="error")
            passwordError()

        if len(pw) < 6:
            self.intf.messageWindow(_("Error with Password"),
                                    _("The root password must be at least "
                                      "six characters long."),
                                    custom_icon="error")
            passwordError()
        
        allowed = string.digits + string.ascii_letters + string.punctuation + " "
        for letter in pw:
            if letter not in allowed:
                self.intf.messageWindow(_("Error with Password"),
                                        _("Requested password contains "
                                          "non-ascii characters which are "
                                          "not allowed for use in password."),
                                        custom_icon="error")
                passwordError()

        self.rootPassword["password"] = self.pw.get_text()
        self.rootPassword["isCrypted"] = False
        return None

    def setFocus (self, area, data):
        self.pw.grab_focus ()

    # AccountWindow tag="accts"
    def getScreen (self, anaconda):
	self.rootPassword = anaconda.id.rootPassword
        self.intf = anaconda.intf

	self.passwords = {}

        box = gtk.VBox ()
        box.set_border_width(5)

        hbox = gtk.HBox()
        pix = gui.readImageFromFile ("root-password.png")
        if pix:
            hbox.pack_start (pix, False)

        label = gui.WrappingLabel (_("The root account is used for "
                                     "administering the system.  Enter "
                                     "a password for the root user."))
        label.set_line_wrap(True)
        label.set_size_request(350, -1)
        label.set_alignment(0.0, 0.5)
        hbox.pack_start(label, False)

        box.pack_start(hbox, False)
       
        self.forward = lambda widget, box=box: box.emit('focus', gtk.DIR_TAB_FORWARD)
        
        table = gtk.Table (2, 2)
        table.set_size_request(365, -1)
        table.set_row_spacings (5)
	table.set_col_spacings (5)

        pass1 = gui.MnemonicLabel (_("Root _Password: "******"_Confirm: "))
        pass2.set_alignment (0.0, 0.5)
        table.attach (pass2, 0, 1, 1, 2, gtk.FILL, 0, 10)
        self.pw = gtk.Entry (128)
        pass1.set_mnemonic_widget(self.pw)
        
        self.pw.connect ("activate", self.forward)
        self.pw.connect ("map-event", self.setFocus)
        self.pw.set_visibility (False)
        self.confirm = gtk.Entry (128)
        pass2.set_mnemonic_widget(self.confirm)
        self.confirm.connect ("activate", self.forward)
        self.confirm.set_visibility (False)
        table.attach (self.pw,      1, 2, 0, 1, gtk.FILL|gtk.EXPAND, 5)
        table.attach (self.confirm, 1, 2, 1, 2, gtk.FILL|gtk.EXPAND, 5)

        hbox = gtk.HBox()
        hbox.pack_start(table, False)
        box.pack_start (hbox, False)

        # root password statusbar
        self.rootStatus = gtk.Label ("")
        wrapper = gtk.HBox(0, False)
        wrapper.pack_start (self.rootStatus)
        box.pack_start (wrapper, False)

        if not self.rootPassword["isCrypted"]:
	    self.pw.set_text(self.rootPassword["password"])
	    self.confirm.set_text(self.rootPassword["password"])
        else:
            self.pw.set_text("xxxxxxxx")
            self.confirm.set_text("xxxxxxxx")

        return box
Example #29
0
class MouseWindow(InstallWindow):
    windowTitle = N_("Mouse Configuration")
    htmlTag = "mouse"

    def getNext(self):
        self.mouse.setMouse(self.currentMouse, self.emulate3.get_active())

        mouse = self.mice[self.currentMouse]
        (make, model, gpmproto, xproto, device, emulate3) = mouse

        if device == "ttyS":
            self.mouse.setDevice(self.serialDevice)
        else:
            self.mouse.setDevice(device)

        if self.flags.setupFilesystems:
            self.mouse.setXProtocol()

        return None

    def selectDeviceType(self, selection, *args):
        if self.ignoreEvents:
            return
        (model, iter) = selection.get_selected()
        if iter:
            self.serialDevice = model.get_value(iter, 1)
            self.ics.setNextEnabled(gtk.TRUE)
        else:
            self.serialDevice = None

    def selectMouseType(self, selection, *args):
        if self.ignoreEvents:
            return
        (model, iter) = selection.get_selected()
        if iter is None:
            return

        if model.iter_has_child(iter):
            self.devview.get_selection().unselect_all()
            self.devview.set_sensitive(gtk.FALSE)
            self.emulate3.set_sensitive(gtk.FALSE)
            self.ics.setNextEnabled(gtk.FALSE)
            return

        cur = model.get_value(iter, 1)

        self.emulate3.set_sensitive(gtk.TRUE)
        (make, model, gpmproto, xproto, device, emulate) = self.mice[cur]

        if device == "ttyS":
            self.setCurrent(self.serialDevice, cur, emulate, recenter=0)
        else:
            self.setCurrent(device, cur, emulate, recenter=0)

    def setupDeviceList(self):
        deviceList = ((_("/dev/ttyS0 (COM1 under DOS)"),
                       "ttyS0"), (_("/dev/ttyS1 (COM2 under DOS)"), "ttyS1"),
                      (_("/dev/ttyS2 (COM3 under DOS)"),
                       "ttyS2"), (_("/dev/ttyS3 (COM4 under DOS)"), "ttyS3"))

        self.devstore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
        for descrip, dev in deviceList:
            iter = self.devstore.append()
            self.devstore.set_value(iter, 0, descrip)
            self.devstore.set_value(iter, 1, dev)
        self.devstore.set_sort_column_id(0, gtk.SORT_ASCENDING)
        self.devview = gtk.TreeView(self.devstore)
        col = gtk.TreeViewColumn(_("_Device"), gtk.CellRendererText(), text=0)
        self.devview.append_column(col)
        selection = self.devview.get_selection()
        selection.connect("changed", self.selectDeviceType)

    def setupMice(self):
        self.mousestore = gtk.TreeStore(gobject.TYPE_STRING,
                                        gobject.TYPE_STRING)
        # go though and find all the makes that have more than 1 mouse
        toplevels = {}
        for key, value in self.mice.items():
            (make, model, gpmproto, xproto, device, emulate3) = value
            make = _(make)
            if toplevels.has_key(make):
                toplevels[make] = toplevels[make] + 1
            else:
                toplevels[make] = 1

        # for each toplevel that has more than one mouse, make a parent
        # node for it.
        for make, count in toplevels.items():
            if count > 1:
                parent = self.mousestore.append(None)
                self.mousestore.set_value(parent, 0, make)
                toplevels[make] = parent
            else:
                del toplevels[make]

        # now go and add each child node
        for key, value in self.mice.items():
            (make, model, gpmproto, xproto, device, emulate3) = value
            make = _(make)
            model = _(model)
            parent = toplevels.get(make)
            iter = self.mousestore.append(parent)
            # if there is a parent, put only the model in the tree
            if parent:
                self.mousestore.set_value(iter, 0, model)
            else:
                # otherwise, put the full device there.
                self.mousestore.set_value(iter, 0, "%s %s" % (make, model))
            self.mousestore.set_value(iter, 1, key)

        self.mousestore.set_sort_column_id(0, gtk.SORT_ASCENDING)
        self.mouseview = gtk.TreeView(self.mousestore)
        self.mouseview.set_property("headers-visible", gtk.TRUE)
        col = gtk.TreeViewColumn(_("_Model"), gtk.CellRendererText(), text=0)
        self.mouseview.append_column(col)
        selection = self.mouseview.get_selection()
        selection.connect("changed", self.selectMouseType)

    def setCurrent(self, currentDev, currentMouse, emulate3, recenter=1):
        self.ignoreEvents = 1
        self.currentMouse = currentMouse

        parent = None
        iter = self.mousestore.get_iter_first()
        fndmouse = 0
        # iterate over the list, looking for the current mouse selection
        while iter:
            # if this is a parent node, get the first child and iter over them
            if self.mousestore.iter_has_child(iter):
                parent = iter
                iter = self.mousestore.iter_children(parent)
                continue
            # if it's not a parent node and the mouse matches, select it.
            elif self.mousestore.get_value(iter, 1) == currentMouse:
                if parent:
                    path = self.mousestore.get_path(parent)
                    self.mouseview.expand_row(path, gtk.TRUE)
                selection = self.mouseview.get_selection()
                selection.unselect_all()
                selection.select_iter(iter)
                path = self.mousestore.get_path(iter)
                col = self.mouseview.get_column(0)
                self.mouseview.set_cursor(path, col, gtk.FALSE)
                if recenter:
                    self.mouseview.scroll_to_cell(path, col, gtk.TRUE, 0.5,
                                                  0.5)
                fndmouse = 1
                break
            # get the next row.
            iter = self.mousestore.iter_next(iter)
            # if there isn't a next row and we had a parent, go to the node
            # after the parent we've just gotten the children of.
            if not iter and parent:
                parent = self.mousestore.iter_next(parent)
                iter = parent

        # set up the device list if we have a serial port
        if currentDev and currentDev.startswith('ttyS'):
            self.serialDevice = currentDev
            selection = self.devview.get_selection()
            path = (int(self.serialDevice[4]), )
            selection.select_path(path)
            col = self.devview.get_column(0)
            self.devview.set_cursor(path, col, gtk.FALSE)
            if recenter:
                self.devview.scroll_to_cell(path, col, gtk.TRUE, 0.5, 0.5)
            self.ics.setNextEnabled(gtk.TRUE)
            self.devview.set_sensitive(gtk.TRUE)
        elif currentDev:
            self.devview.get_selection().unselect_all()
            self.devview.set_sensitive(gtk.FALSE)
            self.ics.setNextEnabled(gtk.TRUE)
        else:
            # XXX - see if this is the 'No - mouse' case
            if fndmouse:
                cur = self.mousestore.get_value(iter, 1)
                (make, model, gpmproto, xdev, device,
                 emulate3) = self.mice[cur]
            else:
                xdev = None

            if xdev == "none":
                self.devview.get_selection().unselect_all()
                self.devview.set_sensitive(gtk.FALSE)
                self.ics.setNextEnabled(gtk.TRUE)

            else:
                # otherwise disable the list
                self.devview.get_selection().unselect_all()
                self.serialDevice = None
                self.ics.setNextEnabled(gtk.FALSE)
                self.devview.set_sensitive(gtk.TRUE)

        self.emulate3.set_active(emulate3)
        self.ignoreEvents = 0

    # MouseWindow tag="mouse"
    def getScreen(self, mouse):
        self.mouse = mouse
        self.flags = flags

        self.ignoreEvents = 0

        self.mice = mouse.mouseModels
        self.serialDevice = None

        currentDev = mouse.getDevice()
        currentMouse, emulate3 = mouse.getMouse()

        # populate the big widgets with the available selections
        self.setupMice()
        self.setupDeviceList()
        self.emulate3 = gtk.CheckButton(_("_Emulate 3 buttons"))
        self.setCurrent(currentDev, currentMouse, emulate3)

        # set up the box for this screen
        box = gtk.VBox(gtk.FALSE, 5)
        box.set_border_width(5)

        # top header, includes graphic and instructions
        hbox = gtk.HBox(gtk.FALSE, 5)
        pix = self.ics.readPixmap("gnome-mouse.png")
        if pix:
            a = gtk.Alignment()
            a.add(pix)
            a.set(0.0, 0.0, 0.0, 0.0)
            hbox.pack_start(a, gtk.FALSE)
        label = gui.MnemonicLabel(
            _("Select the appropriate mouse for the system."))
        label.set_line_wrap(gtk.TRUE)
        label.set_size_request(350, -1)
        hbox.pack_start(label, gtk.FALSE)
        box.pack_start(hbox, gtk.FALSE)

        # next is the mouse tree
        sw = gtk.ScrolledWindow()
        sw.set_shadow_type(gtk.SHADOW_IN)
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        sw.add(self.mouseview)
        box.pack_start(sw)
        label.set_mnemonic_widget(self.mouseview)

        gui.setupTreeViewFixupIdleHandler(self.mouseview, self.mousestore)

        # then the port list
        serial_sw = gtk.ScrolledWindow()
        serial_sw.set_shadow_type(gtk.SHADOW_IN)
        serial_sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)
        serial_sw.add(self.devview)
        box.pack_start(serial_sw, gtk.FALSE)

        # finally the emulate 3 buttons
        box.pack_start(self.emulate3, gtk.FALSE)
        return box
Example #30
0
MAX_PART_SIZE = 1024 * 1024 * 1024

# these are used for kickstart
CHECK_DEPS = 0
IGNORE_DEPS = 1
RESOLVE_DEPS = 2

# firstboot settings
FIRSTBOOT_DEFAULT = 0
FIRSTBOOT_SKIP = 1
FIRSTBOOT_RECONFIG = 2

# common string needs to be easy to change
import product
productName = product.productName
productVersion = product.productVersion
productPath = product.productPath

exceptionText = N_("An unhandled exception has occurred.  This "
                   "is most likely a bug.  Please copy the "
                   "full text of this exception or save the crash "
                   "dump to a floppy then file a detailed bug "
                   "report against anaconda at "
                   "http://bugzilla.redhat.com/bugzilla/")

exceptionTextNoFloppy = N_("An unhandled exception has occurred.  This "
                           "is most likely a bug.  Please copy the "
                           "full text of this exception and file a detailed "
                           "bug report against anaconda at "
                           "http://bugzilla.redhat.com/bugzilla/")