]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkwidget.c
Silence new gcc warnings
[~andy/gtk] / gtk / gtkwidget.c
index 24cc27204a0fb4deef9975867dd7506c26b5b9cf..11338a22ebf69f051e452bf0c0e7ce3c48be96e0 100644 (file)
@@ -42,7 +42,7 @@
 #include "gtkmainprivate.h"
 #include "gtkmarshalers.h"
 #include "gtkrc.h"
-#include "gtkselection.h"
+#include "gtkselectionprivate.h"
 #include "gtksettingsprivate.h"
 #include "gtksizegroup-private.h"
 #include "gtkwidget.h"
@@ -56,7 +56,7 @@
 #include "gtkbuildable.h"
 #include "gtkbuilderprivate.h"
 #include "gtksizerequest.h"
-#include "gtkstylecontext.h"
+#include "gtkstylecontextprivate.h"
 #include "gtksymboliccolor.h"
 #include "gtkcssprovider.h"
 #include "gtkanimationdescription.h"
@@ -663,6 +663,10 @@ static void gtk_widget_set_usize_internal (GtkWidget          *widget,
 static void gtk_widget_add_events_internal (GtkWidget *widget,
                                             GdkDevice *device,
                                             gint       events);
+static void gtk_widget_set_device_enabled_internal (GtkWidget *widget,
+                                                    GdkDevice *device,
+                                                    gboolean   recurse,
+                                                    gboolean   enabled);
 
 /* --- variables --- */
 static gpointer         gtk_widget_parent_class = NULL;
@@ -691,6 +695,7 @@ static GQuark               quark_has_tooltip = 0;
 static GQuark          quark_tooltip_window = 0;
 static GQuark          quark_visual = 0;
 static GQuark           quark_modifier_style = 0;
+static GQuark           quark_enabled_devices = 0;
 GParamSpecPool         *_gtk_widget_child_property_pool = NULL;
 GObjectNotifyContext   *_gtk_widget_child_property_notify_context = NULL;
 
@@ -804,6 +809,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   quark_tooltip_window = g_quark_from_static_string ("gtk-tooltip-window");
   quark_visual = g_quark_from_static_string ("gtk-widget-visual");
   quark_modifier_style = g_quark_from_static_string ("gtk-widget-modifier-style");
+  quark_enabled_devices = g_quark_from_static_string ("gtk-widget-enabled-devices");
 
   style_property_spec_pool = g_param_spec_pool_new (FALSE);
   _gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE);
@@ -4222,6 +4228,105 @@ _gtk_widget_enable_device_events (GtkWidget *widget)
     }
 }
 
+static GList *
+get_widget_windows (GtkWidget *widget)
+{
+  GList *window_list, *last, *l, *children, *ret;
+
+  if (gtk_widget_get_has_window (widget))
+    window_list = g_list_prepend (NULL, gtk_widget_get_window (widget));
+  else
+    window_list = gdk_window_peek_children (gtk_widget_get_window (widget));
+
+  last = g_list_last (window_list);
+  ret = NULL;
+
+  for (l = window_list; l; l = l->next)
+    {
+      GtkWidget *window_widget = NULL;
+
+      gdk_window_get_user_data (l->data, (gpointer *) &window_widget);
+
+      if (widget != window_widget)
+        continue;
+
+      ret = g_list_prepend (ret, l->data);
+      children = gdk_window_peek_children (GDK_WINDOW (l->data));
+
+      if (children)
+        {
+          last = g_list_concat (last, children);
+          last = g_list_last (last);
+        }
+    }
+
+  g_list_free (window_list);
+
+  return ret;
+}
+
+static void
+device_enable_foreach (GtkWidget *widget,
+                       gpointer   user_data)
+{
+  GdkDevice *device = user_data;
+  gtk_widget_set_device_enabled_internal (widget, device, TRUE, TRUE);
+}
+
+static void
+device_disable_foreach (GtkWidget *widget,
+                        gpointer   user_data)
+{
+  GdkDevice *device = user_data;
+  gtk_widget_set_device_enabled_internal (widget, device, TRUE, FALSE);
+}
+
+static void
+gtk_widget_set_device_enabled_internal (GtkWidget *widget,
+                                        GdkDevice *device,
+                                        gboolean   recurse,
+                                        gboolean   enabled)
+{
+  GList *window_list, *l;
+
+  window_list = get_widget_windows (widget);
+
+  for (l = window_list; l; l = l->next)
+    {
+      GdkEventMask events = 0;
+      GdkWindow *window;
+
+      window = l->data;
+
+      if (enabled)
+        events = gdk_window_get_events (window);
+
+      gdk_window_set_device_events (window, device, events);
+    }
+
+  if (recurse && GTK_IS_CONTAINER (widget))
+    {
+      if (enabled)
+        gtk_container_forall (GTK_CONTAINER (widget), device_enable_foreach, device);
+      else
+        gtk_container_forall (GTK_CONTAINER (widget), device_disable_foreach, device);
+    }
+
+  g_list_free (window_list);
+}
+
+static void
+gtk_widget_update_devices_mask (GtkWidget *widget,
+                                gboolean   recurse)
+{
+  GList *enabled_devices, *l;
+
+  enabled_devices = g_object_get_qdata (G_OBJECT (widget), quark_enabled_devices);
+
+  for (l = enabled_devices; l; l = l->next)
+    gtk_widget_set_device_enabled_internal (widget, GDK_DEVICE (l->data), recurse, TRUE);
+}
+
 /**
  * gtk_widget_realize:
  * @widget: a #GtkWidget
@@ -4300,6 +4405,7 @@ gtk_widget_realize (GtkWidget *widget)
         gdk_window_set_support_multidevice (priv->window, TRUE);
 
       _gtk_widget_enable_device_events (widget);
+      gtk_widget_update_devices_mask (widget, TRUE);
 
       gtk_widget_pop_verify_invariants (widget);
     }
@@ -4362,6 +4468,8 @@ gtk_widget_unrealize (GtkWidget *widget)
  * Normally you would only use this function in widget
  * implementations. You might also use it to schedule a redraw of a
  * #GtkDrawingArea or some portion thereof.
+ *
+ * Since: 3.0
  **/
 void
 gtk_widget_queue_draw_region (GtkWidget      *widget,
@@ -4611,7 +4719,7 @@ gtk_widget_queue_shallow_draw (GtkWidget *widget)
 /**
  * gtk_widget_size_allocate:
  * @widget: a #GtkWidget
- * @allocation: (inout): position and size to be allocated to @widget
+ * @allocation: position and size to be allocated to @widget
  *
  * This function is only used by #GtkContainer subclasses, to assign a size
  * and position to their child widgets.
@@ -5501,6 +5609,8 @@ gtk_cairo_set_event (cairo_t        *cr,
  * use "else if" statements to check which window should be drawn.
  *
  * Returns: %TRUE if @window should be drawn
+ *
+ * Since: 3.0
  **/
 gboolean
 gtk_cairo_should_draw_window (cairo_t *cr,
@@ -5575,6 +5685,8 @@ _gtk_widget_draw_internal (GtkWidget *widget,
  * <note><para>Special purpose widgets may contain special code for
  * rendering to the screen and might appear differently on screen
  * and when rendered using gtk_widget_draw().</para></note>
+ *
+ * Since: 3.0
  **/
 void
 gtk_widget_draw (GtkWidget *widget,
@@ -5726,6 +5838,8 @@ _gtk_widget_get_translation_to_window (GtkWidget      *widget,
  * preparing an expose event to be emitted with the #GtkWidget::draw
  * signal. It is intended to help porting multiwindow widgets from
  * GTK+ 2 to the rendering architecture of GTK+ 3.
+ *
+ * Since: 3.0
  **/
 void
 gtk_cairo_transform_to_window (cairo_t   *cr,
@@ -6855,7 +6969,8 @@ _gtk_widget_update_state_flags (GtkWidget     *widget,
     gtk_widget_set_sensitive (widget,
                               operation != STATE_CHANGE_UNSET);
 
-  flags &= ~(GTK_STATE_FLAG_INSENSITIVE);
+  if (operation != STATE_CHANGE_REPLACE)
+    flags &= ~(GTK_STATE_FLAG_INSENSITIVE);
 
   if (flags != 0 ||
       operation == STATE_CHANGE_REPLACE)
@@ -6961,6 +7076,9 @@ gtk_widget_get_state_flags (GtkWidget *widget)
   if (!gtk_widget_is_sensitive (widget))
     flags |= GTK_STATE_FLAG_INSENSITIVE;
 
+  if (gtk_widget_has_focus (widget))
+    flags |= GTK_STATE_FLAG_FOCUSED;
+
   return flags;
 }
 
@@ -7686,6 +7804,8 @@ gtk_widget_get_parent (GtkWidget *widget)
  * (finally #GtkWidget) would attach the style itself.
  *
  * Since: 2.20
+ *
+ * Deprecated: 3.0. This step is unnecessary with #GtkStyleContext.
  **/
 void
 gtk_widget_style_attach (GtkWidget *widget)
@@ -7724,19 +7844,21 @@ gtk_widget_has_rc_style (GtkWidget *widget)
 /**
  * gtk_widget_set_style:
  * @widget: a #GtkWidget
- * @style: (allow-none): a #GtkStyle, or %NULL to remove the effect of a previous
- *         gtk_widget_set_style() and go back to the default style
+ * @style: (allow-none): a #GtkStyle, or %NULL to remove the effect
+ *     of a previous call to gtk_widget_set_style() and go back to
+ *     the default style
+ *
+ * Sets the #GtkStyle for a widget (@widget->style).
  *
- * Sets the #GtkStyle for a widget (@widget->style). You probably don't
- * want to use this function; it interacts badly with themes, because
- * themes work by replacing the #GtkStyle. Instead, use
- * gtk_widget_modify_style().
+ * You probably don't want to use this function; it interacts
+ * badly with themes, because themes work by replacing the #GtkStyle.
+ * Instead, use gtk_widget_modify_style().
  *
  * Deprecated:3.0: Use #GtkStyleContext instead
- **/
+ */
 void
 gtk_widget_set_style (GtkWidget *widget,
-                     GtkStyle  *style)
+                      GtkStyle  *style)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 }
@@ -7745,13 +7867,14 @@ gtk_widget_set_style (GtkWidget *widget,
  * gtk_widget_ensure_style:
  * @widget: a #GtkWidget
  *
- * Ensures that @widget has a style (@widget->style). Not a very useful
- * function; most of the time, if you want the style, the widget is
- * realized, and realized widgets are guaranteed to have a style
- * already.
+ * Ensures that @widget has a style (@widget->style).
+ *
+ * Not a very useful function; most of the time, if you
+ * want the style, the widget is realized, and realized
+ * widgets are guaranteed to have a style already.
  *
  * Deprecated:3.0: Use #GtkStyleContext instead
- **/
+ */
 void
 gtk_widget_ensure_style (GtkWidget *widget)
 {
@@ -7788,7 +7911,7 @@ gtk_widget_ensure_style (GtkWidget *widget)
  * Return value: (transfer none): the widget's #GtkStyle
  *
  * Deprecated:3.0: Use #GtkStyleContext instead
- **/
+ */
 GtkStyle*
 gtk_widget_get_style (GtkWidget *widget)
 {
@@ -7802,13 +7925,14 @@ gtk_widget_get_style (GtkWidget *widget)
  * @widget: a #GtkWidget
  * @style: the #GtkRcStyle holding the style modifications
  *
- * Modifies style values on the widget. Modifications made using this
- * technique take precedence over style values set via an RC file,
- * however, they will be overriden if a style is explicitely set on
- * the widget using gtk_widget_set_style(). The #GtkRcStyle structure
- * is designed so each field can either be set or unset, so it is
- * possible, using this function, to modify some style values and
- * leave the others unchanged.
+ * Modifies style values on the widget.
+ *
+ * Modifications made using this technique take precedence over
+ * style values set via an RC file, however, they will be overridden
+ * if a style is explicitely set on the widget using gtk_widget_set_style().
+ * The #GtkRcStyle structure is designed so each field can either be
+ * set or unset, so it is possible, using this function, to modify some
+ * style values and leave the others unchanged.
  *
  * Note that modifications made with this function are not cumulative
  * with previous calls to gtk_widget_modify_style() or with such
@@ -7821,18 +7945,18 @@ gtk_widget_get_style (GtkWidget *widget)
  * effect with the initial modifications.
  *
  * Deprecated:3.0: Use #GtkStyleContext with a custom #GtkStyleProvider instead
- **/
+ */
 void
 gtk_widget_modify_style (GtkWidget      *widget,
-                        GtkRcStyle     *style)
+                         GtkRcStyle     *style)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (GTK_IS_RC_STYLE (style));
 
   g_object_set_qdata_full (G_OBJECT (widget),
-                          quark_rc_style,
-                          gtk_rc_style_copy (style),
-                          (GDestroyNotify) g_object_unref);
+                           quark_rc_style,
+                           gtk_rc_style_copy (style),
+                           (GDestroyNotify) g_object_unref);
 }
 
 /**
@@ -7858,7 +7982,7 @@ gtk_widget_modify_style (GtkWidget      *widget,
  *     g_object_ref().
  *
  * Deprecated:3.0: Use #GtkStyleContext with a custom #GtkStyleProvider instead
- **/
+ */
 GtkRcStyle *
 gtk_widget_get_modifier_style (GtkWidget *widget)
 {
@@ -7872,9 +7996,9 @@ gtk_widget_get_modifier_style (GtkWidget *widget)
     {
       rc_style = gtk_rc_style_new ();
       g_object_set_qdata_full (G_OBJECT (widget),
-                              quark_rc_style,
-                              rc_style,
-                              (GDestroyNotify) g_object_unref);
+                               quark_rc_style,
+                               rc_style,
+                               (GDestroyNotify) g_object_unref);
     }
 
   return rc_style;
@@ -7882,31 +8006,31 @@ gtk_widget_get_modifier_style (GtkWidget *widget)
 
 static void
 gtk_widget_modify_color_component (GtkWidget      *widget,
-                                  GtkRcFlags      component,
-                                  GtkStateType    state,
-                                  const GdkColor *color)
+                                   GtkRcFlags      component,
+                                   GtkStateType    state,
+                                   const GdkColor *color)
 {
   GtkRcStyle *rc_style = gtk_widget_get_modifier_style (widget);
 
   if (color)
     {
       switch (component)
-       {
-       case GTK_RC_FG:
-         rc_style->fg[state] = *color;
-         break;
-       case GTK_RC_BG:
-         rc_style->bg[state] = *color;
-         break;
-       case GTK_RC_TEXT:
-         rc_style->text[state] = *color;
-         break;
-       case GTK_RC_BASE:
-         rc_style->base[state] = *color;
-         break;
-       default:
-         g_assert_not_reached();
-       }
+        {
+        case GTK_RC_FG:
+          rc_style->fg[state] = *color;
+          break;
+        case GTK_RC_BG:
+          rc_style->bg[state] = *color;
+          break;
+        case GTK_RC_TEXT:
+          rc_style->text[state] = *color;
+          break;
+        case GTK_RC_BASE:
+          rc_style->base[state] = *color;
+          break;
+        default:
+          g_assert_not_reached();
+        }
 
       rc_style->color_flags[state] |= component;
     }
@@ -7961,39 +8085,35 @@ _gtk_widget_get_modifier_properties (GtkWidget *widget)
  * @widget: a #GtkWidget
  * @state: the state for which to set the color
  * @color: the color to assign, or %NULL to undo the effect
- *         of previous calls to gtk_widget_override_color()
+ *     of previous calls to gtk_widget_override_color()
  *
- * Sets the color to use for a widget. All other style values are left
- * untouched.
+ * Sets the color to use for a widget.
  *
- * <note>
- * <para>
- * This API is mostly meant as a quick way for applications to change a
- * widget appearance. If you are developing a widgets library and intend
- * this change to be themeable, it is better done by setting meaningful
- * CSS classes and regions in your widget/container implementation through
- * gtk_style_context_add_class() and gtk_style_context_add_region().
- * </para>
- * <para>
- * This way, your widget library can install a #GtkCssProvider with the
- * %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK priority in order to provide a
- * default styling for those widgets that need so, and this theming may
- * fully overridden by the user's theme.
- * </para>
- * </note>
+ * All other style values are left untouched.
  *
- * <note>
- * <para>
- * Note that for complex widgets this may bring in
- * undesired results (such as uniform background color everywhere),
- * in these cases it is better to fully style such widgets through a
+ * <note><para>
+ * This API is mostly meant as a quick way for applications to
+ * change a widget appearance. If you are developing a widgets
+ * library and intend this change to be themeable, it is better
+ * done by setting meaningful CSS classes and regions in your
+ * widget/container implementation through gtk_style_context_add_class()
+ * and gtk_style_context_add_region().
+ * </para><para>
+ * This way, your widget library can install a #GtkCssProvider
+ * with the %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK priority in order
+ * to provide a default styling for those widgets that need so, and
+ * this theming may fully overridden by the user's theme.
+ * </para></note>
+ * <note><para>
+ * Note that for complex widgets this may bring in undesired
+ * results (such as uniform background color everywhere), in
+ * these cases it is better to fully style such widgets through a
  * #GtkCssProvider with the %GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
  * priority.
- * </para>
- * </note>
+ * </para></note>
  *
  * Since: 3.0
- **/
+ */
 void
 gtk_widget_override_color (GtkWidget     *widget,
                            GtkStateFlags  state,
@@ -8012,13 +8132,15 @@ gtk_widget_override_color (GtkWidget     *widget,
  * @widget: a #GtkWidget
  * @state: the state for which to set the background color
  * @color: the color to assign, or %NULL to undo the effect
- *         of previous calls to gtk_widget_override_background_color()
+ *     of previous calls to gtk_widget_override_background_color()
+ *
+ * Sets the background color to use for a widget.
  *
- * Sets the background color to use for a widget. All other style values
- * are left untouched. See gtk_widget_override_color().
+ * All other style values are left untouched.
+ * See gtk_widget_override_color().
  *
  * Since: 3.0
- **/
+ */
 void
 gtk_widget_override_background_color (GtkWidget     *widget,
                                       GtkStateFlags  state,
@@ -8036,14 +8158,13 @@ gtk_widget_override_background_color (GtkWidget     *widget,
  * gtk_widget_override_font:
  * @widget: a #GtkWidget
  * @font_desc: the font descriptiong to use, or %NULL to undo
- *             the effect of previous calls to
- *             gtk_widget_override_font().
+ *     the effect of previous calls to gtk_widget_override_font()
  *
  * Sets the font to use for a widget. All other style values are
  * left untouched. See gtk_widget_override_color().
  *
  * Since: 3.0
- **/
+ */
 void
 gtk_widget_override_font (GtkWidget                  *widget,
                           const PangoFontDescription *font_desc)
@@ -8060,16 +8181,18 @@ gtk_widget_override_font (GtkWidget                  *widget,
  * gtk_widget_override_symbolic_color:
  * @widget: a #GtkWidget
  * @name: the name of the symbolic color to modify
- * @color: (allow-none): the color to assign (does not need to be allocated),
- *         or %NULL to undo the effect of previous calls to
- *         gtk_widget_override_symbolic_color().
+ * @color: (allow-none): the color to assign (does not need
+ *     to be allocated), or %NULL to undo the effect of previous
+ *     calls to gtk_widget_override_symbolic_color()
+ *
+ * Sets a symbolic color for a widget.
  *
- * Sets a symbolic color for a widget, All other style values are left
- * untouched. See gtk_widget_override_color() for overriding the foreground
+ * All other style values are left untouched.
+ * See gtk_widget_override_color() for overriding the foreground
  * or background color.
  *
  * Since: 3.0
- **/
+ */
 void
 gtk_widget_override_symbolic_color (GtkWidget     *widget,
                                     const gchar   *name,
@@ -8127,19 +8250,20 @@ gtk_widget_override_cursor (GtkWidget     *widget,
  * @widget: a #GtkWidget
  * @state: the state for which to set the foreground color
  * @color: (allow-none): the color to assign (does not need to be allocated),
- *         or %NULL to undo the effect of previous calls to
- *         of gtk_widget_modify_fg().
+ *     or %NULL to undo the effect of previous calls to
+ *     of gtk_widget_modify_fg().
  *
  * Sets the foreground color for a widget in a particular state.
- * All other style values are left untouched. See also
- * gtk_widget_modify_style().
+ *
+ * All other style values are left untouched.
+ * See also gtk_widget_modify_style().
  *
  * Deprecated:3.0: Use gtk_widget_override_color() instead
- **/
+ */
 void
 gtk_widget_modify_fg (GtkWidget      *widget,
-                     GtkStateType    state,
-                     const GdkColor *color)
+                      GtkStateType    state,
+                      const GdkColor *color)
 {
   GtkStateFlags flags;
   GdkRGBA rgba;
@@ -8173,38 +8297,43 @@ gtk_widget_modify_fg (GtkWidget      *widget,
       rgba.blue = color->blue / 65535.;
       rgba.alpha = 1;
 
-      gtk_widget_override_color (widget, state, &rgba);
+      gtk_widget_override_color (widget, flags, &rgba);
     }
   else
-    gtk_widget_override_color (widget, state, NULL);
+    gtk_widget_override_color (widget, flags, NULL);
 }
 
 /**
  * gtk_widget_modify_bg:
  * @widget: a #GtkWidget
  * @state: the state for which to set the background color
- * @color: (allow-none): the color to assign (does not need to be allocated),
- *         or %NULL to undo the effect of previous calls to
- *         of gtk_widget_modify_bg().
+ * @color: (allow-none): the color to assign (does not need
+ *     to be allocated), or %NULL to undo the effect of previous
+ *     calls to of gtk_widget_modify_bg().
  *
  * Sets the background color for a widget in a particular state.
- * All other style values are left untouched. See also
- * gtk_widget_modify_style().
  *
- * Note that "no window" widgets (which have the %GTK_NO_WINDOW flag set)
- * draw on their parent container's window and thus may not draw any
- * background themselves. This is the case for e.g. #GtkLabel. To modify
- * the background of such widgets, you have to set the background color
- * on their parent; if you want to set the background of a rectangular
- * area around a label, try placing the label in a #GtkEventBox widget
- * and setting the background color on that.
+ * All other style values are left untouched.
+ * See also gtk_widget_modify_style().
+ *
+ * <note><para>
+ * Note that "no window" widgets (which have the %GTK_NO_WINDOW
+ * flag set) draw on their parent container's window and thus may
+ * not draw any background themselves. This is the case for e.g.
+ * #GtkLabel.
+ * </para><para>
+ * To modify the background of such widgets, you have to set the
+ * background color on their parent; if you want to set the background
+ * of a rectangular area around a label, try placing the label in
+ * a #GtkEventBox widget and setting the background color on that.
+ * </para></note>
  *
  * Deprecated:3.0: Use gtk_widget_override_background_color() instead
- **/
+ */
 void
 gtk_widget_modify_bg (GtkWidget      *widget,
-                     GtkStateType    state,
-                     const GdkColor *color)
+                      GtkStateType    state,
+                      const GdkColor *color)
 {
   GtkStateFlags flags;
   GdkRGBA rgba;
@@ -8238,32 +8367,34 @@ gtk_widget_modify_bg (GtkWidget      *widget,
       rgba.blue = color->blue / 65535.;
       rgba.alpha = 1;
 
-      gtk_widget_override_background_color (widget, state, &rgba);
+      gtk_widget_override_background_color (widget, flags, &rgba);
     }
   else
-    gtk_widget_override_background_color (widget, state, NULL);
+    gtk_widget_override_background_color (widget, flags, NULL);
 }
 
 /**
  * gtk_widget_modify_text:
  * @widget: a #GtkWidget
  * @state: the state for which to set the text color
- * @color: (allow-none): the color to assign (does not need to be allocated),
- *         or %NULL to undo the effect of previous calls to
- *         of gtk_widget_modify_text().
+ * @color: (allow-none): the color to assign (does not need to
+ *     be allocated), or %NULL to undo the effect of previous
+ *     calls to of gtk_widget_modify_text().
  *
- * Sets the text color for a widget in a particular state.  All other
- * style values are left untouched. The text color is the foreground
- * color used along with the base color (see gtk_widget_modify_base())
- * for widgets such as #GtkEntry and #GtkTextView. See also
- * gtk_widget_modify_style().
+ * Sets the text color for a widget in a particular state.
+ *
+ * All other style values are left untouched.
+ * The text color is the foreground color used along with the
+ * base color (see gtk_widget_modify_base()) for widgets such
+ * as #GtkEntry and #GtkTextView.
+ * See also gtk_widget_modify_style().
  *
  * Deprecated:3.0: Use gtk_widget_override_color() instead
- **/
+ */
 void
 gtk_widget_modify_text (GtkWidget      *widget,
-                       GtkStateType    state,
-                       const GdkColor *color)
+                        GtkStateType    state,
+                        const GdkColor *color)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE);
@@ -8275,9 +8406,9 @@ gtk_widget_modify_text (GtkWidget      *widget,
  * gtk_widget_modify_base:
  * @widget: a #GtkWidget
  * @state: the state for which to set the base color
- * @color: (allow-none): the color to assign (does not need to be allocated),
- *         or %NULL to undo the effect of previous calls to
- *         of gtk_widget_modify_base().
+ * @color: (allow-none): the color to assign (does not need to
+ *     be allocated), or %NULL to undo the effect of previous
+ *     calls to of gtk_widget_modify_base().
  *
  * Sets the base color for a widget in a particular state.
  * All other style values are left untouched. The base color
@@ -8285,20 +8416,24 @@ gtk_widget_modify_text (GtkWidget      *widget,
  * (see gtk_widget_modify_text()) for widgets such as #GtkEntry
  * and #GtkTextView. See also gtk_widget_modify_style().
  *
- * Note that "no window" widgets (which have the %GTK_NO_WINDOW flag set)
- * draw on their parent container's window and thus may not draw any
- * background themselves. This is the case for e.g. #GtkLabel. To modify
- * the background of such widgets, you have to set the base color on their
- * parent; if you want to set the background of a rectangular area around
- * a label, try placing the label in a #GtkEventBox widget and setting
- * the base color on that.
+ * <note><para>
+ * Note that "no window" widgets (which have the %GTK_NO_WINDOW
+ * flag set) draw on their parent container's window and thus may
+ * not draw any background themselves. This is the case for e.g.
+ * #GtkLabel.
+ * </para><para>
+ * To modify the background of such widgets, you have to set the
+ * base color on their parent; if you want to set the background
+ * of a rectangular area around a label, try placing the label in
+ * a #GtkEventBox widget and setting the base color on that.
+ * </para></note>
  *
  * Deprecated:3.0: Use gtk_widget_override_background_color() instead
- **/
+ */
 void
 gtk_widget_modify_base (GtkWidget      *widget,
-                       GtkStateType    state,
-                       const GdkColor *color)
+                        GtkStateType    state,
+                        const GdkColor *color)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE);
@@ -8310,25 +8445,27 @@ gtk_widget_modify_base (GtkWidget      *widget,
  * gtk_widget_modify_cursor:
  * @widget: a #GtkWidget
  * @primary: the color to use for primary cursor (does not need to be
- *           allocated), or %NULL to undo the effect of previous calls to
- *           of gtk_widget_modify_cursor().
+ *     allocated), or %NULL to undo the effect of previous calls to
+ *     of gtk_widget_modify_cursor().
  * @secondary: the color to use for secondary cursor (does not need to be
- *             allocated), or %NULL to undo the effect of previous calls to
- *             of gtk_widget_modify_cursor().
+ *     allocated), or %NULL to undo the effect of previous calls to
+ *     of gtk_widget_modify_cursor().
  *
  * Sets the cursor color to use in a widget, overriding the
  * #GtkWidget:cursor-color and #GtkWidget:secondary-cursor-color
- * style properties. All other style values are left untouched.
+ * style properties.
+ *
+ * All other style values are left untouched.
  * See also gtk_widget_modify_style().
  *
  * Since: 2.12
  *
  * Deprecated: 3.0. Use gtk_widget_override_cursor() instead.
- **/
+ */
 void
 gtk_widget_modify_cursor (GtkWidget      *widget,
-                         const GdkColor *primary,
-                         const GdkColor *secondary)
+                          const GdkColor *primary,
+                          const GdkColor *secondary)
 {
   GdkRGBA primary_rgba, secondary_rgba;
 
@@ -8350,17 +8487,19 @@ gtk_widget_modify_cursor (GtkWidget      *widget,
 /**
  * gtk_widget_modify_font:
  * @widget: a #GtkWidget
- * @font_desc: (allow-none): the font description to use, or %NULL to undo
- *   the effect of previous calls to gtk_widget_modify_font().
+ * @font_desc: (allow-none): the font description to use, or %NULL
+ *     to undo the effect of previous calls to gtk_widget_modify_font()
  *
- * Sets the font to use for a widget.  All other style values are left
- * untouched. See also gtk_widget_modify_style().
+ * Sets the font to use for a widget.
+ *
+ * All other style values are left untouched.
+ * See also gtk_widget_modify_style().
  *
  * Deprecated:3.0: Use gtk_widget_override_font() instead
- **/
+ */
 void
 gtk_widget_modify_font (GtkWidget            *widget,
-                       PangoFontDescription *font_desc)
+                        PangoFontDescription *font_desc)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
@@ -9749,6 +9888,53 @@ gtk_widget_set_device_events (GtkWidget    *widget,
   g_hash_table_insert (device_events, device, GUINT_TO_POINTER (events));
 }
 
+/**
+ * gtk_widget_enable_device:
+ * @widget: a #GtkWidget
+ * @device: a #GdkDevice
+ *
+ * Enables a #GdkDevice to interact with @widget and
+ * all its children, it does so by descending through
+ * the #GdkWindow hierarchy and enabling the same mask
+ * that is has for core events (i.e. the one that
+ * gdk_window_get_events() returns).
+ *
+ * Since: 3.0
+ **/
+void
+gtk_widget_set_device_enabled (GtkWidget *widget,
+                               GdkDevice *device,
+                               gboolean   enabled)
+{
+  GList *enabled_devices;
+
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (GDK_IS_DEVICE (device));
+
+  enabled_devices = g_object_get_qdata (G_OBJECT (widget), quark_enabled_devices);
+  enabled_devices = g_list_append (enabled_devices, device);
+
+  g_object_set_qdata_full (G_OBJECT (widget), quark_enabled_devices,
+                           enabled_devices, (GDestroyNotify) g_list_free);;
+
+  if (gtk_widget_get_realized (widget))
+    gtk_widget_set_device_enabled_internal (widget, device, TRUE, enabled);
+}
+
+gboolean
+gtk_widget_get_device_enabled (GtkWidget *widget,
+                               GdkDevice *device)
+{
+  GList *enabled_devices;
+
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+  g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
+
+  enabled_devices = g_object_get_qdata (G_OBJECT (widget), quark_enabled_devices);
+
+  return g_list_find (enabled_devices, device) != NULL;
+}
+
 static void
 gtk_widget_add_events_internal_list (GtkWidget *widget,
                                      GdkDevice *device,
@@ -9818,7 +10004,10 @@ gtk_widget_add_events (GtkWidget *widget,
                       GINT_TO_POINTER (old_events | events));
 
   if (gtk_widget_get_realized (widget))
-    gtk_widget_add_events_internal (widget, NULL, events);
+    {
+      gtk_widget_add_events_internal (widget, NULL, events);
+      gtk_widget_update_devices_mask (widget, FALSE);
+    }
 
   g_object_notify (G_OBJECT (widget), "events");
 }
@@ -10998,8 +11187,8 @@ _gtk_widget_synthesize_crossing (GtkWidget       *from,
 }
 
 static void
-gtk_widget_propagate_state (GtkWidget           *widget,
-                           GtkStateData        *data)
+gtk_widget_propagate_state (GtkWidget    *widget,
+                            GtkStateData *data)
 {
   GtkWidgetPrivate *priv = widget->priv;
   GtkStateFlags new_flags, old_flags = priv->state_flags;
@@ -11032,7 +11221,7 @@ gtk_widget_propagate_state (GtkWidget           *widget,
       window = gtk_widget_get_toplevel (widget);
 
       if (window && gtk_widget_is_toplevel (window))
-       gtk_window_set_focus (GTK_WINDOW (window), NULL);
+        gtk_window_set_focus (GTK_WINDOW (window), NULL);
     }
 
   new_flags = gtk_widget_get_state_flags (widget);
@@ -11042,7 +11231,7 @@ gtk_widget_propagate_state (GtkWidget           *widget,
       g_object_ref (widget);
 
       if (!gtk_widget_is_sensitive (widget) && gtk_widget_has_grab (widget))
-       gtk_grab_remove (widget);
+        gtk_grab_remove (widget);
 
       g_signal_emit (widget, widget_signals[STATE_CHANGED], 0, old_state);
       g_signal_emit (widget, widget_signals[STATE_FLAGS_CHANGED], 0, old_flags);
@@ -11088,7 +11277,7 @@ gtk_widget_propagate_state (GtkWidget           *widget,
           data->parent_sensitive = gtk_widget_is_sensitive (widget);
 
           /* Do not propagate insensitive state further */
-          data->flags &= ~(GTK_STATE_FLAG_INSENSITIVE);
+          data->flags &= ~(GTK_STATE_FLAG_INSENSITIVE | GTK_STATE_FLAG_FOCUSED);
 
           if (data->use_forall)
             gtk_container_forall (GTK_CONTAINER (widget),
@@ -11105,10 +11294,8 @@ gtk_widget_propagate_state (GtkWidget           *widget,
           gtk_widget_get_mapped (widget))
         {
           gint diff, flag = 1;
-          GdkWindow *window;
 
           diff = old_flags ^ new_flags;
-          window = gtk_widget_get_window (widget);
 
           while (diff != 0)
             {
@@ -11293,7 +11480,7 @@ gtk_widget_input_shape_combine_region (GtkWidget *widget,
  */
 
 /**
- * gtk_widget_class_install_style_property_parser:
+ * gtk_widget_class_install_style_property_parser: (skip)
  * @klass: a #GtkWidgetClass
  * @pspec: the #GParamSpec for the style property
  * @parser: the parser for the style property
@@ -11349,8 +11536,8 @@ gtk_widget_class_install_style_property (GtkWidgetClass *klass,
  * gtk_widget_class_find_style_property:
  * @klass: a #GtkWidgetClass
  * @property_name: the name of the style property to find
- * @returns: (allow-none): the #GParamSpec of the style property or %NULL if @class has no
- *   style property with that name.
+ * @returns: (transfer none): the #GParamSpec of the style property or
+ *   %NULL if @class has no style property with that name.
  *
  * Finds a style property of a widget class by name.
  *
@@ -11372,8 +11559,9 @@ gtk_widget_class_find_style_property (GtkWidgetClass *klass,
  * gtk_widget_class_list_style_properties:
  * @klass: a #GtkWidgetClass
  * @n_properties: location to return the number of style properties found
- * @returns: an newly allocated array of #GParamSpec*. The array must
- *       be freed with g_free().
+ * @returns: (array length=n_properties) (transfer container): an
+ *       newly allocated array of #GParamSpec*. The array must be
+ *       freed with g_free().
  *
  * Returns all style properties of a widget class.
  *
@@ -13739,6 +13927,11 @@ _gtk_widget_set_has_focus (GtkWidget *widget,
                            gboolean   has_focus)
 {
   widget->priv->has_focus = has_focus;
+
+  if (has_focus)
+    gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_FOCUSED, FALSE);
+  else
+    gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_FOCUSED);
 }
 
 /**
@@ -13956,8 +14149,22 @@ gtk_widget_get_path (GtkWidget *widget)
         gtk_widget_path_iter_set_name (widget->priv->path, pos, widget->priv->name);
 
       if (widget->priv->context)
-        gtk_style_context_set_path (widget->priv->context,
-                                    widget->priv->path);
+        {
+          GList *classes, *l;
+
+          /* Also add any persistent classes in
+           * the style context the widget path
+           */
+          classes = gtk_style_context_list_classes (widget->priv->context);
+
+          for (l = classes; l; l = l->next)
+            gtk_widget_path_iter_add_class (widget->priv->path, pos, l->data);
+
+          gtk_style_context_set_path (widget->priv->context,
+                                      widget->priv->path);
+
+          g_list_free (classes);
+        }
     }
 
   return widget->priv->path;