#include "gtkbuilderprivate.h"
#include "gtkalias.h"
+/**
+ * SECTION:gtkwidget
+ * @Short_description: Base class for all widgets
+ * @Title: GtkWidget
+ *
+ * GtkWidget is the base class all widgets in GTK+ derive from. It manages the
+ * widget lifecycle, states and style.
+ * <refsect2 id="style-properties">
+ * <para>
+ * <structname>GtkWidget</structname> introduces <firstterm>style
+ * properties</firstterm> - these are basically object properties that are stored
+ * not on the object, but in the style object associated to the widget. Style
+ * properties are set in <link linkend="gtk-Resource-Files">resource files</link>.
+ * This mechanism is used for configuring such things as the location of the
+ * scrollbar arrows through the theme, giving theme authors more control over the
+ * look of applications without the need to write a theme engine in C.
+ * </para>
+ * <para>
+ * Use gtk_widget_class_install_style_property() to install style properties for
+ * a widget class, gtk_widget_class_find_style_property() or
+ * gtk_widget_class_list_style_properties() to get information about existing
+ * style properties and gtk_widget_style_get_property(), gtk_widget_style_get() or
+ * gtk_widget_style_get_valist() to obtain the value of a style property.
+ * </para>
+ * </refsect2>
+ * <refsect2 id="GtkWidget-BUILDER-UI">
+ * <title>GtkWidget as GtkBuildable</title>
+ * <para>
+ * The GtkWidget implementation of the GtkBuildable interface supports a
+ * custom <accelerator> element, which has attributes named key,
+ * modifiers and signal and allows to specify accelerators.
+ * </para>
+ * <example>
+ * <title>A UI definition fragment specifying an accelerator</title>
+ * <programlisting><![CDATA[
+ * <object class="GtkButton">
+ * <accelerator key="q" modifiers="GDK_CONTROL_MASK" signal="clicked"/>
+ * </object>
+ * ]]></programlisting>
+ * </example>
+ * <para>
+ * In addition to accelerators, <structname>GtkWidget</structname> also support a
+ * custom <accessible> element, which supports actions and relations.
+ * Properties on the accessible implementation of an object can be set by accessing the
+ * internal child "accessible" of a <structname>GtkWidget</structname>.
+ * </para>
+ * <example>
+ * <title>A UI definition fragment specifying an accessible</title>
+ * <programlisting><![CDATA[
+ * <object class="GtkButton" id="label1"/>
+ * <property name="label">I am a Label for a Button</property>
+ * </object>
+ * <object class="GtkButton" id="button1">
+ * <accessibility>
+ * <action action_name="click" translatable="yes">Click the button.</action>
+ * <relation target="label1" type="labelled-by"/>
+ * </accessibility>
+ * <child internal-child="accessible">
+ * <object class="AtkObject" id="a11y-button1">
+ * <property name="AtkObject::name">Clickable Button</property>
+ * </object>
+ * </child>
+ * </object>
+ * ]]></programlisting>
+ * </example>
+ * </refsect2>
+ */
+
#define WIDGET_CLASS(w) GTK_WIDGET_GET_CLASS (w)
#define INIT_PATH_SIZE (512)
PROP_HAS_TOOLTIP,
PROP_TOOLTIP_MARKUP,
PROP_TOOLTIP_TEXT,
- PROP_WINDOW
+ PROP_WINDOW,
+ PROP_DOUBLE_BUFFERED
};
typedef struct _GtkStateData GtkStateData;
static void gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
GtkBuilder *builder);
+static void gtk_widget_queue_tooltip_query (GtkWidget *widget);
static void gtk_widget_set_usize_internal (GtkWidget *widget,
gint width,
GDK_TYPE_WINDOW,
GTK_PARAM_READABLE));
+ /**
+ * GtkWidget:double-buffered
+ *
+ * Whether or not the widget is double buffered.
+ *
+ * Since: 2.18
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_DOUBLE_BUFFERED,
+ g_param_spec_boolean ("double-buffered",
+ P_("Double Buffered"),
+ P_("Whether or not the widget is double buffered"),
+ TRUE,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkWidget::show:
+ * @widget: the object which received the signal.
+ */
widget_signals[SHOW] =
g_signal_new (I_("show"),
G_TYPE_FROM_CLASS (gobject_class),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ /**
+ * GtkWidget::hide:
+ * @widget: the object which received the signal.
+ */
widget_signals[HIDE] =
g_signal_new (I_("hide"),
G_TYPE_FROM_CLASS (gobject_class),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ /**
+ * GtkWidget::map:
+ * @widget: the object which received the signal.
+ */
widget_signals[MAP] =
g_signal_new (I_("map"),
G_TYPE_FROM_CLASS (gobject_class),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ /**
+ * GtkWidget::unmap:
+ * @widget: the object which received the signal.
+ */
widget_signals[UNMAP] =
g_signal_new (I_("unmap"),
G_TYPE_FROM_CLASS (gobject_class),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ /**
+ * GtkWidget::realize:
+ * @widget: the object which received the signal.
+ */
widget_signals[REALIZE] =
g_signal_new (I_("realize"),
G_TYPE_FROM_CLASS (gobject_class),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ /**
+ * GtkWidget::unrealize:
+ * @widget: the object which received the signal.
+ */
widget_signals[UNREALIZE] =
g_signal_new (I_("unrealize"),
G_TYPE_FROM_CLASS (gobject_class),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ /**
+ * GtkWidget::size-request:
+ * @widget: the object which received the signal.
+ * @requisition:
+ */
widget_signals[SIZE_REQUEST] =
g_signal_new (I_("size-request"),
G_TYPE_FROM_CLASS (gobject_class),
_gtk_marshal_VOID__BOXED,
G_TYPE_NONE, 1,
GTK_TYPE_REQUISITION | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+ /**
+ * GtkWidget::size-allocate:
+ * @widget: the object which received the signal.
+ * @allocation:
+ */
widget_signals[SIZE_ALLOCATE] =
g_signal_new (I_("size-allocate"),
G_TYPE_FROM_CLASS (gobject_class),
G_TYPE_NONE, 1,
GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
+ /**
+ * GtkWidget::state-changed:
+ * @widget: the object which received the signal.
+ * @state: the previous state
+ *
+ * The ::state-changed signal is emitted when the widget state changes.
+ * See gtk_widget_get_state().
+ */
widget_signals[STATE_CHANGED] =
g_signal_new (I_("state-changed"),
G_TYPE_FROM_CLASS (gobject_class),
/**
* GtkWidget::parent-set:
* @widget: the object on which the signal is emitted
- * @old_parent: the previous parent, or %NULL if the widget
+ * @old_parent: (allow-none): the previous parent, or %NULL if the widget
* just got its initial parent.
*
* The ::parent-set signal is emitted when a new parent
/**
* GtkWidget::hierarchy-changed:
* @widget: the object on which the signal is emitted
- * @previous_toplevel: the previous toplevel ancestor, or %NULL
+ * @previous_toplevel: (allow-none): the previous toplevel ancestor, or %NULL
* if the widget was previously unanchored
*
* The ::hierarchy-changed signal is emitted when the
/**
* GtkWidget::style-set:
* @widget: the object on which the signal is emitted
- * @previous_style: the previous style, or %NULL if the widget
+ * @previous_style: (allow-none): the previous style, or %NULL if the widget
* just got its initial style
*
* The ::style-set signal is emitted when a new style has been set
g_cclosure_marshal_VOID__PARAM,
G_TYPE_NONE, 1,
G_TYPE_PARAM);
+
+ /**
+ * GtkWidget::mnemonic-activate:
+ * @widget: the object which received the signal.
+ * @arg1:
+ */
widget_signals[MNEMONIC_ACTIVATE] =
g_signal_new (I_("mnemonic-activate"),
G_TYPE_FROM_CLASS (gobject_class),
_gtk_marshal_BOOLEAN__BOOLEAN,
G_TYPE_BOOLEAN, 1,
G_TYPE_BOOLEAN);
+
+ /**
+ * GtkWidget::grab-focus:
+ * @widget: the object which received the signal.
+ */
widget_signals[GRAB_FOCUS] =
g_signal_new (I_("grab-focus"),
G_TYPE_FROM_CLASS (gobject_class),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ /**
+ * GtkWidget::focus:
+ * @widget: the object which received the signal.
+ * @direction:
+ *
+ * Returns: %TRUE to stop other handlers from being invoked for the event. %FALSE to propagate the event further.
+ */
widget_signals[FOCUS] =
g_signal_new (I_("focus"),
G_TYPE_FROM_CLASS (object_class),
_gtk_marshal_BOOLEAN__ENUM,
G_TYPE_BOOLEAN, 1,
GTK_TYPE_DIRECTION_TYPE);
+
+ /**
+ * GtkWidget::move-focus:
+ * @widget: the object which received the signal.
+ * @direction:
+ */
widget_signals[MOVE_FOCUS] =
g_signal_new_class_handler (I_("move-focus"),
G_TYPE_FROM_CLASS (object_class),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+ /**
+ * GtkWidget::selection-notify-event:
+ * @widget: the object which received the signal.
+ * @event:
+ *
+ * Returns: %TRUE to stop other handlers from being invoked for the event. %FALSE to propagate the event further.
+ */
widget_signals[SELECTION_NOTIFY_EVENT] =
g_signal_new (I_("selection-notify-event"),
G_TYPE_FROM_CLASS (gobject_class),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+ /**
+ * GtkWidget::selection-received:
+ * @widget: the object which received the signal.
+ * @data:
+ * @time:
+ */
widget_signals[SELECTION_RECEIVED] =
g_signal_new (I_("selection-received"),
G_TYPE_FROM_CLASS (gobject_class),
GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
G_TYPE_UINT);
+ /**
+ * GtkWidget::selection-get:
+ * @widget: the object which received the signal.
+ * @data:
+ * @info:
+ * @time:
+ */
widget_signals[SELECTION_GET] =
g_signal_new (I_("selection-get"),
G_TYPE_FROM_CLASS (gobject_class),
G_TYPE_INT,
G_TYPE_UINT);
- /**
+ /**
* GtkWidget::drag-data-get:
* @widget: the object which received the signal
* @drag_context: the drag context
_gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__VOID,
G_TYPE_BOOLEAN, 0);
+
+ /**
+ * GtkWidget::show-help:
+ * @widget: the object which received the signal.
+ * @help_type:
+ */
widget_signals[SHOW_HELP] =
g_signal_new (I_("show-help"),
G_TYPE_FROM_CLASS (gobject_class),
_gtk_marshal_BOOLEAN__ENUM,
G_TYPE_BOOLEAN, 1,
GTK_TYPE_WIDGET_HELP_TYPE);
+
+ /**
+ * GtkWidget::accel-closures-changed:
+ * @widget: the object which received the signal.
+ */
widget_signals[ACCEL_CLOSURES_CHANGED] =
g_signal_new (I_("accel-closures-changed"),
G_TYPE_FROM_CLASS (gobject_class),
/**
* GtkWidget::screen-changed:
* @widget: the object on which the signal is emitted
- * @previous_screen: the previous screen, or %NULL if the
+ * @previous_screen: (allow-none): the previous screen, or %NULL if the
* widget was not associated with a screen before
*
* The ::screen-changed signal gets emitted when the
_gtk_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GDK_TYPE_SCREEN);
+
/**
* GtkWidget::can-activate-accel:
* @widget: the object which received the signal
switch (prop_id)
{
gboolean tmp;
- guint32 saved_flags;
gchar *tooltip_markup;
const gchar *tooltip_text;
GtkWindow *tooltip_window;
-
+
case PROP_NAME:
gtk_widget_set_name (widget, g_value_get_string (value));
break;
gtk_widget_set_usize_internal (widget, -2, g_value_get_int (value));
break;
case PROP_VISIBLE:
- if (g_value_get_boolean (value))
- gtk_widget_show (widget);
- else
- gtk_widget_hide (widget);
+ gtk_widget_set_visible (widget, g_value_get_boolean (value));
break;
case PROP_SENSITIVE:
gtk_widget_set_sensitive (widget, g_value_get_boolean (value));
gtk_widget_set_app_paintable (widget, g_value_get_boolean (value));
break;
case PROP_CAN_FOCUS:
- saved_flags = GTK_WIDGET_FLAGS (widget);
- if (g_value_get_boolean (value))
- GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
- else
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
- if (saved_flags != GTK_WIDGET_FLAGS (widget))
- gtk_widget_queue_resize (widget);
+ gtk_widget_set_can_focus (widget, g_value_get_boolean (value));
break;
case PROP_HAS_FOCUS:
if (g_value_get_boolean (value))
gtk_widget_grab_focus (widget);
break;
case PROP_CAN_DEFAULT:
- saved_flags = GTK_WIDGET_FLAGS (widget);
- if (g_value_get_boolean (value))
- GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_DEFAULT);
- else
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_DEFAULT);
- if (saved_flags != GTK_WIDGET_FLAGS (widget))
- gtk_widget_queue_resize (widget);
+ gtk_widget_set_can_default (widget, g_value_get_boolean (value));
break;
case PROP_HAS_DEFAULT:
if (g_value_get_boolean (value))
gtk_widget_grab_default (widget);
break;
case PROP_RECEIVES_DEFAULT:
- if (g_value_get_boolean (value))
- GTK_WIDGET_SET_FLAGS (widget, GTK_RECEIVES_DEFAULT);
- else
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_RECEIVES_DEFAULT);
+ gtk_widget_set_receives_default (widget, g_value_get_boolean (value));
break;
case PROP_STYLE:
gtk_widget_set_style (widget, g_value_get_object (value));
break;
case PROP_EVENTS:
- if (!GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_NO_WINDOW (widget))
+ if (!GTK_WIDGET_REALIZED (widget) && gtk_widget_get_has_window (widget))
gtk_widget_set_events (widget, g_value_get_flags (value));
break;
case PROP_EXTENSION_EVENTS:
* because an empty string would be useless for a tooltip:
*/
if (tooltip_markup && (strlen (tooltip_markup) == 0))
- {
- g_free (tooltip_markup);
- tooltip_markup = NULL;
- }
+ {
+ g_free (tooltip_markup);
+ tooltip_markup = NULL;
+ }
g_object_set_qdata_full (object, quark_tooltip_markup,
tooltip_markup, g_free);
tmp = (tooltip_window != NULL || tooltip_markup != NULL);
gtk_widget_real_set_has_tooltip (widget, tmp, FALSE);
- gtk_widget_trigger_tooltip_query (widget);
+ if (gtk_widget_get_visible (widget))
+ gtk_widget_queue_tooltip_query (widget);
break;
case PROP_TOOLTIP_TEXT:
tooltip_window = g_object_get_qdata (object, quark_tooltip_window);
tmp = (tooltip_window != NULL || tooltip_markup != NULL);
gtk_widget_real_set_has_tooltip (widget, tmp, FALSE);
- gtk_widget_trigger_tooltip_query (widget);
+ if (gtk_widget_get_visible (widget))
+ gtk_widget_queue_tooltip_query (widget);
+ break;
+ case PROP_DOUBLE_BUFFERED:
+ gtk_widget_set_double_buffered (widget, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
break;
case PROP_VISIBLE:
- g_value_set_boolean (value, (GTK_WIDGET_VISIBLE (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_get_visible (widget) != FALSE));
break;
case PROP_SENSITIVE:
- g_value_set_boolean (value, (GTK_WIDGET_SENSITIVE (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_get_sensitive (widget) != FALSE));
break;
case PROP_APP_PAINTABLE:
- g_value_set_boolean (value, (GTK_WIDGET_APP_PAINTABLE (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_get_app_paintable (widget) != FALSE));
break;
case PROP_CAN_FOCUS:
- g_value_set_boolean (value, (GTK_WIDGET_CAN_FOCUS (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_get_can_focus (widget) != FALSE));
break;
case PROP_HAS_FOCUS:
- g_value_set_boolean (value, (GTK_WIDGET_HAS_FOCUS (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_has_focus (widget) != FALSE));
break;
case PROP_IS_FOCUS:
g_value_set_boolean (value, (gtk_widget_is_focus (widget)));
break;
case PROP_CAN_DEFAULT:
- g_value_set_boolean (value, (GTK_WIDGET_CAN_DEFAULT (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_get_can_default (widget) != FALSE));
break;
case PROP_HAS_DEFAULT:
- g_value_set_boolean (value, (GTK_WIDGET_HAS_DEFAULT (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_has_default (widget) != FALSE));
break;
case PROP_RECEIVES_DEFAULT:
- g_value_set_boolean (value, (GTK_WIDGET_RECEIVES_DEFAULT (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_get_receives_default (widget) != FALSE));
break;
case PROP_COMPOSITE_CHILD:
- g_value_set_boolean (value, (GTK_WIDGET_COMPOSITE_CHILD (widget) != FALSE));
+ g_value_set_boolean (value, (GTK_WIDGET_FLAGS (widget) & GTK_COMPOSITE_CHILD) != 0 );
break;
case PROP_STYLE:
g_value_set_object (value, gtk_widget_get_style (widget));
case PROP_WINDOW:
g_value_set_object (value, gtk_widget_get_window (widget));
break;
+ case PROP_DOUBLE_BUFFERED:
+ g_value_set_boolean (value, gtk_widget_get_double_buffered (widget));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
GtkWidget *parent;
parent = widget->parent;
- if (parent && GTK_WIDGET_DRAWABLE (parent))
+ if (parent && gtk_widget_is_drawable (parent))
gtk_widget_queue_draw_area (parent,
widget->allocation.x,
widget->allocation.y,
nqueue = g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
toplevel = gtk_widget_get_toplevel (widget);
- if (GTK_WIDGET_TOPLEVEL (toplevel))
+ if (gtk_widget_is_toplevel (toplevel))
_gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
if (GTK_CONTAINER (widget->parent)->focus_child == widget)
/**
* gtk_widget_destroyed:
* @widget: a #GtkWidget
- * @widget_pointer: address of a variable that contains @widget
+ * @widget_pointer: (inout) (transfer none): address of a variable that contains @widget
*
* This function sets *@widget_pointer to %NULL if @widget_pointer !=
* %NULL. It's intended to be used as a callback connected to the
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (!GTK_WIDGET_VISIBLE (widget))
+ if (!gtk_widget_get_visible (widget))
{
g_object_ref (widget);
- if (!GTK_WIDGET_TOPLEVEL (widget))
+ if (!gtk_widget_is_toplevel (widget))
gtk_widget_queue_resize (widget);
g_signal_emit (widget, widget_signals[SHOW], 0);
g_object_notify (G_OBJECT (widget), "visible");
static void
gtk_widget_real_show (GtkWidget *widget)
{
- if (!GTK_WIDGET_VISIBLE (widget))
+ if (!gtk_widget_get_visible (widget))
{
GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
if (widget->parent &&
- GTK_WIDGET_MAPPED (widget->parent) &&
+ gtk_widget_get_mapped (widget->parent) &&
GTK_WIDGET_CHILD_VISIBLE (widget) &&
- !GTK_WIDGET_MAPPED (widget))
+ !gtk_widget_get_mapped (widget))
gtk_widget_map (widget);
}
}
g_return_if_fail (GTK_IS_WIDGET (widget));
/* make sure we will get event */
- if (!GTK_WIDGET_MAPPED (widget) &&
- GTK_WIDGET_TOPLEVEL (widget))
+ if (!gtk_widget_get_mapped (widget) &&
+ gtk_widget_is_toplevel (widget))
{
gtk_widget_show (widget);
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (GTK_WIDGET_VISIBLE (widget))
+ if (gtk_widget_get_visible (widget))
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
g_object_ref (widget);
- if (toplevel != widget && GTK_WIDGET_TOPLEVEL (toplevel))
+ if (toplevel != widget && gtk_widget_is_toplevel (toplevel))
_gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
g_signal_emit (widget, widget_signals[HIDE], 0);
- if (!GTK_WIDGET_TOPLEVEL (widget))
+ if (!gtk_widget_is_toplevel (widget))
gtk_widget_queue_resize (widget);
g_object_notify (G_OBJECT (widget), "visible");
g_object_unref (widget);
static void
gtk_widget_real_hide (GtkWidget *widget)
{
- if (GTK_WIDGET_VISIBLE (widget))
+ if (gtk_widget_get_visible (widget))
{
GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
- if (GTK_WIDGET_MAPPED (widget))
+ if (gtk_widget_get_mapped (widget))
gtk_widget_unmap (widget);
}
}
g_return_if_fail (GTK_IS_WIDGET (widget));
- if ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0)
+ if (gtk_widget_get_no_show_all (widget))
return;
class = GTK_WIDGET_GET_CLASS (widget);
g_return_if_fail (GTK_IS_WIDGET (widget));
- if ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0)
+ if (gtk_widget_get_no_show_all (widget))
return;
class = GTK_WIDGET_GET_CLASS (widget);
gtk_widget_map (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (GTK_WIDGET_VISIBLE (widget));
+ g_return_if_fail (gtk_widget_get_visible (widget));
g_return_if_fail (GTK_WIDGET_CHILD_VISIBLE (widget));
- if (!GTK_WIDGET_MAPPED (widget))
+ if (!gtk_widget_get_mapped (widget))
{
if (!GTK_WIDGET_REALIZED (widget))
gtk_widget_realize (widget);
g_signal_emit (widget, widget_signals[MAP], 0);
- if (GTK_WIDGET_NO_WINDOW (widget))
+ if (!gtk_widget_get_has_window (widget))
gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
}
}
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (GTK_WIDGET_MAPPED (widget))
+ if (gtk_widget_get_mapped (widget))
{
- if (GTK_WIDGET_NO_WINDOW (widget))
+ if (!gtk_widget_get_has_window (widget))
gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
_gtk_tooltip_hide (widget);
g_signal_emit (widget, widget_signals[UNMAP], 0);
if (window_list == NULL)
{
- if (!GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_has_window (widget))
window_list = g_list_prepend (NULL, widget->window);
else
window_list = gdk_window_get_children (widget->window);
if (!GTK_WIDGET_REALIZED (widget))
{
/*
- if (GTK_IS_CONTAINER (widget) && !GTK_WIDGET_NO_WINDOW (widget))
- g_message ("gtk_widget_realize(%s)", g_type_name (GTK_WIDGET_TYPE (widget)));
+ if (GTK_IS_CONTAINER (widget) && gtk_widget_get_has_window (widget))
+ g_message ("gtk_widget_realize(%s)", G_OBJECT_TYPE_NAME (widget));
*/
if (widget->parent == NULL &&
- !GTK_WIDGET_TOPLEVEL (widget))
+ !gtk_widget_is_toplevel (widget))
g_warning ("Calling gtk_widget_realize() on a widget that isn't "
"inside a toplevel window is not going to work very well. "
"Widgets must be inside a toplevel container before realizing them.");
/* Just return if the widget or one of its ancestors isn't mapped */
for (w = widget; w != NULL; w = w->parent)
- if (!GTK_WIDGET_MAPPED (w))
+ if (!gtk_widget_get_mapped (w))
return;
/* Find the correct widget */
- if (!GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_has_window (widget))
{
if (widget->parent)
{
{
GdkRectangle child_rect;
- if (!GTK_WIDGET_MAPPED (widget) ||
+ if (!gtk_widget_get_mapped (widget) ||
widget->window != widget->parent->window)
return;
gtk_widget_get_draw_rectangle (GtkWidget *widget,
GdkRectangle *rect)
{
- if (GTK_WIDGET_NO_WINDOW (widget))
+ if (!gtk_widget_get_has_window (widget))
{
GtkBorder *draw_border = NULL;
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (GTK_WIDGET_DRAWABLE (widget))
+ if (gtk_widget_is_drawable (widget))
{
if (area)
gtk_widget_queue_draw_area (widget,
if (!GTK_WIDGET_REALIZED (widget))
return;
- if (!GTK_WIDGET_NO_WINDOW (widget) && widget->parent)
+ if (gtk_widget_get_has_window (widget) && widget->parent)
{
int x, y;
* need to convert to the coordinates that widget->allocation
* is in.
*/
- if (!GTK_WIDGET_NO_WINDOW (widget) && widget->parent)
+ if (gtk_widget_get_has_window (widget) && widget->parent)
{
int wx, wy;
g_signal_emit (widget, widget_signals[SIZE_ALLOCATE], 0, &real_allocation);
- if (GTK_WIDGET_MAPPED (widget))
+ if (gtk_widget_get_mapped (widget))
{
- if (GTK_WIDGET_NO_WINDOW (widget) && GTK_WIDGET_REDRAW_ON_ALLOC (widget) && position_changed)
+ if (!gtk_widget_get_has_window (widget) && GTK_WIDGET_REDRAW_ON_ALLOC (widget) && position_changed)
{
/* Invalidate union(old_allaction,widget->allocation) in widget->window
*/
* @dest_widget: a #GtkWidget
* @src_x: X position relative to @src_widget
* @src_y: Y position relative to @src_widget
- * @dest_x: location to store X position relative to @dest_widget
- * @dest_y: location to store Y position relative to @dest_widget
- *
+ * @dest_x: (out): location to store X position relative to @dest_widget
+ * @dest_y: (out): location to store Y position relative to @dest_widget
+ *
* Translate coordinates relative to @src_widget's allocation to coordinates
* relative to @dest_widget's allocations. In order to perform this
* operation, both widgets must be realized, and must share a common
return FALSE;
/* Translate from allocation relative to window relative */
- if (!GTK_WIDGET_NO_WINDOW (src_widget) && src_widget->parent)
+ if (gtk_widget_get_has_window (src_widget) && src_widget->parent)
{
gint wx, wy;
gdk_window_get_position (src_widget->window, &wx, &wy);
}
/* Translate from window relative to allocation relative */
- if (!GTK_WIDGET_NO_WINDOW (dest_widget) && dest_widget->parent)
+ if (gtk_widget_get_has_window (dest_widget) && dest_widget->parent)
{
gint wx, wy;
gdk_window_get_position (dest_widget->window, &wx, &wy);
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget) &&
- !GTK_WIDGET_NO_WINDOW (widget))
+ gtk_widget_get_has_window (widget))
{
gdk_window_move_resize (widget->window,
allocation->x, allocation->y,
guint signal_id)
{
/* widgets must be onscreen for accels to take effect */
- return GTK_WIDGET_IS_SENSITIVE (widget) && GTK_WIDGET_DRAWABLE (widget) && gdk_window_is_viewable (widget->window);
+ return gtk_widget_is_sensitive (widget) &&
+ gtk_widget_is_drawable (widget) &&
+ gdk_window_is_viewable (widget->window);
}
/**
/**
* gtk_widget_set_accel_path:
* @widget: a #GtkWidget
- * @accel_path: path used to look up the accelerator
- * @accel_group: a #GtkAccelGroup.
- *
+ * @accel_path: (allow-none): path used to look up the accelerator
+ * @accel_group: (allow-none): 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
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
group_cycling = group_cycling != FALSE;
- if (!GTK_WIDGET_IS_SENSITIVE (widget))
+ if (!gtk_widget_is_sensitive (widget))
handled = TRUE;
else
g_signal_emit (widget,
{
if (!group_cycling && GTK_WIDGET_GET_CLASS (widget)->activate_signal)
gtk_widget_activate (widget);
- else if (GTK_WIDGET_CAN_FOCUS (widget))
+ else if (gtk_widget_get_can_focus (widget))
gtk_widget_grab_focus (widget);
else
{
/**
* gtk_widget_set_scroll_adjustments:
* @widget: a #GtkWidget
- * @hadjustment: an adjustment for horizontal scrolling, or %NULL
- * @vadjustment: an adjustment for vertical scrolling, or %NULL
+ * @hadjustment: (allow-none): an adjustment for horizontal scrolling, or %NULL
+ * @vadjustment: (allow-none): an adjustment for vertical scrolling, or %NULL
*
* For widgets that support scrolling, sets the scroll adjustments and
* returns %TRUE. For widgets that don't support scrolling, does
gtk_widget_reparent_subwindows (GtkWidget *widget,
GdkWindow *new_window)
{
- if (GTK_WIDGET_NO_WINDOW (widget))
+ if (!gtk_widget_get_has_window (widget))
{
GList *children = gdk_window_get_children (widget->window);
GList *tmp_list;
{
g_assert (client_data != NULL);
- if (GTK_WIDGET_NO_WINDOW (widget))
+ if (!gtk_widget_get_has_window (widget))
{
if (widget->window)
g_object_unref (widget->window);
return_val = gdk_rectangle_intersect (&widget->allocation, area, dest);
- if (return_val && intersection && !GTK_WIDGET_NO_WINDOW (widget))
+ if (return_val && intersection && gtk_widget_get_has_window (widget))
{
intersection->x -= widget->allocation.x;
intersection->y -= widget->allocation.y;
*
* 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)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (!GTK_WIDGET_IS_SENSITIVE (widget))
+ if (!gtk_widget_is_sensitive (widget))
return;
g_object_ref (widget);
static void
gtk_widget_real_grab_focus (GtkWidget *focus_widget)
{
- if (GTK_WIDGET_CAN_FOCUS (focus_widget))
+ if (gtk_widget_get_can_focus (focus_widget))
{
GtkWidget *toplevel;
GtkWidget *widget;
* be set by the next loop.
*/
toplevel = gtk_widget_get_toplevel (focus_widget);
- if (GTK_WIDGET_TOPLEVEL (toplevel) && GTK_IS_WINDOW (toplevel))
+ if (gtk_widget_is_toplevel (toplevel) && GTK_IS_WINDOW (toplevel))
{
widget = GTK_WINDOW (toplevel)->focus_widget;
* toplevel window can request the focus if necessary.
* This is needed when the toplevel is a GtkPlug
*/
- if (!GTK_WIDGET_HAS_FOCUS (widget))
+ if (!gtk_widget_has_focus (widget))
_gtk_window_internal_set_focus (GTK_WINDOW (toplevel), focus_widget);
return;
gtk_widget_real_focus (GtkWidget *widget,
GtkDirectionType direction)
{
- if (!GTK_WIDGET_CAN_FOCUS (widget))
+ if (!gtk_widget_get_can_focus (widget))
return FALSE;
if (!gtk_widget_is_focus (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_get_can_focus (widget))
+ {
+ if (can_focus)
+ GTK_OBJECT_FLAGS (widget) |= GTK_CAN_FOCUS;
+ else
+ GTK_OBJECT_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_FLAGS (widget) & GTK_CAN_FOCUS) != 0;
+}
+
+/**
+ * gtk_widget_has_focus:
+ * @widget: a #GtkWidget
+ *
+ * Determines if the widget has the global input focus. See
+ * gtk_widget_is_focus() for the difference between having the global
+ * input focus, and only having the focus within a toplevel.
+ *
+ * Return value: %TRUE if the widget has the global input focus.
+ *
+ * Since: 2.18
+ **/
+gboolean
+gtk_widget_has_focus (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_OBJECT_FLAGS (widget) & GTK_HAS_FOCUS) != 0;
+}
+
/**
* gtk_widget_is_focus:
* @widget: a #GtkWidget
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_get_can_default (widget))
+ {
+ if (can_default)
+ GTK_OBJECT_FLAGS (widget) |= GTK_CAN_DEFAULT;
+ else
+ GTK_OBJECT_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_FLAGS (widget) & GTK_CAN_DEFAULT) != 0;
+}
+
+/**
+ * gtk_widget_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_FLAGS (widget) & GTK_HAS_DEFAULT) != 0;
+}
+
/**
* 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 <literal>GTK_WIDGET_SET_FLAGS (@widget,
- * GTK_CAN_DEFAULT)</literal>. The default widget is activated when
+ * yourself by calling <literal>gtk_widget_set_can_default (@widget,
+ * %TRUE)</literal>. 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.
**/
GtkWidget *window;
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (GTK_WIDGET_CAN_DEFAULT (widget));
+ g_return_if_fail (gtk_widget_get_can_default (widget));
window = gtk_widget_get_toplevel (widget);
- if (window && GTK_WIDGET_TOPLEVEL (window))
+ if (window && gtk_widget_is_toplevel (window))
gtk_window_set_default (GTK_WINDOW (window), widget);
else
g_warning (G_STRLOC ": widget not within a GtkWindow");
}
+/**
+ * gtk_widget_set_receives_default:
+ * @widget: a #GtkWidget
+ * @receives_default: whether or not @widget can be a default widget.
+ *
+ * Specifies whether @widget will be treated as the default widget
+ * within its toplevel when it has the focus, even if another widget
+ * is the default.
+ *
+ * See gtk_widget_grab_default() for details about the meaning of
+ * "default".
+ *
+ * Since: 2.18
+ **/
+void
+gtk_widget_set_receives_default (GtkWidget *widget,
+ gboolean receives_default)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ if (receives_default != gtk_widget_get_receives_default (widget))
+ {
+ if (receives_default)
+ GTK_OBJECT_FLAGS (widget) |= GTK_RECEIVES_DEFAULT;
+ else
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_RECEIVES_DEFAULT);
+
+ g_object_notify (G_OBJECT (widget), "receives-default");
+ }
+}
+
+/**
+ * gtk_widget_get_receives_default:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether @widget is alyways treated as default widget
+ * withing its toplevel when it has the focus, even if another widget
+ * is the default.
+ *
+ * See gtk_widget_set_receives_default().
+ *
+ * Return value: %TRUE if @widget acts as default widget when focussed,
+ * %FALSE otherwise
+ *
+ * Since: 2.18
+ **/
+gboolean
+gtk_widget_get_receives_default (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_WIDGET_FLAGS (widget) & GTK_RECEIVES_DEFAULT) != 0;
+}
+
+/**
+ * gtk_widget_has_grab:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether the widget is currently grabbing events, so it
+ * is the only widget receiving input events (keyboard and mouse).
+ *
+ * See also gtk_grab_add().
+ *
+ * Return value: %TRUE if the widget is in the grab_widgets stack
+ *
+ * Since: 2.18
+ **/
+gboolean
+gtk_widget_has_grab (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_WIDGET_FLAGS (widget) & GTK_HAS_GRAB) != 0;
+}
+
/**
* gtk_widget_set_name:
* @widget: a #GtkWidget
g_free (widget->name);
widget->name = new_name;
- if (GTK_WIDGET_RC_STYLE (widget))
+ if (gtk_widget_has_rc_style (widget))
gtk_widget_reset_rc_style (widget);
g_object_notify (G_OBJECT (widget), "name");
if (widget->name)
return widget->name;
- return g_type_name (GTK_WIDGET_TYPE (widget));
+ return G_OBJECT_TYPE_NAME (widget);
}
/**
data.state_restoration = FALSE;
data.use_forall = FALSE;
if (widget->parent)
- data.parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (widget->parent) != FALSE);
+ data.parent_sensitive = (gtk_widget_is_sensitive (widget->parent) != FALSE);
else
data.parent_sensitive = TRUE;
gtk_widget_propagate_state (widget, &data);
- if (GTK_WIDGET_DRAWABLE (widget))
+ if (gtk_widget_is_drawable (widget))
gtk_widget_queue_draw (widget);
}
}
+/**
+ * gtk_widget_get_state:
+ * @widget: a #GtkWidget
+ *
+ * Returns the widget's state. See gtk_widget_set_state().
+ *
+ * Returns: the state of @widget.
+ *
+ * Since: 2.18
+ */
+GtkStateType
+gtk_widget_get_state (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_STATE_NORMAL);
+
+ return widget->state;
+}
/**
- * gtk_widget_set_app_paintable:
+ * gtk_widget_set_visible:
* @widget: a #GtkWidget
- * @app_paintable: %TRUE if the application will paint on the widget
+ * @visible: whether the widget should be shown or not
*
- * Sets whether the application intends to draw on the widget in
- * an #GtkWidget::expose-event handler.
+ * Sets the visibility state of @widget. Note that setting this to
+ * %TRUE doesn't mean the widget is actually viewable, see
+ * gtk_widget_get_visible().
*
- * This is a hint to the widget and does not affect the behavior of
- * the GTK+ core; many widgets ignore this flag entirely. For widgets
- * that do pay attention to the flag, such as #GtkEventBox and #GtkWindow,
- * the effect is to suppress default themed drawing of the widget's
- * background. (Children of the widget will still be drawn.) The application
- * is then entirely responsible for drawing the widget background.
+ * This function simply calls gtk_widget_show() or gtk_widget_hide()
+ * but is nicer to use when the visibility of the widget depends on
+ * some condition.
*
- * Note that the background is still drawn when the widget is mapped.
- * If this is not suitable (e.g. because you want to make a transparent
- * window using an RGBA visual), you can work around this by doing:
- * |[
- * gtk_widget_realize (window);
- * gdk_window_set_back_pixmap (window->window, NULL, FALSE);
- * gtk_widget_show (window);
- * ]|
+ * Since: 2.18
**/
void
-gtk_widget_set_app_paintable (GtkWidget *widget,
- gboolean app_paintable)
+gtk_widget_set_visible (GtkWidget *widget,
+ gboolean visible)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- app_paintable = (app_paintable != FALSE);
+ if (visible != gtk_widget_get_visible (widget))
+ {
+ if (visible)
+ gtk_widget_show (widget);
+ else
+ gtk_widget_hide (widget);
+ }
+}
+
+/**
+ * gtk_widget_get_visible:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether the widget is visible. Note that this doesn't
+ * take into account whether the widget's parent is also visible
+ * or the widget is obscured in any way.
+ *
+ * See gtk_widget_set_visible().
+ *
+ * Return value: %TRUE if the widget is visible
+ *
+ * Since: 2.18
+ **/
+gboolean
+gtk_widget_get_visible (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_OBJECT_FLAGS (widget) & GTK_VISIBLE) != 0;
+}
+
+/**
+ * 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_OBJECT_FLAGS (widget) & GTK_NO_WINDOW) != 0);
+}
+
+/**
+ * gtk_widget_is_toplevel:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether @widget is a toplevel widget. Currently only
+ * #GtkWindow and #GtkInvisible are toplevel widgets. Toplevel
+ * widgets have no parent widget.
+ *
+ * Return value: %TRUE if @widget is a toplevel, %FALSE otherwise
+ *
+ * Since: 2.18
+ **/
+gboolean
+gtk_widget_is_toplevel (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_WIDGET_FLAGS (widget) & GTK_TOPLEVEL) != 0;
+}
+
+/**
+ * gtk_widget_is_drawable:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether @widget can be drawn to. A widget can be drawn
+ * to if it is mapped and visible.
+ *
+ * Return value: %TRUE if @widget is drawable, %FALSE otherwise
+ *
+ * Since: 2.18
+ **/
+gboolean
+gtk_widget_is_drawable (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return ((GTK_WIDGET_FLAGS (widget) & GTK_VISIBLE) != 0 &&
+ (GTK_WIDGET_FLAGS (widget) & GTK_MAPPED) != 0);
+}
+
+/**
+ * gtk_widget_get_realized:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether @widget is realized.
+ *
+ * Return value: %TRUE if @widget is realized, %FALSE otherwise
+ *
+ * Since: 2.20
+ **/
+gboolean
+gtk_widget_get_realized (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_WIDGET_FLAGS (widget) & GTK_REALIZED) != 0;
+}
+
+/**
+ * gtk_widget_set_realized:
+ * @widget: a #GtkWidget
+ * @realized: %TRUE to mark the widget as realized
+ *
+ * Marks the widget as being realized.
+ *
+ * This function should only ever be called in a derived widget's
+ * "realize" or "unrealize" implementation.
+ *
+ * Since: 2.20
+ */
+void
+gtk_widget_set_realized (GtkWidget *widget,
+ gboolean realized)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ if (realized)
+ GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+ else
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED);
+}
+
+/**
+ * gtk_widget_get_mapped:
+ * @widget: a #GtkWidget
+ *
+ * Whether the widget is mapped.
+ *
+ * Return value: %TRUE if the widget is mapped, %FALSE otherwise.
+ *
+ * Since: 2.20
+ */
+gboolean
+gtk_widget_get_mapped (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_OBJECT_FLAGS (widget) & GTK_MAPPED) != 0;
+}
+
+/**
+ * gtk_widget_set_mapped:
+ * @widget: a #GtkWidget
+ * @mapped: %TRUE to mark the widget as mapped
+ *
+ * Marks the widget as being realized.
+ *
+ * This function should only ever be called in a derived widget's
+ * "map" or "unmap" implementation.
+ *
+ * Since: 2.20
+ */
+void
+gtk_widget_set_mapped (GtkWidget *widget,
+ gboolean mapped)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
- if (GTK_WIDGET_APP_PAINTABLE (widget) != app_paintable)
+ if (mapped)
+ GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
+ else
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
+}
+
+/**
+ * gtk_widget_set_app_paintable:
+ * @widget: a #GtkWidget
+ * @app_paintable: %TRUE if the application will paint on the widget
+ *
+ * Sets whether the application intends to draw on the widget in
+ * an #GtkWidget::expose-event handler.
+ *
+ * This is a hint to the widget and does not affect the behavior of
+ * the GTK+ core; many widgets ignore this flag entirely. For widgets
+ * that do pay attention to the flag, such as #GtkEventBox and #GtkWindow,
+ * the effect is to suppress default themed drawing of the widget's
+ * background. (Children of the widget will still be drawn.) The application
+ * is then entirely responsible for drawing the widget background.
+ *
+ * Note that the background is still drawn when the widget is mapped.
+ * If this is not suitable (e.g. because you want to make a transparent
+ * window using an RGBA visual), you can work around this by doing:
+ * |[
+ * gtk_widget_realize (window);
+ * gdk_window_set_back_pixmap (window->window, NULL, FALSE);
+ * gtk_widget_show (window);
+ * ]|
+ **/
+void
+gtk_widget_set_app_paintable (GtkWidget *widget,
+ gboolean app_paintable)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ app_paintable = (app_paintable != FALSE);
+
+ if (gtk_widget_get_app_paintable (widget) != app_paintable)
{
if (app_paintable)
GTK_WIDGET_SET_FLAGS (widget, GTK_APP_PAINTABLE);
else
GTK_WIDGET_UNSET_FLAGS (widget, GTK_APP_PAINTABLE);
- if (GTK_WIDGET_DRAWABLE (widget))
+ if (gtk_widget_is_drawable (widget))
gtk_widget_queue_draw (widget);
g_object_notify (G_OBJECT (widget), "app-paintable");
}
}
+/**
+ * gtk_widget_get_app_paintable:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether the application intends to draw on the widget in
+ * an #GtkWidget::expose-event handler.
+ *
+ * See gtk_widget_set_app_paintable()
+ *
+ * Return value: %TRUE if the widget is app paintable
+ *
+ * Since: 2.18
+ **/
+gboolean
+gtk_widget_get_app_paintable (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_WIDGET_FLAGS (widget) & GTK_APP_PAINTABLE) != 0;
+}
+
/**
* gtk_widget_set_double_buffered:
* @widget: a #GtkWidget
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (double_buffered)
- GTK_WIDGET_SET_FLAGS (widget, GTK_DOUBLE_BUFFERED);
- else
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_DOUBLE_BUFFERED);
+ double_buffered = (double_buffered != FALSE);
+
+ if (double_buffered != gtk_widget_get_double_buffered (widget))
+ {
+ if (double_buffered)
+ GTK_OBJECT_FLAGS (widget) |= GTK_DOUBLE_BUFFERED;
+ else
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_DOUBLE_BUFFERED);
+
+ g_object_notify (G_OBJECT (widget), "double-buffered");
+ }
+}
+
+/**
+ * gtk_widget_get_double_buffered:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether the widget is double buffered.
+ *
+ * See gtk_widget_set_double_buffered()
+ *
+ * Return value: %TRUE if the widget is double buffered
+ *
+ * Since: 2.18
+ **/
+gboolean
+gtk_widget_get_double_buffered (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_WIDGET_FLAGS (widget) & GTK_DOUBLE_BUFFERED) != 0;
}
/**
sensitive = (sensitive != FALSE);
- if (sensitive == (GTK_WIDGET_SENSITIVE (widget) != FALSE))
+ if (sensitive == (gtk_widget_get_sensitive (widget) != FALSE))
return;
if (sensitive)
{
- GTK_WIDGET_SET_FLAGS (widget, GTK_SENSITIVE);
- data.state = GTK_WIDGET_SAVED_STATE (widget);
+ GTK_OBJECT_FLAGS (widget) |= GTK_SENSITIVE;
+ data.state = widget->saved_state;
}
else
{
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_SENSITIVE);
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_SENSITIVE);
data.state = GTK_WIDGET_STATE (widget);
}
data.state_restoration = TRUE;
data.use_forall = TRUE;
if (widget->parent)
- data.parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (widget->parent) != FALSE);
+ data.parent_sensitive = (gtk_widget_is_sensitive (widget->parent) != FALSE);
else
data.parent_sensitive = TRUE;
gtk_widget_propagate_state (widget, &data);
- if (GTK_WIDGET_DRAWABLE (widget))
+ if (gtk_widget_is_drawable (widget))
gtk_widget_queue_draw (widget);
g_object_notify (G_OBJECT (widget), "sensitive");
}
+/**
+ * gtk_widget_get_sensitive:
+ * @widget: a #GtkWidget
+ *
+ * Returns the widget's sensitivity (in the sense of returning
+ * the value that has been set using gtk_widget_set_sensitive()).
+ *
+ * The effective sensitivity of a widget is however determined by both its
+ * own and its parent widget's sensitivity. See gtk_widget_is_sensitive().
+ *
+ * Returns: %TRUE if the widget is sensitive
+ *
+ * Since: 2.18
+ */
+gboolean
+gtk_widget_get_sensitive (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_OBJECT_FLAGS (widget) & GTK_SENSITIVE) != 0;
+}
+
+/**
+ * gtk_widget_is_sensitive:
+ * @widget: a #GtkWidget
+ *
+ * Returns the widget's effective sensitivity, which means
+ * it is sensitive itself and also its parent widget is sensntive
+ *
+ * Returns: %TRUE if the widget is effectively sensitive
+ *
+ * Since: 2.18
+ */
+gboolean
+gtk_widget_is_sensitive (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (gtk_widget_get_sensitive (widget) &&
+ (GTK_OBJECT_FLAGS (widget) & GTK_PARENT_SENSITIVE) != 0);
+}
+
/**
* gtk_widget_set_parent:
* @widget: a #GtkWidget
g_warning ("Can't set a parent on widget which has a parent\n");
return;
}
- if (GTK_WIDGET_TOPLEVEL (widget))
+ if (gtk_widget_is_toplevel (widget))
{
g_warning ("Can't set a parent on a toplevel widget\n");
return;
else
data.state = GTK_WIDGET_STATE (widget);
data.state_restoration = FALSE;
- data.parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (parent) != FALSE);
- data.use_forall = GTK_WIDGET_IS_SENSITIVE (parent) != GTK_WIDGET_IS_SENSITIVE (widget);
+ data.parent_sensitive = (gtk_widget_is_sensitive (parent) != FALSE);
+ data.use_forall = gtk_widget_is_sensitive (parent) != gtk_widget_is_sensitive (widget);
gtk_widget_propagate_state (widget, &data);
if (GTK_WIDGET_REALIZED (widget->parent))
gtk_widget_realize (widget);
- if (GTK_WIDGET_VISIBLE (widget->parent) &&
- GTK_WIDGET_VISIBLE (widget))
+ if (gtk_widget_get_visible (widget->parent) &&
+ gtk_widget_get_visible (widget))
{
if (GTK_WIDGET_CHILD_VISIBLE (widget) &&
- GTK_WIDGET_MAPPED (widget->parent))
+ gtk_widget_get_mapped (widget->parent))
gtk_widget_map (widget);
gtk_widget_queue_resize (widget);
*
* Returns the parent container of @widget.
*
- * Return value: the parent container of @widget, or %NULL
+ * Return value: (transfer none): the parent container of @widget, or %NULL
**/
GtkWidget *
gtk_widget_get_parent (GtkWidget *widget)
* see docs/styles.txt
*****************************************/
+/**
+ * gtk_widget_style_attach:
+ * @widget: a #GtkWidget
+ *
+ * This function attaches the widget's #GtkStyle to the widget's
+ * #GdkWindow. It is a replacement for
+ *
+ * <programlisting>
+ * widget->style = gtk_style_attach (widget->style, widget->window);
+ * </programlisting>
+ *
+ * and should only ever be called in a derived widget's "realize"
+ * implementation which does not chain up to its parent class'
+ * "realize" implementation, because one of the parent classes
+ * (finally #GtkWidget) would attach the style itself.
+ *
+ * Since: 2.20
+ **/
+void
+gtk_widget_style_attach (GtkWidget *widget)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GTK_WIDGET_REALIZED (widget));
+
+ widget->style = gtk_style_attach (widget->style, widget->window);
+}
+
+/**
+ * gtk_widget_has_rc_style:
+ * @widget: a #GtkWidget
+ *
+ * Determines if the widget style has been looked up through the rc mechanism.
+ *
+ * Returns: %TRUE if the widget has been looked up through the rc
+ * mechanism, %FALSE otherwise.
+ *
+ * Since: 2.20
+ **/
+gboolean
+gtk_widget_has_rc_style (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_WIDGET_FLAGS (widget) & GTK_RC_STYLE) != 0;
+}
+
/**
* gtk_widget_set_style:
* @widget: a #GtkWidget
- * @style: a #GtkStyle, or %NULL to remove the effect of a previous
+ * @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
*
* Sets the #GtkStyle for a widget (@widget->style). You probably don't
{
gboolean initial_emission;
- initial_emission = !GTK_WIDGET_RC_STYLE (widget) && !GTK_WIDGET_USER_STYLE (widget);
+ initial_emission = !gtk_widget_has_rc_style (widget) && !GTK_WIDGET_USER_STYLE (widget);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_RC_STYLE);
GTK_PRIVATE_SET_FLAG (widget, GTK_USER_STYLE);
g_return_if_fail (GTK_IS_WIDGET (widget));
if (!GTK_WIDGET_USER_STYLE (widget) &&
- !GTK_WIDGET_RC_STYLE (widget))
+ !gtk_widget_has_rc_style (widget))
gtk_widget_reset_rc_style (widget);
}
GtkStyle *new_style = NULL;
gboolean initial_emission;
- initial_emission = !GTK_WIDGET_RC_STYLE (widget) && !GTK_WIDGET_USER_STYLE (widget);
+ initial_emission = !gtk_widget_has_rc_style (widget) && !GTK_WIDGET_USER_STYLE (widget);
GTK_PRIVATE_UNSET_FLAG (widget, GTK_USER_STYLE);
GTK_WIDGET_SET_FLAGS (widget, GTK_RC_STYLE);
* @widget: a #GtkWidget
*
* Simply an accessor function that returns @widget->style.
- *
- * Return value: the widget's #GtkStyle
+ *
+ * Return value: (transfer none): the widget's #GtkStyle
**/
GtkStyle*
gtk_widget_get_style (GtkWidget *widget)
* modifier style and the only reference was our own.
*/
- if (GTK_WIDGET_RC_STYLE (widget))
+ if (gtk_widget_has_rc_style (widget))
gtk_widget_reset_rc_style (widget);
}
* the passed-in style and sets the copy as the new modifier style,
* thus dropping any reference to the old modifier style. Add a reference
* to the modifier style if you want to keep it alive.
- *
- * Return value: the modifier style for the widget. This rc style is
+ *
+ * Return value: (transfer none): the modifier style for the widget. This rc style is
* owned by the widget. If you want to keep a pointer to value this
* around, you must add a refcount using g_object_ref().
**/
* gtk_widget_modify_fg:
* @widget: a #GtkWidget
* @state: the state for which to set the foreground color
- * @color: the color to assign (does not need to be allocated),
+ * @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().
- *
- * Sets the foreground color for a widget in a particular state.
+ *
+ * Sets the foreground color for a widget in a particular state.
* All other style values are left untouched. See also
* gtk_widget_modify_style().
**/
* gtk_widget_modify_bg:
* @widget: a #GtkWidget
* @state: the state for which to set the background color
- * @color: the color to assign (does not need to be allocated),
+ * @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.
+ *
+ * Sets the background color for a widget in a particular state.
* All other style values are left untouched. See also
* gtk_widget_modify_style().
*
* gtk_widget_modify_text:
* @widget: a #GtkWidget
* @state: the state for which to set the text color
- * @color: the color to assign (does not need to be allocated),
+ * @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())
* gtk_widget_modify_base:
* @widget: a #GtkWidget
* @state: the state for which to set the base color
- * @color: the color to assign (does not need to be allocated),
+ * @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
* is the background color used along with the text color
/**
* gtk_widget_modify_font:
* @widget: a #GtkWidget
- * @font_desc: the font description to use, or %NULL to undo
+ * @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().
**/
GtkStyle *previous_style)
{
if (GTK_WIDGET_REALIZED (widget) &&
- !GTK_WIDGET_NO_WINDOW (widget))
+ gtk_widget_get_has_window (widget))
gtk_style_set_background (widget->style, widget->window, widget->state);
}
gpointer client_data)
{
HierarchyChangedInfo *info = client_data;
- gboolean new_anchored = GTK_WIDGET_TOPLEVEL (widget) ||
+ gboolean new_anchored = gtk_widget_is_toplevel (widget) ||
(widget->parent && GTK_WIDGET_ANCHORED (widget->parent));
if (GTK_WIDGET_ANCHORED (widget) != new_anchored)
info.previous_toplevel = previous_toplevel;
info.previous_screen = previous_toplevel ? gtk_widget_get_screen (previous_toplevel) : NULL;
- if (GTK_WIDGET_TOPLEVEL (widget) ||
+ if (gtk_widget_is_toplevel (widget) ||
(widget->parent && GTK_WIDGET_ANCHORED (widget->parent)))
info.new_screen = gtk_widget_get_screen (widget);
else
static void
reset_rc_styles_recurse (GtkWidget *widget, gpointer data)
{
- if (GTK_WIDGET_RC_STYLE (widget))
+ if (gtk_widget_has_rc_style (widget))
gtk_widget_reset_rc_style (widget);
if (GTK_IS_CONTAINER (widget))
NULL);
}
+
+/**
+ * gtk_widget_reset_rc_styles:
+ * @widget: a #GtkWidget.
+ *
+ * Reset the styles of @widget and all descendents, so when
+ * they are looked up again, they get the correct values
+ * for the currently loaded RC file settings.
+ *
+ * This function is not useful for applications.
+ */
void
gtk_widget_reset_rc_styles (GtkWidget *widget)
{
* gtk_widget_get_default_style:
*
* Returns the default style used by all widgets initially.
- *
- * Returns: the default style. This #GtkStyle object is owned
+ *
+ * Returns: (transfer none): the default style. This #GtkStyle object is owned
* by GTK+ and should not be modified or freed.
- */
+ */
GtkStyle*
gtk_widget_get_default_style (void)
{
* on the layout in response to the #GtkWidget::style-set and
* #GtkWidget::direction-changed signals for the widget.
*
- * Return value: the #PangoContext for the widget.
+ * Return value: (transfer none): the #PangoContext for the widget.
**/
PangoContext *
gtk_widget_get_pango_context (GtkWidget *widget)
* gtk_widget_render_icon:
* @widget: a #GtkWidget
* @stock_id: a stock ID
- * @size: a stock size. A size of (GtkIconSize)-1 means render at
- * the size of the source and don't scale (if there are multiple
- * source sizes, GTK+ picks one of the available sizes).
- * @detail: render detail to pass to theme engine
- *
+ * @size: (type int) a stock size. A size of (GtkIconSize)-1 means
+ * render at the size of the source and don't scale (if there are
+ * multiple source sizes, GTK+ picks one of the available sizes).
+ * @detail: (allow-none): render detail to pass to theme engine
+ *
* A convenience function that uses the theme engine and RC file
* settings for @widget to look up @stock_id and render it to
* a pixbuf. @stock_id should be a stock icon ID such as
/**
* gtk_widget_get_parent_window:
* @widget: a #GtkWidget.
- * @returns: the parent window of @widget.
*
* Gets @widget's parent window.
+ *
+ * Returns: (transfer none): the parent window of @widget.
**/
GdkWindow *
gtk_widget_get_parent_window (GtkWidget *widget)
gboolean is_visible)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (!GTK_WIDGET_TOPLEVEL (widget));
+ g_return_if_fail (!gtk_widget_is_toplevel (widget));
g_object_ref (widget);
GTK_PRIVATE_UNSET_FLAG (widget, GTK_CHILD_VISIBLE);
toplevel = gtk_widget_get_toplevel (widget);
- if (toplevel != widget && GTK_WIDGET_TOPLEVEL (toplevel))
+ if (toplevel != widget && gtk_widget_is_toplevel (toplevel))
_gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
}
if (widget->parent && GTK_WIDGET_REALIZED (widget->parent))
{
- if (GTK_WIDGET_MAPPED (widget->parent) &&
+ if (gtk_widget_get_mapped (widget->parent) &&
GTK_WIDGET_CHILD_VISIBLE (widget) &&
- GTK_WIDGET_VISIBLE (widget))
+ gtk_widget_get_visible (widget))
gtk_widget_map (widget);
else
gtk_widget_unmap (widget);
toplevel = gtk_widget_get_toplevel (widget);
- if (GTK_WIDGET_TOPLEVEL (toplevel))
+ if (gtk_widget_is_toplevel (toplevel))
{
if (GTK_IS_WINDOW (toplevel))
return GTK_WINDOW (toplevel)->screen;
* In general, you should only create screen specific
* resources when a widget has been realized, and you should
* free those resources when the widget is unrealized.
- *
- * Return value: the #GdkScreen for the toplevel for this widget.
+ *
+ * Return value: (transfer none): the #GdkScreen for the toplevel for this widget.
*
* Since: 2.2
**/
* In general, you should only create display specific
* resources when a widget has been realized, and you should
* free those resources when the widget is unrealized.
- *
- * Return value: the #GdkDisplay for the toplevel for this widget.
+ *
+ * Return value: (transfer none): the #GdkDisplay for the toplevel for this widget.
*
* Since: 2.2
**/
* #GdkWindow associated with the window. In general, you should only
* create display specific resources when a widget has been realized,
* and you should free those resources when the widget is unrealized.
- *
- * Return value: the #GdkWindow root window for the toplevel for this widget.
+ *
+ * Return value: (transfer none): the #GdkWindow root window for the toplevel for this widget.
*
* Since: 2.2
**/
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- if (!GTK_WIDGET_VISIBLE (widget) ||
- !GTK_WIDGET_IS_SENSITIVE (widget))
+ if (!gtk_widget_get_visible (widget) ||
+ !gtk_widget_is_sensitive (widget))
return FALSE;
/* child widgets must set CAN_FOCUS, containers
* don't have to though.
*/
if (!GTK_IS_CONTAINER (widget) &&
- !GTK_WIDGET_CAN_FOCUS (widget))
+ !gtk_widget_get_can_focus (widget))
return FALSE;
g_signal_emit (widget,
if (GTK_IS_WINDOW (widget) && aux_info->x_set && aux_info->y_set)
_gtk_window_reposition (GTK_WINDOW (widget), aux_info->x, aux_info->y);
- if (GTK_WIDGET_VISIBLE (widget) && widget->parent)
+ if (gtk_widget_get_visible (widget) && widget->parent)
gtk_widget_size_allocate (widget, &widget->allocation);
}
changed = TRUE;
}
- if (GTK_WIDGET_VISIBLE (widget) && changed)
+ if (gtk_widget_get_visible (widget) && changed)
gtk_widget_queue_resize (widget);
g_object_thaw_notify (G_OBJECT (widget));
/**
* gtk_widget_get_size_request:
* @widget: a #GtkWidget
- * @width: return location for width, or %NULL
- * @height: return location for height, or %NULL
+ * @width: (allow-none): (out): return location for width, or %NULL
+ * @height: (allow-none): (out): return location for height, or %NULL
*
* Gets the size request that was explicitly set for the widget using
* gtk_widget_set_size_request(). A value of -1 stored in @width or
{
GList *window_list;
- if (GTK_WIDGET_NO_WINDOW (widget))
+ if (!gtk_widget_get_has_window (widget))
window_list = gdk_window_get_children (widget->window);
else
window_list = g_list_prepend (NULL, widget->window);
* is set on the result.
* |[
* GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
- * if (GTK_WIDGET_TOPLEVEL (toplevel))
+ * if (gtk_widget_is_toplevel (toplevel))
* {
* /* Perform action on toplevel. */
* }
* ]|
*
- * Return value: the topmost ancestor of @widget, or @widget itself
+ * Return value: (transfer none): the topmost ancestor of @widget, or @widget itself
* if there's no ancestor.
**/
GtkWidget*
* Note that unlike gtk_widget_is_ancestor(), gtk_widget_get_ancestor()
* considers @widget to be an ancestor of itself.
*
- * Return value: the ancestor widget, or %NULL if not found
+ * Return value: (transfer none): the ancestor widget, or %NULL if not found
**/
GtkWidget*
gtk_widget_get_ancestor (GtkWidget *widget,
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- while (widget && !g_type_is_a (GTK_WIDGET_TYPE (widget), widget_type))
+ while (widget && !g_type_is_a (G_OBJECT_TYPE (widget), widget_type))
widget = widget->parent;
- if (!(widget && g_type_is_a (GTK_WIDGET_TYPE (widget), widget_type)))
+ if (!(widget && g_type_is_a (G_OBJECT_TYPE (widget), widget_type)))
return NULL;
return widget;
*
* Gets the colormap that will be used to render @widget. No reference will
* be added to the returned colormap; it should not be unreferenced.
- *
- * Return value: the colormap used by @widget
+ *
+ * Return value: (transfer none): the colormap used by @widget
**/
GdkColormap*
gtk_widget_get_colormap (GtkWidget *widget)
* @widget: a #GtkWidget
*
* Gets the visual that will be used to render @widget.
- *
- * Return value: the visual for @widget
+ *
+ * Return value: (transfer none): the visual for @widget
**/
GdkVisual*
gtk_widget_get_visual (GtkWidget *widget)
* Note that this function can only be called when the #GtkWidget
* is attached to a toplevel, since the settings object is specific
* to a particular #GdkScreen.
- *
- * Return value: the relevant #GtkSettings object
+ *
+ * Return value: (transfer none): the relevant #GtkSettings object
**/
GtkSettings*
gtk_widget_get_settings (GtkWidget *widget)
/**
* gtk_widget_get_pointer:
* @widget: a #GtkWidget
- * @x: return location for the X coordinate, or %NULL
- * @y: return location for the Y coordinate, or %NULL
+ * @x: (out) (allow-none): return location for the X coordinate, or %NULL
+ * @y: (out) (allow-none): return location for the Y coordinate, or %NULL
*
* Obtains the location of the mouse pointer in widget coordinates.
* Widget coordinates are a bit odd; for historical reasons, they are
{
gdk_window_get_pointer (widget->window, x, y, NULL);
- if (GTK_WIDGET_NO_WINDOW (widget))
+ if (!gtk_widget_get_has_window (widget))
{
if (x)
*x -= widget->allocation.x;
const gchar *name)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (GTK_WIDGET_COMPOSITE_CHILD (widget));
+ g_return_if_fail ((GTK_WIDGET_FLAGS (widget) & GTK_COMPOSITE_CHILD) != 0);
g_return_if_fail (name != NULL);
if (!quark_composite_name)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- if (GTK_WIDGET_COMPOSITE_CHILD (widget) && widget->parent)
+ if (((GTK_WIDGET_FLAGS (widget) & GTK_COMPOSITE_CHILD) != 0) && widget->parent)
return _gtk_container_child_composite_name (GTK_CONTAINER (widget->parent),
widget);
else
* gtk_widget_get_default_colormap:
*
* Obtains the default colormap used to create widgets.
- *
- * Return value: default widget colormap
+ *
+ * Return value: (transfer none): default widget colormap
**/
GdkColormap*
gtk_widget_get_default_colormap (void)
*
* Obtains the visual of the default colormap. Not really useful;
* used to be useful before gdk_colormap_get_visual() existed.
- *
- * Return value: visual of the default colormap
+ *
+ * Return value: (transfer none): visual of the default colormap
**/
GdkVisual*
gtk_widget_get_default_visual (void)
if (widget->parent)
gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
- else if (GTK_WIDGET_VISIBLE (widget))
+ else if (gtk_widget_get_visible (widget))
gtk_widget_hide (widget);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
{
g_assert (GTK_WIDGET_REALIZED (widget));
- if (!GTK_WIDGET_MAPPED (widget))
+ if (!gtk_widget_get_mapped (widget))
{
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
- if (!GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_has_window (widget))
gdk_window_show (widget->window);
}
}
static void
gtk_widget_real_unmap (GtkWidget *widget)
{
- if (GTK_WIDGET_MAPPED (widget))
+ if (gtk_widget_get_mapped (widget))
{
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
- if (!GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_has_window (widget))
gdk_window_hide (widget->window);
}
}
static void
gtk_widget_real_realize (GtkWidget *widget)
{
- g_assert (GTK_WIDGET_NO_WINDOW (widget));
+ g_assert (!gtk_widget_get_has_window (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
if (widget->parent)
static void
gtk_widget_real_unrealize (GtkWidget *widget)
{
- if (GTK_WIDGET_MAPPED (widget))
+ if (gtk_widget_get_mapped (widget))
gtk_widget_real_unmap (widget);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
NULL);
gtk_style_detach (widget->style);
- if (!GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_has_window (widget))
{
gdk_window_set_user_data (widget->window, NULL);
gdk_window_destroy (widget->window);
_gtk_widget_is_pointer_widget (GtkWidget *widget)
{
if (GTK_WIDGET_HAS_POINTER (widget))
- {
- GdkWindow *win;
+ {
+ GdkWindow *win;
GtkWidget *wid;
win = _gtk_widget_get_pointer_window (widget);
if (win)
- {
- gdk_window_get_user_data (win, &wid);
+ {
+ gdk_window_get_user_data (win, (gpointer *)&wid);
if (wid == widget)
return TRUE;
}
while (from_ancestor != NULL)
{
- if (from_ancestor != NULL)
- {
- from_ancestor = gdk_window_get_parent (from_ancestor);
- if (from_ancestor == NULL)
- break;
- from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
- }
+ from_ancestor = gdk_window_get_parent (from_ancestor);
+ if (from_ancestor == NULL)
+ break;
+ from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
}
synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
while (to_ancestor != NULL)
{
- if (to_ancestor != NULL)
- {
- to_ancestor = gdk_window_get_parent (to_ancestor);
- if (to_ancestor == NULL)
- break;
- to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
- }
- }
+ to_ancestor = gdk_window_get_parent (to_ancestor);
+ if (to_ancestor == NULL)
+ break;
+ to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
+ }
/* XXX: leave/inferior on root window? */
from_ancestor = gdk_window_get_parent (from_ancestor);
if (from_ancestor == to_window)
break;
- from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
+ if (from_ancestor)
+ from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
}
if (to_ancestor != NULL)
{
to_ancestor = gdk_window_get_parent (to_ancestor);
if (to_ancestor == from_window)
break;
- to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
+ if (to_ancestor)
+ to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
}
}
if (to_ancestor == from_window)
GtkStateData *data)
{
guint8 old_state = GTK_WIDGET_STATE (widget);
- guint8 old_saved_state = GTK_WIDGET_SAVED_STATE (widget);
+ guint8 old_saved_state = widget->saved_state;
/* don't call this function with state==GTK_STATE_INSENSITIVE,
* parent_sensitive==TRUE on a sensitive widget
else
GTK_WIDGET_UNSET_FLAGS (widget, GTK_PARENT_SENSITIVE);
- if (GTK_WIDGET_IS_SENSITIVE (widget))
+ if (gtk_widget_is_sensitive (widget))
{
if (data->state_restoration)
- GTK_WIDGET_STATE (widget) = GTK_WIDGET_SAVED_STATE (widget);
+ GTK_WIDGET_STATE (widget) = widget->saved_state;
else
GTK_WIDGET_STATE (widget) = data->state;
}
if (!data->state_restoration)
{
if (data->state != GTK_STATE_INSENSITIVE)
- GTK_WIDGET_SAVED_STATE (widget) = data->state;
+ widget->saved_state = data->state;
}
else if (GTK_WIDGET_STATE (widget) != GTK_STATE_INSENSITIVE)
- GTK_WIDGET_SAVED_STATE (widget) = GTK_WIDGET_STATE (widget);
+ widget->saved_state = GTK_WIDGET_STATE (widget);
GTK_WIDGET_STATE (widget) = GTK_STATE_INSENSITIVE;
}
- if (gtk_widget_is_focus (widget) && !GTK_WIDGET_IS_SENSITIVE (widget))
+ if (gtk_widget_is_focus (widget) && !gtk_widget_is_sensitive (widget))
{
GtkWidget *window;
window = gtk_widget_get_toplevel (widget);
- if (window && GTK_WIDGET_TOPLEVEL (window))
+ if (window && gtk_widget_is_toplevel (window))
gtk_window_set_focus (GTK_WINDOW (window), NULL);
}
if (old_state != GTK_WIDGET_STATE (widget) ||
- old_saved_state != GTK_WIDGET_SAVED_STATE (widget))
+ old_saved_state != widget->saved_state)
{
g_object_ref (widget);
- if (!GTK_WIDGET_IS_SENSITIVE (widget) && GTK_WIDGET_HAS_GRAB (widget))
+ if (!gtk_widget_is_sensitive (widget) && gtk_widget_has_grab (widget))
gtk_grab_remove (widget);
g_signal_emit (widget, widget_signals[STATE_CHANGED], 0, old_state);
if (GTK_WIDGET_HAS_POINTER (widget) && !GTK_WIDGET_SHADOWED (widget))
{
- if (!GTK_WIDGET_IS_SENSITIVE (widget))
+ if (!gtk_widget_is_sensitive (widget))
_gtk_widget_synthesize_crossing (widget, NULL,
GDK_CROSSING_STATE_CHANGED);
else if (old_state == GTK_STATE_INSENSITIVE)
if (GTK_IS_CONTAINER (widget))
{
- data->parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (widget) != FALSE);
+ data->parent_sensitive = (gtk_widget_is_sensitive (widget) != FALSE);
if (data->use_forall)
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback) gtk_widget_propagate_state,
/**
* gtk_widget_shape_combine_mask:
* @widget: a #GtkWidget
- * @shape_mask: shape to be added, or %NULL to remove an existing shape
+ * @shape_mask: (allow-none): shape to be added, or %NULL to remove an existing shape
* @offset_x: X position of shape mask with respect to @window
* @offset_y: Y position of shape mask with respect to @window
*
g_return_if_fail (GTK_IS_WIDGET (widget));
/* set_shape doesn't work on widgets without gdk window */
- g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
+ g_return_if_fail (gtk_widget_get_has_window (widget));
if (!shape_mask)
{
}
/**
- * gtk_widget_input_shape_combine_mask:
+ * gtk_widget_input_shape_combine_mask:
* @widget: a #GtkWidget
- * @shape_mask: shape to be added, or %NULL to remove an existing shape
+ * @shape_mask: (allow-none): shape to be added, or %NULL to remove an existing shape
* @offset_x: X position of shape mask with respect to @window
* @offset_y: Y position of shape mask with respect to @window
- *
+ *
* Sets an input shape for this widget's GDK window. This allows for
* windows which react to mouse click in a nonrectangular region, see
* gdk_window_input_shape_combine_mask() for more information.
g_return_if_fail (GTK_IS_WIDGET (widget));
/* set_shape doesn't work on widgets without gdk window */
- g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
+ g_return_if_fail (gtk_widget_get_has_window (widget));
if (!shape_mask)
{
gdk_window_get_user_data (window, &user_data);
if (user_data)
- is_double_buffered = GTK_WIDGET_DOUBLE_BUFFERED (GTK_WIDGET (user_data));
+ is_double_buffered = gtk_widget_get_double_buffered (GTK_WIDGET (user_data));
else
is_double_buffered = FALSE;
/**
* gtk_widget_get_snapshot:
* @widget: a #GtkWidget
- * @clip_rect: a #GdkRectangle or %NULL
+ * @clip_rect: (allow-none): a #GdkRectangle or %NULL
*
* Create a #GdkPixmap of the contents of the widget and its children.
*
GList *windows = NULL, *list;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- if (!GTK_WIDGET_VISIBLE (widget))
+ if (!gtk_widget_get_visible (widget))
return NULL;
/* the widget (and parent_window) must be realized to be drawable */
width = widget->allocation.width;
height = widget->allocation.height;
- if (widget->parent && !GTK_WIDGET_NO_WINDOW (widget))
+ if (widget->parent && gtk_widget_get_has_window (widget))
{
/* grow snapshot rectangle to cover all widget windows */
parent_window = gtk_widget_get_parent_window (widget);
* gtk_widget_class_find_style_property:
* @klass: a #GtkWidgetClass
* @property_name: the name of the style property to find
- * @returns: the #GParamSpec of the style property or %NULL if @class has no
+ * @returns: (allow-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.
/**
* gtk_widget_path:
* @widget: a #GtkWidget
- * @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
+ * @path_length: (out) (allow-none): location to store length of the path, or %NULL
+ * @path: (out) (allow-none): location to store allocated path string, or %NULL
+ * @path_reversed: (out) (allow-none): 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
/**
* gtk_widget_class_path:
* @widget: a #GtkWidget
- * @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
+ * @path_length: (out) (allow-none): location to store the length of the class path, or %NULL
+ * @path: (out) (allow-none) location to store the class path as an allocated string, or %NULL
+ * @path_reversed: (out) (allow-none) 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,
gchar *d;
guint l;
- string = g_type_name (GTK_WIDGET_TYPE (widget));
+ string = g_type_name (G_OBJECT_TYPE (widget));
l = strlen (string);
while (tmp_path_len <= len + l + 1)
{
*
* The documentation of the <ulink url="http://developer.gnome.org/doc/API/2.0/atk/index.html">ATK</ulink>
* library contains more information about accessible objects and their uses.
- *
- * Returns: the #AtkObject associated with @widget
+ *
+ * Returns: (transfer none): the #AtkObject associated with @widget
*/
-AtkObject*
+AtkObject*
gtk_widget_get_accessible (GtkWidget *widget)
{
GtkWidgetClass *klass;
static GQuark quark_builder_has_default = 0;
static GQuark quark_builder_has_focus = 0;
static GQuark quark_builder_atk_relations = 0;
+static GQuark quark_builder_set_name = 0;
static void
gtk_widget_buildable_interface_init (GtkBuildableIface *iface)
quark_builder_has_default = g_quark_from_static_string ("gtk-builder-has-default");
quark_builder_has_focus = g_quark_from_static_string ("gtk-builder-has-focus");
quark_builder_atk_relations = g_quark_from_static_string ("gtk-builder-atk-relations");
+ quark_builder_set_name = g_quark_from_static_string ("gtk-builder-set-name");
iface->set_name = gtk_widget_buildable_set_name;
iface->get_name = gtk_widget_buildable_get_name;
gtk_widget_buildable_set_name (GtkBuildable *buildable,
const gchar *name)
{
- gtk_widget_set_name (GTK_WIDGET (buildable), name);
+ g_object_set_qdata_full (G_OBJECT (buildable), quark_builder_set_name,
+ g_strdup (name), g_free);
}
static const gchar *
gtk_widget_buildable_get_name (GtkBuildable *buildable)
{
- return gtk_widget_get_name (GTK_WIDGET (buildable));
+ return g_object_get_qdata (G_OBJECT (buildable), quark_builder_set_name);
}
static GObject *
g_object_set_property (G_OBJECT (buildable), name, value);
}
-typedef struct {
+typedef struct
+{
gchar *action_name;
- gchar *description;
+ GString *description;
+ gchar *context;
+ gboolean translatable;
} AtkActionData;
-
-typedef struct {
+
+typedef struct
+{
gchar *target;
gchar *type;
} AtkRelationData;
free_action (AtkActionData *data, gpointer user_data)
{
g_free (data->action_name);
- g_free (data->description);
+ g_string_free (data->description, TRUE);
+ g_free (data->context);
g_slice_free (AtkActionData, data);
}
GtkBuilder *builder)
{
GSList *atk_relations;
-
+
if (g_object_get_qdata (G_OBJECT (buildable), quark_builder_has_default))
gtk_widget_grab_default (GTK_WIDGET (buildable));
if (g_object_get_qdata (G_OBJECT (buildable), quark_builder_has_focus))
GObject *target;
AtkRelationType relation_type;
AtkObject *target_accessible;
-
+
accessible = gtk_widget_get_accessible (GTK_WIDGET (buildable));
relation_set = atk_object_ref_relation_set (accessible);
for (l = atk_relations; l; l = l->next)
{
AtkRelationData *relation = (AtkRelationData*)l->data;
-
+
target = gtk_builder_get_object (builder, relation->target);
if (!target)
{
}
target_accessible = gtk_widget_get_accessible (GTK_WIDGET (target));
g_assert (target_accessible != NULL);
-
+
relation_type = atk_relation_type_for_name (relation->type);
if (relation_type == ATK_RELATION_NULL)
{
g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations,
NULL);
}
-
}
-typedef struct {
+typedef struct
+{
GSList *actions;
GSList *relations;
} AccessibilitySubParserData;
static void
-accessibility_start_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **names,
- const gchar **values,
- gpointer user_data,
- GError **error)
+accessibility_start_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **names,
+ const gchar **values,
+ gpointer user_data,
+ GError **error)
{
AccessibilitySubParserData *data = (AccessibilitySubParserData*)user_data;
guint i;
gchar *target = NULL;
gchar *type = NULL;
AtkRelationData *relation;
-
+
for (i = 0; names[i]; i++)
{
if (strcmp (names[i], "target") == 0)
relation = g_slice_new (AtkRelationData);
relation->target = target;
relation->type = type;
-
+
data->relations = g_slist_prepend (data->relations, relation);
}
else if (strcmp (element_name, "action") == 0)
{
- gchar *action_name = NULL;
- gchar *description = NULL;
+ const gchar *action_name = NULL;
+ const gchar *description = NULL;
+ const gchar *msg_context = NULL;
+ gboolean translatable = FALSE;
AtkActionData *action;
-
+
for (i = 0; names[i]; i++)
{
if (strcmp (names[i], "action_name") == 0)
- action_name = g_strdup (values[i]);
+ action_name = values[i];
else if (strcmp (names[i], "description") == 0)
- description = g_strdup (values[i]);
+ description = values[i];
+ else if (strcmp (names[i], "translatable") == 0)
+ {
+ if (!_gtk_builder_boolean_from_string (values[i], &translatable, error))
+ return;
+ }
+ else if (strcmp (names[i], "comments") == 0)
+ {
+ /* do nothing, comments are for translators */
+ }
+ else if (strcmp (names[i], "context") == 0)
+ msg_context = values[i];
else
{
g_markup_parse_context_get_position (context,
"%s:%d:%d '%s' is not a valid attribute of <%s>",
"<input>",
line_number, char_number, names[i], "action");
- g_free (action_name);
- g_free (description);
return;
}
}
- if (!action_name || !description)
+ if (!action_name)
{
g_markup_parse_context_get_position (context,
&line_number,
"%s:%d:%d <%s> requires attribute \"%s\"",
"<input>",
line_number, char_number, "action",
- description ? "action_name" : "description");
- g_free (action_name);
- g_free (description);
+ "action_name");
return;
}
action = g_slice_new (AtkActionData);
- action->action_name = action_name;
- action->description = description;
-
+ action->action_name = g_strdup (action_name);
+ action->description = g_string_new (description);
+ action->context = g_strdup (msg_context);
+ action->translatable = translatable;
+
data->actions = g_slist_prepend (data->actions, action);
}
else if (strcmp (element_name, "accessibility") == 0)
g_warning ("Unsupported tag for GtkWidget: %s\n", element_name);
}
+static void
+accessibility_text (GMarkupParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error)
+{
+ AccessibilitySubParserData *data = (AccessibilitySubParserData*)user_data;
+
+ if (strcmp (g_markup_parse_context_get_element (context), "action") == 0)
+ {
+ AtkActionData *action = data->actions->data;
+
+ g_string_append_len (action->description, text, text_len);
+ }
+}
+
static const GMarkupParser accessibility_parser =
{
accessibility_start_element,
+ NULL,
+ accessibility_text,
};
-typedef struct {
+typedef struct
+{
GObject *object;
guint key;
guint modifiers;
} AccelGroupParserData;
static void
-accel_group_start_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **names,
- const gchar **values,
- gpointer user_data,
- GError **error)
+accel_group_start_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **names,
+ const gchar **values,
+ gpointer user_data,
+ GError **error)
{
gint i;
guint key = 0;
return FALSE;
}
+void
+_gtk_widget_buildable_finish_accelerator (GtkWidget *widget,
+ GtkWidget *toplevel,
+ gpointer user_data)
+{
+ AccelGroupParserData *accel_data;
+ GSList *accel_groups;
+ GtkAccelGroup *accel_group;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GTK_IS_WIDGET (toplevel));
+ g_return_if_fail (user_data != NULL);
+
+ accel_data = (AccelGroupParserData*)user_data;
+ accel_groups = gtk_accel_groups_from_object (G_OBJECT (toplevel));
+ if (g_slist_length (accel_groups) == 0)
+ {
+ accel_group = gtk_accel_group_new ();
+ gtk_window_add_accel_group (GTK_WINDOW (toplevel), accel_group);
+ }
+ else
+ {
+ g_assert (g_slist_length (accel_groups) == 1);
+ accel_group = g_slist_nth_data (accel_groups, 0);
+ }
+
+ gtk_widget_add_accelerator (GTK_WIDGET (accel_data->object),
+ accel_data->signal,
+ accel_group,
+ accel_data->key,
+ accel_data->modifiers,
+ GTK_ACCEL_VISIBLE);
+
+ g_object_unref (accel_data->object);
+ g_free (accel_data->signal);
+ g_slice_free (AccelGroupParserData, accel_data);
+}
+
static void
gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
GtkBuilder *builder,
AccelGroupParserData *accel_data;
AccessibilitySubParserData *a11y_data;
GtkWidget *toplevel;
- GSList *accel_groups;
- GtkAccelGroup *accel_group;
if (strcmp (tagname, "accelerator") == 0)
{
g_assert (accel_data->object);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (accel_data->object));
- accel_groups = gtk_accel_groups_from_object (G_OBJECT (toplevel));
- if (g_slist_length (accel_groups) == 0)
- {
- accel_group = gtk_accel_group_new ();
- gtk_window_add_accel_group (GTK_WINDOW (toplevel), accel_group);
- }
- else
- {
- g_assert (g_slist_length (accel_groups) == 1);
- accel_group = g_slist_nth_data (accel_groups, 0);
- }
- gtk_widget_add_accelerator (GTK_WIDGET (accel_data->object),
- accel_data->signal,
- accel_group,
- accel_data->key,
- accel_data->modifiers,
- GTK_ACCEL_VISIBLE);
- g_object_unref (accel_data->object);
- g_free (accel_data->signal);
- g_slice_free (AccelGroupParserData, accel_data);
+
+ _gtk_widget_buildable_finish_accelerator (GTK_WIDGET (buildable), toplevel, user_data);
}
else if (strcmp (tagname, "accessibility") == 0)
{
AtkAction *action;
gint i, n_actions;
GSList *l;
-
+
accessible = gtk_widget_get_accessible (GTK_WIDGET (buildable));
-
+
action = ATK_ACTION (accessible);
- n_actions = atk_action_get_n_actions (action);
-
+ n_actions = atk_action_get_n_actions (action);
+
for (l = a11y_data->actions; l; l = l->next)
{
AtkActionData *action_data = (AtkActionData*)l->data;
-
+
for (i = 0; i < n_actions; i++)
if (strcmp (atk_action_get_name (action, i),
action_data->action_name) == 0)
break;
if (i < n_actions)
- atk_action_set_description (action, i,
- action_data->description);
+ {
+ gchar *description;
+
+ if (action_data->translatable && action_data->description->len)
+ description = _gtk_builder_parser_translate (gtk_builder_get_translation_domain (builder),
+ action_data->context,
+ action_data->description->str);
+ else
+ description = action_data->description->str;
+
+ atk_action_set_description (action, i, description);
+ }
}
-
+
g_slist_foreach (a11y_data->actions, (GFunc)free_action, NULL);
g_slist_free (a11y_data->actions);
}
if (a11y_data->relations)
g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations,
a11y_data->relations);
-
+
g_slice_free (AccessibilitySubParserData, a11y_data);
-
}
}
* be used with @widget. @widget must have a #GdkDisplay
* associated with it, so must be attached to a toplevel
* window.
- *
- * Return value: the appropriate clipboard object. If no
+ *
+ * Return value: (transfer none): the appropriate clipboard object. If no
* clipboard already exists, a new one will
* be created. Once a clipboard object has
* been created, it is persistent for all time.
* (GFunc)g_object_ref, NULL)</literal> first, and then unref all the
* widgets afterwards.
- * Return value: the list of mnemonic labels; free this list
+ * Return value: (element-type GtkWidget) (transfer container): the list of
+ * mnemonic labels; free this list
* with g_list_free() when you are done with it.
*
* Since: 2.4
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0;
+ return (GTK_OBJECT_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0;
}
/**
no_show_all = (no_show_all != FALSE);
- if (no_show_all == ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0))
+ if (no_show_all == gtk_widget_get_no_show_all (widget))
return;
if (no_show_all)
- GTK_WIDGET_SET_FLAGS (widget, GTK_NO_SHOW_ALL);
+ GTK_OBJECT_FLAGS (widget) |= GTK_NO_SHOW_ALL;
else
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_NO_SHOW_ALL);
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_NO_SHOW_ALL);
g_object_notify (G_OBJECT (widget), "no-show-all");
}
if (priv_has_tooltip)
{
- if (GTK_WIDGET_REALIZED (widget) && GTK_WIDGET_NO_WINDOW (widget))
+ if (GTK_WIDGET_REALIZED (widget) && !gtk_widget_get_has_window (widget))
gdk_window_set_events (widget->window,
gdk_window_get_events (widget->window) |
GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
- if (!GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_has_window (widget))
gtk_widget_add_events (widget,
GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK |
/**
* gtk_widget_set_tooltip_window:
* @widget: a #GtkWidget
- * @custom_window: a #GtkWindow, or %NULL
+ * @custom_window: (allow-none): a #GtkWindow, or %NULL
*
* Replaces the default, usually yellow, window used for displaying
* tooltips with @custom_window. GTK+ will take care of showing and
* the default tooltip window. If @custom_window is %NULL, the default
* tooltip window will be used.
*
+ * If the custom window should have the default theming it needs to
+ * have the name "gtk-tooltip", see gtk_widget_set_name().
+ *
* Since: 2.12
*/
void
gtk_widget_set_tooltip_window (GtkWidget *widget,
GtkWindow *custom_window)
{
- gboolean tmp;
+ gboolean has_tooltip;
gchar *tooltip_markup;
- GtkWindow *tooltip_window;
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (custom_window)
- g_return_if_fail (GTK_IS_WINDOW (custom_window));
+ g_return_if_fail (custom_window == NULL || GTK_IS_WINDOW (custom_window));
- tooltip_window = g_object_get_qdata (G_OBJECT (widget), quark_tooltip_window);
tooltip_markup = g_object_get_qdata (G_OBJECT (widget), quark_tooltip_markup);
if (custom_window)
g_object_ref (custom_window);
- tooltip_window = custom_window;
g_object_set_qdata_full (G_OBJECT (widget), quark_tooltip_window,
- tooltip_window, g_object_unref);
+ custom_window, g_object_unref);
- tmp = (tooltip_window != NULL || tooltip_markup != NULL);
- gtk_widget_real_set_has_tooltip (widget, tmp, FALSE);
+ has_tooltip = (custom_window != NULL || tooltip_markup != NULL);
+ gtk_widget_real_set_has_tooltip (widget, has_tooltip, FALSE);
- if (tmp)
- gtk_widget_trigger_tooltip_query (widget);
+ if (has_tooltip && gtk_widget_get_visible (widget))
+ gtk_widget_queue_tooltip_query (widget);
}
/**
* GtkWindow created by default, or the custom tooltip window set
* using gtk_widget_set_tooltip_window().
*
- * Return value: The #GtkWindow of the current tooltip.
+ * Return value: (transfer none): The #GtkWindow of the current tooltip.
*
* Since: 2.12
*/
gtk_tooltip_trigger_tooltip_query (gtk_widget_get_display (widget));
}
+static guint tooltip_query_id;
+static GSList *tooltip_query_displays;
+
+static gboolean
+tooltip_query_idle (gpointer data)
+{
+ g_slist_foreach (tooltip_query_displays, (GFunc)gtk_tooltip_trigger_tooltip_query, NULL);
+ g_slist_foreach (tooltip_query_displays, (GFunc)g_object_unref, NULL);
+ g_slist_free (tooltip_query_displays);
+
+ tooltip_query_displays = NULL;
+ tooltip_query_id = 0;
+
+ return FALSE;
+}
+
+static void
+gtk_widget_queue_tooltip_query (GtkWidget *widget)
+{
+ GdkDisplay *display;
+
+ display = gtk_widget_get_display (widget);
+
+ if (!g_slist_find (tooltip_query_displays, display))
+ tooltip_query_displays = g_slist_prepend (tooltip_query_displays, g_object_ref (display));
+
+ if (tooltip_query_id == 0)
+ tooltip_query_id = gdk_threads_add_idle (tooltip_query_idle, NULL);
+}
+
/**
* gtk_widget_set_tooltip_text:
* @widget: a #GtkWidget
/**
* gtk_widget_set_tooltip_markup:
* @widget: a #GtkWidget
- * @markup: the contents of the tooltip for @widget, or %NULL
+ * @markup: (allow-none): the contents of the tooltip for @widget, or %NULL
*
* Sets @markup as the contents of the tooltip, which is marked up with
* the <link linkend="PangoMarkupFormat">Pango text markup language</link>.
return has_tooltip;
}
+/**
+ * gtk_widget_get_allocation:
+ * @widget: a #GtkWidget
+ * @allocation: (out): a pointer to a #GtkAllocation to copy to
+ *
+ * Retrieves the widget's allocation.
+ *
+ * Since: 2.18
+ */
+void
+gtk_widget_get_allocation (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (allocation != NULL);
+
+ *allocation = widget->allocation;
+}
+
+/**
+ * gtk_widget_set_allocation:
+ * @widget: a #GtkWidget
+ * @allocation: a pointer to a #GtkAllocation to copy from
+ *
+ * Sets the widget's allocation. This should not be used
+ * directly, but from within a widget's size_allocate method.
+ *
+ * Since: 2.18
+ */
+void
+gtk_widget_set_allocation (GtkWidget *widget,
+ const GtkAllocation *allocation)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (allocation != NULL);
+
+ widget->allocation = *allocation;
+}
+
+/**
+ * gtk_widget_get_requisition:
+ * @widget: a #GtkWidget
+ * @requisition: (out): a pointer to a #GtkRequisition to copy to
+ *
+ * Retrieves the widget's requisition.
+ *
+ * This function should only be used by widget implementations in
+ * order to figure whether the widget's requisition has actually
+ * changed after some internal state change (so that they can call
+ * gtk_widget_queue_resize() instead of gtk_widget_queue_draw()).
+ *
+ * Normally, gtk_widget_size_request() should be used.
+ *
+ * Since: 2.20
+ */
+void
+gtk_widget_get_requisition (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (requisition != NULL);
+
+ *requisition = widget->requisition;
+}
+
+/**
+ * gtk_widget_set_window:
+ * @widget: a #GtkWidget
+ * @window: a #GdkWindow
+ *
+ * Sets a widget's window. This function should only be used in a
+ * widget's GtkWidget::realize() implementation. The %window passed is
+ * usually either new window created with gdk_window_new(), or the
+ * window of its parent widget as returned by
+ * gtk_widget_get_parent_window().
+ *
+ * Widgets must indicate whether they will create their own #GdkWindow
+ * by calling gtk_widget_set_has_window(). This is usually done in the
+ * widget's init() function.
+ *
+ * Since: 2.18
+ */
+void
+gtk_widget_set_window (GtkWidget *widget,
+ GdkWindow *window)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
+
+ if (widget->window != window)
+ {
+ widget->window = window;
+ g_object_notify (G_OBJECT (widget), "window");
+ }
+}
+
/**
* gtk_widget_get_window:
* @widget: a #GtkWidget