summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2012-09-01 16:28:37 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2013-01-30 16:49:51 +0100
commitb84c9730bf2fda451f2d60b3294f76149027bb5a (patch)
treec1ebc84ad3c89f072424e09cee82e3dbe31eeab4
parent4b03c5476344499c84b405285f963046ae330231 (diff)
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
-rw-r--r--src/app.vala14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/app.vala b/src/app.vala
index 73dddf6..c0ffaa8 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 (); });
@@ -426,7 +432,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;
}
}