[gnome-boxes/wip/props-ui-files: 9/12] props-page-widget: Add add_string_property()



commit eded07ae5f9df2d0ff3de0cae1da477f9bf3dabc
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Jun 1 21:13:24 2016 +0100

    props-page-widget: Add add_string_property()
    
    Add a method that adds a string property. Like the previous patches, this
    ignores the Property hierarchy intentionally to allow for smooth
    transition from Property hierarchy to (yet to be created)
    PropertyPageWidget hierarchy

 src/properties-page-widget.vala |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/properties-page-widget.vala b/src/properties-page-widget.vala
index e664448..312d1fd 100644
--- a/src/properties-page-widget.vala
+++ b/src/properties-page-widget.vala
@@ -12,6 +12,7 @@ private class Boxes.PropertiesPageWidget: Gtk.Box {
     public signal void refresh_properties ();
 
     public delegate void SizePropertyChanged (uint64 value);
+    public delegate void StringPropertyChanged (string value);
 
     private int num_rows = 0;
 
@@ -203,4 +204,24 @@ private class Boxes.PropertiesPageWidget: Gtk.Box {
             changed ((uint64) scale.get_value ());
         });
     }
+
+    public void add_string_property (string name, string value, StringPropertyChanged? changed = null) {
+        if (changed != null) {
+            var entry = new Gtk.Entry ();
+
+            add_property (name, entry, null);
+
+            entry.text = value;
+
+            entry.notify["text"].connect (() => {
+                changed (entry.text);
+            });
+        } else {
+            var label = new Gtk.Label (value);
+            label.halign = Gtk.Align.START;
+            label.selectable = true;
+
+            add_property (name, label, null);
+        }
+    }
 }


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