[PATCH] Add support for deleting an entire root via the existing ConfirmDeleteDialog.

Chris Lumens clumens at redhat.com
Fri Oct 12 18:42:37 UTC 2012


You've already bought into doing something destructive, so why not have the
chance to really tear things up?  Also, make the cancel button the default
action.
---
 pyanaconda/ui/gui/spokes/custom.glade | 50 +++++++++++++++++++++++------------
 pyanaconda/ui/gui/spokes/custom.py    | 17 +++++++++---
 2 files changed, 47 insertions(+), 20 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/custom.glade b/pyanaconda/ui/gui/spokes/custom.glade
index c377e6a..b4ae700 100644
--- a/pyanaconda/ui/gui/spokes/custom.glade
+++ b/pyanaconda/ui/gui/spokes/custom.glade
@@ -242,6 +242,36 @@ use.  Try something else?</property>
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
+        <child>
+          <object class="GtkLabel" id="confirmLabel">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">0</property>
+            <property name="yalign">0</property>
+            <property name="label" translatable="yes">Are you sure you want to delete all of the data on %s?</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkCheckButton" id="removeAllCheckbox">
+            <property name="label" translatable="yes">Delete all other filesystems in the %s root as well.</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="xalign">0</property>
+            <property name="draw_indicator">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
         <child internal-child="action_area">
           <object class="GtkButtonBox" id="dialog-action_area2">
             <property name="can_focus">False</property>
@@ -249,11 +279,11 @@ use.  Try something else?</property>
             <child>
               <object class="GtkButton" id="deleteCancelButton">
                 <property name="label" translatable="yes">_Cancel</property>
-                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_underline">True</property>
                 <signal name="clicked" handler="on_delete_cancel_clicked" swapped="no"/>
               </object>
@@ -285,21 +315,7 @@ use.  Try something else?</property>
             <property name="expand">False</property>
             <property name="fill">True</property>
             <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="confirmLabel">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Are you sure you want to delete
-all of the data on %s?</property>
-            <property name="wrap">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
+            <property name="position">2</property>
           </packing>
         </child>
       </object>
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 3150f6d..8b780a3 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -248,16 +248,23 @@ class ConfirmDeleteDialog(GUIObject):
     mainWidgetName = "confirmDeleteDialog"
     uiFile = "spokes/custom.glade"
 
+    @property
+    def deleteAll(self):
+        return self._removeAll.get_active()
+
     def on_delete_cancel_clicked(self, button, *args):
         self.window.destroy()
 
     def on_delete_confirm_clicked(self, button, *args):
         self.window.destroy()
 
-    def refresh(self, mountpoint, device):
+    def refresh(self, mountpoint, device, rootName):
         GUIObject.refresh(self)
         label = self.builder.get_object("confirmLabel")
 
+        self._removeAll = self.builder.get_object("removeAllCheckbox")
+        self._removeAll.set_label(self._removeAll.get_label() % rootName)
+
         if mountpoint:
             txt = "%s (%s)" % (mountpoint, device)
         else:
@@ -1709,13 +1716,17 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
             dialog = ConfirmDeleteDialog(self.data)
             with enlightbox(self.window, dialog.window):
                 dialog.refresh(getattr(device.format, "mountpoint", ""),
-                               device.name)
+                               device.name, selector._root.name)
                 rc = dialog.run()
 
                 if rc == 0:
                     return
 
-            self._destroy_device(device)
+            if dialog.deleteAll:
+                for dev in selector._root.swaps + selector._root.mounts.values():
+                    self._destroy_device(dev)
+            else:
+                self._destroy_device(device)
 
         log.info("ui: removed device %s" % device.name)
 
-- 
1.7.11.2



More information about the anaconda-patches mailing list