]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkwidget.c
Switch style of stamp file usage.
[~andy/gtk] / gtk / gtkwidget.c
index f2467f585b4cd2ab601390dab40edd012e425af6..3c7369b529adb0b87fbfec2aa644336c586766a0 100644 (file)
@@ -179,7 +179,7 @@ static void gtk_widget_direction_changed     (GtkWidget         *widget,
                                                  GtkTextDirection   previous_direction);
 
 static void    gtk_widget_real_grab_focus       (GtkWidget         *focus_widget);
-static void     gtk_widget_real_show_help        (GtkWidget         *widget,
+static gboolean gtk_widget_real_show_help        (GtkWidget         *widget,
                                                   GtkWidgetHelpType  help_type);
 
 static void    gtk_widget_dispatch_child_properties_changed    (GtkWidget        *object,
@@ -204,8 +204,6 @@ static void             gtk_widget_reset_rc_style               (GtkWidget
 static void            gtk_widget_set_style_internal           (GtkWidget        *widget,
                                                                 GtkStyle         *style,
                                                                 gboolean          initial_emission);
-static void            gtk_widget_set_style_recurse            (GtkWidget        *widget,
-                                                                gpointer          client_data);
 static gint            gtk_widget_event_internal               (GtkWidget        *widget,
                                                                 GdkEvent         *event);
 static gboolean                gtk_widget_real_mnemonic_activate       (GtkWidget        *widget,
@@ -1004,19 +1002,21 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  G_TYPE_BOOLEAN, 1,
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
   widget_signals[POPUP_MENU] =
-    gtk_signal_new ("popup_menu",
-                   GTK_RUN_LAST | GTK_RUN_ACTION,
-                   GTK_CLASS_TYPE (object_class),
-                   GTK_SIGNAL_OFFSET (GtkWidgetClass, popup_menu),
-                    _gtk_marshal_NONE__NONE,
-                   GTK_TYPE_NONE, 0);
+    g_signal_new ("popup_menu",
+                 G_TYPE_FROM_CLASS (object_class),
+                 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                 GTK_SIGNAL_OFFSET (GtkWidgetClass, popup_menu),
+                 _gtk_boolean_handled_accumulator, NULL,
+                  _gtk_marshal_BOOLEAN__VOID,
+                 G_TYPE_BOOLEAN, 0);
   widget_signals[SHOW_HELP] =
-    gtk_signal_new ("show_help",
-                   GTK_RUN_LAST | GTK_RUN_ACTION,
-                   GTK_CLASS_TYPE (object_class),
-                   GTK_SIGNAL_OFFSET (GtkWidgetClass, show_help),
-                    _gtk_marshal_NONE__ENUM,
-                   GTK_TYPE_NONE, 1, GTK_TYPE_WIDGET_HELP_TYPE);
+    g_signal_new ("show_help",
+                 G_TYPE_FROM_CLASS (object_class),
+                 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                 GTK_SIGNAL_OFFSET (GtkWidgetClass, show_help),
+                 _gtk_boolean_handled_accumulator, NULL,
+                  _gtk_marshal_BOOLEAN__ENUM,
+                 G_TYPE_BOOLEAN, 1, GTK_TYPE_WIDGET_HELP_TYPE);
   widget_signals[ACCEL_CLOSURES_CHANGED] =
     gtk_signal_new ("accel_closures_changed",
                    0,
@@ -1074,7 +1074,18 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                             _("Width, in pixels, between focus indicator and the widget 'box'."),
                                                             0, G_MAXINT, 1,
                                                             G_PARAM_READWRITE));
-
+  gtk_widget_class_install_style_property (klass,
+                                          g_param_spec_boxed ("cursor-color",
+                                                              _("Cursor color"),
+                                                              _("Color with which to draw insertion cursor"),
+                                                              GDK_TYPE_COLOR,
+                                                              G_PARAM_READABLE));
+  gtk_widget_class_install_style_property (klass,
+                                           g_param_spec_float ("cursor-aspect-ratio",
+                                                               _("Cursor line aspect ratio"),
+                                                               _("Aspect ratio with which to draw insertion cursor"),
+                                                               0.0, 1.0, 0.033,
+                                                               G_PARAM_READABLE));
 }
 
 static void
@@ -1083,9 +1094,7 @@ gtk_widget_set_property (GObject         *object,
                         const GValue    *value,
                         GParamSpec      *pspec)
 {
-  GtkWidget *widget;
-
-  widget = GTK_WIDGET (object);
+  GtkWidget *widget = GTK_WIDGET (object);
 
   switch (prop_id)
     {
@@ -1168,9 +1177,7 @@ gtk_widget_get_property (GObject         *object,
                         GValue          *value,
                         GParamSpec      *pspec)
 {
-  GtkWidget *widget;
-
-  widget = GTK_WIDGET (object);
+  GtkWidget *widget = GTK_WIDGET (object);
   
   switch (prop_id)
     {
@@ -1185,7 +1192,7 @@ gtk_widget_get_property (GObject         *object,
       break;
     case PROP_PARENT:
       if (widget->parent)
-       g_value_set_object (value, G_OBJECT (widget->parent));
+       g_value_set_object (value, widget->parent);
       else
        g_value_set_object (value, NULL);
       break;
@@ -1231,7 +1238,7 @@ gtk_widget_get_property (GObject         *object,
       g_value_set_boolean (value, (GTK_WIDGET_COMPOSITE_CHILD (widget) != FALSE));
       break;
     case PROP_STYLE:
-      g_value_set_object (value, G_OBJECT (gtk_widget_get_style (widget)));
+      g_value_set_object (value, gtk_widget_get_style (widget));
       break;
     case PROP_EVENTS:
       eventp = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_event_mask);
@@ -1276,6 +1283,8 @@ gtk_widget_init (GtkWidget *widget)
                        GTK_DOUBLE_BUFFERED);
 
   GTK_PRIVATE_SET_FLAG (widget, GTK_REDRAW_ON_ALLOC);
+  GTK_PRIVATE_SET_FLAG (widget, GTK_REQUEST_NEEDED);
+  GTK_PRIVATE_SET_FLAG (widget, GTK_ALLOC_NEEDED);
 
   widget->style = gtk_widget_get_default_style ();
   g_object_ref (widget->style);
@@ -1338,6 +1347,12 @@ gtk_widget_child_notify (GtkWidget    *widget,
   g_object_unref (widget);
 }
 
+/**
+ * gtk_widget_thaw_child_notify:
+ * @widget: a #GtkWidget
+ *
+ * Reverts the effect of a previous call to gtk_widget_freeze_child_notify().
+ */ 
 void
 gtk_widget_thaw_child_notify (GtkWidget *widget)
 {
@@ -1624,8 +1639,6 @@ gtk_widget_show (GtkWidget *widget)
 static void
 gtk_widget_real_show (GtkWidget *widget)
 {
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  
   if (!GTK_WIDGET_VISIBLE (widget))
     {
       GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
@@ -1695,7 +1708,7 @@ gtk_widget_hide (GtkWidget *widget)
     {
       gtk_widget_ref (widget);
       gtk_signal_emit (GTK_OBJECT (widget), widget_signals[HIDE]);
-      if (!GTK_WIDGET_TOPLEVEL (widget) && GTK_WIDGET_REALIZED (widget))
+      if (!GTK_WIDGET_TOPLEVEL (widget))
        gtk_widget_queue_resize (widget);
       g_object_notify (G_OBJECT (widget), "visible");
       gtk_widget_unref (widget);
@@ -1705,8 +1718,6 @@ gtk_widget_hide (GtkWidget *widget)
 static void
 gtk_widget_real_hide (GtkWidget *widget)
 {
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  
   if (GTK_WIDGET_VISIBLE (widget))
     {
       GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
@@ -1722,10 +1733,11 @@ gtk_widget_real_hide (GtkWidget *widget)
  * 
  * Utility function; intended to be connected to the "delete_event"
  * signal on a #GtkWindow. The function calls gtk_widget_hide() on its
- * argument, then returns %TRUE. If connected to "delete_event",
- * the result is that clicking the window manager close button for
- * will hide but not destroy the window. By default, GTK+ destroys
- * windows when "delete_event" is received.
+ * argument, then returns %TRUE. If connected to "delete_event", the
+ * result is that clicking the close button for a window (on the
+ * window frame, top right corner usually) will hide but not destroy
+ * the window. By default, GTK+ destroys windows when "delete_event"
+ * is received.
  * 
  * Return value: %TRUE
  **/
@@ -1831,7 +1843,7 @@ gtk_widget_unmap (GtkWidget *widget)
  * @widget: a #GtkWidget
  * 
  * Creates the GDK (windowing system) resources associated with a
- * widget.  For example, widget->window will be created when a widget
+ * widget.  For example, @widget->window will be created when a widget
  * is realized.  Normally realization happens implicitly; if you show
  * a widget and all its parent containers, then the widget will be
  * realized and mapped automatically.
@@ -1907,7 +1919,7 @@ gtk_widget_realize (GtkWidget *widget)
  *
  * This function is only useful in widget implementations.
  * Causes a widget to be unrealized (frees all GDK resources
- * associated with the widget, such as widget->window).
+ * associated with the widget, such as @widget->window).
  * 
  **/
 void
@@ -2508,8 +2520,6 @@ static void
 gtk_widget_real_size_allocate (GtkWidget     *widget,
                               GtkAllocation *allocation)
 {
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-
   widget->allocation = *allocation;
   
   if (GTK_WIDGET_REALIZED (widget) &&
@@ -2592,28 +2602,28 @@ widget_new_accel_closure (GtkWidget *widget,
 /**
  * gtk_widget_add_accelerator
  * @widget:       widget to install an accelerator on
- * @accel_signal: widget signal to emit on accelerator actiavtion
+ * @accel_signal: widget signal to emit on accelerator activation
  * @accel_group:  accel group for this widget, added to its toplevel
  * @accel_key:    GDK keyval of the accelerator
  * @accel_mods:   modifier key combination of the accelerator
  * @accel_flags:  flag accelerators, e.g. %GTK_ACCEL_VISIBLE
  *
- * Installs an accelerator for this @widget in @accel_group, that causes
+ * Installs an accelerator for this @widget in @accel_group that causes
  * @accel_signal to be emitted if the accelerator is activated.
  * The @accel_group needs to be added to the widget's toplevel via
  * gtk_window_add_accel_group(), and the signal must be of type %G_RUN_ACTION.
- * Accelerators added through this function are not user changable during
+ * Accelerators added through this function are not user changeable during
  * runtime. If you want to support accelerators that can be changed by the
- * user, use gtk_accel_map_add_entry() and gtk_menu_item_set_accel_path()
- * instead.
+ * user, use gtk_accel_map_add_entry() and gtk_widget_set_accel_path() or
+ * gtk_menu_item_set_accel_path() instead.
  */
 void
-gtk_widget_add_accelerator (GtkWidget     *widget,
-                           const gchar   *accel_signal,
-                           GtkAccelGroup *accel_group,
-                           guint          accel_key,
-                           guint          accel_mods,
-                           GtkAccelFlags  accel_flags)
+gtk_widget_add_accelerator (GtkWidget      *widget,
+                           const gchar    *accel_signal,
+                           GtkAccelGroup  *accel_group,
+                           guint           accel_key,
+                           GdkModifierType accel_mods,
+                           GtkAccelFlags   accel_flags)
 {
   GClosure *closure;
   GSignalQuery query;
@@ -2664,10 +2674,10 @@ gtk_widget_add_accelerator (GtkWidget     *widget,
  * gtk_widget_add_accelerator().
  */
 gboolean
-gtk_widget_remove_accelerator (GtkWidget     *widget,
-                              GtkAccelGroup *accel_group,
-                              guint          accel_key,
-                              guint          accel_mods)
+gtk_widget_remove_accelerator (GtkWidget      *widget,
+                              GtkAccelGroup  *accel_group,
+                              guint           accel_key,
+                              GdkModifierType accel_mods)
 {
   GtkAccelGroupEntry *ag_entry;
   GList *slist, *clist;
@@ -2711,8 +2721,8 @@ gtk_widget_remove_accelerator (GtkWidget     *widget,
  * Lists the closures used by @widget for accelerator group connections
  * with gtk_accel_group_connect_by_path() or gtk_accel_group_connect().
  * The closures can be used to monitor accelerator changes on @widget,
- * by connecting to the ::accel_changed signal of the #GtkAccelGroup
- * of a closure which can be found out with gtk_accel_group_from_accel_closure().
+ * by connecting to the ::accel_changed signal of the #GtkAccelGroup of a 
+ * closure which can be found out with gtk_accel_group_from_accel_closure().
  */
 GList*
 gtk_widget_list_accel_closures (GtkWidget *widget)
@@ -2748,15 +2758,35 @@ destroy_accel_path (gpointer data)
   g_free (apath);
 }
 
-/* accel_group: the accel group used to activate this widget
- * accel_path:  the accel path, associating the accelerator
- *              to activate this widget
- * set accel path through which this widget can be actiavated.
- */
+
+/**
+ * gtk_widget_set_accel_path:
+ * @widget: a #GtkWidget
+ * @accel_path: path used to look up the the accelerator
+ * @accel_group: a #GtkAccelGroup.
+ * 
+ * Given an accelerator group, @accel_group, and an accelerator path,
+ * @accel_path, sets up an accelerator in @accel_group so whenever the
+ * key binding that is defined for @accel_path is pressed, @widget
+ * will be activated.  This removes any accelerators (for any
+ * accelerator group) installed by previous calls to
+ * gtk_widget_set_accel_path(). Associating accelerators with
+ * paths allows them to be modified by the user and the modifications
+ * to be saved for future use. (See gtk_accel_map_save().)
+ *
+ * This function is a low level function that would most likely
+ * be used by a menu creation system like #GtkItemFactory. If you
+ * use #GtkItemFactory, setting up accelerator paths will be done
+ * automatically.
+ *
+ * Even when you you aren't using #GtkItemFactory, if you only want to
+ * set up accelerators on menu items gtk_menu_item_set_accel_path()
+ * provides a somewhat more convenient interface.
+ **/
 void
-_gtk_widget_set_accel_path (GtkWidget     *widget,
-                           const gchar   *accel_path,
-                           GtkAccelGroup *accel_group)
+gtk_widget_set_accel_path (GtkWidget     *widget,
+                          const gchar   *accel_path,
+                          GtkAccelGroup *accel_group)
 {
   AccelPath *apath;
 
@@ -2838,41 +2868,20 @@ static gboolean
 gtk_widget_real_key_press_event (GtkWidget         *widget,
                                 GdkEventKey       *event)
 {
-  gboolean handled = FALSE;
-
-  g_return_val_if_fail (GTK_IS_WIDGET (widget), handled);
-  g_return_val_if_fail (event != NULL, handled);
-
-  if (!handled)
-    handled = gtk_bindings_activate (GTK_OBJECT (widget),
-                                    event->keyval,
-                                    event->state);
-
-  return handled;
+  return _gtk_bindings_activate_event (GTK_OBJECT (widget), event);
 }
 
 static gboolean
 gtk_widget_real_key_release_event (GtkWidget         *widget,
                                   GdkEventKey       *event)
 {
-  gboolean handled = FALSE;
-
-  g_return_val_if_fail (GTK_IS_WIDGET (widget), handled);
-  g_return_val_if_fail (event != NULL, handled);
-
-  if (!handled)
-    handled = gtk_bindings_activate (GTK_OBJECT (widget),
-                                    event->keyval,
-                                    event->state | GDK_RELEASE_MASK);
-
-  return handled;
+  return _gtk_bindings_activate_event (GTK_OBJECT (widget), event);
 }
 
 static gboolean
 gtk_widget_real_focus_in_event (GtkWidget     *widget,
                                 GdkEventFocus *event)
 {
-  GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
   gtk_widget_queue_draw (widget);
 
   return FALSE;
@@ -2882,12 +2891,14 @@ static gboolean
 gtk_widget_real_focus_out_event (GtkWidget     *widget,
                                  GdkEventFocus *event)
 {
-  GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
   gtk_widget_queue_draw (widget);
 
   return FALSE;
 }
 
+#define WIDGET_REALIZED_FOR_EVENT(widget, event) \
+     (event->type == GDK_FOCUS_CHANGE || GTK_WIDGET_REALIZED(widget))
+
 /**
  * gtk_widget_event:
  * @widget: a #GtkWidget
@@ -2909,7 +2920,7 @@ gtk_widget_event (GtkWidget *widget,
                  GdkEvent  *event)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
-  g_return_val_if_fail (GTK_WIDGET_REALIZED (widget), TRUE);
+  g_return_val_if_fail (WIDGET_REALIZED_FOR_EVENT (widget, event), TRUE);
 
   if (event->type == GDK_EXPOSE)
     {
@@ -2937,7 +2948,7 @@ gtk_widget_event (GtkWidget *widget,
  * If you want to force an area of a window to be redrawn, 
  * use gdk_window_invalidate_rect() or gdk_window_invalidate_region().
  * To cause the redraw to be done immediately, follow that call
- * with a call to gdk_window_procss_updates().
+ * with a call to gdk_window_process_updates().
  * 
  * Return value: return from the event signal emission (%TRUE if the event was handled)
  **/
@@ -2965,7 +2976,7 @@ gtk_widget_event_internal (GtkWidget *widget,
   gtk_widget_ref (widget);
 
   gtk_signal_emit (GTK_OBJECT (widget), widget_signals[EVENT], event, &return_val);
-  return_val |= !GTK_WIDGET_REALIZED (widget);
+  return_val |= !WIDGET_REALIZED_FOR_EVENT (widget, event);
   if (!return_val)
     {
       gint signal_num;
@@ -3060,7 +3071,7 @@ gtk_widget_event_internal (GtkWidget *widget,
       if (signal_num != -1)
        gtk_signal_emit (GTK_OBJECT (widget), widget_signals[signal_num], event, &return_val);
     }
-  if (GTK_WIDGET_REALIZED (widget))
+  if (WIDGET_REALIZED_FOR_EVENT (widget, event))
     gtk_signal_emit (GTK_OBJECT (widget), widget_signals[EVENT_AFTER], event);
   else
     return_val = TRUE;
@@ -3148,7 +3159,6 @@ static void
 gtk_widget_reparent_container_child (GtkWidget *widget,
                                     gpointer   client_data)
 {
-  g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (client_data != NULL);
   
   if (GTK_WIDGET_NO_WINDOW (widget))
@@ -3207,6 +3217,8 @@ gtk_widget_reparent (GtkWidget *widget,
          gtk_widget_reparent_container_child (widget,
                                               gtk_widget_get_parent_window (widget));
        }
+
+      g_object_notify (G_OBJECT (widget), "parent");
     }
 }
 
@@ -3255,7 +3267,7 @@ gtk_widget_intersect (GtkWidget      *widget,
  * gtk_widget_region_intersect:
  * @widget: a #GtkWidget
  * @region: a #GdkRegion, in the same coordinate system as 
- *          widget->allocation. That is, relative to @widget->window
+ *          @widget->allocation. That is, relative to @widget->window
  *          for %NO_WINDOW widgets; relative to the parent window
  *          of @widget->window for widgets with their own window.
  * @returns: A newly allocated region holding the intersection of @widget
@@ -3299,6 +3311,9 @@ gtk_widget_grab_focus (GtkWidget *widget)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
+  if (!GTK_WIDGET_IS_SENSITIVE (widget))
+    return;
+  
   g_object_ref (G_OBJECT (widget));
   gtk_signal_emit (GTK_OBJECT (widget), widget_signals[GRAB_FOCUS]);
   g_object_notify (G_OBJECT (widget), "has_focus");
@@ -3325,8 +3340,6 @@ reset_focus_recurse (GtkWidget *widget,
 static void
 gtk_widget_real_grab_focus (GtkWidget *focus_widget)
 {
-  g_return_if_fail (GTK_IS_WIDGET (focus_widget));
-  
   if (GTK_WIDGET_CAN_FOCUS (focus_widget))
     {
       GtkWidget *toplevel;
@@ -3387,12 +3400,17 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget)
     }
 }
 
-static void
+static gboolean
 gtk_widget_real_show_help (GtkWidget        *widget,
                            GtkWidgetHelpType help_type)
 {
   if (help_type == GTK_WIDGET_HELP_TOOLTIP)
-    _gtk_tooltips_show_tip (widget);
+    {
+      _gtk_tooltips_toggle_keyboard_mode (widget);
+      return TRUE;
+    }
+  else
+    return FALSE;
 }
 
 static gboolean
@@ -3460,7 +3478,10 @@ gtk_widget_grab_default (GtkWidget *widget)
   window = gtk_widget_get_toplevel (widget);
   
   if (window && GTK_WIDGET_TOPLEVEL (window))
-    gtk_window_set_default (GTK_WINDOW (window), widget);
+    {
+       gtk_window_set_default (GTK_WINDOW (window), widget);
+       g_object_notify (G_OBJECT (widget), "has_default");
+    }
   else
     g_warning (G_STRLOC ": widget not within a GtkWindow");
 }
@@ -3642,13 +3663,13 @@ gtk_widget_set_redraw_on_allocate (GtkWidget *widget,
 
 /**
  * gtk_widget_set_sensitive:
- * @widget: a @widget
+ * @widget: a #GtkWidget
  * @sensitive: %TRUE to make the widget sensitive
  *
  * Sets the sensitivity of a widget. A widget is sensitive if the user
  * can interact with it. Insensitive widgets are "grayed out" and the
  * user can't interact with them. Insensitive widgets are known as
- * "inactive" in some other toolkits.
+ * "inactive", "disabled", or "ghosted" in some other toolkits.
  * 
  **/
 void
@@ -3730,7 +3751,7 @@ gtk_widget_set_parent (GtkWidget *widget,
 
   gtk_widget_propagate_state (widget, &data);
   
-  gtk_widget_set_style_recurse (widget, NULL);
+  gtk_widget_reset_rc_styles (widget);
 
   gtk_signal_emit (GTK_OBJECT (widget), widget_signals[PARENT_SET], NULL);
   if (GTK_WIDGET_ANCHORED (widget->parent))
@@ -3899,6 +3920,7 @@ gtk_widget_modify_style (GtkWidget      *widget,
 {
   GtkRcStyle *old_style;
 
+  g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (GTK_IS_RC_STYLE (style));
   
   old_style = gtk_object_get_data_by_id (GTK_OBJECT (widget),
@@ -3943,6 +3965,8 @@ gtk_widget_get_modifier_style (GtkWidget      *widget)
 {
   GtkRcStyle *rc_style;
   
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
   rc_style = gtk_object_get_data_by_id (GTK_OBJECT (widget),
                                        quark_rc_style);
 
@@ -4129,9 +4153,6 @@ gtk_widget_set_style_internal (GtkWidget *widget,
                               GtkStyle  *style,
                               gboolean   initial_emission)
 {
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (style != NULL);
-
   g_object_ref (G_OBJECT (widget));
   g_object_freeze_notify (G_OBJECT (widget));
 
@@ -4165,18 +4186,7 @@ gtk_widget_set_style_internal (GtkWidget *widget,
       g_object_unref (previous_style);
 
       if (widget->parent && !initial_emission)
-       {
-         GtkRequisition old_requisition;
-         
-         old_requisition = widget->requisition;
-         gtk_widget_size_request (widget, NULL);
-         
-         if ((old_requisition.width != widget->requisition.width) ||
-             (old_requisition.height != widget->requisition.height))
-           gtk_widget_queue_resize (widget);
-         else if (GTK_WIDGET_DRAWABLE (widget))
-           gtk_widget_queue_clear (widget);
-       }
+       gtk_widget_queue_resize (widget);
     }
   else if (initial_emission)
     gtk_signal_emit (GTK_OBJECT (widget),
@@ -4187,19 +4197,6 @@ gtk_widget_set_style_internal (GtkWidget *widget,
   g_object_unref (G_OBJECT (widget));
 }
 
-static void
-gtk_widget_set_style_recurse (GtkWidget *widget,
-                             gpointer   client_data)
-{
-  if (GTK_WIDGET_RC_STYLE (widget))
-    gtk_widget_reset_rc_style (widget);
-  
-  if (GTK_IS_CONTAINER (widget))
-    gtk_container_forall (GTK_CONTAINER (widget),
-                         gtk_widget_set_style_recurse,
-                         NULL);
-}
-
 static void
 gtk_widget_propagate_hierarchy_changed_recurse (GtkWidget *widget,
                                                gpointer   client_data)
@@ -4252,14 +4249,34 @@ _gtk_widget_propagate_hierarchy_changed (GtkWidget    *widget,
     g_object_unref (previous_toplevel);
 }
 
+static void
+reset_rc_styles_recurse (GtkWidget *widget, gpointer data)
+{
+  if (GTK_WIDGET_RC_STYLE (widget))
+    gtk_widget_reset_rc_style (widget);
+  
+  if (GTK_IS_CONTAINER (widget))
+    gtk_container_forall (GTK_CONTAINER (widget),
+                         reset_rc_styles_recurse,
+                         NULL);
+}
+
 void
 gtk_widget_reset_rc_styles (GtkWidget *widget)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  gtk_widget_set_style_recurse (widget, NULL);
+  reset_rc_styles_recurse (widget, NULL);
 }
 
+/**
+ * gtk_widget_get_default_style:
+ * 
+ * Returns the default style used by all widgets initially.
+ * 
+ * Returns: the default style. This #GtkStyle object is owned by GTK+ and
+ * should not be modified or freed.
+ */ 
 GtkStyle*
 gtk_widget_get_default_style (void)
 {
@@ -4319,7 +4336,7 @@ gtk_widget_get_pango_context (GtkWidget *widget)
  * 
  * Creates a new #PangoContext with the appropriate colormap,
  * font description, and base direction for drawing text for
- * this widget. See also gtk_widget_get_pango_context()
+ * this widget. See also gtk_widget_get_pango_context().
  * 
  * Return value: the new #PangoContext
  **/
@@ -4609,7 +4626,7 @@ gtk_widget_child_focus (GtkWidget       *widget,
  * 
  *
  * Sets the position of a widget. The funny "u" in the name comes from
- * the "user position" hint specified by the X window system, and
+ * the "user position" hint specified by the X Window System, and
  * exists for legacy reasons. This function doesn't work if a widget
  * is inside a container; it's only really useful on #GtkWindow.
  *
@@ -4911,7 +4928,10 @@ gtk_widget_add_events (GtkWidget *widget,
              gdk_window_get_user_data (window, &user_data);
              if (user_data == widget)
                gdk_window_set_events (window, gdk_window_get_events (window) | events);
+             tmp_list = tmp_list->next;
            }
+
+         g_list_free (children);
        }
       else
        {
@@ -4965,21 +4985,20 @@ gtk_widget_set_extension_events (GtkWidget *widget,
  * window was inside a #GtkWindow-derived widget which was in turn
  * inside the toplevel #GtkWindow. While the second case may
  * seem unlikely, it actually happens when a #GtkPlug is embedded
- * inside a #GtkSocket within the same application
+ * inside a #GtkSocket within the same application.
  * 
  * To reliably find the toplevel #GtkWindow, use
  * gtk_widget_get_toplevel() and check if the %TOPLEVEL flags
  * is set on the result.
- * 
- *  <programlisting>
- *  GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
- *  if (GTK_WIDGET_TOPLEVEL (toplevel))
- *   {
- *     [ Perform action on toplevel. ]
- *   }
- *  </programlisting>
+ *  <informalexample><programlisting>
+ *  <!>GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
+ *  <!>if (GTK_WIDGET_TOPLEVEL (toplevel))
+ *  <!> {
+ *  <!>   [ Perform action on toplevel. ]
+ *  <!> }
+ *  </programlisting></informalexample>
  *
- * Return value: the topmost ancestor of @widget, or @widget itself if there's no ancestor
+ * Return value: the topmost ancestor of @widget, or @widget itself if there's no ancestor.
  **/
 GtkWidget*
 gtk_widget_get_toplevel (GtkWidget *widget)
@@ -5077,7 +5096,7 @@ gtk_widget_get_visual (GtkWidget *widget)
  * gtk_widget_get_settings:
  * @widget: a #GtkWidget
  * 
- * Get the settings object holding the settings (global property
+ * Gets the settings object holding the settings (global property
  * settings, RC file information, etc) used for this widget.
  * 
  * Return value: the relevant #GtkSettings object
@@ -5282,16 +5301,22 @@ gtk_widget_get_composite_name (GtkWidget *widget)
  * Makes all newly-created widgets as composite children until
  * the corresponding gtk_widget_pop_composite_child() call.
  * 
+ * A composite child is a child that's an implementation detail of the
+ * container it's inside and should not be visible to people using the
+ * container. Composite children aren't treated differently by GTK (but
+ * see gtk_container_foreach() vs. gtk_container_forall()), but e.g. GUI 
+ * builders might want to treat them in a different way.
+ * 
  * Here is a simple example:
- * <programlisting>
- *   gtk_widget_push_composite_child ();
- *   scrolled_window->hscrollbar = gtk_hscrollbar_new (hadjustment);
- *   gtk_widget_set_composite_name (scrolled_window->hscrollbar, "hscrollbar");
- *   gtk_widget_pop_composite_child ();
- *   gtk_widget_set_parent (scrolled_window->hscrollbar, 
- *                          GTK_WIDGET (scrolled_window));
- *   gtk_widget_ref (scrolled_window->hscrollbar);
- * </programlisting>
+ * <informalexample><programlisting>
+ * <!>  gtk_widget_push_composite_child (<!>);
+ * <!>  scrolled_window->hscrollbar = gtk_hscrollbar_new (hadjustment);
+ * <!>  gtk_widget_set_composite_name (scrolled_window->hscrollbar, "hscrollbar");
+ * <!>  gtk_widget_pop_composite_child (<!>);
+ * <!>  gtk_widget_set_parent (scrolled_window->hscrollbar, 
+ * <!>                         GTK_WIDGET (scrolled_window));
+ * <!>  gtk_widget_ref (scrolled_window->hscrollbar);
+ * </programlisting></informalexample>
  **/
 void
 gtk_widget_push_composite_child (void)
@@ -5324,7 +5349,7 @@ gtk_widget_pop_composite_child (void)
 void
 gtk_widget_push_colormap (GdkColormap *cmap)
 {
-  g_return_if_fail (cmap != NULL);
+  g_return_if_fail (GDK_IS_COLORMAP (cmap));
 
   colormap_stack = g_slist_prepend (colormap_stack, cmap);
 }
@@ -5354,6 +5379,8 @@ gtk_widget_pop_colormap (void)
 void
 gtk_widget_set_default_colormap (GdkColormap *colormap)
 {
+  g_return_if_fail (GDK_IS_COLORMAP (colormap));
+
   if (default_colormap != colormap)
     {
       if (default_colormap)
@@ -5421,7 +5448,7 @@ gtk_widget_emit_direction_changed (GtkWidget        *widget,
  * reading directions can be done. Generally, applications will
  * let the default reading direction present, except for containers
  * where the containers are arranged in an order that is explicitely
- * visual rather than logical (such as buttons for text justificiation).
+ * visual rather than logical (such as buttons for text justification).
  *
  * If the direction is set to %GTK_TEXT_DIR_NONE, then the value
  * set by gtk_widget_set_default_direction() will be used.
@@ -5529,7 +5556,7 @@ gtk_widget_set_default_direction (GtkTextDirection dir)
  * gtk_widget_get_default_direction:
  * 
  * Obtains the current default reading direction. See
- * gtk_widget_set_direction().
+ * gtk_widget_set_default_direction().
  *
  * Return value: the current default direction. 
  **/
@@ -5557,18 +5584,14 @@ gtk_widget_dispose (GObject *object)
 static void
 gtk_widget_real_destroy (GtkObject *object)
 {
-  GtkWidget *widget;
-
-  /* gtk_object_destroy() will already hold a refcount on object
-   */
-  widget = GTK_WIDGET (object);
+  /* gtk_object_destroy() will already hold a refcount on object */
+  GtkWidget *widget = GTK_WIDGET (object);
 
   /* wipe accelerator closures (keep order) */
   g_object_set_qdata (G_OBJECT (widget), quark_accel_path, NULL);
   g_object_set_qdata (G_OBJECT (widget), quark_accel_closures, NULL);
 
   gtk_grab_remove (widget);
-  gtk_selection_remove_all (widget);
   
   g_object_unref (widget->style);
   widget->style = gtk_widget_get_default_style ();
@@ -5587,7 +5610,6 @@ gtk_widget_finalize (GObject *object)
   GtkAccessible *accessible;
   
   gtk_grab_remove (widget);
-  gtk_selection_remove_all (widget);
 
   g_object_unref (widget->style);
   widget->style = NULL;
@@ -5625,7 +5647,6 @@ gtk_widget_finalize (GObject *object)
 static void
 gtk_widget_real_map (GtkWidget *widget)
 {
-  g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (GTK_WIDGET_REALIZED (widget) == TRUE);
   
   if (!GTK_WIDGET_MAPPED (widget))
@@ -5648,8 +5669,6 @@ gtk_widget_real_map (GtkWidget *widget)
 static void
 gtk_widget_real_unmap (GtkWidget *widget)
 {
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  
   if (GTK_WIDGET_MAPPED (widget))
     {
       GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
@@ -5670,7 +5689,6 @@ gtk_widget_real_unmap (GtkWidget *widget)
 static void
 gtk_widget_real_realize (GtkWidget *widget)
 {
-  g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (GTK_WIDGET_NO_WINDOW (widget));
   
   GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
@@ -5693,8 +5711,6 @@ gtk_widget_real_realize (GtkWidget *widget)
 static void
 gtk_widget_real_unrealize (GtkWidget *widget)
 {
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-
   if (GTK_WIDGET_MAPPED (widget))
     gtk_widget_real_unmap (widget);
 
@@ -5727,6 +5743,8 @@ gtk_widget_real_unrealize (GtkWidget *widget)
       widget->window = NULL;
     }
 
+  gtk_selection_remove_all (widget);
+  
   GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED);
 }
 
@@ -5734,8 +5752,6 @@ static void
 gtk_widget_real_size_request (GtkWidget         *widget,
                              GtkRequisition    *requisition)
 {
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-
   requisition->width = widget->requisition.width;
   requisition->height = widget->requisition.height;
 }
@@ -5883,8 +5899,6 @@ _gtk_widget_get_aux_info (GtkWidget *widget,
 static void
 gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info)
 {
-  g_return_if_fail (aux_info != NULL);
-  
   g_mem_chunk_free (aux_info_mem_chunk, aux_info);
 }
 
@@ -5902,7 +5916,7 @@ gtk_widget_shape_info_destroy (GtkWidgetShapeInfo *info)
  * @offset_x: X position of shape mask with respect to @window.
  * @offset_y: Y position of shape mask with respect to @window.
  * 
- * Sets a shape for this widget's gdk window. This allows for
+ * Sets a shape for this widget's GDK window. This allows for
  * transparent windows etc., see gdk_window_shape_combine_mask()
  * for more information.
  **/
@@ -6056,6 +6070,14 @@ gtk_widget_class_install_style_property (GtkWidgetClass *class,
   gtk_widget_class_install_style_property_parser (class, pspec, parser);
 }
 
+/**
+ * gtk_widget_style_get_property:
+ * @widget: a #GtkWidget
+ * @property_name: the name of a style property
+ * @value: location to return the property value 
+ *
+ * Gets the value of a style property of @widget.
+ */
 void
 gtk_widget_style_get_property (GtkWidget   *widget,
                               const gchar *property_name,
@@ -6101,6 +6123,17 @@ gtk_widget_style_get_property (GtkWidget   *widget,
   g_object_unref (widget);
 }
 
+/**
+ * gtk_widget_style_get_valist:
+ * @widget: a #GtkWidget
+ * @first_property_name: the name of the first property to get
+ * @var_args: a <type>va_list</type> of pairs of property names and
+ *     locations to return the property values, starting with the location
+ *     for @first_property_name.
+ * 
+ * Non-vararg variant of gtk_widget_style_get(). Used primarily by language 
+ * bindings.
+ */ 
 void
 gtk_widget_style_get_valist (GtkWidget   *widget,
                             const gchar *first_property_name,
@@ -6151,6 +6184,16 @@ gtk_widget_style_get_valist (GtkWidget   *widget,
   g_object_unref (widget);
 }
 
+/**
+ * gtk_widget_style_get:
+ * @widget: a #GtkWidget
+ * @first_property_name: the name of the first property to get
+ * @Varargs: pairs of property names and locations to 
+ *   return the property values, starting with the location for 
+ *   @first_property_name, terminated by %NULL.
+ *
+ * Gets the values of a multiple style properties of @widget.
+ */
 void
 gtk_widget_style_get (GtkWidget   *widget,
                      const gchar *first_property_name,
@@ -6168,9 +6211,9 @@ gtk_widget_style_get (GtkWidget   *widget,
 /**
  * gtk_widget_path:
  * @widget: a #GtkWidget
- * @path_length_p: location to store length of the path, or %NULL
- * @path_p: location to store allocated path string, or %NULL 
- * @path_reversed_p: location to store allocated reverse path string, or %NULL
+ * @path_length: location to store length of the path, or %NULL
+ * @path: location to store allocated path string, or %NULL 
+ * @path_reversed: location to store allocated reverse path string, or %NULL
  *
  * Obtains the full path to @widget. The path is simply the name of a
  * widget and all its parents in the container hierarchy, separated by
@@ -6188,12 +6231,12 @@ gtk_widget_style_get (GtkWidget   *widget,
  **/
 void
 gtk_widget_path (GtkWidget *widget,
-                guint     *path_length_p,
-                gchar    **path_p,
-                gchar    **path_reversed_p)
+                guint     *path_length,
+                gchar    **path,
+                gchar    **path_reversed)
 {
   static gchar *rev_path = NULL;
-  static guint  path_len = 0;
+  static guint tmp_path_len = 0;
   guint len;
   
   g_return_if_fail (GTK_IS_WIDGET (widget));
@@ -6208,10 +6251,10 @@ gtk_widget_path (GtkWidget *widget,
       
       string = gtk_widget_get_name (widget);
       l = strlen (string);
-      while (path_len <= len + l + 1)
+      while (tmp_path_len <= len + l + 1)
        {
-         path_len += INIT_PATH_SIZE;
-         rev_path = g_realloc (rev_path, path_len);
+         tmp_path_len += INIT_PATH_SIZE;
+         rev_path = g_realloc (rev_path, tmp_path_len);
        }
       s = string + l - 1;
       d = rev_path + len;
@@ -6228,23 +6271,23 @@ gtk_widget_path (GtkWidget *widget,
     }
   while (widget);
   
-  if (path_length_p)
-    *path_length_p = len - 1;
-  if (path_reversed_p)
-    *path_reversed_p = g_strdup (rev_path);
-  if (path_p)
+  if (path_length)
+    *path_length = len - 1;
+  if (path_reversed)
+    *path_reversed = g_strdup (rev_path);
+  if (path)
     {
-      *path_p = g_strdup (rev_path);
-      g_strreverse (*path_p);
+      *path = g_strdup (rev_path);
+      g_strreverse (*path);
     }
 }
 
 /**
  * gtk_widget_class_path:
  * @widget: a #GtkWidget
- * @path_length_p: location to store the length of the class path, or %NULL
- * @path_p: location to store the class path as an allocated string, or %NULL
- * @path_reversed_p: location to store the reverse class path as an allocated string, or %NULL
+ * @path_length: location to store the length of the class path, or %NULL
+ * @path: location to store the class path as an allocated string, or %NULL
+ * @path_reversed: location to store the reverse class path as an allocated string, or %NULL
  *
  * Same as gtk_widget_path(), but always uses the name of a widget's type,
  * never uses a custom name set with gtk_widget_set_name().
@@ -6252,12 +6295,12 @@ gtk_widget_path (GtkWidget *widget,
  **/
 void
 gtk_widget_class_path (GtkWidget *widget,
-                      guint     *path_length_p,
-                      gchar    **path_p,
-                      gchar    **path_reversed_p)
+                      guint     *path_length,
+                      gchar    **path,
+                      gchar    **path_reversed)
 {
   static gchar *rev_path = NULL;
-  static guint  path_len = 0;
+  static guint tmp_path_len = 0;
   guint len;
   
   g_return_if_fail (GTK_IS_WIDGET (widget));
@@ -6272,10 +6315,10 @@ gtk_widget_class_path (GtkWidget *widget,
       
       string = gtk_type_name (GTK_WIDGET_TYPE (widget));
       l = strlen (string);
-      while (path_len <= len + l + 1)
+      while (tmp_path_len <= len + l + 1)
        {
-         path_len += INIT_PATH_SIZE;
-         rev_path = g_realloc (rev_path, path_len);
+         tmp_path_len += INIT_PATH_SIZE;
+         rev_path = g_realloc (rev_path, tmp_path_len);
        }
       s = string + l - 1;
       d = rev_path + len;
@@ -6292,14 +6335,14 @@ gtk_widget_class_path (GtkWidget *widget,
     }
   while (widget);
   
-  if (path_length_p)
-    *path_length_p = len - 1;
-  if (path_reversed_p)
-    *path_reversed_p = g_strdup (rev_path);
-  if (path_p)
+  if (path_length)
+    *path_length = len - 1;
+  if (path_reversed)
+    *path_reversed = g_strdup (rev_path);
+  if (path)
     {
-      *path_p = g_strdup (rev_path);
-      g_strreverse (*path_p);
+      *path = g_strdup (rev_path);
+      g_strreverse (*path);
     }
 }
 
@@ -6328,6 +6371,19 @@ gtk_requisition_free (GtkRequisition *requisition)
   g_free (requisition);
 }
 
+GType
+gtk_requisition_get_type (void)
+{
+  static GType our_type = 0;
+  
+  if (our_type == 0)
+    our_type = g_boxed_type_register_static ("GtkTypeRequisition",
+                                            (GBoxedCopyFunc) gtk_requisition_copy,
+                                            (GBoxedFreeFunc) gtk_requisition_free);
+
+  return our_type;
+}
+
 AtkObject* 
 gtk_widget_get_accessible (GtkWidget *widget)
 {
@@ -6387,4 +6443,3 @@ gtk_widget_ref_accessible (AtkImplementor *implementor)
     g_object_ref (G_OBJECT (accessible));
   return accessible;
 }
-