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

[virt-tools-list] [PATCH 3/5] uihelpers: Add set_table_row_visible()



From: "Fred A. Kemp" <anonym riseup net>

---
 virtManager/uihelpers.py |   26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/virtManager/uihelpers.py b/virtManager/uihelpers.py
index 81308a2..0937eea 100644
--- a/virtManager/uihelpers.py
+++ b/virtManager/uihelpers.py
@@ -1383,21 +1383,31 @@ def child_get_property(parent, child, propname):
     return value.get_int()
 
 
+def _set_container_row_visible(container_class, child, visible):
+    # Helper for the set_*_row_visible functions.
+    parent = child.get_parent()
+    if not type(parent) is container_class:
+        raise RuntimeError("Programming error, parent must be %s, "
+                           "not %s" % (container_class.__name__,
+                                       parent.__class__.__name__))
+
+    row = child_get_property(parent, child, "top-attach")
+    for child in parent.get_children():
+        if child_get_property(parent, child, "top-attach") == row:
+            child.set_visible(visible)
+
+
 def set_grid_row_visible(child, visible):
     # For the passed widget, find its parent GtkGrid, and hide/show all
     # elements that are in the same row as it. Simplifies having to name
     # every element in a row when we want to dynamically hide things
     # based on UI interraction
+    _set_container_row_visible(Gtk.Grid, child, visible)
 
-    parent = child.get_parent()
-    if not type(parent) is Gtk.Grid:
-        raise RuntimeError("Programming error, parent must be grid, "
-                           "not %s" % type(parent))
 
-    row = child_get_property(parent, child, "top-attach")
-    for child in parent.get_children():
-        if child_get_property(parent, child, "top-attach") == row:
-            child.set_visible(visible)
+def set_table_row_visible(child, visible):
+    # Same as set_grid_row_visible but looks for GtkTable.
+    _set_container_row_visible(Gtk.Table, child, visible)
 
 
 def default_uri(always_system=False):
-- 
1.7.10.4


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