1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
27 #undef GDK_DISABLE_DEPRECATED /* gdk_input_set_extension_events() */
33 #include "gtkcontainer.h"
34 #include "gtkaccelmap.h"
35 #include "gtkclipboard.h"
36 #include "gtkiconfactory.h"
39 #include "gtkmarshalers.h"
41 #include "gtkselection.h"
42 #include "gtksettings.h"
43 #include "gtksizegroup-private.h"
44 #include "gtkwidget.h"
45 #include "gtkwidgetprivate.h"
46 #include "gtkwindow.h"
47 #include "gtkbindings.h"
48 #include "gtkprivate.h"
50 #include "gdk/gdkprivate.h" /* Used in gtk_reset_shapes_recurse to avoid copy */
51 #include <gobject/gvaluecollector.h>
52 #include <gobject/gobjectnotifyqueue.c>
53 #include <cairo-gobject.h>
54 #include "gdk/gdkkeysyms.h"
55 #include "gtkaccessible.h"
56 #include "gtktooltip.h"
57 #include "gtkinvisible.h"
58 #include "gtkbuildable.h"
59 #include "gtkbuilderprivate.h"
60 #include "gtksizerequest.h"
66 * @Short_description: Base class for all widgets
69 * GtkWidget is the base class all widgets in GTK+ derive from. It manages the
70 * widget lifecycle, states and style.
72 * <refsect2 id="geometry-management">
73 * <title>Height-for-width Geometry Management</title>
75 * GTK+ uses a height-for-width (and width-for-height) geometry management
76 * system Height-for-width means that a widget can change how much
77 * vertical space it needs, depending on the amount of horizontal space
78 * that it is given (and similar for width-for-height). The most common
79 * example is a label that reflows to fill up the available width, wraps
80 * to fewer lines, and therefore needs less height.
82 * Height-for-width geometry management is implemented in GTK+ by way
83 * of five virtual methods:
86 * <term>#GtkWidgetClass.get_request_mode()</term>
88 * This allows a widget to tell it's parent container whether
89 * it preferrs to be allocated in %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH
90 * or %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
91 * %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH means the widget preferrs to
92 * have #GtkWidgetClass.get_preferred_width() called and then
93 * #GtkWidgetClass.get_preferred_height_for_width() and is the
94 * default return for unimplemented cases.
95 * However it's important to note (as described below) that any
96 * widget which trades height-for-width must respond properly to
97 * both #GtkSizeRequestModes since it might be queried in either
98 * orientation by it's parent container.
102 * <term>#GtkWidgetClass.get_preferred_width()</term>
104 * This is called by containers to obtain the minimum and
105 * natural width of a widget. A widget will never be allocated
106 * a width less than it's minimum and will only ever be allocated
107 * a width greater than the natural width once all of the said
108 * widget's siblings have received their natural widths.
109 * Furthermore a widget will only ever be allocated a width greater
110 * than it's natural width if it was configured to receive extra
111 * expand space from it's parent container.
115 * <term>#GtkWidgetClass.get_preferred_height()</term>
117 * This is called by containers to obtain the minimum and
118 * natural height of a widget.
119 * A widget that does not actually trade any height for width
120 * or width for height only has to implement these two virtual
121 * methods (#GtkWidgetClass.get_preferred_width() and
122 * #GtkWidgetClass.get_preferred_height()).
126 * <term>#GtkWidgetClass.get_preferred_height_for_width()</term>
128 * This is similar to #GtkWidgetClass.get_preferred_height() except
129 * that it is passed a contextual width to request height for. By
130 * implementing this virtual method it is possible for a #GtkLabel
131 * to tell it's parent how much height would be required if the
132 * label were to be allocated a said width.
136 * <term>#GtkWidgetClass.get_preferred_width_for_height()</term>
138 * This is analogous to #GtkWidgetClass.get_preferred_height_for_width()
139 * except that it operates in the oposite orientation. It's rare that
140 * a widget actually does %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT requests
141 * but can happen when for example; a widget or container gets additional
142 * columns to compensate for a smaller allocated height.
147 * There are some important things to keep in mind when implementing
148 * height-for-width and when using it in container implementations.
150 * The geometry management system will query a widget hierarchy in
151 * only one orientation at a time. When widgets are initially queried
152 * for their minimum sizes it is generally done in two initial passes
153 * in the #GtkSizeRequestMode chosen by the toplevel.
155 * For example, when queried in the normal
156 * %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH mode:
157 * First, the default minimum and natural width for each widget
158 * in the interface will be computed using gtk_width_get_preferred_width().
159 * Because the preferred widths for each container depends on the preferred
160 * widths of thier children, this information propagates up the hierarchy,
161 * and finally a minimum and natural width is determined for the entire
162 * toplevel. Next, the toplevel will use the minimum width to query for the
163 * minimum height contextual to that width using
164 * gtk_widget_get_preferred_height_for_width(), which will also be a highly
165 * recursive operation. The minimum height for the minimum width is normally
166 * used to set the minimum size constraint on the toplevel
167 * (unless gtk_window_set_geometry_hints() is explicitly used instead).
169 * After the toplevel window has initially requested it's size in both
170 * dimensions it can go on to allocate itself a reasonable size (or a size
171 * previously specified with gtk_window_set_default_size()). During the
172 * recursive allocation process it's important to note that request cycles
173 * will be recursively executed while container widgets allocate their children.
174 * Each container widget, once allocated a size will go on to first share the
175 * space in one orientation among its children and then request each child's
176 * height for their target allocated width or width for allocated height
177 * depending. In this way a #GtkWidget will typically be requested its size
178 * a number of times before actually being allocated a size, the size a
179 * widget is finally allocated can of course differ from the size it
180 * requested. For this reason; #GtkWidget caches a small number of results
181 * to avoid re-querying for the same sizes in one allocation cycle.
183 * See <link linkend="container-geometry-management">GtkContainer's
184 * geometry management section</link>
185 * to learn more about how height-for-width allocations are performed
186 * by container widgets.
188 * If a widget does move content around to smartly use up the
189 * allocated size, then it must support the request in both
190 * #GtkSizeRequestModes even if the widget in question only
191 * trades sizes in a single orientation.
193 * For instance, a #GtkLabel that does height-for-width word wrapping
194 * will not expect to have #GtkWidgetClass.get_preferred_height() called
195 * because that call is specific to a width-for-height request. In this
196 * case the label must return the heights required for it's own minimum
197 * possible width. By following this rule any widget that handles
198 * height-for-width or width-for-height requests will always be allocated
199 * at least enough space to fit its own content.
201 * Here are some examples of how a %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH widget
202 * generally deals with width-for-height requests, for #GtkWidgetClass.get_preferred_height()
204 * <programlisting><![CDATA[
206 * foo_widget_get_preferred_height (GtkWidget *widget, gint *min_height, gint *nat_height)
208 * if (i_am_in_height_for_width_mode)
212 * GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_width, NULL);
213 * GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width (widget, min_width,
214 * min_height, nat_height);
218 * ... some widgets do both, for instance if a GtkLabel is rotated to 90 degrees
219 * it will return the minimum and natural height for the rotated label here.
222 * ]]></programlisting>
224 * And in #GtkWidgetClass.get_preferred_width_for_height() it will simply return
225 * the minimum and natural width:
227 * <programlisting><![CDATA[
229 * foo_widget_get_preferred_width_for_height (GtkWidget *widget, gint for_height,
230 * gint *min_width, gint *nat_width)
232 * if (i_am_in_height_for_width_mode)
234 * GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, min_width, nat_width);
238 * ... again if a widget is sometimes operating in width-for-height mode
239 * (like a rotated GtkLabel) it can go ahead and do it's real width for
240 * height calculation here.
243 * ]]></programlisting>
245 * Often a widget needs to get its own request during size request or
246 * allocation, for example when computing height it may need to also
247 * compute width, or when deciding how to use an allocation the widget
248 * may need to know its natural size. In these cases, the widget should
249 * be careful to call its virtual methods directly, like this:
251 * <title>Widget calling its own size request method.</title>
253 * GTK_WIDGET_GET_CLASS(widget)->get_preferred_width (widget),
258 * It will not work to use the wrapper functions, such as
259 * gtk_widget_get_preferred_width(), inside your own size request
260 * implementation. These return a request adjusted by #GtkSizeGroup
261 * and by the #GtkWidgetClass.adjust_size_request() virtual method. If a
262 * widget used the wrappers inside its virtual method implementations,
263 * then the adjustments (such as widget margins) would be applied
264 * twice. GTK+ therefore does not allow this and will warn if you try
267 * Of course if you are getting the size request for
268 * <emphasis>another</emphasis> widget, such as a child of a
269 * container, you <emphasis>must</emphasis> use the wrapper APIs;
270 * otherwise, you would not properly consider widget margins,
271 * #GtkSizeGroup, and so forth.
274 * <refsect2 id="style-properties">
275 * <title>Style Properties</title>
277 * <structname>GtkWidget</structname> introduces <firstterm>style
278 * properties</firstterm> - these are basically object properties that are stored
279 * not on the object, but in the style object associated to the widget. Style
280 * properties are set in <link linkend="gtk-Resource-Files">resource files</link>.
281 * This mechanism is used for configuring such things as the location of the
282 * scrollbar arrows through the theme, giving theme authors more control over the
283 * look of applications without the need to write a theme engine in C.
286 * Use gtk_widget_class_install_style_property() to install style properties for
287 * a widget class, gtk_widget_class_find_style_property() or
288 * gtk_widget_class_list_style_properties() to get information about existing
289 * style properties and gtk_widget_style_get_property(), gtk_widget_style_get() or
290 * gtk_widget_style_get_valist() to obtain the value of a style property.
293 * <refsect2 id="GtkWidget-BUILDER-UI">
294 * <title>GtkWidget as GtkBuildable</title>
296 * The GtkWidget implementation of the GtkBuildable interface supports a
297 * custom <accelerator> element, which has attributes named key,
298 * modifiers and signal and allows to specify accelerators.
301 * <title>A UI definition fragment specifying an accelerator</title>
302 * <programlisting><![CDATA[
303 * <object class="GtkButton">
304 * <accelerator key="q" modifiers="GDK_CONTROL_MASK" signal="clicked"/>
306 * ]]></programlisting>
309 * In addition to accelerators, <structname>GtkWidget</structname> also support a
310 * custom <accessible> element, which supports actions and relations.
311 * Properties on the accessible implementation of an object can be set by accessing the
312 * internal child "accessible" of a <structname>GtkWidget</structname>.
315 * <title>A UI definition fragment specifying an accessible</title>
316 * <programlisting><![CDATA[
317 * <object class="GtkButton" id="label1"/>
318 * <property name="label">I am a Label for a Button</property>
320 * <object class="GtkButton" id="button1">
322 * <action action_name="click" translatable="yes">Click the button.</action>
323 * <relation target="label1" type="labelled-by"/>
325 * <child internal-child="accessible">
326 * <object class="AtkObject" id="a11y-button1">
327 * <property name="AtkObject::name">Clickable Button</property>
331 * ]]></programlisting>
336 #define WIDGET_CLASS(w) GTK_WIDGET_GET_CLASS (w)
337 #define INIT_PATH_SIZE (512)
339 struct _GtkWidgetPrivate
341 /* The state of the widget. There are actually only
342 * 5 widget states (defined in "gtkenums.h")
347 /* The saved state of the widget. When a widget's state
348 * is changed to GTK_STATE_INSENSITIVE via
349 * "gtk_widget_set_state" or "gtk_widget_set_sensitive"
350 * the old state is kept around in this field. The state
351 * will be restored once the widget gets sensitive again.
353 guint saved_state : 3;
357 guint in_destruction : 1;
360 guint composite_child : 1;
366 guint parent_sensitive : 1;
369 guint can_default : 1;
370 guint has_default : 1;
371 guint receives_default : 1;
375 guint user_style : 1;
376 guint app_paintable : 1;
377 guint double_buffered : 1;
378 guint redraw_on_alloc : 1;
379 guint no_show_all : 1;
380 guint child_visible : 1;
381 guint multidevice : 1;
382 guint has_shape_mask : 1;
383 guint in_reparent : 1;
384 guint resize_pending : 1;
385 guint alloc_needed : 1;
386 guint width_request_needed : 1;
387 guint height_request_needed : 1;
389 /* Expand-related flags */
390 guint need_compute_expand : 1; /* Need to recompute computed_[hv]_expand */
391 guint computed_hexpand : 1; /* computed results (composite of child flags) */
392 guint computed_vexpand : 1;
393 guint hexpand : 1; /* application-forced expand */
395 guint hexpand_set : 1; /* whether to use application-forced */
396 guint vexpand_set : 1; /* instead of computing from children */
398 /* The widget's name. If the widget does not have a name
399 * (the name is NULL), then its name (as returned by
400 * "gtk_widget_get_name") is its class's name.
401 * Among other things, the widget name is used to determine
402 * the style to use for a widget.
406 /* The style for the widget. The style contains the
407 * colors the widget should be drawn in for each state
408 * along with graphics contexts used to draw with and
409 * the font to use for text.
413 /* The widget's allocated size.
415 GtkAllocation allocation;
417 /* The widget's requested sizes */
418 SizeRequestCache requests;
420 /* The widget's window or its parent window if it does
421 * not have a window. (Which will be indicated by the
422 * GTK_NO_WINDOW flag being set).
426 /* The widget's parent.
457 BUTTON_RELEASE_EVENT,
472 PROPERTY_NOTIFY_EVENT,
473 SELECTION_CLEAR_EVENT,
474 SELECTION_REQUEST_EVENT,
475 SELECTION_NOTIFY_EVENT,
482 VISIBILITY_NOTIFY_EVENT,
496 ACCEL_CLOSURES_CHANGED,
519 PROP_RECEIVES_DEFAULT,
520 PROP_COMPOSITE_CHILD,
523 PROP_EXTENSION_EVENTS,
529 PROP_DOUBLE_BUFFERED,
544 typedef struct _GtkStateData GtkStateData;
549 guint state_restoration : 1;
550 guint parent_sensitive : 1;
551 guint use_forall : 1;
554 /* --- prototypes --- */
555 static void gtk_widget_class_init (GtkWidgetClass *klass);
556 static void gtk_widget_base_class_finalize (GtkWidgetClass *klass);
557 static void gtk_widget_init (GtkWidget *widget);
558 static void gtk_widget_set_property (GObject *object,
562 static void gtk_widget_get_property (GObject *object,
566 static void gtk_widget_dispose (GObject *object);
567 static void gtk_widget_real_destroy (GtkWidget *object);
568 static void gtk_widget_finalize (GObject *object);
569 static void gtk_widget_real_show (GtkWidget *widget);
570 static void gtk_widget_real_hide (GtkWidget *widget);
571 static void gtk_widget_real_map (GtkWidget *widget);
572 static void gtk_widget_real_unmap (GtkWidget *widget);
573 static void gtk_widget_real_realize (GtkWidget *widget);
574 static void gtk_widget_real_unrealize (GtkWidget *widget);
575 static void gtk_widget_real_size_request (GtkWidget *widget,
576 GtkRequisition *requisition);
577 static void gtk_widget_real_size_allocate (GtkWidget *widget,
578 GtkAllocation *allocation);
579 static void gtk_widget_real_style_set (GtkWidget *widget,
580 GtkStyle *previous_style);
581 static void gtk_widget_real_direction_changed(GtkWidget *widget,
582 GtkTextDirection previous_direction);
584 static void gtk_widget_real_grab_focus (GtkWidget *focus_widget);
585 static gboolean gtk_widget_real_query_tooltip (GtkWidget *widget,
588 gboolean keyboard_tip,
589 GtkTooltip *tooltip);
590 static gboolean gtk_widget_real_show_help (GtkWidget *widget,
591 GtkWidgetHelpType help_type);
593 static void gtk_widget_dispatch_child_properties_changed (GtkWidget *object,
595 GParamSpec **pspecs);
596 static gboolean gtk_widget_real_key_press_event (GtkWidget *widget,
598 static gboolean gtk_widget_real_key_release_event (GtkWidget *widget,
600 static gboolean gtk_widget_real_focus_in_event (GtkWidget *widget,
601 GdkEventFocus *event);
602 static gboolean gtk_widget_real_focus_out_event (GtkWidget *widget,
603 GdkEventFocus *event);
604 static gboolean gtk_widget_real_focus (GtkWidget *widget,
605 GtkDirectionType direction);
606 static void gtk_widget_real_move_focus (GtkWidget *widget,
607 GtkDirectionType direction);
608 static gboolean gtk_widget_real_keynav_failed (GtkWidget *widget,
609 GtkDirectionType direction);
610 static PangoContext* gtk_widget_peek_pango_context (GtkWidget *widget);
611 static void gtk_widget_update_pango_context (GtkWidget *widget);
612 static void gtk_widget_propagate_state (GtkWidget *widget,
614 static void gtk_widget_reset_rc_style (GtkWidget *widget);
615 static void gtk_widget_set_style_internal (GtkWidget *widget,
617 gboolean initial_emission);
618 static gint gtk_widget_event_internal (GtkWidget *widget,
620 static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget,
621 gboolean group_cycling);
622 static void gtk_widget_real_get_width (GtkWidget *widget,
625 static void gtk_widget_real_get_height (GtkWidget *widget,
628 static void gtk_widget_real_get_height_for_width (GtkWidget *widget,
630 gint *minimum_height,
631 gint *natural_height);
632 static void gtk_widget_real_get_width_for_height (GtkWidget *widget,
635 gint *natural_width);
636 static const GtkWidgetAuxInfo* _gtk_widget_get_aux_info_or_defaults (GtkWidget *widget);
637 static void gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info);
638 static AtkObject* gtk_widget_real_get_accessible (GtkWidget *widget);
639 static void gtk_widget_accessible_interface_init (AtkImplementorIface *iface);
640 static AtkObject* gtk_widget_ref_accessible (AtkImplementor *implementor);
641 static void gtk_widget_invalidate_widget_windows (GtkWidget *widget,
642 cairo_region_t *region);
643 static GdkScreen * gtk_widget_get_screen_unchecked (GtkWidget *widget);
644 static void gtk_widget_queue_shallow_draw (GtkWidget *widget);
645 static gboolean gtk_widget_real_can_activate_accel (GtkWidget *widget,
648 static void gtk_widget_real_set_has_tooltip (GtkWidget *widget,
649 gboolean has_tooltip,
651 static void gtk_widget_buildable_interface_init (GtkBuildableIface *iface);
652 static void gtk_widget_buildable_set_name (GtkBuildable *buildable,
654 static const gchar * gtk_widget_buildable_get_name (GtkBuildable *buildable);
655 static GObject * gtk_widget_buildable_get_internal_child (GtkBuildable *buildable,
657 const gchar *childname);
658 static void gtk_widget_buildable_set_buildable_property (GtkBuildable *buildable,
661 const GValue *value);
662 static gboolean gtk_widget_buildable_custom_tag_start (GtkBuildable *buildable,
665 const gchar *tagname,
666 GMarkupParser *parser,
668 static void gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
671 const gchar *tagname,
673 static void gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
674 GtkBuilder *builder);
676 static void gtk_widget_real_get_width (GtkWidget *widget,
679 static void gtk_widget_real_get_height (GtkWidget *widget,
683 static void gtk_widget_queue_tooltip_query (GtkWidget *widget);
686 static void gtk_widget_real_adjust_size_request (GtkWidget *widget,
687 GtkOrientation orientation,
690 static void gtk_widget_real_adjust_size_allocation (GtkWidget *widget,
691 GtkOrientation orientation,
694 gint *allocated_size);
696 static void gtk_widget_set_usize_internal (GtkWidget *widget,
699 GtkQueueResizeFlags flags);
701 static void gtk_widget_add_events_internal (GtkWidget *widget,
705 /* --- variables --- */
706 static gpointer gtk_widget_parent_class = NULL;
707 static guint widget_signals[LAST_SIGNAL] = { 0 };
708 static GtkStyle *gtk_default_style = NULL;
709 static guint composite_child_stack = 0;
710 static GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR;
711 static GParamSpecPool *style_property_spec_pool = NULL;
713 static GQuark quark_property_parser = 0;
714 static GQuark quark_aux_info = 0;
715 static GQuark quark_accel_path = 0;
716 static GQuark quark_accel_closures = 0;
717 static GQuark quark_event_mask = 0;
718 static GQuark quark_device_event_mask = 0;
719 static GQuark quark_extension_event_mode = 0;
720 static GQuark quark_parent_window = 0;
721 static GQuark quark_pointer_window = 0;
722 static GQuark quark_shape_info = 0;
723 static GQuark quark_input_shape_info = 0;
724 static GQuark quark_pango_context = 0;
725 static GQuark quark_rc_style = 0;
726 static GQuark quark_accessible_object = 0;
727 static GQuark quark_mnemonic_labels = 0;
728 static GQuark quark_tooltip_markup = 0;
729 static GQuark quark_has_tooltip = 0;
730 static GQuark quark_tooltip_window = 0;
731 static GQuark quark_visual = 0;
732 GParamSpecPool *_gtk_widget_child_property_pool = NULL;
733 GObjectNotifyContext *_gtk_widget_child_property_notify_context = NULL;
735 /* --- functions --- */
737 gtk_widget_get_type (void)
739 static GType widget_type = 0;
741 if (G_UNLIKELY (widget_type == 0))
743 const GTypeInfo widget_info =
745 sizeof (GtkWidgetClass),
746 NULL, /* base_init */
747 (GBaseFinalizeFunc) gtk_widget_base_class_finalize,
748 (GClassInitFunc) gtk_widget_class_init,
749 NULL, /* class_finalize */
750 NULL, /* class_init */
753 (GInstanceInitFunc) gtk_widget_init,
754 NULL, /* value_table */
757 const GInterfaceInfo accessibility_info =
759 (GInterfaceInitFunc) gtk_widget_accessible_interface_init,
760 (GInterfaceFinalizeFunc) NULL,
761 NULL /* interface data */
764 const GInterfaceInfo buildable_info =
766 (GInterfaceInitFunc) gtk_widget_buildable_interface_init,
767 (GInterfaceFinalizeFunc) NULL,
768 NULL /* interface data */
771 widget_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, "GtkWidget",
772 &widget_info, G_TYPE_FLAG_ABSTRACT);
774 g_type_add_interface_static (widget_type, ATK_TYPE_IMPLEMENTOR,
775 &accessibility_info) ;
776 g_type_add_interface_static (widget_type, GTK_TYPE_BUILDABLE,
784 child_property_notify_dispatcher (GObject *object,
788 GTK_WIDGET_GET_CLASS (object)->dispatch_child_properties_changed (GTK_WIDGET (object), n_pspecs, pspecs);
791 /* We guard against the draw signal callbacks modifying the state of the
792 * cairo context by surounding it with save/restore.
793 * Maybe we should also cairo_new_path() just to be sure?
796 gtk_widget_draw_marshaller (GClosure *closure,
797 GValue *return_value,
798 guint n_param_values,
799 const GValue *param_values,
800 gpointer invocation_hint,
801 gpointer marshal_data)
803 cairo_t *cr = g_value_get_boxed (¶m_values[1]);
807 _gtk_marshal_BOOLEAN__BOXED (closure,
818 gtk_widget_class_init (GtkWidgetClass *klass)
820 static GObjectNotifyContext cpn_context = { 0, NULL, NULL };
821 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
822 GtkBindingSet *binding_set;
824 gtk_widget_parent_class = g_type_class_peek_parent (klass);
826 quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser");
827 quark_aux_info = g_quark_from_static_string ("gtk-aux-info");
828 quark_accel_path = g_quark_from_static_string ("gtk-accel-path");
829 quark_accel_closures = g_quark_from_static_string ("gtk-accel-closures");
830 quark_event_mask = g_quark_from_static_string ("gtk-event-mask");
831 quark_device_event_mask = g_quark_from_static_string ("gtk-device-event-mask");
832 quark_extension_event_mode = g_quark_from_static_string ("gtk-extension-event-mode");
833 quark_parent_window = g_quark_from_static_string ("gtk-parent-window");
834 quark_pointer_window = g_quark_from_static_string ("gtk-pointer-window");
835 quark_shape_info = g_quark_from_static_string ("gtk-shape-info");
836 quark_input_shape_info = g_quark_from_static_string ("gtk-input-shape-info");
837 quark_pango_context = g_quark_from_static_string ("gtk-pango-context");
838 quark_rc_style = g_quark_from_static_string ("gtk-rc-style");
839 quark_accessible_object = g_quark_from_static_string ("gtk-accessible-object");
840 quark_mnemonic_labels = g_quark_from_static_string ("gtk-mnemonic-labels");
841 quark_tooltip_markup = g_quark_from_static_string ("gtk-tooltip-markup");
842 quark_has_tooltip = g_quark_from_static_string ("gtk-has-tooltip");
843 quark_tooltip_window = g_quark_from_static_string ("gtk-tooltip-window");
844 quark_visual = g_quark_from_static_string ("gtk-widget-visual");
846 style_property_spec_pool = g_param_spec_pool_new (FALSE);
847 _gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE);
848 cpn_context.quark_notify_queue = g_quark_from_static_string ("GtkWidget-child-property-notify-queue");
849 cpn_context.dispatcher = child_property_notify_dispatcher;
850 _gtk_widget_child_property_notify_context = &cpn_context;
852 gobject_class->dispose = gtk_widget_dispose;
853 gobject_class->finalize = gtk_widget_finalize;
854 gobject_class->set_property = gtk_widget_set_property;
855 gobject_class->get_property = gtk_widget_get_property;
857 klass->destroy = gtk_widget_real_destroy;
859 klass->activate_signal = 0;
860 klass->dispatch_child_properties_changed = gtk_widget_dispatch_child_properties_changed;
861 klass->show = gtk_widget_real_show;
862 klass->show_all = gtk_widget_show;
863 klass->hide = gtk_widget_real_hide;
864 klass->map = gtk_widget_real_map;
865 klass->unmap = gtk_widget_real_unmap;
866 klass->realize = gtk_widget_real_realize;
867 klass->unrealize = gtk_widget_real_unrealize;
868 klass->size_request = gtk_widget_real_size_request;
869 klass->size_allocate = gtk_widget_real_size_allocate;
870 klass->get_preferred_width = gtk_widget_real_get_width;
871 klass->get_preferred_height = gtk_widget_real_get_height;
872 klass->get_preferred_width_for_height = gtk_widget_real_get_width_for_height;
873 klass->get_preferred_height_for_width = gtk_widget_real_get_height_for_width;
874 klass->state_changed = NULL;
875 klass->parent_set = NULL;
876 klass->hierarchy_changed = NULL;
877 klass->style_set = gtk_widget_real_style_set;
878 klass->direction_changed = gtk_widget_real_direction_changed;
879 klass->grab_notify = NULL;
880 klass->child_notify = NULL;
882 klass->mnemonic_activate = gtk_widget_real_mnemonic_activate;
883 klass->grab_focus = gtk_widget_real_grab_focus;
884 klass->focus = gtk_widget_real_focus;
885 klass->move_focus = gtk_widget_real_move_focus;
886 klass->keynav_failed = gtk_widget_real_keynav_failed;
888 klass->button_press_event = NULL;
889 klass->button_release_event = NULL;
890 klass->motion_notify_event = NULL;
891 klass->delete_event = NULL;
892 klass->destroy_event = NULL;
893 klass->key_press_event = gtk_widget_real_key_press_event;
894 klass->key_release_event = gtk_widget_real_key_release_event;
895 klass->enter_notify_event = NULL;
896 klass->leave_notify_event = NULL;
897 klass->configure_event = NULL;
898 klass->focus_in_event = gtk_widget_real_focus_in_event;
899 klass->focus_out_event = gtk_widget_real_focus_out_event;
900 klass->map_event = NULL;
901 klass->unmap_event = NULL;
902 klass->window_state_event = NULL;
903 klass->property_notify_event = _gtk_selection_property_notify;
904 klass->selection_clear_event = _gtk_selection_clear;
905 klass->selection_request_event = _gtk_selection_request;
906 klass->selection_notify_event = _gtk_selection_notify;
907 klass->selection_received = NULL;
908 klass->proximity_in_event = NULL;
909 klass->proximity_out_event = NULL;
910 klass->drag_begin = NULL;
911 klass->drag_end = NULL;
912 klass->drag_data_delete = NULL;
913 klass->drag_leave = NULL;
914 klass->drag_motion = NULL;
915 klass->drag_drop = NULL;
916 klass->drag_data_received = NULL;
917 klass->screen_changed = NULL;
918 klass->can_activate_accel = gtk_widget_real_can_activate_accel;
919 klass->grab_broken_event = NULL;
920 klass->query_tooltip = gtk_widget_real_query_tooltip;
922 klass->show_help = gtk_widget_real_show_help;
924 /* Accessibility support */
925 klass->get_accessible = gtk_widget_real_get_accessible;
927 klass->no_expose_event = NULL;
929 klass->adjust_size_request = gtk_widget_real_adjust_size_request;
930 klass->adjust_size_allocation = gtk_widget_real_adjust_size_allocation;
932 g_object_class_install_property (gobject_class,
934 g_param_spec_string ("name",
936 P_("The name of the widget"),
938 GTK_PARAM_READWRITE));
939 g_object_class_install_property (gobject_class,
941 g_param_spec_object ("parent",
943 P_("The parent widget of this widget. Must be a Container widget"),
945 GTK_PARAM_READWRITE));
947 g_object_class_install_property (gobject_class,
949 g_param_spec_int ("width-request",
951 P_("Override for width request of the widget, or -1 if natural request should be used"),
955 GTK_PARAM_READWRITE));
956 g_object_class_install_property (gobject_class,
958 g_param_spec_int ("height-request",
959 P_("Height request"),
960 P_("Override for height request of the widget, or -1 if natural request should be used"),
964 GTK_PARAM_READWRITE));
965 g_object_class_install_property (gobject_class,
967 g_param_spec_boolean ("visible",
969 P_("Whether the widget is visible"),
971 GTK_PARAM_READWRITE));
972 g_object_class_install_property (gobject_class,
974 g_param_spec_boolean ("sensitive",
976 P_("Whether the widget responds to input"),
978 GTK_PARAM_READWRITE));
979 g_object_class_install_property (gobject_class,
981 g_param_spec_boolean ("app-paintable",
982 P_("Application paintable"),
983 P_("Whether the application will paint directly on the widget"),
985 GTK_PARAM_READWRITE));
986 g_object_class_install_property (gobject_class,
988 g_param_spec_boolean ("can-focus",
990 P_("Whether the widget can accept the input focus"),
992 GTK_PARAM_READWRITE));
993 g_object_class_install_property (gobject_class,
995 g_param_spec_boolean ("has-focus",
997 P_("Whether the widget has the input focus"),
999 GTK_PARAM_READWRITE));
1000 g_object_class_install_property (gobject_class,
1002 g_param_spec_boolean ("is-focus",
1004 P_("Whether the widget is the focus widget within the toplevel"),
1006 GTK_PARAM_READWRITE));
1007 g_object_class_install_property (gobject_class,
1009 g_param_spec_boolean ("can-default",
1011 P_("Whether the widget can be the default widget"),
1013 GTK_PARAM_READWRITE));
1014 g_object_class_install_property (gobject_class,
1016 g_param_spec_boolean ("has-default",
1018 P_("Whether the widget is the default widget"),
1020 GTK_PARAM_READWRITE));
1021 g_object_class_install_property (gobject_class,
1022 PROP_RECEIVES_DEFAULT,
1023 g_param_spec_boolean ("receives-default",
1024 P_("Receives default"),
1025 P_("If TRUE, the widget will receive the default action when it is focused"),
1027 GTK_PARAM_READWRITE));
1028 g_object_class_install_property (gobject_class,
1029 PROP_COMPOSITE_CHILD,
1030 g_param_spec_boolean ("composite-child",
1031 P_("Composite child"),
1032 P_("Whether the widget is part of a composite widget"),
1034 GTK_PARAM_READABLE));
1035 g_object_class_install_property (gobject_class,
1037 g_param_spec_object ("style",
1039 P_("The style of the widget, which contains information about how it will look (colors etc)"),
1041 GTK_PARAM_READWRITE));
1042 g_object_class_install_property (gobject_class,
1044 g_param_spec_flags ("events",
1046 P_("The event mask that decides what kind of GdkEvents this widget gets"),
1047 GDK_TYPE_EVENT_MASK,
1049 GTK_PARAM_READWRITE));
1050 g_object_class_install_property (gobject_class,
1051 PROP_EXTENSION_EVENTS,
1052 g_param_spec_enum ("extension-events",
1053 P_("Extension events"),
1054 P_("The mask that decides what kind of extension events this widget gets"),
1055 GDK_TYPE_EXTENSION_MODE,
1056 GDK_EXTENSION_EVENTS_NONE,
1057 GTK_PARAM_READWRITE));
1058 g_object_class_install_property (gobject_class,
1060 g_param_spec_boolean ("no-show-all",
1062 P_("Whether gtk_widget_show_all() should not affect this widget"),
1064 GTK_PARAM_READWRITE));
1067 * GtkWidget:has-tooltip:
1069 * Enables or disables the emission of #GtkWidget::query-tooltip on @widget.
1070 * A value of %TRUE indicates that @widget can have a tooltip, in this case
1071 * the widget will be queried using #GtkWidget::query-tooltip to determine
1072 * whether it will provide a tooltip or not.
1074 * Note that setting this property to %TRUE for the first time will change
1075 * the event masks of the GdkWindows of this widget to include leave-notify
1076 * and motion-notify events. This cannot and will not be undone when the
1077 * property is set to %FALSE again.
1081 g_object_class_install_property (gobject_class,
1083 g_param_spec_boolean ("has-tooltip",
1085 P_("Whether this widget has a tooltip"),
1087 GTK_PARAM_READWRITE));
1089 * GtkWidget:tooltip-text:
1091 * Sets the text of tooltip to be the given string.
1093 * Also see gtk_tooltip_set_text().
1095 * This is a convenience property which will take care of getting the
1096 * tooltip shown if the given string is not %NULL: #GtkWidget:has-tooltip
1097 * will automatically be set to %TRUE and there will be taken care of
1098 * #GtkWidget::query-tooltip in the default signal handler.
1102 g_object_class_install_property (gobject_class,
1104 g_param_spec_string ("tooltip-text",
1106 P_("The contents of the tooltip for this widget"),
1108 GTK_PARAM_READWRITE));
1110 * GtkWidget:tooltip-markup:
1112 * Sets the text of tooltip to be the given string, which is marked up
1113 * with the <link linkend="PangoMarkupFormat">Pango text markup language</link>.
1114 * Also see gtk_tooltip_set_markup().
1116 * This is a convenience property which will take care of getting the
1117 * tooltip shown if the given string is not %NULL: #GtkWidget:has-tooltip
1118 * will automatically be set to %TRUE and there will be taken care of
1119 * #GtkWidget::query-tooltip in the default signal handler.
1123 g_object_class_install_property (gobject_class,
1124 PROP_TOOLTIP_MARKUP,
1125 g_param_spec_string ("tooltip-markup",
1126 P_("Tooltip markup"),
1127 P_("The contents of the tooltip for this widget"),
1129 GTK_PARAM_READWRITE));
1134 * The widget's window if it is realized, %NULL otherwise.
1138 g_object_class_install_property (gobject_class,
1140 g_param_spec_object ("window",
1142 P_("The widget's window if it is realized"),
1144 GTK_PARAM_READABLE));
1147 * GtkWidget:double-buffered
1149 * Whether the widget is double buffered.
1153 g_object_class_install_property (gobject_class,
1154 PROP_DOUBLE_BUFFERED,
1155 g_param_spec_boolean ("double-buffered",
1156 P_("Double Buffered"),
1157 P_("Whether the widget is double buffered"),
1159 GTK_PARAM_READWRITE));
1164 * How to distribute horizontal space if widget gets extra space, see #GtkAlign
1168 g_object_class_install_property (gobject_class,
1170 g_param_spec_enum ("halign",
1171 P_("Horizontal Alignment"),
1172 P_("How to position in extra horizontal space"),
1175 GTK_PARAM_READWRITE));
1180 * How to distribute vertical space if widget gets extra space, see #GtkAlign
1184 g_object_class_install_property (gobject_class,
1186 g_param_spec_enum ("valign",
1187 P_("Vertical Alignment"),
1188 P_("How to position in extra vertical space"),
1191 GTK_PARAM_READWRITE));
1194 * GtkWidget:margin-left
1196 * Margin on left side of widget.
1198 * This property adds margin outside of the widget's normal size
1199 * request, the margin will be added in addition to the size from
1200 * gtk_widget_set_size_request() for example.
1204 g_object_class_install_property (gobject_class,
1206 g_param_spec_int ("margin-left",
1207 P_("Margin on Left"),
1208 P_("Pixels of extra space on the left side"),
1212 GTK_PARAM_READWRITE));
1215 * GtkWidget:margin-right
1217 * Margin on right side of widget.
1219 * This property adds margin outside of the widget's normal size
1220 * request, the margin will be added in addition to the size from
1221 * gtk_widget_set_size_request() for example.
1225 g_object_class_install_property (gobject_class,
1227 g_param_spec_int ("margin-right",
1228 P_("Margin on Right"),
1229 P_("Pixels of extra space on the right side"),
1233 GTK_PARAM_READWRITE));
1236 * GtkWidget:margin-top
1238 * Margin on top side of widget.
1240 * This property adds margin outside of the widget's normal size
1241 * request, the margin will be added in addition to the size from
1242 * gtk_widget_set_size_request() for example.
1246 g_object_class_install_property (gobject_class,
1248 g_param_spec_int ("margin-top",
1249 P_("Margin on Top"),
1250 P_("Pixels of extra space on the top side"),
1254 GTK_PARAM_READWRITE));
1257 * GtkWidget:margin-bottom
1259 * Margin on bottom side of widget.
1261 * This property adds margin outside of the widget's normal size
1262 * request, the margin will be added in addition to the size from
1263 * gtk_widget_set_size_request() for example.
1267 g_object_class_install_property (gobject_class,
1269 g_param_spec_int ("margin-bottom",
1270 P_("Margin on Bottom"),
1271 P_("Pixels of extra space on the bottom side"),
1275 GTK_PARAM_READWRITE));
1280 * Sets all four sides' margin at once. If read, returns max
1281 * margin on any side.
1285 g_object_class_install_property (gobject_class,
1287 g_param_spec_int ("margin",
1289 P_("Pixels of extra space on all four sides"),
1293 GTK_PARAM_READWRITE));
1296 * GtkWidget::destroy:
1297 * @object: the object which received the signal
1299 * Signals that all holders of a reference to the widget should release
1300 * the reference that they hold. May result in finalization of the widget
1301 * if all references are released.
1303 widget_signals[DESTROY] =
1304 g_signal_new (I_("destroy"),
1305 G_TYPE_FROM_CLASS (gobject_class),
1306 G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
1307 G_STRUCT_OFFSET (GtkWidgetClass, destroy),
1309 _gtk_marshal_VOID__VOID,
1315 * Whether to expand horizontally. See gtk_widget_set_hexpand().
1319 g_object_class_install_property (gobject_class,
1321 g_param_spec_boolean ("hexpand",
1322 P_("Horizontal Expand"),
1323 P_("Whether widget wants more horizontal space"),
1325 GTK_PARAM_READWRITE));
1328 * GtkWidget:hexpand-set
1330 * Whether to use the GtkWidget:hexpand property. See gtk_widget_get_hexpand_set().
1334 g_object_class_install_property (gobject_class,
1336 g_param_spec_boolean ("hexpand-set",
1337 P_("Horizontal Expand Set"),
1338 P_("Whether to use the hexpand property"),
1340 GTK_PARAM_READWRITE));
1345 * Whether to expand vertically. See gtk_widget_set_vexpand().
1349 g_object_class_install_property (gobject_class,
1351 g_param_spec_boolean ("vexpand",
1352 P_("Vertical Expand"),
1353 P_("Whether widget wants more vertical space"),
1355 GTK_PARAM_READWRITE));
1358 * GtkWidget:vexpand-set
1360 * Whether to use the GtkWidget:vexpand property. See gtk_widget_get_vexpand_set().
1364 g_object_class_install_property (gobject_class,
1366 g_param_spec_boolean ("vexpand-set",
1367 P_("Vertical Expand Set"),
1368 P_("Whether to use the vexpand property"),
1370 GTK_PARAM_READWRITE));
1375 * Whether to expand in both directions. Setting this sets both GtkWidget:hexpand and GtkWidget:vexpand
1379 g_object_class_install_property (gobject_class,
1381 g_param_spec_boolean ("expand",
1383 P_("Whether widget wants to expand in both directions"),
1385 GTK_PARAM_READWRITE));
1389 * @widget: the object which received the signal.
1391 widget_signals[SHOW] =
1392 g_signal_new (I_("show"),
1393 G_TYPE_FROM_CLASS (gobject_class),
1395 G_STRUCT_OFFSET (GtkWidgetClass, show),
1397 _gtk_marshal_VOID__VOID,
1402 * @widget: the object which received the signal.
1404 widget_signals[HIDE] =
1405 g_signal_new (I_("hide"),
1406 G_TYPE_FROM_CLASS (gobject_class),
1408 G_STRUCT_OFFSET (GtkWidgetClass, hide),
1410 _gtk_marshal_VOID__VOID,
1415 * @widget: the object which received the signal.
1417 widget_signals[MAP] =
1418 g_signal_new (I_("map"),
1419 G_TYPE_FROM_CLASS (gobject_class),
1421 G_STRUCT_OFFSET (GtkWidgetClass, map),
1423 _gtk_marshal_VOID__VOID,
1428 * @widget: the object which received the signal.
1430 widget_signals[UNMAP] =
1431 g_signal_new (I_("unmap"),
1432 G_TYPE_FROM_CLASS (gobject_class),
1434 G_STRUCT_OFFSET (GtkWidgetClass, unmap),
1436 _gtk_marshal_VOID__VOID,
1440 * GtkWidget::realize:
1441 * @widget: the object which received the signal.
1443 widget_signals[REALIZE] =
1444 g_signal_new (I_("realize"),
1445 G_TYPE_FROM_CLASS (gobject_class),
1447 G_STRUCT_OFFSET (GtkWidgetClass, realize),
1449 _gtk_marshal_VOID__VOID,
1453 * GtkWidget::unrealize:
1454 * @widget: the object which received the signal.
1456 widget_signals[UNREALIZE] =
1457 g_signal_new (I_("unrealize"),
1458 G_TYPE_FROM_CLASS (gobject_class),
1460 G_STRUCT_OFFSET (GtkWidgetClass, unrealize),
1462 _gtk_marshal_VOID__VOID,
1466 * GtkWidget::size-request:
1467 * @widget: the object which received the signal.
1470 widget_signals[SIZE_REQUEST] =
1471 g_signal_new (I_("size-request"),
1472 G_TYPE_FROM_CLASS (gobject_class),
1474 G_STRUCT_OFFSET (GtkWidgetClass, size_request),
1476 _gtk_marshal_VOID__BOXED,
1478 GTK_TYPE_REQUISITION | G_SIGNAL_TYPE_STATIC_SCOPE);
1481 * GtkWidget::size-allocate:
1482 * @widget: the object which received the signal.
1485 widget_signals[SIZE_ALLOCATE] =
1486 g_signal_new (I_("size-allocate"),
1487 G_TYPE_FROM_CLASS (gobject_class),
1489 G_STRUCT_OFFSET (GtkWidgetClass, size_allocate),
1491 _gtk_marshal_VOID__BOXED,
1493 GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
1496 * GtkWidget::state-changed:
1497 * @widget: the object which received the signal.
1498 * @state: the previous state
1500 * The ::state-changed signal is emitted when the widget state changes.
1501 * See gtk_widget_get_state().
1503 widget_signals[STATE_CHANGED] =
1504 g_signal_new (I_("state-changed"),
1505 G_TYPE_FROM_CLASS (gobject_class),
1507 G_STRUCT_OFFSET (GtkWidgetClass, state_changed),
1509 _gtk_marshal_VOID__ENUM,
1511 GTK_TYPE_STATE_TYPE);
1514 * GtkWidget::parent-set:
1515 * @widget: the object on which the signal is emitted
1516 * @old_parent: (allow-none): the previous parent, or %NULL if the widget
1517 * just got its initial parent.
1519 * The ::parent-set signal is emitted when a new parent
1520 * has been set on a widget.
1522 widget_signals[PARENT_SET] =
1523 g_signal_new (I_("parent-set"),
1524 G_TYPE_FROM_CLASS (gobject_class),
1526 G_STRUCT_OFFSET (GtkWidgetClass, parent_set),
1528 _gtk_marshal_VOID__OBJECT,
1533 * GtkWidget::hierarchy-changed:
1534 * @widget: the object on which the signal is emitted
1535 * @previous_toplevel: (allow-none): the previous toplevel ancestor, or %NULL
1536 * if the widget was previously unanchored
1538 * The ::hierarchy-changed signal is emitted when the
1539 * anchored state of a widget changes. A widget is
1540 * <firstterm>anchored</firstterm> when its toplevel
1541 * ancestor is a #GtkWindow. This signal is emitted when
1542 * a widget changes from un-anchored to anchored or vice-versa.
1544 widget_signals[HIERARCHY_CHANGED] =
1545 g_signal_new (I_("hierarchy-changed"),
1546 G_TYPE_FROM_CLASS (gobject_class),
1548 G_STRUCT_OFFSET (GtkWidgetClass, hierarchy_changed),
1550 _gtk_marshal_VOID__OBJECT,
1555 * GtkWidget::style-set:
1556 * @widget: the object on which the signal is emitted
1557 * @previous_style: (allow-none): the previous style, or %NULL if the widget
1558 * just got its initial style
1560 * The ::style-set signal is emitted when a new style has been set
1561 * on a widget. Note that style-modifying functions like
1562 * gtk_widget_modify_base() also cause this signal to be emitted.
1564 widget_signals[STYLE_SET] =
1565 g_signal_new (I_("style-set"),
1566 G_TYPE_FROM_CLASS (gobject_class),
1568 G_STRUCT_OFFSET (GtkWidgetClass, style_set),
1570 _gtk_marshal_VOID__OBJECT,
1575 * GtkWidget::direction-changed:
1576 * @widget: the object on which the signal is emitted
1577 * @previous_direction: the previous text direction of @widget
1579 * The ::direction-changed signal is emitted when the text direction
1580 * of a widget changes.
1582 widget_signals[DIRECTION_CHANGED] =
1583 g_signal_new (I_("direction-changed"),
1584 G_TYPE_FROM_CLASS (gobject_class),
1586 G_STRUCT_OFFSET (GtkWidgetClass, direction_changed),
1588 _gtk_marshal_VOID__ENUM,
1590 GTK_TYPE_TEXT_DIRECTION);
1593 * GtkWidget::grab-notify:
1594 * @widget: the object which received the signal
1595 * @was_grabbed: %FALSE if the widget becomes shadowed, %TRUE
1596 * if it becomes unshadowed
1598 * The ::grab-notify signal is emitted when a widget becomes
1599 * shadowed by a GTK+ grab (not a pointer or keyboard grab) on
1600 * another widget, or when it becomes unshadowed due to a grab
1603 * A widget is shadowed by a gtk_grab_add() when the topmost
1604 * grab widget in the grab stack of its window group is not
1607 widget_signals[GRAB_NOTIFY] =
1608 g_signal_new (I_("grab-notify"),
1609 G_TYPE_FROM_CLASS (gobject_class),
1611 G_STRUCT_OFFSET (GtkWidgetClass, grab_notify),
1613 _gtk_marshal_VOID__BOOLEAN,
1618 * GtkWidget::child-notify:
1619 * @widget: the object which received the signal
1620 * @pspec: the #GParamSpec of the changed child property
1622 * The ::child-notify signal is emitted for each
1623 * <link linkend="child-properties">child property</link> that has
1624 * changed on an object. The signal's detail holds the property name.
1626 widget_signals[CHILD_NOTIFY] =
1627 g_signal_new (I_("child-notify"),
1628 G_TYPE_FROM_CLASS (gobject_class),
1629 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS,
1630 G_STRUCT_OFFSET (GtkWidgetClass, child_notify),
1632 g_cclosure_marshal_VOID__PARAM,
1638 * @widget: the object which received the signal
1639 * @cr: the cairo context to draw to
1641 * This signal is emitted when a widget is supposed to render itself.
1642 * The @widget's top left corner must be painted at the origin of
1643 * the passed in context and be sized to the values returned by
1644 * gtk_widget_get_allocated_width() and
1645 * gtk_widget_get_allocated_height().
1647 * Signal handlers connected to this signal can modify the cairo
1648 * context passed as @cr in any way they like and don't need to
1649 * restore it. The signal emission takes care of calling cairo_save()
1650 * before and cairo_restore() after invoking the handler.
1652 widget_signals[DRAW] =
1653 g_signal_new (I_("draw"),
1654 G_TYPE_FROM_CLASS (gobject_class),
1656 G_STRUCT_OFFSET (GtkWidgetClass, draw),
1657 _gtk_boolean_handled_accumulator, NULL,
1658 gtk_widget_draw_marshaller,
1660 CAIRO_GOBJECT_TYPE_CONTEXT);
1663 * GtkWidget::mnemonic-activate:
1664 * @widget: the object which received the signal.
1667 widget_signals[MNEMONIC_ACTIVATE] =
1668 g_signal_new (I_("mnemonic-activate"),
1669 G_TYPE_FROM_CLASS (gobject_class),
1671 G_STRUCT_OFFSET (GtkWidgetClass, mnemonic_activate),
1672 _gtk_boolean_handled_accumulator, NULL,
1673 _gtk_marshal_BOOLEAN__BOOLEAN,
1678 * GtkWidget::grab-focus:
1679 * @widget: the object which received the signal.
1681 widget_signals[GRAB_FOCUS] =
1682 g_signal_new (I_("grab-focus"),
1683 G_TYPE_FROM_CLASS (gobject_class),
1684 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
1685 G_STRUCT_OFFSET (GtkWidgetClass, grab_focus),
1687 _gtk_marshal_VOID__VOID,
1692 * @widget: the object which received the signal.
1695 * Returns: %TRUE to stop other handlers from being invoked for the event. %FALSE to propagate the event further.
1697 widget_signals[FOCUS] =
1698 g_signal_new (I_("focus"),
1699 G_TYPE_FROM_CLASS (klass),
1701 G_STRUCT_OFFSET (GtkWidgetClass, focus),
1702 _gtk_boolean_handled_accumulator, NULL,
1703 _gtk_marshal_BOOLEAN__ENUM,
1705 GTK_TYPE_DIRECTION_TYPE);
1708 * GtkWidget::move-focus:
1709 * @widget: the object which received the signal.
1712 widget_signals[MOVE_FOCUS] =
1713 g_signal_new (I_("move-focus"),
1714 G_TYPE_FROM_CLASS (klass),
1715 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
1716 G_STRUCT_OFFSET (GtkWidgetClass, move_focus),
1718 _gtk_marshal_VOID__ENUM,
1721 GTK_TYPE_DIRECTION_TYPE);
1724 * GtkWidget::keynav-failed:
1725 * @widget: the object which received the signal
1726 * @direction: the direction of movement
1728 * Gets emitted if keyboard navigation fails.
1729 * See gtk_widget_keynav_failed() for details.
1731 * Returns: %TRUE if stopping keyboard navigation is fine, %FALSE
1732 * if the emitting widget should try to handle the keyboard
1733 * navigation attempt in its parent container(s).
1737 widget_signals[KEYNAV_FAILED] =
1738 g_signal_new (I_("keynav-failed"),
1739 G_TYPE_FROM_CLASS (klass),
1741 G_STRUCT_OFFSET (GtkWidgetClass, keynav_failed),
1742 _gtk_boolean_handled_accumulator, NULL,
1743 _gtk_marshal_BOOLEAN__ENUM,
1745 GTK_TYPE_DIRECTION_TYPE);
1749 * @widget: the object which received the signal.
1750 * @event: the #GdkEvent which triggered this signal
1752 * The GTK+ main loop will emit three signals for each GDK event delivered
1753 * to a widget: one generic ::event signal, another, more specific,
1754 * signal that matches the type of event delivered (e.g.
1755 * #GtkWidget::key-press-event) and finally a generic
1756 * #GtkWidget::event-after signal.
1758 * Returns: %TRUE to stop other handlers from being invoked for the event
1759 * and to cancel the emission of the second specific ::event signal.
1760 * %FALSE to propagate the event further and to allow the emission of
1761 * the second signal. The ::event-after signal is emitted regardless of
1764 widget_signals[EVENT] =
1765 g_signal_new (I_("event"),
1766 G_TYPE_FROM_CLASS (klass),
1768 G_STRUCT_OFFSET (GtkWidgetClass, event),
1769 _gtk_boolean_handled_accumulator, NULL,
1770 _gtk_marshal_BOOLEAN__BOXED,
1772 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1775 * GtkWidget::event-after:
1776 * @widget: the object which received the signal.
1777 * @event: the #GdkEvent which triggered this signal
1779 * After the emission of the #GtkWidget::event signal and (optionally)
1780 * the second more specific signal, ::event-after will be emitted
1781 * regardless of the previous two signals handlers return values.
1784 widget_signals[EVENT_AFTER] =
1785 g_signal_new (I_("event-after"),
1786 G_TYPE_FROM_CLASS (klass),
1790 _gtk_marshal_VOID__BOXED,
1792 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1795 * GtkWidget::button-press-event:
1796 * @widget: the object which received the signal.
1797 * @event: (type Gdk.EventButton): the #GdkEventButton which triggered
1800 * The ::button-press-event signal will be emitted when a button
1801 * (typically from a mouse) is pressed.
1803 * To receive this signal, the #GdkWindow associated to the
1804 * widget needs to enable the #GDK_BUTTON_PRESS_MASK mask.
1806 * This signal will be sent to the grab widget if there is one.
1808 * Returns: %TRUE to stop other handlers from being invoked for the event.
1809 * %FALSE to propagate the event further.
1811 widget_signals[BUTTON_PRESS_EVENT] =
1812 g_signal_new (I_("button-press-event"),
1813 G_TYPE_FROM_CLASS (klass),
1815 G_STRUCT_OFFSET (GtkWidgetClass, button_press_event),
1816 _gtk_boolean_handled_accumulator, NULL,
1817 _gtk_marshal_BOOLEAN__BOXED,
1819 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1822 * GtkWidget::button-release-event:
1823 * @widget: the object which received the signal.
1824 * @event: (type Gdk.EventButton): the #GdkEventButton which triggered
1827 * The ::button-release-event signal will be emitted when a button
1828 * (typically from a mouse) is released.
1830 * To receive this signal, the #GdkWindow associated to the
1831 * widget needs to enable the #GDK_BUTTON_RELEASE_MASK mask.
1833 * This signal will be sent to the grab widget if there is one.
1835 * Returns: %TRUE to stop other handlers from being invoked for the event.
1836 * %FALSE to propagate the event further.
1838 widget_signals[BUTTON_RELEASE_EVENT] =
1839 g_signal_new (I_("button-release-event"),
1840 G_TYPE_FROM_CLASS (klass),
1842 G_STRUCT_OFFSET (GtkWidgetClass, button_release_event),
1843 _gtk_boolean_handled_accumulator, NULL,
1844 _gtk_marshal_BOOLEAN__BOXED,
1846 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1849 * GtkWidget::scroll-event:
1850 * @widget: the object which received the signal.
1851 * @event: (type Gdk.EventScroll): the #GdkEventScroll which triggered
1854 * The ::scroll-event signal is emitted when a button in the 4 to 7
1855 * range is pressed. Wheel mice are usually configured to generate
1856 * button press events for buttons 4 and 5 when the wheel is turned.
1858 * To receive this signal, the #GdkWindow associated to the widget needs
1859 * to enable the #GDK_BUTTON_PRESS_MASK mask.
1861 * This signal will be sent to the grab widget if there is one.
1863 * Returns: %TRUE to stop other handlers from being invoked for the event.
1864 * %FALSE to propagate the event further.
1866 widget_signals[SCROLL_EVENT] =
1867 g_signal_new (I_("scroll-event"),
1868 G_TYPE_FROM_CLASS (klass),
1870 G_STRUCT_OFFSET (GtkWidgetClass, scroll_event),
1871 _gtk_boolean_handled_accumulator, NULL,
1872 _gtk_marshal_BOOLEAN__BOXED,
1874 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1877 * GtkWidget::motion-notify-event:
1878 * @widget: the object which received the signal.
1879 * @event: (type Gdk.EventMotion): the #GdkEventMotion which triggered
1882 * The ::motion-notify-event signal is emitted when the pointer moves
1883 * over the widget's #GdkWindow.
1885 * To receive this signal, the #GdkWindow associated to the widget
1886 * needs to enable the #GDK_POINTER_MOTION_MASK mask.
1888 * This signal will be sent to the grab widget if there is one.
1890 * Returns: %TRUE to stop other handlers from being invoked for the event.
1891 * %FALSE to propagate the event further.
1893 widget_signals[MOTION_NOTIFY_EVENT] =
1894 g_signal_new (I_("motion-notify-event"),
1895 G_TYPE_FROM_CLASS (klass),
1897 G_STRUCT_OFFSET (GtkWidgetClass, motion_notify_event),
1898 _gtk_boolean_handled_accumulator, NULL,
1899 _gtk_marshal_BOOLEAN__BOXED,
1901 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1904 * GtkWidget::composited-changed:
1905 * @widget: the object on which the signal is emitted
1907 * The ::composited-changed signal is emitted when the composited
1908 * status of @widget<!-- -->s screen changes.
1909 * See gdk_screen_is_composited().
1911 widget_signals[COMPOSITED_CHANGED] =
1912 g_signal_new (I_("composited-changed"),
1913 G_TYPE_FROM_CLASS (klass),
1914 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
1915 G_STRUCT_OFFSET (GtkWidgetClass, composited_changed),
1917 _gtk_marshal_VOID__VOID,
1921 * GtkWidget::delete-event:
1922 * @widget: the object which received the signal
1923 * @event: the event which triggered this signal
1925 * The ::delete-event signal is emitted if a user requests that
1926 * a toplevel window is closed. The default handler for this signal
1927 * destroys the window. Connecting gtk_widget_hide_on_delete() to
1928 * this signal will cause the window to be hidden instead, so that
1929 * it can later be shown again without reconstructing it.
1931 * Returns: %TRUE to stop other handlers from being invoked for the event.
1932 * %FALSE to propagate the event further.
1934 widget_signals[DELETE_EVENT] =
1935 g_signal_new (I_("delete-event"),
1936 G_TYPE_FROM_CLASS (klass),
1938 G_STRUCT_OFFSET (GtkWidgetClass, delete_event),
1939 _gtk_boolean_handled_accumulator, NULL,
1940 _gtk_marshal_BOOLEAN__BOXED,
1942 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1945 * GtkWidget::destroy-event:
1946 * @widget: the object which received the signal.
1947 * @event: the event which triggered this signal
1949 * The ::destroy-event signal is emitted when a #GdkWindow is destroyed.
1950 * You rarely get this signal, because most widgets disconnect themselves
1951 * from their window before they destroy it, so no widget owns the
1952 * window at destroy time.
1954 * To receive this signal, the #GdkWindow associated to the widget needs
1955 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask
1956 * automatically for all new windows.
1958 * Returns: %TRUE to stop other handlers from being invoked for the event.
1959 * %FALSE to propagate the event further.
1961 widget_signals[DESTROY_EVENT] =
1962 g_signal_new (I_("destroy-event"),
1963 G_TYPE_FROM_CLASS (klass),
1965 G_STRUCT_OFFSET (GtkWidgetClass, destroy_event),
1966 _gtk_boolean_handled_accumulator, NULL,
1967 _gtk_marshal_BOOLEAN__BOXED,
1969 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1972 * GtkWidget::key-press-event:
1973 * @widget: the object which received the signal
1974 * @event: (type Gdk.EventKey): the #GdkEventKey which triggered this signal.
1976 * The ::key-press-event signal is emitted when a key is pressed.
1978 * To receive this signal, the #GdkWindow associated to the widget needs
1979 * to enable the #GDK_KEY_PRESS_MASK mask.
1981 * This signal will be sent to the grab widget if there is one.
1983 * Returns: %TRUE to stop other handlers from being invoked for the event.
1984 * %FALSE to propagate the event further.
1986 widget_signals[KEY_PRESS_EVENT] =
1987 g_signal_new (I_("key-press-event"),
1988 G_TYPE_FROM_CLASS (klass),
1990 G_STRUCT_OFFSET (GtkWidgetClass, key_press_event),
1991 _gtk_boolean_handled_accumulator, NULL,
1992 _gtk_marshal_BOOLEAN__BOXED,
1994 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1997 * GtkWidget::key-release-event:
1998 * @widget: the object which received the signal
1999 * @event: (type Gdk.EventKey): the #GdkEventKey which triggered this signal.
2001 * The ::key-release-event signal is emitted when a key is pressed.
2003 * To receive this signal, the #GdkWindow associated to the widget needs
2004 * to enable the #GDK_KEY_RELEASE_MASK mask.
2006 * This signal will be sent to the grab widget if there is one.
2008 * Returns: %TRUE to stop other handlers from being invoked for the event.
2009 * %FALSE to propagate the event further.
2011 widget_signals[KEY_RELEASE_EVENT] =
2012 g_signal_new (I_("key-release-event"),
2013 G_TYPE_FROM_CLASS (klass),
2015 G_STRUCT_OFFSET (GtkWidgetClass, key_release_event),
2016 _gtk_boolean_handled_accumulator, NULL,
2017 _gtk_marshal_BOOLEAN__BOXED,
2019 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2022 * GtkWidget::enter-notify-event:
2023 * @widget: the object which received the signal
2024 * @event: (type Gdk.EventCrossing): the #GdkEventCrossing which triggered
2027 * The ::enter-notify-event will be emitted when the pointer enters
2028 * the @widget's window.
2030 * To receive this signal, the #GdkWindow associated to the widget needs
2031 * to enable the #GDK_ENTER_NOTIFY_MASK mask.
2033 * This signal will be sent to the grab widget if there is one.
2035 * Returns: %TRUE to stop other handlers from being invoked for the event.
2036 * %FALSE to propagate the event further.
2038 widget_signals[ENTER_NOTIFY_EVENT] =
2039 g_signal_new (I_("enter-notify-event"),
2040 G_TYPE_FROM_CLASS (klass),
2042 G_STRUCT_OFFSET (GtkWidgetClass, enter_notify_event),
2043 _gtk_boolean_handled_accumulator, NULL,
2044 _gtk_marshal_BOOLEAN__BOXED,
2046 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2049 * GtkWidget::leave-notify-event:
2050 * @widget: the object which received the signal
2051 * @event: (type Gdk.EventCrossing): the #GdkEventCrossing which triggered
2054 * The ::leave-notify-event will be emitted when the pointer leaves
2055 * the @widget's window.
2057 * To receive this signal, the #GdkWindow associated to the widget needs
2058 * to enable the #GDK_LEAVE_NOTIFY_MASK mask.
2060 * This signal will be sent to the grab widget if there is one.
2062 * Returns: %TRUE to stop other handlers from being invoked for the event.
2063 * %FALSE to propagate the event further.
2065 widget_signals[LEAVE_NOTIFY_EVENT] =
2066 g_signal_new (I_("leave-notify-event"),
2067 G_TYPE_FROM_CLASS (klass),
2069 G_STRUCT_OFFSET (GtkWidgetClass, leave_notify_event),
2070 _gtk_boolean_handled_accumulator, NULL,
2071 _gtk_marshal_BOOLEAN__BOXED,
2073 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2076 * GtkWidget::configure-event:
2077 * @widget: the object which received the signal
2078 * @event: (type Gdk.EventConfigure): the #GdkEventConfigure which triggered
2081 * The ::configure-event signal will be emitted when the size, position or
2082 * stacking of the @widget's window has changed.
2084 * To receive this signal, the #GdkWindow associated to the widget needs
2085 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask
2086 * automatically for all new windows.
2088 * Returns: %TRUE to stop other handlers from being invoked for the event.
2089 * %FALSE to propagate the event further.
2091 widget_signals[CONFIGURE_EVENT] =
2092 g_signal_new (I_("configure-event"),
2093 G_TYPE_FROM_CLASS (klass),
2095 G_STRUCT_OFFSET (GtkWidgetClass, configure_event),
2096 _gtk_boolean_handled_accumulator, NULL,
2097 _gtk_marshal_BOOLEAN__BOXED,
2099 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2102 * GtkWidget::focus-in-event:
2103 * @widget: the object which received the signal
2104 * @event: (type Gdk.EventFocus): the #GdkEventFocus which triggered
2107 * The ::focus-in-event signal will be emitted when the keyboard focus
2108 * enters the @widget's window.
2110 * To receive this signal, the #GdkWindow associated to the widget needs
2111 * to enable the #GDK_FOCUS_CHANGE_MASK mask.
2113 * Returns: %TRUE to stop other handlers from being invoked for the event.
2114 * %FALSE to propagate the event further.
2116 widget_signals[FOCUS_IN_EVENT] =
2117 g_signal_new (I_("focus-in-event"),
2118 G_TYPE_FROM_CLASS (klass),
2120 G_STRUCT_OFFSET (GtkWidgetClass, focus_in_event),
2121 _gtk_boolean_handled_accumulator, NULL,
2122 _gtk_marshal_BOOLEAN__BOXED,
2124 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2127 * GtkWidget::focus-out-event:
2128 * @widget: the object which received the signal
2129 * @event: (type Gdk.EventFocus): the #GdkEventFocus which triggered this
2132 * The ::focus-out-event signal will be emitted when the keyboard focus
2133 * leaves the @widget's window.
2135 * To receive this signal, the #GdkWindow associated to the widget needs
2136 * to enable the #GDK_FOCUS_CHANGE_MASK mask.
2138 * Returns: %TRUE to stop other handlers from being invoked for the event.
2139 * %FALSE to propagate the event further.
2141 widget_signals[FOCUS_OUT_EVENT] =
2142 g_signal_new (I_("focus-out-event"),
2143 G_TYPE_FROM_CLASS (klass),
2145 G_STRUCT_OFFSET (GtkWidgetClass, focus_out_event),
2146 _gtk_boolean_handled_accumulator, NULL,
2147 _gtk_marshal_BOOLEAN__BOXED,
2149 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2152 * GtkWidget::map-event:
2153 * @widget: the object which received the signal
2154 * @event: (type Gdk.EventAny): the #GdkEventAny which triggered this signal.
2156 * The ::map-event signal will be emitted when the @widget's window is
2157 * mapped. A window is mapped when it becomes visible on the screen.
2159 * To receive this signal, the #GdkWindow associated to the widget needs
2160 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask
2161 * automatically for all new windows.
2163 * Returns: %TRUE to stop other handlers from being invoked for the event.
2164 * %FALSE to propagate the event further.
2166 widget_signals[MAP_EVENT] =
2167 g_signal_new (I_("map-event"),
2168 G_TYPE_FROM_CLASS (klass),
2170 G_STRUCT_OFFSET (GtkWidgetClass, map_event),
2171 _gtk_boolean_handled_accumulator, NULL,
2172 _gtk_marshal_BOOLEAN__BOXED,
2174 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2177 * GtkWidget::unmap-event:
2178 * @widget: the object which received the signal
2179 * @event: (type Gdk.EventAny): the #GdkEventAny which triggered this signal
2181 * The ::unmap-event signal may be emitted when the @widget's window is
2182 * unmapped. A window is unmapped when it becomes invisible on the screen.
2184 * For performance reasons GTK+ may not emit ::unmap-event, so one
2185 * should always also implement ::unrealize in order to release
2186 * resources and disconnect signal handlers.
2188 * To receive this signal, the #GdkWindow associated to the widget needs
2189 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask
2190 * automatically for all new windows.
2192 * Returns: %TRUE to stop other handlers from being invoked for the event.
2193 * %FALSE to propagate the event further.
2195 widget_signals[UNMAP_EVENT] =
2196 g_signal_new (I_("unmap-event"),
2197 G_TYPE_FROM_CLASS (klass),
2199 G_STRUCT_OFFSET (GtkWidgetClass, unmap_event),
2200 _gtk_boolean_handled_accumulator, NULL,
2201 _gtk_marshal_BOOLEAN__BOXED,
2203 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2206 * GtkWidget::property-notify-event:
2207 * @widget: the object which received the signal
2208 * @event: (type Gdk.EventProperty): the #GdkEventProperty which triggered
2211 * The ::property-notify-event signal will be emitted when a property on
2212 * the @widget's window has been changed or deleted.
2214 * To receive this signal, the #GdkWindow associated to the widget needs
2215 * to enable the #GDK_PROPERTY_CHANGE_MASK mask.
2217 * Returns: %TRUE to stop other handlers from being invoked for the event.
2218 * %FALSE to propagate the event further.
2220 widget_signals[PROPERTY_NOTIFY_EVENT] =
2221 g_signal_new (I_("property-notify-event"),
2222 G_TYPE_FROM_CLASS (klass),
2224 G_STRUCT_OFFSET (GtkWidgetClass, property_notify_event),
2225 _gtk_boolean_handled_accumulator, NULL,
2226 _gtk_marshal_BOOLEAN__BOXED,
2228 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2231 * GtkWidget::selection-clear-event:
2232 * @widget: the object which received the signal
2233 * @event: (type Gdk.EventSelection): the #GdkEventSelection which triggered
2236 * The ::selection-clear-event signal will be emitted when the
2237 * the @widget's window has lost ownership of a selection.
2239 * Returns: %TRUE to stop other handlers from being invoked for the event.
2240 * %FALSE to propagate the event further.
2242 widget_signals[SELECTION_CLEAR_EVENT] =
2243 g_signal_new (I_("selection-clear-event"),
2244 G_TYPE_FROM_CLASS (klass),
2246 G_STRUCT_OFFSET (GtkWidgetClass, selection_clear_event),
2247 _gtk_boolean_handled_accumulator, NULL,
2248 _gtk_marshal_BOOLEAN__BOXED,
2250 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2253 * GtkWidget::selection-request-event:
2254 * @widget: the object which received the signal
2255 * @event: (type Gdk.EventSelection): the #GdkEventSelection which triggered
2258 * The ::selection-request-event signal will be emitted when
2259 * another client requests ownership of the selection owned by
2260 * the @widget's window.
2262 * Returns: %TRUE to stop other handlers from being invoked for the event.
2263 * %FALSE to propagate the event further.
2265 widget_signals[SELECTION_REQUEST_EVENT] =
2266 g_signal_new (I_("selection-request-event"),
2267 G_TYPE_FROM_CLASS (klass),
2269 G_STRUCT_OFFSET (GtkWidgetClass, selection_request_event),
2270 _gtk_boolean_handled_accumulator, NULL,
2271 _gtk_marshal_BOOLEAN__BOXED,
2273 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2276 * GtkWidget::selection-notify-event:
2277 * @widget: the object which received the signal.
2280 * Returns: %TRUE to stop other handlers from being invoked for the event. %FALSE to propagate the event further.
2282 widget_signals[SELECTION_NOTIFY_EVENT] =
2283 g_signal_new (I_("selection-notify-event"),
2284 G_TYPE_FROM_CLASS (klass),
2286 G_STRUCT_OFFSET (GtkWidgetClass, selection_notify_event),
2287 _gtk_boolean_handled_accumulator, NULL,
2288 _gtk_marshal_BOOLEAN__BOXED,
2290 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2293 * GtkWidget::selection-received:
2294 * @widget: the object which received the signal.
2298 widget_signals[SELECTION_RECEIVED] =
2299 g_signal_new (I_("selection-received"),
2300 G_TYPE_FROM_CLASS (klass),
2302 G_STRUCT_OFFSET (GtkWidgetClass, selection_received),
2304 _gtk_marshal_VOID__BOXED_UINT,
2306 GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
2310 * GtkWidget::selection-get:
2311 * @widget: the object which received the signal.
2316 widget_signals[SELECTION_GET] =
2317 g_signal_new (I_("selection-get"),
2318 G_TYPE_FROM_CLASS (klass),
2320 G_STRUCT_OFFSET (GtkWidgetClass, selection_get),
2322 _gtk_marshal_VOID__BOXED_UINT_UINT,
2324 GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
2329 * GtkWidget::proximity-in-event:
2330 * @widget: the object which received the signal
2331 * @event: (type Gdk.EventProximity): the #GdkEventProximity which triggered
2334 * To receive this signal the #GdkWindow associated to the widget needs
2335 * to enable the #GDK_PROXIMITY_IN_MASK mask.
2337 * This signal will be sent to the grab widget if there is one.
2339 * Returns: %TRUE to stop other handlers from being invoked for the event.
2340 * %FALSE to propagate the event further.
2342 widget_signals[PROXIMITY_IN_EVENT] =
2343 g_signal_new (I_("proximity-in-event"),
2344 G_TYPE_FROM_CLASS (klass),
2346 G_STRUCT_OFFSET (GtkWidgetClass, proximity_in_event),
2347 _gtk_boolean_handled_accumulator, NULL,
2348 _gtk_marshal_BOOLEAN__BOXED,
2350 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2353 * GtkWidget::proximity-out-event:
2354 * @widget: the object which received the signal
2355 * @event: (type Gdk.EventProximity): the #GdkEventProximity which triggered
2358 * To receive this signal the #GdkWindow associated to the widget needs
2359 * to enable the #GDK_PROXIMITY_OUT_MASK mask.
2361 * This signal will be sent to the grab widget if there is one.
2363 * Returns: %TRUE to stop other handlers from being invoked for the event.
2364 * %FALSE to propagate the event further.
2366 widget_signals[PROXIMITY_OUT_EVENT] =
2367 g_signal_new (I_("proximity-out-event"),
2368 G_TYPE_FROM_CLASS (klass),
2370 G_STRUCT_OFFSET (GtkWidgetClass, proximity_out_event),
2371 _gtk_boolean_handled_accumulator, NULL,
2372 _gtk_marshal_BOOLEAN__BOXED,
2374 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2377 * GtkWidget::drag-leave:
2378 * @widget: the object which received the signal.
2379 * @drag_context: the drag context
2380 * @time: the timestamp of the motion event
2382 * The ::drag-leave signal is emitted on the drop site when the cursor
2383 * leaves the widget. A typical reason to connect to this signal is to
2384 * undo things done in #GtkWidget::drag-motion, e.g. undo highlighting
2385 * with gtk_drag_unhighlight()
2387 widget_signals[DRAG_LEAVE] =
2388 g_signal_new (I_("drag-leave"),
2389 G_TYPE_FROM_CLASS (klass),
2391 G_STRUCT_OFFSET (GtkWidgetClass, drag_leave),
2393 _gtk_marshal_VOID__OBJECT_UINT,
2395 GDK_TYPE_DRAG_CONTEXT,
2399 * GtkWidget::drag-begin:
2400 * @widget: the object which received the signal
2401 * @drag_context: the drag context
2403 * The ::drag-begin signal is emitted on the drag source when a drag is
2404 * started. A typical reason to connect to this signal is to set up a
2405 * custom drag icon with gtk_drag_source_set_icon().
2407 * Note that some widgets set up a drag icon in the default handler of
2408 * this signal, so you may have to use g_signal_connect_after() to
2409 * override what the default handler did.
2411 widget_signals[DRAG_BEGIN] =
2412 g_signal_new (I_("drag-begin"),
2413 G_TYPE_FROM_CLASS (klass),
2415 G_STRUCT_OFFSET (GtkWidgetClass, drag_begin),
2417 _gtk_marshal_VOID__OBJECT,
2419 GDK_TYPE_DRAG_CONTEXT);
2422 * GtkWidget::drag-end:
2423 * @widget: the object which received the signal
2424 * @drag_context: the drag context
2426 * The ::drag-end signal is emitted on the drag source when a drag is
2427 * finished. A typical reason to connect to this signal is to undo
2428 * things done in #GtkWidget::drag-begin.
2430 widget_signals[DRAG_END] =
2431 g_signal_new (I_("drag-end"),
2432 G_TYPE_FROM_CLASS (klass),
2434 G_STRUCT_OFFSET (GtkWidgetClass, drag_end),
2436 _gtk_marshal_VOID__OBJECT,
2438 GDK_TYPE_DRAG_CONTEXT);
2441 * GtkWidget::drag-data-delete:
2442 * @widget: the object which received the signal
2443 * @drag_context: the drag context
2445 * The ::drag-data-delete signal is emitted on the drag source when a drag
2446 * with the action %GDK_ACTION_MOVE is successfully completed. The signal
2447 * handler is responsible for deleting the data that has been dropped. What
2448 * "delete" means depends on the context of the drag operation.
2450 widget_signals[DRAG_DATA_DELETE] =
2451 g_signal_new (I_("drag-data-delete"),
2452 G_TYPE_FROM_CLASS (klass),
2454 G_STRUCT_OFFSET (GtkWidgetClass, drag_data_delete),
2456 _gtk_marshal_VOID__OBJECT,
2458 GDK_TYPE_DRAG_CONTEXT);
2461 * GtkWidget::drag-failed:
2462 * @widget: the object which received the signal
2463 * @drag_context: the drag context
2464 * @result: the result of the drag operation
2466 * The ::drag-failed signal is emitted on the drag source when a drag has
2467 * failed. The signal handler may hook custom code to handle a failed DND
2468 * operation based on the type of error, it returns %TRUE is the failure has
2469 * been already handled (not showing the default "drag operation failed"
2470 * animation), otherwise it returns %FALSE.
2472 * Return value: %TRUE if the failed drag operation has been already handled.
2476 widget_signals[DRAG_FAILED] =
2477 g_signal_new (I_("drag-failed"),
2478 G_TYPE_FROM_CLASS (klass),
2480 0, _gtk_boolean_handled_accumulator, NULL,
2481 _gtk_marshal_BOOLEAN__OBJECT_ENUM,
2483 GDK_TYPE_DRAG_CONTEXT,
2484 GTK_TYPE_DRAG_RESULT);
2487 * GtkWidget::drag-motion:
2488 * @widget: the object which received the signal
2489 * @drag_context: the drag context
2490 * @x: the x coordinate of the current cursor position
2491 * @y: the y coordinate of the current cursor position
2492 * @time: the timestamp of the motion event
2493 * @returns: whether the cursor position is in a drop zone
2495 * The drag-motion signal is emitted on the drop site when the user
2496 * moves the cursor over the widget during a drag. The signal handler
2497 * must determine whether the cursor position is in a drop zone or not.
2498 * If it is not in a drop zone, it returns %FALSE and no further processing
2499 * is necessary. Otherwise, the handler returns %TRUE. In this case, the
2500 * handler is responsible for providing the necessary information for
2501 * displaying feedback to the user, by calling gdk_drag_status().
2503 * If the decision whether the drop will be accepted or rejected can't be
2504 * made based solely on the cursor position and the type of the data, the
2505 * handler may inspect the dragged data by calling gtk_drag_get_data() and
2506 * defer the gdk_drag_status() call to the #GtkWidget::drag-data-received
2507 * handler. Note that you cannot not pass #GTK_DEST_DEFAULT_DROP,
2508 * #GTK_DEST_DEFAULT_MOTION or #GTK_DEST_DEFAULT_ALL to gtk_drag_dest_set()
2509 * when using the drag-motion signal that way.
2511 * Also note that there is no drag-enter signal. The drag receiver has to
2512 * keep track of whether he has received any drag-motion signals since the
2513 * last #GtkWidget::drag-leave and if not, treat the drag-motion signal as
2514 * an "enter" signal. Upon an "enter", the handler will typically highlight
2515 * the drop site with gtk_drag_highlight().
2518 * drag_motion (GtkWidget *widget,
2519 * GdkDragContext *context,
2526 * PrivateData *private_data = GET_PRIVATE_DATA (widget);
2528 * if (!private_data->drag_highlight)
2530 * private_data->drag_highlight = 1;
2531 * gtk_drag_highlight (widget);
2534 * target = gtk_drag_dest_find_target (widget, context, NULL);
2535 * if (target == GDK_NONE)
2536 * gdk_drag_status (context, 0, time);
2539 * private_data->pending_status = context->suggested_action;
2540 * gtk_drag_get_data (widget, context, target, time);
2547 * drag_data_received (GtkWidget *widget,
2548 * GdkDragContext *context,
2551 * GtkSelectionData *selection_data,
2555 * PrivateData *private_data = GET_PRIVATE_DATA (widget);
2557 * if (private_data->suggested_action)
2559 * private_data->suggested_action = 0;
2561 * /* We are getting this data due to a request in drag_motion,
2562 * * rather than due to a request in drag_drop, so we are just
2563 * * supposed to call gdk_drag_status (), not actually paste in
2566 * str = gtk_selection_data_get_text (selection_data);
2567 * if (!data_is_acceptable (str))
2568 * gdk_drag_status (context, 0, time);
2570 * gdk_drag_status (context, private_data->suggested_action, time);
2574 * /* accept the drop */
2579 widget_signals[DRAG_MOTION] =
2580 g_signal_new (I_("drag-motion"),
2581 G_TYPE_FROM_CLASS (klass),
2583 G_STRUCT_OFFSET (GtkWidgetClass, drag_motion),
2584 _gtk_boolean_handled_accumulator, NULL,
2585 _gtk_marshal_BOOLEAN__OBJECT_INT_INT_UINT,
2587 GDK_TYPE_DRAG_CONTEXT,
2593 * GtkWidget::drag-drop:
2594 * @widget: the object which received the signal
2595 * @drag_context: the drag context
2596 * @x: the x coordinate of the current cursor position
2597 * @y: the y coordinate of the current cursor position
2598 * @time: the timestamp of the motion event
2599 * @returns: whether the cursor position is in a drop zone
2601 * The ::drag-drop signal is emitted on the drop site when the user drops
2602 * the data onto the widget. The signal handler must determine whether
2603 * the cursor position is in a drop zone or not. If it is not in a drop
2604 * zone, it returns %FALSE and no further processing is necessary.
2605 * Otherwise, the handler returns %TRUE. In this case, the handler must
2606 * ensure that gtk_drag_finish() is called to let the source know that
2607 * the drop is done. The call to gtk_drag_finish() can be done either
2608 * directly or in a #GtkWidget::drag-data-received handler which gets
2609 * triggered by calling gtk_drag_get_data() to receive the data for one
2610 * or more of the supported targets.
2612 widget_signals[DRAG_DROP] =
2613 g_signal_new (I_("drag-drop"),
2614 G_TYPE_FROM_CLASS (klass),
2616 G_STRUCT_OFFSET (GtkWidgetClass, drag_drop),
2617 _gtk_boolean_handled_accumulator, NULL,
2618 _gtk_marshal_BOOLEAN__OBJECT_INT_INT_UINT,
2620 GDK_TYPE_DRAG_CONTEXT,
2626 * GtkWidget::drag-data-get:
2627 * @widget: the object which received the signal
2628 * @drag_context: the drag context
2629 * @data: the #GtkSelectionData to be filled with the dragged data
2630 * @info: the info that has been registered with the target in the
2632 * @time: the timestamp at which the data was requested
2634 * The ::drag-data-get signal is emitted on the drag source when the drop
2635 * site requests the data which is dragged. It is the responsibility of
2636 * the signal handler to fill @data with the data in the format which
2637 * is indicated by @info. See gtk_selection_data_set() and
2638 * gtk_selection_data_set_text().
2640 widget_signals[DRAG_DATA_GET] =
2641 g_signal_new (I_("drag-data-get"),
2642 G_TYPE_FROM_CLASS (klass),
2644 G_STRUCT_OFFSET (GtkWidgetClass, drag_data_get),
2646 _gtk_marshal_VOID__OBJECT_BOXED_UINT_UINT,
2648 GDK_TYPE_DRAG_CONTEXT,
2649 GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
2654 * GtkWidget::drag-data-received:
2655 * @widget: the object which received the signal
2656 * @drag_context: the drag context
2657 * @x: where the drop happened
2658 * @y: where the drop happened
2659 * @data: the received data
2660 * @info: the info that has been registered with the target in the
2662 * @time: the timestamp at which the data was received
2664 * The ::drag-data-received signal is emitted on the drop site when the
2665 * dragged data has been received. If the data was received in order to
2666 * determine whether the drop will be accepted, the handler is expected
2667 * to call gdk_drag_status() and <emphasis>not</emphasis> finish the drag.
2668 * If the data was received in response to a #GtkWidget::drag-drop signal
2669 * (and this is the last target to be received), the handler for this
2670 * signal is expected to process the received data and then call
2671 * gtk_drag_finish(), setting the @success parameter depending on whether
2672 * the data was processed successfully.
2674 * The handler may inspect and modify @drag_context->action before calling
2675 * gtk_drag_finish(), e.g. to implement %GDK_ACTION_ASK as shown in the
2676 * following example:
2679 * drag_data_received (GtkWidget *widget,
2680 * GdkDragContext *drag_context,
2683 * GtkSelectionData *data,
2687 * if ((data->length >= 0) && (data->format == 8))
2689 * if (drag_context->action == GDK_ACTION_ASK)
2691 * GtkWidget *dialog;
2694 * dialog = gtk_message_dialog_new (NULL,
2695 * GTK_DIALOG_MODAL |
2696 * GTK_DIALOG_DESTROY_WITH_PARENT,
2698 * GTK_BUTTONS_YES_NO,
2699 * "Move the data ?\n");
2700 * response = gtk_dialog_run (GTK_DIALOG (dialog));
2701 * gtk_widget_destroy (dialog);
2703 * if (response == GTK_RESPONSE_YES)
2704 * drag_context->action = GDK_ACTION_MOVE;
2706 * drag_context->action = GDK_ACTION_COPY;
2709 * gtk_drag_finish (drag_context, TRUE, FALSE, time);
2713 * gtk_drag_finish (drag_context, FALSE, FALSE, time);
2717 widget_signals[DRAG_DATA_RECEIVED] =
2718 g_signal_new (I_("drag-data-received"),
2719 G_TYPE_FROM_CLASS (klass),
2721 G_STRUCT_OFFSET (GtkWidgetClass, drag_data_received),
2723 _gtk_marshal_VOID__OBJECT_INT_INT_BOXED_UINT_UINT,
2725 GDK_TYPE_DRAG_CONTEXT,
2728 GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
2733 * GtkWidget::visibility-notify-event:
2734 * @widget: the object which received the signal
2735 * @event: (type Gdk.EventVisibility): the #GdkEventVisibility which
2736 * triggered this signal.
2738 * The ::visibility-notify-event will be emitted when the @widget's window
2739 * is obscured or unobscured.
2741 * To receive this signal the #GdkWindow associated to the widget needs
2742 * to enable the #GDK_VISIBILITY_NOTIFY_MASK mask.
2744 * Returns: %TRUE to stop other handlers from being invoked for the event.
2745 * %FALSE to propagate the event further.
2747 widget_signals[VISIBILITY_NOTIFY_EVENT] =
2748 g_signal_new (I_("visibility-notify-event"),
2749 G_TYPE_FROM_CLASS (klass),
2751 G_STRUCT_OFFSET (GtkWidgetClass, visibility_notify_event),
2752 _gtk_boolean_handled_accumulator, NULL,
2753 _gtk_marshal_BOOLEAN__BOXED,
2755 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2758 * GtkWidget::client-event:
2759 * @widget: the object which received the signal
2760 * @event: (type Gdk.EventClient): the #GdkEventClient which triggered
2763 * The ::client-event will be emitted when the @widget's window
2764 * receives a message (via a ClientMessage event) from another
2767 * Returns: %TRUE to stop other handlers from being invoked for
2768 * the event. %FALSE to propagate the event further.
2770 widget_signals[CLIENT_EVENT] =
2771 g_signal_new (I_("client-event"),
2772 G_TYPE_FROM_CLASS (klass),
2774 G_STRUCT_OFFSET (GtkWidgetClass, client_event),
2775 _gtk_boolean_handled_accumulator, NULL,
2776 _gtk_marshal_BOOLEAN__BOXED,
2778 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2781 * GtkWidget::no-expose-event:
2782 * @widget: the object which received the signal
2783 * @event: (type Gdk.EventNoExpose): the #GdkEventNoExpose which triggered
2786 * The ::no-expose-event will be emitted when the @widget's window is
2787 * drawn as a copy of another #GdkDrawable which was completely unobscured.
2788 * If the source window was partially obscured #GdkEventExpose events will
2789 * be generated for those areas.
2791 * Returns: %TRUE to stop other handlers from being invoked for the event.
2792 * %FALSE to propagate the event further.
2794 widget_signals[NO_EXPOSE_EVENT] =
2795 g_signal_new (I_("no-expose-event"),
2796 G_TYPE_FROM_CLASS (klass),
2798 G_STRUCT_OFFSET (GtkWidgetClass, no_expose_event),
2799 _gtk_boolean_handled_accumulator, NULL,
2800 _gtk_marshal_BOOLEAN__BOXED,
2802 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2805 * GtkWidget::window-state-event:
2806 * @widget: the object which received the signal
2807 * @event: (type Gdk.EventWindowState): the #GdkEventWindowState which
2808 * triggered this signal.
2810 * The ::window-state-event will be emitted when the state of the
2811 * toplevel window associated to the @widget changes.
2813 * To receive this signal the #GdkWindow associated to the widget
2814 * needs to enable the #GDK_STRUCTURE_MASK mask. GDK will enable
2815 * this mask automatically for all new windows.
2817 * Returns: %TRUE to stop other handlers from being invoked for the
2818 * event. %FALSE to propagate the event further.
2820 widget_signals[WINDOW_STATE_EVENT] =
2821 g_signal_new (I_("window-state-event"),
2822 G_TYPE_FROM_CLASS (klass),
2824 G_STRUCT_OFFSET (GtkWidgetClass, window_state_event),
2825 _gtk_boolean_handled_accumulator, NULL,
2826 _gtk_marshal_BOOLEAN__BOXED,
2828 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2831 * GtkWidget::damage-event:
2832 * @widget: the object which received the signal
2833 * @event: the #GdkEventExpose event
2835 * Emitted when a redirected window belonging to @widget gets drawn into.
2836 * The region/area members of the event shows what area of the redirected
2837 * drawable was drawn into.
2839 * Returns: %TRUE to stop other handlers from being invoked for the event.
2840 * %FALSE to propagate the event further.
2844 widget_signals[DAMAGE_EVENT] =
2845 g_signal_new (I_("damage-event"),
2846 G_TYPE_FROM_CLASS (klass),
2848 G_STRUCT_OFFSET (GtkWidgetClass, damage_event),
2849 _gtk_boolean_handled_accumulator, NULL,
2850 _gtk_marshal_BOOLEAN__BOXED,
2852 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2855 * GtkWidget::grab-broken-event:
2856 * @widget: the object which received the signal
2857 * @event: the #GdkEventGrabBroken event
2859 * Emitted when a pointer or keyboard grab on a window belonging
2860 * to @widget gets broken.
2862 * On X11, this happens when the grab window becomes unviewable
2863 * (i.e. it or one of its ancestors is unmapped), or if the same
2864 * application grabs the pointer or keyboard again.
2866 * Returns: %TRUE to stop other handlers from being invoked for
2867 * the event. %FALSE to propagate the event further.
2871 widget_signals[GRAB_BROKEN_EVENT] =
2872 g_signal_new (I_("grab-broken-event"),
2873 G_TYPE_FROM_CLASS (klass),
2875 G_STRUCT_OFFSET (GtkWidgetClass, grab_broken_event),
2876 _gtk_boolean_handled_accumulator, NULL,
2877 _gtk_marshal_BOOLEAN__BOXED,
2879 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2882 * GtkWidget::query-tooltip:
2883 * @widget: the object which received the signal
2884 * @x: the x coordinate of the cursor position where the request has
2885 * been emitted, relative to @widget->window
2886 * @y: the y coordinate of the cursor position where the request has
2887 * been emitted, relative to @widget->window
2888 * @keyboard_mode: %TRUE if the tooltip was trigged using the keyboard
2889 * @tooltip: a #GtkTooltip
2891 * Emitted when #GtkWidget:has-tooltip is %TRUE and the #GtkSettings:gtk-tooltip-timeout
2892 * has expired with the cursor hovering "above" @widget; or emitted when @widget got
2893 * focus in keyboard mode.
2895 * Using the given coordinates, the signal handler should determine
2896 * whether a tooltip should be shown for @widget. If this is the case
2897 * %TRUE should be returned, %FALSE otherwise. Note that if
2898 * @keyboard_mode is %TRUE, the values of @x and @y are undefined and
2899 * should not be used.
2901 * The signal handler is free to manipulate @tooltip with the therefore
2902 * destined function calls.
2904 * Returns: %TRUE if @tooltip should be shown right now, %FALSE otherwise.
2908 widget_signals[QUERY_TOOLTIP] =
2909 g_signal_new (I_("query-tooltip"),
2910 G_TYPE_FROM_CLASS (klass),
2912 G_STRUCT_OFFSET (GtkWidgetClass, query_tooltip),
2913 _gtk_boolean_handled_accumulator, NULL,
2914 _gtk_marshal_BOOLEAN__INT_INT_BOOLEAN_OBJECT,
2922 * GtkWidget::popup-menu
2923 * @widget: the object which received the signal
2925 * This signal gets emitted whenever a widget should pop up a context
2926 * menu. This usually happens through the standard key binding mechanism;
2927 * by pressing a certain key while a widget is focused, the user can cause
2928 * the widget to pop up a menu. For example, the #GtkEntry widget creates
2929 * a menu with clipboard commands. See <xref linkend="checklist-popup-menu"/>
2930 * for an example of how to use this signal.
2932 * Returns: %TRUE if a menu was activated
2934 widget_signals[POPUP_MENU] =
2935 g_signal_new (I_("popup-menu"),
2936 G_TYPE_FROM_CLASS (klass),
2937 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
2938 G_STRUCT_OFFSET (GtkWidgetClass, popup_menu),
2939 _gtk_boolean_handled_accumulator, NULL,
2940 _gtk_marshal_BOOLEAN__VOID,
2944 * GtkWidget::show-help:
2945 * @widget: the object which received the signal.
2948 widget_signals[SHOW_HELP] =
2949 g_signal_new (I_("show-help"),
2950 G_TYPE_FROM_CLASS (klass),
2951 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
2952 G_STRUCT_OFFSET (GtkWidgetClass, show_help),
2953 _gtk_boolean_handled_accumulator, NULL,
2954 _gtk_marshal_BOOLEAN__ENUM,
2956 GTK_TYPE_WIDGET_HELP_TYPE);
2959 * GtkWidget::accel-closures-changed:
2960 * @widget: the object which received the signal.
2962 widget_signals[ACCEL_CLOSURES_CHANGED] =
2963 g_signal_new (I_("accel-closures-changed"),
2964 G_TYPE_FROM_CLASS (klass),
2968 _gtk_marshal_VOID__VOID,
2972 * GtkWidget::screen-changed:
2973 * @widget: the object on which the signal is emitted
2974 * @previous_screen: (allow-none): the previous screen, or %NULL if the
2975 * widget was not associated with a screen before
2977 * The ::screen-changed signal gets emitted when the
2978 * screen of a widget has changed.
2980 widget_signals[SCREEN_CHANGED] =
2981 g_signal_new (I_("screen-changed"),
2982 G_TYPE_FROM_CLASS (klass),
2984 G_STRUCT_OFFSET (GtkWidgetClass, screen_changed),
2986 _gtk_marshal_VOID__OBJECT,
2991 * GtkWidget::can-activate-accel:
2992 * @widget: the object which received the signal
2993 * @signal_id: the ID of a signal installed on @widget
2995 * Determines whether an accelerator that activates the signal
2996 * identified by @signal_id can currently be activated.
2997 * This signal is present to allow applications and derived
2998 * widgets to override the default #GtkWidget handling
2999 * for determining whether an accelerator can be activated.
3001 * Returns: %TRUE if the signal can be activated.
3003 widget_signals[CAN_ACTIVATE_ACCEL] =
3004 g_signal_new (I_("can-activate-accel"),
3005 G_TYPE_FROM_CLASS (klass),
3007 G_STRUCT_OFFSET (GtkWidgetClass, can_activate_accel),
3008 _gtk_boolean_handled_accumulator, NULL,
3009 _gtk_marshal_BOOLEAN__UINT,
3010 G_TYPE_BOOLEAN, 1, G_TYPE_UINT);
3012 binding_set = gtk_binding_set_by_class (klass);
3013 gtk_binding_entry_add_signal (binding_set, GDK_KEY_F10, GDK_SHIFT_MASK,
3015 gtk_binding_entry_add_signal (binding_set, GDK_KEY_Menu, 0,
3018 gtk_binding_entry_add_signal (binding_set, GDK_KEY_F1, GDK_CONTROL_MASK,
3020 GTK_TYPE_WIDGET_HELP_TYPE,
3021 GTK_WIDGET_HELP_TOOLTIP);
3022 gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_F1, GDK_CONTROL_MASK,
3024 GTK_TYPE_WIDGET_HELP_TYPE,
3025 GTK_WIDGET_HELP_TOOLTIP);
3026 gtk_binding_entry_add_signal (binding_set, GDK_KEY_F1, GDK_SHIFT_MASK,
3028 GTK_TYPE_WIDGET_HELP_TYPE,
3029 GTK_WIDGET_HELP_WHATS_THIS);
3030 gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_F1, GDK_SHIFT_MASK,
3032 GTK_TYPE_WIDGET_HELP_TYPE,
3033 GTK_WIDGET_HELP_WHATS_THIS);
3035 gtk_widget_class_install_style_property (klass,
3036 g_param_spec_boolean ("interior-focus",
3037 P_("Interior Focus"),
3038 P_("Whether to draw the focus indicator inside widgets"),
3040 GTK_PARAM_READABLE));
3042 gtk_widget_class_install_style_property (klass,
3043 g_param_spec_int ("focus-line-width",
3044 P_("Focus linewidth"),
3045 P_("Width, in pixels, of the focus indicator line"),
3047 GTK_PARAM_READABLE));
3049 gtk_widget_class_install_style_property (klass,
3050 g_param_spec_string ("focus-line-pattern",
3051 P_("Focus line dash pattern"),
3052 P_("Dash pattern used to draw the focus indicator"),
3054 GTK_PARAM_READABLE));
3055 gtk_widget_class_install_style_property (klass,
3056 g_param_spec_int ("focus-padding",
3057 P_("Focus padding"),
3058 P_("Width, in pixels, between focus indicator and the widget 'box'"),
3060 GTK_PARAM_READABLE));
3061 gtk_widget_class_install_style_property (klass,
3062 g_param_spec_boxed ("cursor-color",
3064 P_("Color with which to draw insertion cursor"),
3066 GTK_PARAM_READABLE));
3067 gtk_widget_class_install_style_property (klass,
3068 g_param_spec_boxed ("secondary-cursor-color",
3069 P_("Secondary cursor color"),
3070 P_("Color with which to draw the secondary insertion cursor when editing mixed right-to-left and left-to-right text"),
3072 GTK_PARAM_READABLE));
3073 gtk_widget_class_install_style_property (klass,
3074 g_param_spec_float ("cursor-aspect-ratio",
3075 P_("Cursor line aspect ratio"),
3076 P_("Aspect ratio with which to draw insertion cursor"),
3078 GTK_PARAM_READABLE));
3080 gtk_widget_class_install_style_property (klass,
3081 g_param_spec_boolean ("window-dragging",
3082 P_("Window dragging"),
3083 P_("Whether windows can be dragged by clicking on empty areas"),
3085 GTK_PARAM_READABLE));
3088 * GtkWidget:link-color:
3090 * The "link-color" style property defines the color of unvisited links.
3094 gtk_widget_class_install_style_property (klass,
3095 g_param_spec_boxed ("link-color",
3096 P_("Unvisited Link Color"),
3097 P_("Color of unvisited links"),
3099 GTK_PARAM_READABLE));
3102 * GtkWidget:visited-link-color:
3104 * The "visited-link-color" style property defines the color of visited links.
3108 gtk_widget_class_install_style_property (klass,
3109 g_param_spec_boxed ("visited-link-color",
3110 P_("Visited Link Color"),
3111 P_("Color of visited links"),
3113 GTK_PARAM_READABLE));
3116 * GtkWidget:wide-separators:
3118 * The "wide-separators" style property defines whether separators have
3119 * configurable width and should be drawn using a box instead of a line.
3123 gtk_widget_class_install_style_property (klass,
3124 g_param_spec_boolean ("wide-separators",
3125 P_("Wide Separators"),
3126 P_("Whether separators have configurable width and should be drawn using a box instead of a line"),
3128 GTK_PARAM_READABLE));
3131 * GtkWidget:separator-width:
3133 * The "separator-width" style property defines the width of separators.
3134 * This property only takes effect if #GtkWidget:wide-separators is %TRUE.
3138 gtk_widget_class_install_style_property (klass,
3139 g_param_spec_int ("separator-width",
3140 P_("Separator Width"),
3141 P_("The width of separators if wide-separators is TRUE"),
3143 GTK_PARAM_READABLE));
3146 * GtkWidget:separator-height:
3148 * The "separator-height" style property defines the height of separators.
3149 * This property only takes effect if #GtkWidget:wide-separators is %TRUE.
3153 gtk_widget_class_install_style_property (klass,
3154 g_param_spec_int ("separator-height",
3155 P_("Separator Height"),
3156 P_("The height of separators if \"wide-separators\" is TRUE"),
3158 GTK_PARAM_READABLE));
3161 * GtkWidget:scroll-arrow-hlength:
3163 * The "scroll-arrow-hlength" style property defines the length of
3164 * horizontal scroll arrows.
3168 gtk_widget_class_install_style_property (klass,
3169 g_param_spec_int ("scroll-arrow-hlength",
3170 P_("Horizontal Scroll Arrow Length"),
3171 P_("The length of horizontal scroll arrows"),
3173 GTK_PARAM_READABLE));
3176 * GtkWidget:scroll-arrow-vlength:
3178 * The "scroll-arrow-vlength" style property defines the length of
3179 * vertical scroll arrows.
3183 gtk_widget_class_install_style_property (klass,
3184 g_param_spec_int ("scroll-arrow-vlength",
3185 P_("Vertical Scroll Arrow Length"),
3186 P_("The length of vertical scroll arrows"),
3188 GTK_PARAM_READABLE));
3190 g_type_class_add_private (klass, sizeof (GtkWidgetPrivate));
3194 gtk_widget_base_class_finalize (GtkWidgetClass *klass)
3198 list = g_param_spec_pool_list_owned (style_property_spec_pool, G_OBJECT_CLASS_TYPE (klass));
3199 for (node = list; node; node = node->next)
3201 GParamSpec *pspec = node->data;
3203 g_param_spec_pool_remove (style_property_spec_pool, pspec);
3204 g_param_spec_unref (pspec);
3210 gtk_widget_set_property (GObject *object,
3212 const GValue *value,
3215 GtkWidget *widget = GTK_WIDGET (object);
3220 gchar *tooltip_markup;
3221 const gchar *tooltip_text;
3222 GtkWindow *tooltip_window;
3225 gtk_widget_set_name (widget, g_value_get_string (value));
3228 gtk_container_add (GTK_CONTAINER (g_value_get_object (value)), widget);
3230 case PROP_WIDTH_REQUEST:
3231 gtk_widget_set_usize_internal (widget, g_value_get_int (value), -2, 0);
3233 case PROP_HEIGHT_REQUEST:
3234 gtk_widget_set_usize_internal (widget, -2, g_value_get_int (value), 0);
3237 gtk_widget_set_visible (widget, g_value_get_boolean (value));
3239 case PROP_SENSITIVE:
3240 gtk_widget_set_sensitive (widget, g_value_get_boolean (value));
3242 case PROP_APP_PAINTABLE:
3243 gtk_widget_set_app_paintable (widget, g_value_get_boolean (value));
3245 case PROP_CAN_FOCUS:
3246 gtk_widget_set_can_focus (widget, g_value_get_boolean (value));
3248 case PROP_HAS_FOCUS:
3249 if (g_value_get_boolean (value))
3250 gtk_widget_grab_focus (widget);
3253 if (g_value_get_boolean (value))
3254 gtk_widget_grab_focus (widget);
3256 case PROP_CAN_DEFAULT:
3257 gtk_widget_set_can_default (widget, g_value_get_boolean (value));
3259 case PROP_HAS_DEFAULT:
3260 if (g_value_get_boolean (value))
3261 gtk_widget_grab_default (widget);
3263 case PROP_RECEIVES_DEFAULT:
3264 gtk_widget_set_receives_default (widget, g_value_get_boolean (value));
3267 gtk_widget_set_style (widget, g_value_get_object (value));
3270 if (!gtk_widget_get_realized (widget) && gtk_widget_get_has_window (widget))
3271 gtk_widget_set_events (widget, g_value_get_flags (value));
3273 case PROP_EXTENSION_EVENTS:
3274 gtk_widget_set_extension_events (widget, g_value_get_enum (value));
3276 case PROP_NO_SHOW_ALL:
3277 gtk_widget_set_no_show_all (widget, g_value_get_boolean (value));
3279 case PROP_HAS_TOOLTIP:
3280 gtk_widget_real_set_has_tooltip (widget,
3281 g_value_get_boolean (value), FALSE);
3283 case PROP_TOOLTIP_MARKUP:
3284 tooltip_window = g_object_get_qdata (object, quark_tooltip_window);
3285 tooltip_markup = g_value_dup_string (value);
3287 /* Treat an empty string as a NULL string,
3288 * because an empty string would be useless for a tooltip:
3290 if (tooltip_markup && (strlen (tooltip_markup) == 0))
3292 g_free (tooltip_markup);
3293 tooltip_markup = NULL;
3296 g_object_set_qdata_full (object, quark_tooltip_markup,
3297 tooltip_markup, g_free);
3299 tmp = (tooltip_window != NULL || tooltip_markup != NULL);
3300 gtk_widget_real_set_has_tooltip (widget, tmp, FALSE);
3301 if (gtk_widget_get_visible (widget))
3302 gtk_widget_queue_tooltip_query (widget);
3304 case PROP_TOOLTIP_TEXT:
3305 tooltip_window = g_object_get_qdata (object, quark_tooltip_window);
3307 tooltip_text = g_value_get_string (value);
3309 /* Treat an empty string as a NULL string,
3310 * because an empty string would be useless for a tooltip:
3312 if (tooltip_text && (strlen (tooltip_text) == 0))
3313 tooltip_text = NULL;
3315 tooltip_markup = tooltip_text ? g_markup_escape_text (tooltip_text, -1) : NULL;
3317 g_object_set_qdata_full (object, quark_tooltip_markup,
3318 tooltip_markup, g_free);
3320 tmp = (tooltip_window != NULL || tooltip_markup != NULL);
3321 gtk_widget_real_set_has_tooltip (widget, tmp, FALSE);
3322 if (gtk_widget_get_visible (widget))
3323 gtk_widget_queue_tooltip_query (widget);
3325 case PROP_DOUBLE_BUFFERED:
3326 gtk_widget_set_double_buffered (widget, g_value_get_boolean (value));
3329 gtk_widget_set_halign (widget, g_value_get_enum (value));
3332 gtk_widget_set_valign (widget, g_value_get_enum (value));
3334 case PROP_MARGIN_LEFT:
3335 gtk_widget_set_margin_left (widget, g_value_get_int (value));
3337 case PROP_MARGIN_RIGHT:
3338 gtk_widget_set_margin_right (widget, g_value_get_int (value));
3340 case PROP_MARGIN_TOP:
3341 gtk_widget_set_margin_top (widget, g_value_get_int (value));
3343 case PROP_MARGIN_BOTTOM:
3344 gtk_widget_set_margin_bottom (widget, g_value_get_int (value));
3347 g_object_freeze_notify (G_OBJECT (widget));
3348 gtk_widget_set_margin_left (widget, g_value_get_int (value));
3349 gtk_widget_set_margin_right (widget, g_value_get_int (value));
3350 gtk_widget_set_margin_top (widget, g_value_get_int (value));
3351 gtk_widget_set_margin_bottom (widget, g_value_get_int (value));
3352 g_object_thaw_notify (G_OBJECT (widget));
3355 gtk_widget_set_hexpand (widget, g_value_get_boolean (value));
3357 case PROP_HEXPAND_SET:
3358 gtk_widget_set_hexpand_set (widget, g_value_get_boolean (value));
3361 gtk_widget_set_vexpand (widget, g_value_get_boolean (value));
3363 case PROP_VEXPAND_SET:
3364 gtk_widget_set_vexpand_set (widget, g_value_get_boolean (value));
3367 g_object_freeze_notify (G_OBJECT (widget));
3368 gtk_widget_set_hexpand (widget, g_value_get_boolean (value));
3369 gtk_widget_set_vexpand (widget, g_value_get_boolean (value));
3370 g_object_thaw_notify (G_OBJECT (widget));
3373 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3379 gtk_widget_get_property (GObject *object,
3384 GtkWidget *widget = GTK_WIDGET (object);
3385 GtkWidgetPrivate *priv = widget->priv;
3394 g_value_set_string (value, priv->name);
3396 g_value_set_static_string (value, "");
3399 g_value_set_object (value, priv->parent);
3401 case PROP_WIDTH_REQUEST:
3404 gtk_widget_get_size_request (widget, &w, NULL);
3405 g_value_set_int (value, w);
3408 case PROP_HEIGHT_REQUEST:
3411 gtk_widget_get_size_request (widget, NULL, &h);
3412 g_value_set_int (value, h);
3416 g_value_set_boolean (value, (gtk_widget_get_visible (widget) != FALSE));
3418 case PROP_SENSITIVE:
3419 g_value_set_boolean (value, (gtk_widget_get_sensitive (widget) != FALSE));
3421 case PROP_APP_PAINTABLE:
3422 g_value_set_boolean (value, (gtk_widget_get_app_paintable (widget) != FALSE));
3424 case PROP_CAN_FOCUS:
3425 g_value_set_boolean (value, (gtk_widget_get_can_focus (widget) != FALSE));
3427 case PROP_HAS_FOCUS:
3428 g_value_set_boolean (value, (gtk_widget_has_focus (widget) != FALSE));
3431 g_value_set_boolean (value, (gtk_widget_is_focus (widget)));
3433 case PROP_CAN_DEFAULT:
3434 g_value_set_boolean (value, (gtk_widget_get_can_default (widget) != FALSE));
3436 case PROP_HAS_DEFAULT:
3437 g_value_set_boolean (value, (gtk_widget_has_default (widget) != FALSE));
3439 case PROP_RECEIVES_DEFAULT:
3440 g_value_set_boolean (value, (gtk_widget_get_receives_default (widget) != FALSE));
3442 case PROP_COMPOSITE_CHILD:
3443 g_value_set_boolean (value, widget->priv->composite_child);
3446 g_value_set_object (value, gtk_widget_get_style (widget));
3449 eventp = g_object_get_qdata (G_OBJECT (widget), quark_event_mask);
3450 g_value_set_flags (value, GPOINTER_TO_INT (eventp));
3452 case PROP_EXTENSION_EVENTS:
3453 modep = g_object_get_qdata (G_OBJECT (widget), quark_extension_event_mode);
3454 g_value_set_enum (value, GPOINTER_TO_INT (modep));
3456 case PROP_NO_SHOW_ALL:
3457 g_value_set_boolean (value, gtk_widget_get_no_show_all (widget));
3459 case PROP_HAS_TOOLTIP:
3460 g_value_set_boolean (value, GPOINTER_TO_UINT (g_object_get_qdata (object, quark_has_tooltip)));
3462 case PROP_TOOLTIP_TEXT:
3464 gchar *escaped = g_object_get_qdata (object, quark_tooltip_markup);
3467 if (escaped && !pango_parse_markup (escaped, -1, 0, NULL, &text, NULL, NULL))
3468 g_assert (NULL == text); /* text should still be NULL in case of markup errors */
3470 g_value_take_string (value, text);
3473 case PROP_TOOLTIP_MARKUP:
3474 g_value_set_string (value, g_object_get_qdata (object, quark_tooltip_markup));
3477 g_value_set_object (value, gtk_widget_get_window (widget));
3479 case PROP_DOUBLE_BUFFERED:
3480 g_value_set_boolean (value, gtk_widget_get_double_buffered (widget));
3483 g_value_set_enum (value, gtk_widget_get_halign (widget));
3486 g_value_set_enum (value, gtk_widget_get_valign (widget));
3488 case PROP_MARGIN_LEFT:
3489 g_value_set_int (value, gtk_widget_get_margin_left (widget));
3491 case PROP_MARGIN_RIGHT:
3492 g_value_set_int (value, gtk_widget_get_margin_right (widget));
3494 case PROP_MARGIN_TOP:
3495 g_value_set_int (value, gtk_widget_get_margin_top (widget));
3497 case PROP_MARGIN_BOTTOM:
3498 g_value_set_int (value, gtk_widget_get_margin_bottom (widget));
3502 GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (widget, FALSE);
3503 if (aux_info == NULL)
3505 g_value_set_int (value, 0);
3509 g_value_set_int (value, MAX (MAX (aux_info->margin.left,
3510 aux_info->margin.right),
3511 MAX (aux_info->margin.top,
3512 aux_info->margin.bottom)));
3517 g_value_set_boolean (value, gtk_widget_get_hexpand (widget));
3519 case PROP_HEXPAND_SET:
3520 g_value_set_boolean (value, gtk_widget_get_hexpand_set (widget));
3523 g_value_set_boolean (value, gtk_widget_get_vexpand (widget));
3525 case PROP_VEXPAND_SET:
3526 g_value_set_boolean (value, gtk_widget_get_vexpand_set (widget));
3529 g_value_set_boolean (value,
3530 gtk_widget_get_hexpand (widget) &&
3531 gtk_widget_get_vexpand (widget));
3534 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3540 gtk_widget_init (GtkWidget *widget)
3542 GtkWidgetPrivate *priv;
3544 widget->priv = G_TYPE_INSTANCE_GET_PRIVATE (widget,
3547 priv = widget->priv;
3549 priv->child_visible = TRUE;
3550 priv->state = GTK_STATE_NORMAL;
3551 priv->saved_state = GTK_STATE_NORMAL;
3553 priv->allocation.x = -1;
3554 priv->allocation.y = -1;
3555 priv->allocation.width = 1;
3556 priv->allocation.height = 1;
3557 priv->window = NULL;
3558 priv->parent = NULL;
3560 priv->sensitive = TRUE;
3561 priv->parent_sensitive = TRUE;
3562 priv->composite_child = composite_child_stack != 0;
3563 priv->double_buffered = TRUE;
3564 priv->redraw_on_alloc = TRUE;
3565 priv->width_request_needed = TRUE;
3566 priv->height_request_needed = TRUE;
3567 priv->alloc_needed = TRUE;
3569 /* this will be set to TRUE if the widget gets a child or if the
3570 * expand flag is set on the widget, but until one of those happen
3571 * we know the expand is already properly FALSE.
3573 * We really want to default FALSE here to avoid computing expand
3574 * all over the place while initially building a widget tree.
3576 priv->need_compute_expand = FALSE;
3578 priv->style = gtk_widget_get_default_style ();
3579 g_object_ref (priv->style);
3584 gtk_widget_dispatch_child_properties_changed (GtkWidget *widget,
3586 GParamSpec **pspecs)
3588 GtkWidgetPrivate *priv = widget->priv;
3589 GtkWidget *container = priv->parent;
3592 for (i = 0; widget->priv->parent == container && i < n_pspecs; i++)
3593 g_signal_emit (widget, widget_signals[CHILD_NOTIFY], g_quark_from_string (pspecs[i]->name), pspecs[i]);
3597 * gtk_widget_freeze_child_notify:
3598 * @widget: a #GtkWidget
3600 * Stops emission of #GtkWidget::child-notify signals on @widget. The
3601 * signals are queued until gtk_widget_thaw_child_notify() is called
3604 * This is the analogue of g_object_freeze_notify() for child properties.
3607 gtk_widget_freeze_child_notify (GtkWidget *widget)
3609 g_return_if_fail (GTK_IS_WIDGET (widget));
3611 if (!G_OBJECT (widget)->ref_count)
3614 g_object_ref (widget);
3615 g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
3616 g_object_unref (widget);
3620 * gtk_widget_child_notify:
3621 * @widget: a #GtkWidget
3622 * @child_property: the name of a child property installed on the
3623 * class of @widget<!-- -->'s parent
3625 * Emits a #GtkWidget::child-notify signal for the
3626 * <link linkend="child-properties">child property</link> @child_property
3629 * This is the analogue of g_object_notify() for child properties.
3632 gtk_widget_child_notify (GtkWidget *widget,
3633 const gchar *child_property)
3635 GtkWidgetPrivate *priv = widget->priv;
3638 g_return_if_fail (GTK_IS_WIDGET (widget));
3639 g_return_if_fail (child_property != NULL);
3640 if (!G_OBJECT (widget)->ref_count || !priv->parent)
3643 g_object_ref (widget);
3644 pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool,
3646 G_OBJECT_TYPE (priv->parent),
3649 g_warning ("%s: container class `%s' has no child property named `%s'",
3651 G_OBJECT_TYPE_NAME (priv->parent),
3655 GObjectNotifyQueue *nqueue = g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
3657 g_object_notify_queue_add (G_OBJECT (widget), nqueue, pspec);
3658 g_object_notify_queue_thaw (G_OBJECT (widget), nqueue);
3660 g_object_unref (widget);
3664 * gtk_widget_thaw_child_notify:
3665 * @widget: a #GtkWidget
3667 * Reverts the effect of a previous call to gtk_widget_freeze_child_notify().
3668 * This causes all queued #GtkWidget::child-notify signals on @widget to be
3672 gtk_widget_thaw_child_notify (GtkWidget *widget)
3674 GObjectNotifyQueue *nqueue;
3676 g_return_if_fail (GTK_IS_WIDGET (widget));
3678 if (!G_OBJECT (widget)->ref_count)
3681 g_object_ref (widget);
3682 nqueue = g_object_notify_queue_from_object (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
3683 if (!nqueue || !nqueue->freeze_count)
3684 g_warning (G_STRLOC ": child-property-changed notification for %s(%p) is not frozen",
3685 G_OBJECT_TYPE_NAME (widget), widget);
3687 g_object_notify_queue_thaw (G_OBJECT (widget), nqueue);
3688 g_object_unref (widget);
3694 * @type: type ID of the widget to create
3695 * @first_property_name: name of first property to set
3696 * @Varargs: value of first property, followed by more properties,
3699 * This is a convenience function for creating a widget and setting
3700 * its properties in one go. For example you might write:
3701 * <literal>gtk_widget_new (GTK_TYPE_LABEL, "label", "Hello World", "xalign",
3702 * 0.0, NULL)</literal> to create a left-aligned label. Equivalent to
3703 * g_object_new(), but returns a widget so you don't have to
3704 * cast the object yourself.
3706 * Return value: a new #GtkWidget of type @widget_type
3709 gtk_widget_new (GType type,
3710 const gchar *first_property_name,
3716 g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), NULL);
3718 va_start (var_args, first_property_name);
3719 widget = (GtkWidget *)g_object_new_valist (type, first_property_name, var_args);
3726 gtk_widget_queue_draw_child (GtkWidget *widget)
3728 GtkWidgetPrivate *priv = widget->priv;
3731 parent = priv->parent;
3732 if (parent && gtk_widget_is_drawable (parent))
3733 gtk_widget_queue_draw_area (parent,
3736 priv->allocation.width,
3737 priv->allocation.height);
3741 * gtk_widget_unparent:
3742 * @widget: a #GtkWidget
3744 * This function is only for use in widget implementations.
3745 * Should be called by implementations of the remove method
3746 * on #GtkContainer, to dissociate a child from the container.
3749 gtk_widget_unparent (GtkWidget *widget)
3751 GtkWidgetPrivate *priv;
3752 GObjectNotifyQueue *nqueue;
3753 GtkWidget *toplevel;
3754 GtkWidget *old_parent;
3756 g_return_if_fail (GTK_IS_WIDGET (widget));
3758 priv = widget->priv;
3760 if (priv->parent == NULL)
3763 /* keep this function in sync with gtk_menu_detach()
3766 g_object_freeze_notify (G_OBJECT (widget));
3767 nqueue = g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
3769 toplevel = gtk_widget_get_toplevel (widget);
3770 if (gtk_widget_is_toplevel (toplevel))
3771 _gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
3773 if (gtk_container_get_focus_child (GTK_CONTAINER (priv->parent)) == widget)
3774 gtk_container_set_focus_child (GTK_CONTAINER (priv->parent), NULL);
3776 /* If we are unanchoring the child, we save around the toplevel
3777 * to emit hierarchy changed
3779 if (priv->parent->priv->anchored)
3780 g_object_ref (toplevel);
3784 gtk_widget_queue_draw_child (widget);
3786 /* Reset the width and height here, to force reallocation if we
3787 * get added back to a new parent. This won't work if our new
3788 * allocation is smaller than 1x1 and we actually want a size of 1x1...
3789 * (would 0x0 be OK here?)
3791 priv->allocation.width = 1;
3792 priv->allocation.height = 1;
3794 if (gtk_widget_get_realized (widget))
3796 if (priv->in_reparent)
3797 gtk_widget_unmap (widget);
3799 gtk_widget_unrealize (widget);
3802 /* Removing a widget from a container restores the child visible
3803 * flag to the default state, so it doesn't affect the child
3804 * in the next parent.
3806 priv->child_visible = TRUE;
3808 old_parent = priv->parent;
3809 priv->parent = NULL;
3810 gtk_widget_set_parent_window (widget, NULL);
3812 /* parent may no longer expand if the removed
3813 * child was expand=TRUE and could therefore
3816 if (gtk_widget_get_visible (widget) &&
3817 (priv->need_compute_expand ||
3818 priv->computed_hexpand ||
3819 priv->computed_vexpand))
3821 gtk_widget_queue_compute_expand (old_parent);
3824 g_signal_emit (widget, widget_signals[PARENT_SET], 0, old_parent);
3827 _gtk_widget_propagate_hierarchy_changed (widget, toplevel);
3828 g_object_unref (toplevel);
3831 g_object_notify (G_OBJECT (widget), "parent");
3832 g_object_thaw_notify (G_OBJECT (widget));
3834 g_object_notify_queue_clear (G_OBJECT (widget), nqueue);
3835 g_object_notify_queue_thaw (G_OBJECT (widget), nqueue);
3836 g_object_unref (widget);
3840 * gtk_widget_destroy:
3841 * @widget: a #GtkWidget
3843 * Destroys a widget.
3846 * destroyed, it will break any references it holds to other objects.
3847 * If the widget is inside a container, the widget will be removed
3848 * from the container. If the widget is a toplevel (derived from
3849 * #GtkWindow), it will be removed from the list of toplevels, and the
3850 * reference GTK+ holds to it will be removed. Removing a
3851 * widget from its container or the list of toplevels results in the
3852 * widget being finalized, unless you've added additional references
3853 * to the widget with g_object_ref().
3855 * In most cases, only toplevel widgets (windows) require explicit
3856 * destruction, because when you destroy a toplevel its children will
3857 * be destroyed as well.
3860 gtk_widget_destroy (GtkWidget *widget)
3862 g_return_if_fail (GTK_IS_WIDGET (widget));
3864 if (!widget->priv->in_destruction)
3865 g_object_run_dispose (G_OBJECT (widget));
3869 * gtk_widget_destroyed:
3870 * @widget: a #GtkWidget
3871 * @widget_pointer: (inout) (transfer none): address of a variable that contains @widget
3873 * This function sets *@widget_pointer to %NULL if @widget_pointer !=
3874 * %NULL. It's intended to be used as a callback connected to the
3875 * "destroy" signal of a widget. You connect gtk_widget_destroyed()
3876 * as a signal handler, and pass the address of your widget variable
3877 * as user data. Then when the widget is destroyed, the variable will
3878 * be set to %NULL. Useful for example to avoid multiple copies
3879 * of the same dialog.
3882 gtk_widget_destroyed (GtkWidget *widget,
3883 GtkWidget **widget_pointer)
3885 /* Don't make any assumptions about the
3887 * Even check widget_pointer.
3890 *widget_pointer = NULL;
3895 * @widget: a #GtkWidget
3897 * Flags a widget to be displayed. Any widget that isn't shown will
3898 * not appear on the screen. If you want to show all the widgets in a
3899 * container, it's easier to call gtk_widget_show_all() on the
3900 * container, instead of individually showing the widgets.
3902 * Remember that you have to show the containers containing a widget,
3903 * in addition to the widget itself, before it will appear onscreen.
3905 * When a toplevel container is shown, it is immediately realized and
3906 * mapped; other shown widgets are realized and mapped when their
3907 * toplevel container is realized and mapped.
3910 gtk_widget_show (GtkWidget *widget)
3912 g_return_if_fail (GTK_IS_WIDGET (widget));
3914 if (!gtk_widget_get_visible (widget))
3916 g_object_ref (widget);
3917 if (!gtk_widget_is_toplevel (widget))
3918 gtk_widget_queue_resize (widget);
3920 /* see comment in set_parent() for why this should and can be
3923 if (widget->priv->need_compute_expand ||
3924 widget->priv->computed_hexpand ||
3925 widget->priv->computed_vexpand)
3927 if (widget->priv->parent != NULL)
3928 gtk_widget_queue_compute_expand (widget->priv->parent);
3931 g_signal_emit (widget, widget_signals[SHOW], 0);
3932 g_object_notify (G_OBJECT (widget), "visible");
3933 g_object_unref (widget);
3938 gtk_widget_real_show (GtkWidget *widget)
3940 GtkWidgetPrivate *priv = widget->priv;
3942 if (!gtk_widget_get_visible (widget))
3944 priv->visible = TRUE;
3947 gtk_widget_get_mapped (priv->parent) &&
3948 gtk_widget_get_child_visible (widget) &&
3949 !gtk_widget_get_mapped (widget))
3950 gtk_widget_map (widget);
3955 gtk_widget_show_map_callback (GtkWidget *widget, GdkEvent *event, gint *flag)
3958 g_signal_handlers_disconnect_by_func (widget,
3959 gtk_widget_show_map_callback,
3964 * gtk_widget_show_now:
3965 * @widget: a #GtkWidget
3967 * Shows a widget. If the widget is an unmapped toplevel widget
3968 * (i.e. a #GtkWindow that has not yet been shown), enter the main
3969 * loop and wait for the window to actually be mapped. Be careful;
3970 * because the main loop is running, anything can happen during
3974 gtk_widget_show_now (GtkWidget *widget)
3978 g_return_if_fail (GTK_IS_WIDGET (widget));
3980 /* make sure we will get event */
3981 if (!gtk_widget_get_mapped (widget) &&
3982 gtk_widget_is_toplevel (widget))
3984 gtk_widget_show (widget);
3986 g_signal_connect (widget, "map-event",
3987 G_CALLBACK (gtk_widget_show_map_callback),
3991 gtk_main_iteration ();
3994 gtk_widget_show (widget);
3999 * @widget: a #GtkWidget
4001 * Reverses the effects of gtk_widget_show(), causing the widget to be
4002 * hidden (invisible to the user).
4005 gtk_widget_hide (GtkWidget *widget)
4007 g_return_if_fail (GTK_IS_WIDGET (widget));
4009 if (gtk_widget_get_visible (widget))
4011 GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
4013 g_object_ref (widget);
4014 if (toplevel != widget && gtk_widget_is_toplevel (toplevel))
4015 _gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
4017 /* a parent may now be expand=FALSE since we're hidden. */
4018 if (widget->priv->need_compute_expand ||
4019 widget->priv->computed_hexpand ||
4020 widget->priv->computed_vexpand)
4022 gtk_widget_queue_compute_expand (widget);
4025 g_signal_emit (widget, widget_signals[HIDE], 0);
4026 if (!gtk_widget_is_toplevel (widget))
4027 gtk_widget_queue_resize (widget);
4028 g_object_notify (G_OBJECT (widget), "visible");
4029 g_object_unref (widget);
4034 gtk_widget_real_hide (GtkWidget *widget)
4036 if (gtk_widget_get_visible (widget))
4038 widget->priv->visible = FALSE;
4040 if (gtk_widget_get_mapped (widget))
4041 gtk_widget_unmap (widget);
4046 * gtk_widget_hide_on_delete:
4047 * @widget: a #GtkWidget
4049 * Utility function; intended to be connected to the #GtkWidget::delete-event
4050 * signal on a #GtkWindow. The function calls gtk_widget_hide() on its
4051 * argument, then returns %TRUE. If connected to ::delete-event, the
4052 * result is that clicking the close button for a window (on the
4053 * window frame, top right corner usually) will hide but not destroy
4054 * the window. By default, GTK+ destroys windows when ::delete-event
4057 * Return value: %TRUE
4060 gtk_widget_hide_on_delete (GtkWidget *widget)
4062 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
4064 gtk_widget_hide (widget);
4070 * gtk_widget_show_all:
4071 * @widget: a #GtkWidget
4073 * Recursively shows a widget, and any child widgets (if the widget is
4077 gtk_widget_show_all (GtkWidget *widget)
4079 GtkWidgetClass *class;
4081 g_return_if_fail (GTK_IS_WIDGET (widget));
4083 if (gtk_widget_get_no_show_all (widget))
4086 class = GTK_WIDGET_GET_CLASS (widget);
4088 if (class->show_all)
4089 class->show_all (widget);
4094 * @widget: a #GtkWidget
4096 * This function is only for use in widget implementations. Causes
4097 * a widget to be mapped if it isn't already.
4100 gtk_widget_map (GtkWidget *widget)
4102 GtkWidgetPrivate *priv;
4104 g_return_if_fail (GTK_IS_WIDGET (widget));
4105 g_return_if_fail (gtk_widget_get_visible (widget));
4106 g_return_if_fail (gtk_widget_get_child_visible (widget));
4108 priv = widget->priv;
4110 if (!gtk_widget_get_mapped (widget))
4112 if (!gtk_widget_get_realized (widget))
4113 gtk_widget_realize (widget);
4115 g_signal_emit (widget, widget_signals[MAP], 0);
4117 if (!gtk_widget_get_has_window (widget))
4118 gdk_window_invalidate_rect (priv->window, &priv->allocation, FALSE);
4124 * @widget: a #GtkWidget
4126 * This function is only for use in widget implementations. Causes
4127 * a widget to be unmapped if it's currently mapped.
4130 gtk_widget_unmap (GtkWidget *widget)
4132 GtkWidgetPrivate *priv;
4134 g_return_if_fail (GTK_IS_WIDGET (widget));
4136 priv = widget->priv;
4138 if (gtk_widget_get_mapped (widget))
4140 if (!gtk_widget_get_has_window (widget))
4141 gdk_window_invalidate_rect (priv->window, &priv->allocation, FALSE);
4142 _gtk_tooltip_hide (widget);
4143 g_signal_emit (widget, widget_signals[UNMAP], 0);
4148 gtk_widget_set_extension_events_internal (GtkWidget *widget,
4149 GdkExtensionMode mode,
4152 GtkWidgetPrivate *priv = widget->priv;
4153 GList *free_list = NULL;
4156 if (window_list == NULL)
4158 if (gtk_widget_get_has_window (widget))
4159 window_list = g_list_prepend (NULL, priv->window);
4161 window_list = gdk_window_get_children (priv->window);
4163 free_list = window_list;
4166 for (l = window_list; l != NULL; l = l->next)
4168 GdkWindow *window = l->data;
4171 gdk_window_get_user_data (window, &user_data);
4172 if (user_data == widget)
4176 gdk_input_set_extension_events (window,
4177 gdk_window_get_events (window),
4180 children = gdk_window_get_children (window);
4183 gtk_widget_set_extension_events_internal (widget, mode, children);
4184 g_list_free (children);
4190 g_list_free (free_list);
4194 _gtk_widget_enable_device_events (GtkWidget *widget)
4196 GHashTable *device_events;
4197 GHashTableIter iter;
4198 gpointer key, value;
4200 device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
4205 g_hash_table_iter_init (&iter, device_events);
4207 while (g_hash_table_iter_next (&iter, &key, &value))
4210 GdkEventMask event_mask;
4213 event_mask = GPOINTER_TO_UINT (value);
4214 gtk_widget_add_events_internal (widget, device, event_mask);
4219 * gtk_widget_realize:
4220 * @widget: a #GtkWidget
4222 * Creates the GDK (windowing system) resources associated with a
4223 * widget. For example, @widget->window will be created when a widget
4224 * is realized. Normally realization happens implicitly; if you show
4225 * a widget and all its parent containers, then the widget will be
4226 * realized and mapped automatically.
4228 * Realizing a widget requires all
4229 * the widget's parent widgets to be realized; calling
4230 * gtk_widget_realize() realizes the widget's parents in addition to
4231 * @widget itself. If a widget is not yet inside a toplevel window
4232 * when you realize it, bad things will happen.
4234 * This function is primarily used in widget implementations, and
4235 * isn't very useful otherwise. Many times when you think you might
4236 * need it, a better approach is to connect to a signal that will be
4237 * called after the widget is realized automatically, such as
4238 * GtkWidget::expose-event. Or simply g_signal_connect () to the
4239 * GtkWidget::realize signal.
4242 gtk_widget_realize (GtkWidget *widget)
4244 GtkWidgetPrivate *priv;
4245 GdkExtensionMode mode;
4246 cairo_region_t *region;
4248 g_return_if_fail (GTK_IS_WIDGET (widget));
4249 g_return_if_fail (widget->priv->anchored ||
4250 GTK_IS_INVISIBLE (widget));
4252 priv = widget->priv;
4254 if (!gtk_widget_get_realized (widget))
4257 if (GTK_IS_CONTAINER (widget) && gtk_widget_get_has_window (widget))
4258 g_message ("gtk_widget_realize(%s)", G_OBJECT_TYPE_NAME (widget));
4261 if (priv->parent == NULL &&
4262 !gtk_widget_is_toplevel (widget))
4263 g_warning ("Calling gtk_widget_realize() on a widget that isn't "
4264 "inside a toplevel window is not going to work very well. "
4265 "Widgets must be inside a toplevel container before realizing them.");
4267 if (priv->parent && !gtk_widget_get_realized (priv->parent))
4268 gtk_widget_realize (priv->parent);
4270 gtk_widget_ensure_style (widget);
4272 g_signal_emit (widget, widget_signals[REALIZE], 0);
4274 gtk_widget_real_set_has_tooltip (widget,
4275 GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (widget), quark_has_tooltip)),
4278 if (priv->has_shape_mask)
4280 region = g_object_get_qdata (G_OBJECT (widget), quark_shape_info);
4281 gdk_window_shape_combine_region (priv->window, region, 0, 0);
4284 region = g_object_get_qdata (G_OBJECT (widget), quark_input_shape_info);
4286 gdk_window_input_shape_combine_region (priv->window, region, 0, 0);
4288 mode = gtk_widget_get_extension_events (widget);
4289 if (mode != GDK_EXTENSION_EVENTS_NONE)
4290 gtk_widget_set_extension_events_internal (widget, mode, NULL);
4292 if (priv->multidevice)
4293 gdk_window_set_support_multidevice (priv->window, TRUE);
4295 _gtk_widget_enable_device_events (widget);
4300 * gtk_widget_unrealize:
4301 * @widget: a #GtkWidget
4303 * This function is only useful in widget implementations.
4304 * Causes a widget to be unrealized (frees all GDK resources
4305 * associated with the widget, such as @widget->window).
4308 gtk_widget_unrealize (GtkWidget *widget)
4310 g_return_if_fail (GTK_IS_WIDGET (widget));
4312 if (widget->priv->has_shape_mask)
4313 gtk_widget_shape_combine_region (widget, NULL);
4315 if (g_object_get_qdata (G_OBJECT (widget), quark_input_shape_info))
4316 gtk_widget_input_shape_combine_region (widget, NULL);
4318 if (gtk_widget_get_realized (widget))
4320 g_object_ref (widget);
4321 _gtk_tooltip_hide (widget);
4322 g_signal_emit (widget, widget_signals[UNREALIZE], 0);
4323 gtk_widget_set_realized (widget, FALSE);
4324 gtk_widget_set_mapped (widget, FALSE);
4325 g_object_unref (widget);
4329 /*****************************************
4331 *****************************************/
4334 * gtk_widget_queue_draw_region:
4335 * @widget: a #GtkWidget
4336 * @region: region to draw
4338 * Invalidates the rectangular area of @widget defined by @region by
4339 * calling gdk_window_invalidate_region() on the widget's window and
4340 * all its child windows. Once the main loop becomes idle (after the
4341 * current batch of events has been processed, roughly), the window
4342 * will receive expose events for the union of all regions that have
4345 * Normally you would only use this function in widget
4346 * implementations. You might also use it to schedule a redraw of a
4347 * #GtkDrawingArea or some portion thereof.
4350 gtk_widget_queue_draw_region (GtkWidget *widget,
4351 cairo_region_t *region)
4353 GtkWidgetPrivate *priv;
4356 g_return_if_fail (GTK_IS_WIDGET (widget));
4358 priv = widget->priv;
4360 if (!gtk_widget_get_realized (widget))
4363 /* Just return if the widget or one of its ancestors isn't mapped */
4364 for (w = widget; w != NULL; w = w->priv->parent)
4365 if (!gtk_widget_get_mapped (w))
4368 gdk_window_invalidate_region (priv->window, region, TRUE);
4372 * gtk_widget_queue_draw_area:
4373 * @widget: a #GtkWidget
4374 * @x: x coordinate of upper-left corner of rectangle to redraw
4375 * @y: y coordinate of upper-left corner of rectangle to redraw
4376 * @width: width of region to draw
4377 * @height: height of region to draw
4379 * Convenience function that calls gtk_widget_queue_draw_region() on
4380 * the region created from the given coordinates.
4383 gtk_widget_queue_draw_area (GtkWidget *widget,
4390 cairo_region_t *region;
4392 g_return_if_fail (GTK_IS_WIDGET (widget));
4397 rect.height = height;
4399 region = cairo_region_create_rectangle (&rect);
4400 gtk_widget_queue_draw_region (widget, region);
4401 cairo_region_destroy (region);
4405 * gtk_widget_queue_draw:
4406 * @widget: a #GtkWidget
4408 * Equivalent to calling gtk_widget_queue_draw_area() for the
4409 * entire area of a widget.
4412 gtk_widget_queue_draw (GtkWidget *widget)
4416 g_return_if_fail (GTK_IS_WIDGET (widget));
4418 gtk_widget_get_allocation (widget, &rect);
4420 if (!gtk_widget_get_has_window (widget))
4421 gtk_widget_queue_draw_area (widget,
4422 rect.x, rect.y, rect.width, rect.height);
4424 gtk_widget_queue_draw_area (widget,
4425 0, 0, rect.width, rect.height);
4429 * gtk_widget_queue_resize:
4430 * @widget: a #GtkWidget
4432 * This function is only for use in widget implementations.
4433 * Flags a widget to have its size renegotiated; should
4434 * be called when a widget for some reason has a new size request.
4435 * For example, when you change the text in a #GtkLabel, #GtkLabel
4436 * queues a resize to ensure there's enough space for the new text.
4439 gtk_widget_queue_resize (GtkWidget *widget)
4441 g_return_if_fail (GTK_IS_WIDGET (widget));
4443 if (gtk_widget_get_realized (widget))
4444 gtk_widget_queue_shallow_draw (widget);
4446 _gtk_size_group_queue_resize (widget, 0);
4450 * gtk_widget_queue_resize_no_redraw:
4451 * @widget: a #GtkWidget
4453 * This function works like gtk_widget_queue_resize(),
4454 * except that the widget is not invalidated.
4459 gtk_widget_queue_resize_no_redraw (GtkWidget *widget)
4461 g_return_if_fail (GTK_IS_WIDGET (widget));
4463 _gtk_size_group_queue_resize (widget, 0);
4467 * gtk_widget_size_request:
4468 * @widget: a #GtkWidget
4469 * @requisition: (out): a #GtkRequisition to be filled in
4471 * This function is typically used when implementing a #GtkContainer
4472 * subclass. Obtains the preferred size of a widget. The container
4473 * uses this information to arrange its child widgets and decide what
4474 * size allocations to give them with gtk_widget_size_allocate().
4476 * You can also call this function from an application, with some
4477 * caveats. Most notably, getting a size request requires the widget
4478 * to be associated with a screen, because font information may be
4479 * needed. Multihead-aware applications should keep this in mind.
4481 * Also remember that the size request is not necessarily the size
4482 * a widget will actually be allocated.
4484 * Deprecated: 3.0: Use gtk_widget_get_preferred_size() instead.
4487 gtk_widget_size_request (GtkWidget *widget,
4488 GtkRequisition *requisition)
4490 g_return_if_fail (GTK_IS_WIDGET (widget));
4492 gtk_widget_get_preferred_size (widget, requisition, NULL);
4496 * gtk_widget_get_child_requisition:
4497 * @widget: a #GtkWidget
4498 * @requisition: (out): a #GtkRequisition to be filled in
4500 * This function is only for use in widget implementations. Obtains
4501 * @widget->requisition, unless someone has forced a particular
4502 * geometry on the widget (e.g. with gtk_widget_set_size_request()),
4503 * in which case it returns that geometry instead of the widget's
4506 * This function differs from gtk_widget_size_request() in that
4507 * it retrieves the last size request value from @widget->requisition,
4508 * while gtk_widget_size_request() actually calls the "size_request" method
4509 * on @widget to compute the size request and fill in @widget->requisition,
4510 * and only then returns @widget->requisition.
4512 * Because this function does not call the "size_request" method, it
4513 * can only be used when you know that @widget->requisition is
4514 * up-to-date, that is, gtk_widget_size_request() has been called
4515 * since the last time a resize was queued. In general, only container
4516 * implementations have this information; applications should use
4517 * gtk_widget_size_request().
4520 * Deprecated: 3.0: Use gtk_widget_get_preferred_size() instead.
4523 gtk_widget_get_child_requisition (GtkWidget *widget,
4524 GtkRequisition *requisition)
4526 gtk_widget_get_preferred_size (widget, requisition, NULL);
4530 invalidate_predicate (GdkWindow *window,
4535 gdk_window_get_user_data (window, &user_data);
4537 return (user_data == data);
4540 /* Invalidate @region in widget->window and all children
4541 * of widget->window owned by widget. @region is in the
4542 * same coordinates as widget->allocation and will be
4543 * modified by this call.
4546 gtk_widget_invalidate_widget_windows (GtkWidget *widget,
4547 cairo_region_t *region)
4549 GtkWidgetPrivate *priv = widget->priv;
4551 if (!gtk_widget_get_realized (widget))
4554 if (gtk_widget_get_has_window (widget) && priv->parent)
4558 gdk_window_get_position (priv->window, &x, &y);
4559 cairo_region_translate (region, -x, -y);
4562 gdk_window_invalidate_maybe_recurse (priv->window, region,
4563 invalidate_predicate, widget);
4567 * gtk_widget_queue_shallow_draw:
4568 * @widget: a #GtkWidget
4570 * Like gtk_widget_queue_draw(), but only windows owned
4571 * by @widget are invalidated.
4574 gtk_widget_queue_shallow_draw (GtkWidget *widget)
4577 cairo_region_t *region;
4579 if (!gtk_widget_get_realized (widget))
4582 gtk_widget_get_allocation (widget, &rect);
4584 region = cairo_region_create_rectangle (&rect);
4585 gtk_widget_invalidate_widget_windows (widget, region);
4586 cairo_region_destroy (region);
4590 * gtk_widget_size_allocate:
4591 * @widget: a #GtkWidget
4592 * @allocation: (inout): position and size to be allocated to @widget
4594 * This function is only used by #GtkContainer subclasses, to assign a size
4595 * and position to their child widgets.
4597 * In this function, the allocation may be adjusted. It will be forced
4598 * to a 1x1 minimum size, and the adjust_size_allocation virtual
4599 * method on the child will be used to adjust the allocation. Standard
4600 * adjustments include removing the widget's margins, and applying the
4601 * widget's #GtkWidget:halign and #GtkWidget:valign properties.
4604 gtk_widget_size_allocate (GtkWidget *widget,
4605 GtkAllocation *allocation)
4607 GtkWidgetPrivate *priv;
4608 GdkRectangle real_allocation;
4609 GdkRectangle old_allocation;
4610 GdkRectangle adjusted_allocation;
4611 gboolean alloc_needed;
4612 gboolean size_changed;
4613 gboolean position_changed;
4614 gint natural_width, natural_height;
4615 gint min_width, min_height;
4617 priv = widget->priv;
4619 g_return_if_fail (GTK_IS_WIDGET (widget));
4621 #ifdef G_ENABLE_DEBUG
4622 if (gtk_get_debug_flags () & GTK_DEBUG_GEOMETRY)
4633 parent = gtk_widget_get_parent (parent);
4636 name = g_type_name (G_OBJECT_TYPE (G_OBJECT (widget)));
4637 g_print ("gtk_widget_size_allocate: %*s%s %d %d\n",
4638 2 * depth, " ", name,
4639 allocation->width, allocation->height);
4641 #endif /* G_ENABLE_DEBUG */
4643 alloc_needed = priv->alloc_needed;
4644 if (!priv->width_request_needed && !priv->height_request_needed)
4645 /* Preserve request/allocate ordering */
4646 priv->alloc_needed = FALSE;
4648 old_allocation = priv->allocation;
4649 real_allocation = *allocation;
4651 adjusted_allocation = real_allocation;
4652 if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
4654 /* Go ahead and request the height for allocated width, note that the internals
4655 * of get_height_for_width will internally limit the for_size to natural size
4656 * when aligning implicitly.
4658 gtk_widget_get_preferred_width (widget, &min_width, &natural_width);
4659 gtk_widget_get_preferred_height_for_width (widget, real_allocation.width, NULL, &natural_height);
4663 /* Go ahead and request the width for allocated height, note that the internals
4664 * of get_width_for_height will internally limit the for_size to natural size
4665 * when aligning implicitly.
4667 gtk_widget_get_preferred_height (widget, &min_height, &natural_height);
4668 gtk_widget_get_preferred_width_for_height (widget, real_allocation.height, NULL, &natural_width);
4671 /* Now that we have the right natural height and width, go ahead and remove any margins from the
4672 * allocated sizes and possibly limit them to the natural sizes */
4673 GTK_WIDGET_GET_CLASS (widget)->adjust_size_allocation (widget,
4674 GTK_ORIENTATION_HORIZONTAL,
4676 &adjusted_allocation.x,
4677 &adjusted_allocation.width);
4678 GTK_WIDGET_GET_CLASS (widget)->adjust_size_allocation (widget,
4679 GTK_ORIENTATION_VERTICAL,
4681 &adjusted_allocation.y,
4682 &adjusted_allocation.height);
4684 if (adjusted_allocation.x < real_allocation.x ||
4685 adjusted_allocation.y < real_allocation.y ||
4686 (adjusted_allocation.x + adjusted_allocation.width) >
4687 (real_allocation.x + real_allocation.width) ||
4688 (adjusted_allocation.y + adjusted_allocation.height >
4689 real_allocation.y + real_allocation.height))
4691 g_warning ("%s %p attempted to adjust its size allocation from %d,%d %dx%d to %d,%d %dx%d. adjust_size_allocation must keep allocation inside original bounds",
4692 G_OBJECT_TYPE_NAME (widget), widget,
4693 real_allocation.x, real_allocation.y, real_allocation.width, real_allocation.height,
4694 adjusted_allocation.x, adjusted_allocation.y, adjusted_allocation.width, adjusted_allocation.height);
4695 adjusted_allocation = real_allocation; /* veto it */
4699 real_allocation = adjusted_allocation;
4702 if (real_allocation.width < 0 || real_allocation.height < 0)
4704 g_warning ("gtk_widget_size_allocate(): attempt to allocate widget with width %d and height %d",
4705 real_allocation.width,
4706 real_allocation.height);
4709 real_allocation.width = MAX (real_allocation.width, 1);
4710 real_allocation.height = MAX (real_allocation.height, 1);
4712 size_changed = (old_allocation.width != real_allocation.width ||
4713 old_allocation.height != real_allocation.height);
4714 position_changed = (old_allocation.x != real_allocation.x ||
4715 old_allocation.y != real_allocation.y);
4717 if (!alloc_needed && !size_changed && !position_changed)
4720 g_signal_emit (widget, widget_signals[SIZE_ALLOCATE], 0, &real_allocation);
4722 if (gtk_widget_get_mapped (widget))
4724 if (!gtk_widget_get_has_window (widget) && priv->redraw_on_alloc && position_changed)
4726 /* Invalidate union(old_allaction,priv->allocation) in priv->window
4728 cairo_region_t *invalidate = cairo_region_create_rectangle (&priv->allocation);
4729 cairo_region_union_rectangle (invalidate, &old_allocation);
4731 gdk_window_invalidate_region (priv->window, invalidate, FALSE);
4732 cairo_region_destroy (invalidate);
4737 if (priv->redraw_on_alloc)
4739 /* Invalidate union(old_allaction,priv->allocation) in priv->window and descendents owned by widget
4741 cairo_region_t *invalidate = cairo_region_create_rectangle (&priv->allocation);
4742 cairo_region_union_rectangle (invalidate, &old_allocation);
4744 gtk_widget_invalidate_widget_windows (widget, invalidate);
4745 cairo_region_destroy (invalidate);
4750 if ((size_changed || position_changed) && priv->parent &&
4751 gtk_widget_get_realized (priv->parent) && _gtk_container_get_reallocate_redraws (GTK_CONTAINER (priv->parent)))
4753 cairo_region_t *invalidate = cairo_region_create_rectangle (&priv->parent->priv->allocation);
4754 gtk_widget_invalidate_widget_windows (priv->parent, invalidate);
4755 cairo_region_destroy (invalidate);
4760 * gtk_widget_common_ancestor:
4761 * @widget_a: a #GtkWidget
4762 * @widget_b: a #GtkWidget
4764 * Find the common ancestor of @widget_a and @widget_b that
4765 * is closest to the two widgets.
4767 * Return value: the closest common ancestor of @widget_a and
4768 * @widget_b or %NULL if @widget_a and @widget_b do not
4769 * share a common ancestor.
4772 gtk_widget_common_ancestor (GtkWidget *widget_a,
4773 GtkWidget *widget_b)
4775 GtkWidget *parent_a;
4776 GtkWidget *parent_b;
4780 parent_a = widget_a;
4781 while (parent_a->priv->parent)
4783 parent_a = parent_a->priv->parent;
4787 parent_b = widget_b;
4788 while (parent_b->priv->parent)
4790 parent_b = parent_b->priv->parent;
4794 if (parent_a != parent_b)
4797 while (depth_a > depth_b)
4799 widget_a = widget_a->priv->parent;
4803 while (depth_b > depth_a)
4805 widget_b = widget_b->priv->parent;
4809 while (widget_a != widget_b)
4811 widget_a = widget_a->priv->parent;
4812 widget_b = widget_b->priv->parent;
4819 * gtk_widget_translate_coordinates:
4820 * @src_widget: a #GtkWidget
4821 * @dest_widget: a #GtkWidget
4822 * @src_x: X position relative to @src_widget
4823 * @src_y: Y position relative to @src_widget
4824 * @dest_x: (out): location to store X position relative to @dest_widget
4825 * @dest_y: (out): location to store Y position relative to @dest_widget
4827 * Translate coordinates relative to @src_widget's allocation to coordinates
4828 * relative to @dest_widget's allocations. In order to perform this
4829 * operation, both widgets must be realized, and must share a common
4832 * Return value: %FALSE if either widget was not realized, or there
4833 * was no common ancestor. In this case, nothing is stored in
4834 * *@dest_x and *@dest_y. Otherwise %TRUE.
4837 gtk_widget_translate_coordinates (GtkWidget *src_widget,
4838 GtkWidget *dest_widget,
4844 GtkWidgetPrivate *src_priv = src_widget->priv;
4845 GtkWidgetPrivate *dest_priv = dest_widget->priv;
4846 GtkWidget *ancestor;
4848 GList *dest_list = NULL;
4850 g_return_val_if_fail (GTK_IS_WIDGET (src_widget), FALSE);
4851 g_return_val_if_fail (GTK_IS_WIDGET (dest_widget), FALSE);
4853 ancestor = gtk_widget_common_ancestor (src_widget, dest_widget);
4854 if (!ancestor || !gtk_widget_get_realized (src_widget) || !gtk_widget_get_realized (dest_widget))
4857 /* Translate from allocation relative to window relative */
4858 if (gtk_widget_get_has_window (src_widget) && src_priv->parent)
4861 gdk_window_get_position (src_priv->window, &wx, &wy);
4863 src_x -= wx - src_priv->allocation.x;
4864 src_y -= wy - src_priv->allocation.y;
4868 src_x += src_priv->allocation.x;
4869 src_y += src_priv->allocation.y;
4872 /* Translate to the common ancestor */
4873 window = src_priv->window;
4874 while (window != ancestor->priv->window)
4878 gdk_window_coords_to_parent (window, src_x, src_y, &dx, &dy);
4883 window = gdk_window_get_effective_parent (window);
4885 if (!window) /* Handle GtkHandleBox */
4890 window = dest_priv->window;
4891 while (window != ancestor->priv->window)
4893 dest_list = g_list_prepend (dest_list, window);
4895 window = gdk_window_get_effective_parent (window);
4897 if (!window) /* Handle GtkHandleBox */
4899 g_list_free (dest_list);
4908 gdk_window_coords_from_parent (dest_list->data, src_x, src_y, &dx, &dy);
4913 dest_list = g_list_remove (dest_list, dest_list->data);
4916 /* Translate from window relative to allocation relative */
4917 if (gtk_widget_get_has_window (dest_widget) && dest_priv->parent)
4920 gdk_window_get_position (dest_priv->window, &wx, &wy);
4922 src_x += wx - dest_priv->allocation.x;
4923 src_y += wy - dest_priv->allocation.y;
4927 src_x -= dest_priv->allocation.x;
4928 src_y -= dest_priv->allocation.y;
4940 gtk_widget_real_size_allocate (GtkWidget *widget,
4941 GtkAllocation *allocation)
4943 GtkWidgetPrivate *priv = widget->priv;
4945 priv->allocation = *allocation;
4947 if (gtk_widget_get_realized (widget) &&
4948 gtk_widget_get_has_window (widget))
4950 gdk_window_move_resize (priv->window,
4951 allocation->x, allocation->y,
4952 allocation->width, allocation->height);
4957 adjust_for_align(GtkAlign align,
4959 gint *allocated_pos,
4960 gint *allocated_size)
4964 case GTK_ALIGN_FILL:
4965 /* change nothing */
4967 case GTK_ALIGN_START:
4968 /* keep *allocated_pos where it is */
4969 *allocated_size = MIN (*allocated_size, *natural_size);
4972 if (*allocated_size > *natural_size)
4974 *allocated_pos += (*allocated_size - *natural_size);
4975 *allocated_size = *natural_size;
4978 case GTK_ALIGN_CENTER:
4979 if (*allocated_size > *natural_size)
4981 *allocated_pos += (*allocated_size - *natural_size) / 2;
4982 *allocated_size = MIN (*allocated_size, *natural_size);
4989 adjust_for_margin(gint start_margin,
4992 gint *allocated_pos,
4993 gint *allocated_size)
4995 *natural_size -= (start_margin + end_margin);
4996 *allocated_pos += start_margin;
4997 *allocated_size -= (start_margin + end_margin);
5001 gtk_widget_real_adjust_size_allocation (GtkWidget *widget,
5002 GtkOrientation orientation,
5004 gint *allocated_pos,
5005 gint *allocated_size)
5007 const GtkWidgetAuxInfo *aux_info;
5009 aux_info = _gtk_widget_get_aux_info_or_defaults (widget);
5011 if (orientation == GTK_ORIENTATION_HORIZONTAL)
5013 adjust_for_margin (aux_info->margin.left,
5014 aux_info->margin.right,
5015 natural_size, allocated_pos, allocated_size);
5016 adjust_for_align (aux_info->halign,
5017 natural_size, allocated_pos, allocated_size);
5021 adjust_for_margin (aux_info->margin.top,
5022 aux_info->margin.bottom,
5023 natural_size, allocated_pos, allocated_size);
5024 adjust_for_align (aux_info->valign,
5025 natural_size, allocated_pos, allocated_size);
5030 gtk_widget_real_can_activate_accel (GtkWidget *widget,
5033 GtkWidgetPrivate *priv = widget->priv;
5035 /* widgets must be onscreen for accels to take effect */
5036 return gtk_widget_is_sensitive (widget) &&
5037 gtk_widget_is_drawable (widget) &&
5038 gdk_window_is_viewable (priv->window);
5042 * gtk_widget_can_activate_accel:
5043 * @widget: a #GtkWidget
5044 * @signal_id: the ID of a signal installed on @widget
5046 * Determines whether an accelerator that activates the signal
5047 * identified by @signal_id can currently be activated.
5048 * This is done by emitting the #GtkWidget::can-activate-accel
5049 * signal on @widget; if the signal isn't overridden by a
5050 * handler or in a derived widget, then the default check is
5051 * that the widget must be sensitive, and the widget and all
5052 * its ancestors mapped.
5054 * Return value: %TRUE if the accelerator can be activated.
5059 gtk_widget_can_activate_accel (GtkWidget *widget,
5062 gboolean can_activate = FALSE;
5063 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
5064 g_signal_emit (widget, widget_signals[CAN_ACTIVATE_ACCEL], 0, signal_id, &can_activate);
5065 return can_activate;
5074 closure_accel_activate (GClosure *closure,
5075 GValue *return_value,
5076 guint n_param_values,
5077 const GValue *param_values,
5078 gpointer invocation_hint,
5079 gpointer marshal_data)
5081 AccelClosure *aclosure = (AccelClosure*) closure;
5082 gboolean can_activate = gtk_widget_can_activate_accel (closure->data, aclosure->signal_id);
5085 g_signal_emit (closure->data, aclosure->signal_id, 0);
5087 /* whether accelerator was handled */
5088 g_value_set_boolean (return_value, can_activate);
5092 closures_destroy (gpointer data)
5094 GSList *slist, *closures = data;
5096 for (slist = closures; slist; slist = slist->next)
5098 g_closure_invalidate (slist->data);
5099 g_closure_unref (slist->data);
5101 g_slist_free (closures);
5105 widget_new_accel_closure (GtkWidget *widget,
5108 AccelClosure *aclosure;
5109 GClosure *closure = NULL;
5110 GSList *slist, *closures;
5112 closures = g_object_steal_qdata (G_OBJECT (widget), quark_accel_closures);
5113 for (slist = closures; slist; slist = slist->next)
5114 if (!gtk_accel_group_from_accel_closure (slist->data))
5116 /* reuse this closure */
5117 closure = slist->data;
5122 closure = g_closure_new_object (sizeof (AccelClosure), G_OBJECT (widget));
5123 closures = g_slist_prepend (closures, g_closure_ref (closure));
5124 g_closure_sink (closure);
5125 g_closure_set_marshal (closure, closure_accel_activate);
5127 g_object_set_qdata_full (G_OBJECT (widget), quark_accel_closures, closures, closures_destroy);
5129 aclosure = (AccelClosure*) closure;
5130 g_assert (closure->data == widget);
5131 g_assert (closure->marshal == closure_accel_activate);
5132 aclosure->signal_id = signal_id;
5138 * gtk_widget_add_accelerator
5139 * @widget: widget to install an accelerator on
5140 * @accel_signal: widget signal to emit on accelerator activation
5141 * @accel_group: accel group for this widget, added to its toplevel
5142 * @accel_key: GDK keyval of the accelerator
5143 * @accel_mods: modifier key combination of the accelerator
5144 * @accel_flags: flag accelerators, e.g. %GTK_ACCEL_VISIBLE
5146 * Installs an accelerator for this @widget in @accel_group that causes
5147 * @accel_signal to be emitted if the accelerator is activated.
5148 * The @accel_group needs to be added to the widget's toplevel via
5149 * gtk_window_add_accel_group(), and the signal must be of type %G_RUN_ACTION.
5150 * Accelerators added through this function are not user changeable during
5151 * runtime. If you want to support accelerators that can be changed by the
5152 * user, use gtk_accel_map_add_entry() and gtk_widget_set_accel_path() or
5153 * gtk_menu_item_set_accel_path() instead.
5156 gtk_widget_add_accelerator (GtkWidget *widget,
5157 const gchar *accel_signal,
5158 GtkAccelGroup *accel_group,
5160 GdkModifierType accel_mods,
5161 GtkAccelFlags accel_flags)
5166 g_return_if_fail (GTK_IS_WIDGET (widget));
5167 g_return_if_fail (accel_signal != NULL);
5168 g_return_if_fail (GTK_IS_ACCEL_GROUP (accel_group));
5170 g_signal_query (g_signal_lookup (accel_signal, G_OBJECT_TYPE (widget)), &query);
5171 if (!query.signal_id ||
5172 !(query.signal_flags & G_SIGNAL_ACTION) ||
5173 query.return_type != G_TYPE_NONE ||
5176 /* hmm, should be elaborate enough */
5177 g_warning (G_STRLOC ": widget `%s' has no activatable signal \"%s\" without arguments",
5178 G_OBJECT_TYPE_NAME (widget), accel_signal);
5182 closure = widget_new_accel_closure (widget, query.signal_id);
5184 g_object_ref (widget);
5186 /* install the accelerator. since we don't map this onto an accel_path,
5187 * the accelerator will automatically be locked.
5189 gtk_accel_group_connect (accel_group,
5192 accel_flags | GTK_ACCEL_LOCKED,
5195 g_signal_emit (widget, widget_signals[ACCEL_CLOSURES_CHANGED], 0);
5197 g_object_unref (widget);
5201 * gtk_widget_remove_accelerator:
5202 * @widget: widget to install an accelerator on
5203 * @accel_group: accel group for this widget
5204 * @accel_key: GDK keyval of the accelerator
5205 * @accel_mods: modifier key combination of the accelerator
5206 * @returns: whether an accelerator was installed and could be removed
5208 * Removes an accelerator from @widget, previously installed with
5209 * gtk_widget_add_accelerator().
5212 gtk_widget_remove_accelerator (GtkWidget *widget,
5213 GtkAccelGroup *accel_group,
5215 GdkModifierType accel_mods)
5217 GtkAccelGroupEntry *ag_entry;
5218 GList *slist, *clist;
5221 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
5222 g_return_val_if_fail (GTK_IS_ACCEL_GROUP (accel_group), FALSE);
5224 ag_entry = gtk_accel_group_query (accel_group, accel_key, accel_mods, &n);
5225 clist = gtk_widget_list_accel_closures (widget);
5226 for (slist = clist; slist; slist = slist->next)
5230 for (i = 0; i < n; i++)
5231 if (slist->data == (gpointer) ag_entry[i].closure)
5233 gboolean is_removed = gtk_accel_group_disconnect (accel_group, slist->data);
5235 g_signal_emit (widget, widget_signals[ACCEL_CLOSURES_CHANGED], 0);
5237 g_list_free (clist);
5242 g_list_free (clist);
5244 g_warning (G_STRLOC ": no accelerator (%u,%u) installed in accel group (%p) for %s (%p)",
5245 accel_key, accel_mods, accel_group,
5246 G_OBJECT_TYPE_NAME (widget), widget);
5252 * gtk_widget_list_accel_closures:
5253 * @widget: widget to list accelerator closures for
5255 * Lists the closures used by @widget for accelerator group connections
5256 * with gtk_accel_group_connect_by_path() or gtk_accel_group_connect().
5257 * The closures can be used to monitor accelerator changes on @widget,
5258 * by connecting to the @GtkAccelGroup::accel-changed signal of the
5259 * #GtkAccelGroup of a closure which can be found out with
5260 * gtk_accel_group_from_accel_closure().
5262 * Return value: (transfer container) (element-type GClosure):
5263 * a newly allocated #GList of closures
5266 gtk_widget_list_accel_closures (GtkWidget *widget)
5269 GList *clist = NULL;
5271 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
5273 for (slist = g_object_get_qdata (G_OBJECT (widget), quark_accel_closures); slist; slist = slist->next)
5274 if (gtk_accel_group_from_accel_closure (slist->data))
5275 clist = g_list_prepend (clist, slist->data);
5281 GtkAccelGroup *accel_group;
5286 destroy_accel_path (gpointer data)
5288 AccelPath *apath = data;
5290 gtk_accel_group_disconnect (apath->accel_group, apath->closure);
5292 /* closures_destroy takes care of unrefing the closure */
5293 g_object_unref (apath->accel_group);
5295 g_slice_free (AccelPath, apath);
5300 * gtk_widget_set_accel_path:
5301 * @widget: a #GtkWidget
5302 * @accel_path: (allow-none): path used to look up the accelerator
5303 * @accel_group: (allow-none): a #GtkAccelGroup.
5305 * Given an accelerator group, @accel_group, and an accelerator path,
5306 * @accel_path, sets up an accelerator in @accel_group so whenever the
5307 * key binding that is defined for @accel_path is pressed, @widget
5308 * will be activated. This removes any accelerators (for any
5309 * accelerator group) installed by previous calls to
5310 * gtk_widget_set_accel_path(). Associating accelerators with
5311 * paths allows them to be modified by the user and the modifications
5312 * to be saved for future use. (See gtk_accel_map_save().)
5314 * This function is a low level function that would most likely
5315 * be used by a menu creation system like #GtkUIManager. If you
5316 * use #GtkUIManager, setting up accelerator paths will be done
5319 * Even when you you aren't using #GtkUIManager, if you only want to
5320 * set up accelerators on menu items gtk_menu_item_set_accel_path()
5321 * provides a somewhat more convenient interface.
5323 * Note that @accel_path string will be stored in a #GQuark. Therefore, if you
5324 * pass a static string, you can save some memory by interning it first with
5325 * g_intern_static_string().
5328 gtk_widget_set_accel_path (GtkWidget *widget,
5329 const gchar *accel_path,
5330 GtkAccelGroup *accel_group)
5334 g_return_if_fail (GTK_IS_WIDGET (widget));
5335 g_return_if_fail (GTK_WIDGET_GET_CLASS (widget)->activate_signal != 0);
5339 g_return_if_fail (GTK_IS_ACCEL_GROUP (accel_group));
5340 g_return_if_fail (_gtk_accel_path_is_valid (accel_path));
5342 gtk_accel_map_add_entry (accel_path, 0, 0);
5343 apath = g_slice_new (AccelPath);
5344 apath->accel_group = g_object_ref (accel_group);
5345 apath->path_quark = g_quark_from_string (accel_path);
5346 apath->closure = widget_new_accel_closure (widget, GTK_WIDGET_GET_CLASS (widget)->activate_signal);
5351 /* also removes possible old settings */
5352 g_object_set_qdata_full (G_OBJECT (widget), quark_accel_path, apath, destroy_accel_path);
5355 gtk_accel_group_connect_by_path (apath->accel_group, g_quark_to_string (apath->path_quark), apath->closure);
5357 g_signal_emit (widget, widget_signals[ACCEL_CLOSURES_CHANGED], 0);
5361 _gtk_widget_get_accel_path (GtkWidget *widget,
5366 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
5368 apath = g_object_get_qdata (G_OBJECT (widget), quark_accel_path);
5370 *locked = apath ? gtk_accel_group_get_is_locked (apath->accel_group) : TRUE;
5371 return apath ? g_quark_to_string (apath->path_quark) : NULL;
5375 * gtk_widget_mnemonic_activate:
5376 * @widget: a #GtkWidget
5377 * @group_cycling: %TRUE if there are other widgets with the same mnemonic
5379 * Emits the #GtkWidget::mnemonic-activate signal.
5381 * The default handler for this signal activates the @widget if
5382 * @group_cycling is %FALSE, and just grabs the focus if @group_cycling
5385 * Returns: %TRUE if the signal has been handled
5388 gtk_widget_mnemonic_activate (GtkWidget *widget,
5389 gboolean group_cycling)
5393 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
5395 group_cycling = group_cycling != FALSE;
5396 if (!gtk_widget_is_sensitive (widget))
5399 g_signal_emit (widget,
5400 widget_signals[MNEMONIC_ACTIVATE],
5408 gtk_widget_real_mnemonic_activate (GtkWidget *widget,
5409 gboolean group_cycling)
5411 if (!group_cycling && GTK_WIDGET_GET_CLASS (widget)->activate_signal)
5412 gtk_widget_activate (widget);
5413 else if (gtk_widget_get_can_focus (widget))
5414 gtk_widget_grab_focus (widget);
5417 g_warning ("widget `%s' isn't suitable for mnemonic activation",
5418 G_OBJECT_TYPE_NAME (widget));
5419 gtk_widget_error_bell (widget);
5424 static const cairo_user_data_key_t event_key;
5427 _gtk_cairo_get_event (cairo_t *cr)
5429 g_return_val_if_fail (cr != NULL, NULL);
5431 return cairo_get_user_data (cr, &event_key);
5435 gtk_cairo_set_event (cairo_t *cr,
5436 GdkEventExpose *event)
5438 cairo_set_user_data (cr, &event_key, event, NULL);
5442 * gtk_cairo_should_draw_window:
5443 * @cr: a cairo context
5444 * @window: the window to check
5446 * This function is supposed to be called in GtkWidget::draw
5447 * implementations for widgets that support multiple windows.
5448 * @cr must be untransformed from invoking of the draw function.
5449 * This function will return %TRUE if the contents of the given
5450 * @window are supposed to be drawn and %FALSE otherwise. Note
5451 * that when the drawing was not initiated by the windowing
5452 * system this function will return %TRUE for all windows, so
5453 * you need to draw the bottommost window first. Also, do not
5454 * use "else if" statements to check which window should be drawn.
5456 * Returns: %TRUE if @window should be drawn
5459 gtk_cairo_should_draw_window (cairo_t *cr,
5462 GdkEventExpose *event;
5464 g_return_val_if_fail (cr != NULL, FALSE);
5465 g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
5467 event = _gtk_cairo_get_event (cr);
5469 return event == NULL ||
5470 event->window == window;
5473 /* code shared by gtk_container_propagate_draw() and
5477 _gtk_widget_draw_internal (GtkWidget *widget,
5479 gboolean clip_to_size)
5481 if (!gtk_widget_is_drawable (widget))
5486 cairo_rectangle (cr,
5488 widget->priv->allocation.width,
5489 widget->priv->allocation.height);
5493 if (gdk_cairo_get_clip_rectangle (cr, NULL))
5497 g_signal_emit (widget, widget_signals[DRAW],
5505 * @widget: the widget to draw. It must be drawable (see
5506 * gtk_widget_is_drawable()) and a size must have been allocated.
5507 * @cr: a cairo context to draw to
5509 * Draws @widget to @cr. The top left corner of the widget will be
5510 * drawn to the currently set origin point of @cr.
5512 * You should pass a cairo context as @cr argument that is in an
5513 * original state. Otherwise the resulting drawing is undefined. For
5514 * example changing the operator using cairo_set_operator() or the
5515 * line width using cairo_set_line_width() might have unwanted side
5517 * You may however change the context's transform matrix - like with
5518 * cairo_scale(), cairo_translate() or cairo_set_matrix() and clip
5519 * region with cairo_clip() prior to calling this function. Also, it
5520 * is fine to modify the context with cairo_save() and
5521 * cairo_push_group() prior to calling this function.
5523 * <note><para>Special purpose widgets may contain special code for
5524 * rendering to the screen and might appear differently on screen
5525 * and when rendered using gtk_widget_draw().</para></note>
5528 gtk_widget_draw (GtkWidget *widget,
5531 GdkEventExpose *tmp_event;
5533 g_return_if_fail (GTK_IS_WIDGET (widget));
5534 g_return_if_fail (!widget->priv->alloc_needed);
5535 g_return_if_fail (cr != NULL);
5538 /* We have to reset the event here so that draw functions can call
5539 * gtk_widget_draw() on random other widgets and get the desired
5540 * effect: Drawing all contents, not just the current window.
5542 tmp_event = _gtk_cairo_get_event (cr);
5543 gtk_cairo_set_event (cr, NULL);
5545 _gtk_widget_draw_internal (widget, cr, TRUE);
5547 gtk_cairo_set_event (cr, tmp_event);
5552 gtk_widget_real_key_press_event (GtkWidget *widget,
5555 return gtk_bindings_activate_event (G_OBJECT (widget), event);
5559 gtk_widget_real_key_release_event (GtkWidget *widget,
5562 return gtk_bindings_activate_event (G_OBJECT (widget), event);
5566 gtk_widget_real_focus_in_event (GtkWidget *widget,
5567 GdkEventFocus *event)
5569 gtk_widget_queue_shallow_draw (widget);
5575 gtk_widget_real_focus_out_event (GtkWidget *widget,
5576 GdkEventFocus *event)
5578 gtk_widget_queue_shallow_draw (widget);
5583 #define WIDGET_REALIZED_FOR_EVENT(widget, event) \
5584 (event->type == GDK_FOCUS_CHANGE || gtk_widget_get_realized(widget))
5588 * @widget: a #GtkWidget
5589 * @event: a #GdkEvent
5591 * Rarely-used function. This function is used to emit
5592 * the event signals on a widget (those signals should never
5593 * be emitted without using this function to do so).
5594 * If you want to synthesize an event though, don't use this function;
5595 * instead, use gtk_main_do_event() so the event will behave as if
5596 * it were in the event queue. Don't synthesize expose events; instead,
5597 * use gdk_window_invalidate_rect() to invalidate a region of the
5600 * Return value: return from the event signal emission (%TRUE if
5601 * the event was handled)
5604 gtk_widget_event (GtkWidget *widget,
5607 g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
5608 g_return_val_if_fail (WIDGET_REALIZED_FOR_EVENT (widget, event), TRUE);
5610 if (event->type == GDK_EXPOSE)
5612 g_warning ("Events of type GDK_EXPOSE cannot be synthesized. To get "
5613 "the same effect, call gdk_window_invalidate_rect/region(), "
5614 "followed by gdk_window_process_updates().");
5618 return gtk_widget_event_internal (widget, event);
5621 /* Returns TRUE if a translation should be done */
5623 gtk_widget_get_translation_to_window (GtkWidget *widget,
5628 GdkWindow *w, *widget_window;
5630 if (!gtk_widget_get_has_window (widget))
5632 *x = -widget->priv->allocation.x;
5633 *y = -widget->priv->allocation.y;
5641 widget_window = gtk_widget_get_window (widget);
5643 for (w = window; w && w != widget_window; w = gdk_window_get_parent (w))
5646 gdk_window_get_position (w, &wx, &wy);
5663 * gtk_cairo_transform_to_window:
5664 * @cr: the cairo context to transform
5665 * @widget: the widget the context is currently centered for
5666 * @window: the window to transform the context to
5668 * Transforms the given cairo context @cr that from @widget-relative
5669 * coordinates to @window-relative coordinates.
5670 * If the @widget's window is not an ancestor of @window, no
5671 * modification will be applied.
5673 * This is the inverse to the transformation GTK applies when
5674 * preparing an expose event to be emitted with the GtkWidget::draw
5675 * signal. It is intended to help porting multiwindow widgets from
5676 * GTK 2 to the rendering architecture of GTK 3.
5679 gtk_cairo_transform_to_window (cairo_t *cr,
5685 g_return_if_fail (cr != NULL);
5686 g_return_if_fail (GTK_IS_WIDGET (widget));
5687 g_return_if_fail (GDK_IS_WINDOW (window));
5689 if (gtk_widget_get_translation_to_window (widget, window, &x, &y))
5690 cairo_translate (cr, x, y);
5694 * gtk_widget_send_expose:
5695 * @widget: a #GtkWidget
5696 * @event: a expose #GdkEvent
5698 * Very rarely-used function. This function is used to emit
5699 * an expose event on a widget. This function is not normally used
5700 * directly. The only time it is used is when propagating an expose
5701 * event to a child %NO_WINDOW widget, and that is normally done
5702 * using gtk_container_propagate_draw().
5704 * If you want to force an area of a window to be redrawn,
5705 * use gdk_window_invalidate_rect() or gdk_window_invalidate_region().
5706 * To cause the redraw to be done immediately, follow that call
5707 * with a call to gdk_window_process_updates().
5709 * Return value: return from the event signal emission (%TRUE if
5710 * the event was handled)
5713 gtk_widget_send_expose (GtkWidget *widget,
5716 gboolean result = FALSE;
5721 g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
5722 g_return_val_if_fail (gtk_widget_get_realized (widget), TRUE);
5723 g_return_val_if_fail (event != NULL, TRUE);
5724 g_return_val_if_fail (event->type == GDK_EXPOSE, TRUE);
5726 cr = gdk_cairo_create (event->expose.window);
5727 gtk_cairo_set_event (cr, &event->expose);
5729 gdk_cairo_region (cr, event->expose.region);
5732 do_clip = gtk_widget_get_translation_to_window (widget,
5733 event->expose.window,
5735 cairo_translate (cr, -x, -y);
5737 _gtk_widget_draw_internal (widget, cr, do_clip);
5739 /* unset here, so if someone keeps a reference to cr we
5740 * don't leak the window. */
5741 gtk_cairo_set_event (cr, NULL);
5748 event_window_is_still_viewable (GdkEvent *event)
5750 /* Check that we think the event's window is viewable before
5751 * delivering the event, to prevent suprises. We do this here
5752 * at the last moment, since the event may have been queued
5753 * up behind other events, held over a recursive main loop, etc.
5755 switch (event->type)
5758 case GDK_MOTION_NOTIFY:
5759 case GDK_BUTTON_PRESS:
5760 case GDK_2BUTTON_PRESS:
5761 case GDK_3BUTTON_PRESS:
5763 case GDK_ENTER_NOTIFY:
5764 case GDK_PROXIMITY_IN:
5766 return event->any.window && gdk_window_is_viewable (event->any.window);
5769 /* The following events are the second half of paired events;
5770 * we always deliver them to deal with widgets that clean up
5771 * on the second half.
5773 case GDK_BUTTON_RELEASE:
5774 case GDK_KEY_RELEASE:
5775 case GDK_LEAVE_NOTIFY:
5776 case GDK_PROXIMITY_OUT:
5780 /* Remaining events would make sense on an not-viewable window,
5781 * or don't have an associated window.
5788 gtk_widget_event_internal (GtkWidget *widget,
5791 gboolean return_val = FALSE;
5793 /* We check only once for is-still-visible; if someone
5794 * hides the window in on of the signals on the widget,
5795 * they are responsible for returning TRUE to terminate
5798 if (!event_window_is_still_viewable (event))
5801 g_object_ref (widget);
5803 g_signal_emit (widget, widget_signals[EVENT], 0, event, &return_val);
5804 return_val |= !WIDGET_REALIZED_FOR_EVENT (widget, event);
5809 switch (event->type)
5814 case GDK_BUTTON_PRESS:
5815 case GDK_2BUTTON_PRESS:
5816 case GDK_3BUTTON_PRESS:
5817 signal_num = BUTTON_PRESS_EVENT;
5820 signal_num = SCROLL_EVENT;
5822 case GDK_BUTTON_RELEASE:
5823 signal_num = BUTTON_RELEASE_EVENT;
5825 case GDK_MOTION_NOTIFY:
5826 signal_num = MOTION_NOTIFY_EVENT;
5829 signal_num = DELETE_EVENT;
5832 signal_num = DESTROY_EVENT;
5833 _gtk_tooltip_hide (widget);
5836 signal_num = KEY_PRESS_EVENT;
5838 case GDK_KEY_RELEASE:
5839 signal_num = KEY_RELEASE_EVENT;
5841 case GDK_ENTER_NOTIFY:
5842 signal_num = ENTER_NOTIFY_EVENT;
5844 case GDK_LEAVE_NOTIFY:
5845 signal_num = LEAVE_NOTIFY_EVENT;
5847 case GDK_FOCUS_CHANGE:
5848 signal_num = event->focus_change.in ? FOCUS_IN_EVENT : FOCUS_OUT_EVENT;
5849 if (event->focus_change.in)
5850 _gtk_tooltip_focus_in (widget);
5852 _gtk_tooltip_focus_out (widget);
5855 signal_num = CONFIGURE_EVENT;
5858 signal_num = MAP_EVENT;
5861 signal_num = UNMAP_EVENT;
5863 case GDK_WINDOW_STATE:
5864 signal_num = WINDOW_STATE_EVENT;
5866 case GDK_PROPERTY_NOTIFY:
5867 signal_num = PROPERTY_NOTIFY_EVENT;
5869 case GDK_SELECTION_CLEAR:
5870 signal_num = SELECTION_CLEAR_EVENT;
5872 case GDK_SELECTION_REQUEST:
5873 signal_num = SELECTION_REQUEST_EVENT;
5875 case GDK_SELECTION_NOTIFY:
5876 signal_num = SELECTION_NOTIFY_EVENT;
5878 case GDK_PROXIMITY_IN:
5879 signal_num = PROXIMITY_IN_EVENT;
5881 case GDK_PROXIMITY_OUT:
5882 signal_num = PROXIMITY_OUT_EVENT;
5885 signal_num = NO_EXPOSE_EVENT;
5887 case GDK_CLIENT_EVENT:
5888 signal_num = CLIENT_EVENT;
5891 signal_num = EXPOSE_EVENT;
5893 case GDK_VISIBILITY_NOTIFY:
5894 signal_num = VISIBILITY_NOTIFY_EVENT;
5896 case GDK_GRAB_BROKEN:
5897 signal_num = GRAB_BROKEN_EVENT;
5900 signal_num = DAMAGE_EVENT;
5903 g_warning ("gtk_widget_event(): unhandled event type: %d", event->type);
5907 if (signal_num != -1)
5908 g_signal_emit (widget, widget_signals[signal_num], 0, event, &return_val);
5910 if (WIDGET_REALIZED_FOR_EVENT (widget, event))
5911 g_signal_emit (widget, widget_signals[EVENT_AFTER], 0, event);
5915 g_object_unref (widget);
5921 * gtk_widget_activate:
5922 * @widget: a #GtkWidget that's activatable
5924 * For widgets that can be "activated" (buttons, menu items, etc.)
5925 * this function activates them. Activation is what happens when you
5926 * press Enter on a widget during key navigation. If @widget isn't
5927 * activatable, the function returns %FALSE.
5929 * Return value: %TRUE if the widget was activatable
5932 gtk_widget_activate (GtkWidget *widget)
5934 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
5936 if (WIDGET_CLASS (widget)->activate_signal)
5938 /* FIXME: we should eventually check the signals signature here */
5939 g_signal_emit (widget, WIDGET_CLASS (widget)->activate_signal, 0);
5948 gtk_widget_reparent_subwindows (GtkWidget *widget,
5949 GdkWindow *new_window)
5951 GtkWidgetPrivate *priv = widget->priv;
5953 if (!gtk_widget_get_has_window (widget))
5955 GList *children = gdk_window_get_children (priv->window);
5958 for (tmp_list = children; tmp_list; tmp_list = tmp_list->next)
5960 GdkWindow *window = tmp_list->data;
5963 gdk_window_get_user_data (window, &child);
5964 while (child && child != widget)
5965 child = ((GtkWidget*) child)->priv->parent;
5968 gdk_window_reparent (window, new_window, 0, 0);
5971 g_list_free (children);
5976 GList *tmp_list, *children;
5978 parent = gdk_window_get_parent (priv->window);
5981 gdk_window_reparent (priv->window, new_window, 0, 0);
5984 children = gdk_window_get_children (parent);
5986 for (tmp_list = children; tmp_list; tmp_list = tmp_list->next)
5988 GdkWindow *window = tmp_list->data;
5991 gdk_window_get_user_data (window, &child);
5993 if (child == widget)
5994 gdk_window_reparent (window, new_window, 0, 0);
5997 g_list_free (children);
6003 gtk_widget_reparent_fixup_child (GtkWidget *widget,
6004 gpointer client_data)
6006 GtkWidgetPrivate *priv = widget->priv;
6008 g_assert (client_data != NULL);
6010 if (!gtk_widget_get_has_window (widget))
6013 g_object_unref (priv->window);
6014 priv->window = (GdkWindow*) client_data;
6016 g_object_ref (priv->window);
6018 if (GTK_IS_CONTAINER (widget))
6019 gtk_container_forall (GTK_CONTAINER (widget),
6020 gtk_widget_reparent_fixup_child,
6026 * gtk_widget_reparent:
6027 * @widget: a #GtkWidget
6028 * @new_parent: a #GtkContainer to move the widget into
6030 * Moves a widget from one #GtkContainer to another, handling reference
6031 * count issues to avoid destroying the widget.
6034 gtk_widget_reparent (GtkWidget *widget,
6035 GtkWidget *new_parent)
6037 GtkWidgetPrivate *priv;
6039 g_return_if_fail (GTK_IS_WIDGET (widget));
6040 g_return_if_fail (GTK_IS_CONTAINER (new_parent));
6041 priv = widget->priv;
6042 g_return_if_fail (priv->parent != NULL);
6044 if (priv->parent != new_parent)
6046 /* First try to see if we can get away without unrealizing
6047 * the widget as we reparent it. if so we set a flag so
6048 * that gtk_widget_unparent doesn't unrealize widget
6050 if (gtk_widget_get_realized (widget) && gtk_widget_get_realized (new_parent))
6051 priv->in_reparent = TRUE;
6053 g_object_ref (widget);
6054 gtk_container_remove (GTK_CONTAINER (priv->parent), widget);
6055 gtk_container_add (GTK_CONTAINER (new_parent), widget);
6056 g_object_unref (widget);
6058 if (priv->in_reparent)
6060 priv->in_reparent = FALSE;
6062 gtk_widget_reparent_subwindows (widget, gtk_widget_get_parent_window (widget));
6063 gtk_widget_reparent_fixup_child (widget,
6064 gtk_widget_get_parent_window (widget));
6067 g_object_notify (G_OBJECT (widget), "parent");
6072 * gtk_widget_intersect:
6073 * @widget: a #GtkWidget
6074 * @area: a rectangle
6075 * @intersection: rectangle to store intersection of @widget and @area
6077 * Computes the intersection of a @widget's area and @area, storing
6078 * the intersection in @intersection, and returns %TRUE if there was
6079 * an intersection. @intersection may be %NULL if you're only
6080 * interested in whether there was an intersection.
6082 * Return value: %TRUE if there was an intersection
6085 gtk_widget_intersect (GtkWidget *widget,
6086 const GdkRectangle *area,
6087 GdkRectangle *intersection)
6089 GtkWidgetPrivate *priv;
6094 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6095 g_return_val_if_fail (area != NULL, FALSE);
6097 priv = widget->priv;
6100 dest = intersection;
6104 return_val = gdk_rectangle_intersect (&priv->allocation, area, dest);
6106 if (return_val && intersection && gtk_widget_get_has_window (widget))
6108 intersection->x -= priv->allocation.x;
6109 intersection->y -= priv->allocation.y;
6116 * gtk_widget_region_intersect:
6117 * @widget: a #GtkWidget
6118 * @region: a #cairo_region_t, in the same coordinate system as
6119 * @widget->allocation. That is, relative to @widget->window
6120 * for %NO_WINDOW widgets; relative to the parent window
6121 * of @widget->window for widgets with their own window.
6122 * @returns: A newly allocated region holding the intersection of @widget
6123 * and @region. The coordinates of the return value are
6124 * relative to @widget->window for %NO_WINDOW widgets, and
6125 * relative to the parent window of @widget->window for
6126 * widgets with their own window.
6128 * Computes the intersection of a @widget's area and @region, returning
6129 * the intersection. The result may be empty, use cairo_region_is_empty() to
6133 gtk_widget_region_intersect (GtkWidget *widget,
6134 const cairo_region_t *region)
6137 cairo_region_t *dest;
6139 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
6140 g_return_val_if_fail (region != NULL, NULL);
6142 gtk_widget_get_allocation (widget, &rect);
6144 dest = cairo_region_create_rectangle (&rect);
6146 cairo_region_intersect (dest, region);
6152 * _gtk_widget_grab_notify:
6153 * @widget: a #GtkWidget
6154 * @was_grabbed: whether a grab is now in effect
6156 * Emits the #GtkWidget::grab-notify signal on @widget.
6161 _gtk_widget_grab_notify (GtkWidget *widget,
6162 gboolean was_grabbed)
6164 g_signal_emit (widget, widget_signals[GRAB_NOTIFY], 0, was_grabbed);
6168 * gtk_widget_grab_focus:
6169 * @widget: a #GtkWidget
6171 * Causes @widget to have the keyboard focus for the #GtkWindow it's
6172 * inside. @widget must be a focusable widget, such as a #GtkEntry;
6173 * something like #GtkFrame won't work.
6175 * More precisely, it must have the %GTK_CAN_FOCUS flag set. Use
6176 * gtk_widget_set_can_focus() to modify that flag.
6178 * The widget also needs to be realized and mapped. This is indicated by the
6179 * related signals. Grabbing the focus immediately after creating the widget
6180 * will likely fail and cause critical warnings.
6183 gtk_widget_grab_focus (GtkWidget *widget)
6185 g_return_if_fail (GTK_IS_WIDGET (widget));
6187 if (!gtk_widget_is_sensitive (widget))
6190 g_object_ref (widget);
6191 g_signal_emit (widget, widget_signals[GRAB_FOCUS], 0);
6192 g_object_notify (G_OBJECT (widget), "has-focus");
6193 g_object_unref (widget);
6197 reset_focus_recurse (GtkWidget *widget,
6200 if (GTK_IS_CONTAINER (widget))
6202 GtkContainer *container;
6204 container = GTK_CONTAINER (widget);
6205 gtk_container_set_focus_child (container, NULL);
6207 gtk_container_foreach (container,
6208 reset_focus_recurse,
6214 gtk_widget_real_grab_focus (GtkWidget *focus_widget)
6216 if (gtk_widget_get_can_focus (focus_widget))
6218 GtkWidget *toplevel;
6221 /* clear the current focus setting, break if the current widget
6222 * is the focus widget's parent, since containers above that will
6223 * be set by the next loop.
6225 toplevel = gtk_widget_get_toplevel (focus_widget);
6226 if (gtk_widget_is_toplevel (toplevel) && GTK_IS_WINDOW (toplevel))
6228 widget = gtk_window_get_focus (GTK_WINDOW (toplevel));
6230 if (widget == focus_widget)
6232 /* We call _gtk_window_internal_set_focus() here so that the
6233 * toplevel window can request the focus if necessary.
6234 * This is needed when the toplevel is a GtkPlug
6236 if (!gtk_widget_has_focus (widget))
6237 _gtk_window_internal_set_focus (GTK_WINDOW (toplevel), focus_widget);
6244 while (widget->priv->parent && widget->priv->parent != focus_widget->priv->parent)
6246 widget = widget->priv->parent;
6247 gtk_container_set_focus_child (GTK_CONTAINER (widget), NULL);
6251 else if (toplevel != focus_widget)
6253 /* gtk_widget_grab_focus() operates on a tree without window...
6254 * actually, this is very questionable behaviour.
6257 gtk_container_foreach (GTK_CONTAINER (toplevel),
6258 reset_focus_recurse,
6262 /* now propagate the new focus up the widget tree and finally
6263 * set it on the window
6265 widget = focus_widget;
6266 while (widget->priv->parent)
6268 gtk_container_set_focus_child (GTK_CONTAINER (widget->priv->parent), widget);
6269 widget = widget->priv->parent;
6271 if (GTK_IS_WINDOW (widget))
6272 _gtk_window_internal_set_focus (GTK_WINDOW (widget), focus_widget);
6277 gtk_widget_real_query_tooltip (GtkWidget *widget,
6280 gboolean keyboard_tip,
6281 GtkTooltip *tooltip)
6283 gchar *tooltip_markup;
6284 gboolean has_tooltip;
6286 tooltip_markup = g_object_get_qdata (G_OBJECT (widget), quark_tooltip_markup);
6287 has_tooltip = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (widget), quark_has_tooltip));
6289 if (has_tooltip && tooltip_markup)
6291 gtk_tooltip_set_markup (tooltip, tooltip_markup);
6299 gtk_widget_real_show_help (GtkWidget *widget,
6300 GtkWidgetHelpType help_type)
6302 if (help_type == GTK_WIDGET_HELP_TOOLTIP)
6304 _gtk_tooltip_toggle_keyboard_mode (widget);
6313 gtk_widget_real_focus (GtkWidget *widget,
6314 GtkDirectionType direction)
6316 if (!gtk_widget_get_can_focus (widget))
6319 if (!gtk_widget_is_focus (widget))
6321 gtk_widget_grab_focus (widget);
6329 gtk_widget_real_move_focus (GtkWidget *widget,
6330 GtkDirectionType direction)
6332 GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
6334 if (widget != toplevel && GTK_IS_WINDOW (toplevel))
6336 g_signal_emit (toplevel, widget_signals[MOVE_FOCUS], 0,
6342 gtk_widget_real_keynav_failed (GtkWidget *widget,
6343 GtkDirectionType direction)
6345 gboolean cursor_only;
6349 case GTK_DIR_TAB_FORWARD:
6350 case GTK_DIR_TAB_BACKWARD:
6357 g_object_get (gtk_widget_get_settings (widget),
6358 "gtk-keynav-cursor-only", &cursor_only,
6365 gtk_widget_error_bell (widget);
6371 * gtk_widget_set_can_focus:
6372 * @widget: a #GtkWidget
6373 * @can_focus: whether or not @widget can own the input focus.
6375 * Specifies whether @widget can own the input focus. See
6376 * gtk_widget_grab_focus() for actually setting the input focus on a
6382 gtk_widget_set_can_focus (GtkWidget *widget,
6385 g_return_if_fail (GTK_IS_WIDGET (widget));
6387 if (widget->priv->can_focus != can_focus)
6389 widget->priv->can_focus = can_focus;
6391 gtk_widget_queue_resize (widget);
6392 g_object_notify (G_OBJECT (widget), "can-focus");
6397 * gtk_widget_get_can_focus:
6398 * @widget: a #GtkWidget
6400 * Determines whether @widget can own the input focus. See
6401 * gtk_widget_set_can_focus().
6403 * Return value: %TRUE if @widget can own the input focus, %FALSE otherwise
6408 gtk_widget_get_can_focus (GtkWidget *widget)
6410 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6412 return widget->priv->can_focus;
6416 * gtk_widget_has_focus:
6417 * @widget: a #GtkWidget
6419 * Determines if the widget has the global input focus. See
6420 * gtk_widget_is_focus() for the difference between having the global
6421 * input focus, and only having the focus within a toplevel.
6423 * Return value: %TRUE if the widget has the global input focus.
6428 gtk_widget_has_focus (GtkWidget *widget)
6430 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6432 return widget->priv->has_focus;
6436 * gtk_widget_is_focus:
6437 * @widget: a #GtkWidget
6439 * Determines if the widget is the focus widget within its
6440 * toplevel. (This does not mean that the %HAS_FOCUS flag is
6441 * necessarily set; %HAS_FOCUS will only be set if the
6442 * toplevel widget additionally has the global input focus.)
6444 * Return value: %TRUE if the widget is the focus widget.
6447 gtk_widget_is_focus (GtkWidget *widget)
6449 GtkWidget *toplevel;
6451 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6453 toplevel = gtk_widget_get_toplevel (widget);
6455 if (GTK_IS_WINDOW (toplevel))
6456 return widget == gtk_window_get_focus (GTK_WINDOW (toplevel));
6462 * gtk_widget_set_can_default:
6463 * @widget: a #GtkWidget
6464 * @can_default: whether or not @widget can be a default widget.
6466 * Specifies whether @widget can be a default widget. See
6467 * gtk_widget_grab_default() for details about the meaning of
6473 gtk_widget_set_can_default (GtkWidget *widget,
6474 gboolean can_default)
6476 g_return_if_fail (GTK_IS_WIDGET (widget));
6478 if (widget->priv->can_default != can_default)
6480 widget->priv->can_default = can_default;
6482 gtk_widget_queue_resize (widget);
6483 g_object_notify (G_OBJECT (widget), "can-default");
6488 * gtk_widget_get_can_default:
6489 * @widget: a #GtkWidget
6491 * Determines whether @widget can be a default widget. See
6492 * gtk_widget_set_can_default().
6494 * Return value: %TRUE if @widget can be a default widget, %FALSE otherwise
6499 gtk_widget_get_can_default (GtkWidget *widget)
6501 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6503 return widget->priv->can_default;
6507 * gtk_widget_has_default:
6508 * @widget: a #GtkWidget
6510 * Determines whether @widget is the current default widget within its
6511 * toplevel. See gtk_widget_set_can_default().
6513 * Return value: %TRUE if @widget is the current default widget within
6514 * its toplevel, %FALSE otherwise
6519 gtk_widget_has_default (GtkWidget *widget)
6521 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6523 return widget->priv->has_default;
6527 _gtk_widget_set_has_default (GtkWidget *widget,
6528 gboolean has_default)
6530 widget->priv->has_default = has_default;
6534 * gtk_widget_grab_default:
6535 * @widget: a #GtkWidget
6537 * Causes @widget to become the default widget. @widget must have the
6538 * %GTK_CAN_DEFAULT flag set; typically you have to set this flag
6539 * yourself by calling <literal>gtk_widget_set_can_default (@widget,
6540 * %TRUE)</literal>. The default widget is activated when
6541 * the user presses Enter in a window. Default widgets must be
6542 * activatable, that is, gtk_widget_activate() should affect them. Note
6543 * that #GtkEntry widgets require the "activates-default" property
6544 * set to %TRUE before they activate the default widget when Enter
6545 * is pressed and the #GtkEntry is focused.
6548 gtk_widget_grab_default (GtkWidget *widget)
6552 g_return_if_fail (GTK_IS_WIDGET (widget));
6553 g_return_if_fail (gtk_widget_get_can_default (widget));
6555 window = gtk_widget_get_toplevel (widget);
6557 if (window && gtk_widget_is_toplevel (window))
6558 gtk_window_set_default (GTK_WINDOW (window), widget);
6560 g_warning (G_STRLOC ": widget not within a GtkWindow");
6564 * gtk_widget_set_receives_default:
6565 * @widget: a #GtkWidget
6566 * @receives_default: whether or not @widget can be a default widget.
6568 * Specifies whether @widget will be treated as the default widget
6569 * within its toplevel when it has the focus, even if another widget
6572 * See gtk_widget_grab_default() for details about the meaning of
6578 gtk_widget_set_receives_default (GtkWidget *widget,
6579 gboolean receives_default)
6581 g_return_if_fail (GTK_IS_WIDGET (widget));
6583 if (widget->priv->receives_default != receives_default)
6585 widget->priv->receives_default = receives_default;
6587 g_object_notify (G_OBJECT (widget), "receives-default");
6592 * gtk_widget_get_receives_default:
6593 * @widget: a #GtkWidget
6595 * Determines whether @widget is alyways treated as default widget
6596 * withing its toplevel when it has the focus, even if another widget
6599 * See gtk_widget_set_receives_default().
6601 * Return value: %TRUE if @widget acts as default widget when focussed,
6607 gtk_widget_get_receives_default (GtkWidget *widget)
6609 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6611 return widget->priv->receives_default;
6615 * gtk_widget_has_grab:
6616 * @widget: a #GtkWidget
6618 * Determines whether the widget is currently grabbing events, so it
6619 * is the only widget receiving input events (keyboard and mouse).
6621 * See also gtk_grab_add().
6623 * Return value: %TRUE if the widget is in the grab_widgets stack
6628 gtk_widget_has_grab (GtkWidget *widget)
6630 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6632 return widget->priv->has_grab;
6636 _gtk_widget_set_has_grab (GtkWidget *widget,
6639 widget->priv->has_grab = has_grab;
6643 * gtk_widget_device_is_shadowed:
6644 * @widget: a #GtkWidget
6645 * @device: a #GdkDevice
6647 * Returns %TRUE if @device has been shadowed by a GTK+
6648 * device grab on another widget, so it would stop sending
6649 * events to @widget. This may be used in the
6650 * #GtkWidget::grab-notify signal to check for specific
6651 * devices. See gtk_device_grab_add().
6653 * Returns: %TRUE if there is an ongoing grab on @device
6654 * by another #GtkWidget than @widget.
6659 gtk_widget_device_is_shadowed (GtkWidget *widget,
6662 GtkWindowGroup *group;
6663 GtkWidget *grab_widget, *toplevel;
6665 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6666 g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
6668 if (!gtk_widget_get_realized (widget))
6671 toplevel = gtk_widget_get_toplevel (widget);
6673 if (GTK_IS_WINDOW (toplevel))
6674 group = gtk_window_get_group (GTK_WINDOW (toplevel));
6676 group = gtk_window_get_group (NULL);
6678 grab_widget = gtk_window_group_get_current_device_grab (group, device);
6680 /* Widget not inside the hierarchy of grab_widget */
6682 widget != grab_widget &&
6683 !gtk_widget_is_ancestor (widget, grab_widget))
6686 grab_widget = gtk_window_group_get_current_grab (group);
6687 if (grab_widget && widget != grab_widget &&
6688 !gtk_widget_is_ancestor (widget, grab_widget))
6695 * gtk_widget_set_name:
6696 * @widget: a #GtkWidget
6697 * @name: name for the widget
6699 * Widgets can be named, which allows you to refer to them from a
6700 * gtkrc file. You can apply a style to widgets with a particular name
6701 * in the gtkrc file. See the documentation for gtkrc files (on the
6702 * same page as the docs for #GtkRcStyle).
6704 * Note that widget names are separated by periods in paths (see
6705 * gtk_widget_path()), so names with embedded periods may cause confusion.
6708 gtk_widget_set_name (GtkWidget *widget,
6711 GtkWidgetPrivate *priv;
6714 g_return_if_fail (GTK_IS_WIDGET (widget));
6716 priv = widget->priv;
6718 new_name = g_strdup (name);
6719 g_free (priv->name);
6720 priv->name = new_name;
6723 gtk_widget_reset_rc_style (widget);
6725 g_object_notify (G_OBJECT (widget), "name");
6729 * gtk_widget_get_name:
6730 * @widget: a #GtkWidget
6732 * Retrieves the name of a widget. See gtk_widget_set_name() for the
6733 * significance of widget names.
6735 * Return value: name of the widget. This string is owned by GTK+ and
6736 * should not be modified or freed
6738 G_CONST_RETURN gchar*
6739 gtk_widget_get_name (GtkWidget *widget)
6741 GtkWidgetPrivate *priv;
6743 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
6745 priv = widget->priv;
6749 return G_OBJECT_TYPE_NAME (widget);
6753 * gtk_widget_set_state:
6754 * @widget: a #GtkWidget
6755 * @state: new state for @widget
6757 * This function is for use in widget implementations. Sets the state
6758 * of a widget (insensitive, prelighted, etc.) Usually you should set
6759 * the state using wrapper functions such as gtk_widget_set_sensitive().
6762 gtk_widget_set_state (GtkWidget *widget,
6765 GtkWidgetPrivate *priv;
6767 g_return_if_fail (GTK_IS_WIDGET (widget));
6769 priv = widget->priv;
6771 if (state == gtk_widget_get_state (widget))
6774 if (state == GTK_STATE_INSENSITIVE)
6775 gtk_widget_set_sensitive (widget, FALSE);
6781 data.state_restoration = FALSE;
6782 data.use_forall = FALSE;
6784 data.parent_sensitive = (gtk_widget_is_sensitive (priv->parent) != FALSE);
6786 data.parent_sensitive = TRUE;
6788 gtk_widget_propagate_state (widget, &data);
6790 if (gtk_widget_is_drawable (widget))
6791 gtk_widget_queue_draw (widget);
6796 * gtk_widget_get_state:
6797 * @widget: a #GtkWidget
6799 * Returns the widget's state. See gtk_widget_set_state().
6801 * Returns: the state of @widget.
6806 gtk_widget_get_state (GtkWidget *widget)
6808 g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_STATE_NORMAL);
6810 return widget->priv->state;
6814 * gtk_widget_set_visible:
6815 * @widget: a #GtkWidget
6816 * @visible: whether the widget should be shown or not
6818 * Sets the visibility state of @widget. Note that setting this to
6819 * %TRUE doesn't mean the widget is actually viewable, see
6820 * gtk_widget_get_visible().
6822 * This function simply calls gtk_widget_show() or gtk_widget_hide()
6823 * but is nicer to use when the visibility of the widget depends on
6829 gtk_widget_set_visible (GtkWidget *widget,
6832 g_return_if_fail (GTK_IS_WIDGET (widget));
6834 if (visible != gtk_widget_get_visible (widget))
6837 gtk_widget_show (widget);
6839 gtk_widget_hide (widget);
6844 _gtk_widget_set_visible_flag (GtkWidget *widget,
6847 widget->priv->visible = visible;
6851 * gtk_widget_get_visible:
6852 * @widget: a #GtkWidget
6854 * Determines whether the widget is visible. Note that this doesn't
6855 * take into account whether the widget's parent is also visible
6856 * or the widget is obscured in any way.
6858 * See gtk_widget_set_visible().
6860 * Return value: %TRUE if the widget is visible
6865 gtk_widget_get_visible (GtkWidget *widget)
6867 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6869 return widget->priv->visible;
6873 * gtk_widget_set_has_window:
6874 * @widget: a #GtkWidget
6875 * @has_window: whether or not @widget has a window.
6877 * Specifies whether @widget has a #GdkWindow of its own. Note that
6878 * all realized widgets have a non-%NULL "window" pointer
6879 * (gtk_widget_get_window() never returns a %NULL window when a widget
6880 * is realized), but for many of them it's actually the #GdkWindow of
6881 * one of its parent widgets. Widgets that do not create a %window for
6882 * themselves in GtkWidget::realize() must announce this by
6883 * calling this function with @has_window = %FALSE.
6885 * This function should only be called by widget implementations,
6886 * and they should call it in their init() function.
6891 gtk_widget_set_has_window (GtkWidget *widget,
6892 gboolean has_window)
6894 g_return_if_fail (GTK_IS_WIDGET (widget));
6896 widget->priv->no_window = !has_window;
6900 * gtk_widget_get_has_window:
6901 * @widget: a #GtkWidget
6903 * Determines whether @widget has a #GdkWindow of its own. See
6904 * gtk_widget_set_has_window().
6906 * Return value: %TRUE if @widget has a window, %FALSE otherwise
6911 gtk_widget_get_has_window (GtkWidget *widget)
6913 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6915 return ! widget->priv->no_window;
6919 * gtk_widget_is_toplevel:
6920 * @widget: a #GtkWidget
6922 * Determines whether @widget is a toplevel widget. Currently only
6923 * #GtkWindow and #GtkInvisible are toplevel widgets. Toplevel
6924 * widgets have no parent widget.
6926 * Return value: %TRUE if @widget is a toplevel, %FALSE otherwise
6931 gtk_widget_is_toplevel (GtkWidget *widget)
6933 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6935 return widget->priv->toplevel;
6939 _gtk_widget_set_is_toplevel (GtkWidget *widget,
6940 gboolean is_toplevel)
6942 widget->priv->toplevel = is_toplevel;
6946 * gtk_widget_is_drawable:
6947 * @widget: a #GtkWidget
6949 * Determines whether @widget can be drawn to. A widget can be drawn
6950 * to if it is mapped and visible.
6952 * Return value: %TRUE if @widget is drawable, %FALSE otherwise
6957 gtk_widget_is_drawable (GtkWidget *widget)
6959 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6961 return (gtk_widget_get_visible (widget) &&
6962 gtk_widget_get_mapped (widget));
6966 * gtk_widget_get_realized:
6967 * @widget: a #GtkWidget
6969 * Determines whether @widget is realized.
6971 * Return value: %TRUE if @widget is realized, %FALSE otherwise
6976 gtk_widget_get_realized (GtkWidget *widget)
6978 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6980 return widget->priv->realized;
6984 * gtk_widget_set_realized:
6985 * @widget: a #GtkWidget
6986 * @realized: %TRUE to mark the widget as realized
6988 * Marks the widget as being realized.
6990 * This function should only ever be called in a derived widget's
6991 * "realize" or "unrealize" implementation.
6996 gtk_widget_set_realized (GtkWidget *widget,
6999 g_return_if_fail (GTK_IS_WIDGET (widget));
7001 widget->priv->realized = realized;
7005 * gtk_widget_get_mapped:
7006 * @widget: a #GtkWidget
7008 * Whether the widget is mapped.
7010 * Return value: %TRUE if the widget is mapped, %FALSE otherwise.
7015 gtk_widget_get_mapped (GtkWidget *widget)
7017 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
7019 return widget->priv->mapped;
7023 * gtk_widget_set_mapped:
7024 * @widget: a #GtkWidget
7025 * @mapped: %TRUE to mark the widget as mapped
7027 * Marks the widget as being realized.
7029 * This function should only ever be called in a derived widget's
7030 * "map" or "unmap" implementation.
7035 gtk_widget_set_mapped (GtkWidget *widget,
7038 g_return_if_fail (GTK_IS_WIDGET (widget));
7040 widget->priv->mapped = mapped;
7044 * gtk_widget_set_app_paintable:
7045 * @widget: a #GtkWidget
7046 * @app_paintable: %TRUE if the application will paint on the widget
7048 * Sets whether the application intends to draw on the widget in
7049 * an #GtkWidget::draw handler.
7051 * This is a hint to the widget and does not affect the behavior of
7052 * the GTK+ core; many widgets ignore this flag entirely. For widgets
7053 * that do pay attention to the flag, such as #GtkEventBox and #GtkWindow,
7054 * the effect is to suppress default themed drawing of the widget's
7055 * background. (Children of the widget will still be drawn.) The application
7056 * is then entirely responsible for drawing the widget background.
7058 * Note that the background is still drawn when the widget is mapped.
7061 gtk_widget_set_app_paintable (GtkWidget *widget,
7062 gboolean app_paintable)
7064 g_return_if_fail (GTK_IS_WIDGET (widget));
7066 app_paintable = (app_paintable != FALSE);
7068 if (widget->priv->app_paintable != app_paintable)
7070 widget->priv->app_paintable = app_paintable;
7072 if (gtk_widget_is_drawable (widget))
7073 gtk_widget_queue_draw (widget);
7075 g_object_notify (G_OBJECT (widget), "app-paintable");
7080 * gtk_widget_get_app_paintable:
7081 * @widget: a #GtkWidget
7083 * Determines whether the application intends to draw on the widget in
7084 * an #GtkWidget::draw handler.
7086 * See gtk_widget_set_app_paintable()
7088 * Return value: %TRUE if the widget is app paintable
7093 gtk_widget_get_app_paintable (GtkWidget *widget)
7095 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
7097 return widget->priv->app_paintable;
7101 * gtk_widget_set_double_buffered:
7102 * @widget: a #GtkWidget
7103 * @double_buffered: %TRUE to double-buffer a widget
7105 * Widgets are double buffered by default; you can use this function
7106 * to turn off the buffering. "Double buffered" simply means that
7107 * gdk_window_begin_paint_region() and gdk_window_end_paint() are called
7108 * automatically around expose events sent to the
7109 * widget. gdk_window_begin_paint() diverts all drawing to a widget's
7110 * window to an offscreen buffer, and gdk_window_end_paint() draws the
7111 * buffer to the screen. The result is that users see the window
7112 * update in one smooth step, and don't see individual graphics
7113 * primitives being rendered.
7115 * In very simple terms, double buffered widgets don't flicker,
7116 * so you would only use this function to turn off double buffering
7117 * if you had special needs and really knew what you were doing.
7119 * Note: if you turn off double-buffering, you have to handle
7120 * expose events, since even the clearing to the background color or
7121 * pixmap will not happen automatically (as it is done in
7122 * gdk_window_begin_paint()).
7125 gtk_widget_set_double_buffered (GtkWidget *widget,
7126 gboolean double_buffered)
7128 g_return_if_fail (GTK_IS_WIDGET (widget));
7130 double_buffered = (double_buffered != FALSE);
7132 if (widget->priv->double_buffered != double_buffered)
7134 widget->priv->double_buffered = double_buffered;
7136 g_object_notify (G_OBJECT (widget), "double-buffered");
7141 * gtk_widget_get_double_buffered:
7142 * @widget: a #GtkWidget
7144 * Determines whether the widget is double buffered.
7146 * See gtk_widget_set_double_buffered()
7148 * Return value: %TRUE if the widget is double buffered
7153 gtk_widget_get_double_buffered (GtkWidget *widget)
7155 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
7157 return widget->priv->double_buffered;
7161 * gtk_widget_set_redraw_on_allocate:
7162 * @widget: a #GtkWidget
7163 * @redraw_on_allocate: if %TRUE, the entire widget will be redrawn
7164 * when it is allocated to a new size. Otherwise, only the
7165 * new portion of the widget will be redrawn.
7167 * Sets whether the entire widget is queued for drawing when its size
7168 * allocation changes. By default, this setting is %TRUE and
7169 * the entire widget is redrawn on every size change. If your widget
7170 * leaves the upper left unchanged when made bigger, turning this
7171 * setting off will improve performance.
7173 * Note that for %NO_WINDOW widgets setting this flag to %FALSE turns
7174 * off all allocation on resizing: the widget will not even redraw if
7175 * its position changes; this is to allow containers that don't draw
7176 * anything to avoid excess invalidations. If you set this flag on a
7177 * %NO_WINDOW widget that <emphasis>does</emphasis> draw on @widget->window,
7178 * you are responsible for invalidating both the old and new allocation
7179 * of the widget when the widget is moved and responsible for invalidating
7180 * regions newly when the widget increases size.
7183 gtk_widget_set_redraw_on_allocate (GtkWidget *widget,
7184 gboolean redraw_on_allocate)
7186 g_return_if_fail (GTK_IS_WIDGET (widget));
7188 widget->priv->redraw_on_alloc = redraw_on_allocate;
7192 * gtk_widget_set_sensitive:
7193 * @widget: a #GtkWidget
7194 * @sensitive: %TRUE to make the widget sensitive
7196 * Sets the sensitivity of a widget. A widget is sensitive if the user
7197 * can interact with it. Insensitive widgets are "grayed out" and the
7198 * user can't interact with them. Insensitive widgets are known as
7199 * "inactive", "disabled", or "ghosted" in some other toolkits.
7202 gtk_widget_set_sensitive (GtkWidget *widget,
7205 GtkWidgetPrivate *priv;
7208 g_return_if_fail (GTK_IS_WIDGET (widget));
7210 priv = widget->priv;
7212 sensitive = (sensitive != FALSE);
7214 if (widget->priv->sensitive == sensitive)
7219 widget->priv->sensitive = TRUE;
7220 data.state = priv->saved_state;
7224 widget->priv->sensitive = FALSE;
7225 data.state = gtk_widget_get_state (widget);
7227 data.state_restoration = TRUE;
7228 data.use_forall = TRUE;
7231 data.parent_sensitive = gtk_widget_is_sensitive (priv->parent);
7233 data.parent_sensitive = TRUE;
7235 gtk_widget_propagate_state (widget, &data);
7236 if (gtk_widget_is_drawable (widget))
7237 gtk_widget_queue_draw (widget);
7239 g_object_notify (G_OBJECT (widget), "sensitive");
7243 * gtk_widget_get_sensitive:
7244 * @widget: a #GtkWidget
7246 * Returns the widget's sensitivity (in the sense of returning
7247 * the value that has been set using gtk_widget_set_sensitive()).
7249 * The effective sensitivity of a widget is however determined by both its
7250 * own and its parent widget's sensitivity. See gtk_widget_is_sensitive().
7252 * Returns: %TRUE if the widget is sensitive
7257 gtk_widget_get_sensitive (GtkWidget *widget)
7259 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
7261 return widget->priv->sensitive;
7265 * gtk_widget_is_sensitive:
7266 * @widget: a #GtkWidget
7268 * Returns the widget's effective sensitivity, which means
7269 * it is sensitive itself and also its parent widget is sensntive
7271 * Returns: %TRUE if the widget is effectively sensitive
7276 gtk_widget_is_sensitive (GtkWidget *widget)
7278 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
7280 return widget->priv->sensitive && widget->priv->parent_sensitive;
7284 * gtk_widget_set_parent:
7285 * @widget: a #GtkWidget
7286 * @parent: parent container
7288 * This function is useful only when implementing subclasses of
7290 * Sets the container as the parent of @widget, and takes care of
7291 * some details such as updating the state and style of the child
7292 * to reflect its new location. The opposite function is
7293 * gtk_widget_unparent().
7296 gtk_widget_set_parent (GtkWidget *widget,
7299 GtkWidgetPrivate *priv;
7302 g_return_if_fail (GTK_IS_WIDGET (widget));
7303 g_return_if_fail (GTK_IS_WIDGET (parent));
7304 g_return_if_fail (widget != parent);
7306 priv = widget->priv;
7308 if (priv->parent != NULL)
7310 g_warning ("Can't set a parent on widget which has a parent\n");
7313 if (gtk_widget_is_toplevel (widget))
7315 g_warning ("Can't set a parent on a toplevel widget\n");
7319 /* keep this function in sync with gtk_menu_attach_to_widget()
7322 g_object_ref_sink (widget);
7323 priv->parent = parent;
7325 if (gtk_widget_get_state (parent) != GTK_STATE_NORMAL)
7326 data.state = gtk_widget_get_state (parent);
7328 data.state = gtk_widget_get_state (widget);
7329 data.state_restoration = FALSE;
7330 data.parent_sensitive = (gtk_widget_is_sensitive (parent) != FALSE);
7331 data.use_forall = gtk_widget_is_sensitive (parent) != gtk_widget_is_sensitive (widget);
7333 gtk_widget_propagate_state (widget, &data);
7335 gtk_widget_reset_rc_styles (widget);
7337 g_signal_emit (widget, widget_signals[PARENT_SET], 0, NULL);
7338 if (priv->parent->priv->anchored)
7339 _gtk_widget_propagate_hierarchy_changed (widget, NULL);
7340 g_object_notify (G_OBJECT (widget), "parent");
7342 /* Enforce realized/mapped invariants
7344 if (gtk_widget_get_realized (priv->parent))
7345 gtk_widget_realize (widget);
7347 if (gtk_widget_get_visible (priv->parent) &&
7348 gtk_widget_get_visible (widget))
7350 if (gtk_widget_get_child_visible (widget) &&
7351 gtk_widget_get_mapped (priv->parent))
7352 gtk_widget_map (widget);
7354 gtk_widget_queue_resize (widget);
7357 /* child may cause parent's expand to change, if the child is
7358 * expanded. If child is not expanded, then it can't modify the
7359 * parent's expand. If the child becomes expanded later then it will
7360 * queue compute_expand then. This optimization plus defaulting
7361 * newly-constructed widgets to need_compute_expand=FALSE should
7362 * mean that initially building a widget tree doesn't have to keep
7363 * walking up setting need_compute_expand on parents over and over.
7365 * We can't change a parent to need to expand unless we're visible.
7367 if (gtk_widget_get_visible (widget) &&
7368 (priv->need_compute_expand ||
7369 priv->computed_hexpand ||
7370 priv->computed_vexpand))
7372 gtk_widget_queue_compute_expand (parent);
7377 * gtk_widget_get_parent:
7378 * @widget: a #GtkWidget
7380 * Returns the parent container of @widget.
7382 * Return value: (transfer none): the parent container of @widget, or %NULL
7385 gtk_widget_get_parent (GtkWidget *widget)
7387 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
7389 return widget->priv->parent;
7392 /*****************************************
7394 * see docs/styles.txt
7395 *****************************************/
7398 * gtk_widget_style_attach:
7399 * @widget: a #GtkWidget
7401 * This function attaches the widget's #GtkStyle to the widget's
7402 * #GdkWindow. It is a replacement for
7405 * widget->style = gtk_style_attach (widget->style, widget->window);
7408 * and should only ever be called in a derived widget's "realize"
7409 * implementation which does not chain up to its parent class'
7410 * "realize" implementation, because one of the parent classes
7411 * (finally #GtkWidget) would attach the style itself.
7416 gtk_widget_style_attach (GtkWidget *widget)
7418 GtkWidgetPrivate *priv;
7420 g_return_if_fail (GTK_IS_WIDGET (widget));
7421 g_return_if_fail (gtk_widget_get_realized (widget));
7423 priv = widget->priv;
7425 priv->style = gtk_style_attach (priv->style, priv->window);
7429 * gtk_widget_has_rc_style:
7430 * @widget: a #GtkWidget
7432 * Determines if the widget style has been looked up through the rc mechanism.
7434 * Returns: %TRUE if the widget has been looked up through the rc
7435 * mechanism, %FALSE otherwise.
7440 gtk_widget_has_rc_style (GtkWidget *widget)
7442 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
7444 return widget->priv->rc_style;
7448 * gtk_widget_set_style:
7449 * @widget: a #GtkWidget
7450 * @style: (allow-none): a #GtkStyle, or %NULL to remove the effect of a previous
7451 * gtk_widget_set_style() and go back to the default style
7453 * Sets the #GtkStyle for a widget (@widget->style). You probably don't
7454 * want to use this function; it interacts badly with themes, because
7455 * themes work by replacing the #GtkStyle. Instead, use
7456 * gtk_widget_modify_style().
7459 gtk_widget_set_style (GtkWidget *widget,
7462 g_return_if_fail (GTK_IS_WIDGET (widget));
7466 gboolean initial_emission;
7468 initial_emission = !widget->priv->rc_style && !widget->priv->user_style;
7470 widget->priv->rc_style = FALSE;
7471 widget->priv->user_style = TRUE;
7473 gtk_widget_set_style_internal (widget, style, initial_emission);
7477 if (widget->priv->user_style)
7478 gtk_widget_reset_rc_style (widget);
7483 * gtk_widget_ensure_style:
7484 * @widget: a #GtkWidget
7486 * Ensures that @widget has a style (@widget->style). Not a very useful
7487 * function; most of the time, if you want the style, the widget is
7488 * realized, and realized widgets are guaranteed to have a style
7492 gtk_widget_ensure_style (GtkWidget *widget)
7494 g_return_if_fail (GTK_IS_WIDGET (widget));
7496 if (!widget->priv->rc_style && !widget->priv->user_style)
7497 gtk_widget_reset_rc_style (widget);
7500 /* Look up the RC style for this widget, unsetting any user style that
7501 * may be in effect currently
7504 gtk_widget_reset_rc_style (GtkWidget *widget)
7506 GtkWidgetPrivate *priv = widget->priv;
7507 GtkStyle *new_style = NULL;
7508 gboolean initial_emission;
7510 initial_emission = !priv->rc_style && !priv->user_style;
7512 priv->user_style = FALSE;
7513 priv->rc_style = TRUE;
7515 if (gtk_widget_has_screen (widget))
7516 new_style = gtk_rc_get_style (widget);
7518 new_style = gtk_widget_get_default_style ();
7520 if (initial_emission || new_style != priv->style)
7521 gtk_widget_set_style_internal (widget, new_style, initial_emission);
7525 * gtk_widget_get_style:
7526 * @widget: a #GtkWidget
7528 * Simply an accessor function that returns @widget->style.
7530 * Return value: (transfer none): the widget's #GtkStyle
7533 gtk_widget_get_style (GtkWidget *widget)
7535 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
7537 return widget->priv->style;
7541 * gtk_widget_modify_style:
7542 * @widget: a #GtkWidget
7543 * @style: the #GtkRcStyle holding the style modifications
7545 * Modifies style values on the widget. Modifications made using this
7546 * technique take precedence over style values set via an RC file,
7547 * however, they will be overriden if a style is explicitely set on
7548 * the widget using gtk_widget_set_style(). The #GtkRcStyle structure
7549 * is designed so each field can either be set or unset, so it is
7550 * possible, using this function, to modify some style values and
7551 * leave the others unchanged.
7553 * Note that modifications made with this function are not cumulative
7554 * with previous calls to gtk_widget_modify_style() or with such
7555 * functions as gtk_widget_modify_fg(). If you wish to retain
7556 * previous values, you must first call gtk_widget_get_modifier_style(),
7557 * make your modifications to the returned style, then call
7558 * gtk_widget_modify_style() with that style. On the other hand,
7559 * if you first call gtk_widget_modify_style(), subsequent calls
7560 * to such functions gtk_widget_modify_fg() will have a cumulative
7561 * effect with the initial modifications.
7564 gtk_widget_modify_style (GtkWidget *widget,
7567 g_return_if_fail (GTK_IS_WIDGET (widget));
7568 g_return_if_fail (GTK_IS_RC_STYLE (style));
7570 g_object_set_qdata_full (G_OBJECT (widget),
7572 gtk_rc_style_copy (style),
7573 (GDestroyNotify) g_object_unref);
7575 /* note that "style" may be invalid here if it was the old
7576 * modifier style and the only reference was our own.
7579 if (widget->priv->rc_style)
7580 gtk_widget_reset_rc_style (widget);
7584 * gtk_widget_get_modifier_style:
7585 * @widget: a #GtkWidget
7587 * Returns the current modifier style for the widget. (As set by
7588 * gtk_widget_modify_style().) If no style has previously set, a new
7589 * #GtkRcStyle will be created with all values unset, and set as the
7590 * modifier style for the widget. If you make changes to this rc
7591 * style, you must call gtk_widget_modify_style(), passing in the
7592 * returned rc style, to make sure that your changes take effect.
7594 * Caution: passing the style back to gtk_widget_modify_style() will
7595 * normally end up destroying it, because gtk_widget_modify_style() copies
7596 * the passed-in style and sets the copy as the new modifier style,
7597 * thus dropping any reference to the old modifier style. Add a reference
7598 * to the modifier style if you want to keep it alive.
7600 * Return value: (transfer none): the modifier style for the widget. This rc style is
7601 * owned by the widget. If you want to keep a pointer to value this
7602 * around, you must add a refcount using g_object_ref().
7605 gtk_widget_get_modifier_style (GtkWidget *widget)
7607 GtkRcStyle *rc_style;
7609 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
7611 rc_style = g_object_get_qdata (G_OBJECT (widget), quark_rc_style);
7615 rc_style = gtk_rc_style_new ();
7616 g_object_set_qdata_full (G_OBJECT (widget),
7619 (GDestroyNotify) g_object_unref);
7626 gtk_widget_modify_color_component (GtkWidget *widget,
7627 GtkRcFlags component,
7629 const GdkColor *color)
7631 GtkRcStyle *rc_style = gtk_widget_get_modifier_style (widget);
7638 rc_style->fg[state] = *color;
7641 rc_style->bg[state] = *color;
7644 rc_style->text[state] = *color;
7647 rc_style->base[state] = *color;
7650 g_assert_not_reached();
7653 rc_style->color_flags[state] |= component;
7656 rc_style->color_flags[state] &= ~component;
7658 gtk_widget_modify_style (widget, rc_style);
7662 * gtk_widget_modify_symbolic_color:
7663 * @widget: a #GtkWidget
7664 * @name: the name of the symbolic color to modify
7665 * @color: (allow-none): the color to assign (does not need to be allocated),
7666 * or %NULL to undo the effect of previous calls to
7667 * of gtk_widget_modify_symbolic_color().
7669 * Sets a symbolic color for a widget.
7670 * All other style values are left untouched. See also
7671 * gtk_widget_modify_style().
7676 gtk_widget_modify_symbolic_color (GtkWidget *widget,
7678 const GdkColor *color)
7680 GtkRcStyle *rc_style = gtk_widget_get_modifier_style (widget);
7682 _gtk_rc_style_set_symbolic_color (rc_style, name, color);
7684 gtk_widget_modify_style (widget, rc_style);
7688 * gtk_widget_modify_fg:
7689 * @widget: a #GtkWidget
7690 * @state: the state for which to set the foreground color
7691 * @color: (allow-none): the color to assign (does not need to be allocated),
7692 * or %NULL to undo the effect of previous calls to
7693 * of gtk_widget_modify_fg().
7695 * Sets the foreground color for a widget in a particular state.
7696 * All other style values are left untouched. See also
7697 * gtk_widget_modify_style().
7700 gtk_widget_modify_fg (GtkWidget *widget,
7702 const GdkColor *color)
7704 g_return_if_fail (GTK_IS_WIDGET (widget));
7705 g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE);
7707 gtk_widget_modify_color_component (widget, GTK_RC_FG, state, color);
7711 * gtk_widget_modify_bg:
7712 * @widget: a #GtkWidget
7713 * @state: the state for which to set the background color
7714 * @color: (allow-none): the color to assign (does not need to be allocated),
7715 * or %NULL to undo the effect of previous calls to
7716 * of gtk_widget_modify_bg().
7718 * Sets the background color for a widget in a particular state.
7719 * All other style values are left untouched. See also
7720 * gtk_widget_modify_style().
7722 * Note that "no window" widgets (which have the %GTK_NO_WINDOW flag set)
7723 * draw on their parent container's window and thus may not draw any
7724 * background themselves. This is the case for e.g. #GtkLabel. To modify
7725 * the background of such widgets, you have to set the background color
7726 * on their parent; if you want to set the background of a rectangular
7727 * area around a label, try placing the label in a #GtkEventBox widget
7728 * and setting the background color on that.
7731 gtk_widget_modify_bg (GtkWidget *widget,
7733 const GdkColor *color)
7735 g_return_if_fail (GTK_IS_WIDGET (widget));
7736 g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE);
7738 gtk_widget_modify_color_component (widget, GTK_RC_BG, state, color);
7742 * gtk_widget_modify_text:
7743 * @widget: a #GtkWidget
7744 * @state: the state for which to set the text color
7745 * @color: (allow-none): the color to assign (does not need to be allocated),
7746 * or %NULL to undo the effect of previous calls to
7747 * of gtk_widget_modify_text().
7749 * Sets the text color for a widget in a particular state. All other
7750 * style values are left untouched. The text color is the foreground
7751 * color used along with the base color (see gtk_widget_modify_base())
7752 * for widgets such as #GtkEntry and #GtkTextView. See also
7753 * gtk_widget_modify_style().
7756 gtk_widget_modify_text (GtkWidget *widget,
7758 const GdkColor *color)
7760 g_return_if_fail (GTK_IS_WIDGET (widget));
7761 g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE);
7763 gtk_widget_modify_color_component (widget, GTK_RC_TEXT, state, color);
7767 * gtk_widget_modify_base:
7768 * @widget: a #GtkWidget
7769 * @state: the state for which to set the base color
7770 * @color: (allow-none): the color to assign (does not need to be allocated),
7771 * or %NULL to undo the effect of previous calls to
7772 * of gtk_widget_modify_base().
7774 * Sets the base color for a widget in a particular state.
7775 * All other style values are left untouched. The base color
7776 * is the background color used along with the text color
7777 * (see gtk_widget_modify_text()) for widgets such as #GtkEntry
7778 * and #GtkTextView. See also gtk_widget_modify_style().
7780 * Note that "no window" widgets (which have the %GTK_NO_WINDOW flag set)
7781 * draw on their parent container's window and thus may not draw any
7782 * background themselves. This is the case for e.g. #GtkLabel. To modify
7783 * the background of such widgets, you have to set the base color on their
7784 * parent; if you want to set the background of a rectangular area around
7785 * a label, try placing the label in a #GtkEventBox widget and setting
7786 * the base color on that.
7789 gtk_widget_modify_base (GtkWidget *widget,
7791 const GdkColor *color)
7793 g_return_if_fail (GTK_IS_WIDGET (widget));
7794 g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE);
7796 gtk_widget_modify_color_component (widget, GTK_RC_BASE, state, color);
7800 modify_color_property (GtkWidget *widget,
7801 GtkRcStyle *rc_style,
7803 const GdkColor *color)
7805 GQuark type_name = g_type_qname (G_OBJECT_TYPE (widget));
7806 GQuark property_name = g_quark_from_string (name);
7810 GtkRcProperty rc_property = {0};
7813 rc_property.type_name = type_name;
7814 rc_property.property_name = property_name;
7815 rc_property.origin = NULL;
7817 color_name = gdk_color_to_string (color);
7818 g_value_init (&rc_property.value, G_TYPE_STRING);
7819 g_value_take_string (&rc_property.value, color_name);
7821 _gtk_rc_style_set_rc_property (rc_style, &rc_property);
7823 g_value_unset (&rc_property.value);
7826 _gtk_rc_style_unset_rc_property (rc_style, type_name, property_name);
7830 * gtk_widget_modify_cursor:
7831 * @widget: a #GtkWidget
7832 * @primary: the color to use for primary cursor (does not need to be
7833 * allocated), or %NULL to undo the effect of previous calls to
7834 * of gtk_widget_modify_cursor().
7835 * @secondary: the color to use for secondary cursor (does not need to be
7836 * allocated), or %NULL to undo the effect of previous calls to
7837 * of gtk_widget_modify_cursor().
7839 * Sets the cursor color to use in a widget, overriding the
7840 * #GtkWidget:cursor-color and #GtkWidget:secondary-cursor-color
7841 * style properties. All other style values are left untouched.
7842 * See also gtk_widget_modify_style().
7847 gtk_widget_modify_cursor (GtkWidget *widget,
7848 const GdkColor *primary,
7849 const GdkColor *secondary)
7851 GtkRcStyle *rc_style;
7853 g_return_if_fail (GTK_IS_WIDGET (widget));
7855 rc_style = gtk_widget_get_modifier_style (widget);
7857 modify_color_property (widget, rc_style, "cursor-color", primary);
7858 modify_color_property (widget, rc_style, "secondary-cursor-color", secondary);
7860 gtk_widget_modify_style (widget, rc_style);
7864 * gtk_widget_modify_font:
7865 * @widget: a #GtkWidget
7866 * @font_desc: (allow-none): the font description to use, or %NULL to undo
7867 * the effect of previous calls to gtk_widget_modify_font().
7869 * Sets the font to use for a widget. All other style values are left
7870 * untouched. See also gtk_widget_modify_style().
7873 gtk_widget_modify_font (GtkWidget *widget,
7874 PangoFontDescription *font_desc)
7876 GtkRcStyle *rc_style;
7878 g_return_if_fail (GTK_IS_WIDGET (widget));
7880 rc_style = gtk_widget_get_modifier_style (widget);
7882 if (rc_style->font_desc)
7883 pango_font_description_free (rc_style->font_desc);
7886 rc_style->font_desc = pango_font_description_copy (font_desc);
7888 rc_style->font_desc = NULL;
7890 gtk_widget_modify_style (widget, rc_style);
7894 gtk_widget_real_direction_changed (GtkWidget *widget,
7895 GtkTextDirection previous_direction)
7897 gtk_widget_queue_resize (widget);
7901 gtk_widget_real_style_set (GtkWidget *widget,
7902 GtkStyle *previous_style)
7904 GtkWidgetPrivate *priv = widget->priv;
7906 if (gtk_widget_get_realized (widget) &&
7907 gtk_widget_get_has_window (widget))
7908 gtk_style_set_background (priv->style, priv->window, priv->state);
7912 gtk_widget_set_style_internal (GtkWidget *widget,
7914 gboolean initial_emission)
7916 GtkWidgetPrivate *priv = widget->priv;
7918 g_object_ref (widget);
7919 g_object_freeze_notify (G_OBJECT (widget));
7921 if (priv->style != style)
7923 GtkStyle *previous_style;
7925 if (gtk_widget_get_realized (widget))
7927 gtk_widget_reset_shapes (widget);
7928 gtk_style_detach (priv->style);
7931 previous_style = priv->style;
7932 priv->style = style;
7933 g_object_ref (priv->style);
7935 if (gtk_widget_get_realized (widget))
7936 priv->style = gtk_style_attach (priv->style, priv->window);
7938 gtk_widget_update_pango_context (widget);
7939 g_signal_emit (widget,
7940 widget_signals[STYLE_SET],
7942 initial_emission ? NULL : previous_style);
7943 g_object_unref (previous_style);
7945 if (priv->anchored && !initial_emission)
7946 gtk_widget_queue_resize (widget);
7948 else if (initial_emission)
7950 gtk_widget_update_pango_context (widget);
7951 g_signal_emit (widget,
7952 widget_signals[STYLE_SET],
7956 g_object_notify (G_OBJECT (widget), "style");
7957 g_object_thaw_notify (G_OBJECT (widget));
7958 g_object_unref (widget);
7962 GtkWidget *previous_toplevel;
7963 GdkScreen *previous_screen;
7964 GdkScreen *new_screen;
7965 } HierarchyChangedInfo;
7968 do_screen_change (GtkWidget *widget,
7969 GdkScreen *old_screen,
7970 GdkScreen *new_screen)
7972 if (old_screen != new_screen)
7976 PangoContext *context = g_object_get_qdata (G_OBJECT (widget), quark_pango_context);
7978 g_object_set_qdata (G_OBJECT (widget), quark_pango_context, NULL);
7981 _gtk_tooltip_hide (widget);
7982 g_signal_emit (widget, widget_signals[SCREEN_CHANGED], 0, old_screen);
7987 gtk_widget_propagate_hierarchy_changed_recurse (GtkWidget *widget,
7988 gpointer client_data)
7990 GtkWidgetPrivate *priv = widget->priv;
7991 HierarchyChangedInfo *info = client_data;
7992 gboolean new_anchored = gtk_widget_is_toplevel (widget) ||
7993 (priv->parent && priv->parent->priv->anchored);
7995 if (priv->anchored != new_anchored)
7997 g_object_ref (widget);
7999 priv->anchored = new_anchored;
8001 g_signal_emit (widget, widget_signals[HIERARCHY_CHANGED], 0, info->previous_toplevel);
8002 do_screen_change (widget, info->previous_screen, info->new_screen);
8004 if (GTK_IS_CONTAINER (widget))
8005 gtk_container_forall (GTK_CONTAINER (widget),
8006 gtk_widget_propagate_hierarchy_changed_recurse,
8009 g_object_unref (widget);
8014 * _gtk_widget_propagate_hierarchy_changed:
8015 * @widget: a #GtkWidget
8016 * @previous_toplevel: Previous toplevel
8018 * Propagates changes in the anchored state to a widget and all
8019 * children, unsetting or setting the %ANCHORED flag, and
8020 * emitting #GtkWidget::hierarchy-changed.
8023 _gtk_widget_propagate_hierarchy_changed (GtkWidget *widget,
8024 GtkWidget *previous_toplevel)
8026 GtkWidgetPrivate *priv = widget->priv;
8027 HierarchyChangedInfo info;
8029 info.previous_toplevel = previous_toplevel;
8030 info.previous_screen = previous_toplevel ? gtk_widget_get_screen (previous_toplevel) : NULL;
8032 if (gtk_widget_is_toplevel (widget) ||
8033 (priv->parent && priv->parent->priv->anchored))
8034 info.new_screen = gtk_widget_get_screen (widget);
8036 info.new_screen = NULL;
8038 if (info.previous_screen)
8039 g_object_ref (info.previous_screen);
8040 if (previous_toplevel)
8041 g_object_ref (previous_toplevel);
8043 gtk_widget_propagate_hierarchy_changed_recurse (widget, &info);
8045 if (previous_toplevel)
8046 g_object_unref (previous_toplevel);
8047 if (info.previous_screen)
8048 g_object_unref (info.previous_screen);
8052 gtk_widget_propagate_screen_changed_recurse (GtkWidget *widget,
8053 gpointer client_data)
8055 HierarchyChangedInfo *info = client_data;
8057 g_object_ref (widget);
8059 do_screen_change (widget, info->previous_screen, info->new_screen);
8061 if (GTK_IS_CONTAINER (widget))
8062 gtk_container_forall (GTK_CONTAINER (widget),
8063 gtk_widget_propagate_screen_changed_recurse,
8066 g_object_unref (widget);
8070 * gtk_widget_is_composited:
8071 * @widget: a #GtkWidget
8073 * Whether @widget can rely on having its alpha channel
8074 * drawn correctly. On X11 this function returns whether a
8075 * compositing manager is running for @widget's screen.
8077 * Please note that the semantics of this call will change
8078 * in the future if used on a widget that has a composited
8079 * window in its hierarchy (as set by gdk_window_set_composited()).
8081 * Return value: %TRUE if the widget can rely on its alpha
8082 * channel being drawn correctly.
8087 gtk_widget_is_composited (GtkWidget *widget)
8091 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
8093 screen = gtk_widget_get_screen (widget);
8095 return gdk_screen_is_composited (screen);
8099 propagate_composited_changed (GtkWidget *widget,
8102 if (GTK_IS_CONTAINER (widget))
8104 gtk_container_forall (GTK_CONTAINER (widget),
8105 propagate_composited_changed,
8109 g_signal_emit (widget, widget_signals[COMPOSITED_CHANGED], 0);
8113 _gtk_widget_propagate_composited_changed (GtkWidget *widget)
8115 propagate_composited_changed (widget, NULL);
8119 * _gtk_widget_propagate_screen_changed:
8120 * @widget: a #GtkWidget
8121 * @previous_screen: Previous screen
8123 * Propagates changes in the screen for a widget to all
8124 * children, emitting #GtkWidget::screen-changed.
8127 _gtk_widget_propagate_screen_changed (GtkWidget *widget,
8128 GdkScreen *previous_screen)
8130 HierarchyChangedInfo info;
8132 info.previous_screen = previous_screen;
8133 info.new_screen = gtk_widget_get_screen (widget);
8135 if (previous_screen)
8136 g_object_ref (previous_screen);
8138 gtk_widget_propagate_screen_changed_recurse (widget, &info);
8140 if (previous_screen)
8141 g_object_unref (previous_screen);
8145 reset_rc_styles_recurse (GtkWidget *widget, gpointer data)
8147 if (widget->priv->rc_style)
8148 gtk_widget_reset_rc_style (widget);
8150 if (GTK_IS_CONTAINER (widget))
8151 gtk_container_forall (GTK_CONTAINER (widget),
8152 reset_rc_styles_recurse,
8158 * gtk_widget_reset_rc_styles:
8159 * @widget: a #GtkWidget.
8161 * Reset the styles of @widget and all descendents, so when
8162 * they are looked up again, they get the correct values
8163 * for the currently loaded RC file settings.
8165 * This function is not useful for applications.
8168 gtk_widget_reset_rc_styles (GtkWidget *widget)
8170 g_return_if_fail (GTK_IS_WIDGET (widget));
8172 reset_rc_styles_recurse (widget, NULL);
8176 * gtk_widget_get_default_style:
8178 * Returns the default style used by all widgets initially.
8180 * Returns: (transfer none): the default style. This #GtkStyle object is owned
8181 * by GTK+ and should not be modified or freed.
8184 gtk_widget_get_default_style (void)
8186 if (!gtk_default_style)
8188 gtk_default_style = gtk_style_new ();
8189 g_object_ref (gtk_default_style);
8192 return gtk_default_style;
8195 static PangoContext *
8196 gtk_widget_peek_pango_context (GtkWidget *widget)
8198 return g_object_get_qdata (G_OBJECT (widget), quark_pango_context);
8202 * gtk_widget_get_pango_context:
8203 * @widget: a #GtkWidget
8205 * Gets a #PangoContext with the appropriate font map, font description,
8206 * and base direction for this widget. Unlike the context returned
8207 * by gtk_widget_create_pango_context(), this context is owned by
8208 * the widget (it can be used until the screen for the widget changes
8209 * or the widget is removed from its toplevel), and will be updated to
8210 * match any changes to the widget's attributes.
8212 * If you create and keep a #PangoLayout using this context, you must
8213 * deal with changes to the context by calling pango_layout_context_changed()
8214 * on the layout in response to the #GtkWidget::style-set and
8215 * #GtkWidget::direction-changed signals for the widget.
8217 * Return value: (transfer none): the #PangoContext for the widget.
8220 gtk_widget_get_pango_context (GtkWidget *widget)
8222 PangoContext *context;
8224 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8226 context = g_object_get_qdata (G_OBJECT (widget), quark_pango_context);
8229 context = gtk_widget_create_pango_context (GTK_WIDGET (widget));
8230 g_object_set_qdata_full (G_OBJECT (widget),
8231 quark_pango_context,
8240 update_pango_context (GtkWidget *widget,
8241 PangoContext *context)
8243 GtkWidgetPrivate *priv = widget->priv;
8245 pango_context_set_font_description (context, priv->style->font_desc);
8246 pango_context_set_base_dir (context,
8247 gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
8248 PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
8252 gtk_widget_update_pango_context (GtkWidget *widget)
8254 PangoContext *context = gtk_widget_peek_pango_context (widget);
8260 update_pango_context (widget, context);
8262 screen = gtk_widget_get_screen_unchecked (widget);
8265 pango_cairo_context_set_resolution (context,
8266 gdk_screen_get_resolution (screen));
8267 pango_cairo_context_set_font_options (context,
8268 gdk_screen_get_font_options (screen));
8274 * gtk_widget_create_pango_context:
8275 * @widget: a #GtkWidget
8277 * Creates a new #PangoContext with the appropriate font map,
8278 * font description, and base direction for drawing text for
8279 * this widget. See also gtk_widget_get_pango_context().
8281 * Return value: (transfer full): the new #PangoContext
8284 gtk_widget_create_pango_context (GtkWidget *widget)
8287 PangoContext *context;
8289 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8291 screen = gtk_widget_get_screen_unchecked (widget);
8294 GTK_NOTE (MULTIHEAD,
8295 g_warning ("gtk_widget_create_pango_context ()) called without screen"));
8297 screen = gdk_screen_get_default ();
8300 context = gdk_pango_context_get_for_screen (screen);
8302 update_pango_context (widget, context);
8303 pango_context_set_language (context, gtk_get_default_language ());
8309 * gtk_widget_create_pango_layout:
8310 * @widget: a #GtkWidget
8311 * @text: text to set on the layout (can be %NULL)
8313 * Creates a new #PangoLayout with the appropriate font map,
8314 * font description, and base direction for drawing text for
8317 * If you keep a #PangoLayout created in this way around, in order to
8318 * notify the layout of changes to the base direction or font of this
8319 * widget, you must call pango_layout_context_changed() in response to
8320 * the #GtkWidget::style-set and #GtkWidget::direction-changed signals
8323 * Return value: (transfer full): the new #PangoLayout
8326 gtk_widget_create_pango_layout (GtkWidget *widget,
8329 PangoLayout *layout;
8330 PangoContext *context;
8332 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8334 context = gtk_widget_get_pango_context (widget);
8335 layout = pango_layout_new (context);
8338 pango_layout_set_text (layout, text, -1);
8344 * gtk_widget_render_icon:
8345 * @widget: a #GtkWidget
8346 * @stock_id: a stock ID
8347 * @size: (type int): a stock size. A size of (GtkIconSize)-1 means
8348 * render at the size of the source and don't scale (if there are
8349 * multiple source sizes, GTK+ picks one of the available sizes).
8350 * @detail: (allow-none): render detail to pass to theme engine
8352 * A convenience function that uses the theme engine and RC file
8353 * settings for @widget to look up @stock_id and render it to
8354 * a pixbuf. @stock_id should be a stock icon ID such as
8355 * #GTK_STOCK_OPEN or #GTK_STOCK_OK. @size should be a size
8356 * such as #GTK_ICON_SIZE_MENU. @detail should be a string that
8357 * identifies the widget or code doing the rendering, so that
8358 * theme engines can special-case rendering for that widget or code.
8360 * The pixels in the returned #GdkPixbuf are shared with the rest of
8361 * the application and should not be modified. The pixbuf should be freed
8362 * after use with g_object_unref().
8364 * Return value: (transfer full): a new pixbuf, or %NULL if the
8365 * stock ID wasn't known
8368 gtk_widget_render_icon (GtkWidget *widget,
8369 const gchar *stock_id,
8371 const gchar *detail)
8373 GtkWidgetPrivate *priv;
8374 GtkIconSet *icon_set;
8377 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8378 g_return_val_if_fail (stock_id != NULL, NULL);
8379 g_return_val_if_fail (size > GTK_ICON_SIZE_INVALID || size == -1, NULL);
8381 priv = widget->priv;
8383 gtk_widget_ensure_style (widget);
8385 icon_set = gtk_style_lookup_icon_set (priv->style, stock_id);
8387 if (icon_set == NULL)
8390 retval = gtk_icon_set_render_icon (icon_set,
8392 gtk_widget_get_direction (widget),
8393 gtk_widget_get_state (widget),
8402 * gtk_widget_set_parent_window:
8403 * @widget: a #GtkWidget.
8404 * @parent_window: the new parent window.
8406 * Sets a non default parent window for @widget.
8409 gtk_widget_set_parent_window (GtkWidget *widget,
8410 GdkWindow *parent_window)
8412 GdkWindow *old_parent_window;
8414 g_return_if_fail (GTK_IS_WIDGET (widget));
8416 old_parent_window = g_object_get_qdata (G_OBJECT (widget),
8417 quark_parent_window);
8419 if (parent_window != old_parent_window)
8421 g_object_set_qdata (G_OBJECT (widget), quark_parent_window,
8423 if (old_parent_window)
8424 g_object_unref (old_parent_window);
8426 g_object_ref (parent_window);
8431 * gtk_widget_get_parent_window:
8432 * @widget: a #GtkWidget.
8434 * Gets @widget's parent window.
8436 * Returns: (transfer none): the parent window of @widget.
8439 gtk_widget_get_parent_window (GtkWidget *widget)
8441 GtkWidgetPrivate *priv;
8442 GdkWindow *parent_window;
8444 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8446 priv = widget->priv;
8448 parent_window = g_object_get_qdata (G_OBJECT (widget), quark_parent_window);
8450 return (parent_window != NULL) ? parent_window :
8451 (priv->parent != NULL) ? priv->parent->priv->window : NULL;
8456 * gtk_widget_set_child_visible:
8457 * @widget: a #GtkWidget
8458 * @is_visible: if %TRUE, @widget should be mapped along with its parent.
8460 * Sets whether @widget should be mapped along with its when its parent
8461 * is mapped and @widget has been shown with gtk_widget_show().
8463 * The child visibility can be set for widget before it is added to
8464 * a container with gtk_widget_set_parent(), to avoid mapping
8465 * children unnecessary before immediately unmapping them. However
8466 * it will be reset to its default state of %TRUE when the widget
8467 * is removed from a container.
8469 * Note that changing the child visibility of a widget does not
8470 * queue a resize on the widget. Most of the time, the size of
8471 * a widget is computed from all visible children, whether or
8472 * not they are mapped. If this is not the case, the container
8473 * can queue a resize itself.
8475 * This function is only useful for container implementations and
8476 * never should be called by an application.
8479 gtk_widget_set_child_visible (GtkWidget *widget,
8480 gboolean is_visible)
8482 GtkWidgetPrivate *priv;
8484 g_return_if_fail (GTK_IS_WIDGET (widget));
8485 g_return_if_fail (!gtk_widget_is_toplevel (widget));
8487 priv = widget->priv;
8489 g_object_ref (widget);
8492 priv->child_visible = TRUE;
8495 GtkWidget *toplevel;
8497 priv->child_visible = FALSE;
8499 toplevel = gtk_widget_get_toplevel (widget);
8500 if (toplevel != widget && gtk_widget_is_toplevel (toplevel))
8501 _gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
8504 if (priv->parent && gtk_widget_get_realized (priv->parent))
8506 if (gtk_widget_get_mapped (priv->parent) &&
8507 priv->child_visible &&
8508 gtk_widget_get_visible (widget))
8509 gtk_widget_map (widget);
8511 gtk_widget_unmap (widget);
8514 g_object_unref (widget);
8518 * gtk_widget_get_child_visible:
8519 * @widget: a #GtkWidget
8521 * Gets the value set with gtk_widget_set_child_visible().
8522 * If you feel a need to use this function, your code probably
8523 * needs reorganization.
8525 * This function is only useful for container implementations and
8526 * never should be called by an application.
8528 * Return value: %TRUE if the widget is mapped with the parent.
8531 gtk_widget_get_child_visible (GtkWidget *widget)
8533 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
8535 return widget->priv->child_visible;
8539 gtk_widget_get_screen_unchecked (GtkWidget *widget)
8541 GtkWidget *toplevel;
8543 toplevel = gtk_widget_get_toplevel (widget);
8545 if (gtk_widget_is_toplevel (toplevel))
8547 if (GTK_IS_WINDOW (toplevel))
8548 return gtk_window_get_screen (GTK_WINDOW (toplevel));
8549 else if (GTK_IS_INVISIBLE (toplevel))
8550 return gtk_invisible_get_screen (GTK_INVISIBLE (widget));
8557 * gtk_widget_get_screen:
8558 * @widget: a #GtkWidget
8560 * Get the #GdkScreen from the toplevel window associated with
8561 * this widget. This function can only be called after the widget
8562 * has been added to a widget hierarchy with a #GtkWindow
8565 * In general, you should only create screen specific
8566 * resources when a widget has been realized, and you should
8567 * free those resources when the widget is unrealized.
8569 * Return value: (transfer none): the #GdkScreen for the toplevel for this widget.
8574 gtk_widget_get_screen (GtkWidget *widget)
8578 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8580 screen = gtk_widget_get_screen_unchecked (widget);
8587 g_warning (G_STRLOC ": Can't get associated screen"
8588 " for a widget unless it is inside a toplevel GtkWindow\n"
8589 " widget type is %s associated top level type is %s",
8590 g_type_name (G_OBJECT_TYPE(G_OBJECT (widget))),
8591 g_type_name (G_OBJECT_TYPE(G_OBJECT (toplevel))));
8593 return gdk_screen_get_default ();
8598 * gtk_widget_has_screen:
8599 * @widget: a #GtkWidget
8601 * Checks whether there is a #GdkScreen is associated with
8602 * this widget. All toplevel widgets have an associated
8603 * screen, and all widgets added into a hierarchy with a toplevel
8604 * window at the top.
8606 * Return value: %TRUE if there is a #GdkScreen associcated
8612 gtk_widget_has_screen (GtkWidget *widget)
8614 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
8616 return (gtk_widget_get_screen_unchecked (widget) != NULL);
8620 * gtk_widget_get_display:
8621 * @widget: a #GtkWidget
8623 * Get the #GdkDisplay for the toplevel window associated with
8624 * this widget. This function can only be called after the widget
8625 * has been added to a widget hierarchy with a #GtkWindow at the top.
8627 * In general, you should only create display specific
8628 * resources when a widget has been realized, and you should
8629 * free those resources when the widget is unrealized.
8631 * Return value: (transfer none): the #GdkDisplay for the toplevel for this widget.
8636 gtk_widget_get_display (GtkWidget *widget)
8638 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8640 return gdk_screen_get_display (gtk_widget_get_screen (widget));
8644 * gtk_widget_get_root_window:
8645 * @widget: a #GtkWidget
8647 * Get the root window where this widget is located. This function can
8648 * only be called after the widget has been added to a widget
8649 * hierarchy with #GtkWindow at the top.
8651 * The root window is useful for such purposes as creating a popup
8652 * #GdkWindow associated with the window. In general, you should only
8653 * create display specific resources when a widget has been realized,
8654 * and you should free those resources when the widget is unrealized.
8656 * Return value: (transfer none): the #GdkWindow root window for the toplevel for this widget.
8661 gtk_widget_get_root_window (GtkWidget *widget)
8663 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8665 return gdk_screen_get_root_window (gtk_widget_get_screen (widget));
8669 * gtk_widget_child_focus:
8670 * @widget: a #GtkWidget
8671 * @direction: direction of focus movement
8673 * This function is used by custom widget implementations; if you're
8674 * writing an app, you'd use gtk_widget_grab_focus() to move the focus
8675 * to a particular widget, and gtk_container_set_focus_chain() to
8676 * change the focus tab order. So you may want to investigate those
8677 * functions instead.
8679 * gtk_widget_child_focus() is called by containers as the user moves
8680 * around the window using keyboard shortcuts. @direction indicates
8681 * what kind of motion is taking place (up, down, left, right, tab
8682 * forward, tab backward). gtk_widget_child_focus() emits the
8683 * #GtkWidget::focus signal; widgets override the default handler
8684 * for this signal in order to implement appropriate focus behavior.
8686 * The default ::focus handler for a widget should return %TRUE if
8687 * moving in @direction left the focus on a focusable location inside
8688 * that widget, and %FALSE if moving in @direction moved the focus
8689 * outside the widget. If returning %TRUE, widgets normally
8690 * call gtk_widget_grab_focus() to place the focus accordingly;
8691 * if returning %FALSE, they don't modify the current focus location.
8693 * Return value: %TRUE if focus ended up inside @widget
8696 gtk_widget_child_focus (GtkWidget *widget,
8697 GtkDirectionType direction)
8699 gboolean return_val;
8701 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
8703 if (!gtk_widget_get_visible (widget) ||
8704 !gtk_widget_is_sensitive (widget))
8707 /* child widgets must set CAN_FOCUS, containers
8708 * don't have to though.
8710 if (!GTK_IS_CONTAINER (widget) &&
8711 !gtk_widget_get_can_focus (widget))
8714 g_signal_emit (widget,
8715 widget_signals[FOCUS],
8717 direction, &return_val);
8723 * gtk_widget_keynav_failed:
8724 * @widget: a #GtkWidget
8725 * @direction: direction of focus movement
8727 * This function should be called whenever keyboard navigation within
8728 * a single widget hits a boundary. The function emits the
8729 * #GtkWidget::keynav-failed signal on the widget and its return
8730 * value should be interpreted in a way similar to the return value of
8731 * gtk_widget_child_focus():
8733 * When %TRUE is returned, stay in the widget, the failed keyboard
8734 * navigation is Ok and/or there is nowhere we can/should move the
8737 * When %FALSE is returned, the caller should continue with keyboard
8738 * navigation outside the widget, e.g. by calling
8739 * gtk_widget_child_focus() on the widget's toplevel.
8741 * The default ::keynav-failed handler returns %TRUE for
8742 * %GTK_DIR_TAB_FORWARD and %GTK_DIR_TAB_BACKWARD. For the other
8743 * values of #GtkDirectionType, it looks at the
8744 * #GtkSettings:gtk-keynav-cursor-only setting and returns %FALSE
8745 * if the setting is %TRUE. This way the entire user interface
8746 * becomes cursor-navigatable on input devices such as mobile phones
8747 * which only have cursor keys but no tab key.
8749 * Whenever the default handler returns %TRUE, it also calls
8750 * gtk_widget_error_bell() to notify the user of the failed keyboard
8753 * A use case for providing an own implementation of ::keynav-failed
8754 * (either by connecting to it or by overriding it) would be a row of
8755 * #GtkEntry widgets where the user should be able to navigate the
8756 * entire row with the cursor keys, as e.g. known from user interfaces
8757 * that require entering license keys.
8759 * Return value: %TRUE if stopping keyboard navigation is fine, %FALSE
8760 * if the emitting widget should try to handle the keyboard
8761 * navigation attempt in its parent container(s).
8766 gtk_widget_keynav_failed (GtkWidget *widget,
8767 GtkDirectionType direction)
8769 gboolean return_val;
8771 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
8773 g_signal_emit (widget, widget_signals[KEYNAV_FAILED], 0,
8774 direction, &return_val);
8780 * gtk_widget_error_bell:
8781 * @widget: a #GtkWidget
8783 * Notifies the user about an input-related error on this widget.
8784 * If the #GtkSettings:gtk-error-bell setting is %TRUE, it calls
8785 * gdk_window_beep(), otherwise it does nothing.
8787 * Note that the effect of gdk_window_beep() can be configured in many
8788 * ways, depending on the windowing backend and the desktop environment
8789 * or window manager that is used.
8794 gtk_widget_error_bell (GtkWidget *widget)
8796 GtkWidgetPrivate *priv;
8797 GtkSettings* settings;
8800 g_return_if_fail (GTK_IS_WIDGET (widget));
8802 priv = widget->priv;
8804 settings = gtk_widget_get_settings (widget);
8808 g_object_get (settings,
8809 "gtk-error-bell", &beep,
8812 if (beep && priv->window)
8813 gdk_window_beep (priv->window);
8817 gtk_widget_set_usize_internal (GtkWidget *widget,
8820 GtkQueueResizeFlags flags)
8822 GtkWidgetAuxInfo *aux_info;
8823 gboolean changed = FALSE;
8825 g_object_freeze_notify (G_OBJECT (widget));
8827 aux_info = _gtk_widget_get_aux_info (widget, TRUE);
8829 if (width > -2 && aux_info->width != width)
8831 if ((flags & GTK_QUEUE_RESIZE_INVALIDATE_ONLY) == 0)
8832 g_object_notify (G_OBJECT (widget), "width-request");
8833 aux_info->width = width;
8836 if (height > -2 && aux_info->height != height)
8838 if ((flags & GTK_QUEUE_RESIZE_INVALIDATE_ONLY) == 0)
8839 g_object_notify (G_OBJECT (widget), "height-request");
8840 aux_info->height = height;
8844 if (gtk_widget_get_visible (widget) && changed)
8846 if ((flags & GTK_QUEUE_RESIZE_INVALIDATE_ONLY) == 0)
8847 gtk_widget_queue_resize (widget);
8849 _gtk_size_group_queue_resize (widget, GTK_QUEUE_RESIZE_INVALIDATE_ONLY);
8852 g_object_thaw_notify (G_OBJECT (widget));
8856 * gtk_widget_set_size_request:
8857 * @widget: a #GtkWidget
8858 * @width: width @widget should request, or -1 to unset
8859 * @height: height @widget should request, or -1 to unset
8861 * Sets the minimum size of a widget; that is, the widget's size
8862 * request will be @width by @height. You can use this function to
8863 * force a widget to be either larger or smaller than it normally
8866 * In most cases, gtk_window_set_default_size() is a better choice for
8867 * toplevel windows than this function; setting the default size will
8868 * still allow users to shrink the window. Setting the size request
8869 * will force them to leave the window at least as large as the size
8870 * request. When dealing with window sizes,
8871 * gtk_window_set_geometry_hints() can be a useful function as well.
8873 * Note the inherent danger of setting any fixed size - themes,
8874 * translations into other languages, different fonts, and user action
8875 * can all change the appropriate size for a given widget. So, it's
8876 * basically impossible to hardcode a size that will always be
8879 * The size request of a widget is the smallest size a widget can
8880 * accept while still functioning well and drawing itself correctly.
8881 * However in some strange cases a widget may be allocated less than
8882 * its requested size, and in many cases a widget may be allocated more
8883 * space than it requested.
8885 * If the size request in a given direction is -1 (unset), then
8886 * the "natural" size request of the widget will be used instead.
8888 * Widgets can't actually be allocated a size less than 1 by 1, but
8889 * you can pass 0,0 to this function to mean "as small as possible."
8891 * The size request set here does not include any margin from the
8892 * #GtkWidget properties margin-left, margin-right, margin-top, and
8893 * margin-bottom, but it does include pretty much all other padding
8894 * or border properties set by any subclass of #GtkWidget.
8897 gtk_widget_set_size_request (GtkWidget *widget,
8901 g_return_if_fail (GTK_IS_WIDGET (widget));
8902 g_return_if_fail (width >= -1);
8903 g_return_if_fail (height >= -1);
8910 gtk_widget_set_usize_internal (widget, width, height, 0);
8915 * gtk_widget_get_size_request:
8916 * @widget: a #GtkWidget
8917 * @width: (out) (allow-none): return location for width, or %NULL
8918 * @height: (out) (allow-none): return location for height, or %NULL
8920 * Gets the size request that was explicitly set for the widget using
8921 * gtk_widget_set_size_request(). A value of -1 stored in @width or
8922 * @height indicates that that dimension has not been set explicitly
8923 * and the natural requisition of the widget will be used intead. See
8924 * gtk_widget_set_size_request(). To get the size a widget will
8925 * actually request, call gtk_widget_get_preferred_size() instead of
8929 gtk_widget_get_size_request (GtkWidget *widget,
8933 const GtkWidgetAuxInfo *aux_info;
8935 g_return_if_fail (GTK_IS_WIDGET (widget));
8937 aux_info = _gtk_widget_get_aux_info_or_defaults (widget);
8940 *width = aux_info->width;
8943 *height = aux_info->height;
8947 * _gtk_widget_override_size_request:
8948 * @widget: a #GtkWidget
8949 * @width: new forced minimum width
8950 * @height: new forced minimum height
8951 * @old_width: location to store previous forced minimum width
8952 * @old_width: location to store previous forced minumum height
8954 * Temporarily establishes a forced minimum size for a widget; this
8955 * is used by GtkWindow when calculating the size to add to the
8956 * window's geometry widget. Cached sizes for the widget and its
8957 * parents are invalidated, so that subsequent calls to the size
8958 * negotiation machinery produce the overriden result, but the
8959 * widget is not queued for relayout or redraw. The old size must
8960 * be restored with _gtk_widget_restore_size_request() or things
8964 _gtk_widget_override_size_request (GtkWidget *widget,
8970 gtk_widget_get_size_request (widget, old_width, old_height);
8971 gtk_widget_set_usize_internal (widget, width, height,
8972 GTK_QUEUE_RESIZE_INVALIDATE_ONLY);
8976 * _gtk_widget_restore_size_request:
8977 * @widget: a #GtkWidget
8978 * @old_width: saved forced minimum size
8979 * @old_height: saved forced minimum size
8981 * Undoes the operation of_gtk_widget_override_size_request().
8984 _gtk_widget_restore_size_request (GtkWidget *widget,
8988 gtk_widget_set_usize_internal (widget, old_width, old_height,
8989 GTK_QUEUE_RESIZE_INVALIDATE_ONLY);
8993 * gtk_widget_set_events:
8994 * @widget: a #GtkWidget
8995 * @events: event mask
8997 * Sets the event mask (see #GdkEventMask) for a widget. The event
8998 * mask determines which events a widget will receive. Keep in mind
8999 * that different widgets have different default event masks, and by
9000 * changing the event mask you may disrupt a widget's functionality,
9001 * so be careful. This function must be called while a widget is
9002 * unrealized. Consider gtk_widget_add_events() for widgets that are
9003 * already realized, or if you want to preserve the existing event
9004 * mask. This function can't be used with #GTK_NO_WINDOW widgets;
9005 * to get events on those widgets, place them inside a #GtkEventBox
9006 * and receive events on the event box.
9009 gtk_widget_set_events (GtkWidget *widget,
9012 g_return_if_fail (GTK_IS_WIDGET (widget));
9013 g_return_if_fail (!gtk_widget_get_realized (widget));
9015 g_object_set_qdata (G_OBJECT (widget), quark_event_mask,
9016 GINT_TO_POINTER (events));
9017 g_object_notify (G_OBJECT (widget), "events");
9021 * gtk_widget_set_device_events:
9022 * @widget: a #GtkWidget
9023 * @device: a #GdkDevice
9024 * @events: event mask
9026 * Sets the device event mask (see #GdkEventMask) for a widget. The event
9027 * mask determines which events a widget will receive from @device. Keep
9028 * in mind that different widgets have different default event masks, and by
9029 * changing the event mask you may disrupt a widget's functionality,
9030 * so be careful. This function must be called while a widget is
9031 * unrealized. Consider gtk_widget_add_device_events() for widgets that are
9032 * already realized, or if you want to preserve the existing event
9033 * mask. This function can't be used with #GTK_NO_WINDOW widgets;
9034 * to get events on those widgets, place them inside a #GtkEventBox
9035 * and receive events on the event box.
9040 gtk_widget_set_device_events (GtkWidget *widget,
9042 GdkEventMask events)
9044 GHashTable *device_events;
9046 g_return_if_fail (GTK_IS_WIDGET (widget));
9047 g_return_if_fail (GDK_IS_DEVICE (device));
9048 g_return_if_fail (!gtk_widget_get_realized (widget));
9050 device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
9052 if (G_UNLIKELY (!device_events))
9054 device_events = g_hash_table_new (NULL, NULL);
9055 g_object_set_qdata_full (G_OBJECT (widget), quark_device_event_mask, device_events,
9056 (GDestroyNotify) g_hash_table_unref);
9059 g_hash_table_insert (device_events, device, GUINT_TO_POINTER (events));
9063 gtk_widget_add_events_internal_list (GtkWidget *widget,
9070 for (l = window_list; l != NULL; l = l->next)
9072 GdkWindow *window = l->data;
9075 gdk_window_get_user_data (window, &user_data);
9076 if (user_data == widget)
9081 gdk_window_set_device_events (window, device, gdk_window_get_events (window) | events);
9083 gdk_window_set_events (window, gdk_window_get_events (window) | events);
9085 children = gdk_window_get_children (window);
9086 gtk_widget_add_events_internal_list (widget, device, events, children);
9087 g_list_free (children);
9093 gtk_widget_add_events_internal (GtkWidget *widget,
9097 GtkWidgetPrivate *priv = widget->priv;
9100 if (!gtk_widget_get_has_window (widget))
9101 window_list = gdk_window_get_children (priv->window);
9103 window_list = g_list_prepend (NULL, priv->window);
9105 gtk_widget_add_events_internal_list (widget, device, events, window_list);
9107 g_list_free (window_list);
9111 * gtk_widget_add_events:
9112 * @widget: a #GtkWidget
9113 * @events: an event mask, see #GdkEventMask
9115 * Adds the events in the bitfield @events to the event mask for
9116 * @widget. See gtk_widget_set_events() for details.
9119 gtk_widget_add_events (GtkWidget *widget,
9124 g_return_if_fail (GTK_IS_WIDGET (widget));
9126 old_events = GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), quark_event_mask));
9127 g_object_set_qdata (G_OBJECT (widget), quark_event_mask,
9128 GINT_TO_POINTER (old_events | events));
9130 if (gtk_widget_get_realized (widget))
9131 gtk_widget_add_events_internal (widget, NULL, events);
9133 g_object_notify (G_OBJECT (widget), "events");
9137 * gtk_widget_add_device_events:
9138 * @widget: a #GtkWidget
9139 * @device: a #GdkDevice
9140 * @events: an event mask, see #GdkEventMask
9142 * Adds the device events in the bitfield @events to the event mask for
9143 * @widget. See gtk_widget_set_device_events() for details.
9148 gtk_widget_add_device_events (GtkWidget *widget,
9150 GdkEventMask events)
9152 GdkEventMask old_events;
9153 GHashTable *device_events;
9155 g_return_if_fail (GTK_IS_WIDGET (widget));
9156 g_return_if_fail (GDK_IS_DEVICE (device));
9158 old_events = gtk_widget_get_device_events (widget, device);
9160 device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
9162 if (G_UNLIKELY (!device_events))
9164 device_events = g_hash_table_new (NULL, NULL);
9165 g_object_set_qdata_full (G_OBJECT (widget), quark_device_event_mask, device_events,
9166 (GDestroyNotify) g_hash_table_unref);
9169 g_hash_table_insert (device_events, device,
9170 GUINT_TO_POINTER (old_events | events));
9172 if (gtk_widget_get_realized (widget))
9173 gtk_widget_add_events_internal (widget, device, events);
9175 g_object_notify (G_OBJECT (widget), "events");
9179 * gtk_widget_set_extension_events:
9180 * @widget: a #GtkWidget
9181 * @mode: bitfield of extension events to receive
9183 * Sets the extension events mask to @mode. See #GdkExtensionMode
9184 * and gdk_input_set_extension_events().
9187 gtk_widget_set_extension_events (GtkWidget *widget,
9188 GdkExtensionMode mode)
9190 g_return_if_fail (GTK_IS_WIDGET (widget));
9192 if (gtk_widget_get_realized (widget))
9193 gtk_widget_set_extension_events_internal (widget, mode, NULL);
9195 g_object_set_qdata (G_OBJECT (widget), quark_extension_event_mode,
9196 GINT_TO_POINTER (mode));
9197 g_object_notify (G_OBJECT (widget), "extension-events");
9201 * gtk_widget_get_toplevel:
9202 * @widget: a #GtkWidget
9204 * This function returns the topmost widget in the container hierarchy
9205 * @widget is a part of. If @widget has no parent widgets, it will be
9206 * returned as the topmost widget. No reference will be added to the
9207 * returned widget; it should not be unreferenced.
9209 * Note the difference in behavior vs. gtk_widget_get_ancestor();
9210 * <literal>gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW)</literal>
9212 * %NULL if @widget wasn't inside a toplevel window, and if the
9213 * window was inside a #GtkWindow-derived widget which was in turn
9214 * inside the toplevel #GtkWindow. While the second case may
9215 * seem unlikely, it actually happens when a #GtkPlug is embedded
9216 * inside a #GtkSocket within the same application.
9218 * To reliably find the toplevel #GtkWindow, use
9219 * gtk_widget_get_toplevel() and check if the %TOPLEVEL flags
9220 * is set on the result.
9222 * GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
9223 * if (gtk_widget_is_toplevel (toplevel))
9225 * /* Perform action on toplevel. */
9229 * Return value: (transfer none): the topmost ancestor of @widget, or @widget itself
9230 * if there's no ancestor.
9233 gtk_widget_get_toplevel (GtkWidget *widget)
9235 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
9237 while (widget->priv->parent)
9238 widget = widget->priv->parent;
9244 * gtk_widget_get_ancestor:
9245 * @widget: a #GtkWidget
9246 * @widget_type: ancestor type
9248 * Gets the first ancestor of @widget with type @widget_type. For example,
9249 * <literal>gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)</literal> gets
9250 * the first #GtkBox that's an ancestor of @widget. No reference will be
9251 * added to the returned widget; it should not be unreferenced. See note
9252 * about checking for a toplevel #GtkWindow in the docs for
9253 * gtk_widget_get_toplevel().
9255 * Note that unlike gtk_widget_is_ancestor(), gtk_widget_get_ancestor()
9256 * considers @widget to be an ancestor of itself.
9258 * Return value: (transfer none): the ancestor widget, or %NULL if not found
9261 gtk_widget_get_ancestor (GtkWidget *widget,
9264 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
9266 while (widget && !g_type_is_a (G_OBJECT_TYPE (widget), widget_type))
9267 widget = widget->priv->parent;
9269 if (!(widget && g_type_is_a (G_OBJECT_TYPE (widget), widget_type)))
9276 * gtk_widget_set_visual:
9277 * @widget: a #GtkWidget
9278 * @visual: visual to be used or %NULL to unset a previous one
9280 * Sets the visual that should be used for by widget and its children for
9281 * creating #GdkWindows. The visual must be on the same #GdkScreen as
9282 * returned by gdk_widget_get_screen(), so handling the
9283 * GtkWidget::screen-changed signal is necessary.
9285 * Setting a new @visual will not cause @widget to recreate its windows,
9286 * so you should call this function before @widget is realized.
9289 gtk_widget_set_visual (GtkWidget *widget,
9292 g_return_if_fail (GTK_IS_WIDGET (widget));
9293 g_return_if_fail (visual == NULL || GDK_IS_VISUAL (visual));
9296 g_return_if_fail (gtk_widget_get_screen (widget) == gdk_visual_get_screen (visual));
9299 g_object_set_qdata_full (G_OBJECT (widget),
9301 g_object_ref (visual),
9306 * gtk_widget_get_visual:
9307 * @widget: a #GtkWidget
9309 * Gets the visual that will be used to render @widget.
9311 * Return value: (transfer none): the visual for @widget
9314 gtk_widget_get_visual (GtkWidget *widget)
9320 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
9322 if (gtk_widget_get_has_window (widget) &&
9323 widget->priv->window)
9324 return gdk_window_get_visual (widget->priv->window);
9326 screen = gtk_widget_get_screen (widget);
9328 for (w = widget; w != NULL; w = w->priv->parent)
9330 visual = g_object_get_qdata (G_OBJECT (w), quark_visual);
9333 if (gdk_visual_get_screen (visual) == screen)
9336 g_warning ("Ignoring visual set on widget `%s' that is not on the correct screen.",
9337 gtk_widget_get_name (widget));
9341 return gdk_screen_get_system_visual (screen);
9345 * gtk_widget_get_settings:
9346 * @widget: a #GtkWidget
9348 * Gets the settings object holding the settings (global property
9349 * settings, RC file information, etc) used for this widget.
9351 * Note that this function can only be called when the #GtkWidget
9352 * is attached to a toplevel, since the settings object is specific
9353 * to a particular #GdkScreen.
9355 * Return value: (transfer none): the relevant #GtkSettings object
9358 gtk_widget_get_settings (GtkWidget *widget)
9360 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
9362 return gtk_settings_get_for_screen (gtk_widget_get_screen (widget));
9366 * gtk_widget_get_events:
9367 * @widget: a #GtkWidget
9369 * Returns the event mask for the widget (a bitfield containing flags
9370 * from the #GdkEventMask enumeration). These are the events that the widget
9373 * Return value: event mask for @widget
9376 gtk_widget_get_events (GtkWidget *widget)
9378 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
9380 return GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), quark_event_mask));
9384 * gtk_widget_get_device_events:
9385 * @widget: a #GtkWidget
9386 * @device: a #GdkDevice
9388 * Returns the events mask for the widget corresponding to an specific device. These
9389 * are the events that the widget will receive when @device operates on it.
9391 * Returns: device event mask for @widget
9396 gtk_widget_get_device_events (GtkWidget *widget,
9399 GHashTable *device_events;
9401 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
9402 g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
9404 device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
9409 return GPOINTER_TO_UINT (g_hash_table_lookup (device_events, device));
9413 * gtk_widget_get_extension_events:
9414 * @widget: a #GtkWidget
9416 * Retrieves the extension events the widget will receive; see
9417 * gdk_input_set_extension_events().
9419 * Return value: extension events for @widget
9422 gtk_widget_get_extension_events (GtkWidget *widget)
9424 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
9426 return GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), quark_extension_event_mode));
9430 * gtk_widget_get_pointer:
9431 * @widget: a #GtkWidget
9432 * @x: (out) (allow-none): return location for the X coordinate, or %NULL
9433 * @y: (out) (allow-none): return location for the Y coordinate, or %NULL
9435 * Obtains the location of the mouse pointer in widget coordinates.
9436 * Widget coordinates are a bit odd; for historical reasons, they are
9437 * defined as @widget->window coordinates for widgets that are not
9438 * #GTK_NO_WINDOW widgets, and are relative to @widget->allocation.x,
9439 * @widget->allocation.y for widgets that are #GTK_NO_WINDOW widgets.
9442 gtk_widget_get_pointer (GtkWidget *widget,
9446 GtkWidgetPrivate *priv;
9448 g_return_if_fail (GTK_IS_WIDGET (widget));
9450 priv = widget->priv;
9457 if (gtk_widget_get_realized (widget))
9459 gdk_window_get_pointer (priv->window, x, y, NULL);
9461 if (!gtk_widget_get_has_window (widget))
9464 *x -= priv->allocation.x;
9466 *y -= priv->allocation.y;
9472 * gtk_widget_is_ancestor:
9473 * @widget: a #GtkWidget
9474 * @ancestor: another #GtkWidget
9476 * Determines whether @widget is somewhere inside @ancestor, possibly with
9477 * intermediate containers.
9479 * Return value: %TRUE if @ancestor contains @widget as a child,
9480 * grandchild, great grandchild, etc.
9483 gtk_widget_is_ancestor (GtkWidget *widget,
9484 GtkWidget *ancestor)
9486 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
9487 g_return_val_if_fail (ancestor != NULL, FALSE);
9491 if (widget->priv->parent == ancestor)
9493 widget = widget->priv->parent;
9499 static GQuark quark_composite_name = 0;
9502 * gtk_widget_set_composite_name:
9503 * @widget: a #GtkWidget.
9504 * @name: the name to set
9506 * Sets a widgets composite name. The widget must be
9507 * a composite child of its parent; see gtk_widget_push_composite_child().
9510 gtk_widget_set_composite_name (GtkWidget *widget,
9513 g_return_if_fail (GTK_IS_WIDGET (widget));
9514 g_return_if_fail (widget->priv->composite_child);
9515 g_return_if_fail (name != NULL);
9517 if (!quark_composite_name)
9518 quark_composite_name = g_quark_from_static_string ("gtk-composite-name");
9520 g_object_set_qdata_full (G_OBJECT (widget),
9521 quark_composite_name,
9527 * gtk_widget_get_composite_name:
9528 * @widget: a #GtkWidget
9530 * Obtains the composite name of a widget.
9532 * Returns: the composite name of @widget, or %NULL if @widget is not
9533 * a composite child. The string should be freed when it is no
9537 gtk_widget_get_composite_name (GtkWidget *widget)
9539 GtkWidgetPrivate *priv;
9541 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
9543 priv = widget->priv;
9545 if (widget->priv->composite_child && priv->parent)
9546 return _gtk_container_child_composite_name (GTK_CONTAINER (priv->parent),
9553 * gtk_widget_push_composite_child:
9555 * Makes all newly-created widgets as composite children until
9556 * the corresponding gtk_widget_pop_composite_child() call.
9558 * A composite child is a child that's an implementation detail of the
9559 * container it's inside and should not be visible to people using the
9560 * container. Composite children aren't treated differently by GTK (but
9561 * see gtk_container_foreach() vs. gtk_container_forall()), but e.g. GUI
9562 * builders might want to treat them in a different way.
9564 * Here is a simple example:
9566 * gtk_widget_push_composite_child ();
9567 * scrolled_window->hscrollbar = gtk_hscrollbar_new (hadjustment);
9568 * gtk_widget_set_composite_name (scrolled_window->hscrollbar, "hscrollbar");
9569 * gtk_widget_pop_composite_child ();
9570 * gtk_widget_set_parent (scrolled_window->hscrollbar,
9571 * GTK_WIDGET (scrolled_window));
9572 * g_object_ref (scrolled_window->hscrollbar);
9576 gtk_widget_push_composite_child (void)
9578 composite_child_stack++;
9582 * gtk_widget_pop_composite_child:
9584 * Cancels the effect of a previous call to gtk_widget_push_composite_child().
9587 gtk_widget_pop_composite_child (void)
9589 if (composite_child_stack)
9590 composite_child_stack--;
9594 gtk_widget_emit_direction_changed (GtkWidget *widget,
9595 GtkTextDirection old_dir)
9597 gtk_widget_update_pango_context (widget);
9599 g_signal_emit (widget, widget_signals[DIRECTION_CHANGED], 0, old_dir);
9603 * gtk_widget_set_direction:
9604 * @widget: a #GtkWidget
9605 * @dir: the new direction
9607 * Sets the reading direction on a particular widget. This direction
9608 * controls the primary direction for widgets containing text,
9609 * and also the direction in which the children of a container are
9610 * packed. The ability to set the direction is present in order
9611 * so that correct localization into languages with right-to-left
9612 * reading directions can be done. Generally, applications will
9613 * let the default reading direction present, except for containers
9614 * where the containers are arranged in an order that is explicitely
9615 * visual rather than logical (such as buttons for text justification).
9617 * If the direction is set to %GTK_TEXT_DIR_NONE, then the value
9618 * set by gtk_widget_set_default_direction() will be used.
9621 gtk_widget_set_direction (GtkWidget *widget,
9622 GtkTextDirection dir)
9624 GtkTextDirection old_dir;
9626 g_return_if_fail (GTK_IS_WIDGET (widget));
9627 g_return_if_fail (dir >= GTK_TEXT_DIR_NONE && dir <= GTK_TEXT_DIR_RTL);
9629 old_dir = gtk_widget_get_direction (widget);
9631 widget->priv->direction = dir;
9633 if (old_dir != gtk_widget_get_direction (widget))
9634 gtk_widget_emit_direction_changed (widget, old_dir);
9638 * gtk_widget_get_direction:
9639 * @widget: a #GtkWidget
9641 * Gets the reading direction for a particular widget. See
9642 * gtk_widget_set_direction().
9644 * Return value: the reading direction for the widget.
9647 gtk_widget_get_direction (GtkWidget *widget)
9649 g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_TEXT_DIR_LTR);
9651 if (widget->priv->direction == GTK_TEXT_DIR_NONE)
9652 return gtk_default_direction;
9654 return widget->priv->direction;
9658 gtk_widget_set_default_direction_recurse (GtkWidget *widget, gpointer data)
9660 GtkTextDirection old_dir = GPOINTER_TO_UINT (data);
9662 g_object_ref (widget);
9664 if (widget->priv->direction == GTK_TEXT_DIR_NONE)
9665 gtk_widget_emit_direction_changed (widget, old_dir);
9667 if (GTK_IS_CONTAINER (widget))
9668 gtk_container_forall (GTK_CONTAINER (widget),
9669 gtk_widget_set_default_direction_recurse,
9672 g_object_unref (widget);
9676 * gtk_widget_set_default_direction:
9677 * @dir: the new default direction. This cannot be
9678 * %GTK_TEXT_DIR_NONE.
9680 * Sets the default reading direction for widgets where the
9681 * direction has not been explicitly set by gtk_widget_set_direction().
9684 gtk_widget_set_default_direction (GtkTextDirection dir)
9686 g_return_if_fail (dir == GTK_TEXT_DIR_RTL || dir == GTK_TEXT_DIR_LTR);
9688 if (dir != gtk_default_direction)
9690 GList *toplevels, *tmp_list;
9691 GtkTextDirection old_dir = gtk_default_direction;
9693 gtk_default_direction = dir;
9695 tmp_list = toplevels = gtk_window_list_toplevels ();
9696 g_list_foreach (toplevels, (GFunc)g_object_ref, NULL);
9700 gtk_widget_set_default_direction_recurse (tmp_list->data,
9701 GUINT_TO_POINTER (old_dir));
9702 g_object_unref (tmp_list->data);
9703 tmp_list = tmp_list->next;
9706 g_list_free (toplevels);
9711 * gtk_widget_get_default_direction:
9713 * Obtains the current default reading direction. See
9714 * gtk_widget_set_default_direction().
9716 * Return value: the current default direction.
9719 gtk_widget_get_default_direction (void)
9721 return gtk_default_direction;
9725 gtk_widget_dispose (GObject *object)
9727 GtkWidget *widget = GTK_WIDGET (object);
9728 GtkWidgetPrivate *priv = widget->priv;
9731 gtk_container_remove (GTK_CONTAINER (priv->parent), widget);
9732 else if (gtk_widget_get_visible (widget))
9733 gtk_widget_hide (widget);
9735 priv->visible = FALSE;
9736 if (gtk_widget_get_realized (widget))
9737 gtk_widget_unrealize (widget);
9739 if (!priv->in_destruction)
9741 priv->in_destruction = TRUE;
9742 g_signal_emit (object, widget_signals[DESTROY], 0);
9743 priv->in_destruction = FALSE;
9746 G_OBJECT_CLASS (gtk_widget_parent_class)->dispose (object);
9750 gtk_widget_real_destroy (GtkWidget *object)
9752 /* gtk_object_destroy() will already hold a refcount on object */
9753 GtkWidget *widget = GTK_WIDGET (object);
9754 GtkWidgetPrivate *priv = widget->priv;
9756 /* wipe accelerator closures (keep order) */
9757 g_object_set_qdata (G_OBJECT (widget), quark_accel_path, NULL);
9758 g_object_set_qdata (G_OBJECT (widget), quark_accel_closures, NULL);
9760 /* Callers of add_mnemonic_label() should disconnect on ::destroy */
9761 g_object_set_qdata (G_OBJECT (widget), quark_mnemonic_labels, NULL);
9763 gtk_grab_remove (widget);
9765 g_object_unref (priv->style);
9766 priv->style = gtk_widget_get_default_style ();
9767 g_object_ref (priv->style);
9771 gtk_widget_finalize (GObject *object)
9773 GtkWidget *widget = GTK_WIDGET (object);
9774 GtkWidgetPrivate *priv = widget->priv;
9775 GtkWidgetAuxInfo *aux_info;
9776 GtkAccessible *accessible;
9778 gtk_grab_remove (widget);
9780 g_object_unref (priv->style);
9783 g_free (priv->name);
9785 aux_info =_gtk_widget_get_aux_info (widget, FALSE);
9787 gtk_widget_aux_info_destroy (aux_info);
9789 accessible = g_object_get_qdata (G_OBJECT (widget), quark_accessible_object);
9791 g_object_unref (accessible);
9793 if (g_object_is_floating (object))
9794 g_warning ("A floating object was finalized. This means that someone\n"
9795 "called g_object_unref() on an object that had only a floating\n"
9796 "reference; the initial floating reference is not owned by anyone\n"
9797 "and must be removed with g_object_ref_sink().");
9799 G_OBJECT_CLASS (gtk_widget_parent_class)->finalize (object);
9802 /*****************************************
9803 * gtk_widget_real_map:
9808 *****************************************/
9811 gtk_widget_real_map (GtkWidget *widget)
9813 GtkWidgetPrivate *priv = widget->priv;
9815 g_assert (gtk_widget_get_realized (widget));
9817 if (!gtk_widget_get_mapped (widget))
9819 gtk_widget_set_mapped (widget, TRUE);
9821 if (gtk_widget_get_has_window (widget))
9822 gdk_window_show (priv->window);
9826 /*****************************************
9827 * gtk_widget_real_unmap:
9832 *****************************************/
9835 gtk_widget_real_unmap (GtkWidget *widget)
9837 GtkWidgetPrivate *priv = widget->priv;
9839 if (gtk_widget_get_mapped (widget))
9841 gtk_widget_set_mapped (widget, FALSE);
9843 if (gtk_widget_get_has_window (widget))
9844 gdk_window_hide (priv->window);
9848 /*****************************************
9849 * gtk_widget_real_realize:
9854 *****************************************/
9857 gtk_widget_real_realize (GtkWidget *widget)
9859 GtkWidgetPrivate *priv = widget->priv;
9861 g_assert (!gtk_widget_get_has_window (widget));
9863 gtk_widget_set_realized (widget, TRUE);
9866 priv->window = gtk_widget_get_parent_window (widget);
9867 g_object_ref (priv->window);
9869 priv->style = gtk_style_attach (priv->style, priv->window);
9872 /*****************************************
9873 * gtk_widget_real_unrealize:
9878 *****************************************/
9881 gtk_widget_real_unrealize (GtkWidget *widget)
9883 GtkWidgetPrivate *priv = widget->priv;
9885 if (gtk_widget_get_mapped (widget))
9886 gtk_widget_real_unmap (widget);
9888 gtk_widget_set_mapped (widget, FALSE);
9890 /* printf ("unrealizing %s\n", g_type_name (G_TYPE_FROM_INSTANCE (widget)));
9893 /* We must do unrealize child widget BEFORE container widget.
9894 * gdk_window_destroy() destroys specified xwindow and its sub-xwindows.
9895 * So, unrealizing container widget bofore its children causes the problem
9896 * (for example, gdk_ic_destroy () with destroyed window causes crash. )
9899 if (GTK_IS_CONTAINER (widget))
9900 gtk_container_forall (GTK_CONTAINER (widget),
9901 (GtkCallback) gtk_widget_unrealize,
9904 gtk_style_detach (priv->style);
9905 if (gtk_widget_get_has_window (widget))
9907 gdk_window_set_user_data (priv->window, NULL);
9908 gdk_window_destroy (priv->window);
9909 priv->window = NULL;
9913 g_object_unref (priv->window);
9914 priv->window = NULL;
9917 gtk_selection_remove_all (widget);
9919 gtk_widget_set_realized (widget, FALSE);
9923 gtk_widget_real_size_request (GtkWidget *widget,
9924 GtkRequisition *requisition)
9926 requisition->width = 0;
9927 requisition->height = 0;
9931 gtk_widget_real_adjust_size_request (GtkWidget *widget,
9932 GtkOrientation orientation,
9936 const GtkWidgetAuxInfo *aux_info;
9938 aux_info =_gtk_widget_get_aux_info_or_defaults (widget);
9940 if (orientation == GTK_ORIENTATION_HORIZONTAL &&
9941 aux_info->width > 0)
9943 *minimum_size = MAX (*minimum_size, aux_info->width);
9945 else if (orientation == GTK_ORIENTATION_VERTICAL &&
9946 aux_info->height > 0)
9948 *minimum_size = MAX (*minimum_size, aux_info->height);
9951 /* Fix it if set_size_request made natural size smaller than min size.
9952 * This would also silently fix broken widgets, but we warn about them
9953 * in gtksizerequest.c when calling their size request vfuncs.
9955 *natural_size = MAX (*natural_size, *minimum_size);
9957 if (orientation == GTK_ORIENTATION_HORIZONTAL)
9959 *minimum_size += (aux_info->margin.left + aux_info->margin.right);
9960 *natural_size += (aux_info->margin.left + aux_info->margin.right);
9964 *minimum_size += (aux_info->margin.top + aux_info->margin.bottom);
9965 *natural_size += (aux_info->margin.top + aux_info->margin.bottom);
9970 * _gtk_widget_peek_request_cache:
9972 * Returns the address of the widget's request cache (strictly for
9973 * internal use in gtksizerequest.c)
9975 * Return value: the address of @widget's size request cache.
9978 _gtk_widget_peek_request_cache (GtkWidget *widget)
9980 /* Don't bother slowing things down with the return_if_fail guards here */
9981 return &widget->priv->requests;
9985 * _gtk_widget_set_device_window:
9986 * @widget: a #GtkWidget.
9987 * @device: a #GdkDevice.
9988 * @window: the new device window.
9990 * Sets pointer window for @widget and @device. Does not ref @window.
9991 * Actually stores it on the #GdkScreen, but you don't need to know that.
9994 _gtk_widget_set_device_window (GtkWidget *widget,
9998 GtkWidgetPrivate *priv;
10000 GHashTable *device_window;
10002 g_return_if_fail (GTK_IS_WIDGET (widget));
10003 g_return_if_fail (GDK_IS_DEVICE (device));
10004 g_return_if_fail (!window || GDK_IS_WINDOW (window));
10006 priv = widget->priv;
10008 if (!gtk_widget_get_realized (widget))
10011 screen = gdk_window_get_screen (priv->window);
10012 device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
10014 if (G_UNLIKELY (!device_window))
10016 device_window = g_hash_table_new (NULL, NULL);
10017 g_object_set_qdata_full (G_OBJECT (screen),
10018 quark_pointer_window,
10020 (GDestroyNotify) g_hash_table_destroy);
10024 g_hash_table_insert (device_window, device, window);
10026 g_hash_table_remove (device_window, device);
10030 * _gtk_widget_get_device_window:
10031 * @widget: a #GtkWidget.
10032 * @device: a #GdkDevice.
10034 * Return value: the device window set on the #GdkScreen @widget is attached
10038 _gtk_widget_get_device_window (GtkWidget *widget,
10041 GtkWidgetPrivate *priv;
10043 GHashTable *device_window;
10047 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
10048 g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
10050 priv = widget->priv;
10052 if (!gtk_widget_get_realized (widget))
10055 screen = gdk_window_get_screen (priv->window);
10056 device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
10058 if (G_UNLIKELY (!device_window))
10061 window = g_hash_table_lookup (device_window, device);
10066 gdk_window_get_user_data (window, (gpointer *) &w);
10075 * _gtk_widget_list_devices:
10076 * @widget: a #GtkWidget.
10078 * Returns the list of #GdkDevices that is currently on top of any widget #GdkWindow.
10079 * Free the list with g_list_free(), the elements are owned by GTK+ and must not
10083 _gtk_widget_list_devices (GtkWidget *widget)
10085 GtkWidgetPrivate *priv;
10087 GHashTableIter iter;
10088 GHashTable *device_window;
10089 GList *devices = NULL;
10090 gpointer key, value;
10092 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
10094 priv = widget->priv;
10096 if (!gtk_widget_get_realized (widget))
10099 screen = gdk_window_get_screen (priv->window);
10100 device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
10102 if (G_UNLIKELY (!device_window))
10105 g_hash_table_iter_init (&iter, device_window);
10107 while (g_hash_table_iter_next (&iter, &key, &value))
10109 GdkDevice *device = key;
10110 GdkWindow *window = value;
10115 gdk_window_get_user_data (window, (gpointer *) &w);
10118 devices = g_list_prepend (devices, device);
10126 synth_crossing (GtkWidget *widget,
10130 GdkCrossingMode mode,
10131 GdkNotifyType detail)
10135 event = gdk_event_new (type);
10137 event->crossing.window = g_object_ref (window);
10138 event->crossing.send_event = TRUE;
10139 event->crossing.subwindow = g_object_ref (window);
10140 event->crossing.time = GDK_CURRENT_TIME;
10141 event->crossing.x = event->crossing.y = 0;
10142 event->crossing.x_root = event->crossing.y_root = 0;
10143 event->crossing.mode = mode;
10144 event->crossing.detail = detail;
10145 event->crossing.focus = FALSE;
10146 event->crossing.state = 0;
10147 gdk_event_set_device (event, device);
10150 widget = gtk_get_event_widget (event);
10153 gtk_widget_event_internal (widget, event);
10155 gdk_event_free (event);
10159 * _gtk_widget_synthesize_crossing:
10160 * @from: the #GtkWidget the virtual pointer is leaving.
10161 * @to: the #GtkWidget the virtual pointer is moving to.
10162 * @mode: the #GdkCrossingMode to place on the synthesized events.
10164 * Generate crossing event(s) on widget state (sensitivity) or GTK+ grab change.
10166 * The real pointer window is the window that most recently received an enter notify
10167 * event. Windows that don't select for crossing events can't become the real
10168 * poiner window. The real pointer widget that owns the real pointer window. The
10169 * effective pointer window is the same as the real pointer window unless the real
10170 * pointer widget is either insensitive or there is a grab on a widget that is not
10171 * an ancestor of the real pointer widget (in which case the effective pointer
10172 * window should be the root window).
10174 * When the effective pointer window is the same as the real poiner window, we
10175 * receive crossing events from the windowing system. When the effective pointer
10176 * window changes to become different from the real pointer window we synthesize
10177 * crossing events, attempting to follow X protocol rules:
10179 * When the root window becomes the effective pointer window:
10180 * - leave notify on real pointer window, detail Ancestor
10181 * - leave notify on all of its ancestors, detail Virtual
10182 * - enter notify on root window, detail Inferior
10184 * When the root window ceases to be the effective pointer window:
10185 * - leave notify on root window, detail Inferior
10186 * - enter notify on all ancestors of real pointer window, detail Virtual
10187 * - enter notify on real pointer window, detail Ancestor
10190 _gtk_widget_synthesize_crossing (GtkWidget *from,
10193 GdkCrossingMode mode)
10195 GdkWindow *from_window = NULL, *to_window = NULL;
10197 g_return_if_fail (from != NULL || to != NULL);
10201 from_window = _gtk_widget_get_device_window (from, device);
10204 from_window = from->priv->window;
10209 to_window = _gtk_widget_get_device_window (to, device);
10212 to_window = to->priv->window;
10215 if (from_window == NULL && to_window == NULL)
10217 else if (from_window != NULL && to_window == NULL)
10219 GList *from_ancestors = NULL, *list;
10220 GdkWindow *from_ancestor = from_window;
10222 while (from_ancestor != NULL)
10224 from_ancestor = gdk_window_get_effective_parent (from_ancestor);
10225 if (from_ancestor == NULL)
10227 from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
10230 synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
10231 device, mode, GDK_NOTIFY_ANCESTOR);
10232 for (list = g_list_last (from_ancestors); list; list = list->prev)
10234 synth_crossing (NULL, GDK_LEAVE_NOTIFY, (GdkWindow *) list->data,
10235 device, mode, GDK_NOTIFY_VIRTUAL);
10238 /* XXX: enter/inferior on root window? */
10240 g_list_free (from_ancestors);
10242 else if (from_window == NULL && to_window != NULL)
10244 GList *to_ancestors = NULL, *list;
10245 GdkWindow *to_ancestor = to_window;
10247 while (to_ancestor != NULL)
10249 to_ancestor = gdk_window_get_effective_parent (to_ancestor);
10250 if (to_ancestor == NULL)
10252 to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
10255 /* XXX: leave/inferior on root window? */
10257 for (list = to_ancestors; list; list = list->next)
10259 synth_crossing (NULL, GDK_ENTER_NOTIFY, (GdkWindow *) list->data,
10260 device, mode, GDK_NOTIFY_VIRTUAL);
10262 synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
10263 device, mode, GDK_NOTIFY_ANCESTOR);
10265 g_list_free (to_ancestors);
10267 else if (from_window == to_window)
10271 GList *from_ancestors = NULL, *to_ancestors = NULL, *list;
10272 GdkWindow *from_ancestor = from_window, *to_ancestor = to_window;
10274 while (from_ancestor != NULL || to_ancestor != NULL)
10276 if (from_ancestor != NULL)
10278 from_ancestor = gdk_window_get_effective_parent (from_ancestor);
10279 if (from_ancestor == to_window)
10282 from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
10284 if (to_ancestor != NULL)
10286 to_ancestor = gdk_window_get_effective_parent (to_ancestor);
10287 if (to_ancestor == from_window)
10290 to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
10293 if (to_ancestor == from_window)
10295 if (mode != GDK_CROSSING_GTK_UNGRAB)
10296 synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
10297 device, mode, GDK_NOTIFY_INFERIOR);
10298 for (list = to_ancestors; list; list = list->next)
10299 synth_crossing (NULL, GDK_ENTER_NOTIFY, (GdkWindow *) list->data,
10300 device, mode, GDK_NOTIFY_VIRTUAL);
10301 synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
10302 device, mode, GDK_NOTIFY_ANCESTOR);
10304 else if (from_ancestor == to_window)
10306 synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
10307 device, mode, GDK_NOTIFY_ANCESTOR);
10308 for (list = g_list_last (from_ancestors); list; list = list->prev)
10310 synth_crossing (NULL, GDK_LEAVE_NOTIFY, (GdkWindow *) list->data,
10311 device, mode, GDK_NOTIFY_VIRTUAL);
10313 if (mode != GDK_CROSSING_GTK_GRAB)
10314 synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
10315 device, mode, GDK_NOTIFY_INFERIOR);
10319 while (from_ancestors != NULL && to_ancestors != NULL
10320 && from_ancestors->data == to_ancestors->data)
10322 from_ancestors = g_list_delete_link (from_ancestors,
10324 to_ancestors = g_list_delete_link (to_ancestors, to_ancestors);
10327 synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
10328 device, mode, GDK_NOTIFY_NONLINEAR);
10330 for (list = g_list_last (from_ancestors); list; list = list->prev)
10332 synth_crossing (NULL, GDK_LEAVE_NOTIFY, (GdkWindow *) list->data,
10333 device, mode, GDK_NOTIFY_NONLINEAR_VIRTUAL);
10335 for (list = to_ancestors; list; list = list->next)
10337 synth_crossing (NULL, GDK_ENTER_NOTIFY, (GdkWindow *) list->data,
10338 device, mode, GDK_NOTIFY_NONLINEAR_VIRTUAL);
10340 synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
10341 device, mode, GDK_NOTIFY_NONLINEAR);
10343 g_list_free (from_ancestors);
10344 g_list_free (to_ancestors);
10349 gtk_widget_propagate_state (GtkWidget *widget,
10350 GtkStateData *data)
10352 GtkWidgetPrivate *priv = widget->priv;
10353 guint8 old_state = gtk_widget_get_state (widget);
10354 guint8 old_saved_state = priv->saved_state;
10356 /* don't call this function with state==GTK_STATE_INSENSITIVE,
10357 * parent_sensitive==TRUE on a sensitive widget
10361 priv->parent_sensitive = data->parent_sensitive;
10363 if (gtk_widget_is_sensitive (widget))
10365 if (data->state_restoration)
10366 priv->state = priv->saved_state;
10368 priv->state = data->state;
10372 if (!data->state_restoration)
10374 if (data->state != GTK_STATE_INSENSITIVE)
10375 priv->saved_state = data->state;
10377 else if (gtk_widget_get_state (widget) != GTK_STATE_INSENSITIVE)
10378 priv->saved_state = gtk_widget_get_state (widget);
10379 priv->state = GTK_STATE_INSENSITIVE;
10382 if (gtk_widget_is_focus (widget) && !gtk_widget_is_sensitive (widget))
10386 window = gtk_widget_get_toplevel (widget);
10387 if (window && gtk_widget_is_toplevel (window))
10388 gtk_window_set_focus (GTK_WINDOW (window), NULL);
10391 if (old_state != gtk_widget_get_state (widget) ||
10392 old_saved_state != priv->saved_state)
10394 g_object_ref (widget);
10396 if (!gtk_widget_is_sensitive (widget) && gtk_widget_has_grab (widget))
10397 gtk_grab_remove (widget);
10399 g_signal_emit (widget, widget_signals[STATE_CHANGED], 0, old_state);
10401 if (!priv->shadowed)
10403 GList *event_windows = NULL;
10404 GList *devices, *d;
10406 devices = _gtk_widget_list_devices (widget);
10408 for (d = devices; d; d = d->next)
10414 window = _gtk_widget_get_device_window (widget, device);
10416 /* Do not propagate more than once to the
10417 * same window if non-multidevice aware.
10419 if (!gdk_window_get_support_multidevice (window) &&
10420 g_list_find (event_windows, window))
10423 if (!gtk_widget_is_sensitive (widget))
10424 _gtk_widget_synthesize_crossing (widget, NULL, d->data,
10425 GDK_CROSSING_STATE_CHANGED);
10426 else if (old_state == GTK_STATE_INSENSITIVE)
10427 _gtk_widget_synthesize_crossing (NULL, widget, d->data,
10428 GDK_CROSSING_STATE_CHANGED);
10430 event_windows = g_list_prepend (event_windows, window);
10433 g_list_free (event_windows);
10434 g_list_free (devices);
10437 if (GTK_IS_CONTAINER (widget))
10439 data->parent_sensitive = (gtk_widget_is_sensitive (widget) != FALSE);
10440 if (data->use_forall)
10441 gtk_container_forall (GTK_CONTAINER (widget),
10442 (GtkCallback) gtk_widget_propagate_state,
10445 gtk_container_foreach (GTK_CONTAINER (widget),
10446 (GtkCallback) gtk_widget_propagate_state,
10449 g_object_unref (widget);
10453 static const GtkWidgetAuxInfo default_aux_info = {
10461 * _gtk_widget_get_aux_info:
10462 * @widget: a #GtkWidget
10463 * @create: if %TRUE, create the structure if it doesn't exist
10465 * Get the #GtkWidgetAuxInfo structure for the widget.
10467 * Return value: the #GtkAuxInfo structure for the widget, or
10468 * %NULL if @create is %FALSE and one doesn't already exist.
10471 _gtk_widget_get_aux_info (GtkWidget *widget,
10474 GtkWidgetAuxInfo *aux_info;
10476 aux_info = g_object_get_qdata (G_OBJECT (widget), quark_aux_info);
10477 if (!aux_info && create)
10479 aux_info = g_slice_new0 (GtkWidgetAuxInfo);
10481 *aux_info = default_aux_info;
10483 g_object_set_qdata (G_OBJECT (widget), quark_aux_info, aux_info);
10489 static const GtkWidgetAuxInfo*
10490 _gtk_widget_get_aux_info_or_defaults (GtkWidget *widget)
10492 GtkWidgetAuxInfo *aux_info;
10494 aux_info = _gtk_widget_get_aux_info (widget, FALSE);
10495 if (aux_info == NULL)
10497 return &default_aux_info;
10505 /*****************************************
10506 * gtk_widget_aux_info_destroy:
10511 *****************************************/
10514 gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info)
10516 g_slice_free (GtkWidgetAuxInfo, aux_info);
10520 * gtk_widget_shape_combine_region:
10521 * @widget: a #GtkWidget
10522 * @region: (allow-none): shape to be added, or %NULL to remove an existing shape
10524 * Sets a shape for this widget's GDK window. This allows for
10525 * transparent windows etc., see gdk_window_shape_combine_region()
10526 * for more information.
10531 gtk_widget_shape_combine_region (GtkWidget *widget,
10532 cairo_region_t *region)
10534 GtkWidgetPrivate *priv;
10536 g_return_if_fail (GTK_IS_WIDGET (widget));
10537 /* set_shape doesn't work on widgets without gdk window */
10538 g_return_if_fail (gtk_widget_get_has_window (widget));
10540 priv = widget->priv;
10542 if (region == NULL)
10544 priv->has_shape_mask = FALSE;
10547 gdk_window_shape_combine_region (priv->window, NULL, 0, 0);
10549 g_object_set_qdata (G_OBJECT (widget), quark_shape_info, NULL);
10553 priv->has_shape_mask = TRUE;
10555 g_object_set_qdata_full (G_OBJECT (widget), quark_shape_info,
10556 cairo_region_copy (region),
10557 (GDestroyNotify) cairo_region_destroy);
10559 /* set shape if widget has a gdk window already.
10560 * otherwise the shape is scheduled to be set by gtk_widget_realize().
10563 gdk_window_shape_combine_region (priv->window, region, 0, 0);
10568 * gtk_widget_input_shape_combine_region:
10569 * @widget: a #GtkWidget
10570 * @region: (allow-none): shape to be added, or %NULL to remove an existing shape
10572 * Sets an input shape for this widget's GDK window. This allows for
10573 * windows which react to mouse click in a nonrectangular region, see
10574 * gdk_window_input_shape_combine_region() for more information.
10579 gtk_widget_input_shape_combine_region (GtkWidget *widget,
10580 cairo_region_t *region)
10582 GtkWidgetPrivate *priv;
10584 g_return_if_fail (GTK_IS_WIDGET (widget));
10585 /* set_shape doesn't work on widgets without gdk window */
10586 g_return_if_fail (gtk_widget_get_has_window (widget));
10588 priv = widget->priv;
10590 if (region == NULL)
10593 gdk_window_input_shape_combine_region (priv->window, NULL, 0, 0);
10595 g_object_set_qdata (G_OBJECT (widget), quark_input_shape_info, NULL);
10599 g_object_set_qdata_full (G_OBJECT (widget), quark_input_shape_info,
10600 cairo_region_copy (region),
10601 (GDestroyNotify) cairo_region_destroy);
10603 /* set shape if widget has a gdk window already.
10604 * otherwise the shape is scheduled to be set by gtk_widget_realize().
10607 gdk_window_input_shape_combine_region (priv->window, region, 0, 0);
10613 gtk_reset_shapes_recurse (GtkWidget *widget,
10619 gdk_window_get_user_data (window, &data);
10620 if (data != widget)
10623 gdk_window_shape_combine_region (window, NULL, 0, 0);
10624 for (list = gdk_window_peek_children (window); list; list = list->next)
10625 gtk_reset_shapes_recurse (widget, list->data);
10629 * gtk_widget_reset_shapes:
10630 * @widget: a #GtkWidget
10632 * Recursively resets the shape on this widget and its descendants.
10635 gtk_widget_reset_shapes (GtkWidget *widget)
10637 GtkWidgetPrivate *priv;
10639 g_return_if_fail (GTK_IS_WIDGET (widget));
10640 g_return_if_fail (gtk_widget_get_realized (widget));
10642 priv = widget->priv;
10644 if (!priv->has_shape_mask)
10645 gtk_reset_shapes_recurse (widget, priv->window);
10648 /* style properties
10652 * gtk_widget_class_install_style_property_parser:
10653 * @klass: a #GtkWidgetClass
10654 * @pspec: the #GParamSpec for the style property
10655 * @parser: the parser for the style property
10657 * Installs a style property on a widget class.
10660 gtk_widget_class_install_style_property_parser (GtkWidgetClass *klass,
10662 GtkRcPropertyParser parser)
10664 g_return_if_fail (GTK_IS_WIDGET_CLASS (klass));
10665 g_return_if_fail (G_IS_PARAM_SPEC (pspec));
10666 g_return_if_fail (pspec->flags & G_PARAM_READABLE);
10667 g_return_if_fail (!(pspec->flags & (G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT)));
10669 if (g_param_spec_pool_lookup (style_property_spec_pool, pspec->name, G_OBJECT_CLASS_TYPE (klass), FALSE))
10671 g_warning (G_STRLOC ": class `%s' already contains a style property named `%s'",
10672 G_OBJECT_CLASS_NAME (klass),
10677 g_param_spec_ref_sink (pspec);
10678 g_param_spec_set_qdata (pspec, quark_property_parser, (gpointer) parser);
10679 g_param_spec_pool_insert (style_property_spec_pool, pspec, G_OBJECT_CLASS_TYPE (klass));
10683 * gtk_widget_class_install_style_property:
10684 * @klass: a #GtkWidgetClass
10685 * @pspec: the #GParamSpec for the property
10687 * Installs a style property on a widget class. The parser for the
10688 * style property is determined by the value type of @pspec.
10691 gtk_widget_class_install_style_property (GtkWidgetClass *klass,
10694 GtkRcPropertyParser parser;
10696 g_return_if_fail (GTK_IS_WIDGET_CLASS (klass));
10697 g_return_if_fail (G_IS_PARAM_SPEC (pspec));
10699 parser = _gtk_rc_property_parser_from_type (G_PARAM_SPEC_VALUE_TYPE (pspec));
10701 gtk_widget_class_install_style_property_parser (klass, pspec, parser);
10705 * gtk_widget_class_find_style_property:
10706 * @klass: a #GtkWidgetClass
10707 * @property_name: the name of the style property to find
10708 * @returns: (allow-none): the #GParamSpec of the style property or %NULL if @class has no
10709 * style property with that name.
10711 * Finds a style property of a widget class by name.
10716 gtk_widget_class_find_style_property (GtkWidgetClass *klass,
10717 const gchar *property_name)
10719 g_return_val_if_fail (property_name != NULL, NULL);
10721 return g_param_spec_pool_lookup (style_property_spec_pool,
10723 G_OBJECT_CLASS_TYPE (klass),
10728 * gtk_widget_class_list_style_properties:
10729 * @klass: a #GtkWidgetClass
10730 * @n_properties: location to return the number of style properties found
10731 * @returns: an newly allocated array of #GParamSpec*. The array must
10732 * be freed with g_free().
10734 * Returns all style properties of a widget class.
10739 gtk_widget_class_list_style_properties (GtkWidgetClass *klass,
10740 guint *n_properties)
10742 GParamSpec **pspecs;
10745 pspecs = g_param_spec_pool_list (style_property_spec_pool,
10746 G_OBJECT_CLASS_TYPE (klass),
10755 * gtk_widget_style_get_property:
10756 * @widget: a #GtkWidget
10757 * @property_name: the name of a style property
10758 * @value: location to return the property value
10760 * Gets the value of a style property of @widget.
10763 gtk_widget_style_get_property (GtkWidget *widget,
10764 const gchar *property_name,
10767 GtkWidgetPrivate *priv;
10770 g_return_if_fail (GTK_IS_WIDGET (widget));
10771 g_return_if_fail (property_name != NULL);
10772 g_return_if_fail (G_IS_VALUE (value));
10774 priv = widget->priv;
10776 g_object_ref (widget);
10777 pspec = g_param_spec_pool_lookup (style_property_spec_pool,
10779 G_OBJECT_TYPE (widget),
10782 g_warning ("%s: widget class `%s' has no property named `%s'",
10784 G_OBJECT_TYPE_NAME (widget),
10788 const GValue *peek_value;
10790 peek_value = _gtk_style_peek_property_value (priv->style,
10791 G_OBJECT_TYPE (widget),
10793 (GtkRcPropertyParser) g_param_spec_get_qdata (pspec, quark_property_parser));
10795 /* auto-conversion of the caller's value type
10797 if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec))
10798 g_value_copy (peek_value, value);
10799 else if (g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), G_VALUE_TYPE (value)))
10800 g_value_transform (peek_value, value);
10802 g_warning ("can't retrieve style property `%s' of type `%s' as value of type `%s'",
10804 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
10805 G_VALUE_TYPE_NAME (value));
10807 g_object_unref (widget);
10811 * gtk_widget_style_get_valist:
10812 * @widget: a #GtkWidget
10813 * @first_property_name: the name of the first property to get
10814 * @var_args: a <type>va_list</type> of pairs of property names and
10815 * locations to return the property values, starting with the location
10816 * for @first_property_name.
10818 * Non-vararg variant of gtk_widget_style_get(). Used primarily by language
10822 gtk_widget_style_get_valist (GtkWidget *widget,
10823 const gchar *first_property_name,
10826 GtkWidgetPrivate *priv;
10829 g_return_if_fail (GTK_IS_WIDGET (widget));
10831 priv = widget->priv;
10833 g_object_ref (widget);
10835 name = first_property_name;
10838 const GValue *peek_value;
10842 pspec = g_param_spec_pool_lookup (style_property_spec_pool,
10844 G_OBJECT_TYPE (widget),
10848 g_warning ("%s: widget class `%s' has no property named `%s'",
10850 G_OBJECT_TYPE_NAME (widget),
10854 /* style pspecs are always readable so we can spare that check here */
10856 peek_value = _gtk_style_peek_property_value (priv->style,
10857 G_OBJECT_TYPE (widget),
10859 (GtkRcPropertyParser) g_param_spec_get_qdata (pspec, quark_property_parser));
10860 G_VALUE_LCOPY (peek_value, var_args, 0, &error);
10863 g_warning ("%s: %s", G_STRLOC, error);
10868 name = va_arg (var_args, gchar*);
10871 g_object_unref (widget);
10875 * gtk_widget_style_get:
10876 * @widget: a #GtkWidget
10877 * @first_property_name: the name of the first property to get
10878 * @Varargs: pairs of property names and locations to
10879 * return the property values, starting with the location for
10880 * @first_property_name, terminated by %NULL.
10882 * Gets the values of a multiple style properties of @widget.
10885 gtk_widget_style_get (GtkWidget *widget,
10886 const gchar *first_property_name,
10891 g_return_if_fail (GTK_IS_WIDGET (widget));
10893 va_start (var_args, first_property_name);
10894 gtk_widget_style_get_valist (widget, first_property_name, var_args);
10900 * @widget: a #GtkWidget
10901 * @path_length: (out) (allow-none): location to store length of the path, or %NULL
10902 * @path: (out) (allow-none): location to store allocated path string, or %NULL
10903 * @path_reversed: (out) (allow-none): location to store allocated reverse path string, or %NULL
10905 * Obtains the full path to @widget. The path is simply the name of a
10906 * widget and all its parents in the container hierarchy, separated by
10907 * periods. The name of a widget comes from
10908 * gtk_widget_get_name(). Paths are used to apply styles to a widget
10909 * in gtkrc configuration files. Widget names are the type of the
10910 * widget by default (e.g. "GtkButton") or can be set to an
10911 * application-specific value with gtk_widget_set_name(). By setting
10912 * the name of a widget, you allow users or theme authors to apply
10913 * styles to that specific widget in their gtkrc
10914 * file. @path_reversed_p fills in the path in reverse order,
10915 * i.e. starting with @widget's name instead of starting with the name
10916 * of @widget's outermost ancestor.
10919 gtk_widget_path (GtkWidget *widget,
10920 guint *path_length,
10922 gchar **path_reversed)
10924 static gchar *rev_path = NULL;
10925 static guint tmp_path_len = 0;
10928 g_return_if_fail (GTK_IS_WIDGET (widget));
10933 const gchar *string;
10938 string = gtk_widget_get_name (widget);
10939 l = strlen (string);
10940 while (tmp_path_len <= len + l + 1)
10942 tmp_path_len += INIT_PATH_SIZE;
10943 rev_path = g_realloc (rev_path, tmp_path_len);
10945 s = string + l - 1;
10946 d = rev_path + len;
10947 while (s >= string)
10951 widget = widget->priv->parent;
10954 rev_path[len++] = '.';
10956 rev_path[len++] = 0;
10961 *path_length = len - 1;
10963 *path_reversed = g_strdup (rev_path);
10966 *path = g_strdup (rev_path);
10967 g_strreverse (*path);
10972 * gtk_widget_class_path:
10973 * @widget: a #GtkWidget
10974 * @path_length: (out) (allow-none): location to store the length of the class path, or %NULL
10975 * @path: (out) (allow-none): location to store the class path as an allocated string, or %NULL
10976 * @path_reversed: (out) (allow-none): location to store the reverse class path as an allocated
10979 * Same as gtk_widget_path(), but always uses the name of a widget's type,
10980 * never uses a custom name set with gtk_widget_set_name().
10984 gtk_widget_class_path (GtkWidget *widget,
10985 guint *path_length,
10987 gchar **path_reversed)
10989 static gchar *rev_path = NULL;
10990 static guint tmp_path_len = 0;
10993 g_return_if_fail (GTK_IS_WIDGET (widget));
10998 const gchar *string;
11003 string = g_type_name (G_OBJECT_TYPE (widget));
11004 l = strlen (string);
11005 while (tmp_path_len <= len + l + 1)
11007 tmp_path_len += INIT_PATH_SIZE;
11008 rev_path = g_realloc (rev_path, tmp_path_len);
11010 s = string + l - 1;
11011 d = rev_path + len;
11012 while (s >= string)
11016 widget = widget->priv->parent;
11019 rev_path[len++] = '.';
11021 rev_path[len++] = 0;
11026 *path_length = len - 1;
11028 *path_reversed = g_strdup (rev_path);
11031 *path = g_strdup (rev_path);
11032 g_strreverse (*path);
11037 * gtk_requisition_new:
11039 * Allocates a new #GtkRequisition structure and initializes its elements to zero.
11041 * Returns: a new empty #GtkRequisition. The newly allocated #GtkRequisition should
11042 * be freed with gtk_requisition_free().
11047 gtk_requisition_new (void)
11049 return g_slice_new0 (GtkRequisition);
11053 * gtk_requisition_copy:
11054 * @requisition: a #GtkRequisition
11056 * Copies a #GtkRequisition.
11058 * Returns: a copy of @requisition
11061 gtk_requisition_copy (const GtkRequisition *requisition)
11063 return g_slice_dup (GtkRequisition, requisition);
11067 * gtk_requisition_free:
11068 * @requisition: a #GtkRequisition
11070 * Frees a #GtkRequisition.
11073 gtk_requisition_free (GtkRequisition *requisition)
11075 g_slice_free (GtkRequisition, requisition);
11078 G_DEFINE_BOXED_TYPE (GtkRequisition, gtk_requisition,
11079 gtk_requisition_copy,
11080 gtk_requisition_free)
11083 * gtk_widget_get_accessible:
11084 * @widget: a #GtkWidget
11086 * Returns the accessible object that describes the widget to an
11087 * assistive technology.
11089 * If no accessibility library is loaded (i.e. no ATK implementation library is
11090 * loaded via <envar>GTK_MODULES</envar> or via another application library,
11091 * such as libgnome), then this #AtkObject instance may be a no-op. Likewise,
11092 * if no class-specific #AtkObject implementation is available for the widget
11093 * instance in question, it will inherit an #AtkObject implementation from the
11094 * first ancestor class for which such an implementation is defined.
11096 * The documentation of the <ulink url="http://developer.gnome.org/doc/API/2.0/atk/index.html">ATK</ulink>
11097 * library contains more information about accessible objects and their uses.
11099 * Returns: (transfer none): the #AtkObject associated with @widget
11102 gtk_widget_get_accessible (GtkWidget *widget)
11104 GtkWidgetClass *klass;
11106 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
11108 klass = GTK_WIDGET_GET_CLASS (widget);
11110 g_return_val_if_fail (klass->get_accessible != NULL, NULL);
11112 return klass->get_accessible (widget);
11116 gtk_widget_real_get_accessible (GtkWidget *widget)
11118 AtkObject* accessible;
11120 accessible = g_object_get_qdata (G_OBJECT (widget),
11121 quark_accessible_object);
11124 AtkObjectFactory *factory;
11125 AtkRegistry *default_registry;
11127 default_registry = atk_get_default_registry ();
11128 factory = atk_registry_get_factory (default_registry,
11129 G_TYPE_FROM_INSTANCE (widget));
11131 atk_object_factory_create_accessible (factory,
11132 G_OBJECT (widget));
11133 g_object_set_qdata (G_OBJECT (widget),
11134 quark_accessible_object,
11141 * Initialize a AtkImplementorIface instance's virtual pointers as
11142 * appropriate to this implementor's class (GtkWidget).
11145 gtk_widget_accessible_interface_init (AtkImplementorIface *iface)
11147 iface->ref_accessible = gtk_widget_ref_accessible;
11151 gtk_widget_ref_accessible (AtkImplementor *implementor)
11153 AtkObject *accessible;
11155 accessible = gtk_widget_get_accessible (GTK_WIDGET (implementor));
11157 g_object_ref (accessible);
11162 * Expand flag management
11166 gtk_widget_update_computed_expand (GtkWidget *widget)
11168 GtkWidgetPrivate *priv;
11170 priv = widget->priv;
11172 if (priv->need_compute_expand)
11176 if (priv->hexpand_set)
11181 if (priv->vexpand_set)
11186 /* we don't need to use compute_expand if both expands are
11187 * forced by the app
11189 if (!(priv->hexpand_set && priv->vexpand_set))
11191 if (GTK_WIDGET_GET_CLASS (widget)->compute_expand != NULL)
11195 GTK_WIDGET_GET_CLASS (widget)->compute_expand (widget,
11196 priv->hexpand_set ? &ignored : &h,
11197 priv->vexpand_set ? &ignored : &v);
11201 priv->need_compute_expand = FALSE;
11202 priv->computed_hexpand = h != FALSE;
11203 priv->computed_vexpand = v != FALSE;
11208 * gtk_widget_queue_compute_expand:
11209 * @widget: a #GtkWidget
11211 * Mark @widget as needing to recompute its expand flags. Call
11212 * this function when setting legacy expand child properties
11213 * on the child of a container.
11215 * See gtk_widget_compute_expand().
11218 gtk_widget_queue_compute_expand (GtkWidget *widget)
11221 gboolean changed_anything;
11223 if (widget->priv->need_compute_expand)
11226 changed_anything = FALSE;
11228 while (parent != NULL)
11230 if (!parent->priv->need_compute_expand)
11232 parent->priv->need_compute_expand = TRUE;
11233 changed_anything = TRUE;
11236 /* Note: if we had an invariant that "if a child needs to
11237 * compute expand, its parents also do" then we could stop going
11238 * up when we got to a parent that already needed to
11239 * compute. However, in general we compute expand lazily (as
11240 * soon as we see something in a subtree that is expand, we know
11241 * we're expanding) and so this invariant does not hold and we
11242 * have to always walk all the way up in case some ancestor
11243 * is not currently need_compute_expand.
11246 parent = parent->priv->parent;
11249 /* recomputing expand always requires
11250 * a relayout as well
11252 if (changed_anything)
11253 gtk_widget_queue_resize (widget);
11257 * gtk_widget_compute_expand:
11258 * @widget: the widget
11259 * @orientation: expand direction
11261 * Computes whether a container should give this widget extra space
11262 * when possible. Containers should check this, rather than
11263 * looking at gtk_widget_get_hexpand() or gtk_widget_get_vexpand().
11265 * This function already checks whether the widget is visible, so
11266 * visibility does not need to be checked separately. Non-visible
11267 * widgets are not expanded.
11269 * The computed expand value uses either the expand setting explicitly
11270 * set on the widget itself, or, if none has been explicitly set,
11271 * the widget may expand if some of its children do.
11273 * Return value: whether widget tree rooted here should be expanded
11276 gtk_widget_compute_expand (GtkWidget *widget,
11277 GtkOrientation orientation)
11279 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
11281 /* We never make a widget expand if not even showing. */
11282 if (!gtk_widget_get_visible (widget))
11285 gtk_widget_update_computed_expand (widget);
11287 if (orientation == GTK_ORIENTATION_HORIZONTAL)
11289 return widget->priv->computed_hexpand;
11293 return widget->priv->computed_vexpand;
11298 gtk_widget_set_expand (GtkWidget *widget,
11299 GtkOrientation orientation,
11302 const char *expand_prop;
11303 const char *expand_set_prop;
11305 GtkWidgetPrivate *priv;
11307 g_return_if_fail (GTK_IS_WIDGET (widget));
11309 priv = widget->priv;
11311 expand = expand != FALSE;
11313 was_both = priv->hexpand && priv->vexpand;
11315 if (orientation == GTK_ORIENTATION_HORIZONTAL)
11317 if (priv->hexpand_set &&
11318 priv->hexpand == expand)
11321 priv->hexpand_set = TRUE;
11322 priv->hexpand = expand;
11324 expand_prop = "hexpand";
11325 expand_set_prop = "hexpand-set";
11329 if (priv->vexpand_set &&
11330 priv->vexpand == expand)
11333 priv->vexpand_set = TRUE;
11334 priv->vexpand = expand;
11336 expand_prop = "vexpand";
11337 expand_set_prop = "vexpand-set";
11340 gtk_widget_queue_compute_expand (widget);
11342 g_object_freeze_notify (G_OBJECT (widget));
11343 g_object_notify (G_OBJECT (widget), expand_prop);
11344 g_object_notify (G_OBJECT (widget), expand_set_prop);
11345 if (was_both != (priv->hexpand && priv->vexpand))
11346 g_object_notify (G_OBJECT (widget), "expand");
11347 g_object_thaw_notify (G_OBJECT (widget));
11351 gtk_widget_set_expand_set (GtkWidget *widget,
11352 GtkOrientation orientation,
11355 GtkWidgetPrivate *priv;
11358 priv = widget->priv;
11360 set = set != FALSE;
11362 if (orientation == GTK_ORIENTATION_HORIZONTAL)
11364 if (set == priv->hexpand_set)
11367 priv->hexpand_set = set;
11368 prop = "hexpand-set";
11372 if (set == priv->vexpand_set)
11375 priv->vexpand_set = set;
11376 prop = "vexpand-set";
11379 gtk_widget_queue_compute_expand (widget);
11381 g_object_notify (G_OBJECT (widget), prop);
11385 * gtk_widget_get_hexpand:
11386 * @widget: the widget
11388 * Gets whether the widget would like any available extra horizontal
11389 * space. When a user resizes a #GtkWindow, widgets with expand=TRUE
11390 * generally receive the extra space. For example, a list or
11391 * scrollable area or document in your window would often be set to
11394 * Containers should use gtk_widget_compute_expand() rather than
11395 * this function, to see whether a widget, or any of its children,
11396 * has the expand flag set. If any child of a widget wants to
11397 * expand, the parent may ask to expand also.
11399 * This function only looks at the widget's own hexpand flag, rather
11400 * than computing whether the entire widget tree rooted at this widget
11403 * Return value: whether hexpand flag is set
11406 gtk_widget_get_hexpand (GtkWidget *widget)
11408 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
11410 return widget->priv->hexpand;
11414 * gtk_widget_set_hexpand:
11415 * @widget: the widget
11416 * @expand: whether to expand
11418 * Sets whether the widget would like any available extra horizontal
11419 * space. When a user resizes a #GtkWindow, widgets with expand=TRUE
11420 * generally receive the extra space. For example, a list or
11421 * scrollable area or document in your window would often be set to
11424 * Call this function to set the expand flag if you would like your
11425 * widget to become larger horizontally when the window has extra
11428 * By default, widgets automatically expand if any of their children
11429 * want to expand. (To see if a widget will automatically expand given
11430 * its current children and state, call gtk_widget_compute_expand(). A
11431 * container can decide how the expandability of children affects the
11432 * expansion of the container by overriding the compute_expand virtual
11433 * method on #GtkWidget.).
11435 * Setting hexpand explicitly with this function will override the
11436 * automatic expand behavior.
11438 * This function forces the widget to expand or not to expand,
11439 * regardless of children. The override occurs because
11440 * gtk_widget_set_hexpand() sets the hexpand-set property (see
11441 * gtk_widget_set_hexpand_set()) which causes the widget's hexpand
11442 * value to be used, rather than looking at children and widget state.
11445 gtk_widget_set_hexpand (GtkWidget *widget,
11448 g_return_if_fail (GTK_IS_WIDGET (widget));
11450 gtk_widget_set_expand (widget, GTK_ORIENTATION_HORIZONTAL, expand);
11454 * gtk_widget_get_hexpand_set:
11455 * @widget: the widget
11457 * Gets whether gtk_widget_set_hexpand() has been used to
11458 * explicitly set the expand flag on this widget.
11460 * If hexpand is set, then it overrides any computed
11461 * expand value based on child widgets. If hexpand is not
11462 * set, then the expand value depends on whether any
11463 * children of the widget would like to expand.
11465 * There are few reasons to use this function, but it's here
11466 * for completeness and consistency.
11468 * Return value: whether hexpand has been explicitly set
11471 gtk_widget_get_hexpand_set (GtkWidget *widget)
11473 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
11475 return widget->priv->hexpand_set;
11479 * gtk_widget_set_hexpand_set:
11480 * @widget: the widget
11481 * @set: value for hexpand-set property
11483 * Sets whether the hexpand flag (see gtk_widget_get_hexpand()) will
11486 * The hexpand-set property will be set automatically when you call
11487 * gtk_widget_set_hexpand() to set hexpand, so the most likely
11488 * reason to use this function would be to unset an explicit expand
11491 * If hexpand is set, then it overrides any computed
11492 * expand value based on child widgets. If hexpand is not
11493 * set, then the expand value depends on whether any
11494 * children of the widget would like to expand.
11496 * There are few reasons to use this function, but it's here
11497 * for completeness and consistency.
11499 * Return value: whether hexpand has been explicitly set
11502 gtk_widget_set_hexpand_set (GtkWidget *widget,
11505 g_return_if_fail (GTK_IS_WIDGET (widget));
11507 gtk_widget_set_expand_set (widget, GTK_ORIENTATION_HORIZONTAL, set);
11512 * gtk_widget_get_vexpand:
11513 * @widget: the widget
11515 * Gets whether the widget would like any available extra vertical
11518 * See gtk_widget_get_hexpand() for more detail.
11520 * Return value: whether vexpand flag is set
11523 gtk_widget_get_vexpand (GtkWidget *widget)
11525 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
11527 return widget->priv->vexpand;
11531 * gtk_widget_set_vexpand:
11532 * @widget: the widget
11533 * @expand: whether to expand
11535 * Sets whether the widget would like any available extra vertical
11538 * See gtk_widget_set_hexpand() for more detail.
11541 gtk_widget_set_vexpand (GtkWidget *widget,
11544 g_return_if_fail (GTK_IS_WIDGET (widget));
11546 gtk_widget_set_expand (widget, GTK_ORIENTATION_VERTICAL, expand);
11550 * gtk_widget_get_vexpand_set:
11551 * @widget: the widget
11553 * Gets whether gtk_widget_set_vexpand() has been used to
11554 * explicitly set the expand flag on this widget.
11556 * See gtk_widget_get_hexpand_set() for more detail.
11558 * Return value: whether vexpand has been explicitly set
11561 gtk_widget_get_vexpand_set (GtkWidget *widget)
11563 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
11565 return widget->priv->vexpand_set;
11569 * gtk_widget_set_vexpand_set:
11570 * @widget: the widget
11571 * @set: value for vexpand-set property
11573 * Sets whether the vexpand flag (see gtk_widget_get_vexpand()) will
11576 * See gtk_widget_set_hexpand_set() for more detail.
11578 * Return value: whether vexpand has been explicitly set
11581 gtk_widget_set_vexpand_set (GtkWidget *widget,
11584 g_return_if_fail (GTK_IS_WIDGET (widget));
11586 gtk_widget_set_expand_set (widget, GTK_ORIENTATION_VERTICAL, set);
11590 * GtkBuildable implementation
11592 static GQuark quark_builder_has_default = 0;
11593 static GQuark quark_builder_has_focus = 0;
11594 static GQuark quark_builder_atk_relations = 0;
11595 static GQuark quark_builder_set_name = 0;
11598 gtk_widget_buildable_interface_init (GtkBuildableIface *iface)
11600 quark_builder_has_default = g_quark_from_static_string ("gtk-builder-has-default");
11601 quark_builder_has_focus = g_quark_from_static_string ("gtk-builder-has-focus");
11602 quark_builder_atk_relations = g_quark_from_static_string ("gtk-builder-atk-relations");
11603 quark_builder_set_name = g_quark_from_static_string ("gtk-builder-set-name");
11605 iface->set_name = gtk_widget_buildable_set_name;
11606 iface->get_name = gtk_widget_buildable_get_name;
11607 iface->get_internal_child = gtk_widget_buildable_get_internal_child;
11608 iface->set_buildable_property = gtk_widget_buildable_set_buildable_property;
11609 iface->parser_finished = gtk_widget_buildable_parser_finished;
11610 iface->custom_tag_start = gtk_widget_buildable_custom_tag_start;
11611 iface->custom_finished = gtk_widget_buildable_custom_finished;
11615 gtk_widget_buildable_set_name (GtkBuildable *buildable,
11618 g_object_set_qdata_full (G_OBJECT (buildable), quark_builder_set_name,
11619 g_strdup (name), g_free);
11622 static const gchar *
11623 gtk_widget_buildable_get_name (GtkBuildable *buildable)
11625 return g_object_get_qdata (G_OBJECT (buildable), quark_builder_set_name);
11629 gtk_widget_buildable_get_internal_child (GtkBuildable *buildable,
11630 GtkBuilder *builder,
11631 const gchar *childname)
11633 if (strcmp (childname, "accessible") == 0)
11634 return G_OBJECT (gtk_widget_get_accessible (GTK_WIDGET (buildable)));
11640 gtk_widget_buildable_set_buildable_property (GtkBuildable *buildable,
11641 GtkBuilder *builder,
11643 const GValue *value)
11645 if (strcmp (name, "has-default") == 0 && g_value_get_boolean (value))
11646 g_object_set_qdata (G_OBJECT (buildable), quark_builder_has_default,
11647 GINT_TO_POINTER (TRUE));
11648 else if (strcmp (name, "has-focus") == 0 && g_value_get_boolean (value))
11649 g_object_set_qdata (G_OBJECT (buildable), quark_builder_has_focus,
11650 GINT_TO_POINTER (TRUE));
11652 g_object_set_property (G_OBJECT (buildable), name, value);
11657 gchar *action_name;
11658 GString *description;
11660 gboolean translatable;
11670 free_action (AtkActionData *data, gpointer user_data)
11672 g_free (data->action_name);
11673 g_string_free (data->description, TRUE);
11674 g_free (data->context);
11675 g_slice_free (AtkActionData, data);
11679 free_relation (AtkRelationData *data, gpointer user_data)
11681 g_free (data->target);
11682 g_free (data->type);
11683 g_slice_free (AtkRelationData, data);
11687 gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
11688 GtkBuilder *builder)
11690 GSList *atk_relations;
11692 if (g_object_get_qdata (G_OBJECT (buildable), quark_builder_has_default))
11693 gtk_widget_grab_default (GTK_WIDGET (buildable));
11694 if (g_object_get_qdata (G_OBJECT (buildable), quark_builder_has_focus))
11695 gtk_widget_grab_focus (GTK_WIDGET (buildable));
11697 atk_relations = g_object_get_qdata (G_OBJECT (buildable),
11698 quark_builder_atk_relations);
11701 AtkObject *accessible;
11702 AtkRelationSet *relation_set;
11705 AtkRelationType relation_type;
11706 AtkObject *target_accessible;
11708 accessible = gtk_widget_get_accessible (GTK_WIDGET (buildable));
11709 relation_set = atk_object_ref_relation_set (accessible);
11711 for (l = atk_relations; l; l = l->next)
11713 AtkRelationData *relation = (AtkRelationData*)l->data;
11715 target = gtk_builder_get_object (builder, relation->target);
11718 g_warning ("Target object %s in <relation> does not exist",
11722 target_accessible = gtk_widget_get_accessible (GTK_WIDGET (target));
11723 g_assert (target_accessible != NULL);
11725 relation_type = atk_relation_type_for_name (relation->type);
11726 if (relation_type == ATK_RELATION_NULL)
11728 g_warning ("<relation> type %s not found",
11732 atk_relation_set_add_relation_by_type (relation_set, relation_type,
11733 target_accessible);
11735 g_object_unref (relation_set);
11737 g_slist_foreach (atk_relations, (GFunc)free_relation, NULL);
11738 g_slist_free (atk_relations);
11739 g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations,
11748 } AccessibilitySubParserData;
11751 accessibility_start_element (GMarkupParseContext *context,
11752 const gchar *element_name,
11753 const gchar **names,
11754 const gchar **values,
11755 gpointer user_data,
11758 AccessibilitySubParserData *data = (AccessibilitySubParserData*)user_data;
11760 gint line_number, char_number;
11762 if (strcmp (element_name, "relation") == 0)
11764 gchar *target = NULL;
11765 gchar *type = NULL;
11766 AtkRelationData *relation;
11768 for (i = 0; names[i]; i++)
11770 if (strcmp (names[i], "target") == 0)
11771 target = g_strdup (values[i]);
11772 else if (strcmp (names[i], "type") == 0)
11773 type = g_strdup (values[i]);
11776 g_markup_parse_context_get_position (context,
11779 g_set_error (error,
11781 GTK_BUILDER_ERROR_INVALID_ATTRIBUTE,
11782 "%s:%d:%d '%s' is not a valid attribute of <%s>",
11784 line_number, char_number, names[i], "relation");
11791 if (!target || !type)
11793 g_markup_parse_context_get_position (context,
11796 g_set_error (error,
11798 GTK_BUILDER_ERROR_MISSING_ATTRIBUTE,
11799 "%s:%d:%d <%s> requires attribute \"%s\"",
11801 line_number, char_number, "relation",
11802 type ? "target" : "type");
11808 relation = g_slice_new (AtkRelationData);
11809 relation->target = target;
11810 relation->type = type;
11812 data->relations = g_slist_prepend (data->relations, relation);
11814 else if (strcmp (element_name, "action") == 0)
11816 const gchar *action_name = NULL;
11817 const gchar *description = NULL;
11818 const gchar *msg_context = NULL;
11819 gboolean translatable = FALSE;
11820 AtkActionData *action;
11822 for (i = 0; names[i]; i++)
11824 if (strcmp (names[i], "action_name") == 0)
11825 action_name = values[i];
11826 else if (strcmp (names[i], "description") == 0)
11827 description = values[i];
11828 else if (strcmp (names[i], "translatable") == 0)
11830 if (!_gtk_builder_boolean_from_string (values[i], &translatable, error))
11833 else if (strcmp (names[i], "comments") == 0)
11835 /* do nothing, comments are for translators */
11837 else if (strcmp (names[i], "context") == 0)
11838 msg_context = values[i];
11841 g_markup_parse_context_get_position (context,
11844 g_set_error (error,
11846 GTK_BUILDER_ERROR_INVALID_ATTRIBUTE,
11847 "%s:%d:%d '%s' is not a valid attribute of <%s>",
11849 line_number, char_number, names[i], "action");
11856 g_markup_parse_context_get_position (context,
11859 g_set_error (error,
11861 GTK_BUILDER_ERROR_MISSING_ATTRIBUTE,
11862 "%s:%d:%d <%s> requires attribute \"%s\"",
11864 line_number, char_number, "action",
11869 action = g_slice_new (AtkActionData);
11870 action->action_name = g_strdup (action_name);
11871 action->description = g_string_new (description);
11872 action->context = g_strdup (msg_context);
11873 action->translatable = translatable;
11875 data->actions = g_slist_prepend (data->actions, action);
11877 else if (strcmp (element_name, "accessibility") == 0)
11880 g_warning ("Unsupported tag for GtkWidget: %s\n", element_name);
11884 accessibility_text (GMarkupParseContext *context,
11887 gpointer user_data,
11890 AccessibilitySubParserData *data = (AccessibilitySubParserData*)user_data;
11892 if (strcmp (g_markup_parse_context_get_element (context), "action") == 0)
11894 AtkActionData *action = data->actions->data;
11896 g_string_append_len (action->description, text, text_len);
11900 static const GMarkupParser accessibility_parser =
11902 accessibility_start_element,
11904 accessibility_text,
11913 } AccelGroupParserData;
11916 accel_group_start_element (GMarkupParseContext *context,
11917 const gchar *element_name,
11918 const gchar **names,
11919 const gchar **values,
11920 gpointer user_data,
11925 guint modifiers = 0;
11926 gchar *signal = NULL;
11927 AccelGroupParserData *parser_data = (AccelGroupParserData*)user_data;
11929 for (i = 0; names[i]; i++)
11931 if (strcmp (names[i], "key") == 0)
11932 key = gdk_keyval_from_name (values[i]);
11933 else if (strcmp (names[i], "modifiers") == 0)
11935 if (!_gtk_builder_flags_from_string (GDK_TYPE_MODIFIER_TYPE,
11941 else if (strcmp (names[i], "signal") == 0)
11942 signal = g_strdup (values[i]);
11945 if (key == 0 || signal == NULL)
11947 g_warning ("<accelerator> requires key and signal attributes");
11950 parser_data->key = key;
11951 parser_data->modifiers = modifiers;
11952 parser_data->signal = signal;
11955 static const GMarkupParser accel_group_parser =
11957 accel_group_start_element,
11961 gtk_widget_buildable_custom_tag_start (GtkBuildable *buildable,
11962 GtkBuilder *builder,
11964 const gchar *tagname,
11965 GMarkupParser *parser,
11968 g_assert (buildable);
11970 if (strcmp (tagname, "accelerator") == 0)
11972 AccelGroupParserData *parser_data;
11974 parser_data = g_slice_new0 (AccelGroupParserData);
11975 parser_data->object = g_object_ref (buildable);
11976 *parser = accel_group_parser;
11977 *data = parser_data;
11980 if (strcmp (tagname, "accessibility") == 0)
11982 AccessibilitySubParserData *parser_data;
11984 parser_data = g_slice_new0 (AccessibilitySubParserData);
11985 *parser = accessibility_parser;
11986 *data = parser_data;
11993 _gtk_widget_buildable_finish_accelerator (GtkWidget *widget,
11994 GtkWidget *toplevel,
11995 gpointer user_data)
11997 AccelGroupParserData *accel_data;
11998 GSList *accel_groups;
11999 GtkAccelGroup *accel_group;
12001 g_return_if_fail (GTK_IS_WIDGET (widget));
12002 g_return_if_fail (GTK_IS_WIDGET (toplevel));
12003 g_return_if_fail (user_data != NULL);
12005 accel_data = (AccelGroupParserData*)user_data;
12006 accel_groups = gtk_accel_groups_from_object (G_OBJECT (toplevel));
12007 if (g_slist_length (accel_groups) == 0)
12009 accel_group = gtk_accel_group_new ();
12010 gtk_window_add_accel_group (GTK_WINDOW (toplevel), accel_group);
12014 g_assert (g_slist_length (accel_groups) == 1);
12015 accel_group = g_slist_nth_data (accel_groups, 0);
12018 gtk_widget_add_accelerator (GTK_WIDGET (accel_data->object),
12019 accel_data->signal,
12022 accel_data->modifiers,
12023 GTK_ACCEL_VISIBLE);
12025 g_object_unref (accel_data->object);
12026 g_free (accel_data->signal);
12027 g_slice_free (AccelGroupParserData, accel_data);
12031 gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
12032 GtkBuilder *builder,
12034 const gchar *tagname,
12035 gpointer user_data)
12037 AccelGroupParserData *accel_data;
12038 AccessibilitySubParserData *a11y_data;
12039 GtkWidget *toplevel;
12041 if (strcmp (tagname, "accelerator") == 0)
12043 accel_data = (AccelGroupParserData*)user_data;
12044 g_assert (accel_data->object);
12046 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (accel_data->object));
12048 _gtk_widget_buildable_finish_accelerator (GTK_WIDGET (buildable), toplevel, user_data);
12050 else if (strcmp (tagname, "accessibility") == 0)
12052 a11y_data = (AccessibilitySubParserData*)user_data;
12054 if (a11y_data->actions)
12056 AtkObject *accessible;
12061 accessible = gtk_widget_get_accessible (GTK_WIDGET (buildable));
12063 action = ATK_ACTION (accessible);
12064 n_actions = atk_action_get_n_actions (action);
12066 for (l = a11y_data->actions; l; l = l->next)
12068 AtkActionData *action_data = (AtkActionData*)l->data;
12070 for (i = 0; i < n_actions; i++)
12071 if (strcmp (atk_action_get_name (action, i),
12072 action_data->action_name) == 0)
12077 gchar *description;
12079 if (action_data->translatable && action_data->description->len)
12080 description = _gtk_builder_parser_translate (gtk_builder_get_translation_domain (builder),
12081 action_data->context,
12082 action_data->description->str);
12084 description = action_data->description->str;
12086 atk_action_set_description (action, i, description);
12090 g_slist_foreach (a11y_data->actions, (GFunc)free_action, NULL);
12091 g_slist_free (a11y_data->actions);
12094 if (a11y_data->relations)
12095 g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations,
12096 a11y_data->relations);
12098 g_slice_free (AccessibilitySubParserData, a11y_data);
12103 gtk_widget_real_get_width (GtkWidget *widget,
12104 gint *minimum_size,
12105 gint *natural_size)
12115 gtk_widget_real_get_height (GtkWidget *widget,
12116 gint *minimum_size,
12117 gint *natural_size)
12127 gtk_widget_real_get_height_for_width (GtkWidget *widget,
12129 gint *minimum_height,
12130 gint *natural_height)
12132 GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, minimum_height, natural_height);
12136 gtk_widget_real_get_width_for_height (GtkWidget *widget,
12138 gint *minimum_width,
12139 gint *natural_width)
12141 GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_width, natural_width);
12145 * gtk_widget_get_halign:
12146 * @widget: a #GtkWidget
12148 * Gets the value of the #GtkWidget:halign property.
12150 * Returns: the horizontal alignment of @widget
12153 gtk_widget_get_halign (GtkWidget *widget)
12155 g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_ALIGN_FILL);
12156 return _gtk_widget_get_aux_info_or_defaults (widget)->halign;
12160 * gtk_widget_set_halign:
12161 * @widget: a #GtkWidget
12162 * @align: the horizontal alignment
12164 * Sets the horizontal alignment of @widget.
12165 * See the #GtkWidget:halign property.
12168 gtk_widget_set_halign (GtkWidget *widget,
12171 GtkWidgetAuxInfo *aux_info;
12173 g_return_if_fail (GTK_IS_WIDGET (widget));
12175 aux_info = _gtk_widget_get_aux_info (widget, TRUE);
12177 if (aux_info->halign == align)
12180 aux_info->halign = align;
12181 gtk_widget_queue_resize (widget);
12182 g_object_notify (G_OBJECT (widget), "halign");
12186 * gtk_widget_get_valign:
12187 * @widget: a #GtkWidget
12189 * Gets the value of the #GtkWidget:valign property.
12191 * Returns: the vertical alignment of @widget
12194 gtk_widget_get_valign (GtkWidget *widget)
12196 g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_ALIGN_FILL);
12197 return _gtk_widget_get_aux_info_or_defaults (widget)->valign;
12201 * gtk_widget_set_valign:
12202 * @widget: a #GtkWidget
12203 * @align: the vertical alignment
12205 * Sets the vertical alignment of @widget.
12206 * See the #GtkWidget:valign property.
12209 gtk_widget_set_valign (GtkWidget *widget,
12212 GtkWidgetAuxInfo *aux_info;
12214 g_return_if_fail (GTK_IS_WIDGET (widget));
12216 aux_info = _gtk_widget_get_aux_info (widget, TRUE);
12218 if (aux_info->valign == align)
12221 aux_info->valign = align;
12222 gtk_widget_queue_resize (widget);
12223 g_object_notify (G_OBJECT (widget), "valign");
12227 * gtk_widget_get_margin_left:
12228 * @widget: a #GtkWidget
12230 * Gets the value of the #GtkWidget:margin-left property.
12232 * Returns: The left margin of @widget
12235 gtk_widget_get_margin_left (GtkWidget *widget)
12237 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
12239 return _gtk_widget_get_aux_info_or_defaults (widget)->margin.left;
12243 * gtk_widget_set_margin_left:
12244 * @widget: a #GtkWidget
12245 * @margin: the left margin
12247 * Sets the left margin of @widget.
12248 * See the #GtkWidget:margin-left property.
12251 gtk_widget_set_margin_left (GtkWidget *widget,
12254 GtkWidgetAuxInfo *aux_info;
12256 g_return_if_fail (GTK_IS_WIDGET (widget));
12257 g_return_if_fail (margin <= G_MAXINT16);
12259 aux_info = _gtk_widget_get_aux_info (widget, TRUE);
12261 if (aux_info->margin.left == margin)
12264 aux_info->margin.left = margin;
12265 gtk_widget_queue_resize (widget);
12266 g_object_notify (G_OBJECT (widget), "margin-left");
12270 * gtk_widget_get_margin_right:
12271 * @widget: a #GtkWidget
12273 * Gets the value of the #GtkWidget:margin-right property.
12275 * Returns: The left margin of @widget
12278 gtk_widget_get_margin_right (GtkWidget *widget)
12280 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
12282 return _gtk_widget_get_aux_info_or_defaults (widget)->margin.right;
12286 * gtk_widget_set_margin_right:
12287 * @widget: a #GtkWidget
12288 * @margin: the right margin
12290 * Sets the right margin of @widget.
12291 * See the #GtkWidget:margin-right property.
12294 gtk_widget_set_margin_right (GtkWidget *widget,
12297 GtkWidgetAuxInfo *aux_info;
12299 g_return_if_fail (GTK_IS_WIDGET (widget));
12300 g_return_if_fail (margin <= G_MAXINT16);
12302 aux_info = _gtk_widget_get_aux_info (widget, TRUE);
12304 if (aux_info->margin.right == margin)
12307 aux_info->margin.right = margin;
12308 gtk_widget_queue_resize (widget);
12309 g_object_notify (G_OBJECT (widget), "margin-right");
12313 * gtk_widget_get_margin_top:
12314 * @widget: a #GtkWidget
12316 * Gets the value of the #GtkWidget:margin-top property.
12318 * Returns: The top margin of @widget
12321 gtk_widget_get_margin_top (GtkWidget *widget)
12323 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
12325 return _gtk_widget_get_aux_info_or_defaults (widget)->margin.top;
12329 * gtk_widget_set_margin_top:
12330 * @widget: a #GtkWidget
12331 * @margin: the top margin
12333 * Sets the top margin of @widget.
12334 * See the #GtkWidget:margin-top property.
12337 gtk_widget_set_margin_top (GtkWidget *widget,
12340 GtkWidgetAuxInfo *aux_info;
12342 g_return_if_fail (GTK_IS_WIDGET (widget));
12343 g_return_if_fail (margin <= G_MAXINT16);
12345 aux_info = _gtk_widget_get_aux_info (widget, TRUE);
12347 if (aux_info->margin.top == margin)
12350 aux_info->margin.top = margin;
12351 gtk_widget_queue_resize (widget);
12352 g_object_notify (G_OBJECT (widget), "margin-top");
12356 * gtk_widget_get_margin_bottom:
12357 * @widget: a #GtkWidget
12359 * Gets the value of the #GtkWidget:margin-bottom property.
12361 * Returns: The bottom margin of @widget
12364 gtk_widget_get_margin_bottom (GtkWidget *widget)
12366 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
12368 return _gtk_widget_get_aux_info_or_defaults (widget)->margin.bottom;
12372 * gtk_widget_set_margin_bottom:
12373 * @widget: a #GtkWidget
12374 * @margin: the bottom margin
12376 * Sets the bottom margin of @widget.
12377 * See the #GtkWidget:margin-bottom property.
12380 gtk_widget_set_margin_bottom (GtkWidget *widget,
12383 GtkWidgetAuxInfo *aux_info;
12385 g_return_if_fail (GTK_IS_WIDGET (widget));
12386 g_return_if_fail (margin <= G_MAXINT16);
12388 aux_info = _gtk_widget_get_aux_info (widget, TRUE);
12390 if (aux_info->margin.bottom == margin)
12393 aux_info->margin.bottom = margin;
12394 gtk_widget_queue_resize (widget);
12395 g_object_notify (G_OBJECT (widget), "margin-bottom");
12399 * gtk_widget_get_clipboard:
12400 * @widget: a #GtkWidget
12401 * @selection: a #GdkAtom which identifies the clipboard
12402 * to use. %GDK_SELECTION_CLIPBOARD gives the
12403 * default clipboard. Another common value
12404 * is %GDK_SELECTION_PRIMARY, which gives
12405 * the primary X selection.
12407 * Returns the clipboard object for the given selection to
12408 * be used with @widget. @widget must have a #GdkDisplay
12409 * associated with it, so must be attached to a toplevel
12412 * Return value: (transfer none): the appropriate clipboard object. If no
12413 * clipboard already exists, a new one will
12414 * be created. Once a clipboard object has
12415 * been created, it is persistent for all time.
12420 gtk_widget_get_clipboard (GtkWidget *widget, GdkAtom selection)
12422 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
12423 g_return_val_if_fail (gtk_widget_has_screen (widget), NULL);
12425 return gtk_clipboard_get_for_display (gtk_widget_get_display (widget),
12430 * gtk_widget_list_mnemonic_labels:
12431 * @widget: a #GtkWidget
12433 * Returns a newly allocated list of the widgets, normally labels, for
12434 * which this widget is the target of a mnemonic (see for example,
12435 * gtk_label_set_mnemonic_widget()).
12437 * The widgets in the list are not individually referenced. If you
12438 * want to iterate through the list and perform actions involving
12439 * callbacks that might destroy the widgets, you
12440 * <emphasis>must</emphasis> call <literal>g_list_foreach (result,
12441 * (GFunc)g_object_ref, NULL)</literal> first, and then unref all the
12442 * widgets afterwards.
12444 * Return value: (element-type GtkWidget) (transfer container): the list of
12445 * mnemonic labels; free this list
12446 * with g_list_free() when you are done with it.
12451 gtk_widget_list_mnemonic_labels (GtkWidget *widget)
12453 GList *list = NULL;
12456 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
12458 for (l = g_object_get_qdata (G_OBJECT (widget), quark_mnemonic_labels); l; l = l->next)
12459 list = g_list_prepend (list, l->data);
12465 * gtk_widget_add_mnemonic_label:
12466 * @widget: a #GtkWidget
12467 * @label: a #GtkWidget that acts as a mnemonic label for @widget
12469 * Adds a widget to the list of mnemonic labels for
12470 * this widget. (See gtk_widget_list_mnemonic_labels()). Note the
12471 * list of mnemonic labels for the widget is cleared when the
12472 * widget is destroyed, so the caller must make sure to update
12473 * its internal state at this point as well, by using a connection
12474 * to the #GtkWidget::destroy signal or a weak notifier.
12479 gtk_widget_add_mnemonic_label (GtkWidget *widget,
12482 GSList *old_list, *new_list;
12484 g_return_if_fail (GTK_IS_WIDGET (widget));
12485 g_return_if_fail (GTK_IS_WIDGET (label));
12487 old_list = g_object_steal_qdata (G_OBJECT (widget), quark_mnemonic_labels);
12488 new_list = g_slist_prepend (old_list, label);
12490 g_object_set_qdata_full (G_OBJECT (widget), quark_mnemonic_labels,
12491 new_list, (GDestroyNotify) g_slist_free);
12495 * gtk_widget_remove_mnemonic_label:
12496 * @widget: a #GtkWidget
12497 * @label: a #GtkWidget that was previously set as a mnemnic label for
12498 * @widget with gtk_widget_add_mnemonic_label().
12500 * Removes a widget from the list of mnemonic labels for
12501 * this widget. (See gtk_widget_list_mnemonic_labels()). The widget
12502 * must have previously been added to the list with
12503 * gtk_widget_add_mnemonic_label().
12508 gtk_widget_remove_mnemonic_label (GtkWidget *widget,
12511 GSList *old_list, *new_list;
12513 g_return_if_fail (GTK_IS_WIDGET (widget));
12514 g_return_if_fail (GTK_IS_WIDGET (label));
12516 old_list = g_object_steal_qdata (G_OBJECT (widget), quark_mnemonic_labels);
12517 new_list = g_slist_remove (old_list, label);
12520 g_object_set_qdata_full (G_OBJECT (widget), quark_mnemonic_labels,
12521 new_list, (GDestroyNotify) g_slist_free);
12525 * gtk_widget_get_no_show_all:
12526 * @widget: a #GtkWidget
12528 * Returns the current value of the GtkWidget:no-show-all property,
12529 * which determines whether calls to gtk_widget_show_all()
12530 * will affect this widget.
12532 * Return value: the current value of the "no-show-all" property.
12537 gtk_widget_get_no_show_all (GtkWidget *widget)
12539 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
12541 return widget->priv->no_show_all;
12545 * gtk_widget_set_no_show_all:
12546 * @widget: a #GtkWidget
12547 * @no_show_all: the new value for the "no-show-all" property
12549 * Sets the #GtkWidget:no-show-all property, which determines whether
12550 * calls to gtk_widget_show_all() will affect this widget.
12552 * This is mostly for use in constructing widget hierarchies with externally
12553 * controlled visibility, see #GtkUIManager.
12558 gtk_widget_set_no_show_all (GtkWidget *widget,
12559 gboolean no_show_all)
12561 g_return_if_fail (GTK_IS_WIDGET (widget));
12563 no_show_all = (no_show_all != FALSE);
12565 if (widget->priv->no_show_all != no_show_all)
12567 widget->priv->no_show_all = no_show_all;
12569 g_object_notify (G_OBJECT (widget), "no-show-all");
12575 gtk_widget_real_set_has_tooltip (GtkWidget *widget,
12576 gboolean has_tooltip,
12579 GtkWidgetPrivate *priv = widget->priv;
12580 gboolean priv_has_tooltip;
12582 priv_has_tooltip = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (widget),
12583 quark_has_tooltip));
12585 if (priv_has_tooltip != has_tooltip || force)
12587 priv_has_tooltip = has_tooltip;
12589 if (priv_has_tooltip)
12591 if (gtk_widget_get_realized (widget) && !gtk_widget_get_has_window (widget))
12592 gdk_window_set_events (priv->window,
12593 gdk_window_get_events (priv->window) |
12594 GDK_LEAVE_NOTIFY_MASK |
12595 GDK_POINTER_MOTION_MASK |
12596 GDK_POINTER_MOTION_HINT_MASK);
12598 if (gtk_widget_get_has_window (widget))
12599 gtk_widget_add_events (widget,
12600 GDK_LEAVE_NOTIFY_MASK |
12601 GDK_POINTER_MOTION_MASK |
12602 GDK_POINTER_MOTION_HINT_MASK);
12605 g_object_set_qdata (G_OBJECT (widget), quark_has_tooltip,
12606 GUINT_TO_POINTER (priv_has_tooltip));
12611 * gtk_widget_set_tooltip_window:
12612 * @widget: a #GtkWidget
12613 * @custom_window: (allow-none): a #GtkWindow, or %NULL
12615 * Replaces the default, usually yellow, window used for displaying
12616 * tooltips with @custom_window. GTK+ will take care of showing and
12617 * hiding @custom_window at the right moment, to behave likewise as
12618 * the default tooltip window. If @custom_window is %NULL, the default
12619 * tooltip window will be used.
12621 * If the custom window should have the default theming it needs to
12622 * have the name "gtk-tooltip", see gtk_widget_set_name().
12627 gtk_widget_set_tooltip_window (GtkWidget *widget,
12628 GtkWindow *custom_window)
12630 gboolean has_tooltip;
12631 gchar *tooltip_markup;
12633 g_return_if_fail (GTK_IS_WIDGET (widget));
12634 g_return_if_fail (custom_window == NULL || GTK_IS_WINDOW (custom_window));
12636 tooltip_markup = g_object_get_qdata (G_OBJECT (widget), quark_tooltip_markup);
12639 g_object_ref (custom_window);
12641 g_object_set_qdata_full (G_OBJECT (widget), quark_tooltip_window,
12642 custom_window, g_object_unref);
12644 has_tooltip = (custom_window != NULL || tooltip_markup != NULL);
12645 gtk_widget_real_set_has_tooltip (widget, has_tooltip, FALSE);
12647 if (has_tooltip && gtk_widget_get_visible (widget))
12648 gtk_widget_queue_tooltip_query (widget);
12652 * gtk_widget_get_tooltip_window:
12653 * @widget: a #GtkWidget
12655 * Returns the #GtkWindow of the current tooltip. This can be the
12656 * GtkWindow created by default, or the custom tooltip window set
12657 * using gtk_widget_set_tooltip_window().
12659 * Return value: (transfer none): The #GtkWindow of the current tooltip.
12664 gtk_widget_get_tooltip_window (GtkWidget *widget)
12666 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
12668 return g_object_get_qdata (G_OBJECT (widget), quark_tooltip_window);
12672 * gtk_widget_trigger_tooltip_query:
12673 * @widget: a #GtkWidget
12675 * Triggers a tooltip query on the display where the toplevel of @widget
12676 * is located. See gtk_tooltip_trigger_tooltip_query() for more
12682 gtk_widget_trigger_tooltip_query (GtkWidget *widget)
12684 gtk_tooltip_trigger_tooltip_query (gtk_widget_get_display (widget));
12687 static guint tooltip_query_id;
12688 static GSList *tooltip_query_displays;
12691 tooltip_query_idle (gpointer data)
12693 g_slist_foreach (tooltip_query_displays, (GFunc)gtk_tooltip_trigger_tooltip_query, NULL);
12694 g_slist_foreach (tooltip_query_displays, (GFunc)g_object_unref, NULL);
12695 g_slist_free (tooltip_query_displays);
12697 tooltip_query_displays = NULL;
12698 tooltip_query_id = 0;
12704 gtk_widget_queue_tooltip_query (GtkWidget *widget)
12706 GdkDisplay *display;
12708 display = gtk_widget_get_display (widget);
12710 if (!g_slist_find (tooltip_query_displays, display))
12711 tooltip_query_displays = g_slist_prepend (tooltip_query_displays, g_object_ref (display));
12713 if (tooltip_query_id == 0)
12714 tooltip_query_id = gdk_threads_add_idle (tooltip_query_idle, NULL);
12718 * gtk_widget_set_tooltip_text:
12719 * @widget: a #GtkWidget
12720 * @text: the contents of the tooltip for @widget
12722 * Sets @text as the contents of the tooltip. This function will take
12723 * care of setting GtkWidget:has-tooltip to %TRUE and of the default
12724 * handler for the GtkWidget::query-tooltip signal.
12726 * See also the GtkWidget:tooltip-text property and gtk_tooltip_set_text().
12731 gtk_widget_set_tooltip_text (GtkWidget *widget,
12734 g_return_if_fail (GTK_IS_WIDGET (widget));
12736 g_object_set (G_OBJECT (widget), "tooltip-text", text, NULL);
12740 * gtk_widget_get_tooltip_text:
12741 * @widget: a #GtkWidget
12743 * Gets the contents of the tooltip for @widget.
12745 * Return value: the tooltip text, or %NULL. You should free the
12746 * returned string with g_free() when done.
12751 gtk_widget_get_tooltip_text (GtkWidget *widget)
12753 gchar *text = NULL;
12755 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
12757 g_object_get (G_OBJECT (widget), "tooltip-text", &text, NULL);
12763 * gtk_widget_set_tooltip_markup:
12764 * @widget: a #GtkWidget
12765 * @markup: (allow-none): the contents of the tooltip for @widget, or %NULL
12767 * Sets @markup as the contents of the tooltip, which is marked up with
12768 * the <link linkend="PangoMarkupFormat">Pango text markup language</link>.
12770 * This function will take care of setting GtkWidget:has-tooltip to %TRUE
12771 * and of the default handler for the GtkWidget::query-tooltip signal.
12773 * See also the GtkWidget:tooltip-markup property and
12774 * gtk_tooltip_set_markup().
12779 gtk_widget_set_tooltip_markup (GtkWidget *widget,
12780 const gchar *markup)
12782 g_return_if_fail (GTK_IS_WIDGET (widget));
12784 g_object_set (G_OBJECT (widget), "tooltip-markup", markup, NULL);
12788 * gtk_widget_get_tooltip_markup:
12789 * @widget: a #GtkWidget
12791 * Gets the contents of the tooltip for @widget.
12793 * Return value: the tooltip text, or %NULL. You should free the
12794 * returned string with g_free() when done.
12799 gtk_widget_get_tooltip_markup (GtkWidget *widget)
12801 gchar *text = NULL;
12803 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
12805 g_object_get (G_OBJECT (widget), "tooltip-markup", &text, NULL);
12811 * gtk_widget_set_has_tooltip:
12812 * @widget: a #GtkWidget
12813 * @has_tooltip: whether or not @widget has a tooltip.
12815 * Sets the has-tooltip property on @widget to @has_tooltip. See
12816 * GtkWidget:has-tooltip for more information.
12821 gtk_widget_set_has_tooltip (GtkWidget *widget,
12822 gboolean has_tooltip)
12824 g_return_if_fail (GTK_IS_WIDGET (widget));
12826 g_object_set (G_OBJECT (widget), "has-tooltip", has_tooltip, NULL);
12830 * gtk_widget_get_has_tooltip:
12831 * @widget: a #GtkWidget
12833 * Returns the current value of the has-tooltip property. See
12834 * GtkWidget:has-tooltip for more information.
12836 * Return value: current value of has-tooltip on @widget.
12841 gtk_widget_get_has_tooltip (GtkWidget *widget)
12843 gboolean has_tooltip = FALSE;
12845 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
12847 g_object_get (G_OBJECT (widget), "has-tooltip", &has_tooltip, NULL);
12849 return has_tooltip;
12853 * gtk_widget_get_allocation:
12854 * @widget: a #GtkWidget
12855 * @allocation: (out): a pointer to a #GtkAllocation to copy to
12857 * Retrieves the widget's allocation.
12859 * Note, when implementing a #GtkContainer: a widget's allocation will
12860 * be its "adjusted" allocation, that is, the widget's parent
12861 * container typically calls gtk_widget_size_allocate() with an
12862 * allocation, and that allocation is then adjusted (to handle margin
12863 * and alignment for example) before assignment to the widget.
12864 * gtk_widget_get_allocation() returns the adjusted allocation that
12865 * was actually assigned to the widget. The adjusted allocation is
12866 * guaranteed to be completely contained within the
12867 * gtk_widget_size_allocate() allocation, however. So a #GtkContainer
12868 * is guaranteed that its children stay inside the assigned bounds,
12869 * but not that they have exactly the bounds the container assigned.
12870 * There is no way to get the original allocation assigned by
12871 * gtk_widget_size_allocate(), since it isn't stored; if a container
12872 * implementation needs that information it will have to track it itself.
12877 gtk_widget_get_allocation (GtkWidget *widget,
12878 GtkAllocation *allocation)
12880 GtkWidgetPrivate *priv;
12882 g_return_if_fail (GTK_IS_WIDGET (widget));
12883 g_return_if_fail (allocation != NULL);
12885 priv = widget->priv;
12887 *allocation = priv->allocation;
12891 * gtk_widget_set_allocation:
12892 * @widget: a #GtkWidget
12893 * @allocation: a pointer to a #GtkAllocation to copy from
12895 * Sets the widget's allocation. This should not be used
12896 * directly, but from within a widget's size_allocate method.
12898 * The allocation set should be the "adjusted" or actual
12899 * allocation. If you're implementing a #GtkContainer, you want to use
12900 * gtk_widget_size_allocate() instead of gtk_widget_set_allocation().
12901 * The GtkWidgetClass::adjust_size_allocation virtual method adjusts the
12902 * allocation inside gtk_widget_size_allocate() to create an adjusted
12908 gtk_widget_set_allocation (GtkWidget *widget,
12909 const GtkAllocation *allocation)
12911 GtkWidgetPrivate *priv;
12913 g_return_if_fail (GTK_IS_WIDGET (widget));
12914 g_return_if_fail (allocation != NULL);
12916 priv = widget->priv;
12918 priv->allocation = *allocation;
12922 * gtk_widget_get_allocated_width:
12923 * @widget: the widget to query
12925 * Returns the width that has currently been allocated to @widget.
12926 * This function is intended to be used when implementing handlers
12927 * for the GtkWidget::draw function.
12929 * Returns: the width of the @widget
12932 gtk_widget_get_allocated_width (GtkWidget *widget)
12934 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
12936 return widget->priv->allocation.width;
12940 * gtk_widget_get_allocated_height:
12941 * @widget: the widget to query
12943 * Returns the height that has currently been allocated to @widget.
12944 * This function is intended to be used when implementing handlers
12945 * for the GtkWidget::draw function.
12947 * Returns: the height of the @widget
12950 gtk_widget_get_allocated_height (GtkWidget *widget)
12952 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
12954 return widget->priv->allocation.height;
12958 * gtk_widget_get_requisition:
12959 * @widget: a #GtkWidget
12960 * @requisition: (out): a pointer to a #GtkRequisition to copy to
12962 * Retrieves the widget's requisition.
12964 * This function should only be used by widget implementations in
12965 * order to figure whether the widget's requisition has actually
12966 * changed after some internal state change (so that they can call
12967 * gtk_widget_queue_resize() instead of gtk_widget_queue_draw()).
12969 * Normally, gtk_widget_size_request() should be used.
12973 * Deprecated: 3.0: The #GtkRequisition cache on the widget was
12974 * removed, If you need to cache sizes across requests and allocations,
12975 * add an explicit cache to the widget in question instead.
12978 gtk_widget_get_requisition (GtkWidget *widget,
12979 GtkRequisition *requisition)
12981 g_return_if_fail (GTK_IS_WIDGET (widget));
12982 g_return_if_fail (requisition != NULL);
12984 gtk_widget_get_preferred_size (widget, requisition, NULL);
12988 * gtk_widget_set_window:
12989 * @widget: a #GtkWidget
12990 * @window: a #GdkWindow
12992 * Sets a widget's window. This function should only be used in a
12993 * widget's GtkWidget::realize() implementation. The %window passed is
12994 * usually either new window created with gdk_window_new(), or the
12995 * window of its parent widget as returned by
12996 * gtk_widget_get_parent_window().
12998 * Widgets must indicate whether they will create their own #GdkWindow
12999 * by calling gtk_widget_set_has_window(). This is usually done in the
13000 * widget's init() function.
13002 * <note><para>This function does not add any reference to @window.</para></note>
13007 gtk_widget_set_window (GtkWidget *widget,
13010 GtkWidgetPrivate *priv;
13012 g_return_if_fail (GTK_IS_WIDGET (widget));
13013 g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
13015 priv = widget->priv;
13017 if (priv->window != window)
13019 priv->window = window;
13020 g_object_notify (G_OBJECT (widget), "window");
13025 * gtk_widget_get_window:
13026 * @widget: a #GtkWidget
13028 * Returns the widget's window if it is realized, %NULL otherwise
13030 * Return value: (transfer none): @widget's window.
13035 gtk_widget_get_window (GtkWidget *widget)
13037 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
13039 return widget->priv->window;
13043 * gtk_widget_get_support_multidevice:
13044 * @widget: a #GtkWidget
13046 * Returns %TRUE if @widget is multiple pointer aware. See
13047 * gtk_widget_set_support_multidevice() for more information.
13049 * Returns: %TRUE is @widget is multidevice aware.
13052 gtk_widget_get_support_multidevice (GtkWidget *widget)
13054 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
13056 return widget->priv->multidevice;
13060 * gtk_widget_set_support_multidevice:
13061 * @widget: a #GtkWidget
13062 * @support_multidevice: %TRUE to support input from multiple devices.
13064 * Enables or disables multiple pointer awareness. If this setting is %TRUE,
13065 * @widget will start receiving multiple, per device enter/leave events. Note
13066 * that if custom #GdkWindow<!-- -->s are created in #GtkWidget::realize,
13067 * gdk_window_set_support_multidevice() will have to be called manually on them.
13072 gtk_widget_set_support_multidevice (GtkWidget *widget,
13073 gboolean support_multidevice)
13075 GtkWidgetPrivate *priv;
13077 g_return_if_fail (GTK_IS_WIDGET (widget));
13079 priv = widget->priv;
13081 if (support_multidevice)
13083 priv->multidevice = TRUE;
13084 gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_ALL);
13088 priv->multidevice = FALSE;
13089 gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_NONE);
13092 if (gtk_widget_get_realized (widget))
13093 gdk_window_set_support_multidevice (priv->window, support_multidevice);
13097 _gtk_widget_set_has_focus (GtkWidget *widget,
13098 gboolean has_focus)
13100 widget->priv->has_focus = has_focus;
13104 * gtk_widget_send_focus_change:
13105 * @widget: a #GtkWidget
13106 * @event: a #GdkEvent of type GDK_FOCUS_CHANGE
13108 * Sends the focus change @event to @widget
13110 * This function is not meant to be used by applications. The only time it
13111 * should be used is when it is necessary for a #GtkWidget to assign focus
13112 * to a widget that is semantically owned by the first widget even though
13113 * it's not a direct child - for instance, a search entry in a floating
13114 * window similar to the quick search in #GtkTreeView.
13116 * An example of its usage is:
13119 * GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE);
13121 * fevent->focus_change.type = GDK_FOCUS_CHANGE;
13122 * fevent->focus_change.in = TRUE;
13123 * fevent->focus_change.window = gtk_widget_get_window (widget);
13124 * if (fevent->focus_change.window != NULL)
13125 * g_object_ref (fevent->focus_change.window);
13127 * gtk_widget_send_focus_change (widget, fevent);
13129 * gdk_event_free (event);
13132 * Return value: the return value from the event signal emission: %TRUE
13133 * if the event was handled, and %FALSE otherwise
13138 gtk_widget_send_focus_change (GtkWidget *widget,
13143 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
13144 g_return_val_if_fail (event != NULL && event->type == GDK_FOCUS_CHANGE, FALSE);
13146 g_object_ref (widget);
13148 _gtk_widget_set_has_focus (widget, event->focus_change.in);
13150 res = gtk_widget_event (widget, event);
13152 g_object_notify (G_OBJECT (widget), "has-focus");
13154 g_object_unref (widget);
13160 * gtk_widget_in_destruction:
13161 * @widget: a #GtkWidget
13163 * Returns whether the widget is currently being destroyed.
13164 * This information can sometimes be used to avoid doing
13165 * unnecessary work.
13167 * Returns: %TRUE if @widget is being destroyed
13170 gtk_widget_in_destruction (GtkWidget *widget)
13172 return widget->priv->in_destruction;
13176 _gtk_widget_get_resize_pending (GtkWidget *widget)
13178 return widget->priv->resize_pending;
13182 _gtk_widget_set_resize_pending (GtkWidget *widget,
13183 gboolean resize_pending)
13185 widget->priv->resize_pending = resize_pending;
13189 _gtk_widget_get_in_reparent (GtkWidget *widget)
13191 return widget->priv->in_reparent;
13195 _gtk_widget_set_in_reparent (GtkWidget *widget,
13196 gboolean in_reparent)
13198 widget->priv->in_reparent = in_reparent;
13202 _gtk_widget_get_anchored (GtkWidget *widget)
13204 return widget->priv->anchored;
13208 _gtk_widget_set_anchored (GtkWidget *widget,
13211 widget->priv->anchored = anchored;
13215 _gtk_widget_get_shadowed (GtkWidget *widget)
13217 return widget->priv->shadowed;
13221 _gtk_widget_set_shadowed (GtkWidget *widget,
13224 widget->priv->shadowed = shadowed;
13228 _gtk_widget_get_alloc_needed (GtkWidget *widget)
13230 return widget->priv->alloc_needed;
13234 _gtk_widget_set_alloc_needed (GtkWidget *widget,
13235 gboolean alloc_needed)
13237 widget->priv->alloc_needed = alloc_needed;
13241 _gtk_widget_get_width_request_needed (GtkWidget *widget)
13243 return widget->priv->width_request_needed;
13247 _gtk_widget_set_width_request_needed (GtkWidget *widget,
13248 gboolean width_request_needed)
13250 widget->priv->width_request_needed = width_request_needed;
13254 _gtk_widget_get_height_request_needed (GtkWidget *widget)
13256 return widget->priv->height_request_needed;
13260 _gtk_widget_set_height_request_needed (GtkWidget *widget,
13261 gboolean height_request_needed)
13263 widget->priv->height_request_needed = height_request_needed;