diff --git a/src/virtManager/engine.py b/src/virtManager/engine.py index 0d59294a..158aa899 100644 --- a/src/virtManager/engine.py +++ b/src/virtManager/engine.py @@ -281,7 +281,7 @@ class vmmEngine(vmmGObject): # First run PackageKit # ######################## - def add_default_connection(self): + def add_default_connection(self, manager): # Only add default if no connections are currently known if self.config.get_connections(): return @@ -294,7 +294,6 @@ class vmmEngine(vmmGObject): "A hypervisor connection can be manually\n" "added via File->Add Connection") - manager = self.get_manager() logging.debug("Determining default libvirt URI") ret = None @@ -585,7 +584,8 @@ class vmmEngine(vmmGObject): logging.exception("Error cleaning up conn in engine") - def remove_connection(self, uri): + def remove_connection(self, src, uri): + ignore = src self.cleanup_connection(uri) del(self.connections[uri]) @@ -746,7 +746,7 @@ class vmmEngine(vmmGObject): if self.windowManager: return self.windowManager - obj = vmmManager(self) + obj = vmmManager() obj.connect("action-suspend-domain", self._do_suspend_domain) obj.connect("action-resume-domain", self._do_resume_domain) obj.connect("action-run-domain", self._do_run_domain) @@ -767,6 +767,11 @@ class vmmEngine(vmmGObject): obj.connect("action-exit-app", self.exit_app) obj.connect("manager-opened", self.increment_window_counter) obj.connect("manager-closed", self.decrement_window_counter) + obj.connect("remove-connection", self.remove_connection) + obj.connect("add-default-connection", self.add_default_connection) + + self.connect("connection-added", obj.add_connection) + self.connect("connection-removed", obj.remove_connection) self.windowManager = obj return self.windowManager diff --git a/src/virtManager/inspection.py b/src/virtManager/inspection.py index 6a85118e..c67d218a 100644 --- a/src/virtManager/inspection.py +++ b/src/virtManager/inspection.py @@ -47,7 +47,10 @@ class vmmInspection(Thread): self._q.put(obj) # Called by the main thread whenever a VM is added to vmlist. - def vm_added(self): + def vm_added(self, conn, uri, uuid): + ignore = conn + ignore = uri + ignore = uuid obj = ("vm_added") self._q.put(obj) @@ -84,6 +87,7 @@ class vmmInspection(Thread): if conn and not (conn.is_remote()): uri = conn.get_uri() self._conns[uri] = conn + conn.connect("vm-added", self.vm_added) elif obj[0] == "conn_removed": uri = obj[1] del self._conns[uri] diff --git a/src/virtManager/manager.py b/src/virtManager/manager.py index f6cd0d96..a08fe2bf 100644 --- a/src/virtManager/manager.py +++ b/src/virtManager/manager.py @@ -69,9 +69,8 @@ gtk.rc_parse_string(rcstring) class vmmManager(vmmGObjectUI): - def __init__(self, engine): + def __init__(self): vmmGObjectUI.__init__(self, "vmm-manager.glade", "vmm-manager") - self.engine = engine self.delete_dialog = None self.ignore_pause = False @@ -151,9 +150,6 @@ class vmmManager(vmmGObjectUI): (COL_NETWORK, self.config.get_stats_enable_net_poll())]: self.enable_polling(None, None, init_val, typ) - self.engine.connect("connection-added", self._add_connection) - self.engine.connect("connection-removed", self._remove_connection) - # Select first list entry vmlist = self.widget("vm-list") if len(vmlist.get_model()) != 0: @@ -161,7 +157,7 @@ class vmmManager(vmmGObjectUI): vmlist.get_model().get_iter_first()) # Queue up the default connection detector - self.safe_idle_add(self.engine.add_default_connection) + self.idle_emit("add-default-connection") ################## # Common methods # @@ -194,7 +190,6 @@ class vmmManager(vmmGObjectUI): self.close() try: - self.engine = None self.rows = None self.diskcol = None @@ -561,7 +556,8 @@ class vmmManager(vmmGObjectUI): "Are you sure?") % conn.get_uri()) if not result: return - self.engine.remove_connection(conn.get_uri()) + + self.emit("remove-connection", conn.get_uri()) def _do_delete_vm(self, vm): if vm.is_active(): @@ -692,9 +688,6 @@ class vmmManager(vmmGObjectUI): self._append_vm(model, vm, connection) - if self.engine.inspection_thread: - self.engine.inspection_thread.vm_added() - def vm_removed(self, connection, uri_ignore, vmuuid): vmlist = self.widget("vm-list") model = vmlist.get_model() @@ -796,7 +789,7 @@ class vmmManager(vmmGObjectUI): self.rows[conn.get_uri()] = model[path] return _iter - def _add_connection(self, engine_ignore, conn): + def add_connection(self, engine_ignore, conn): # Make sure error page isn't showing self.widget("vm-notebook").set_current_page(0) @@ -832,7 +825,7 @@ class vmmManager(vmmGObjectUI): newname = conn.get_pretty_desc_inactive(False, True) self.conn_refresh_resources(conn, newname) - def _remove_connection(self, engine_ignore, uri): + def remove_connection(self, engine_ignore, uri): model = self.widget("vm-list").get_model() parent = self.rows[uri].iter @@ -1200,3 +1193,5 @@ vmmManager.signal_new(vmmManager, "action-clone-domain", [str, str]) vmmManager.signal_new(vmmManager, "action-exit-app", []) vmmManager.signal_new(vmmManager, "manager-closed", []) vmmManager.signal_new(vmmManager, "manager-opened", []) +vmmManager.signal_new(vmmManager, "remove-connection", [str]) +vmmManager.signal_new(vmmManager, "add-default-connection", [])