[virt-tools-list] [PATCH virt-manager] virt-manager: automatically select the only active connection

Cole Robinson crobinso at redhat.com
Thu Jun 26 13:00:35 UTC 2014


On 06/26/2014 05:54 AM, Giuseppe Scrivano wrote:
> If there is only one active connection, automatically select it.  The
> advantage is that it makes easier to jump into the connection details
> when there is only one Autoconnect connection.
> 
> Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
> ---
>  virtManager/manager.py | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/virtManager/manager.py b/virtManager/manager.py
> index 1ca84e4..05491be 100644
> --- a/virtManager/manager.py
> +++ b/virtManager/manager.py
> @@ -1,5 +1,5 @@
>  #
> -# Copyright (C) 2006-2008, 2013 Red Hat, Inc.
> +# Copyright (C) 2006-2008, 2013-2014 Red Hat, Inc.
>  # Copyright (C) 2006 Daniel P. Berrange <berrange at redhat.com>
>  #
>  # This program is free software; you can redistribute it and/or modify
> @@ -845,6 +845,13 @@ class vmmManager(vmmGObjectUI):
>                      model.remove(child)
>                      child = model.iter_children(parent)
>  
> +        # If there is only one active connection, automatically select it
> +        if conn.get_state() == vmmConnection.STATE_ACTIVE:
> +            active_conns = [i for i in self.rows.values()
> +                            if i[0].get_state() == vmmConnection.STATE_ACTIVE]
> +            if len(active_conns) == 1:
> +                self.widget("vm-list").get_selection().select_iter(row.iter)
> +
>          self.conn_row_updated(conn)
>          self.update_current_selection()
>  
> 

Good idea, but I think this should be implemented differently so it can tackle
some other problems. Right now the connection selected at startup is just
determined by how the connection key is hashed in a python dictionary, which
is pretty arbitrary.

Can you add a new function vmmManager.set_initial_selection, and call that
from engine.py:get_manager after add-conn/remove-conn signals are registered?
I think the logic should be:

- If URI specified via command line --connect, select it
- else select the first active connection
- else select the first connection

Thanks,
Cole




More information about the virt-tools-list mailing list