[gnome-boxes] Sync a few properties from libvirt/vnc/spice
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Sync a few properties from libvirt/vnc/spice
- Date: Fri, 28 Oct 2011 15:19:39 +0000 (UTC)
commit 4c91fe5aab3e669a81069ca5bc65910a2647a562
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Fri Oct 28 01:44:01 2011 +0200
Sync a few properties from libvirt/vnc/spice
src/app.vala | 11 +-
src/display.vala | 8 +-
src/libvirt-machine.vala | 20 +++
src/machine.vala | 4 +-
src/properties.vala | 57 ++++++--
src/remote-machine.vala | 24 +++-
src/spice-display.vala | 39 +++++-
src/vnc-display.vala | 18 ++
vapi/spice-client-glib-2.0.vapi | 326 ---------------------------------------
vapi/spice-client-gtk-3.0.deps | 1 -
vapi/spice-client-gtk-3.0.vapi | 49 ------
11 files changed, 158 insertions(+), 399 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index 14c4a94..0c9caee 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -228,19 +228,16 @@ private class Boxes.App: Boxes.UI {
}
private bool item_clicked (CollectionItem item, Clutter.ButtonEvent event) {
- message ("button %u".printf (event.button));
-
- if (Clutter.ModifierType.BUTTON2_MASK in event.modifier_state)
- return false;
-
if (ui_state == UIState.COLLECTION) {
current_item = item;
if (current_item is Machine) {
var machine = current_item as Machine;
- machine.connect_display ();
- ui_state = UIState.CREDS;
+ if (event.button == 1) {
+ machine.connect_display ();
+ ui_state = UIState.CREDS;
+ }
} else
warning ("unknown item, fix your code");
}
diff --git a/src/display.vala b/src/display.vala
index afc85ee..ffbd72e 100644
--- a/src/display.vala
+++ b/src/display.vala
@@ -1,6 +1,10 @@
// This file is part of GNOME Boxes. License: LGPLv2+
+using Gtk;
+
+private abstract class Boxes.Display: GLib.Object, Boxes.IProperties {
+ public abstract string protocol { get; }
+ public abstract string uri { owned get; }
-private abstract class Boxes.Display: GLib.Object {
public bool need_password { get; set; }
public bool need_username { get; set; }
public string? password { get; set; }
@@ -14,6 +18,8 @@ private abstract class Boxes.Display: GLib.Object {
public abstract void connect_it ();
public abstract void disconnect_it ();
+ public abstract List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page);
+
protected HashTable<int, Gtk.Widget?> displays;
construct {
displays = new HashTable<int, Gtk.Widget> (direct_hash, direct_equal);
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 37d606e..beddb25 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -1,5 +1,6 @@
// This file is part of GNOME Boxes. License: LGPLv2+
using GVir;
+using Gtk;
private class Boxes.LibvirtMachine: Boxes.Machine {
public GVir.Domain domain;
@@ -71,6 +72,25 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
set_screenshot_enable (true);
}
+ public override List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page) {
+ var list = new List<Pair<string, Widget>> ();
+
+ switch (page) {
+ case PropertiesPage.LOGIN:
+ add_string_property (ref list, _("Virtualizer"), source.uri);
+ add_string_property (ref list, _("URI"), display.uri);
+ break;
+
+ case PropertiesPage.DISPLAY:
+ add_string_property (ref list, _("Protocol"), display.protocol);
+ break;
+ }
+
+ list.concat (display.get_properties (page));
+
+ return list;
+ }
+
private void update_display () {
string type, port, socket, host;
diff --git a/src/machine.vala b/src/machine.vala
index 3c561a5..c629c36 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -3,7 +3,7 @@ using Clutter;
using Gdk;
using Gtk;
-private abstract class Boxes.Machine: Boxes.CollectionItem {
+private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IProperties {
public override Clutter.Actor actor { get { return machine_actor.actor; } }
public Boxes.App app;
public MachineActor machine_actor;
@@ -116,6 +116,8 @@ private abstract class Boxes.Machine: Boxes.CollectionItem {
return false;
}
+ public abstract List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page);
+
public abstract bool is_running ();
public abstract string get_screenshot_prefix ();
diff --git a/src/properties.vala b/src/properties.vala
index aec3c28..b8188cd 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -9,6 +9,24 @@ private enum Boxes.PropertiesPage {
LAST,
}
+public delegate void PropertyStringChanged (string value) throws Boxes.Error;
+
+private interface Boxes.IProperties: GLib.Object {
+ public abstract List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page);
+
+ protected void add_property (ref List<Pair<string, Widget>> list, string name, Widget widget) {
+ list.append (new Pair<string, Widget> (name, widget));
+ }
+
+ protected void add_string_property (ref List<Pair<string, Widget>> list,
+ string name, string value,
+ PropertyStringChanged? changed = null) {
+ var label = new Gtk.Label (value);
+ label.selectable = true;
+ add_property (ref list, name, label);
+ }
+}
+
private class Boxes.Properties: Boxes.UI {
public override Clutter.Actor actor { get { return gtk_actor; } }
@@ -24,7 +42,7 @@ private class Boxes.Properties: Boxes.UI {
public Gtk.Widget widget;
public string name;
- private Gtk.Table table;
+ private Gtk.Grid grid;
public PageWidget (PropertiesPage page, Machine machine) {
switch (page) {
@@ -41,22 +59,36 @@ private class Boxes.Properties: Boxes.UI {
break;
}
- var vbox = new Gtk.VBox (false, 10);
- table = new Gtk.Table (1, 2, false);
- vbox.pack_start (table, false, false, 0);
- table.margin = 20;
- table.row_spacing = 10;
- table.column_spacing = 20;
+ grid = new Gtk.Grid ();
+ grid.margin = 20;
+ grid.row_spacing = 10;
+ grid.column_spacing = 20;
+ grid.valign = Gtk.Align.START;
- table.resize (1, 2);
var label = new Gtk.Label (name);
label.get_style_context ().add_class ("boxes-step-label");
label.margin_bottom = 10;
label.xalign = 0.0f;
- table.attach_defaults (label, 0, 2, 0, 1);
+ label.hexpand = false;
+ grid.attach (label, 0, 0, 2, 1);
+
+ int current_row = 1;
+ foreach (var p in machine.get_properties (page)) {
+ var label_name = new Gtk.Label (p.first);
+ label_name.modify_fg (Gtk.StateType.NORMAL, get_color ("grey"));
+ label_name.margin_left = 25;
+ label_name.halign = Gtk.Align.START;
+ label_name.hexpand = false;
+ grid.attach (label_name, 0, current_row, 1, 1);
+ var widget = p.second;
+ widget.halign = Gtk.Align.START;
+ grid.attach (widget, 1, current_row, 1, 1);
+
+ current_row += 1;
+ }
- vbox.show_all ();
- widget = vbox;
+ grid.show_all ();
+ widget = grid;
}
public bool is_empty () {
@@ -80,7 +112,7 @@ private class Boxes.Properties: Boxes.UI {
private void populate () {
listmodel.clear ();
for (var i = 0; i < PropertiesPage.LAST; i++)
- notebook.remove_page (i);
+ notebook.remove_page (-1);
if (app.current_item == null)
return;
@@ -147,6 +179,7 @@ private class Boxes.Properties: Boxes.UI {
tree_view.set_model (listmodel);
tree_view.headers_visible = false;
var renderer = new CellRendererText ();
+ renderer.xpad = 20;
tree_view.insert_column_with_attributes (-1, "", renderer, "text", 0);
vbox.pack_start (tree_view, true, true, 0);
diff --git a/src/remote-machine.vala b/src/remote-machine.vala
index 03c01b4..942328d 100644
--- a/src/remote-machine.vala
+++ b/src/remote-machine.vala
@@ -1,6 +1,7 @@
// This file is part of GNOME Boxes. License: LGPLv2+
+using Gtk;
-private class Boxes.RemoteMachine: Boxes.Machine {
+private class Boxes.RemoteMachine: Boxes.Machine, Boxes.IProperties {
public RemoteMachine (CollectionSource source, Boxes.App app) {
base (source, app, source.name);
@@ -35,6 +36,27 @@ private class Boxes.RemoteMachine: Boxes.Machine {
}
}
+ public override List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page) {
+ var list = new List<Pair<string, Widget>> ();
+
+ switch (page) {
+ case PropertiesPage.LOGIN:
+ add_string_property (ref list, _("Name"), source.name, (name) => {
+ source.name = name;
+ });
+ add_string_property (ref list, _("URI"), source.uri);
+ break;
+
+ case PropertiesPage.DISPLAY:
+ add_string_property (ref list, _("Protocol"), source.source_type.up ());
+ break;
+ }
+
+ list.concat (display.get_properties (page));
+
+ return list;
+ }
+
public override string get_screenshot_prefix () {
return source.filename;
}
diff --git a/src/spice-display.vala b/src/spice-display.vala
index 61870e4..ab59ffc 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -2,8 +2,12 @@
using Gtk;
using Spice;
-private class Boxes.SpiceDisplay: Boxes.Display {
+private class Boxes.SpiceDisplay: Boxes.Display, Boxes.IProperties {
+ public override string protocol { get { return "SPICE"; } }
+ public override string uri { owned get { return session.uri; } }
+
private Session session;
+ private unowned GtkSession gtk_session;
private ulong channel_new_id;
private ulong channel_destroy_id;
@@ -15,6 +19,7 @@ private class Boxes.SpiceDisplay: Boxes.Display {
session = new Session ();
session.port = port.to_string ();
session.host = host;
+ gtk_session = GtkSession.get (session);
}
public SpiceDisplay.with_uri (string uri) {
@@ -83,4 +88,36 @@ private class Boxes.SpiceDisplay: Boxes.Display {
break;
}
}
+
+ public override List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page) {
+ var list = new List<Pair<string, Widget>> ();
+
+ switch (page) {
+ case PropertiesPage.DISPLAY:
+ var toggle = new Gtk.Switch ();
+ gtk_session.bind_property ("auto-clipboard", toggle, "active",
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
+ add_property (ref list, _("Share clipboard"), toggle);
+
+ try {
+ toggle = new Gtk.Switch ();
+ var display = get_display (0);
+ display.bind_property ("resize-guest", toggle, "active",
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
+ add_property (ref list, _("Resize guest"), toggle);
+ } catch (Boxes.Error error) {
+ warning (error.message);
+ }
+ break;
+
+ case PropertiesPage.DEVICES:
+ var toggle = new Gtk.Switch ();
+ gtk_session.bind_property ("auto-usbredir", toggle, "active",
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
+ add_property (ref list, _("USB redirection"), toggle);
+ break;
+ }
+
+ return list;
+ }
}
diff --git a/src/vnc-display.vala b/src/vnc-display.vala
index 4b6c62e..deaa47e 100644
--- a/src/vnc-display.vala
+++ b/src/vnc-display.vala
@@ -3,6 +3,9 @@ using Gtk;
using Vnc;
private class Boxes.VncDisplay: Boxes.Display {
+ public override string protocol { get { return "VNC"; } }
+ public override string uri { owned get { return @"vnc://$host:$port"; } }
+
private Vnc.Display display;
private string host;
private int port;
@@ -100,4 +103,19 @@ private class Boxes.VncDisplay: Boxes.Display {
if (display.is_open ())
display.close ();
}
+
+ public override List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page) {
+ var list = new List<Pair<string, Widget>> ();
+
+ switch (page) {
+ case PropertiesPage.DISPLAY:
+ var toggle = new Gtk.Switch ();
+ display.bind_property ("read-only", toggle, "active",
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
+ add_property (ref list, _("Read-only"), toggle);
+ break;
+ }
+
+ return list;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]