]> Pileus Git - ~andy/gtk/commitdiff
clamp the value to the range that was set
authorHavoc Pennington <hp@redhat.com>
Tue, 5 Jun 2001 20:07:02 +0000 (20:07 +0000)
committerHavoc Pennington <hp@src.gnome.org>
Tue, 5 Jun 2001 20:07:02 +0000 (20:07 +0000)
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

23 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/ChangeLog
docs/reference/gtk/tmpl/gtkhscale.sgml
docs/reference/gtk/tmpl/gtkrange.sgml
docs/reference/gtk/tmpl/gtkscale.sgml
docs/reference/gtk/tmpl/gtkspinbutton.sgml
docs/reference/gtk/tmpl/gtkvscale.sgml
gdk-pixbuf/ChangeLog
gdk-pixbuf/test-loaders.c
gtk/gtkhscale.c
gtk/gtkhscale.h
gtk/gtkrange.c
gtk/gtkrange.h
gtk/gtkspinbutton.c
gtk/gtkspinbutton.h
gtk/gtkvscale.c
gtk/gtkvscale.h

index 49973b23e1acec7c77634f3e6ea5e7cf82af9220..f67f2a891887746425c7b407e49a59d2f3d65b67 100644 (file)
--- 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
index 49973b23e1acec7c77634f3e6ea5e7cf82af9220..f67f2a891887746425c7b407e49a59d2f3d65b67 100644 (file)
@@ -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
index 49973b23e1acec7c77634f3e6ea5e7cf82af9220..f67f2a891887746425c7b407e49a59d2f3d65b67 100644 (file)
@@ -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
index 49973b23e1acec7c77634f3e6ea5e7cf82af9220..f67f2a891887746425c7b407e49a59d2f3d65b67 100644 (file)
@@ -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
index 49973b23e1acec7c77634f3e6ea5e7cf82af9220..f67f2a891887746425c7b407e49a59d2f3d65b67 100644 (file)
@@ -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
index 49973b23e1acec7c77634f3e6ea5e7cf82af9220..f67f2a891887746425c7b407e49a59d2f3d65b67 100644 (file)
@@ -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
index 49973b23e1acec7c77634f3e6ea5e7cf82af9220..f67f2a891887746425c7b407e49a59d2f3d65b67 100644 (file)
@@ -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
index 8d4e86042cf286baddf8195129756535ab67be53..e4afc0565428f66ffa807d1de737587a3ee07242 100644 (file)
@@ -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.
index 60a554e47f34f00957e2aec45a92be3d0ac1351b..91c2a42f173edeb4ff409da19f40ea1373f3c284 100644 (file)
@@ -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
index 6966f7864e3fadb962c9be0b28395aedfcb28e62..dc47896ff223316c64ebd1f5369501b07b7d3f72 100644 (file)
@@ -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>
 
index 3f765150b756ca31aa2acf6f2645ecda3bc363c2..2a3383272bace74951ccd283b3716fb88f01c342 100644 (file)
@@ -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>
index ff3c5e187cfc90627e6c2d4f9ce64ae79cf040f1..abc66d3bb00701cbe7e67940525dc9d26c9e9bde 100644 (file)
@@ -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 ##### -->
index 5e111ac40f8b686c22951e071d12199edf7925b1..a08ded65bbf9d6a8143b27ec81d0909d93fc4d60 100644 (file)
@@ -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
index 06960c42dac636271d909e09fe089aa5d19079f0..1f5dcd6fbb310b05cfa1d69aa524e3617ef17f1d 100644 (file)
@@ -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, 
index 6f14d8f0eeac4d25936f3cce219fedca54e182de..a1eebc1ade723b4ee2b45d9295036d3fc8c8538d 100644 (file)
@@ -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);   
index 4b6e34a4ccb0f6c48e7ca2d28f6b6778f5b069c4..ebd37861e46237407de665173dab7cca27f59aed 100644 (file)
@@ -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)
index b4a49648e5a6bff2119fbf47e0af64a05e73fd58..18b96e6aeb77e285483adcf0021d7719d24c858e 100644 (file)
@@ -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
index a2109f66ed2fe3627611cf4224481eeb1877798b..c4ae093d8ff54c3a536507e937095f5fb2ce94d6 100644 (file)
@@ -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
index 6228b74e3bde4f72465fd4e3f0c93b07e3a2eafd..e988d56e09495453228e36ba76dac8af630d2427 100644 (file)
@@ -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
 }
index d1605a8278df9c318ef113793a70875a4f446e1e..76cea643e0ca1488c76648c9b4122c93e0e742a7 100644 (file)
@@ -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);
 
index 3d1561f444a714e8c3fe86af0d891d8a70837020..1686ea27adc56ca825cb62465d92942ca603add7 100644 (file)
@@ -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
 }
index 9a60d5ad845f2f4a00d754cca9be1123fcce54e1..2dca2cc99e3723710fadd69bf431b9d4cbbb5010 100644 (file)
@@ -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)
index 5194089050eca5fccf81684650ef1c445d223aaf..69757ecdee9d08d45d8825dd4873998ac027e1d2 100644 (file)
@@ -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