summaryrefslogtreecommitdiffstats
path: root/iw/fdisk.py
blob: 546377dc0820226f1cf5b79d00a7cc8f1db3e9c8 (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
from gtk import *
from iw import *
from gnome.zvt import *
from os import execvp
from gui import _

class FDiskWindow (InstallWindow):		

    def __init__ (self, ics):
	InstallWindow.__init__ (self, ics)
        ics.setTitle (_("fdisk"))

    def child_died (self, widget, button):
        self.windowContainer.remove (self.windowContainer.children ()[0])
        self.windowContainer.pack_start (self.buttonBox)
        button.set_state (STATE_NORMAL)
        
        self.ics.setPrevEnabled (1)
        self.ics.setNextEnabled (1)
        self.ics.setHelpEnabled (1)

    def button_clicked (self, widget, drive):
        zvt = ZvtTerm (80, 24)
        zvt.connect ("child_died", self.child_died, widget)
        if zvt.forkpty() == 0:
           execvp ("/sbin/fdisk", ("/sbin/fdisk", "/dev/%s" % (drive,)))
        zvt.show ()

        self.windowContainer.remove (self.buttonBox)
        self.windowContainer.pack_start (zvt)

        self.ics.setHelpEnabled (0)
	self.ics.setPrevEnabled (0)
        self.ics.setNextEnabled (0)


    def getScreen (self):
        self.windowContainer = GtkVBox (FALSE)
        self.buttonBox = GtkVBox (FALSE, 5)
        self.buttonBox.set_border_width (5)
        box = GtkVButtonBox ()
        label = GtkLabel (_("Select drive to run fdisk on"))

        drives = self.todo.drives.available ().keys ()
        drives.sort ()
        for drive in drives:
            button = GtkButton (drive)
            button.connect ("clicked", self.button_clicked, drive)
            box.add (button)

        self.buttonBox.pack_start (label, FALSE)
        self.buttonBox.pack_start (box, FALSE)
        self.windowContainer.pack_start (self.buttonBox)

        return self.windowContainer