[PATCH 1/3] Added all disks function to partitioning in text mode

TiOluwa Olarewaju tolarewa at redhat.com
Wed Jun 5 17:40:32 UTC 2013


---
 pyanaconda/ui/tui/spokes/storage.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py
index 68c6663..b41166e 100644
--- a/pyanaconda/ui/tui/spokes/storage.py
+++ b/pyanaconda/ui/tui/spokes/storage.py
@@ -185,11 +185,20 @@ class StorageSpoke(NormalTUISpoke):
                                                  disk.name),
                                completed=(disk.name in self.selected_disks))
             self._window += [c, ""]
+	cAll = CheckboxWidget(title="0) All Disks"
+	completed=(self.allDisks())	
+
 
         self._window += [TextWidget(message), ""]
 
         return True
 
+    def allDisks():
+	completed = false
+	for disk in self.disks:
+		completed = disk.name in self.selected_disks
+	return completed
+
     def input(self, args, key):
         """Grab the disk choice and update things"""
 
@@ -205,7 +214,12 @@ class StorageSpoke(NormalTUISpoke):
 
         try:
             number = int(key)
-            self._update_disk_list(self.disks[number -1])
+            if(key == 0){
+                for disk in self.disks:
+                    self.update_disk_list(disk)
+            else{
+                self._update_disk_list(self.disks[number -1])
+            }
             return None
 
         except (ValueError, KeyError, IndexError):
-- 
1.8.1.4


>From 6ce7ee1ba5f3a9fc50de8bf39b9a040d00f04910 Mon Sep 17 00:00:00 2001
Date: Thu, 23 May 2013 16:29:17 -0400
Subject: [PATCH 2/3] Working copy of all disks partitioning optio

---
 pyanaconda/ui/tui/spokes/storage.py | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py
index b41166e..1d1d15d 100644
--- a/pyanaconda/ui/tui/spokes/storage.py
+++ b/pyanaconda/ui/tui/spokes/storage.py
@@ -66,6 +66,7 @@ class StorageSpoke(NormalTUISpoke):
         # This list gets set up once in initialize and should not be modified
         # except perhaps to add advanced devices. It will remain the full list
         # of disks that can be included in the install.
+        self.allSelected = False; #Boolean so only all disks shows as checked
         self.disks = []
         self.errors = []
         self.warnings = []
@@ -178,26 +179,25 @@ class StorageSpoke(NormalTUISpoke):
         self.autopart = self.data.autopart.autopart
 
         message = self._update_summary()
+	# present an all disks option
+        cAll = CheckboxWidget(title="0) All Disks", completed=self.allDisks())
+        self._window += [cAll, ""]
 
         # loop through the disks and present them.
         for disk in self.disks:
             c = CheckboxWidget(title="%i) %s" % (self.disks.index(disk) + 1,
                                                  disk.name),
-                               completed=(disk.name in self.selected_disks))
+                               completed=((disk.name in self.selected_disks) & self.allSelected))
             self._window += [c, ""]
-	cAll = CheckboxWidget(title="0) All Disks"
-	completed=(self.allDisks())	
-
-
         self._window += [TextWidget(message), ""]
 
         return True
 
-    def allDisks():
-	completed = false
-	for disk in self.disks:
-		completed = disk.name in self.selected_disks
-	return completed
+    def allDisks(self):
+	#scans through all disks and adds them
+        for disk in self.disks:
+            completed = disk.name in self.selected_disks
+        return completed
 
     def input(self, args, key):
         """Grab the disk choice and update things"""
@@ -214,12 +214,12 @@ class StorageSpoke(NormalTUISpoke):
 
         try:
             number = int(key)
-            if(key == 0){
+            if(number == 0):
                 for disk in self.disks:
-                    self.update_disk_list(disk)
-            else{
+                    index = self.disks.index(disk)
+                    self._update_disk_list(self.disks[index])
+            else:
                 self._update_disk_list(self.disks[number -1])
-            }
             return None
 
         except (ValueError, KeyError, IndexError):
-- 
1.8.1.4


>From ee02f7883b740e40581cd150bf55d9fceff9574b Mon Sep 17 00:00:00 2001
Date: Fri, 24 May 2013 16:29:18 -0400
Subject: [PATCH 3/3] corrected all disk selection to support single disk
 removal and selection out of order

---
 pyanaconda/ui/tui/spokes/storage.py | 43 ++++++++++++++++++++++++++++++-------
 1 file changed, 35 insertions(+), 8 deletions(-)

diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py
index 1d1d15d..ab247af 100644
--- a/pyanaconda/ui/tui/spokes/storage.py
+++ b/pyanaconda/ui/tui/spokes/storage.py
@@ -131,7 +131,13 @@ class StorageSpoke(NormalTUISpoke):
         # If the disk is already selected, deselect it.
         elif name in self.selected_disks:
             self.selected_disks.remove(name)
-
+    
+    def _add_all_disks(self):
+        for disk in self.disks:
+            if disk.name not in self.selected_disks:
+                 self.selected_disks.append(disk.name)
+        return None
+    
     def _update_summary(self):
         """ Update the summary based on the UI. """
         count = 0
@@ -184,20 +190,41 @@ class StorageSpoke(NormalTUISpoke):
         self._window += [cAll, ""]
 
         # loop through the disks and present them.
+        notAllSelected = not self.allSelected
         for disk in self.disks:
             c = CheckboxWidget(title="%i) %s" % (self.disks.index(disk) + 1,
                                                  disk.name),
-                               completed=((disk.name in self.selected_disks) & self.allSelected))
+                               completed=((disk.name in self.selected_disks) and notAllSelected))
             self._window += [c, ""]
         self._window += [TextWidget(message), ""]
 
         return True
 
+    #clears all selected disks
+    def clearAllSelection(self):
+        for disk in self.disks:
+            self.selected_disks.remove(disk.name)
+        self.allSelected = False
+        return None
+
     def allDisks(self):
-	#scans through all disks and adds them
+	#checks if all disks are selected
+        selected = True;
         for disk in self.disks:
-            completed = disk.name in self.selected_disks
-        return completed
+            selected = (disk.name in self.selected_disks)
+            if selected == False:
+                return selected
+        self.allSelected = selected
+        return selected
+
+    # toggles all disk select
+    def selectAllDisks(self):
+        if self.allSelected == True:
+            self.clearAllSelection()
+        else:
+            self.allSelected = True
+            self._add_all_disks()
+        return None
 
     def input(self, args, key):
         """Grab the disk choice and update things"""
@@ -215,10 +242,10 @@ class StorageSpoke(NormalTUISpoke):
         try:
             number = int(key)
             if(number == 0):
-                for disk in self.disks:
-                    index = self.disks.index(disk)
-                    self._update_disk_list(self.disks[index])
+                self.selectAllDisks()
             else:
+                if self.allSelected == True:
+                    self.clearAllSelection()
                 self._update_disk_list(self.disks[number -1])
             return None
 
-- 
1.8.1.4



More information about the anaconda-patches mailing list