[gnome-boxes] remote-machine: return properties when display isn't connected



commit f970cb4be7591593f4c020e8a87fe47735c5e16b
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Mon Oct 29 12:35:07 2012 +0100

    remote-machine: return properties when display isn't connected
    
    Currently, get_properties () returns correctly only when the display
    is connected, because the display isn't created until then.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684233

 src/remote-machine.vala |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/src/remote-machine.vala b/src/remote-machine.vala
index 8bf543f..b56a94f 100644
--- a/src/remote-machine.vala
+++ b/src/remote-machine.vala
@@ -15,14 +15,24 @@ private class Boxes.RemoteMachine: Boxes.Machine, Boxes.IPropertiesProvider {
         load_screenshot ();
     }
 
-    public override async void connect_display () throws GLib.Error {
-        if (display != null)
-            return;
+    private Display? create_display () throws Boxes.Error {
+        var type = source.source_type;
+
+        switch (type) {
+        case "spice":
+            return new SpiceDisplay.with_uri (config, source.uri);
+
+        case "vnc":
+            return new VncDisplay.with_uri (config, source.uri);
 
-        if (source.source_type == "spice")
-            display = new SpiceDisplay.with_uri (config, source.uri);
-        else if (source.source_type == "vnc")
-            display = new VncDisplay.with_uri (config, source.uri);
+        default:
+            throw new Boxes.Error.INVALID ("unsupported display of type " + type);
+        }
+    }
+
+    public override async void connect_display () throws GLib.Error {
+        if (display == null)
+            display = create_display ();
 
         display.connect_it ();
     }
@@ -43,7 +53,14 @@ private class Boxes.RemoteMachine: Boxes.Machine, Boxes.IPropertiesProvider {
             break;
         }
 
-        list.concat (display.get_properties (page));
+        try {
+            if (display == null)
+                display = create_display ();
+
+            list.concat (display.get_properties (page));
+        } catch (Boxes.Error error) {
+            warning (error.message);
+        }
 
         return list;
     }



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