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

Giuseppe Scrivano gscrivan at redhat.com
Thu Jun 26 09:54:57 UTC 2014


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()
 
-- 
1.9.3




More information about the virt-tools-list mailing list