[gtk+] Add accessors for GtkRange::round-digits
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add accessors for GtkRange::round-digits
- Date: Sat, 15 Jan 2011 05:09:14 +0000 (UTC)
commit ccc3d874ef34593088b6bcf33a38580d64153063
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jan 15 00:08:39 2011 -0500
Add accessors for GtkRange::round-digits
Patch by Christian Dywan,
https://bugzilla.gnome.org/show_bug.cgi?id=351755
docs/reference/gtk/gtk3-sections.txt | 4 +-
gtk/gtk.symbols | 2 +
gtk/gtkrange.c | 77 ++++++++++++++++++++++++++++++----
gtk/gtkrange.h | 7 ++-
gtk/gtkscale.c | 8 ++--
5 files changed, 81 insertions(+), 17 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index dfba4d3..8134a01 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -2482,9 +2482,11 @@ gtk_range_set_adjustment
gtk_range_get_inverted
gtk_range_set_inverted
gtk_range_get_value
+gtk_range_set_value
gtk_range_set_increments
gtk_range_set_range
-gtk_range_set_value
+gtk_range_get_round_digits
+gtk_range_set_round_digits
GtkSensitivityType
gtk_range_set_lower_stepper_sensitivity
gtk_range_get_lower_stepper_sensitivity
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index a8aa36e..8aefc9b 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -2050,6 +2050,7 @@ gtk_range_get_lower_stepper_sensitivity
gtk_range_get_min_slider_size
gtk_range_get_range_rect
gtk_range_get_restrict_to_fill_level
+gtk_range_get_round_digits
gtk_range_get_show_fill_level
gtk_range_get_slider_range
gtk_range_get_slider_size_fixed
@@ -2065,6 +2066,7 @@ gtk_range_set_lower_stepper_sensitivity
gtk_range_set_min_slider_size
gtk_range_set_range
gtk_range_set_restrict_to_fill_level
+gtk_range_set_round_digits
gtk_range_set_show_fill_level
gtk_range_set_slider_size_fixed
gtk_range_set_upper_stepper_sensitivity
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 4c8d428..2ad0357 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -151,7 +151,8 @@ enum {
PROP_UPPER_STEPPER_SENSITIVITY,
PROP_SHOW_FILL_LEVEL,
PROP_RESTRICT_TO_FILL_LEVEL,
- PROP_FILL_LEVEL
+ PROP_FILL_LEVEL,
+ PROP_ROUND_DIGITS
};
enum {
@@ -376,7 +377,7 @@ gtk_range_class_init (GtkRangeClass *class)
* @returns: %TRUE to prevent other handlers from being invoked for the
* signal, %FALSE to propagate the signal further
*
- * The ::change-value signal is emitted when a scroll action is
+ * The #GtkRange::change-value signal is emitted when a scroll action is
* performed on a range. It allows an application to determine the
* type of scroll event that occurred and the resultant new value.
* The application can handle the event itself and return %TRUE to
@@ -385,12 +386,12 @@ gtk_range_class_init (GtkRangeClass *class)
* reached.
*
* The value parameter is unrounded. An application that overrides
- * the ::change-value signal is responsible for clamping the value to
- * the desired number of decimal digits; the default GTK+ handler
- * clamps the value based on @range->round_digits.
+ * the GtkRange::change-value signal is responsible for clamping the
+ * value to the desired number of decimal digits; the default GTK+
+ * handler clamps the value based on #GtkRange:round-digits.
*
* It is not possible to use delayed update policies in an overridden
- * ::change-value handler.
+ * #GtkRange::change-value handler.
*
* Since: 2.6
*/
@@ -495,6 +496,24 @@ gtk_range_class_init (GtkRangeClass *class)
G_MAXDOUBLE,
GTK_PARAM_READWRITE));
+ /**
+ * GtkRange:round-digits:
+ *
+ * The number of digits to round the value to when
+ * it changes, or -1. See #GtkRange::change-value.
+ *
+ * Since: 2.24
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_ROUND_DIGITS,
+ g_param_spec_int ("round-digits",
+ P_("Round Digits"),
+ P_("The number of widgets to round the value to."),
+ -1,
+ G_MAXINT,
+ -1,
+ GTK_PARAM_READWRITE));
+
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("slider-width",
P_("Slider Width"),
@@ -629,6 +648,9 @@ gtk_range_set_property (GObject *object,
case PROP_FILL_LEVEL:
gtk_range_set_fill_level (range, g_value_get_double (value));
break;
+ case PROP_ROUND_DIGITS:
+ gtk_range_set_round_digits (range, g_value_get_int (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -670,6 +692,9 @@ gtk_range_get_property (GObject *object,
case PROP_FILL_LEVEL:
g_value_set_double (value, gtk_range_get_fill_level (range));
break;
+ case PROP_ROUND_DIGITS:
+ g_value_set_int (value, gtk_range_get_round_digits (range));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -2895,7 +2920,7 @@ gtk_range_adjustment_value_changed (GtkAdjustment *adjustment,
181, force_repaint,
range, NULL);
}
-
+
/* Note that we don't round off to priv->round_digits here.
* that's because it's really broken to change a value
* in response to a change signal on that value; round_digits
@@ -4055,11 +4080,45 @@ _gtk_range_get_stop_positions (GtkRange *range,
return priv->n_marks;
}
+/**
+ * gtk_range_set_round_digits:
+ * @range: a #GtkRange
+ * @round_digits: the precision in digits, or -1
+ *
+ * Sets the number of digits to round the value to when
+ * it changes. See #GtkRange::change-value.
+ *
+ * Since: 2.24
+ */
void
-_gtk_range_set_round_digits (GtkRange *range,
- gint round_digits)
+gtk_range_set_round_digits (GtkRange *range,
+ gint round_digits)
{
+ g_return_if_fail (GTK_IS_RANGE (range));
+ g_return_if_fail (round_digits >= -1);
+
range->priv->round_digits = round_digits;
+
+ g_object_notify (G_OBJECT (range), "round-digits");
+}
+
+/**
+ * gtk_range_get_round_digits:
+ * @range: a #GtkRange
+ *
+ * Gets the number of digits to round the value to when
+ * it changes. See #GtkRange::change-value.
+ *
+ * Return value: the number of digits to round to
+ *
+ * Since: 2.24
+ */
+gint
+gtk_range_get_round_digits (GtkRange *range)
+{
+ g_return_val_if_fail (GTK_IS_RANGE (range), -1);
+
+ return range->priv->round_digits;
}
void
diff --git a/gtk/gtkrange.h b/gtk/gtkrange.h
index 92ac96f..7c01ab2 100644
--- a/gtk/gtkrange.h
+++ b/gtk/gtkrange.h
@@ -143,6 +143,9 @@ gboolean gtk_range_get_restrict_to_fill_level (GtkRange *range
void gtk_range_set_fill_level (GtkRange *range,
gdouble fill_level);
gdouble gtk_range_get_fill_level (GtkRange *range);
+void gtk_range_set_round_digits (GtkRange *range,
+ gint round_digits);
+gint gtk_range_get_round_digits (GtkRange *range);
/* internal API */
gdouble _gtk_range_get_wheel_delta (GtkRange *range,
@@ -152,9 +155,7 @@ void _gtk_range_set_stop_values (GtkRange *range
gdouble *values,
gint n_values);
gint _gtk_range_get_stop_positions (GtkRange *range,
- gint **values);
-void _gtk_range_set_round_digits (GtkRange *range,
- gint round_digits);
+ gint **values);
void _gtk_range_set_steppers (GtkRange *range,
gboolean has_a,
gboolean has_b,
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index b34167a..486e647 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -443,7 +443,7 @@ gtk_scale_init (GtkScale *scale)
priv->draw_value = TRUE;
priv->value_pos = GTK_POS_TOP;
priv->digits = 1;
- _gtk_range_set_round_digits (range, priv->digits);
+ gtk_range_set_round_digits (range, priv->digits);
gtk_scale_orientation_notify (range, NULL);
g_signal_connect (scale, "notify::orientation",
@@ -613,7 +613,7 @@ gtk_scale_set_digits (GtkScale *scale,
{
priv->digits = digits;
if (priv->draw_value)
- _gtk_range_set_round_digits (range, digits);
+ gtk_range_set_round_digits (range, digits);
_gtk_scale_clear_layout (scale);
gtk_widget_queue_resize (GTK_WIDGET (scale));
@@ -662,9 +662,9 @@ gtk_scale_set_draw_value (GtkScale *scale,
{
priv->draw_value = draw_value;
if (draw_value)
- _gtk_range_set_round_digits (GTK_RANGE (scale), priv->digits);
+ gtk_range_set_round_digits (GTK_RANGE (scale), priv->digits);
else
- _gtk_range_set_round_digits (GTK_RANGE (scale), -1);
+ gtk_range_set_round_digits (GTK_RANGE (scale), -1);
_gtk_scale_clear_layout (scale);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]