[gnome-boxes/wip/props-ui-files: 37/37] tmp
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/wip/props-ui-files: 37/37] tmp
- Date: Wed, 13 Jul 2016 13:30:27 +0000 (UTC)
commit 33bf86d14494ae8c374918a9c614c555b62211a6
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Jul 13 13:30:50 2016 +0100
tmp
src/display.vala | 3 +-
src/i-properties-provider.vala | 2 +-
src/libvirt-machine-properties.vala | 67 ++++++++++++++++------------------
src/libvirt-machine.vala | 8 ++--
src/machine.vala | 2 +-
src/ovirt-machine.vala | 14 ++++----
src/properties-page-widget.vala | 20 +---------
src/properties.vala | 4 +-
src/remote-machine.vala | 30 +++++++--------
src/spice-display.vala | 24 +++++++-----
src/vnc-display.vala | 14 +++++---
11 files changed, 88 insertions(+), 100 deletions(-)
---
diff --git a/src/display.vala b/src/display.vala
index 43128f2..99b069e 100644
--- a/src/display.vala
+++ b/src/display.vala
@@ -37,7 +37,8 @@ private abstract class Boxes.Display: GLib.Object, Boxes.IPropertiesProvider {
}
public abstract void send_keys (uint[] keyvals);
- public abstract async List<Boxes.Property> get_properties (Boxes.PropertiesPage page);
+ public abstract async PropertiesPageWidget? get_properties (Boxes.PropertiesPage page);
+ public abstract async void add_properties (PropertiesPageWidget widget, PropertiesPage page);
protected HashTable<int, Gtk.Widget?> displays;
diff --git a/src/i-properties-provider.vala b/src/i-properties-provider.vala
index 0a670d2..875101e 100644
--- a/src/i-properties-provider.vala
+++ b/src/i-properties-provider.vala
@@ -193,7 +193,7 @@ private class Boxes.EditableStringProperty : Boxes.Property {
}
private interface Boxes.IPropertiesProvider: GLib.Object {
- public abstract async List<Boxes.Property> get_properties (Boxes.PropertiesPage page);
+ public abstract async PropertiesPageWidget? get_properties (Boxes.PropertiesPage page);
protected Boxes.Property add_property (ref List<Boxes.Property> list,
string? name,
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index b210fbe..01633ac 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -80,8 +80,8 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
return builder.str;
}
- public async List<Boxes.Property> get_properties (Boxes.PropertiesPage page) {
- var list = new List<Boxes.Property> ();
+ public async PropertiesPageWidget? get_properties (Boxes.PropertiesPage page) {
+ var widget = new PropertiesPageWidget (page);
// the wizard may want to modify display properties, before connect_display()
if (machine.is_on && machine.display == null)
@@ -93,39 +93,37 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
switch (page) {
case PropertiesPage.GENERAL:
- var property = add_editable_string_property (ref list, _("_Name"), machine.name);
- property.changed.connect ((property, name) => {
+ widget.add_string_property (_("_Name"), machine.name, (name) => {
machine.name = name;
});
- var name_property = property;
machine.notify["name"].connect (() => {
- name_property.text = machine.name;
+ widget.refresh_properties ();
});
var ip = machine.get_ip_address ();
if (ip != null)
- add_string_property (ref list, _("IP Address"), ip);
+ widget.add_string_property (_("IP Address"), ip);
- add_string_property (ref list, _("Broker"), machine.source.name);
+ widget.add_string_property (_("Broker"), machine.source.name);
if (machine.display != null) {
// Translators: This is the protocal being used to connect to the display/desktop, e.g
Spice, VNC, etc.
- add_string_property (ref list, _("Display Protocol"), machine.display.protocol);
+ widget.add_string_property (_("Display Protocol"), machine.display.protocol);
if (machine.display.uri != null)
// Translators: This is the URL to connect to the display/desktop. e.g
spice://somehost:5051.
- add_string_property (ref list, _("Display URL"), machine.display.uri);
+ widget.add_string_property (_("Display URL"), machine.display.uri);
}
break;
case PropertiesPage.SYSTEM:
- add_resource_usage_graphs (ref list);
+ add_resource_usage_graphs (widget);
- add_system_props_buttons (ref list);
+ add_system_props_buttons (widget);
- get_resources_properties (ref list);
+ get_resources_properties (widget);
- add_run_in_bg_property (ref list);
+ add_run_in_bg_property (widget);
break;
@@ -136,7 +134,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
var disk_config = device_config as GVirConfig.DomainDisk;
var disk_type = disk_config.get_guest_device_type ();
if (disk_type == GVirConfig.DomainDiskGuestDeviceType.CDROM)
- add_cdrom_property (disk_config, ref list);
+ add_cdrom_property (disk_config, widget);
}
break;
@@ -147,24 +145,27 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
// Snapshots currently don't work with host-passthrough
if (config.get_cpu ().get_mode () != GVirConfig.DomainCpuMode.HOST_PASSTHROUGH &&
!VMConfigurator.is_install_config (config))
- add_snapshots_property (ref list);
+ add_snapshots_property (widget);
} catch (GLib.Error e) {
warning (e.message);
}
break;
+
+ default:
+ return null;
}
- return list;
+ return widget;
}
- public void get_resources_properties (ref List<Boxes.Property> list) {
- var ram_property = add_ram_property (ref list);
- var storage_property = add_storage_property (ref list);
+ public void get_resources_properties (PropertiesPageWidget widget) {
+ var ram_property = add_ram_property (PropertiesPageWidget widget);
+ var storage_property = add_storage_property (PropertiesPageWidget widget);
mark_recommended_resources.begin (ram_property, storage_property);
}
- private void add_cdrom_property (GVirConfig.DomainDisk disk_config, ref List<Boxes.Property> list) {
+ private void add_cdrom_property (GVirConfig.DomainDisk disk_config, PropertiesPageWidget widget) {
var grid = new Gtk.Grid ();
grid.set_orientation (Gtk.Orientation.HORIZONTAL);
grid.set_column_spacing (12);
@@ -290,7 +291,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
}
}
- private void add_resource_usage_graphs (ref List<Boxes.Property> list) {
+ private void add_resource_usage_graphs (PropertiesPageWidget widget) {
var grid = new Gtk.Grid ();
grid.margin_top = 20;
grid.margin_bottom = 20;
@@ -324,15 +325,13 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
net_graph.points = machine.net_stats;
});
- var prop = add_property (ref list, null, grid);
- ulong flushed_id = 0;
- flushed_id = prop.flushed.connect (() => {
+ widget.add_property (null, grid);
+ widget.add_deferred_change (() => {
machine.disconnect (stats_id);
- prop.disconnect (flushed_id);
});
}
- private void add_system_props_buttons (ref List<Boxes.Property> list) {
+ private void add_system_props_buttons (PropertiesPageWidget widget) {
var grid = new Gtk.Grid ();
grid.margin_bottom = 20;
grid.column_spacing = 5;
@@ -374,15 +373,13 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
machine.window.props_window.show_troubleshoot_log (log);
});
- var prop = add_property (ref list, null, grid);
- ulong flushed_id = 0;
- flushed_id = prop.flushed.connect (() => {
+ widget.add_property (null, grid);
+ widget.add_deferred_change (() => {
machine.disconnect (state_notify_id);
- prop.disconnect (flushed_id);
});
}
- private SizeProperty? add_ram_property (ref List<Boxes.Property> list) {
+ private SizeProperty? add_ram_property (PropertiesPageWidget widget) {
try {
var max_ram = machine.connection.get_node_info ().memory;
@@ -441,7 +438,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
};
}
- private SizeProperty? add_storage_property (ref List<Boxes.Property> list) {
+ private SizeProperty? add_storage_property (PropertiesPageWidget widget) {
if (machine.importing || machine.storage_volume == null)
return null;
@@ -600,7 +597,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
return machine.domain.get_snapshots ();
}
- private void add_run_in_bg_property (ref List<Boxes.Property> list) {
+ private void add_run_in_bg_property (PropertiesPageWidget widget) {
if (machine.connection != App.app.default_connection)
return; // We only autosuspend machines on default connection so this property is N/A to other
machines
@@ -629,7 +626,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
add_property (ref list, null, box, null);
}
- private Boxes.SnapshotsProperty add_snapshots_property (ref List<Boxes.Property> list) {
+ private Boxes.SnapshotsProperty add_snapshots_property (PropertiesPageWidget widget) {
var property = new SnapshotsProperty (machine);
list.append (property);
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 000ae0a..bd9b34d 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -384,13 +384,13 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
}
}
- public override async List<Boxes.Property> get_properties (Boxes.PropertiesPage page) {
- var list = yield properties.get_properties (page);
+ public override async Boxes.PropertiesPageWidget get_properties (Boxes.PropertiesPage page) {
+ var widget = yield properties.get_properties (page);
if (display != null)
- list.concat (yield display.get_properties (page));
+ yield display.add_properties (widget, page);
- return list;
+ return widget;
}
public bool update_display () throws GLib.Error {
diff --git a/src/machine.vala b/src/machine.vala
index 29efaa4..27eb703 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -358,7 +358,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
return display.get_pixbuf (0);
}
- public abstract async List<Boxes.Property> get_properties (Boxes.PropertiesPage page);
+ public abstract async PropertiesPageWidget? get_properties (Boxes.PropertiesPage page);
public abstract async void connect_display (ConnectFlags flags) throws GLib.Error;
public abstract void restart ();
diff --git a/src/ovirt-machine.vala b/src/ovirt-machine.vala
index e510d63..9ff8e47 100644
--- a/src/ovirt-machine.vala
+++ b/src/ovirt-machine.vala
@@ -63,20 +63,20 @@ private class Boxes.OvirtMachine: Boxes.Machine {
}
}
- public override async List<Boxes.Property> get_properties (Boxes.PropertiesPage page) {
- var list = new List<Boxes.Property> ();
+ public override async PropertiesPageWidget? get_properties (Boxes.PropertiesPage page) {
+ var widget = new PropertiesPageWidget (page, this);
switch (page) {
case PropertiesPage.GENERAL:
- add_string_property (ref list, _("Broker"), source.name);
- add_string_property (ref list, _("Protocol"), display.protocol);
- add_string_property (ref list, _("URL"), display.uri);
+ widget.add_string_property (_("Broker"), source.name);
+ widget.add_string_property (_("Protocol"), display.protocol);
+ widget.add_string_property (_("URL"), display.uri);
break;
}
- list.concat (yield display.get_properties (page));
+ yield display.add_properties (widget, page);
- return list;
+ return widget;
}
public override void restart () {} // See FIXME on RemoteMachine.restart
diff --git a/src/properties-page-widget.vala b/src/properties-page-widget.vala
index 0510125..6012343 100644
--- a/src/properties-page-widget.vala
+++ b/src/properties-page-widget.vala
@@ -2,7 +2,6 @@
using Gtk;
private class Boxes.PropertiesPageWidget: Gtk.Box {
- public bool empty;
public bool reboot_required;
private Gtk.Grid grid;
@@ -32,7 +31,7 @@ private class Boxes.PropertiesPageWidget: Gtk.Box {
}
}
- public async PropertiesPageWidget (PropertiesPage page, Machine machine) {
+ public async PropertiesPageWidget (PropertiesPage page) {
deferred_changes = new List<DeferredChange> ();
switch (page) {
@@ -66,21 +65,6 @@ private class Boxes.PropertiesPageWidget: Gtk.Box {
scrolled_win.add (grid);
pack_end (scrolled_win, true, true);
- properties = yield machine.get_properties (page);
- empty = properties.length () == 0;
- if (!empty) {
- foreach (var property in properties) {
- add_property (property.description,
- property.widget,
- property.extra_widget,
- property.description_alignment);
-
- property.refresh_properties.connect (() => {
- this.refresh_properties ();
- });
- }
- }
-
show_all ();
}
@@ -120,7 +104,7 @@ private class Boxes.PropertiesPageWidget: Gtk.Box {
public void add_property (string? description,
Gtk.Widget widget,
- Gtk.Widget? extra_widget,
+ Gtk.Widget? extra_widget = null,
Gtk.Align description_alignment = Gtk.Align.END) {
if (description != null) {
var label_name = new Gtk.Label.with_mnemonic (description);
diff --git a/src/properties.vala b/src/properties.vala
index 5c3e531..33ed20f 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -33,8 +33,8 @@ private class Boxes.Properties: Gtk.Notebook, Boxes.UI {
return;
for (var i = 0; i < PropertiesPage.LAST; i++) {
- var page = yield new PropertiesPageWidget (i, machine);
- if (page.empty)
+ var page = yield machine.get_properties (i);
+ if (page == null)
continue;
var label = new Gtk.Label (page.name);
diff --git a/src/remote-machine.vala b/src/remote-machine.vala
index ece3ecb..0879b1a 100644
--- a/src/remote-machine.vala
+++ b/src/remote-machine.vala
@@ -53,30 +53,28 @@ private class Boxes.RemoteMachine: Boxes.Machine, Boxes.IPropertiesProvider {
}
}
- public override async List<Boxes.Property> get_properties (Boxes.PropertiesPage page) {
- var list = new List<Boxes.Property> ();
+ public override async PropertiesPageWidget? get_properties (Boxes.PropertiesPage page) {
+ var widget = new PropertiesPageWidget (page);
switch (page) {
case PropertiesPage.GENERAL:
- var property = add_editable_string_property (ref list, _("_Name"), source.name);
- property.changed.connect ((property, name) => {
+ widget.add_string_property (_("_Name"), source.name, (name) => {
this.name = name;
});
- var name_property = property;
notify["name"].connect (() => {
- name_property.text = name;
+ widget.refresh_properties ();
});
- add_string_property (ref list, _("Protocol"), source.source_type.up ());
- if (is_connected) {
- add_string_property (ref list, _("URL"), source.uri);
- } else {
- property = add_editable_string_property (ref list, _("_URL"), source.uri);
- property.changed.connect ((property, uri) => {
+ widget.add_string_property (_("Protocol"), source.source_type.up ());
+ PropertiesPageWidget.StringPropertyChanged? on_changed;
+ if (is_connected)
+ on_changed = null;
+ else
+ on_changed = (uri) => {
source.uri = uri;
- });
- }
+ };
+ widget.add_string_property (_("_URL"), source.uri, on_changed);
break;
}
@@ -85,12 +83,12 @@ private class Boxes.RemoteMachine: Boxes.Machine, Boxes.IPropertiesProvider {
if (display == null)
display = create_display ();
- list.concat (yield display.get_properties (page));
+ yield display.add_properties (widget, page);
} catch (Boxes.Error error) {
warning (error.message);
}
- return list;
+ return widget;
}
public override void delete (bool by_user = true) {
diff --git a/src/spice-display.vala b/src/spice-display.vala
index 05e6ee1..71753ca 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -306,16 +306,22 @@ private class Boxes.SpiceDisplay: Boxes.Display {
}
}
- public override async List<Boxes.Property> get_properties (Boxes.PropertiesPage page) {
- var list = new List<Boxes.Property> ();
+ public override async Boxes.PropertiesPageWidget? get_properties (Boxes.PropertiesPage page) {
+ var widget = new PropertiesPageWidget (page);
+ yield add_properties (widget, page);
+
+ return widget;
+ }
+
+ public override async void add_properties (PropertiesPageWidget widget, PropertiesPage page) {
switch (page) {
case PropertiesPage.GENERAL:
var toggle = new Gtk.Switch ();
gtk_session.bind_property ("auto-clipboard", toggle, "active",
BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
toggle.halign = Gtk.Align.START;
- add_property (ref list, _("Share Clipboard"), toggle);
+ widget.add_property (_("Share Clipboard"), toggle);
if (!connected || !main_channel.agent_connected)
break;
@@ -329,7 +335,7 @@ private class Boxes.SpiceDisplay: Boxes.Display {
label.use_markup = true;
label.get_style_context ().add_class ("boxes-spice-tools-notice-label");
- add_property (ref list, null, label);
+ widget.add_property (null, label);
break;
case PropertiesPage.DEVICES:
@@ -341,7 +347,7 @@ private class Boxes.SpiceDisplay: Boxes.Display {
var devs = get_usb_devices (manager);
if (devs.length <= 0)
- return list;
+ return;
devs.sort ( (a, b) => {
string str_a = a.get_description (" %1$s %2$s");
@@ -395,20 +401,18 @@ private class Boxes.SpiceDisplay: Boxes.Display {
});
}
- var usb_property = add_property (ref list, _("USB devices"), new Gtk.Label (""), frame);
+ widget.add_property (_("USB devices"), new Gtk.Label (""), frame);
manager.device_added.connect ((manager, dev) => {
- usb_property.refresh_properties ();
+ widget.refresh_properties ();
});
manager.device_removed.connect ((manager, dev) => {
- usb_property.refresh_properties ();
+ widget.refresh_properties ();
});
} catch (GLib.Error error) {
}
break;
}
-
- return list;
}
public override void send_keys (uint[] keyvals) {
diff --git a/src/vnc-display.vala b/src/vnc-display.vala
index d572ae3..65c244a 100644
--- a/src/vnc-display.vala
+++ b/src/vnc-display.vala
@@ -133,20 +133,24 @@ private class Boxes.VncDisplay: Boxes.Display {
display.close ();
}
- public override async List<Boxes.Property> get_properties (Boxes.PropertiesPage page) {
- var list = new List<Boxes.Property> ();
+ public override async Boxes.PropertiesPageWidget? get_properties (Boxes.PropertiesPage page) {
+ var widget = new PropertiesPageWidget (page);
+ yield add_properties (widget, page);
+
+ return widget;
+ }
+
+ public override async void add_properties (PropertiesPageWidget widget, PropertiesPage page) {
switch (page) {
case PropertiesPage.GENERAL:
var toggle = new Gtk.Switch ();
toggle.halign = Gtk.Align.START;
display.bind_property ("read-only", toggle, "active",
BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
- add_property (ref list, _("Read-only"), toggle);
+ widget.add_property (_("Read-only"), toggle);
break;
}
-
- return list;
}
public override void send_keys (uint[] keyvals) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]