[gnome-boxes] size-property: API to mark recommended size



commit a47a1aeeade9b3fd064c5cf4262a62c7d4d77157
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Feb 6 00:48:06 2013 +0200

    size-property: API to mark recommended size
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688333

 src/i-properties-provider.vala |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/i-properties-provider.vala b/src/i-properties-provider.vala
index 8efd122..77d2a4c 100644
--- a/src/i-properties-provider.vala
+++ b/src/i-properties-provider.vala
@@ -53,6 +53,20 @@ private class Boxes.Property: GLib.Object {
 private class Boxes.SizeProperty : Boxes.Property {
     public signal void changed (uint64 value);
 
+    private Gtk.Scale scale;
+
+    public uint64 recommended  {
+        set {
+            // FIXME: Better way to ensure recommended mark is not too close to min and max marks?
+            if (value < (scale.adjustment.lower + Osinfo.GIBIBYTES) ||
+                value > (scale.adjustment.upper - Osinfo.GIBIBYTES))
+                return;
+
+            var size = "%s (recommended)".printf (format_size (value, FormatSizeFlags.IEC_UNITS));
+            scale.add_mark (value, Gtk.PositionType.BOTTOM, size);
+        }
+    }
+
     public SizeProperty (string name, uint64 size, uint64 min, uint64 max, uint64 step) {
         var label = new Gtk.Label (format_size ((uint64) size, FormatSizeFlags.IEC_UNITS));
         label.halign = Gtk.Align.CENTER;
@@ -73,6 +87,8 @@ private class Boxes.SizeProperty : Boxes.Property {
 
         base (name, label, scale);
 
+        this.scale = scale;
+
         scale.value_changed.connect (() => {
             uint64 v = (uint64) scale.get_value ();
             label.set_text (format_size (v, FormatSizeFlags.IEC_UNITS));



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