summaryrefslogtreecommitdiffstats
path: root/iw/partition_gui.py
blob: 0d31964ce0a05285e2a6ceb62640b4224183d88b (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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
#
# partition_gui.py: allows the user to choose how to partition their disks
#
# Copyright (C) 2001, 2002  Red Hat, Inc.  All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Author(s): Matt Wilson <msw@redhat.com>
#            Michael Fulbright <msf@redhat.com>
#

import gobject
import gtk
import gtk.glade
try:
    import gnomecanvas
except ImportError:
    import gnome.canvas as gnomecanvas
import pango
import gui
import parted
import string
import types

import storage
from iw_gui import *
from flags import flags

import lvm_dialog_gui
import raid_dialog_gui
import partition_dialog_gui

from partIntfHelpers import *
from constants import *
from partition_ui_helpers_gui import *
from storage.partitioning import doPartitioning
from storage.partitioning import hasFreeDiskSpace
from storage.devicelibs import lvm
from storage.devices import devicePathToName, PartitionDevice

import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)
P_ = lambda x, y, z: gettext.ldngettext("anaconda", x, y, z)

import logging
log = logging.getLogger("anaconda")

STRIPE_HEIGHT = 35.0
LOGICAL_INSET = 3.0
CANVAS_WIDTH_800 = 490
CANVAS_WIDTH_640 = 390
CANVAS_HEIGHT = 200
TREE_SPACING = 2

MODE_ADD = 1
MODE_EDIT = 2

class DiskStripeSlice:
    def eventHandler(self, widget, event):
        if event.type == gtk.gdk.BUTTON_PRESS:
            if event.button == 1:
                self.parent.selectSlice(self.partition, 1)
        elif event.type == gtk.gdk._2BUTTON_PRESS:
            self.editCB()
                
        return True

    def shutDown(self):
        self.parent = None
        if self.group:
            self.group.destroy()
            self.group = None
        del self.partedPartition
        del self.partition

    def select(self):
        if self.partedPartition.type != parted.PARTITION_EXTENDED:
            self.group.raise_to_top()
        self.box.set(outline_color="red")
        self.box.set(fill_color=self.selectColor())

    def deselect(self):
        self.box.set(outline_color="black", fill_color=self.fillColor())

    def getPartition(self):
        return self.partition

    def fillColor(self):
        if self.partedPartition.type & parted.PARTITION_FREESPACE:
            return "grey88"
        return "white"

    def selectColor(self):
        if self.partedPartition.type & parted.PARTITION_FREESPACE:
            return "cornsilk2"
        return "cornsilk1"

    def sliceText(self):
        if self.partedPartition.type & parted.PARTITION_EXTENDED:
            return ""
        if self.partedPartition.type & parted.PARTITION_FREESPACE:
            rc = "Free\n"
        else:
            rc = "%s\n" % (self.partedPartition.getDeviceNodeName().split("/")[-1],)
        rc = rc + "%Ld MB" % (self.partedPartition.getSize(unit="MB"),)
        return rc

    def update(self):
        disk = self.parent.getDisk()
        (cylinders, heads, sectors) = disk.device.biosGeometry
        totalSectors = float(heads * sectors * cylinders)

        # XXX hack but will work for now
        if gtk.gdk.screen_width() > 640:
            width = CANVAS_WIDTH_800
        else:
            width = CANVAS_WIDTH_640

        # If it's a very, very small partition then there's no point in trying
        # cut off a piece of the parent disk's stripe for it.
        if totalSectors == 0:
            return

        xoffset = self.partedPartition.geometry.start / totalSectors * width
        xlength = self.partedPartition.geometry.length / totalSectors * width

        if self.partedPartition.type & parted.PARTITION_LOGICAL:
            yoffset = 0.0 + LOGICAL_INSET
            yheight = STRIPE_HEIGHT - (LOGICAL_INSET * 2)
            texty = 0.0
        else:
            yoffset = 0.0
            yheight = STRIPE_HEIGHT
            texty = LOGICAL_INSET
        self.group.set(x=xoffset, y=yoffset)
        self.box.set(x1=0.0, y1=0.0, x2=xlength,
                     y2=yheight, fill_color=self.fillColor(),
                     outline_color='black', width_units=1.0)
        self.text.set(x=2.0, y=texty + 2.0, text=self.sliceText(),
                      fill_color='black',
                      anchor=gtk.ANCHOR_NW, clip=True,
                      clip_width=xlength-1, clip_height=yheight-1)
       
    def __init__(self, parent, partition, treeView, editCB):
        self.text = None
        self.partition = partition
        self.parent = parent
        self.treeView = treeView
        self.editCB = editCB
        pgroup = parent.getGroup()

        # Slices representing freespace are passed a pyparted object as
        # partition, not an anaconda storage object.  Therefore, they do
        # not have a partedPartition attribute.
        if self.partition and hasattr(self.partition, "partedPartition"):
            self.partedPartition = self.partition.partedPartition
        else:
            self.partedPartition = self.partition

        self.group = pgroup.add(gnomecanvas.CanvasGroup)
        self.box = self.group.add(gnomecanvas.CanvasRect)
        self.group.connect("event", self.eventHandler)
        self.text = self.group.add(gnomecanvas.CanvasText,
                                    font="sans", size_points=8)
        self.update()

class DiskStripe:
    def __init__(self, drive, disk, group, tree, editCB):
        self.disk = disk
        self.group = group
        self.tree = tree
        self.drive = drive
        self.slices = []
        self.hash = {}
        self.editCB = editCB
        self.selected = None

        # XXX hack but will work for now
        if gtk.gdk.screen_width() > 640:
            width = CANVAS_WIDTH_800
        else:
            width = CANVAS_WIDTH_640
        
        group.add(gnomecanvas.CanvasRect, x1=0.0, y1=10.0, x2=width,
                  y2=STRIPE_HEIGHT, fill_color='green',
                  outline_color='grey71', width_units=1.0)
        group.lower_to_bottom()

    def shutDown(self):
        while self.slices:
            slice = self.slices.pop()
            slice.shutDown()
        if self.group:
            self.group.destroy()
            self.group = None
        del self.disk

    def holds(self, partition):
        return self.hash.has_key(partition)

    def getSlice(self, partition):
        return self.hash[partition]
   
    def getDisk(self):
        return self.disk

    def getDrive(self):
        return self.drive

    def getGroup(self):
        return self.group

    def selectSlice(self, partition, updateTree=0):
        self.deselect()
        slice = self.hash[partition]
        slice.select()

        # update selection of the tree
        if updateTree:
            self.tree.selectPartition(partition)
        self.selected = slice

    def deselect(self):
        if self.selected:
            self.selected.deselect()
        self.selected = None
    
    def add(self, partition):
        stripe = DiskStripeSlice(self, partition, self.tree, self.editCB)
        self.slices.append(stripe)
        self.hash[partition] = stripe

class DiskStripeGraph:
    def __init__(self, tree, editCB):
        self.canvas = gnomecanvas.Canvas()
        self.diskStripes = []
        self.textlabels = []
        self.tree = tree
        self.editCB = editCB
        self.next_ypos = 0.0

    def __del__(self):
        self.shutDown()
        
    def shutDown(self):
        # remove any circular references so we can clean up
        while self.diskStripes:
            stripe = self.diskStripes.pop()
            stripe.shutDown()

        while self.textlabels:
            lab = self.textlabels.pop()
            lab.destroy()

        self.next_ypos = 0.0

    def getCanvas(self):
        return self.canvas

    def selectSlice(self, partition):
        for stripe in self.diskStripes:
            stripe.deselect()
            if stripe.holds(partition):
                stripe.selectSlice(partition)

    def getSlice(self, partition):
        for stripe in self.diskStripes:
            if stripe.holds(partition):
                return stripe.getSlice(partition)

    def getDisk(self, partition):
        for stripe in self.diskStripes:
            if stripe.holds(partition):
                return stripe.getDisk()

    def add(self, drive, disk):
        yoff = self.next_ypos
        text = self.canvas.root().add(gnomecanvas.CanvasText,
                                      x=0.0, y=yoff,
                                      font="sans",
                                      size_points=9)
        drivetext = _("Drive %s (%-0.f MB) "
                     "(Model: %s)") % ('/dev/' + drive,
                                       disk.device.getSize(unit="MB"),
                                       disk.device.model)

        text.set(text=drivetext, fill_color='black', anchor=gtk.ANCHOR_NW,
                 weight=pango.WEIGHT_BOLD)
        (xxx1, yyy1, xxx2, yyy2) =  text.get_bounds()
        textheight = yyy2 - yyy1 + 2
        self.textlabels.append(text)
        group = self.canvas.root().add(gnomecanvas.CanvasGroup,
                                       x=0, y=yoff+textheight)
        stripe = DiskStripe(drive, disk, group, self.tree, self.editCB)
        self.diskStripes.append(stripe)
        self.next_ypos = self.next_ypos + STRIPE_HEIGHT+textheight+10
        return stripe

class DiskTreeModelHelper:
    def __init__(self, model, columns, iter):
        self.model = model
        self.iter = iter
        self.columns = columns

    def __getitem__(self, key):
        if type(key) == types.StringType:
            key = self.columns[key]
        try:
            return self.model.get_value(self.iter, key)
        except:
            return None

    def __setitem__(self, key, value):
        if type(key) == types.StringType:
            key = self.columns[key]
        self.model.set_value(self.iter, key, value)

class DiskTreeModel(gtk.TreeStore):
    isLeaf = -3
    isFormattable = -2
    
    # format: column header, type, x alignment, hide?, visibleKey
    titles = ((N_("Device"), gobject.TYPE_STRING, 0.0, 0, 0),
              (N_("Label"), gobject.TYPE_STRING, 0.0, 1, 0),
              (N_("Size (MB)"), gobject.TYPE_STRING, 1.0, 0, 0),
              (N_("Mount Point"), gobject.TYPE_STRING, 0.0, 0, isLeaf),
              (N_("Type"), gobject.TYPE_STRING, 0.0, 0, 0),
              (N_("Format"), gobject.TYPE_OBJECT, 0.5, 0, isFormattable),
              ("", gobject.TYPE_STRING, 0.0, 0, 0),
              # the following must be the last two
              ("IsLeaf", gobject.TYPE_BOOLEAN, 0.0, 1, 0),
              ("IsFormattable", gobject.TYPE_BOOLEAN, 0.0, 1, 0),
              ("PyObject", gobject.TYPE_PYOBJECT, 0.0, 1, 0))
    
    def __init__(self):
	self.hiddenPartitions = []
        self.titleSlot = {}
        i = 0
        types = [self]
        self.columns = []
        for title, kind, alignment, hide, key in self.titles:
            self.titleSlot[title] = i
            types.append(kind)
            if hide:
                i += 1
                continue
            elif kind == gobject.TYPE_OBJECT:
                renderer = gtk.CellRendererPixbuf()
                propertyMapping = {'pixbuf': i}
            elif kind == gobject.TYPE_BOOLEAN:
                renderer = gtk.CellRendererToggle()
                propertyMapping = {'active': i}
            elif (kind == gobject.TYPE_STRING or
                  kind == gobject.TYPE_INT):
                renderer = gtk.CellRendererText()
		propertyMapping = {'text': i}

            # wire in the cells that we want only visible on leaf nodes to
            # the special leaf node column.
            if key < 0:
                propertyMapping['visible'] = len(self.titles) + key
                
            renderer.set_property('xalign', alignment)
	    if title == "Mount Point":
		title = _("Mount Point/\nRAID/Volume")
	    elif title == "Size (MB)":
		title = _("Size\n(MB)")
            elif title != "":
                title = _(title)
            col = apply(gtk.TreeViewColumn, (title, renderer),
                        propertyMapping)
	    col.set_alignment(0.5)
	    if kind == gobject.TYPE_STRING or kind == gobject.TYPE_INT:
		col.set_property('sizing', gtk.TREE_VIEW_COLUMN_AUTOSIZE)
            self.columns.append(col)
            i += 1

        apply(gtk.TreeStore.__init__, types)

        self.view = gtk.TreeView(self)
        # append all of the columns
        map(self.view.append_column, self.columns)

    def getTreeView(self):
        return self.view

    def clearHiddenPartitionsList(self):
	self.hiddenPartitions = []

    def appendToHiddenPartitionsList(self, member):
	self.hiddenPartitions.append(member)

    def selectPartition(self, partition):
	# if we've hidden this partition in the tree view just return
	if partition in self.hiddenPartitions:
	    return
	
        pyobject = self.titleSlot['PyObject']
        iter = self.get_iter_first()
	parentstack = [None,]
	parent = None
        # iterate over the list, looking for the current mouse selection
        while iter:
            try:
                rowpart = self.get_value(iter, pyobject)
            except SystemError:
                rowpart = None
            if rowpart == partition:
                path = self.get_path(parent)
                self.view.expand_row(path, True)
                selection = self.view.get_selection()
                if selection is not None:
                    selection.unselect_all()
                    selection.select_iter(iter)
                path = self.get_path(iter)
                col = self.view.get_column(0)
                self.view.set_cursor(path, col, False)
                self.view.scroll_to_cell(path, col, True, 0.5, 0.5)
                return
            # if this is a parent node, and it didn't point to the partition
            # we're looking for, get the first child and iter over them
            elif self.iter_has_child(iter):
                parent = iter
                parentstack.append(iter)
                iter = self.iter_children(iter)
                continue
            # get the next row.
            iter = self.iter_next(iter)
            # if there isn't a next row and we had a parent, go to the next
            # node after our parent
            while not iter and parent:
                # pop last parent off of parentstack and resume search at next
                # node after the last parent... and don't forget to update the
                # variable "parent" to its new value
                if len(parentstack) > 0:
                    iter = self.iter_next(parentstack.pop())
                    parent = parentstack[-1]
                else:
                    # we've fallen off the end of the model, and we have
                    # not found the partition
                    raise RuntimeError, "could not find partition"

    def getCurrentDevice(self):
        """ Return the device representing the current selection """
        selection = self.view.get_selection()
        model, iter = selection.get_selected()
        if not iter:
            return None

        pyobject = self.titleSlot['PyObject']
	try:
            val = self.get_value(iter, pyobject)
        except Exception:
            val = None

        return val

    def resetSelection(self):
        pass
##         selection = self.view.get_selection()
##         selection.set_mode(gtk.SELECTION_SINGLE)
##         selection.set_mode(gtk.SELECTION_BROWSE)

    def clear(self):
        selection = self.view.get_selection()
        if selection is not None:
            selection.unselect_all()
        gtk.TreeStore.clear(self)

    def __getitem__(self, iter):
        if type(iter) == gtk.TreeIter:
            return DiskTreeModelHelper(self, self.titleSlot, iter)
        raise KeyError, iter


class PartitionWindow(InstallWindow):
    def __init__(self, ics):
	InstallWindow.__init__(self, ics)
        ics.setTitle(_("Partitioning"))
        ics.setNextEnabled(True)
        self.parent = ics.getICW().window

    def quit(self):
        pass

    def presentPartitioningComments(self,title, labelstr1, labelstr2, comments,
				    type="ok", custom_buttons=None):

        if flags.autostep:
            return 1

        win = gtk.Dialog(title)
        gui.addFrame(win)
        
        if type == "ok":
            win.add_button('gtk-ok', 1)
	    defaultchoice = 0
        elif type == "yesno":
            win.add_button('gtk-no', 2)
            win.add_button('gtk-yes', 1)
	    defaultchoice = 1
	elif type == "continue":
            win.add_button('gtk-cancel', 0)
            win.add_button(_("Continue"), 1)
	    defaultchoice = 1
	elif type == "custom":
	    rid=0

	    for button in custom_buttons:
		widget = win.add_button(button, rid)
		rid = rid + 1

            defaultchoice = rid - 1
	    
        image = gtk.Image()
        image.set_from_stock('gtk-dialog-warning', gtk.ICON_SIZE_DIALOG)
        hbox = gtk.HBox(False, 9)
	al=gtk.Alignment(0.0, 0.0)
	al.add(image)
        hbox.pack_start(al, False)

        buffer = gtk.TextBuffer(None)
        buffer.set_text(comments)
        text = gtk.TextView()
        text.set_buffer(buffer)
        text.set_property("editable", False)
        text.set_property("cursor_visible", False)
        text.set_wrap_mode(gtk.WRAP_WORD)
        
        sw = gtk.ScrolledWindow()
        sw.add(text)
	sw.set_size_request(400, 200)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)
        
        info1 = gtk.Label(labelstr1)
        info1.set_line_wrap(True)
        info1.set_size_request(400, -1)

        info2 = gtk.Label(labelstr2)
        info2.set_line_wrap(True)
        info2.set_size_request(400, -1)
        
        vbox = gtk.VBox(False, 9)

	al=gtk.Alignment(0.0, 0.0)
	al.add(info1)
        vbox.pack_start(al, False)
	
        vbox.pack_start(sw, True, True)

	al=gtk.Alignment(0.0, 0.0)
	al.add(info2)
        vbox.pack_start(al, True)
	
        hbox.pack_start(vbox, True, True)

        win.vbox.pack_start(hbox)
        win.set_position(gtk.WIN_POS_CENTER)
        win.set_default_response(defaultchoice)
        win.show_all()
        rc = win.run()
        win.destroy()
        return rc
        
    def getNext(self):
        (errors, warnings) = self.storage.sanityCheck()
        if errors:
            labelstr1 =  _("The partitioning scheme you requested "
                           "caused the following critical errors.")
            labelstr2 = _("You must correct these errors before "
                          "you continue your installation of "
                          "%s.") % (productName,)

            commentstr = string.join(errors, "\n\n")
            
            self.presentPartitioningComments(_("Partitioning Errors"),
                                             labelstr1, labelstr2,
                                             commentstr, type="ok")
            raise gui.StayOnScreen
        
        if warnings:
            # "storage configuration"
            labelstr1 = _("The partitioning scheme you requested "
                          "generated the following warnings.")
            labelstr2 = _("Would you like to continue with "
                         "your requested partitioning "
                         "scheme?")
            
            commentstr = string.join(warnings, "\n\n")
            rc = self.presentPartitioningComments(_("Partitioning Warnings"),
                                                  labelstr1, labelstr2,
                                                  commentstr,
						  type="yesno")
            if rc != 1:
                raise gui.StayOnScreen

        formatWarnings = getPreExistFormatWarnings(self.storage)
        if formatWarnings:
            labelstr1 = _("The following pre-existing partitions have been "
                          "selected to be formatted, destroying all data.")

#            labelstr2 = _("Select 'Yes' to continue and format these "
#                          "partitions, or 'No' to go back and change these "
#                          "settings.")
            labelstr2 = ""
            commentstr = ""
            for (dev, type, mntpt) in formatWarnings:
                commentstr = commentstr + \
                        "%s         %s         %s\n" % (dev,type,mntpt)

            rc = self.presentPartitioningComments(_("Format Warnings"),
                                                  labelstr1, labelstr2,
                                                  commentstr,
						  type="custom",
						  custom_buttons=["gtk-cancel",
								  _("_Format")])
            if rc != 1:
                raise gui.StayOnScreen

        
        self.diskStripeGraph.shutDown()
        self.tree.clear()
        del self.parent
        return None

    def getPrev(self):
        self.diskStripeGraph.shutDown()
        self.storage.clearPartType = None
        self.storage.reset()
        self.tree.clear()
        del self.parent
        return None

    def populate(self, initial = 0):
        self.tree.resetSelection()

	self.tree.clearHiddenPartitionsList()

	# first do LVM
        vgs = self.storage.vgs
        if vgs:
	    lvmparent = self.tree.append(None)
	    self.tree[lvmparent]['Device'] = _("LVM Volume Groups")
            for vg in vgs:
		rsize = vg.size

                vgparent = self.tree.append(lvmparent)
		self.tree[vgparent]['Device'] = "%s" % vg.name
                self.tree[vgparent]['Label'] = ""
		self.tree[vgparent]['Mount Point'] = ""
		self.tree[vgparent]['Size (MB)'] = "%Ld" % (rsize,)
                self.tree[vgparent]['PyObject'] = vg
		for lv in vg.lvs:
                    if lv.format.type == "luks":
                        # we'll want to grab format info from the mapped
                        # device, not the encrypted one
                        try:
                            dm_dev = self.storage.devicetree.getChildren(lv)[0]
                        except IndexError:
                            format = lv.format
                        else:
                            format = dm_dev.format
                    else:
                        format = lv.format
		    iter = self.tree.append(vgparent)
		    self.tree[iter]['Device'] = lv.lvname
		    if format.mountable and format.mountpoint:
			self.tree[iter]['Mount Point'] = format.mountpoint
		    else:
			self.tree[iter]['Mount Point'] = ""
		    self.tree[iter]['Size (MB)'] = "%Ld" % lv.size
		    self.tree[iter]['PyObject'] = lv
		
                    if lv.format.type == "luks" and not lv.format.exists:
                        # we're creating the LUKS header
			self.tree[iter]['Format'] = self.lock_pixbuf
                    elif not format.exists:
                        # we're creating a format on the device
			self.tree[iter]['Format'] = self.checkmark_pixbuf
                    self.tree[iter]['IsFormattable'] = format.formattable
		    self.tree[iter]['IsLeaf'] = True
		    self.tree[iter]['Type'] = format.name
		    #self.tree[iter]['Start'] = ""
		    #self.tree[iter]['End'] = ""

        # handle RAID next
        mdarrays = self.storage.mdarrays
        if mdarrays:
	    raidparent = self.tree.append(None)
	    self.tree[raidparent]['Device'] = _("RAID Devices")
            for array in mdarrays:
		mntpt = None
                if array.format.type == "luks":
                    # look up the mapped/decrypted device since that's
                    # where we'll find the format we want to display
                    try:
                        dm_dev = self.storage.devicetree.getChildren(array)[0]
                    except IndexError:
                        format = array.format
                    else:
                        format = dm_dev.format
                else:
                    format = array.format

                if format.type == "lvmpv":
                    vg = None
		    for _vg in self.storage.vgs:
                        if _vg.dependsOn(array):
                            vg = _vg
                            break
                    if vg and self.show_uneditable:
                        mntpt = vg.name
                    elif vg:
                        self.tree.appendToHiddenPartitionsList(array.path)
                        continue
		    else:
			mntpt = ""
                elif format.mountable and format.mountpoint:
                    mntpt = format.mountpoint

                iter = self.tree.append(raidparent)
		if mntpt:
                    self.tree[iter]["Mount Point"] = mntpt
                else:
                    self.tree[iter]["Mount Point"] = ""
		    
                if format.type:
                    ptype = format.name
                    if array.format.type == "luks" and \
                       not array.format.exists:
			self.tree[iter]['Format'] = self.lock_pixbuf
                    elif not format.exists:
                        self.tree[iter]['Format'] = self.checkmark_pixbuf
                    self.tree[iter]['IsFormattable'] = format.formattable
                else:
                    ptype = _("Unknown")
                    self.tree[iter]['IsFormattable'] = False

		if array.minor is not None:
		    device = "%s" % array.path
		else:
		    device = "Auto"
		    
                self.tree[iter]['IsLeaf'] = True
                self.tree[iter]['Device'] = device
                if array.format.exists and getattr(format, "label", None):
                    self.tree[iter]['Label'] = "%s" % format.label
                else:
                    self.tree[iter]['Label'] = ""
                self.tree[iter]['Type'] = ptype
                self.tree[iter]['Size (MB)'] = "%Ld" % array.size
                self.tree[iter]['PyObject'] = array

	# now normal partitions
        disks = self.storage.disks
	drvparent = self.tree.append(None)
	self.tree[drvparent]['Device'] = _("Hard Drives")
        for disk in disks:
            # add a disk stripe to the graph
            stripe = self.diskStripeGraph.add(disk.name, disk.format.partedDisk)

            # add a parent node to the tree
            parent = self.tree.append(drvparent)
            self.tree[parent]['Device'] = "%s" % disk.path
            self.tree[parent]['PyObject'] = disk

            part = disk.format.firstPartition
            extendedParent = None
            while part:
                if part.type & parted.PARTITION_METADATA:
                    part = part.nextPartition()
                    continue

                partName = devicePathToName(part.getDeviceNodeName())
                device = self.storage.devicetree.getDeviceByName(partName)
                if not device and not part.type & parted.PARTITION_FREESPACE:
                    log.debug("can't find partition %s in device"
                                       " tree" % partName)

                # ignore the tiny < 1 MB partitions (#119479)
                if part.getSize(unit="MB") <= 1.0:
                    if not part.active or not device.bootable:
                        part = part.nextPartition()
                        continue

                # If this is a freespace "partition", there's no device so
                # don't add it.
                if device:
                    stripe.add(device)
                else:
                    stripe.add(part)

                if device and device.isExtended:
                    if extendedParent:
                        raise RuntimeError, ("can't handle more than "
                                             "one extended partition per disk")
                    extendedParent = self.tree.append(parent)
                    iter = extendedParent
                elif device and device.isLogical:
                    if not extendedParent:
                        raise RuntimeError, ("crossed logical partition "
                                             "before extended")
                    iter = self.tree.append(extendedParent)
                    self.tree[iter]['IsLeaf'] = True
                else:
                    iter = self.tree.append(parent)
                    self.tree[iter]['IsLeaf'] = True

                if device and device.format.type == "luks":
                    # look up the mapped/decrypted device in the tree
                    # the format we care about will be on it
                    try:
                        dm_dev = self.storage.devicetree.getChildren(device)[0]
                    except IndexError:
                        format = device.format
                    else:
                        format = dm_dev.format
                elif device:
                    format = device.format
                else:
                    format = None

                if format and format.mountable and format.mountpoint:
                    self.tree[iter]['Mount Point'] = format.mountpoint
                else:
                    self.tree[iter]['Mount Point'] = ""

		if format and format.type == "lvmpv":
		    vg = None
                    for _vg in self.storage.vgs:
                        if _vg.dependsOn(part):
                            vg = _vg
                            break
		    if vg and vg.name:
			if self.show_uneditable:
			    self.tree[iter]['Mount Point'] = vg.name
			else:
			    self.tree.appendToHiddenPartitionsList(part)
			    self.tree.remove(iter)
                            part = part.nextPartition()
			    continue
		    else:
			self.tree[iter]['Mount Point'] = ""

                if device and device.format and \
                   device.format.type == "luks" and \
                   not device.format.exists:
                    self.tree[iter]['Format'] = self.lock_pixbuf
                elif format and not format.exists:
                    self.tree[iter]['Format'] = self.checkmark_pixbuf
		
                if format and format.type:
                    self.tree[iter]['IsFormattable'] = device.format.formattable

                if device and device.isExtended:
                    ptype = _("Extended")
                elif format and format.type == "mdmember":
                    ptype = _("software RAID")
                    mds = self.storage.mdarrays
                    array = None
                    for _array in mds:
                        if _array.dependsOn(device):
                            array = _array
                            break
		    if array:
			if self.show_uneditable:
                            if array.minor is not None:
                                mddevice = "%s" % array.path
                            else:
                                mddevice = "Auto"
				mddevice = "Auto"
			    self.tree[iter]['Mount Point'] = mddevice
			else:
			    self.tree.appendToHiddenPartitionsList(part)
			    self.tree.remove(iter)
			    part = part.nextPartition()
			    continue
		    else:
			self.tree[iter]['Mount Point'] = ""

                    if device.format.type == "luks" and \
                       not device.format.exists:
			self.tree[iter]['Format'] = self.lock_pixbuf
                else:
                    if format and format.type:
                        ptype = format.name
                    else:
                        ptype = _("Unknown")
                if part.type & parted.PARTITION_FREESPACE:
                    devname = _("Free")
                    ptype = ""
                else:
                    devname = "%s" % device.path
                self.tree[iter]['Device'] = devname
                if format and format.exists and \
                   getattr(format, "label", None):
                    self.tree[iter]['Label'] = "%s" % format.label
                else:
                    self.tree[iter]['Label'] = ""

                self.tree[iter]['Type'] = ptype
                size = part.getSize(unit="MB")
                if size < 1.0:
                    sizestr = "< 1"
                else:
                    sizestr = "%Ld" % (size)
                self.tree[iter]['Size (MB)'] = sizestr
                self.tree[iter]['PyObject'] = device

                part = part.nextPartition()

        canvas = self.diskStripeGraph.getCanvas()
        apply(canvas.set_scroll_region, canvas.root().get_bounds())
        self.treeView.expand_all()

    def treeActivateCB(self, view, path, col):
        if isinstance(self.tree.getCurrentDevice(),
                      storage.devices.PartitionDevice):
            self.editCB()

    def treeSelectCB(self, selection, *args):
        model, iter = selection.get_selected()
        if not iter:
            return
        device = model[iter]['PyObject']
        if device:
            if not isinstance(device, PartitionDevice):
                return

            self.diskStripeGraph.selectSlice(device)

    def deleteCB(self, widget):
        """ Right now we can say that if the device is partitioned we
            want to delete all of the devices it contains. At some point
            we will want to support creation and removal of partitionable
            devices. This will need some work when that time comes.
        """
        device = self.tree.getCurrentDevice()
        if not device:
            return
        if device.format.type == "disklabel":
            if doClearPartitionedDevice(self.intf,
                                        self.storage,
                                        device):
                self.refresh()
        elif doDeleteDevice(self.intf,
                            self.storage,
                            device):
            if isinstance(device, storage.devices.DiskDevice) or \
               isinstance(device, storage.devices.PartitionDevice):
                justRedraw = False
            else:
                justRedraw = True
                if device.type == "lvmlv" and device in device.vg.lvs:
                    device.vg._removeLogVol(device)

            self.refresh(justRedraw=justRedraw)

    def createCB(self, *args):
        # First we must decide what parts of the create_storage_dialog
        # we will activate.

        # For the Partition checkboxes.
        # If we see that there is free space in the "Hard Drive" list, then we
        # must activate all the partition radio buttons (RAID partition,
        # LVM partition and Standard partition).  We will have only one var to
        # control all three activations (Since they all depend on the same
        # thing)
        activate_create_partition = False
        free_part_available = hasFreeDiskSpace(self.storage)
        if free_part_available:
            activate_create_partition = True

        # We activate the create Volume Group radio button if there is a free
        # partition with a Physical Volume format.
        activate_create_vg = False
        availpvs = len(self.storage.unusedPVs())
        if (lvm.has_lvm()
                and getFormat("lvmpv").supported
                and availpvs > 0):
            activate_create_vg = True

        # We activate the create RAID dev if there are partitions that have
        # raid format and are not related to any raid dev.
        activate_create_raid_dev = False
        availraidparts = len(self.storage.unusedMDMembers())
        availminors = self.storage.unusedMDMinors
        if (len(availminors) > 0
                and getFormat("software RAID").supported
                and availraidparts > 1):
            activate_create_raid_dev = True

        # FIXME: Why do I need availraidparts to clone?
        activate_create_raid_clone = False
        if (len(self.storage.disks) > 1
                and availraidparts > 0):
            activate_create_raid_clone = True

        # Must check if all the possibilities are False.  In this case tell the
        # user that he can't create anything and the reasons.
        if (not activate_create_partition
                and not activate_create_vg
                and not activate_create_raid_dev
                and not activate_create_raid_clone):
            self.intf.messageWindow(_("Cannot perform any creation action"),
                        _("Note that the creation action requires one of the "
                        "following:\n\n"
                        "* Free space in one of the Hard Drives.\n"
                        "* At least two free Software RAID partitions.\n"
                        "* At least one free physical volume (LVM) partition.\n"
                        "* At least one Volume Group with free space."),
                        custom_icon="warning")
            return

        # GTK crap starts here.
        create_storage_xml = gtk.glade.XML(
                gui.findGladeFile("create-storage.glade"), domain="anaconda")
        self.dialog = create_storage_xml.get_widget("create_storage_dialog")

        # Activate the partition radio buttons if needed.
        # sp_rb -> standard partition
        sp_rb = create_storage_xml.get_widget("create_storage_rb_standard_part")
        # lp_rb -> lvm partition (physical volume)
        lp_rb = create_storage_xml.get_widget("create_storage_rb_lvm_part")
        # rp_rb -> RAID partition
        rp_rb = create_storage_xml.get_widget("create_storage_rb_raid_part")
        if activate_create_partition:
            sp_rb.set_sensitive(True)
            lp_rb.set_sensitive(True)
            rp_rb.set_sensitive(True)

        # Activate the Volume Group radio buttons if needed.
        # vg_rb -> Volume Group
        vg_rb = create_storage_xml.get_widget("create_storage_rb_lvm_vg")
        if activate_create_vg:
            vg_rb.set_sensitive(True)

        # Activate the RAID dev if needed.
        # rd_rb -> RAID device
        rd_rb = create_storage_xml.get_widget("create_storage_rb_raid_dev")
        if activate_create_raid_dev:
            rd_rb.set_sensitive(True)

        # Activate RAID clone if needed.
        # rc_rb -> RAID clone
        rc_rb = create_storage_xml.get_widget("create_storage_rb_raid_clone")
        if activate_create_raid_clone:
            rc_rb.set_sensitive(True)

        # Before drawing lets select the first radio button that is sensitive:
        # How can I get sensitivity from gtk.radiobutton?
        if activate_create_partition:
            sp_rb.set_active(True)
        elif activate_create_vg:
            vg_rb.set_active(True)
        elif activate_create_raid_dev:
            rd_rb.set_active(True)
        elif activate_create_raid_clone:
            rc_rb.set_active(True)

        gui.addFrame(self.dialog)
        self.dialog.show_all()

        # Lets work the information messages with CB
        # The RAID info message
        rinfo_button = create_storage_xml.get_widget("create_storage_info_raid")
        whatis_r = _("Software RAID allows you to combine several disks into "
                    "a larger RAID device.  A RAID device can be configured "
                    "to provide additional speed and reliability compared "
                    "to using an individual drive.  For more information on "
                    "using RAID devices please consult the %s "
                    "documentation.\n") % (productName,)
        whatneed_r = _("To use RAID you must first create at least two "
                "partitions of type 'software RAID'.  Then you can create a "
                "RAID device that can be formatted and mounted.\n\n")
        whathave_r = P_(
                "You currently have %d software RAID partition free to use.",
                "You currently have %d software RAID partitions free to use.",
                availraidparts) % (availraidparts,)
        rinfo_message = "%s\n%s%s" % (whatis_r, whatneed_r, whathave_r)
        rinfo_cb = lambda x : self.intf.messageWindow(_("About RAID"),
                                rinfo_message, custom_icon="information")
        rinfo_button.connect("clicked", rinfo_cb)

        # The LVM info message
        lvminfo_button = create_storage_xml.get_widget("create_storage_info_lvm")
        whatis_lvm = _("Logical Volume Manager (LVM) is a 3 level construct. "
                "The fist level is made up of disks or partitions formated with "
                "LVM metadata called Physical Volumes (PV).  A Volume Group "
                "(VG) sits on top of one or more PVs. The VG, in turn, is the "
                "base to creat one ore more Logical Volumes (LV).  Note that a "
                "VG can be an aggregate of PVs from multiple physical disk.  For "
                "more information on using LVM please consult the %s "
                "documentation\n") % (productName, )
        whatneed_lvm = _("To create a PV you need a partition with "
                "free space.  To create a VG you need a PV that is not "
                "part of any existing VG.  To create a LV you need a VG with "
                "free space.\n\n")
        whathave_lvm = P_("You currently have %d available PV free to use.\n",
                            "You currently have %d available PVs free to use.\n",
                            availpvs) % (availpvs, )
        if free_part_available:
            whathave_lvm = whathave_lvm + _("You currently have free space to "
                    "create PVs.")
        lvminfo_message = "%s\n%s%s" % (whatis_lvm, whatneed_lvm, whathave_lvm)
        lvminfo_cb = lambda x : self.intf.messageWindow(_("About LVM"),
                                    lvminfo_message, custom_icon="information")
        lvminfo_button.connect("clicked", lvminfo_cb)

        dialog_rc = self.dialog.run()

        # If Cancel was pressed
        if dialog_rc == 0:
            self.dialog.destroy()
            return

        # If Create was pressed  Make sure we do a dialog.destroy before
        # calling any other screen.  We don't want the create dialog to show
        # in the back when we pop up other screens.
        if dialog_rc != 1:
            log.error("I received a dialog_rc != 1 (%d) witch should not "
                    "happen" % rc)
            self.dialog.destroy()
            return

        self.dialog.destroy()
        if rp_rb.get_active():
            member = self.storage.newPartition(fmt_type="software RAID",
                                               size=200)
            self.editPartition(member, isNew = 1, restrictfs=["mdmember"])
            return

        elif rc_rb.get_active():
            cloneDialog = raid_dialog_gui.RaidCloneDialog(self.storage,
                                                          self.intf,
                                                          self.parent)
            if cloneDialog is None:
                self.intf.messageWindow(_("Couldn't Create Drive Clone Editor"),
                                        _("The drive clone editor could not "
                                          "be created for some reason."),
                                        custom_icon="error")
                return

            if cloneDialog.run():
                self.refresh()

            cloneDialog.destroy()
            return

        elif rd_rb.get_active():
            array = self.storage.newMDArray(fmt_type=self.storage.defaultFSType)
            self.editRaidArray(array, isNew=1)
            return

        elif lp_rb.get_active():
            member = self.storage.newPartition(fmt_type="physical volume (LVM)",
                                               size=200)
            self.editPartition(member, isNew = 1, restrictfs=["lvmpv"])
            return

        elif vg_rb.get_active():
            tempvg = self.storage.newVG()
            self.editLVMVolumeGroup(tempvg, isNew = 1)
            return

        elif sp_rb.get_active():
            tempformat = self.storage.defaultFSType
            device = self.storage.newPartition(fmt_type=tempformat, size=200)
            self.editPartition(device, isNew=1)
            return

    def resetCB(self, *args):
        if not confirmResetPartitionState(self.intf):
            return
        
        self.diskStripeGraph.shutDown()
        self.storage.reset()
        self.tree.clear()
        self.populate()

    def refresh(self, justRedraw=None):
        log.debug("refresh: justRedraw=%s" % justRedraw)
        self.diskStripeGraph.shutDown()
        self.tree.clear()

        if justRedraw:
            rc = 0
        else:
            try:
                doPartitioning(self.storage)
                rc = 0
            except PartitioningError, msg:
                self.intf.messageWindow(_("Error Partitioning"),
                       _("Could not allocate requested partitions: %s.") % (msg),
                                        custom_icon="error")
                rc = -1
            except PartitioningWarning, msg:
                # XXX somebody other than me should make this look better
                # XXX this doesn't handle the 'delete /boot partition spec' case
                #     (it says 'add anyway')
                dialog = gtk.MessageDialog(self.parent, 0, gtk.MESSAGE_WARNING,
                                           gtk.BUTTONS_NONE,
                                           _("Warning: %s.") % (msg))
                gui.addFrame(dialog)
                button = gtk.Button(_("_Modify Partition"))
                dialog.add_action_widget(button, 1)
                button = gtk.Button(_("_Continue"))
                dialog.add_action_widget(button, 2)
                dialog.set_position(gtk.WIN_POS_CENTER)

                dialog.show_all()
                rc = dialog.run()
                dialog.destroy()
                
                if rc == 1:
                    rc = -1
                else:
                    rc = 0
                    all_devices = self.storage.devicetree.devices
                    bootDevs = [d for d in all_devices if d.bootable]
                    #if reqs:
                    #    for req in reqs:
                    #        req.ignoreBootConstraints = 1

	if not rc == -1:
	    self.populate()

        return rc

    def editCB(self, *args):
        device = self.tree.getCurrentDevice()
        if not device:
            self.intf.messageWindow(_("Unable To Edit"),
                               _("You must select a device to edit"),
                               custom_icon="error")
            return

        reason = self.storage.deviceImmutable(device, ignoreProtected=True)
        if reason:
            self.intf.messageWindow(_("Unable To Edit"),
                                    _("You cannot edit this device:\n\n%s")
                                    % reason,
                                    custom_icon="error")
            return

        if device.type == "mdarray":
            self.editRaidArray(device)
        elif device.type == "lvmvg":
            self.editLVMVolumeGroup(device)
        elif device.type == "lvmlv":
            self.editLVMLogicalVolume(device)
        elif isinstance(device, storage.devices.PartitionDevice):
            self.editPartition(device)

    # isNew implies that this request has never been successfully used before
    def editRaidArray(self, raiddev, isNew = 0):
	raideditor = raid_dialog_gui.RaidEditor(self.storage,
						self.intf,
						self.parent,
                                                raiddev,
						isNew)
	
	while 1:
	    actions = raideditor.run()

            for action in actions:
                # FIXME: this needs to handle exceptions
                self.storage.devicetree.registerAction(action)

	    if self.refresh(justRedraw=True):
                actions.reverse()
                for action in actions:
                    self.storage.devicetree.cancelAction(action)
                    if self.refresh():
                        raise RuntimeError, ("Returning partitions to state "
                                             "prior to RAID edit failed")
                continue
	    else:
		break

	raideditor.destroy()		


    def editPartition(self, device, isNew = 0, restrictfs = None):
	parteditor = partition_dialog_gui.PartitionEditor(self.anaconda,
							  self.parent,
							  device,
							  isNew = isNew,
                                                          restrictfs = restrictfs)

	while 1:
	    actions = parteditor.run()

            for action in actions:
                # XXX we should handle exceptions here
                self.anaconda.id.storage.devicetree.registerAction(action)

            if self.refresh(justRedraw=not actions):
                # autopart failed -- cancel the actions and try to get
                # back to previous state
                actions.reverse()
                for action in actions:
                    self.anaconda.id.storage.devicetree.cancelAction(action)

                if self.refresh():
                    # this worked before and doesn't now...
                    raise RuntimeError, ("Returning partitions to state "
                                         "prior to edit failed")
            else:
		break

	parteditor.destroy()
	return 1

    def editLVMVolumeGroup(self, device, isNew = 0):
        # we don't really need to pass in self.storage if we're passing
        # self.anaconda already
        vgeditor = lvm_dialog_gui.VolumeGroupEditor(self.anaconda,
                                                    self.intf,
                                                    self.parent,
                                                    device,
                                                    isNew)
	
	while True:
	    actions = vgeditor.run()

            for action in actions:
                # FIXME: handle exceptions
                self.storage.devicetree.registerAction(action)

	    if self.refresh(justRedraw=True):
                actions.reverse()
                for action in actions:
                    self.storage.devicetree.cancelAction(action)

                if self.refresh():
                    raise RuntimeError, ("Returning partitions to state "
                                         "prior to edit failed")
		continue
	    else:
		break

	vgeditor.destroy()

    def editLVMLogicalVolume (self, device):
        vgeditor = lvm_dialog_gui.VolumeGroupEditor(self.anaconda,
                                                    self.intf,
                                                    self.parent,
                                                    device.vg,
                                                    isNew = False)
        while True:
            lv = vgeditor.lvs[device.lvname]
            vgeditor.editLogicalVolume(lv)
            actions = vgeditor.convertToActions();

            for action in actions:
                # FIXME: handle exceptions
                self.storage.devicetree.registerAction(action)

            if self.refresh(justRedraw=True):
                actions.reverse()
                for action in actions:
                    self.storage.devicetree.cancelAction(action)

                if self.refresh():
                    raise RuntimeError, ("Returning partitions to state "
                                         "prior to edit failed")
                continue
            else:
                break

        vgeditor.destroy()

    def viewButtonCB(self, widget):
	self.show_uneditable = not widget.get_active()
        self.diskStripeGraph.shutDown()
	self.tree.clear()
	self.populate()

    def getScreen(self, anaconda):
        self.anaconda = anaconda
        self.storage = anaconda.id.storage
        self.intf = anaconda.intf
        
	self.show_uneditable = 1

        checkForSwapNoMatch(anaconda)

        # load up checkmark & lock
        self.checkmark_pixbuf = gui.getPixbuf("checkMark.png")
        self.lock_pixbuf = gui.getPixbuf("gnome-lock.png")

        # operational buttons
        buttonBox = gtk.HButtonBox()
        buttonBox.set_spacing(6)
        buttonBox.set_layout(gtk.BUTTONBOX_END)

        ops = ((_("_Create"), self.createCB),
               (_("_Edit"), self.editCB),
               (_("_Delete"), self.deleteCB),
               (_("Re_set"), self.resetCB))

        for label, cb in ops:
            button = gtk.Button(label)
            buttonBox.add (button)
            button.connect ("clicked", cb)

        self.tree = DiskTreeModel()
        self.treeView = self.tree.getTreeView()
        self.treeView.connect('row-activated', self.treeActivateCB)
        self.treeViewSelection = self.treeView.get_selection()
        self.treeViewSelection.connect("changed", self.treeSelectCB)

        # set up the canvas
        self.diskStripeGraph = DiskStripeGraph(self.tree, self.editCB)
        
        # do the initial population of the tree and the graph
        self.populate(initial = 1)

	vpaned = gtk.VPaned()

        hadj = gtk.Adjustment(step_incr = 5.0)
        vadj = gtk.Adjustment(step_incr = 5.0)
        sw = gtk.ScrolledWindow(hadjustment = hadj, vadjustment = vadj)
        sw.add(self.diskStripeGraph.getCanvas())
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)
            
        frame = gtk.Frame()
        frame.add(sw)
	vpaned.add1(frame)

        box = gtk.VBox(False, 5)
        sw = gtk.ScrolledWindow()
        sw.add(self.treeView)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
	sw.set_shadow_type(gtk.SHADOW_IN)
	
        box.pack_start(sw, True)

	self.toggleViewButton = gtk.CheckButton(_("Hide RAID device/LVM Volume _Group members"))
	self.toggleViewButton.set_active(not self.show_uneditable)
	self.toggleViewButton.connect("toggled", self.viewButtonCB)
	box.pack_start(self.toggleViewButton, False, False)
        box.pack_start(buttonBox, False)
        box.pack_start(gtk.HSeparator(), False)

	vpaned.add2(box)

	# XXX should probably be set according to height 
	vpaned.set_position(175)

	return vpaned