[virt-tools-list] [PATCH virt-manager] virt-manager: select the initial connection
Giuseppe Scrivano
gscrivan at redhat.com
Fri Jun 27 12:05:12 UTC 2014
Automatically select the connection in this order:
- URI specified via command line --connect
- First active connection
- First connection
Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
---
virtManager/engine.py | 4 +++-
virtManager/manager.py | 32 ++++++++++++++++++++++++--------
2 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/virtManager/engine.py b/virtManager/engine.py
index d3a49d7..38d7e2d 100644
--- a/virtManager/engine.py
+++ b/virtManager/engine.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2006, 2013 Red Hat, Inc.
+# Copyright (C) 2006, 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
@@ -805,6 +805,8 @@ class vmmEngine(vmmGObject):
self.connect("conn-added", obj.add_conn)
self.connect("conn-removed", obj.remove_conn)
+ obj.set_initial_selection(self.uri_at_startup)
+
self.windowManager = obj
return self.windowManager
diff --git a/virtManager/manager.py b/virtManager/manager.py
index 158bd28..1aabae3 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
@@ -192,12 +192,6 @@ class vmmManager(vmmGObjectUI):
self.enable_polling(COL_NETWORK)
self.enable_polling(COL_MEM)
- # Select first list entry
- vmlist = self.widget("vm-list")
- if len(vmlist.get_model()) != 0:
- vmlist.get_selection().select_iter(
- vmlist.get_model().get_iter_first())
-
# Queue up the default connection detector
self.idle_emit("add-default-conn")
@@ -720,7 +714,6 @@ class vmmManager(vmmGObjectUI):
# add the connection to the treeModel
vmlist = self.widget("vm-list")
row = self._append_conn(vmlist.get_model(), conn)
- vmlist.get_selection().select_iter(row)
# Try to make sure that 2 row descriptions don't collide
connrows = []
@@ -827,6 +820,29 @@ class vmmManager(vmmGObjectUI):
self.vm_row_updated(vm)
+ def set_initial_selection(self, uri):
+ vmlist = self.widget("vm-list")
+ model = vmlist.get_model()
+ it = model.get_iter_first()
+ selected = None
+ while it:
+ key = model.get_value(it, ROW_HANDLE)
+
+ if key.get_uri() == uri:
+ vmlist.get_selection().select_iter(it)
+ return
+
+ if not selected:
+ vmlist.get_selection().select_iter(it)
+ selected = key
+ elif key.get_autoconnect() and not selected.get_autoconnect():
+ vmlist.get_selection().select_iter(it)
+ selected = key
+ if not uri:
+ return
+
+ it = model.iter_next(it)
+
def conn_state_changed(self, conn, newname=None):
row = self.rows[conn.get_uri()]
if newname:
--
1.9.3
More information about the virt-tools-list
mailing list