[gnome-boxes] Change Pair property into object Property
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Change Pair property into object Property
- Date: Mon, 30 Jul 2012 17:13:55 +0000 (UTC)
commit b1ce37da8b10d3f39b44430bdc0f70d93df2daa1
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Thu Jul 19 15:15:44 2012 +0200
Change Pair property into object Property
https://bugzilla.gnome.org/show_bug.cgi?id=680293
src/display.vala | 2 +-
src/i-properties-provider.vala | 46 ++++++++++++++++++++++++++--------------
src/libvirt-machine.vala | 4 +-
src/machine.vala | 2 +-
src/properties.vala | 4 +-
src/remote-machine.vala | 4 +-
src/spice-display.vala | 4 +-
src/vnc-display.vala | 4 +-
8 files changed, 42 insertions(+), 28 deletions(-)
---
diff --git a/src/display.vala b/src/display.vala
index e24396a..a60989d 100644
--- a/src/display.vala
+++ b/src/display.vala
@@ -28,7 +28,7 @@ private abstract class Boxes.Display: GLib.Object, Boxes.IPropertiesProvider {
public abstract void connect_it ();
public abstract void disconnect_it ();
- public abstract List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page);
+ public abstract List<Boxes.Property> get_properties (Boxes.PropertiesPage page);
protected HashTable<int, Gtk.Widget?> displays;
construct {
diff --git a/src/i-properties-provider.vala b/src/i-properties-provider.vala
index ed8d78c..7fe6bcc 100644
--- a/src/i-properties-provider.vala
+++ b/src/i-properties-provider.vala
@@ -1,26 +1,39 @@
// This file is part of GNOME Boxes. License: LGPLv2+
using Gtk;
+private class Boxes.Property: GLib.Object {
+ public string description { get; construct set; }
+ public Gtk.Widget widget { get; construct set; }
+ public bool changes_pending { get; set; }
+
+ public Property (string description, Gtk.Widget widget) {
+ base (description: description, widget: widget);
+ }
+}
+
public delegate void PropertyStringChanged (string value) throws Boxes.Error;
public delegate void PropertySizeChanged (uint64 value) throws Boxes.Error;
private interface Boxes.IPropertiesProvider: GLib.Object {
- public abstract List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page);
+ public abstract List<Boxes.Property> 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 Boxes.Property add_property (ref List<Boxes.Property> list, string name, Widget widget) {
+ var property = new Property (name, widget);
+ list.append (property);
+ return property;
}
- protected void add_string_property (ref List<Pair<string, Widget>> list,
- string name,
- string value,
- PropertyStringChanged? changed = null) {
+ protected Boxes.Property add_string_property (ref List<Boxes.Property> list,
+ string name,
+ string value,
+ PropertyStringChanged? changed = null) {
var entry = new Boxes.EditableEntry ();
entry.text = value;
entry.selectable = true;
entry.editable = changed != null;
+ var property = add_property (ref list, name, entry);
entry.editing_done.connect (() => {
try {
changed (entry.text);
@@ -31,16 +44,16 @@ private interface Boxes.IPropertiesProvider: GLib.Object {
}
});
- add_property (ref list, name, entry);
+ return property;
}
- protected void add_size_property (ref List<Pair<string, Widget>> list,
- string name,
- uint64 size,
- uint64 min,
- uint64 max,
- uint64 step,
- PropertySizeChanged? changed = null) {
+ protected Boxes.Property add_size_property (ref List<Boxes.Property> list,
+ string name,
+ uint64 size,
+ uint64 min,
+ uint64 max,
+ uint64 step,
+ PropertySizeChanged? changed = null) {
var scale = new Gtk.HScale.with_range (min, max, step);
scale.format_value.connect ((scale, value) => {
@@ -52,6 +65,7 @@ private interface Boxes.IPropertiesProvider: GLib.Object {
scale.vexpand = true;
scale.margin_bottom = 20;
+ var property = add_property (ref list, name, scale);
if (changed != null)
scale.value_changed.connect (() => {
try {
@@ -61,7 +75,7 @@ private interface Boxes.IPropertiesProvider: GLib.Object {
}
});
- add_property (ref list, name, scale);
+ return property;
}
}
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 823c09a..c6e0d49 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -288,8 +288,8 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
}
}
- public override List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page) {
- var list = new List<Pair<string, Widget>> ();
+ public override List<Boxes.Property> get_properties (Boxes.PropertiesPage page) {
+ var list = new List<Boxes.Property> ();
switch (page) {
case PropertiesPage.LOGIN:
diff --git a/src/machine.vala b/src/machine.vala
index 0e0b2ec..b31d7ac 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -160,7 +160,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
return null;
}
- public abstract List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page);
+ public abstract List<Boxes.Property> get_properties (Boxes.PropertiesPage page);
public abstract string get_screenshot_prefix ();
diff --git a/src/properties.vala b/src/properties.vala
index e0b290b..3e6d287 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -70,13 +70,13 @@ private class Boxes.Properties: Boxes.UI {
if (!empty) {
int current_row = 1;
foreach (var property in properties) {
- var label_name = new Gtk.Label (property.first);
+ var label_name = new Gtk.Label (property.description);
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 = property.second;
+ var widget = property.widget;
grid.attach (widget, 1, current_row, 1, 1);
current_row += 1;
diff --git a/src/remote-machine.vala b/src/remote-machine.vala
index 87ac3cb..1bd3e53 100644
--- a/src/remote-machine.vala
+++ b/src/remote-machine.vala
@@ -31,8 +31,8 @@ private class Boxes.RemoteMachine: Boxes.Machine, Boxes.IPropertiesProvider {
}
}
- public override List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page) {
- var list = new List<Pair<string, Widget>> ();
+ public override List<Boxes.Property> get_properties (Boxes.PropertiesPage page) {
+ var list = new List<Boxes.Property> ();
switch (page) {
case PropertiesPage.LOGIN:
diff --git a/src/spice-display.vala b/src/spice-display.vala
index 92e187d..200782c 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -145,8 +145,8 @@ private class Boxes.SpiceDisplay: Boxes.Display, Boxes.IPropertiesProvider {
}
}
- public override List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page) {
- var list = new List<Pair<string, Widget>> ();
+ public override List<Boxes.Property> get_properties (Boxes.PropertiesPage page) {
+ var list = new List<Boxes.Property> ();
switch (page) {
case PropertiesPage.DISPLAY:
diff --git a/src/vnc-display.vala b/src/vnc-display.vala
index 688e0ed..ea3ab64 100644
--- a/src/vnc-display.vala
+++ b/src/vnc-display.vala
@@ -123,8 +123,8 @@ private class Boxes.VncDisplay: Boxes.Display {
display.close ();
}
- public override List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page) {
- var list = new List<Pair<string, Widget>> ();
+ public override List<Boxes.Property> get_properties (Boxes.PropertiesPage page) {
+ var list = new List<Boxes.Property> ();
switch (page) {
case PropertiesPage.DISPLAY:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]