[gnome-boxes] Display VNC source
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Display VNC source
- Date: Wed, 26 Oct 2011 19:36:38 +0000 (UTC)
commit b8e9c124c8f0e74301a3b89e80c3246e04547b88
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Wed Oct 26 21:34:47 2011 +0200
Display VNC source
src/Makefile.am | 2 +-
src/app.vala | 15 ++++++++++++---
src/machine.vala | 3 ++-
src/{spice-machine.vala => remote-machine.vala} | 16 ++++++++++++----
src/vnc-display.vala | 2 +-
5 files changed, 28 insertions(+), 10 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 13f5098..b6af7de 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -34,9 +34,9 @@ gnome_boxes_SOURCES = \
libvirt-machine.vala \
machine.vala \
main.vala \
+ remote-machine.vala \
sidebar.vala \
spice-display.vala \
- spice-machine.vala \
topbar.vala \
ui.vala \
util.vala \
diff --git a/src/app.vala b/src/app.vala
index bd6d2f7..9b48985 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -69,11 +69,20 @@ private class Boxes.App: Boxes.UI {
}
public void add_collection_source (CollectionSource source) {
- if (source.source_type == "libvirt")
+ switch (source.source_type) {
+ case "libvirt":
setup_libvirt (source);
- else if (source.source_type == "spice") {
- var machine = new SpiceMachine (source, this);
+ break;
+
+ case "vnc":
+ case "spice":
+ var machine = new RemoteMachine (source, this);
collection.add_item (machine);
+ break;
+
+ default:
+ warning ("Unsupported source type %s", source.source_type);
+ break;
}
}
diff --git a/src/machine.vala b/src/machine.vala
index 3107932..dc94484 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -95,7 +95,8 @@ private abstract class Boxes.Machine: Boxes.CollectionItem {
if (screenshot_id != 0)
return;
update_screenshot.begin ();
- screenshot_id = Timeout.add_seconds (5, () => {
+ var interval = app.settings.get_int ("screenshot-interval");
+ screenshot_id = Timeout.add_seconds (interval, () => {
update_screenshot.begin ();
return true;
diff --git a/src/spice-machine.vala b/src/remote-machine.vala
similarity index 59%
rename from src/spice-machine.vala
rename to src/remote-machine.vala
index 62c12ef..03c01b4 100644
--- a/src/spice-machine.vala
+++ b/src/remote-machine.vala
@@ -1,8 +1,8 @@
// This file is part of GNOME Boxes. License: LGPLv2+
-private class Boxes.SpiceMachine: Boxes.Machine {
+private class Boxes.RemoteMachine: Boxes.Machine {
- public SpiceMachine (CollectionSource source, Boxes.App app) {
+ public RemoteMachine (CollectionSource source, Boxes.App app) {
base (source, app, source.name);
update_screenshot.begin ();
@@ -12,8 +12,16 @@ private class Boxes.SpiceMachine: Boxes.Machine {
if (_connect_display == true)
return;
- display = new SpiceDisplay.with_uri (source.uri);
- display.connect_it ();
+ try {
+ if (source.source_type == "spice")
+ display = new SpiceDisplay.with_uri (source.uri);
+ else if (source.source_type == "vnc")
+ display = new VncDisplay.with_uri (source.uri);
+
+ display.connect_it ();
+ } catch (GLib.Error error) {
+ warning (error.message);
+ }
}
public override void disconnect_display () {
diff --git a/src/vnc-display.vala b/src/vnc-display.vala
index efcec9c..4b6c62e 100644
--- a/src/vnc-display.vala
+++ b/src/vnc-display.vala
@@ -78,7 +78,7 @@ private class Boxes.VncDisplay: Boxes.Display {
throw new Boxes.Error.INVALID ("the URI is missing a server");
this.host = uri.server;
- this.port = uri.port == -1 ? 5900 : uri.port;
+ this.port = uri.port <= 0 ? 5900 : uri.port;
}
public override Gtk.Widget? get_display (int n) throws Boxes.Error {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]