[PATCH 5/8] Create getCurrentDeviceParent function.

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

 



One of the ways of knowing where we are in the tree view is to ask for
the parent of the current row.  If there is no parent, then we know that
we are in a root row.  Additionally, when we click on free space, we
need the parent to know what to put in the bar view.
* iw/partition_gui.py (getCurrentDevice): Access the PyObject directly
from the model (model[iter]["PyObject"]).  If there is not PyObject then
it will contain None.
(getCurrentDeviceParent): Use model.iter_parent(iter) to get the parent
from iter.  Will return None if no parent is found.
---
 iw/partition_gui.py |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/iw/partition_gui.py b/iw/partition_gui.py
index 45d7cdb..11fdd09 100644
--- a/iw/partition_gui.py
+++ b/iw/partition_gui.py
@@ -686,19 +686,26 @@ class DiskTreeModel(gtk.TreeStore):
         return iter
 
     def getCurrentDevice(self):
-        """ Return the device representing the current selection """
+        """ Return the device representing the current selection,
+            None otherwise.
+        """
         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 model[iter]['PyObject']
+
+    def getCurrentDeviceParent(self):
+        """ Return the parent of the selected row.  Returns an iter.
+            None if there is no parent.
+        """
+        selection = self.view.get_selection()
+        model, iter = selection.get_selected()
+        if not iter:
+            return None
 
-        return val
+        return model.iter_parent(iter)
 
     def resetSelection(self):
         pass
-- 
1.6.4.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