[PATCH 2/2] Fix partition editor window for regular partitions (#491675)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The format check mark now reflects what will happen.  Correct some
problems with the UI elements in the partition editor window.
---
 iw/partition_dialog_gui.py     |   12 +++---
 iw/partition_gui.py            |   14 +++---
 iw/partition_ui_helpers_gui.py |   92 +++++++++++++++++++++++----------------
 3 files changed, 67 insertions(+), 51 deletions(-)

diff --git a/iw/partition_dialog_gui.py b/iw/partition_dialog_gui.py
index bb4a730..96ca9b6 100644
--- a/iw/partition_dialog_gui.py
+++ b/iw/partition_dialog_gui.py
@@ -215,10 +215,12 @@ class PartitionEditor:
                 request = self.origrequest
                 mountpoint = self.mountCombo.get_children()[0].get_text()
 
-                if self.fsoptionsDict.has_key("formatcb") and \
-                   self.fsoptionsDict["formatcb"].get_active():
+                if request.format.wantFormat:
                     fmt_class = self.fsoptionsDict["fstypeCombo"].get_active_value()
                     format = fmt_class(mountpoint=mountpoint)
+                    format.wantFormat = request.format.wantFormat
+                    format.exists = request.format.exists
+                    format.device = request.format.device
                     luksdev = None
                     if self.fsoptionsDict.has_key("lukscb") and \
                        self.fsoptionsDict["lukscb"].get_active() and \
@@ -239,12 +241,10 @@ class PartitionEditor:
                 request.weight = self.anaconda.platform.weight(mountpoint=mountpoint,
                                                                fstype=request.format.type)
 
-                if self.fsoptionsDict.has_key("migratecb") and \
-                   self.fsoptionsDict["migratecb"].get_active():
+                if request.format.wantMigrate:
                     actions.append(ActionMigrateFormat(request))
 
-                if self.fsoptionsDict.has_key("resizecb") and \
-                   self.fsoptionsDict["resizecb"].get_active():
+                if request.format.wantResize:
                     size = self.fsoptionsDict["resizesb"].get_value_as_int()
 
                     try:
diff --git a/iw/partition_gui.py b/iw/partition_gui.py
index 6ce1b11..eaf0f87 100644
--- a/iw/partition_gui.py
+++ b/iw/partition_gui.py
@@ -714,10 +714,10 @@ class PartitionWindow(InstallWindow):
 		    self.tree[iter]['Size (MB)'] = "%Ld" % lv.size
 		    self.tree[iter]['PyObject'] = vg
 		
-                    if lv.format.type == "luks" and not lv.format.exists:
+                    if format.type == "luks" and not format.wantFormat:
                         # we're creating the LUKS header
 			self.tree[iter]['Format'] = self.lock_pixbuf
-                    elif not format.exists:
+                    elif format.wantFormat:
                         # we're creating a format on the device
 			self.tree[iter]['Format'] = self.checkmark_pixbuf
                     self.tree[iter]['IsFormattable'] = format.formattable
@@ -770,9 +770,9 @@ class PartitionWindow(InstallWindow):
                 if format.type:
                     ptype = format.name
                     if array.format.type == "luks" and \
-                       not array.format.exists:
+                       array.format.wantFormat:
 			self.tree[iter]['Format'] = self.lock_pixbuf
-                    elif not format.exists:
+                    elif format.wantFormat:
                         self.tree[iter]['Format'] = self.checkmark_pixbuf
                     self.tree[iter]['IsFormattable'] = format.formattable
                 else:
@@ -883,9 +883,9 @@ class PartitionWindow(InstallWindow):
 
                 if device and device.format and \
                    device.format.type == "luks" and \
-                   not device.format.exists:
+                   device.format.wantFormat:
                     self.tree[iter]['Format'] = self.lock_pixbuf
-                elif format and not format.exists:
+                elif format and format.wantFormat:
                     self.tree[iter]['Format'] = self.checkmark_pixbuf
 		
                 if format and format.type:
@@ -918,7 +918,7 @@ class PartitionWindow(InstallWindow):
 			self.tree[iter]['Mount Point'] = ""
 
                     if device.format.type == "luks" and \
-                       not device.format.exists:
+                       device.format.wantFormat:
 			self.tree[iter]['Format'] = self.lock_pixbuf
                 else:
                     if format and format.type:
diff --git a/iw/partition_ui_helpers_gui.py b/iw/partition_ui_helpers_gui.py
index ede0200..20fdaba 100644
--- a/iw/partition_ui_helpers_gui.py
+++ b/iw/partition_ui_helpers_gui.py
@@ -35,6 +35,9 @@ from storage.formats import *
 import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
 
+FLAG_FORMAT = 1
+FLAG_MIGRATE = 2
+
 class WideCheckList(checklist.CheckList):
     def toggled_item(self, data, row):
 
@@ -231,7 +234,10 @@ def mountptchangeCB(widget, fstypecombo):
 def resizeOptionCB(widget, resizesb):
     resizesb.set_sensitive(widget.get_active())
 
-def formatOptionResizeCB(widget, resizesb):
+def formatOptionResizeCB(widget, data):
+    (resizesb, format) = data
+    format.wantResize = widget.get_active()
+
     if widget.get_active():
         lower = 1
     else:
@@ -249,9 +255,16 @@ def formatMigrateOptionCB(widget, data):
     if not sensitive:
         return
 
-    (combowidget, mntptcombo, ofstype, lukscb, othercombo, othercb) = data
+    (combowidget, mntptcombo, format, lukscb, othercombo, othercb, flag) = data
     combowidget.set_sensitive(widget.get_active())
 
+    if flag == FLAG_FORMAT:
+        format.wantFormat = widget.get_active()
+        format.wantMigrate = False
+    elif flag == FLAG_MIGRATE:
+        format.wantFormat = False
+        format.wantMigrate = widget.get_active()
+
     if othercb is not None:
         othercb.set_sensitive(not widget.get_active())
         othercb.set_active(False)
@@ -264,9 +277,9 @@ def formatMigrateOptionCB(widget, data):
         if not widget.get_active():
             # set "Encrypt" checkbutton to match partition's initial state
             lukscb.set_active(lukscb.get_data("encrypted"))
-            lukscb.set_sensitive(0)
+            lukscb.set_sensitive(False)
         else:
-            lukscb.set_sensitive(1)
+            lukscb.set_sensitive(True)
 
     # inject event for fstype menu
     if widget.get_active():
@@ -274,10 +287,10 @@ def formatMigrateOptionCB(widget, data):
         setMntPtComboStateFromType(fstype, mntptcombo)
         combowidget.grab_focus()
     else:
-        if isinstance(ofstype, type(ofstype)):
-            ofstype = type(ofstype)
+        if isinstance(format, type(format)):
+            format = type(format)
 
-        setMntPtComboStateFromType(ofstype, mntptcombo)
+        setMntPtComboStateFromType(format, mntptcombo)
 
 
 """ createPreExistFSOptionSection: given inputs for a preexisting partition,
@@ -303,55 +316,58 @@ def createPreExistFSOptionSection(origrequest, maintable, row, mountCombo,
     else:
         origfs = origrequest.format
 
-    formatcb = gtk.CheckButton(label=_("_Format as:"))
-    maintable.attach(formatcb, 0, 1, row, row + 1)
-    formatcb.set_active(not origfs.exists)
-    rc["formatcb"] = formatcb
-
-    fstypeCombo = createFSTypeMenu(origfs, fstypechangeCB,
-                                   mountCombo, ignorefs=ignorefs)
-    fstypeCombo.set_sensitive(formatcb.get_active())
-    maintable.attach(fstypeCombo, 1, 2, row, row + 1)
-    row += 1
-    rc["fstypeCombo"] = fstypeCombo
+    if origfs.formattable:
+        formatcb = gtk.CheckButton(label=_("_Format as:"))
+        maintable.attach(formatcb, 0, 1, row, row + 1)
+        formatcb.set_active(origfs.wantFormat)
+        rc["formatcb"] = formatcb
+
+        fstypeCombo = createFSTypeMenu(origfs, fstypechangeCB,
+                                       mountCombo, ignorefs=ignorefs)
+        fstypeCombo.set_sensitive(formatcb.get_active())
+        maintable.attach(fstypeCombo, 1, 2, row, row + 1)
+        row += 1
+        rc["fstypeCombo"] = fstypeCombo
+    else:
+        formatcb = None
+        fstypeCombo = None
 
     if not formatcb.get_active() and not origfs.migrate:
-	mountCombo.set_data("prevmountable", origfs.mountable)
+        mountCombo.set_data("prevmountable", origfs.mountable)
 
     # this gets added to the table a bit later on
     lukscb = gtk.CheckButton(_("_Encrypt"))
 
     if origfs.migratable:
-	migratecb = gtk.CheckButton(label=_("Mi_grate filesystem to:"))
-        migratecb.set_active(origfs.migrate)
+        migratecb = gtk.CheckButton(label=_("Mi_grate filesystem to:"))
+        migratecb.set_active(origfs.wantMigrate)
 
-	migtypes = [origfs.migrationTarget]
+        migtypes = [origfs.migrationTarget]
 
-	maintable.attach(migratecb, 0, 1, row, row + 1)
-	migfstypeCombo = createFSTypeMenu(origfs,
+        maintable.attach(migratecb, 0, 1, row, row + 1)
+        migfstypeCombo = createFSTypeMenu(origfs,
                                           None, None,
                                           availablefstypes = migtypes)
-	migfstypeCombo.set_sensitive(migratecb.get_active())
-	maintable.attach(migfstypeCombo, 1, 2, row, row + 1)
-	row = row + 1
+        migfstypeCombo.set_sensitive(migratecb.get_active())
+        maintable.attach(migfstypeCombo, 1, 2, row, row + 1)
+        row = row + 1
         rc["migratecb"] = migratecb
         rc["migfstypeCombo"] = migfstypeCombo
-	migratecb.connect("toggled", formatMigrateOptionCB,
+        migratecb.connect("toggled", formatMigrateOptionCB,
                           (migfstypeCombo, mountCombo, origfs, None,
-                           fstypeCombo, formatcb))
+                           fstypeCombo, formatcb, FLAG_MIGRATE))
     else:
-	migratecb = None
-	migfstypeCombo = None
+        migratecb = None
+        migfstypeCombo = None
 
-    formatcb.connect("toggled", formatMigrateOptionCB,
-                    (fstypeCombo, mountCombo, origfs, lukscb,
-                     migfstypeCombo, migratecb))
+    if formatcb:
+        formatcb.connect("toggled", formatMigrateOptionCB,
+                         (fstypeCombo, mountCombo, origfs, lukscb,
+                          migfstypeCombo, migratecb, FLAG_FORMAT))
 
     if origrequest.resizable:
         resizecb = gtk.CheckButton(label=_("_Resize"))
-        resizecb.set_active(origrequest.resizable and \
-            ((origrequest.targetSize != 0) and \
-             (origrequest.targetSize != origrequest.currentSize)))
+        resizecb.set_active(origfs.resizable and origfs.wantResize)
         rc["resizecb"] = resizecb
         maintable.attach(resizecb, 0, 1, row, row + 1)
 
@@ -378,7 +394,7 @@ def createPreExistFSOptionSection(origrequest, maintable, row, mountCombo,
         resizeOptionCB(resizecb, resizesb)
         row = row + 1
 
-        formatcb.connect("toggled", formatOptionResizeCB, resizesb)
+        formatcb.connect("toggled", formatOptionResizeCB, (resizesb, origfs))
 
     if luksdev:
         lukscb.set_active(1)
-- 
1.6.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux