[gnome-boxes] Add generic broker support to App



commit 453b2f2861551659985391741e486f183d7e35b6
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Sat Sep 1 16:28:37 2012 +0200

    Add generic broker support to App
    
    Add some code in App to let brokers register the uri schemes they know
    how to handle, and to automatically use the registered brokers. This
    is achieved through the addition of a Broker base class.
    However, I'm not sure it's possible to have broker registration run
    automatically at the application startup, so we may still need a bit
    of broker specific code in App.vala :(
    
    https://bugzilla.gnome.org/show_bug.cgi?id=681747

 src/app.vala |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index 5676688..c1c8c90 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -3,6 +3,10 @@ using Gtk;
 using Gdk;
 using Clutter;
 
+private abstract class Boxes.Broker : GLib.Object {
+    public abstract async void add_source (CollectionSource source);
+}
+
 private enum Boxes.AppPage {
     MAIN,
     DISPLAY
@@ -77,6 +81,7 @@ private class Boxes.App: Boxes.UI {
     private Boxes.Application application;
     public CollectionView view;
 
+    private HashTable<string,Broker> brokers;
     private HashTable<string,GVir.Connection> connections;
     private HashTable<string,CollectionSource> sources;
     public GVir.Connection default_connection { get { return connections.get ("QEMU Session"); } }
@@ -93,6 +98,7 @@ private class Boxes.App: Boxes.UI {
         settings = new GLib.Settings ("org.gnome.boxes");
         connections = new HashTable<string, GVir.Connection> (str_hash, str_equal);
         sources = new HashTable<string,CollectionSource> (str_hash, str_equal);
+        brokers = new HashTable<string,Broker> (str_hash, str_equal);
         filter = new Boxes.CollectionFilter ();
         var action = new GLib.SimpleAction ("quit", null);
         action.activate.connect (() => { quit (); });
@@ -438,7 +444,13 @@ private class Boxes.App: Boxes.UI {
             break;
 
         default:
-            warning ("Unsupported source type %s", source.source_type);
+            Broker? broker = brokers.lookup(source.source_type);
+            if (broker != null) {
+                yield broker.add_source (source);
+                sources.insert (source.name, source);
+            } else {
+                warning ("Unsupported source type %s", source.source_type);
+            }
             break;
         }
     }


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