[gnome-boxes] Add GSettings schema, and start using it



commit 738f5d937744713e978bc2185c205861ee294e79
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Thu Oct 13 21:01:00 2011 +0200

    Add GSettings schema, and start using it

 configure.ac                        |    1 +
 data/Makefile.am                    |    5 +++++
 data/org.gnome.boxes.gschema.xml.in |   24 ++++++++++++++++++++++++
 src/app.vala                        |   17 ++++++++++++-----
 src/machine.vala                    |    8 +++++---
 5 files changed, 47 insertions(+), 8 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6671607..d043e8f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,6 +22,7 @@ AM_GNU_GETTEXT([external])
 AM_GNU_GETTEXT_VERSION([0.17])
 
 GOBJECT_INTROSPECTION_REQUIRE([0.9.6])
+GLIB_GSETTINGS
 
 AC_PROG_CC
 AM_PROG_CC_C_O
diff --git a/data/Makefile.am b/data/Makefile.am
index a54229f..2f67bf1 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -6,6 +6,10 @@ desktop_in_files = gnome-boxes.desktop.in
 desktop_DATA     = $(desktop_in_files:.desktop.in=.desktop)
 @INTLTOOL_DESKTOP_RULE@
 
+gsettings_SCHEMAS = org.gnome.boxes.gschema.xml
+ INTLTOOL_XML_NOMERGE_RULE@
+ GSETTINGS_RULES@
+
 styledir         = $(datadir)/gnome-boxes/style
 style_DATA       = gtk-style.css
 
@@ -13,6 +17,7 @@ iconsdir = $(pkgdatadir)/icons
 
 EXTRA_DIST =					\
 	gnome-boxes.desktop.in			\
+	org.gnome.boxes.gschema.xml.in		\
 	$(desktop_in_files)			\
 	$(NULL)
 
diff --git a/data/org.gnome.boxes.gschema.xml.in b/data/org.gnome.boxes.gschema.xml.in
new file mode 100644
index 0000000..5d670f2
--- /dev/null
+++ b/data/org.gnome.boxes.gschema.xml.in
@@ -0,0 +1,24 @@
+<schemalist>
+  <schema id="org.gnome.boxes" path="/org/gnome/boxes/" gettext-domain="gnome-boxes">
+
+    <key name="broker-uris" type="as">
+      <summary>Broker URIs</summary>
+      <description>
+        List broker URIs to connect to. A broker URI can only be a
+        libvirt URI for now. The default value is:
+        qemu+unix:///session.
+      </description>
+      <default>[ 'qemu+unix:///session' ]</default>
+    </key>
+
+    <key name="screenshot-interval" type="i">
+      <summary>Screenshot interval</summary>
+      <description>
+        The interval in seconds between screenshot updates.
+        Default value: 5.
+      </description>
+      <default>5</default>
+    </key>
+
+  </schema>
+</schemalist>
diff --git a/src/app.vala b/src/app.vala
index a17bb45..0be7eac 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -27,8 +27,8 @@ private class Boxes.App: Boxes.UI {
     public Clutter.State state;
     public Clutter.Box box; // the whole app box
     public CollectionItem current_item; // current object/vm manipulated
-    public GVir.Connection connection;
     public static const uint duration = 555;  // default to 1/2 for all transitions
+    public static GLib.Settings settings;
 
     private Clutter.TableLayout box_table;
     private Collection collection;
@@ -37,6 +37,7 @@ private class Boxes.App: Boxes.UI {
     private CollectionView view;
 
     public App () {
+        settings = new GLib.Settings ("org.gnome.boxes");
         setup_ui ();
         collection = new Collection ();
 
@@ -49,15 +50,15 @@ private class Boxes.App: Boxes.UI {
             view.add_item (item);
         });
 
-        setup_libvirt.begin ();
+        setup_brokers ();
     }
 
     public void set_category (Category category) {
         topbar.label.set_text (category.name);
     }
 
-    private async void setup_libvirt () {
-        connection = new GVir.Connection ("qemu:///system");
+    private async void setup_broker (string uri) {
+        var connection = new GVir.Connection (uri);
 
         try {
             yield connection.open_async (null);
@@ -67,11 +68,17 @@ private class Boxes.App: Boxes.UI {
         }
 
         foreach (var domain in connection.get_domains ()) {
-            var machine = new Machine (this, domain);
+            var machine = new Machine (this, connection, domain);
             collection.add_item (machine);
         }
     }
 
+    private async void setup_brokers () {
+        foreach (var uri in settings.get_strv("broker-uris")) {
+            setup_broker.begin (uri);
+        }
+    }
+
     private void setup_ui () {
         window = new Gtk.Window ();
         window.set_default_size (640, 480);
diff --git a/src/machine.vala b/src/machine.vala
index 4c1db3e..fae1af1 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -9,6 +9,7 @@ private class Boxes.Machine: Boxes.CollectionItem {
     public Boxes.App app;
     public MachineActor machine_actor;
     public GVir.Domain domain;
+    public GVir.Connection connection;
     public DomainState state {
         get {
             try {
@@ -57,9 +58,10 @@ private class Boxes.Machine: Boxes.CollectionItem {
         }
     }
 
-    public Machine (Boxes.App app, GVir.Domain domain) {
-        this.domain = domain;
+    public Machine (Boxes.App app, GVir.Connection connection, GVir.Domain domain) {
         this.app = app;
+        this.connection = connection;
+        this.domain = domain;
 
         name = domain.get_name ();
         machine_actor = new MachineActor (this);
@@ -94,7 +96,7 @@ private class Boxes.Machine: Boxes.CollectionItem {
             state != DomainState.PAUSED)
             return false;
 
-        var stream = app.connection.get_stream (0);
+        var stream = connection.get_stream (0);
         var file_name = get_screenshot_filename ();
         var file = File.new_for_path (file_name);
         var output_stream = yield file.replace_async (null, false, FileCreateFlags.REPLACE_DESTINATION);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]