Package pyanaconda :: Package iw :: Module examine_gui
[hide private]
[frames] | no frames]

Source Code for Module pyanaconda.iw.examine_gui

  1  # 
  2  # examine_gui.py: dialog to allow selection of a RHL installation to upgrade 
  3  # 
  4  # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006  Red Hat, Inc. 
  5  # All rights reserved. 
  6  # 
  7  # This program is free software; you can redistribute it and/or modify 
  8  # it under the terms of the GNU General Public License as published by 
  9  # the Free Software Foundation; either version 2 of the License, or 
 10  # (at your option) any later version. 
 11  # 
 12  # This program is distributed in the hope that it will be useful, 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 15  # GNU General Public License for more details. 
 16  # 
 17  # You should have received a copy of the GNU General Public License 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 19  # 
 20   
 21  import gtk 
 22  from pyanaconda import gui 
 23  from iw_gui import * 
 24  from pixmapRadioButtonGroup_gui import pixmapRadioButtonGroup 
 25  from pyanaconda.constants import * 
 26  from pyanaconda import upgrade 
 27  from pyanaconda.flags import flags 
 28   
 29  import gettext 
 30  _ = lambda x: gettext.ldgettext("anaconda", x) 
 31   
 32  UPGRADE_STR = "upgrade" 
 33  REINSTALL_STR = "reinstall" 
 34   
 35  seenExamineScreen = False 
 36   
37 -class UpgradeExamineWindow (InstallWindow):
38 39 windowTitle = N_("Upgrade Examine") 40
41 - def getNext (self):
42 if self.doupgrade: 43 upgrade.setSteps(self.anaconda) 44 self.anaconda.upgrade = True 45 46 rootfs = self.parts[self.upgradecombo.get_active()] 47 self.anaconda.upgradeRoot = [(rootfs[0], rootfs[1])] 48 self.anaconda.rootParts = self.parts 49 50 self.anaconda.upgrade = True 51 else: 52 self.anaconda.upgrade = False 53 self.anaconda.bootloader.skip_bootloader = False 54 55 return None
56
57 - def createUpgradeOption(self):
58 r = pixmapRadioButtonGroup() 59 r.addEntry(REINSTALL_STR, _("Fresh Installation"), 60 pixmap=gui.readImageFromFile("install.png"), 61 descr=_("Choose this option to install a fresh copy of %s " 62 "on your system. Existing software and data may " 63 "be overwritten depending on your configuration " 64 "choices.") % productName) 65 66 r.addEntry(UPGRADE_STR, _("Upgrade an Existing Installation"), 67 pixmap=gui.readImageFromFile("upgrade.png"), 68 descr=_("Choose this option if you would like to upgrade " 69 "your existing %s system. This option will " 70 "preserve the existing data on your storage " 71 "device(s).") % productName) 72 73 return r
74
75 - def upgradeOptionsSetSensitivity(self, state):
76 self.uplabel.set_sensitive(state) 77 self.upgradecombo.set_sensitive(state)
78
79 - def optionToggled(self, widget, name):
80 if name == UPGRADE_STR: 81 self.upgradeOptionsSetSensitivity(widget.get_active()) 82 self.doupgrade = widget.get_active()
83 84 #UpgradeExamineWindow tag = "upgrade"
85 - def getScreen (self, anaconda):
86 global seenExamineScreen 87 self.anaconda = anaconda 88 89 if anaconda.dir == DISPATCH_BACK: 90 # reset storage to catch any changes since we only reset when 91 # moving forward from autopart, not back. 92 # temporarily unset storage.config.clearPartType so that all devices will be 93 # found during storage reset 94 clearPartType = self.anaconda.storage.config.clearPartType 95 self.anaconda.storage.config.clearPartType = None 96 self.anaconda.storage.reset() 97 self.anaconda.storage.config.clearPartType = clearPartType 98 99 # we might get here after storage reset that obsoleted 100 # root device objects we had found 101 if not self.anaconda.rootParts: 102 (self.anaconda.rootParts, notUpgradable) = upgrade.findExistingRootDevices(self.anaconda, 103 flags.cmdline.has_key("upgradeany")) 104 upgrade.setUpgradeRoot(self.anaconda) 105 106 self.parts = self.anaconda.rootParts 107 108 if not seenExamineScreen: 109 # this is the first time we've entered this screen 110 self.doupgrade = self.anaconda.upgrade or bool(self.parts) 111 seenExamineScreen = True 112 else: 113 self.doupgrade = self.anaconda.upgrade 114 115 vbox = gtk.VBox (False, 12) 116 vbox.set_border_width (8) 117 118 introLabel = gtk.Label(_("At least one existing installation has been " 119 "detected on your system. What would you " 120 "like to do?")) 121 introLabel.set_alignment(0, 0) 122 vbox.pack_start(introLabel, False, False) 123 124 r = self.createUpgradeOption() 125 self.r = r 126 127 b = self.r.render() 128 if self.doupgrade: 129 self.r.setCurrent(UPGRADE_STR) 130 else: 131 self.r.setCurrent(REINSTALL_STR) 132 133 self.r.setToggleCallback(self.optionToggled) 134 vbox.pack_start(b, False) 135 self.root = self.parts[0] 136 137 uplabelstr = _("<b>Which %s installation would you like to upgrade?</b>") % productName 138 self.uplabel = gtk.Label(uplabelstr) 139 self.uplabel.set_use_markup(True) 140 self.uplabel.set_alignment(0, 0) 141 model = gtk.ListStore(str) 142 self.upgradecombo = gtk.ComboBox(model) 143 144 cell = gtk.CellRendererText() 145 self.upgradecombo.pack_start(cell, True) 146 self.upgradecombo.set_attributes(cell, markup=0) 147 148 for (dev, desc) in self.parts: 149 iter = model.append() 150 if (desc is None) or len(desc) < 1: 151 desc = _("Unknown Linux system") 152 model[iter][0] = "<small>%s <i>(installed on %s)</i></small>" %(desc, dev.path) 153 154 # hack hack hackity hack 155 alignment = gtk.Alignment(xalign=0.25) 156 alignmentBox = gtk.VBox(False, 6) 157 alignmentBox.pack_start(self.uplabel, False, False) 158 alignmentBox.pack_start(self.upgradecombo, False, False) 159 alignment.add(alignmentBox) 160 vbox.pack_start(alignment, True, True) 161 162 # set default 163 idx = 0 164 for p in self.parts: 165 if self.anaconda.upgradeRoot[0][0] == p[0]: 166 self.upgradecombo.set_active(idx) 167 break 168 idx = idx + 1 169 170 self.upgradeOptionsSetSensitivity(self.doupgrade) 171 172 return vbox
173