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

Cole Robinson crobinso at redhat.com
Fri Oct 4 12:11:07 UTC 2013


On 10/03/2013 09:39 PM, Fred A. Kemp wrote:
> From: "Fred A. Kemp" <anonym at 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):
> 

Hmm, actually I'd prefer to just convert the disk UI from table->grid, since
grid is the new fangled way, and has spacing improvements like automatically
resizing when we hide rows. The conversion is kind of awkward though, so I
handled it and pushed it upstream. This patch can be dropped.

Thanks,
Cole




More information about the virt-tools-list mailing list