summaryrefslogtreecommitdiffstats
path: root/iw/rootpartition.py
blob: f0e20f4f760e04870722a3f6f55e566c361e5868 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
from gtk import *
from iw import *
from thread import *
import isys
from gui import _
from fdisk import *
import isys

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

        self.todo = ics.getToDo ()
        ics.setTitle (_("Confirm Partitioning Selection"))
        ics.readHTML ("partition")
	ics.setNextEnabled (TRUE)
        
    def getScreen (self):
        return self.window

    def getPrev (self):
        return PartitionWindow

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

        self.todo = ics.getToDo ()
        ics.setTitle (_("Disk Druid"))
        ics.readHTML ("partition")
	ics.setNextEnabled (FALSE)
	self.skippedScreen = 0

    def getNext (self):
        from installpath import InstallPathWindow
        if InstallPathWindow.fdisk and InstallPathWindow.fdisk.get_active ():
            return FDiskWindow
        
	self.todo.ddruid.next ()
        
	if not self.skippedScreen:
	    win = self.todo.ddruid.getConfirm ()
	    if win:
		bin = GtkFrame (None, _obj = win)
		bin.set_shadow_type (SHADOW_NONE)
		window = ConfirmPartitionWindow
		window.window = bin
		return window

        fstab = self.todo.ddruid.getFstab ()
        for (partition, mount, fsystem, size) in fstab:
            self.todo.addMount(partition, mount, fsystem)

        (drives, raid) = self.todo.ddruid.partitionList()

	for (mount, device, type, other) in raid:
	    self.todo.addMount(device, mount, "ext2")

        return None

    def enableCallback (self, value):
        self.ics.setNextEnabled (value)

    def getScreen (self):
        from installpath import InstallPathWindow

	if InstallPathWindow.fdisk and InstallPathWindow.fdisk.get_active ():
            return None

        self.todo.ddruid.setCallback (self.enableCallback)

	if self.skippedScreen:
	    # if we skipped it once, skip it again
	    return None

	if self.todo.getSkipPartitioning():
	    self.skippedScreen = 1
	    return None

        self.bin = GtkFrame (None, _obj = self.todo.ddruid.getWindow ())
        self.bin.set_shadow_type (SHADOW_NONE)
        self.todo.ddruid.edit ()
        
        return self.bin

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

        self.todo = ics.getToDo ()
        ics.setTitle (_("Automatic Partitioning"))
	ics.setNextEnabled (TRUE)
        self.ics = ics

    def getNext(self):
        from gnomepyfsedit import fsedit

	if (self.__dict__.has_key("manuallyPartition") and   
		self.manuallyPartition.get_active()):
            drives = self.todo.drives.available ().keys ()
            drives.sort (isys.compareDrives)
            self.todo.ddruid = fsedit(0, drives, self.fstab, self.todo.zeroMbr)
	    self.todo.manuallyPartition()
	    
	return None

    def getScreen (self):   
        from gnomepyfsedit import fsedit
        
        # XXX hack
        if self.todo.instClass.clearType:
            self.ics.readHTML (self.todo.instClass.clearType)

	todo = self.todo

        self.fstab = []
        for mntpoint, (dev, fstype, reformat) in todo.mounts.items ():
            self.fstab.append ((dev, mntpoint))

        if not todo.ddruid:
            drives = todo.drives.available ().keys ()
            drives.sort (isys.compareDrives)
            todo.ddruid = fsedit(0, drives, self.fstab, self.todo.zeroMbr)
	    todo.instClass.finishPartitioning(todo.ddruid)

	if not todo.getPartitionWarningText(): 
	    return None

	label = GtkLabel(
	    _("%s\n\nIf you don't want to do this, you can continue with "
	      "this install by partitioning manually, or you can go back "
	      "and perform a fully customized installation.") % 
		    (todo.getPartitionWarningText(), ))
	label.set_line_wrap(TRUE)
	label.set_alignment(0.0, 0.0)
	label.set_usize(400, -1)

        box = GtkVBox (FALSE)
	box.pack_start(label, FALSE)

        radioBox = GtkVBox (FALSE)
	self.continueChoice = GtkRadioButton (None, _("Remove data"))
	radioBox.pack_start(self.continueChoice, FALSE)
	self.manuallyPartition = GtkRadioButton(
		self.continueChoice, _("Manually partition"))
	radioBox.pack_start(self.manuallyPartition, FALSE)

	align = GtkAlignment()
	align.add(radioBox)
	align.set(0.5, 0.5, 0.0, 0.0)

	box.pack_start(align, TRUE, TRUE)

	return box