[PATCH 1/2] Improve CheckList class.

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

 



Add Select All/None functionality to header.
Add support for titles in header.
---
 pyanaconda/iw/checklist.py                |   27 +++++++++++++++++++++------
 pyanaconda/iw/lvm_dialog_gui.py           |    3 ++-
 pyanaconda/iw/partition_ui_helpers_gui.py |    4 +++-
 pyanaconda/iw/raid_dialog_gui.py          |    3 ++-
 4 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/pyanaconda/iw/checklist.py b/pyanaconda/iw/checklist.py
index 50026a1..304978a 100644
--- a/pyanaconda/iw/checklist.py
+++ b/pyanaconda/iw/checklist.py
@@ -31,15 +31,16 @@ class CheckList (gtk.TreeView):
     # override this to make your own columns if necessary
     def create_columns(self, columns):
         # add the string columns to the tree view widget
-        for i in range(1, columns + 1):
+        titles = [''] + columns
+        for i in range(1, len(titles)):
             renderer = gtk.CellRendererText()
-            column = gtk.TreeViewColumn('Text', renderer, text=i,
+            column = gtk.TreeViewColumn(titles[i], renderer, text=i,
                                         **self.sensitivity_args)
             column.set_clickable(False)
             self.append_column(column)
 
     # XXX need to handle the multicolumn case better still....
-    def __init__ (self, columns = 1, custom_store=None, sensitivity=False):
+    def __init__ (self, columns = [''], custom_store=None, sensitivity=False):
 	if custom_store is None:
 	    self.store = gtk.TreeStore(gobject.TYPE_BOOLEAN,
 				       gobject.TYPE_STRING,
@@ -50,10 +51,10 @@ class CheckList (gtk.TreeView):
         gtk.TreeView.__init__ (self, self.store)
         
         # XXX we only handle two text columns right now
-        if custom_store is None and columns > 2:
+        if custom_store is None and len(columns) > 2:
             raise RuntimeError, "CheckList supports a maximum of 2 columns"
 	
-        self.columns = columns
+	self.columns = len(columns)
 
         # sensitivity_col is an optional hidden boolean column that controls
         # the sensitive property of all of the CellRenderers in its row.
@@ -76,6 +77,11 @@ class CheckList (gtk.TreeView):
 #        column.set_fixed_width(40)
         column.set_clickable(True)
         self.checkboxrenderer.connect ("toggled", self.toggled_item)        
+        column.connect("clicked", self.select_deselect)
+        column.set_alignment(0.75)
+        self.allButton = gtk.ToggleButton()
+        column.set_widget(self.allButton)
+        self.allButton.show_all()
         self.append_column(column)
 
 	self.create_columns(columns)
@@ -88,6 +94,7 @@ class CheckList (gtk.TreeView):
         # keep track of the number of rows we have so we can
         # iterate over them all
         self.num_rows = 0
+        self.select_all = True
 
         self.tiptext = {}
         self.props.has_tooltip = True
@@ -203,9 +210,17 @@ class CheckList (gtk.TreeView):
         if col:
             col.set_sort_column_id(id)
 
+    def select_deselect (self, widget, data=None):
+        """Select/Deselect all checkboxes"""
+        
+        self.select_all = not self.select_all
+        for i in xrange(self.num_rows):
+            self.set_active(i, self.select_all)
+
+
 def main():
     win = gtk.Window()
-    cl = CheckList(1)
+    cl = CheckList(['Column'])
     for i in range(1, 10):
         cl.append_row("%s" %(i,), False, "foo: %d" %(i,))
 
diff --git a/pyanaconda/iw/lvm_dialog_gui.py b/pyanaconda/iw/lvm_dialog_gui.py
index cef3be8..c669f6e 100644
--- a/pyanaconda/iw/lvm_dialog_gui.py
+++ b/pyanaconda/iw/lvm_dialog_gui.py
@@ -315,7 +315,8 @@ class VolumeGroupEditor:
 	store = gtk.TreeStore(gobject.TYPE_BOOLEAN,
 			      gobject.TYPE_STRING,
 			      gobject.TYPE_STRING)
-	partlist = WideCheckList(2, store, self.clickCB)
+	columns = ['Drive', 'Capacity']
+	partlist = WideCheckList(columns, store, self.clickCB)
 
 	sw = gtk.ScrolledWindow()
 	sw.add(partlist)
diff --git a/pyanaconda/iw/partition_ui_helpers_gui.py b/pyanaconda/iw/partition_ui_helpers_gui.py
index 08ba44b..ccba7e9 100644
--- a/pyanaconda/iw/partition_ui_helpers_gui.py
+++ b/pyanaconda/iw/partition_ui_helpers_gui.py
@@ -55,6 +55,7 @@ class WideCheckList(checklist.CheckList):
                                      sensitivity=sensitivity)
 
         # make checkbox column wider
+        columns = len(columns)
         column = self.get_column(columns)
         self.set_expander_column(column)
         column = self.get_column(0)
@@ -171,7 +172,8 @@ def createAllowedDrivesList(disks, reqdrives, selectDrives=True, disallowDrives=
                           gobject.TYPE_STRING,
                           gobject.TYPE_STRING,
                           gobject.TYPE_BOOLEAN)
-    drivelist = WideCheckList(3, store, sensitivity=True)
+    columns = ['Drive', 'Capacity', 'Model']
+    drivelist = WideCheckList(columns, store, sensitivity=True)
     createAllowedDrivesStore(disks, reqdrives, drivelist, selectDrives=selectDrives,
                              disallowDrives=disallowDrives)
 
diff --git a/pyanaconda/iw/raid_dialog_gui.py b/pyanaconda/iw/raid_dialog_gui.py
index 770344c..3256689 100644
--- a/pyanaconda/iw/raid_dialog_gui.py
+++ b/pyanaconda/iw/raid_dialog_gui.py
@@ -46,7 +46,8 @@ class RaidEditor:
 	store = gtk.TreeStore(gobject.TYPE_BOOLEAN,
 			      gobject.TYPE_STRING,
 			      gobject.TYPE_STRING)
-	partlist = WideCheckList(2, store, 
+	columns = ['Drive', 'Capacity']
+	partlist = WideCheckList(columns, store, 
                                  clickCB=self.raidlist_toggle_callback)
 
 	sw = gtk.ScrolledWindow()
-- 
1.7.2.3

_______________________________________________
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