summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-06-05 20:07:02 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-06-05 20:07:02 +0000
commitb32e7c9bb82396e4930957bb649a2e1cd57f00c1 (patch)
treeb95893653c899c31699a91803eebeb1e934e7f1e
parent451b224324864047842dfe009834a0fe53728147 (diff)
downloadgtk+-b32e7c9bb82396e4930957bb649a2e1cd57f00c1.tar.gz
clamp the value to the range that was set
2001-06-05 Havoc Pennington <hp@redhat.com> * gtk/gtkspinbutton.c (gtk_spin_button_set_range): clamp the value to the range that was set * gtk/gtkrange.c: add value_changed signal, primarily intended for use with GtkScale (gtk_range_set_increments): new function (gtk_range_set_range): new function with weird name (gtk_range_set_value): new function (gtk_range_get_value): new function * gtk/gtkspinbutton.c (gtk_spin_button_get_value): rename from gtk_spin_button_get_value_as_float(). Compat #define added for get_value_as_float. * gtk/gtkhscale.c (gtk_hscale_new_with_range): new function * gtk/gtkvscale.c (gtk_vscale_new_with_range): new function 2001-06-05 Havoc Pennington <hp@redhat.com> * test-loaders.c (main): use putenv not setenv, reported by Armin Theissen
-rw-r--r--ChangeLog20
-rw-r--r--ChangeLog.pre-2-020
-rw-r--r--ChangeLog.pre-2-1020
-rw-r--r--ChangeLog.pre-2-220
-rw-r--r--ChangeLog.pre-2-420
-rw-r--r--ChangeLog.pre-2-620
-rw-r--r--ChangeLog.pre-2-820
-rw-r--r--docs/reference/ChangeLog4
-rw-r--r--docs/reference/gtk/tmpl/gtkhscale.sgml5
-rw-r--r--docs/reference/gtk/tmpl/gtkrange.sgml13
-rw-r--r--docs/reference/gtk/tmpl/gtkscale.sgml30
-rw-r--r--docs/reference/gtk/tmpl/gtkspinbutton.sgml5
-rw-r--r--docs/reference/gtk/tmpl/gtkvscale.sgml3
-rw-r--r--gdk-pixbuf/ChangeLog5
-rw-r--r--gdk-pixbuf/test-loaders.c2
-rw-r--r--gtk/gtkhscale.c44
-rw-r--r--gtk/gtkhscale.h7
-rw-r--r--gtk/gtkrange.c164
-rw-r--r--gtk/gtkrange.h28
-rw-r--r--gtk/gtkspinbutton.c17
-rw-r--r--gtk/gtkspinbutton.h5
-rw-r--r--gtk/gtkvscale.c45
-rw-r--r--gtk/gtkvscale.h8
23 files changed, 493 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index 49973b23e1..f67f2a8918 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2001-06-05 Havoc Pennington <hp@redhat.com>
+
+ * gtk/gtkspinbutton.c (gtk_spin_button_set_range): clamp the value
+ to the range that was set
+
+ * gtk/gtkrange.c: add value_changed signal, primarily
+ intended for use with GtkScale
+ (gtk_range_set_increments): new function
+ (gtk_range_set_range): new function with weird name
+ (gtk_range_set_value): new function
+ (gtk_range_get_value): new function
+
+ * gtk/gtkspinbutton.c (gtk_spin_button_get_value): rename
+ from gtk_spin_button_get_value_as_float(). Compat #define
+ added for get_value_as_float.
+
+ * gtk/gtkhscale.c (gtk_hscale_new_with_range): new function
+
+ * gtk/gtkvscale.c (gtk_vscale_new_with_range): new function
+
Tue Jun 5 14:57:18 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_size): Fix bug #55573
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 49973b23e1..f67f2a8918 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,23 @@
+2001-06-05 Havoc Pennington <hp@redhat.com>
+
+ * gtk/gtkspinbutton.c (gtk_spin_button_set_range): clamp the value
+ to the range that was set
+
+ * gtk/gtkrange.c: add value_changed signal, primarily
+ intended for use with GtkScale
+ (gtk_range_set_increments): new function
+ (gtk_range_set_range): new function with weird name
+ (gtk_range_set_value): new function
+ (gtk_range_get_value): new function
+
+ * gtk/gtkspinbutton.c (gtk_spin_button_get_value): rename
+ from gtk_spin_button_get_value_as_float(). Compat #define
+ added for get_value_as_float.
+
+ * gtk/gtkhscale.c (gtk_hscale_new_with_range): new function
+
+ * gtk/gtkvscale.c (gtk_vscale_new_with_range): new function
+
Tue Jun 5 14:57:18 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_size): Fix bug #55573
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 49973b23e1..f67f2a8918 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,23 @@
+2001-06-05 Havoc Pennington <hp@redhat.com>
+
+ * gtk/gtkspinbutton.c (gtk_spin_button_set_range): clamp the value
+ to the range that was set
+
+ * gtk/gtkrange.c: add value_changed signal, primarily
+ intended for use with GtkScale
+ (gtk_range_set_increments): new function
+ (gtk_range_set_range): new function with weird name
+ (gtk_range_set_value): new function
+ (gtk_range_get_value): new function
+
+ * gtk/gtkspinbutton.c (gtk_spin_button_get_value): rename
+ from gtk_spin_button_get_value_as_float(). Compat #define
+ added for get_value_as_float.
+
+ * gtk/gtkhscale.c (gtk_hscale_new_with_range): new function
+
+ * gtk/gtkvscale.c (gtk_vscale_new_with_range): new function
+
Tue Jun 5 14:57:18 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_size): Fix bug #55573
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 49973b23e1..f67f2a8918 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,23 @@
+2001-06-05 Havoc Pennington <hp@redhat.com>
+
+ * gtk/gtkspinbutton.c (gtk_spin_button_set_range): clamp the value
+ to the range that was set
+
+ * gtk/gtkrange.c: add value_changed signal, primarily
+ intended for use with GtkScale
+ (gtk_range_set_increments): new function
+ (gtk_range_set_range): new function with weird name
+ (gtk_range_set_value): new function
+ (gtk_range_get_value): new function
+
+ * gtk/gtkspinbutton.c (gtk_spin_button_get_value): rename
+ from gtk_spin_button_get_value_as_float(). Compat #define
+ added for get_value_as_float.
+
+ * gtk/gtkhscale.c (gtk_hscale_new_with_range): new function
+
+ * gtk/gtkvscale.c (gtk_vscale_new_with_range): new function
+
Tue Jun 5 14:57:18 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_size): Fix bug #55573
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 49973b23e1..f67f2a8918 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,23 @@
+2001-06-05 Havoc Pennington <hp@redhat.com>
+
+ * gtk/gtkspinbutton.c (gtk_spin_button_set_range): clamp the value
+ to the range that was set
+
+ * gtk/gtkrange.c: add value_changed signal, primarily
+ intended for use with GtkScale
+ (gtk_range_set_increments): new function
+ (gtk_range_set_range): new function with weird name
+ (gtk_range_set_value): new function
+ (gtk_range_get_value): new function
+
+ * gtk/gtkspinbutton.c (gtk_spin_button_get_value): rename
+ from gtk_spin_button_get_value_as_float(). Compat #define
+ added for get_value_as_float.
+
+ * gtk/gtkhscale.c (gtk_hscale_new_with_range): new function
+
+ * gtk/gtkvscale.c (gtk_vscale_new_with_range): new function
+
Tue Jun 5 14:57:18 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_size): Fix bug #55573
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 49973b23e1..f67f2a8918 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,23 @@
+2001-06-05 Havoc Pennington <hp@redhat.com>
+
+ * gtk/gtkspinbutton.c (gtk_spin_button_set_range): clamp the value
+ to the range that was set
+
+ * gtk/gtkrange.c: add value_changed signal, primarily
+ intended for use with GtkScale
+ (gtk_range_set_increments): new function
+ (gtk_range_set_range): new function with weird name
+ (gtk_range_set_value): new function
+ (gtk_range_get_value): new function
+
+ * gtk/gtkspinbutton.c (gtk_spin_button_get_value): rename
+ from gtk_spin_button_get_value_as_float(). Compat #define
+ added for get_value_as_float.
+
+ * gtk/gtkhscale.c (gtk_hscale_new_with_range): new function
+
+ * gtk/gtkvscale.c (gtk_vscale_new_with_range): new function
+
Tue Jun 5 14:57:18 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_size): Fix bug #55573
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 49973b23e1..f67f2a8918 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,23 @@
+2001-06-05 Havoc Pennington <hp@redhat.com>
+
+ * gtk/gtkspinbutton.c (gtk_spin_button_set_range): clamp the value
+ to the range that was set
+
+ * gtk/gtkrange.c: add value_changed signal, primarily
+ intended for use with GtkScale
+ (gtk_range_set_increments): new function
+ (gtk_range_set_range): new function with weird name
+ (gtk_range_set_value): new function
+ (gtk_range_get_value): new function
+
+ * gtk/gtkspinbutton.c (gtk_spin_button_get_value): rename
+ from gtk_spin_button_get_value_as_float(). Compat #define
+ added for get_value_as_float.
+
+ * gtk/gtkhscale.c (gtk_hscale_new_with_range): new function
+
+ * gtk/gtkvscale.c (gtk_vscale_new_with_range): new function
+
Tue Jun 5 14:57:18 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_size): Fix bug #55573
diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog
index 8d4e86042c..e4afc05654 100644
--- a/docs/reference/ChangeLog
+++ b/docs/reference/ChangeLog
@@ -1,3 +1,7 @@
+2001-06-05 Havoc Pennington <hp@redhat.com>
+
+ * gtk/tmpl/gtkscale.sgml: more docs
+
Tue Jun 5 10:54:48 2001 Owen Taylor <otaylor@redhat.com>
* gtk/tmpl/gtkenums.sgml: Improve docs for GtkStateType.
diff --git a/docs/reference/gtk/tmpl/gtkhscale.sgml b/docs/reference/gtk/tmpl/gtkhscale.sgml
index 60a554e47f..91c2a42f17 100644
--- a/docs/reference/gtk/tmpl/gtkhscale.sgml
+++ b/docs/reference/gtk/tmpl/gtkhscale.sgml
@@ -7,9 +7,8 @@ a horizontal slider widget for selecting a value from a range.
<!-- ##### SECTION Long_Description ##### -->
<para>
The #GtkHScale widget is used to allow the user to select a value using
-a horizontal slider.
-A #GtkAdjustment is used to set the initial value, the lower
-and upper bounds, and the step and page increments.
+a horizontal slider. To create one, use
+gtk_hscale_new_with_range().
</para>
<para>
The position to show the current value, and the number of decimal places
diff --git a/docs/reference/gtk/tmpl/gtkrange.sgml b/docs/reference/gtk/tmpl/gtkrange.sgml
index 6966f7864e..dc47896ff2 100644
--- a/docs/reference/gtk/tmpl/gtkrange.sgml
+++ b/docs/reference/gtk/tmpl/gtkrange.sgml
@@ -67,14 +67,21 @@ GtkRange
<!-- ##### SIGNAL GtkRange::move-slider ##### -->
<para>
-
+Virtual function that moves the slider. Used for keybindings.
</para>
-@range: the object which received the signal.
-@arg1:
+@range: the #GtkRange
+@step: how to move the slider
<!-- # Unused Parameters # -->
@arg2:
+<!-- ##### SIGNAL GtkRange::value-changed ##### -->
+<para>
+Emitted when the range value changes.
+</para>
+
+@range: the #GtkRange
+
<!-- ##### ARG GtkRange:update-policy ##### -->
<para>
diff --git a/docs/reference/gtk/tmpl/gtkscale.sgml b/docs/reference/gtk/tmpl/gtkscale.sgml
index 3f765150b7..2a3383272b 100644
--- a/docs/reference/gtk/tmpl/gtkscale.sgml
+++ b/docs/reference/gtk/tmpl/gtkscale.sgml
@@ -6,8 +6,17 @@ a base class for #GtkHScale and #GtkVScale.
<!-- ##### SECTION Long_Description ##### -->
<para>
+A #GtkScale is a slider control used to select a numeric value.
+To use it, you'll probably want to investigate the methods on
+its base class, #GtkRange, in addition to the methods for #GtkScale itself.
+To set the value of a scale, you would normally use gtk_range_set_value().
+To detect changes to the value, you would normally use the "value_changed"
+signal.
+</para>
+<para>
The #GtkScale widget is an abstract class, used only for deriving the
-subclasses #GtkHScale and #GtkVScale.
+subclasses #GtkHScale and #GtkVScale. To create a scale widget,
+call gtk_hscale_new_with_range() or gtk_vscale_new_with_range().
</para>
<!-- ##### SECTION See_Also ##### -->
@@ -74,12 +83,25 @@ Sets the position in which the current value is displayed.
<!-- ##### SIGNAL GtkScale::format-value ##### -->
<para>
-
+Signal which allows you to change how the scale value is displayed. Connect a
+signal handler which returns an allocated string representing @value.
+That string will then be used to display the scale's value.
+Here's an example signal handler which displays a value 1.0 as
+with "-->1.0<--".
+<programlisting>
+static gchar*
+format_value_callback (GtkScale *scale,
+ gdouble value)
+{
+ return g_strdup_printf ("-->%0.*g<--",
+ gtk_scale_get_digits (scale), value);
+}
+</programlisting>
</para>
@scale: the object which received the signal.
-@arg1:
-@Returns:
+@value: value to format
+@Returns: allocated string representing @value
<!-- ##### ARG GtkScale:digits ##### -->
<para>
diff --git a/docs/reference/gtk/tmpl/gtkspinbutton.sgml b/docs/reference/gtk/tmpl/gtkspinbutton.sgml
index ff3c5e187c..abc66d3bb0 100644
--- a/docs/reference/gtk/tmpl/gtkspinbutton.sgml
+++ b/docs/reference/gtk/tmpl/gtkspinbutton.sgml
@@ -230,13 +230,14 @@ Creates a new #GtkSpinButton.
@max:
-<!-- ##### FUNCTION gtk_spin_button_get_value_as_float ##### -->
+<!-- ##### MACRO gtk_spin_button_get_value_as_float ##### -->
<para>
</para>
-@spin_button:
@Returns:
+<!-- # Unused Parameters # -->
+@spin_button:
<!-- ##### FUNCTION gtk_spin_button_get_value_as_int ##### -->
diff --git a/docs/reference/gtk/tmpl/gtkvscale.sgml b/docs/reference/gtk/tmpl/gtkvscale.sgml
index 5e111ac40f..a08ded65bb 100644
--- a/docs/reference/gtk/tmpl/gtkvscale.sgml
+++ b/docs/reference/gtk/tmpl/gtkvscale.sgml
@@ -8,8 +8,7 @@ a vertical slider widget for selecting a value from a range.
<para>
The #GtkVScale widget is used to allow the user to select a value using
a vertical slider.
-A #GtkAdjustment is used to set the initial value, the lower
-and upper bounds, and the step and page increments.
+To create one, use gtk_hscale_new_with_range().
</para>
<para>
The position to show the current value, and the number of decimal places
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog
index 06960c42da..1f5dcd6fbb 100644
--- a/gdk-pixbuf/ChangeLog
+++ b/gdk-pixbuf/ChangeLog
@@ -1,3 +1,8 @@
+2001-06-05 Havoc Pennington <hp@redhat.com>
+
+ * test-loaders.c (main): use putenv not setenv, reported by
+ Armin Theissen
+
2001-05-08 Havoc Pennington <hp@redhat.com>
* gdk-pixbuf-util.c (gdk_pixbuf_add_alpha): docs fixup,
diff --git a/gdk-pixbuf/test-loaders.c b/gdk-pixbuf/test-loaders.c
index 6f14d8f0ee..a1eebc1ade 100644
--- a/gdk-pixbuf/test-loaders.c
+++ b/gdk-pixbuf/test-loaders.c
@@ -373,7 +373,7 @@ main (int argc, char **argv)
g_type_init (G_TYPE_DEBUG_NONE);
g_log_set_fatal_mask (NULL, G_LOG_LEVEL_WARNING | G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
- setenv ("GDK_PIXBUF_MODULEDIR", BUILT_MODULES_DIR, TRUE);
+ putenv ("GDK_PIXBUF_MODULEDIR="BUILT_MODULES_DIR);
TEST (valid_gif_test, TRUE);
TEST (gif_test_1, FALSE);
diff --git a/gtk/gtkhscale.c b/gtk/gtkhscale.c
index 4b6e34a4cc..ebd37861e4 100644
--- a/gtk/gtkhscale.c
+++ b/gtk/gtkhscale.c
@@ -102,6 +102,50 @@ gtk_hscale_new (GtkAdjustment *adjustment)
return hscale;
}
+/**
+ * gtk_hscale_new_with_range:
+ * @min: minimum value
+ * @max: maximum value
+ * @step: step increment (tick size) used with keyboard shortcuts
+ *
+ * Creates a new horizontal scale widget that lets the user
+ * input a number between @min and @max with the increment @step.
+ * @step must be nonzero; it's the distance the slider moves when
+ * using the arrow keys to adjust the scale value.
+ *
+ * Return value: a new #GtkHScale
+ **/
+GtkWidget*
+gtk_hscale_new_with_range (gdouble min,
+ gdouble max,
+ gdouble step)
+{
+ GtkObject *adj;
+ GtkScale *scale;
+ gint digits;
+
+ g_return_val_if_fail (min < max, NULL);
+ g_return_val_if_fail (step != 0.0, NULL);
+
+ adj = gtk_adjustment_new (min, min, max, step, 10 * step, step);
+
+ scale = g_object_new (GTK_TYPE_HSCALE,
+ "adjustment", adj,
+ NULL);
+
+ if (fabs (step) >= 1.0 || step == 0.0)
+ digits = 0;
+ else {
+ digits = abs ((gint) floor (log10 (fabs (step))));
+ if (digits > 5)
+ digits = 5;
+ }
+
+ gtk_scale_set_digits (scale, digits);
+
+ return GTK_WIDGET (scale);
+}
+
static gboolean
gtk_hscale_expose (GtkWidget *widget,
GdkEventExpose *event)
diff --git a/gtk/gtkhscale.h b/gtk/gtkhscale.h
index b4a49648e5..18b96e6aeb 100644
--- a/gtk/gtkhscale.h
+++ b/gtk/gtkhscale.h
@@ -59,8 +59,11 @@ struct _GtkHScaleClass
};
-GtkType gtk_hscale_get_type (void) G_GNUC_CONST;
-GtkWidget* gtk_hscale_new (GtkAdjustment *adjustment);
+GtkType gtk_hscale_get_type (void) G_GNUC_CONST;
+GtkWidget* gtk_hscale_new (GtkAdjustment *adjustment);
+GtkWidget* gtk_hscale_new_with_range (gdouble min,
+ gdouble max,
+ gdouble step);
#ifdef __cplusplus
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index a2109f66ed..c4ae093d8f 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -43,6 +43,7 @@ enum {
};
enum {
+ VALUE_CHANGED,
MOVE_SLIDER,
LAST_SIGNAL
};
@@ -222,6 +223,15 @@ gtk_range_class_init (GtkRangeClass *class)
class->slider_detail = "slider";
class->stepper_detail = "stepper";
+
+ signals[VALUE_CHANGED] =
+ g_signal_newc ("value_changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkRangeClass, value_changed),
+ NULL, NULL,
+ gtk_marshal_NONE__NONE,
+ G_TYPE_NONE, 0);
signals[MOVE_SLIDER] =
g_signal_newc ("move_slider",
@@ -353,6 +363,17 @@ gtk_range_init (GtkRange *range)
range->timer = NULL;
}
+/**
+ * gtk_range_get_adjustment:
+ * @range: a #GtkRange
+ *
+ * Get the #GtkAdjustment which is the "model" object for #GtkRange.
+ * See gtk_range_set_adjustment() for details.
+ * The return value does not have a reference added, so should not
+ * be unreferenced.
+ *
+ * Return value: a #GtkAdjustment
+ **/
GtkAdjustment*
gtk_range_get_adjustment (GtkRange *range)
{
@@ -365,6 +386,21 @@ gtk_range_get_adjustment (GtkRange *range)
return range->adjustment;
}
+/**
+ * gtk_range_set_update_policy:
+ * @range: a #GtkRange
+ * @policy: update policy
+ *
+ * Sets the update policy for the range. #GTK_UPDATE_CONTINUOUS means that
+ * anytime the range slider is moved, the range value will change and the
+ * value_changed signal will be emitted. #GTK_UPDATE_DELAYED means that
+ * the value will be updated after a brief timeout where no slider motion
+ * occurs, so updates are spaced by a short time rather than
+ * continuous. #GTK_UPDATE_DISCONTINUOUS means that the value will only
+ * be updated when the user releases the button and ends the slider
+ * drag operation.
+ *
+ **/
void
gtk_range_set_update_policy (GtkRange *range,
GtkUpdateType policy)
@@ -379,6 +415,20 @@ gtk_range_set_update_policy (GtkRange *range,
}
}
+/**
+ * gtk_range_set_adjustment:
+ * @range: a #GtkRange
+ * @adjustment: a #GtkAdjustment
+ *
+ * Sets the adjustment to be used as the "model" object for this range
+ * widget. The adjustment indicates the current range value, the
+ * minimum and maximum range values, the step/page increments used
+ * for keybindings and scrolling, and the page size. The page size
+ * is normally 0 for #GtkScale and nonzero for #GtkScrollbar, and
+ * indicates the size of the visible area of the widget being scrolled.
+ * The page size affects the size of the scrollbar slider.
+ *
+ **/
void
gtk_range_set_adjustment (GtkRange *range,
GtkAdjustment *adjustment)
@@ -420,6 +470,17 @@ gtk_range_set_adjustment (GtkRange *range,
}
}
+/**
+ * gtk_range_set_inverted:
+ * @range: a #GtkRange
+ * @setting: %TRUE to invert the range
+ *
+ * Ranges normally move from lower to higher values as the
+ * slider moves from top to bottom or left to right. Inverted
+ * ranges have higher values at the top or on the right rather than
+ * on the bottom or left.
+ *
+ **/
void
gtk_range_set_inverted (GtkRange *range,
gboolean setting)
@@ -435,6 +496,14 @@ gtk_range_set_inverted (GtkRange *range,
}
}
+/**
+ * gtk_range_get_inverted:
+ * @range: a #GtkRange
+ *
+ * Gets the value set by gtk_range_set_inverted().
+ *
+ * Return value: %TRUE if the range is inverted
+ **/
gboolean
gtk_range_get_inverted (GtkRange *range)
{
@@ -443,6 +512,99 @@ gtk_range_get_inverted (GtkRange *range)
return range->inverted;
}
+/**
+ * gtk_range_set_increments:
+ * @range: a #GtkRange
+ * @step: step size
+ * @page: page size
+ *
+ * Sets the step and page sizes for the range.
+ * The step size is used when the user clicks the #GtkScrollbar
+ * arrows or moves #GtkScale via arrow keys. The page size
+ * is used for example when moving via Page Up or Page Down keys.
+ *
+ **/
+void
+gtk_range_set_increments (GtkRange *range,
+ gdouble step,
+ gdouble page)
+{
+ g_return_if_fail (GTK_IS_RANGE (range));
+
+ range->adjustment->step_increment = step;
+ range->adjustment->page_increment = page;
+
+ gtk_adjustment_changed (range->adjustment);
+}
+
+/**
+ * gtk_range_set_range:
+ * @range: a #GtkRange
+ * @min: minimum range value
+ * @max: maximum range value
+ *
+ * Sets the allowable values in the #GtkRange, and clamps the range
+ * value to be between min and max.
+ **/
+void
+gtk_range_set_range (GtkRange *range,
+ gdouble min,
+ gdouble max)
+{
+ gdouble value;
+
+ g_return_if_fail (GTK_IS_RANGE (range));
+ g_return_if_fail (min < max);
+
+ range->adjustment->lower = min;
+ range->adjustment->upper = max;
+
+ value = CLAMP (range->adjustment->value,
+ range->adjustment->lower,
+ (range->adjustment->upper - range->adjustment->page_size));
+
+ gtk_adjustment_changed (range->adjustment);
+}
+
+/**
+ * gtk_range_set_value:
+ * @range: a #GtkRange
+ * @value: new value of the range
+ *
+ * Sets the current value of the range; if the value is outside the
+ * minimum or maximum range values, it will be clamped to fit inside
+ * them. The range emits the "value_changed" signal if the value
+ * changes.
+ *
+ **/
+void
+gtk_range_set_value (GtkRange *range,
+ gdouble value)
+{
+ g_return_if_fail (GTK_IS_RANGE (range));
+
+ value = CLAMP (value, range->adjustment->lower,
+ (range->adjustment->upper - range->adjustment->page_size));
+
+ gtk_adjustment_set_value (range->adjustment, value);
+}
+
+/**
+ * gtk_range_get_value:
+ * @range: a #GtkRange
+ *
+ * Gets the current value of the range.
+ *
+ * Return value: current value of the range.
+ **/
+gdouble
+gtk_range_get_value (GtkRange *range)
+{
+ g_return_val_if_fail (GTK_IS_RANGE (range), 0.0);
+
+ return range->adjustment->value;
+}
+
static gboolean
should_invert (GtkRange *range)
{
@@ -1184,6 +1346,8 @@ gtk_range_adjustment_value_changed (GtkAdjustment *adjustment,
* can input into the adjustment, not a filter that the GtkRange
* will enforce on the adjustment.
*/
+
+ g_signal_emit (G_OBJECT (range), signals[VALUE_CHANGED], 0);
}
static void
diff --git a/gtk/gtkrange.h b/gtk/gtkrange.h
index 6228b74e3b..e988d56e09 100644
--- a/gtk/gtkrange.h
+++ b/gtk/gtkrange.h
@@ -106,6 +106,8 @@ struct _GtkRangeClass
/* what detail to pass to GTK drawing functions */
gchar *slider_detail;
gchar *stepper_detail;
+
+ void (* value_changed) (GtkRange *range);
/* action signals for keybindings */
void (* move_slider) (GtkRange *range,
@@ -119,16 +121,24 @@ struct _GtkRangeClass
GtkType gtk_range_get_type (void) G_GNUC_CONST;
-void gtk_range_set_update_policy (GtkRange *range,
- GtkUpdateType policy);
-
-void gtk_range_set_adjustment (GtkRange *range,
- GtkAdjustment *adjustment);
-GtkAdjustment* gtk_range_get_adjustment (GtkRange *range);
+void gtk_range_set_update_policy (GtkRange *range,
+ GtkUpdateType policy);
+void gtk_range_set_adjustment (GtkRange *range,
+ GtkAdjustment *adjustment);
+GtkAdjustment* gtk_range_get_adjustment (GtkRange *range);
+void gtk_range_set_inverted (GtkRange *range,
+ gboolean setting);
+gboolean gtk_range_get_inverted (GtkRange *range);
+void gtk_range_set_increments (GtkRange *range,
+ gdouble step,
+ gdouble page);
+void gtk_range_set_range (GtkRange *range,
+ gdouble min,
+ gdouble max);
+void gtk_range_set_value (GtkRange *range,
+ gdouble value);
+gdouble gtk_range_get_value (GtkRange *range);
-void gtk_range_set_inverted (GtkRange *range,
- gboolean setting);
-gboolean gtk_range_get_inverted (GtkRange *range);
#ifdef __cplusplus
}
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index d1605a8278..76cea643e0 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -1685,22 +1685,33 @@ gtk_spin_button_set_range (GtkSpinButton *spin_button,
gdouble min,
gdouble max)
{
+ gdouble value;
+
g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
spin_button->adjustment->lower = min;
spin_button->adjustment->upper = max;
+
+ value = CLAMP (spin_button->adjustment->value,
+ spin_button->adjustment->lower,
+ (spin_button->adjustment->upper - spin_button->adjustment->page_size));
+
+ if (value != spin_button->adjustment->value)
+ gtk_spin_button_set_value (spin_button, value);
+
+ gtk_adjustment_changed (spin_button->adjustment);
}
/**
- * gtk_spin_button_get_value_as_float:
+ * gtk_spin_button_get_value:
* @spin_button: a #GtkSpinButton
*
- * Get the value @spin_button represented as a floating point number.
+ * Get the value in the @spin_button.
*
* Return value: the value of @spin_button
**/
gdouble
-gtk_spin_button_get_value_as_float (GtkSpinButton *spin_button)
+gtk_spin_button_get_value (GtkSpinButton *spin_button)
{
g_return_val_if_fail (GTK_IS_SPIN_BUTTON (spin_button), 0.0);
diff --git a/gtk/gtkspinbutton.h b/gtk/gtkspinbutton.h
index 3d1561f444..1686ea27ad 100644
--- a/gtk/gtkspinbutton.h
+++ b/gtk/gtkspinbutton.h
@@ -141,7 +141,7 @@ void gtk_spin_button_set_range (GtkSpinButton *spin_button,
gdouble min,
gdouble max);
-gdouble gtk_spin_button_get_value_as_float (GtkSpinButton *spin_button);
+gdouble gtk_spin_button_get_value (GtkSpinButton *spin_button);
gint gtk_spin_button_get_value_as_int (GtkSpinButton *spin_button);
@@ -166,6 +166,9 @@ void gtk_spin_button_set_snap_to_ticks (GtkSpinButton *spin_button,
void gtk_spin_button_update (GtkSpinButton *spin_button);
+#ifndef GTK_DISABLE_DEPRECATED
+#define gtk_spin_button_get_value_as_float gtk_spin_button_get_value
+#endif
#ifdef __cplusplus
}
diff --git a/gtk/gtkvscale.c b/gtk/gtkvscale.c
index 9a60d5ad84..2dca2cc99e 100644
--- a/gtk/gtkvscale.c
+++ b/gtk/gtkvscale.c
@@ -103,6 +103,51 @@ gtk_vscale_new (GtkAdjustment *adjustment)
return vscale;
}
+
+/**
+ * gtk_vscale_new_with_range:
+ * @min: minimum value
+ * @max: maximum value
+ * @step: step increment (tick size) used with keyboard shortcuts
+ *
+ * Creates a new vertical scale widget that lets the user
+ * input a number between @min and @max with the increment @step.
+ * @step must be nonzero; it's the distance the slider moves when
+ * using the arrow keys to adjust the scale value.
+ *
+ * Return value: a new #GtkVScale
+ **/
+GtkWidget*
+gtk_vscale_new_with_range (gdouble min,
+ gdouble max,
+ gdouble step)
+{
+ GtkObject *adj;
+ GtkScale *scale;
+ gint digits;
+
+ g_return_val_if_fail (min < max, NULL);
+ g_return_val_if_fail (step != 0.0, NULL);
+
+ adj = gtk_adjustment_new (min, min, max, step, 10 * step, step);
+
+ scale = g_object_new (GTK_TYPE_VSCALE,
+ "adjustment", adj,
+ NULL);
+
+ if (fabs (step) >= 1.0 || step == 0.0)
+ digits = 0;
+ else {
+ digits = abs ((gint) floor (log10 (fabs (step))));
+ if (digits > 5)
+ digits = 5;
+ }
+
+ gtk_scale_set_digits (scale, digits);
+
+ return GTK_WIDGET (scale);
+}
+
static gboolean
gtk_vscale_expose (GtkWidget *widget,
GdkEventExpose *event)
diff --git a/gtk/gtkvscale.h b/gtk/gtkvscale.h
index 5194089050..69757ecdee 100644
--- a/gtk/gtkvscale.h
+++ b/gtk/gtkvscale.h
@@ -59,8 +59,12 @@ struct _GtkVScaleClass
};
-GtkType gtk_vscale_get_type (void) G_GNUC_CONST;
-GtkWidget* gtk_vscale_new (GtkAdjustment *adjustment);
+GtkType gtk_vscale_get_type (void) G_GNUC_CONST;
+GtkWidget* gtk_vscale_new (GtkAdjustment *adjustment);
+GtkWidget* gtk_vscale_new_with_range (gdouble min,
+ gdouble max,
+ gdouble step);
+
#ifdef __cplusplus