[gnome-boxes/wip/props-ui-files: 10/16] props-page-widget: Add add_property()
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/wip/props-ui-files: 10/16] props-page-widget: Add add_property()
- Date: Fri, 15 Jul 2016 14:55:19 +0000 (UTC)
commit 896b42c7b3f7637c0ed74b1818751ff2208df229
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Jun 1 21:13:24 2016 +0100
props-page-widget: Add add_property()
Split property addition code into a separa te public method. This method
is kept independent of Property class on purpose to allow for smooth
transition from Property hierarchy to (yet to be created)
PropertyPageWidget hierarchy.
src/properties-page-widget.vala | 58 +++++++++++++++++++++++----------------
1 files changed, 34 insertions(+), 24 deletions(-)
---
diff --git a/src/properties-page-widget.vala b/src/properties-page-widget.vala
index 6734f36..2d60b3d 100644
--- a/src/properties-page-widget.vala
+++ b/src/properties-page-widget.vala
@@ -11,6 +11,8 @@ private class Boxes.PropertiesPageWidget: Gtk.Box {
public signal void refresh_properties ();
+ private int num_rows = 0;
+
public PropertiesPageWidget (PropertiesPage page, Machine machine) {
deferred_changes = new List<DeferredChange> ();
@@ -48,35 +50,15 @@ private class Boxes.PropertiesPageWidget: Gtk.Box {
properties = machine.get_properties (page);
empty = properties.length () == 0;
if (!empty) {
- int current_row = 1;
foreach (var property in properties) {
- if (property.description != null) {
- var label_name = new Gtk.Label.with_mnemonic (property.description);
- label_name.get_style_context ().add_class ("dim-label");
- label_name.halign = property.description_alignment;
- label_name.hexpand = false;
- grid.attach (label_name, 0, current_row, 1, 1);
- var widget = property.widget;
- widget.hexpand = true;
- grid.attach (widget, 1, current_row, 1, 1);
- label_name.mnemonic_widget = widget;
- } else {
- var widget = property.widget;
- widget.hexpand = true;
- grid.attach (widget, 0, current_row, 2, 1);
- }
-
- var widget = property.extra_widget;
- if (widget != null) {
- current_row += 1;
- widget.hexpand = true;
- grid.attach (widget, 0, current_row, 2, 1);
- }
+ add_property (property.description,
+ property.widget,
+ property.extra_widget,
+ property.description_alignment);
property.refresh_properties.connect (() => {
this.refresh_properties ();
});
- current_row += 1;
}
}
@@ -116,4 +98,32 @@ private class Boxes.PropertiesPageWidget: Gtk.Box {
deferred_changes.append (change);
}
+
+ public void add_property (string? description,
+ Gtk.Widget widget,
+ Gtk.Widget? extra_widget,
+ Gtk.Align description_alignment = Gtk.Align.END) {
+ if (description != null) {
+ var label_name = new Gtk.Label.with_mnemonic (description);
+ label_name.get_style_context ().add_class ("dim-label");
+ label_name.halign = description_alignment;
+ label_name.hexpand = false;
+ grid.attach (label_name, 0, num_rows, 1, 1);
+ widget.hexpand = true;
+ grid.attach (widget, 1, num_rows, 1, 1);
+ label_name.mnemonic_widget = widget;
+ } else {
+ widget.hexpand = true;
+ grid.attach (widget, 0, num_rows, 2, 1);
+ }
+
+ num_rows++;
+
+ if (extra_widget != null) {
+ extra_widget.hexpand = true;
+ grid.attach (extra_widget, 0, num_rows, 2, 1);
+
+ num_rows++;
+ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]