]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkrange.c
Include "config.h" instead of <config.h> Command used: find -name
[~andy/gtk] / gtk / gtkrange.c
index bc15e6b53c48d7564cce453b5042f9e527cf9e2d..32023ebaf6538721b040239bd9cfbcb29a55aa07 100644 (file)
@@ -25,7 +25,7 @@
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#include <config.h>
+#include "config.h"
 #include <stdio.h>
 #include <math.h>
 #include <gdk/gdkkeysyms.h>
@@ -107,6 +107,7 @@ struct _GtkRangeLayout
 
   GtkSensitivityType lower_sensitivity;
   GtkSensitivityType upper_sensitivity;
+  guint repaint_id;
 
   gdouble fill_level;
 };
@@ -251,6 +252,12 @@ gtk_range_class_init (GtkRangeClass *class)
   class->slider_detail = "slider";
   class->stepper_detail = "stepper";
 
+  /**
+   * GtkRange::value-changed:
+   * @range: the #GtkRange
+   *
+   * Emitted when the range value changes.
+   */
   signals[VALUE_CHANGED] =
     g_signal_new (I_("value_changed"),
                   G_TYPE_FROM_CLASS (gobject_class),
@@ -270,6 +277,13 @@ gtk_range_class_init (GtkRangeClass *class)
                   G_TYPE_NONE, 1,
                   G_TYPE_DOUBLE);
   
+  /**
+   * GtkRange::move-slider:
+   * @range: the #GtkRange
+   * @step: how to move the slider
+   *
+   * Virtual function that moves the slider. Used for keybindings.
+   */
   signals[MOVE_SLIDER] =
     g_signal_new (I_("move_slider"),
                   G_TYPE_FROM_CLASS (gobject_class),
@@ -282,11 +296,11 @@ gtk_range_class_init (GtkRangeClass *class)
 
   /**
    * GtkRange::change-value:
-   * @range: the range that received the signal.
-   * @scroll: the type of scroll action that was performed.
-   * @value: the new value resulting from the scroll action.
+   * @range: the range that received the signal
+   * @scroll: the type of scroll action that was performed
+   * @value: the new value resulting from the scroll action
    * @returns: %TRUE to prevent other handlers from being invoked for the
-   * signal.  %FALSE to propagate the signal further.
+   * signal, %FALSE to propagate the signal further
    *
    * The ::change-value signal is emitted when a scroll action is
    * performed on a range.  It allows an application to determine the
@@ -316,7 +330,7 @@ gtk_range_class_init (GtkRangeClass *class)
                   G_TYPE_BOOLEAN, 2,
                   GTK_TYPE_SCROLL_TYPE,
                   G_TYPE_DOUBLE);
-  
+
   g_object_class_install_property (gobject_class,
                                    PROP_UPDATE_POLICY,
                                    g_param_spec_enum ("update-policy",
@@ -363,7 +377,7 @@ gtk_range_class_init (GtkRangeClass *class)
   /**
    * GtkRange:show-fill-level:
    *
-   * The show-fill-level property controls wether fill level indicator
+   * The show-fill-level property controls whether fill level indicator
    * graphics are displayed on the trough. See
    * gtk_range_set_show_fill_level().
    *
@@ -380,9 +394,9 @@ gtk_range_class_init (GtkRangeClass *class)
   /**
    * GtkRange:restrict-to-fill-level:
    *
-   * The restrict-to-fill-level proeprty controls whether slider
+   * The restrict-to-fill-level property controls whether slider
    * movement is restricted to an upper boundary set by the
-   * fill-level. See gtk_range_set_restrict_to_fill_level().
+   * fill level. See gtk_range_set_restrict_to_fill_level().
    *
    * Since: 2.12
    **/
@@ -441,7 +455,7 @@ gtk_range_class_init (GtkRangeClass *class)
    *
    * The spacing between the stepper buttons and thumb. Note that
    * setting this value to anything > 0 will automatically set the
-   * trough-under-steppers style property to TRUE as well. Also,
+   * trough-under-steppers style property to %TRUE as well. Also,
    * stepper-spacing won't have any effect if there are no steppers.
    */
   gtk_widget_class_install_style_property (widget_class,
@@ -479,6 +493,9 @@ gtk_range_class_init (GtkRangeClass *class)
   /**
    * GtkRange:trough-side-details:
    *
+   * When %TRUE, the parts of the trough on the two sides of the 
+   * slider are drawn with different details.
+   *
    * Since: 2.10
    */
   gtk_widget_class_install_style_property (widget_class,
@@ -493,7 +510,7 @@ gtk_range_class_init (GtkRangeClass *class)
    *
    * Whether to draw the trough across the full length of the range or
    * to exclude the steppers and their spacing. Note that setting the
-   * stepper-spacing style property to any value > 0 will
+   * #GtkRange:stepper-spacing style property to any value > 0 will
    * automatically enable trough-under-steppers too.
    *
    * Since: 2.10
@@ -659,7 +676,6 @@ gtk_range_get_adjustment (GtkRange *range)
  * 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,
@@ -702,7 +718,6 @@ gtk_range_get_update_policy (GtkRange *range)
  * 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,
@@ -752,7 +767,6 @@ gtk_range_set_adjustment (GtkRange      *range,
  * 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,
@@ -890,7 +904,6 @@ gtk_range_get_upper_stepper_sensitivity (GtkRange *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,
@@ -948,9 +961,8 @@ gtk_range_set_range (GtkRange *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.
- * 
+ * them. The range emits the #GtkRange::value-changed signal if the 
+ * value changes.
  **/
 void
 gtk_range_set_value (GtkRange *range,
@@ -1156,7 +1168,11 @@ gtk_range_destroy (GtkObject *object)
 
   gtk_range_remove_step_timer (range);
   gtk_range_remove_update_timer (range);
-  
+
+  if (range->layout->repaint_id)
+    g_source_remove (range->layout->repaint_id);
+  range->layout->repaint_id = 0;
+
   if (range->adjustment)
     {
       g_signal_handlers_disconnect_by_func (range->adjustment,
@@ -1391,7 +1407,7 @@ static gboolean
 gtk_range_expose (GtkWidget      *widget,
                  GdkEventExpose *event)
 {
-  GtkRange *range;
+  GtkRange *range = GTK_RANGE (widget);
   gboolean sensitive;
   GtkStateType state;
   GtkShadowType shadow_type;
@@ -1404,17 +1420,17 @@ gtk_range_expose (GtkWidget      *widget,
   g_object_get (gtk_widget_get_settings (widget),
                 "gtk-touchscreen-mode", &touchscreen,
                 NULL);
+  if (GTK_WIDGET_CAN_FOCUS (range))
+    gtk_widget_style_get (GTK_WIDGET (range),
+                          "focus-line-width", &focus_line_width,
+                          "focus-padding", &focus_padding,
+                          NULL);
 
-  range = GTK_RANGE (widget);
+  /* we're now exposing, so there's no need to force early repaints */
+  if (range->layout->repaint_id)
+    g_source_remove (range->layout->repaint_id);
+  range->layout->repaint_id = 0;
 
-  if (GTK_WIDGET_CAN_FOCUS (range))
-    {
-      gtk_widget_style_get (GTK_WIDGET (range),
-                           "focus-line-width", &focus_line_width,
-                           "focus-padding", &focus_padding,
-                           NULL);
-    }
-  
   expose_area = event->area;
   expose_area.x -= widget->allocation.x;
   expose_area.y -= widget->allocation.y;
@@ -2255,6 +2271,16 @@ gtk_range_adjustment_changed (GtkAdjustment *adjustment,
    */
 }
 
+static gboolean
+force_repaint (gpointer data)
+{
+  GtkRange *range = GTK_RANGE (data);
+  range->layout->repaint_id = 0;
+  if (GTK_WIDGET_DRAWABLE (range))
+    gdk_window_process_updates (GTK_WIDGET (range)->window, FALSE);
+  return FALSE;
+}
+
 static void
 gtk_range_adjustment_value_changed (GtkAdjustment *adjustment,
                                    gpointer       data)
@@ -2270,10 +2296,9 @@ gtk_range_adjustment_value_changed (GtkAdjustment *adjustment,
   if (layout_changed (range->layout, &layout))
     {
       gtk_widget_queue_draw (GTK_WIDGET (range));
-      
-      /* This is so we don't lag the widget being scrolled. */
-      if (GTK_WIDGET_REALIZED (range))
-        gdk_window_process_updates (GTK_WIDGET (range)->window, FALSE);
+      /* setup a timer to ensure the range isn't lagging too much behind the scroll position */
+      if (!range->layout->repaint_id)
+        range->layout->repaint_id = gdk_threads_add_timeout_full (GDK_PRIORITY_EVENTS, 181, force_repaint, range, NULL);
     }
   
   /* Note that we don't round off to range->round_digits here.