diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 5941cc3ef7..9b624676a0 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -5086,6 +5086,13 @@ gtk_widget_unmap
gtk_widget_unparent
gtk_widget_unrealize
gtk_widget_get_window
+gtk_widget_set_has_window
+gtk_widget_get_has_window
+gtk_widget_set_can_default
+gtk_widget_get_can_default
+gtk_widget_has_default
+gtk_widget_set_can_focus
+gtk_widget_get_can_focus
#endif
#endif
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 44fd9cda0d..4f664cb8d9 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5066,8 +5066,10 @@ _gtk_widget_grab_notify (GtkWidget *widget,
*
* Causes @widget to have the keyboard focus for the #GtkWindow it's
* inside. @widget must be a focusable widget, such as a #GtkEntry;
- * something like #GtkFrame won't work. (More precisely, it must have the
- * %GTK_CAN_FOCUS flag set.)
+ * something like #GtkFrame won't work.
+ *
+ * More precisely, it must have the %GTK_CAN_FOCUS flag set. Use
+ * gtk_widget_set_can_focus() to modify that flag.
**/
void
gtk_widget_grab_focus (GtkWidget *widget)
@@ -5258,6 +5260,54 @@ gtk_widget_real_keynav_failed (GtkWidget *widget,
return TRUE;
}
+/**
+ * gtk_widget_set_can_focus:
+ * @widget: a #GtkWidget
+ * @can_focus: whether or not @widget can own the input focus.
+ *
+ * Specifies whether @widget can own the input focus. See
+ * gtk_widget_grab_focus() for actually setting the input focus on a
+ * widget.
+ *
+ * Since: 2.18
+ **/
+void
+gtk_widget_set_can_focus (GtkWidget *widget,
+ gboolean can_focus)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ if (can_focus != GTK_WIDGET_CAN_FOCUS (widget))
+ {
+ if (can_focus)
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+ else
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+
+ gtk_widget_queue_resize (widget);
+ g_object_notify (G_OBJECT (widget), "can-focus");
+ }
+}
+
+/**
+ * gtk_widget_get_can_focus:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether @widget can own the input focus. See
+ * gtk_widget_set_can_focus().
+ *
+ * Return value: %TRUE if @widget can own the input focus, %FALSE otherwise
+ *
+ * Since: 2.18
+ **/
+gboolean
+gtk_widget_get_can_focus (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return GTK_WIDGET_CAN_FOCUS (widget);
+}
+
/**
* gtk_widget_has_focus:
* @widget: a #GtkWidget
@@ -5304,14 +5354,82 @@ gtk_widget_is_focus (GtkWidget *widget)
return FALSE;
}
+/**
+ * gtk_widget_set_can_default:
+ * @widget: a #GtkWidget
+ * @can_default: whether or not @widget can be a default widget.
+ *
+ * Specifies whether @widget can be a default widget. See
+ * gtk_widget_grab_default() for details about the meaning of
+ * "default".
+ *
+ * Since: 2.18
+ **/
+void
+gtk_widget_set_can_default (GtkWidget *widget,
+ gboolean can_default)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ if (can_default != GTK_WIDGET_CAN_DEFAULT (widget))
+ {
+ if (can_default)
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_DEFAULT);
+ else
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_DEFAULT);
+
+ gtk_widget_queue_resize (widget);
+ g_object_notify (G_OBJECT (widget), "can-default");
+ }
+}
+
+/**
+ * gtk_widget_get_can_default:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether @widget can be a default widget. See
+ * gtk_widget_set_can_default().
+ *
+ * Return value: %TRUE if @widget can be a default widget, %FALSE otherwise
+ *
+ * Since: 2.18
+ **/
+gboolean
+gtk_widget_get_can_default (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return GTK_WIDGET_CAN_DEFAULT (widget);
+}
+
+/**
+ * gtk_widget_get_has_default:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether @widget is the current default widget within its
+ * toplevel. See gtk_widget_set_can_default().
+ *
+ * Return value: %TRUE if @widget is the current default widget within
+ * its toplevel, %FALSE otherwise
+ *
+ * Since: 2.18
+ **/
+gboolean
+gtk_widget_has_default (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return GTK_WIDGET_HAS_DEFAULT (widget);
+}
+
/**
* gtk_widget_grab_default:
* @widget: a #GtkWidget
*
* Causes @widget to become the default widget. @widget must have the
* %GTK_CAN_DEFAULT flag set; typically you have to set this flag
- * yourself by calling GTK_WIDGET_SET_FLAGS (@widget,
- * GTK_CAN_DEFAULT). The default widget is activated when
+ * yourself by calling gtk_widget_set_can_default (@widget,
+ * %TRUE). The default widget is activated when
* the user presses Enter in a window. Default widgets must be
* activatable, that is, gtk_widget_activate() should affect them.
**/
@@ -5437,6 +5555,55 @@ gtk_widget_get_state (GtkWidget *widget)
return widget->state;
}
+/**
+ * gtk_widget_set_has_window:
+ * @widget: a #GtkWidget
+ * @has_window: whether or not @widget has a window.
+ *
+ * Specifies whether @widget has a #GdkWindow of its own. Note that
+ * all realized widgets have a non-%NULL "window" pointer
+ * (gtk_widget_get_window() never returns a %NULL window when a widget
+ * is realized), but for many of them it's actually the #GdkWindow of
+ * one of its parent widgets. Widgets that create a %window for
+ * themselves in GtkWidget::realize() however must announce this by
+ * calling this function with @has_window = %TRUE.
+ *
+ * This function should only be called by widget implementations,
+ * and they should call it in their init() function.
+ *
+ * Since: 2.18
+ **/
+void
+gtk_widget_set_has_window (GtkWidget *widget,
+ gboolean has_window)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ if (has_window)
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_NO_WINDOW);
+ else
+ GTK_WIDGET_SET_FLAGS (widget, GTK_NO_WINDOW);
+}
+
+/**
+ * gtk_widget_get_has_window:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether @widget has a #GdkWindow of its own. See
+ * gtk_widget_set_has_window().
+ *
+ * Return value: %TRUE if @widget has a window, %FALSE otherwise
+ *
+ * Since: 2.18
+ **/
+gboolean
+gtk_widget_get_has_window (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return !GTK_WIDGET_NO_WINDOW (widget);
+}
+
/**
* gtk_widget_set_app_paintable:
* @widget: a #GtkWidget
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 36869f97c6..decd6d566f 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -548,10 +548,18 @@ void gtk_widget_child_notify (GtkWidget *widget,
const gchar *child_property);
void gtk_widget_thaw_child_notify (GtkWidget *widget);
+void gtk_widget_set_can_focus (GtkWidget *widget,
+ gboolean can_focus);
+gboolean gtk_widget_get_can_focus (GtkWidget *widget);
gboolean gtk_widget_has_focus (GtkWidget *widget);
gboolean gtk_widget_is_focus (GtkWidget *widget);
-void gtk_widget_grab_focus (GtkWidget *widget);
-void gtk_widget_grab_default (GtkWidget *widget);
+void gtk_widget_grab_focus (GtkWidget *widget);
+
+void gtk_widget_set_can_default (GtkWidget *widget,
+ gboolean can_default);
+gboolean gtk_widget_get_can_default (GtkWidget *widget);
+gboolean gtk_widget_has_default (GtkWidget *widget);
+void gtk_widget_grab_default (GtkWidget *widget);
void gtk_widget_set_name (GtkWidget *widget,
const gchar *name);
@@ -566,6 +574,10 @@ void gtk_widget_set_sensitive (GtkWidget *widget,
gboolean gtk_widget_get_sensitive (GtkWidget *widget);
gboolean gtk_widget_is_sensitive (GtkWidget *widget);
+void gtk_widget_set_has_window (GtkWidget *widget,
+ gboolean has_window);
+gboolean gtk_widget_get_has_window (GtkWidget *widget);
+
void gtk_widget_set_app_paintable (GtkWidget *widget,
gboolean app_paintable);
void gtk_widget_set_double_buffered (GtkWidget *widget,