[gnome-boxes] Remove libvirt machine on events
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Remove libvirt machine on events
- Date: Mon, 7 Nov 2011 13:36:37 +0000 (UTC)
commit f80583d3db425c7744f1115df89ea633aa566491
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Mon Nov 7 02:23:49 2011 +0100
Remove libvirt machine on events
src/app.vala | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index c03260c..e3255d2 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -63,6 +63,13 @@ private class Boxes.App: Boxes.UI {
view.category = category;
}
+ private void add_domain (CollectionSource source,
+ GVir.Connection connection, GVir.Domain domain) {
+ var machine = new LibvirtMachine (source, this, connection, domain);
+ collection.add_item (machine);
+ domain.set_data<LibvirtMachine> ("machine", machine);
+ }
+
private async void setup_libvirt (CollectionSource source) {
var connection = new GVir.Connection (source.uri);
@@ -73,14 +80,16 @@ private class Boxes.App: Boxes.UI {
warning (error.message);
}
- foreach (var domain in connection.get_domains ()) {
- var machine = new LibvirtMachine (source, this, connection, domain);
- collection.add_item (machine);
- }
+ foreach (var domain in connection.get_domains ())
+ add_domain (source, connection, domain);
+
+ connection.domain_removed.connect ((connection, domain) => {
+ var machine = domain.get_data<LibvirtMachine> ("machine");
+ view.remove_item (machine);
+ });
connection.domain_added.connect ((connection, domain) => {
- var machine = new LibvirtMachine (source, this, connection, domain);
- collection.add_item (machine);
+ add_domain (source, connection, domain);
});
connections.replace (source.uri, connection);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]