[gnome-boxes] libvirt: Move App::add_domain to LibvirtBroker
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] libvirt: Move App::add_domain to LibvirtBroker
- Date: Fri, 8 Feb 2013 17:12:01 +0000 (UTC)
commit 2d7dcf4bd0e969b780a65f083ecf3b3aa7e774fb
Author: Christophe Fergeau <cfergeau redhat com>
Date: Sat Sep 1 17:48:24 2012 +0200
libvirt: Move App::add_domain to LibvirtBroker
https://bugzilla.gnome.org/show_bug.cgi?id=681747
src/app.vala | 14 --------------
src/libvirt-broker.vala | 20 ++++++++++++++++++--
src/vm-creator.vala | 2 +-
3 files changed, 19 insertions(+), 17 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index 70f36f4..6d33caa 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -337,20 +337,6 @@ private class Boxes.App: Boxes.UI {
return false;
}
- public LibvirtMachine add_domain (CollectionSource source, GVir.Connection connection, GVir.Domain domain)
- throws GLib.Error {
- var machine = domain.get_data<LibvirtMachine> ("machine");
- if (machine != null)
- return machine; // Already added
-
- machine = new LibvirtMachine (source, connection, domain);
- machine.suspend_at_exit = (connection == default_connection);
- collection.add_item (machine);
- domain.set_data<LibvirtMachine> ("machine", machine);
-
- return machine;
- }
-
public void delete_machine (Machine machine, bool by_user = true) {
machine.delete (by_user); // Will also delete associated storage volume if by_user is 'true'
collection.remove_item (machine);
diff --git a/src/libvirt-broker.vala b/src/libvirt-broker.vala
index 3c41d69..4e0185f 100644
--- a/src/libvirt-broker.vala
+++ b/src/libvirt-broker.vala
@@ -22,10 +22,26 @@ private class Boxes.LibvirtBroker : Boxes.Broker {
return broker.connections.get (name);
}
+ public LibvirtMachine add_domain (CollectionSource source, GVir.Connection connection, GVir.Domain domain)
+ throws GLib.Error {
+ return_if_fail (broker != null);
+
+ var machine = domain.get_data<LibvirtMachine> ("machine");
+ if (machine != null)
+ return machine; // Already added
+
+ machine = new LibvirtMachine (source, connection, domain);
+ machine.suspend_at_exit = (connection == App.app.default_connection);
+ App.app.collection.add_item (machine);
+ domain.set_data<LibvirtMachine> ("machine", machine);
+
+ return machine;
+ }
+
// New == Added after Boxes launch
private void try_add_new_domain (CollectionSource source, GVir.Connection connection, GVir.Domain domain) {
try {
- App.app.add_domain (source, connection, domain);
+ add_domain (source, connection, domain);
} catch (GLib.Error error) {
warning ("Failed to create source '%s': %s", source.name, error.message);
}
@@ -34,7 +50,7 @@ private class Boxes.LibvirtBroker : Boxes.Broker {
// Existing == Existed before Boxes was launched
private void try_add_existing_domain (CollectionSource source, GVir.Connection connection, GVir.Domain domain) {
try {
- var machine = App.app.add_domain (source, connection, domain);
+ var machine = add_domain (source, connection, domain);
var config = machine.domain_config;
if (VMConfigurator.is_install_config (config) || VMConfigurator.is_live_config (config)) {
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index cf696d3..5de483f 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -52,7 +52,7 @@ private class Boxes.VMCreator {
var domain = connection.create_domain (config);
- return App.app.add_domain (App.app.default_source, App.app.default_connection, domain);
+ return LibvirtBroker.get_default ().add_domain (App.app.default_source, App.app.default_connection, domain);
}
public void launch_vm (LibvirtMachine machine) throws GLib.Error {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]