[gnome-boxes/gnome-3-32] properties-page-widget: Let Properties create its label



commit 691559e0d187261666d2a7dc2c81403a06e22e81
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue May 21 16:35:33 2019 +0200

    properties-page-widget: Let Properties create its label
    
    Instead of creating labels based on descriptions for each Property,
    let's create the Labels in the Property class itself, so we access
    the label as much as the action widget.

 src/i-properties-provider.vala  | 12 ++++++++++++
 src/properties-page-widget.vala | 16 +++-------------
 2 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/src/i-properties-provider.vala b/src/i-properties-provider.vala
index 65eab35d..3dba4ee9 100644
--- a/src/i-properties-provider.vala
+++ b/src/i-properties-provider.vala
@@ -3,6 +3,7 @@
 
 private class Boxes.Property: GLib.Object {
     public string? description { get; construct set; }
+    public Gtk.Label? label;
     public Gtk.Widget widget { get; construct set; }
     public Gtk.Widget? extra_widget { get; construct set; }
     public bool reboot_required { get; set; }
@@ -50,6 +51,17 @@
 
     public Property (string? description, Gtk.Widget widget, Gtk.Widget? extra_widget) {
         base (description: description, widget: widget, extra_widget: extra_widget);
+
+        label = new Gtk.Label.with_mnemonic (description);
+        label.get_style_context ().add_class ("dim-label");
+        label.halign = description_alignment;
+        label.hexpand = false;
+
+        widget.hexpand = true;
+
+        if (description != null) {
+            label.mnemonic_widget = widget;
+        }
     }
 
     public void flush () {
diff --git a/src/properties-page-widget.vala b/src/properties-page-widget.vala
index 825ab34b..3374b9d5 100644
--- a/src/properties-page-widget.vala
+++ b/src/properties-page-widget.vala
@@ -47,25 +47,15 @@ public PropertiesPageWidget (PropertiesPage page, Machine machine) {
             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;
+                    grid.attach (property.label, 0, current_row, 1, 1);
+                    grid.attach (property.widget, 1, current_row, 1, 1);
                 } else {
-                    var widget = property.widget;
-                    widget.hexpand = true;
-                    grid.attach (widget, 0, current_row, 2, 1);
+                    grid.attach (property.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);
                 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]