From 595d3d13e724e707c69f6b6f89717d12b6b18dee Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 14 Jul 2011 20:52:40 -0400 Subject: [PATCH] connect: If readding an existing connection, update 'autoconnect' --- src/virtManager/connect.py | 8 +++----- src/virtManager/engine.py | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/virtManager/connect.py b/src/virtManager/connect.py index d17737ff2..5c682ba96 100644 --- a/src/virtManager/connect.py +++ b/src/virtManager/connect.py @@ -335,16 +335,14 @@ class vmmConnect(vmmGObjectUI): if not self.validate(): return - readonly = False auto = False if self.widget("autoconnect").get_property("sensitive"): auto = self.widget("autoconnect").get_active() uri = self.generate_uri() - logging.debug("Generate URI=%s, auto=%s, readonly=%s" % - (uri, auto, readonly)) + logging.debug("Generate URI=%s, auto=%s" % (uri, auto)) self.close() - self.emit("completed", uri, readonly, auto) + self.emit("completed", uri, auto) def sanitize_hostname(self, host): if host == "linux" or host == "localhost": @@ -400,5 +398,5 @@ class vmmConnect(vmmGObjectUI): vmmGObjectUI.type_register(vmmConnect) -vmmConnect.signal_new(vmmConnect, "completed", [str, object, object]) +vmmConnect.signal_new(vmmConnect, "completed", [str, str]) vmmConnect.signal_new(vmmConnect, "cancelled", []) diff --git a/src/virtManager/engine.py b/src/virtManager/engine.py index 3ae1f7a73..dbbb8bd70 100644 --- a/src/virtManager/engine.py +++ b/src/virtManager/engine.py @@ -345,13 +345,15 @@ class vmmEngine(vmmGObject): if conn.get_autoconnect(): self.connect_to_uri(uri) - def connect_to_uri(self, uri, readOnly=None, autoconnect=False, - do_start=True): + def connect_to_uri(self, uri, autoconnect=None, do_start=True): try: conn = self._check_connection(uri) if not conn: # Unknown connection, add it - conn = self.add_connection(uri, readOnly, autoconnect) + conn = self.add_connection(uri) + + if autoconnect is not None: + conn.set_autoconnect(bool(autoconnect)) self.show_manager() if do_start: @@ -529,12 +531,12 @@ class vmmEngine(vmmGObject): logging.debug("Exiting app normally.") gtk.main_quit() - def add_connection(self, uri, readOnly=None, autoconnect=False): + def add_connection(self, uri): conn = self._check_connection(uri) if conn: return conn - conn = vmmConnection(uri, readOnly=readOnly) + conn = vmmConnection(uri) self.connections[uri] = { "connection": conn, "windowHost": None, @@ -548,9 +550,6 @@ class vmmEngine(vmmGObject): self.emit("connection-added", conn) self.config.add_connection(conn.get_uri()) - if autoconnect: - conn.set_autoconnect(True) - return conn def cleanup_connection(self, uri): @@ -663,8 +662,9 @@ class vmmEngine(vmmGObject): if self.windowConnect: return self.windowConnect - def connect_wrap(src_ignore, *args): - return self.connect_to_uri(*args) + def connect_wrap(src, uri, autoconnect): + ignore = src + return self.connect_to_uri(uri, autoconnect) obj = vmmConnect() obj.connect("completed", connect_wrap)