[gtk+/gtk-2-24] Revert "Scale: Always sync ::digits to Range::round-digits"



commit 7191a048c1d93ee113309f4b635673900bdb03a6
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Sun Apr 30 19:19:05 2017 +0200

    Revert "Scale: Always sync ::digits to Range::round-digits"
    
    This reverts commit fd218fee464b5120b0eafbdc05d3af4a5b8b159b.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781605

 gtk/gtkscale.c |   34 ++++++++++++++++------------------
 1 files changed, 16 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index 1e24c6f..9171328 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -269,18 +269,11 @@ gtk_scale_class_init (GtkScaleClass *class)
                   G_TYPE_STRING, 1,
                   G_TYPE_DOUBLE);
 
-  /**
-   * GtkScale:digits:
-   *
-   * The number of decimal places to which the value is rounded when it is
-   * changed. This also sets the number of digits shown in the displayed value
-   * when using the default handler for the #GtkScale::format-value signal.
-   */
   g_object_class_install_property (gobject_class,
                                    PROP_DIGITS,
                                    g_param_spec_int ("digits",
                                                     P_("Digits"),
-                                                    P_("The number of decimal places to which the value is 
rounded"),
+                                                    P_("The number of decimal places that are displayed in 
the value"),
                                                     -1,
                                                     MAX_DIGITS,
                                                     1,
@@ -600,11 +593,12 @@ gtk_scale_new_with_range (GtkOrientation orientation,
 /**
  * gtk_scale_set_digits:
  * @scale: a #GtkScale
- * @digits: the number of decimal places to which the value will be rounded
- *
- * Sets the number of decimal places to which the value is rounded when it is
- * changed. This also sets the number of digits shown in the displayed value
- * when using the default handler for the #GtkScale::format-value signal.
+ * @digits: the number of decimal places to display, 
+ *     e.g. use 1 to display 1.0, 2 to display 1.00, etc
+ * 
+ * Sets the number of decimal places that are displayed in the value.
+ * Also causes the value of the adjustment to be rounded off to this
+ * number of digits, so the retrieved value matches the value the user saw.
  */
 void
 gtk_scale_set_digits (GtkScale *scale,
@@ -621,8 +615,9 @@ gtk_scale_set_digits (GtkScale *scale,
   if (scale->digits != digits)
     {
       scale->digits = digits;
-      range->round_digits = digits;
-
+      if (scale->draw_value)
+       range->round_digits = digits;
+      
       _gtk_scale_clear_layout (scale);
       gtk_widget_queue_resize (GTK_WIDGET (scale));
 
@@ -634,10 +629,9 @@ gtk_scale_set_digits (GtkScale *scale,
  * gtk_scale_get_digits:
  * @scale: a #GtkScale
  *
- * Gets the number of decimal places to which the value is rounded on change.
- * This number is also used by the default #GtkScale::format-value handler.
+ * Gets the number of decimal places that are displayed in the value.
  *
- * Returns: the number of decimal places
+ * Returns: the number of decimal places that are displayed
  */
 gint
 gtk_scale_get_digits (GtkScale *scale)
@@ -666,6 +660,10 @@ gtk_scale_set_draw_value (GtkScale *scale,
   if (scale->draw_value != draw_value)
     {
       scale->draw_value = draw_value;
+      if (draw_value)
+       GTK_RANGE (scale)->round_digits = scale->digits;
+      else
+       GTK_RANGE (scale)->round_digits = -1;
 
       _gtk_scale_clear_layout (scale);
 


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