summaryrefslogtreecommitdiffstats
path: root/text.py
blob: e47e026943136fa888746eeb272f810c85678cca (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
from snack import *
import _balkan
import sys

class WelcomeWindow:
    def run(self, screen):
        ButtonChoiceWindow(screen, "Red Hat Linux", 
		"Welcome to Red Hat Linux!\n\n"
            "This installation process is outlined in detail in the "
	    "Official Red Hat Linux Installation Guide available from "
	    "Red Hat Software. If you have access to this manual, you "
	    "should read the installation section before continuing.\n\n"
	    "If you have purchased Official Red Hat Linux, be sure to "
	    "register your purchase through our web site, "
	    "http://www.redhat.com/.", buttons = ['Ok'])
        return 0

class InstallProgressWindow:

    def setPackageScale(self, amount, total):
	self.s.set(int(((amount * 1.0)/ total) * 100))
	self.g.draw()
	self.screen.refresh()

    def setPackage(self, name):
	self.l.setText('Package: ' + name)
	self.g.draw()
	self.screen.refresh()

    def __del__(self):
	self.screen.popWindow()
	self.screen.refresh()

    def __init__(self, screen):
	self.screen = screen
	self.l = Label('Package:                                  ')
	self.s = Scale(50, 100)
	g = GridForm(self.screen, 'Installing Packages', 1, 2)
	g.add(self.l, 0, 0)
	g.add(self.s, 0, 1)
	g.draw()
	self.g = g
	screen.refresh()

class PartitionWindow:
    def run(self, screen, todo):
	if (not todo.setupFilesystems): return -2

        device = 'hda';

	table = _balkan.readTable('/dev/' + device)
	partList = []
	for i in range(0, len(table) - 1):
	    (type, start, size) = table[i]
	    if (type == 0x83 and size):
		fullName = '/dev/%s%d' % (device, i + 1)
		partList.append((fullName, fullName))

	rc = ListboxChoiceWindow(screen, 'Root Partition',
				 'What partition would you '
				 'like to use for your root partition?',
				 partList, buttons = ['Ok', 'Back'])

	if rc[0] == 'back':
	    return -1

	todo.addMount(rc[1], '/')

        return 0

class WaitWindow:

    def pop(self):
	self.screen.popWindow()
	self.screen.refresh()

    def __init__(self, screen, title, text):
	self.screen = screen
	width = 40
	if (len(text) < width): width = len(text)

	t = TextboxReflowed(width, text)

	g = GridForm(self.screen, title, 1, 1)
	g.add(t, 0, 0)
	g.draw()
	self.screen.refresh()

class InstallInterface:

    def waitWindow(self, title, text):
	return WaitWindow(self.screen, title, text)

    def packageProgessWindow(self):
	return InstallProgressWindow(self.screen)

    def __init__(self):
        self.screen = SnackScreen()
	#self.screen.suspendCallback(killSelf, self)

    def __del__(self):
        self.screen.finish()

    def run(self, todo):
        steps = [
            ["Welcome", WelcomeWindow, (self.screen,)],
            ["Partition", PartitionWindow, (self.screen, todo)]
        ]

        step = 0
	dir = 0
        while step >= 0 and step < len(steps) and steps[step]:
            rc =  apply(steps[step][1]().run, steps[step][2])
	    if rc == -1:
		dir = -1
            else:
		dir = 1
	    step = step + dir

	todo.liloLocation("/dev/hda")

def killSelf(screen):
    print "HERE"
    del screen
    sys.exit(0)