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.
92 * %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH means the widget preferrs to
93 * have #GtkWidgetClass.get_preferred_width() called and then
94 * #GtkWidgetClass.get_preferred_height_for_width() and is the
95 * default return for unimplemented cases.
97 * However it's important to note (as described below) that any
98 * widget which trades height-for-width must respond properly to
99 * both #GtkSizeRequestModes since it might be queried in either
100 * orientation by it's parent container.
104 * <term>#GtkWidgetClass.get_preferred_width()</term>
106 * This is called by containers to obtain the minimum and
107 * natural width of a widget. A widget will never be allocated
108 * a width less than it's minimum and will only ever be allocated
109 * a width greater than the natural width once all of the said
110 * widget's siblings have received their natural widths.
112 * Furthermore a widget will only ever be allocated a width greater
113 * than it's natural width if it was configured to receive extra
114 * expand space from it's parent container.
118 * <term>#GtkWidgetClass.get_preferred_height()</term>
120 * This is called by containers to obtain the minimum and
121 * natural height of a widget.
123 * A widget that does not actually trade any height for width
124 * or width for height only has to implement these two virtual
125 * methods (#GtkWidgetClass.get_preferred_width() and
126 * #GtkWidgetClass.get_preferred_height()).
130 * <term>#GtkWidgetClass.get_preferred_height_for_width()</term>
132 * This is similar to #GtkWidgetClass.get_preferred_height() except
133 * that it is passed a contextual width to request height for. By
134 * implementing this virtual method it is possible for a #GtkLabel
135 * to tell it's parent how much height would be required if the
136 * label were to be allocated a said width.
140 * <term>#GtkWidgetClass.get_preferred_width_for_height()</term>
142 * This is analogous to #GtkWidgetClass.get_preferred_height_for_width()
143 * except that it operates in the oposite orientation. It's rare that
144 * a widget actually does %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT requests
145 * but can happen when for example; a widget or container gets additional
146 * columns to compensate for a smaller allocated height.
151 * There are some important things to keep in mind when implementing
152 * height-for-width and when using it in container implementations.
154 * The geometry management system will query a widget hierarchy in
155 * only one orientation at a time. When widgets are initially queried
156 * for their minimum sizes it is generally done in two initial passes
157 * in the #GtkSizeRequestMode chosen by the toplevel.
159 * For example, when queried in the normal
160 * %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH mode:
161 * First, the default minimum and natural width for each widget
162 * in the interface will be computed using gtk_width_get_preferred_width().
163 * Because the preferred widths for each container depends on the preferred
164 * widths of thier children, this information propagates up the hierarchy,
165 * and finally a minimum and natural width is determined for the entire
166 * toplevel. Next, the toplevel will use the minimum width to query for the
167 * minimum height contextual to that width using
168 * gtk_widget_get_preferred_height_for_width(), which will also be a highly
169 * recursive operation. The minimum height for the minimum width is normally
170 * used to set the minimum size constraint on the toplevel
171 * (unless gtk_window_set_geometry_hints() is explicitly used instead).
173 * After the toplevel window has initially requested it's size in both
174 * dimensions it can go on to allocate itself a reasonable size (or a size
175 * previously specified with gtk_window_set_default_size()). During the
176 * recursive allocation process it's important to note that request cycles
177 * will be recursively executed while container widgets allocate their children.
178 * Each container widget, once allocated a size will go on to first share the
179 * space in one orientation among its children and then request each child's
180 * height for their target allocated width or width for allocated height
181 * depending. In this way a #GtkWidget will typically be requested its size
182 * a number of times before actually being allocated a size, the size a
183 * widget is finally allocated can of course differ from the size it
184 * requested. For this reason; #GtkWidget caches a small number of results
185 * to avoid re-querying for the same sizes in one allocation cycle.
187 * See <link linkend="container-geometry-management">GtkContainer's
188 * geometry management section</link>
189 * to learn more about how height-for-width allocations are performed
190 * by container widgets.
192 * If a widget does move content around to smartly use up the
193 * allocated size, then it must support the request in both
194 * #GtkSizeRequestModes even if the widget in question only
195 * trades sizes in a single orientation.
197 * For instance, a #GtkLabel that does height-for-width word wrapping
198 * will not expect to have #GtkWidgetClass.get_preferred_height() called
199 * because that call is specific to a width-for-height request. In this
200 * case the label must return the heights required for it's own minimum
201 * possible width. By following this rule any widget that handles
202 * height-for-width or width-for-height requests will always be allocated
203 * at least enough space to fit its own content.
205 * Here are some examples of how a %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH widget
206 * generally deals with width-for-height requests, for #GtkWidgetClass.get_preferred_height()
208 * <programlisting><![CDATA[
210 * foo_widget_get_preferred_height (GtkWidget *widget, gint *min_height, gint *nat_height)
212 * if (i_am_in_height_for_width_mode)
216 * GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_width, NULL);
217 * GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width (widget, min_width,
218 * min_height, nat_height);
222 * ... some widgets do both, for instance if a GtkLabel is rotated to 90 degrees
223 * it will return the minimum and natural height for the rotated label here.
226 * ]]></programlisting>
228 * And in #GtkWidgetClass.get_preferred_width_for_height() it will simply return
229 * the minimum and natural width:
231 * <programlisting><![CDATA[
233 * foo_widget_get_preferred_width_for_height (GtkWidget *widget, gint for_height,
234 * gint *min_width, gint *nat_width)
236 * if (i_am_in_height_for_width_mode)
238 * GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, min_width, nat_width);
242 * ... again if a widget is sometimes operating in width-for-height mode
243 * (like a rotated GtkLabel) it can go ahead and do it's real width for
244 * height calculation here.
247 * ]]></programlisting>
249 * Often a widget needs to get its own request during size request or
250 * allocation, for example when computing height it may need to also
251 * compute width, or when deciding how to use an allocation the widget
252 * may need to know its natural size. In these cases, the widget should
253 * be careful to call its virtual methods directly, like this:
255 * <title>Widget calling its own size request method.</title>
257 * GTK_WIDGET_GET_CLASS(widget)->get_preferred_width (widget),
262 * It will not work to use the wrapper functions, such as
263 * gtk_widget_get_preferred_width(), inside your own size request
264 * implementation. These return a request adjusted by #GtkSizeGroup
265 * and by the #GtkWidgetClass.adjust_size_request() virtual method. If a
266 * widget used the wrappers inside its virtual method implementations,
267 * then the adjustments (such as widget margins) would be applied
268 * twice. GTK+ therefore does not allow this and will warn if you try
271 * Of course if you are getting the size request for
272 * <emphasis>another</emphasis> widget, such as a child of a
273 * container, you <emphasis>must</emphasis> use the wrapper APIs;
274 * otherwise, you would not properly consider widget margins,
275 * #GtkSizeGroup, and so forth.
278 * <refsect2 id="style-properties">
279 * <title>Style Properties</title>
281 * <structname>GtkWidget</structname> introduces <firstterm>style
282 * properties</firstterm> - these are basically object properties that are stored
283 * not on the object, but in the style object associated to the widget. Style
284 * properties are set in <link linkend="gtk-Resource-Files">resource files</link>.
285 * This mechanism is used for configuring such things as the location of the
286 * scrollbar arrows through the theme, giving theme authors more control over the
287 * look of applications without the need to write a theme engine in C.
290 * Use gtk_widget_class_install_style_property() to install style properties for
291 * a widget class, gtk_widget_class_find_style_property() or
292 * gtk_widget_class_list_style_properties() to get information about existing
293 * style properties and gtk_widget_style_get_property(), gtk_widget_style_get() or
294 * gtk_widget_style_get_valist() to obtain the value of a style property.
297 * <refsect2 id="GtkWidget-BUILDER-UI">
298 * <title>GtkWidget as GtkBuildable</title>
300 * The GtkWidget implementation of the GtkBuildable interface supports a
301 * custom <accelerator> element, which has attributes named key,
302 * modifiers and signal and allows to specify accelerators.
305 * <title>A UI definition fragment specifying an accelerator</title>
306 * <programlisting><![CDATA[
307 * <object class="GtkButton">
308 * <accelerator key="q" modifiers="GDK_CONTROL_MASK" signal="clicked"/>
310 * ]]></programlisting>
313 * In addition to accelerators, <structname>GtkWidget</structname> also support a
314 * custom <accessible> element, which supports actions and relations.
315 * Properties on the accessible implementation of an object can be set by accessing the
316 * internal child "accessible" of a <structname>GtkWidget</structname>.
319 * <title>A UI definition fragment specifying an accessible</title>
320 * <programlisting><![CDATA[
321 * <object class="GtkButton" id="label1"/>
322 * <property name="label">I am a Label for a Button</property>
324 * <object class="GtkButton" id="button1">
326 * <action action_name="click" translatable="yes">Click the button.</action>
327 * <relation target="label1" type="labelled-by"/>
329 * <child internal-child="accessible">
330 * <object class="AtkObject" id="a11y-button1">
331 * <property name="AtkObject::name">Clickable Button</property>
335 * ]]></programlisting>
340 #define WIDGET_CLASS(w) GTK_WIDGET_GET_CLASS (w)
341 #define INIT_PATH_SIZE (512)
343 struct _GtkWidgetPrivate
345 /* The state of the widget. There are actually only
346 * 5 widget states (defined in "gtkenums.h")
351 /* The saved state of the widget. When a widget's state
352 * is changed to GTK_STATE_INSENSITIVE via
353 * "gtk_widget_set_state" or "gtk_widget_set_sensitive"
354 * the old state is kept around in this field. The state
355 * will be restored once the widget gets sensitive again.
357 guint saved_state : 3;
361 guint in_destruction : 1;
364 guint composite_child : 1;
370 guint parent_sensitive : 1;
373 guint can_default : 1;
374 guint has_default : 1;
375 guint receives_default : 1;
379 guint user_style : 1;
380 guint app_paintable : 1;
381 guint double_buffered : 1;
382 guint redraw_on_alloc : 1;
383 guint no_show_all : 1;
384 guint child_visible : 1;
385 guint multidevice : 1;
386 guint has_shape_mask : 1;
387 guint in_reparent : 1;
388 guint resize_pending : 1;
389 guint alloc_needed : 1;
390 guint width_request_needed : 1;
391 guint height_request_needed : 1;
393 /* Expand-related flags */
394 guint need_compute_expand : 1; /* Need to recompute computed_[hv]_expand */
395 guint computed_hexpand : 1; /* computed results (composite of child flags) */
396 guint computed_vexpand : 1;
397 guint hexpand : 1; /* application-forced expand */
399 guint hexpand_set : 1; /* whether to use application-forced */
400 guint vexpand_set : 1; /* instead of computing from children */
402 /* The widget's name. If the widget does not have a name
403 * (the name is NULL), then its name (as returned by
404 * "gtk_widget_get_name") is its class's name.
405 * Among other things, the widget name is used to determine
406 * the style to use for a widget.
410 /* The style for the widget. The style contains the
411 * colors the widget should be drawn in for each state
412 * along with graphics contexts used to draw with and
413 * the font to use for text.
417 /* The widget's allocated size.
419 GtkAllocation allocation;
421 /* The widget's requested sizes */
422 SizeRequestCache requests;
424 /* The widget's window or its parent window if it does
425 * not have a window. (Which will be indicated by the
426 * GTK_NO_WINDOW flag being set).
430 /* The widget's parent.
461 BUTTON_RELEASE_EVENT,
476 PROPERTY_NOTIFY_EVENT,
477 SELECTION_CLEAR_EVENT,
478 SELECTION_REQUEST_EVENT,
479 SELECTION_NOTIFY_EVENT,
486 VISIBILITY_NOTIFY_EVENT,
500 ACCEL_CLOSURES_CHANGED,
523 PROP_RECEIVES_DEFAULT,
524 PROP_COMPOSITE_CHILD,
527 PROP_EXTENSION_EVENTS,
533 PROP_DOUBLE_BUFFERED,
548 typedef struct _GtkStateData GtkStateData;
553 guint state_restoration : 1;
554 guint parent_sensitive : 1;
555 guint use_forall : 1;
558 /* --- prototypes --- */
559 static void gtk_widget_class_init (GtkWidgetClass *klass);
560 static void gtk_widget_base_class_finalize (GtkWidgetClass *klass);
561 static void gtk_widget_init (GtkWidget *widget);
562 static void gtk_widget_set_property (GObject *object,
566 static void gtk_widget_get_property (GObject *object,
570 static void gtk_widget_dispose (GObject *object);
571 static void gtk_widget_real_destroy (GtkWidget *object);
572 static void gtk_widget_finalize (GObject *object);
573 static void gtk_widget_real_show (GtkWidget *widget);
574 static void gtk_widget_real_hide (GtkWidget *widget);
575 static void gtk_widget_real_map (GtkWidget *widget);
576 static void gtk_widget_real_unmap (GtkWidget *widget);
577 static void gtk_widget_real_realize (GtkWidget *widget);
578 static void gtk_widget_real_unrealize (GtkWidget *widget);
579 static void gtk_widget_real_size_request (GtkWidget *widget,
580 GtkRequisition *requisition);
581 static void gtk_widget_real_size_allocate (GtkWidget *widget,
582 GtkAllocation *allocation);
583 static void gtk_widget_real_style_set (GtkWidget *widget,
584 GtkStyle *previous_style);
585 static void gtk_widget_real_direction_changed(GtkWidget *widget,
586 GtkTextDirection previous_direction);
588 static void gtk_widget_real_grab_focus (GtkWidget *focus_widget);
589 static gboolean gtk_widget_real_query_tooltip (GtkWidget *widget,
592 gboolean keyboard_tip,
593 GtkTooltip *tooltip);
594 static gboolean gtk_widget_real_show_help (GtkWidget *widget,
595 GtkWidgetHelpType help_type);
597 static void gtk_widget_dispatch_child_properties_changed (GtkWidget *object,
599 GParamSpec **pspecs);
600 static gboolean gtk_widget_real_key_press_event (GtkWidget *widget,
602 static gboolean gtk_widget_real_key_release_event (GtkWidget *widget,
604 static gboolean gtk_widget_real_focus_in_event (GtkWidget *widget,
605 GdkEventFocus *event);
606 static gboolean gtk_widget_real_focus_out_event (GtkWidget *widget,
607 GdkEventFocus *event);
608 static gboolean gtk_widget_real_focus (GtkWidget *widget,
609 GtkDirectionType direction);
610 static void gtk_widget_real_move_focus (GtkWidget *widget,
611 GtkDirectionType direction);
612 static gboolean gtk_widget_real_keynav_failed (GtkWidget *widget,
613 GtkDirectionType direction);
614 static PangoContext* gtk_widget_peek_pango_context (GtkWidget *widget);
615 static void gtk_widget_update_pango_context (GtkWidget *widget);
616 static void gtk_widget_propagate_state (GtkWidget *widget,
618 static void gtk_widget_reset_rc_style (GtkWidget *widget);
619 static void gtk_widget_set_style_internal (GtkWidget *widget,
621 gboolean initial_emission);
622 static gint gtk_widget_event_internal (GtkWidget *widget,
624 static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget,
625 gboolean group_cycling);
626 static void gtk_widget_real_get_width (GtkWidget *widget,
629 static void gtk_widget_real_get_height (GtkWidget *widget,
632 static void gtk_widget_real_get_height_for_width (GtkWidget *widget,
634 gint *minimum_height,
635 gint *natural_height);
636 static void gtk_widget_real_get_width_for_height (GtkWidget *widget,
639 gint *natural_width);
640 static const GtkWidgetAuxInfo* _gtk_widget_get_aux_info_or_defaults (GtkWidget *widget);
641 static void gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info);
642 static AtkObject* gtk_widget_real_get_accessible (GtkWidget *widget);
643 static void gtk_widget_accessible_interface_init (AtkImplementorIface *iface);
644 static AtkObject* gtk_widget_ref_accessible (AtkImplementor *implementor);
645 static void gtk_widget_invalidate_widget_windows (GtkWidget *widget,
646 cairo_region_t *region);
647 static GdkScreen * gtk_widget_get_screen_unchecked (GtkWidget *widget);
648 static void gtk_widget_queue_shallow_draw (GtkWidget *widget);
649 static gboolean gtk_widget_real_can_activate_accel (GtkWidget *widget,
652 static void gtk_widget_real_set_has_tooltip (GtkWidget *widget,
653 gboolean has_tooltip,
655 static void gtk_widget_buildable_interface_init (GtkBuildableIface *iface);
656 static void gtk_widget_buildable_set_name (GtkBuildable *buildable,
658 static const gchar * gtk_widget_buildable_get_name (GtkBuildable *buildable);
659 static GObject * gtk_widget_buildable_get_internal_child (GtkBuildable *buildable,
661 const gchar *childname);
662 static void gtk_widget_buildable_set_buildable_property (GtkBuildable *buildable,
665 const GValue *value);
666 static gboolean gtk_widget_buildable_custom_tag_start (GtkBuildable *buildable,
669 const gchar *tagname,
670 GMarkupParser *parser,
672 static void gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
675 const gchar *tagname,
677 static void gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
678 GtkBuilder *builder);
680 static void gtk_widget_real_get_width (GtkWidget *widget,
683 static void gtk_widget_real_get_height (GtkWidget *widget,
687 static void gtk_widget_queue_tooltip_query (GtkWidget *widget);
690 static void gtk_widget_real_adjust_size_request (GtkWidget *widget,
691 GtkOrientation orientation,
695 static void gtk_widget_real_adjust_size_allocation (GtkWidget *widget,
696 GtkAllocation *allocation);
698 static void gtk_widget_set_usize_internal (GtkWidget *widget,
701 GtkQueueResizeFlags flags);
703 static void gtk_widget_add_events_internal (GtkWidget *widget,
707 /* --- variables --- */
708 static gpointer gtk_widget_parent_class = NULL;
709 static guint widget_signals[LAST_SIGNAL] = { 0 };
710 static GtkStyle *gtk_default_style = NULL;
711 static guint composite_child_stack = 0;
712 static GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR;
713 static GParamSpecPool *style_property_spec_pool = NULL;
715 static GQuark quark_property_parser = 0;
716 static GQuark quark_aux_info = 0;
717 static GQuark quark_accel_path = 0;
718 static GQuark quark_accel_closures = 0;
719 static GQuark quark_event_mask = 0;
720 static GQuark quark_device_event_mask = 0;
721 static GQuark quark_extension_event_mode = 0;
722 static GQuark quark_parent_window = 0;
723 static GQuark quark_pointer_window = 0;
724 static GQuark quark_shape_info = 0;
725 static GQuark quark_input_shape_info = 0;
726 static GQuark quark_pango_context = 0;
727 static GQuark quark_rc_style = 0;
728 static GQuark quark_accessible_object = 0;
729 static GQuark quark_mnemonic_labels = 0;
730 static GQuark quark_tooltip_markup = 0;
731 static GQuark quark_has_tooltip = 0;
732 static GQuark quark_tooltip_window = 0;
733 static GQuark quark_visual = 0;
734 GParamSpecPool *_gtk_widget_child_property_pool = NULL;
735 GObjectNotifyContext *_gtk_widget_child_property_notify_context = NULL;
737 /* --- functions --- */
739 gtk_widget_get_type (void)
741 static GType widget_type = 0;
743 if (G_UNLIKELY (widget_type == 0))
745 const GTypeInfo widget_info =
747 sizeof (GtkWidgetClass),
748 NULL, /* base_init */
749 (GBaseFinalizeFunc) gtk_widget_base_class_finalize,
750 (GClassInitFunc) gtk_widget_class_init,
751 NULL, /* class_finalize */
752 NULL, /* class_init */
755 (GInstanceInitFunc) gtk_widget_init,
756 NULL, /* value_table */
759 const GInterfaceInfo accessibility_info =
761 (GInterfaceInitFunc) gtk_widget_accessible_interface_init,
762 (GInterfaceFinalizeFunc) NULL,
763 NULL /* interface data */
766 const GInterfaceInfo buildable_info =
768 (GInterfaceInitFunc) gtk_widget_buildable_interface_init,
769 (GInterfaceFinalizeFunc) NULL,
770 NULL /* interface data */
773 widget_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, "GtkWidget",
774 &widget_info, G_TYPE_FLAG_ABSTRACT);
776 g_type_add_interface_static (widget_type, ATK_TYPE_IMPLEMENTOR,
777 &accessibility_info) ;
778 g_type_add_interface_static (widget_type, GTK_TYPE_BUILDABLE,
786 child_property_notify_dispatcher (GObject *object,
790 GTK_WIDGET_GET_CLASS (object)->dispatch_child_properties_changed (GTK_WIDGET (object), n_pspecs, pspecs);
793 /* We guard against the draw signal callbacks modifying the state of the
794 * cairo context by surounding it with save/restore.
795 * Maybe we should also cairo_new_path() just to be sure?
798 gtk_widget_draw_marshaller (GClosure *closure,
799 GValue *return_value,
800 guint n_param_values,
801 const GValue *param_values,
802 gpointer invocation_hint,
803 gpointer marshal_data)
805 cairo_t *cr = g_value_get_boxed (¶m_values[1]);
809 _gtk_marshal_BOOLEAN__BOXED (closure,
820 gtk_widget_class_init (GtkWidgetClass *klass)
822 static GObjectNotifyContext cpn_context = { 0, NULL, NULL };
823 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
824 GtkBindingSet *binding_set;
826 gtk_widget_parent_class = g_type_class_peek_parent (klass);
828 quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser");
829 quark_aux_info = g_quark_from_static_string ("gtk-aux-info");
830 quark_accel_path = g_quark_from_static_string ("gtk-accel-path");
831 quark_accel_closures = g_quark_from_static_string ("gtk-accel-closures");
832 quark_event_mask = g_quark_from_static_string ("gtk-event-mask");
833 quark_device_event_mask = g_quark_from_static_string ("gtk-device-event-mask");
834 quark_extension_event_mode = g_quark_from_static_string ("gtk-extension-event-mode");
835 quark_parent_window = g_quark_from_static_string ("gtk-parent-window");
836 quark_pointer_window = g_quark_from_static_string ("gtk-pointer-window");
837 quark_shape_info = g_quark_from_static_string ("gtk-shape-info");
838 quark_input_shape_info = g_quark_from_static_string ("gtk-input-shape-info");
839 quark_pango_context = g_quark_from_static_string ("gtk-pango-context");
840 quark_rc_style = g_quark_from_static_string ("gtk-rc-style");
841 quark_accessible_object = g_quark_from_static_string ("gtk-accessible-object");
842 quark_mnemonic_labels = g_quark_from_static_string ("gtk-mnemonic-labels");
843 quark_tooltip_markup = g_quark_from_static_string ("gtk-tooltip-markup");
844 quark_has_tooltip = g_quark_from_static_string ("gtk-has-tooltip");
845 quark_tooltip_window = g_quark_from_static_string ("gtk-tooltip-window");
846 quark_visual = g_quark_from_static_string ("gtk-widget-visual");
848 style_property_spec_pool = g_param_spec_pool_new (FALSE);
849 _gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE);
850 cpn_context.quark_notify_queue = g_quark_from_static_string ("GtkWidget-child-property-notify-queue");
851 cpn_context.dispatcher = child_property_notify_dispatcher;
852 _gtk_widget_child_property_notify_context = &cpn_context;
854 gobject_class->dispose = gtk_widget_dispose;
855 gobject_class->finalize = gtk_widget_finalize;
856 gobject_class->set_property = gtk_widget_set_property;
857 gobject_class->get_property = gtk_widget_get_property;
859 klass->destroy = gtk_widget_real_destroy;
861 klass->activate_signal = 0;
862 klass->dispatch_child_properties_changed = gtk_widget_dispatch_child_properties_changed;
863 klass->show = gtk_widget_real_show;
864 klass->show_all = gtk_widget_show;
865 klass->hide = gtk_widget_real_hide;
866 klass->map = gtk_widget_real_map;
867 klass->unmap = gtk_widget_real_unmap;
868 klass->realize = gtk_widget_real_realize;
869 klass->unrealize = gtk_widget_real_unrealize;
870 klass->size_request = gtk_widget_real_size_request;
871 klass->size_allocate = gtk_widget_real_size_allocate;
872 klass->get_preferred_width = gtk_widget_real_get_width;
873 klass->get_preferred_height = gtk_widget_real_get_height;
874 klass->get_preferred_width_for_height = gtk_widget_real_get_width_for_height;
875 klass->get_preferred_height_for_width = gtk_widget_real_get_height_for_width;
876 klass->state_changed = NULL;
877 klass->parent_set = NULL;
878 klass->hierarchy_changed = NULL;
879 klass->style_set = gtk_widget_real_style_set;
880 klass->direction_changed = gtk_widget_real_direction_changed;
881 klass->grab_notify = NULL;
882 klass->child_notify = NULL;
884 klass->mnemonic_activate = gtk_widget_real_mnemonic_activate;
885 klass->grab_focus = gtk_widget_real_grab_focus;
886 klass->focus = gtk_widget_real_focus;
887 klass->move_focus = gtk_widget_real_move_focus;
888 klass->keynav_failed = gtk_widget_real_keynav_failed;
890 klass->button_press_event = NULL;
891 klass->button_release_event = NULL;
892 klass->motion_notify_event = NULL;
893 klass->delete_event = NULL;
894 klass->destroy_event = NULL;
895 klass->key_press_event = gtk_widget_real_key_press_event;
896 klass->key_release_event = gtk_widget_real_key_release_event;
897 klass->enter_notify_event = NULL;
898 klass->leave_notify_event = NULL;
899 klass->configure_event = NULL;
900 klass->focus_in_event = gtk_widget_real_focus_in_event;
901 klass->focus_out_event = gtk_widget_real_focus_out_event;
902 klass->map_event = NULL;
903 klass->unmap_event = NULL;
904 klass->window_state_event = NULL;
905 klass->property_notify_event = _gtk_selection_property_notify;
906 klass->selection_clear_event = _gtk_selection_clear;
907 klass->selection_request_event = _gtk_selection_request;
908 klass->selection_notify_event = _gtk_selection_notify;
909 klass->selection_received = NULL;
910 klass->proximity_in_event = NULL;
911 klass->proximity_out_event = NULL;
912 klass->drag_begin = NULL;
913 klass->drag_end = NULL;
914 klass->drag_data_delete = NULL;
915 klass->drag_leave = NULL;
916 klass->drag_motion = NULL;
917 klass->drag_drop = NULL;
918 klass->drag_data_received = NULL;
919 klass->screen_changed = NULL;
920 klass->can_activate_accel = gtk_widget_real_can_activate_accel;
921 klass->grab_broken_event = NULL;
922 klass->query_tooltip = gtk_widget_real_query_tooltip;
924 klass->show_help = gtk_widget_real_show_help;
926 /* Accessibility support */
927 klass->get_accessible = gtk_widget_real_get_accessible;
929 klass->no_expose_event = NULL;
931 klass->adjust_size_request = gtk_widget_real_adjust_size_request;
932 klass->adjust_size_allocation = gtk_widget_real_adjust_size_allocation;
934 g_object_class_install_property (gobject_class,
936 g_param_spec_string ("name",
938 P_("The name of the widget"),
940 GTK_PARAM_READWRITE));
941 g_object_class_install_property (gobject_class,
943 g_param_spec_object ("parent",
945 P_("The parent widget of this widget. Must be a Container widget"),
947 GTK_PARAM_READWRITE));
949 g_object_class_install_property (gobject_class,
951 g_param_spec_int ("width-request",
953 P_("Override for width request of the widget, or -1 if natural request should be used"),
957 GTK_PARAM_READWRITE));
958 g_object_class_install_property (gobject_class,
960 g_param_spec_int ("height-request",
961 P_("Height request"),
962 P_("Override for height request of the widget, or -1 if natural request should be used"),
966 GTK_PARAM_READWRITE));
967 g_object_class_install_property (gobject_class,
969 g_param_spec_boolean ("visible",
971 P_("Whether the widget is visible"),
973 GTK_PARAM_READWRITE));
974 g_object_class_install_property (gobject_class,
976 g_param_spec_boolean ("sensitive",
978 P_("Whether the widget responds to input"),
980 GTK_PARAM_READWRITE));
981 g_object_class_install_property (gobject_class,
983 g_param_spec_boolean ("app-paintable",
984 P_("Application paintable"),
985 P_("Whether the application will paint directly on the widget"),
987 GTK_PARAM_READWRITE));
988 g_object_class_install_property (gobject_class,
990 g_param_spec_boolean ("can-focus",
992 P_("Whether the widget can accept the input focus"),
994 GTK_PARAM_READWRITE));
995 g_object_class_install_property (gobject_class,
997 g_param_spec_boolean ("has-focus",
999 P_("Whether the widget has the input focus"),
1001 GTK_PARAM_READWRITE));
1002 g_object_class_install_property (gobject_class,
1004 g_param_spec_boolean ("is-focus",
1006 P_("Whether the widget is the focus widget within the toplevel"),
1008 GTK_PARAM_READWRITE));
1009 g_object_class_install_property (gobject_class,
1011 g_param_spec_boolean ("can-default",
1013 P_("Whether the widget can be the default widget"),
1015 GTK_PARAM_READWRITE));
1016 g_object_class_install_property (gobject_class,
1018 g_param_spec_boolean ("has-default",
1020 P_("Whether the widget is the default widget"),
1022 GTK_PARAM_READWRITE));
1023 g_object_class_install_property (gobject_class,
1024 PROP_RECEIVES_DEFAULT,
1025 g_param_spec_boolean ("receives-default",
1026 P_("Receives default"),
1027 P_("If TRUE, the widget will receive the default action when it is focused"),
1029 GTK_PARAM_READWRITE));
1030 g_object_class_install_property (gobject_class,
1031 PROP_COMPOSITE_CHILD,
1032 g_param_spec_boolean ("composite-child",
1033 P_("Composite child"),
1034 P_("Whether the widget is part of a composite widget"),
1036 GTK_PARAM_READABLE));
1037 g_object_class_install_property (gobject_class,
1039 g_param_spec_object ("style",
1041 P_("The style of the widget, which contains information about how it will look (colors etc)"),
1043 GTK_PARAM_READWRITE));
1044 g_object_class_install_property (gobject_class,
1046 g_param_spec_flags ("events",
1048 P_("The event mask that decides what kind of GdkEvents this widget gets"),
1049 GDK_TYPE_EVENT_MASK,
1051 GTK_PARAM_READWRITE));
1052 g_object_class_install_property (gobject_class,
1053 PROP_EXTENSION_EVENTS,
1054 g_param_spec_enum ("extension-events",
1055 P_("Extension events"),
1056 P_("The mask that decides what kind of extension events this widget gets"),
1057 GDK_TYPE_EXTENSION_MODE,
1058 GDK_EXTENSION_EVENTS_NONE,
1059 GTK_PARAM_READWRITE));
1060 g_object_class_install_property (gobject_class,
1062 g_param_spec_boolean ("no-show-all",
1064 P_("Whether gtk_widget_show_all() should not affect this widget"),
1066 GTK_PARAM_READWRITE));
1069 * GtkWidget:has-tooltip:
1071 * Enables or disables the emission of #GtkWidget::query-tooltip on @widget.
1072 * A value of %TRUE indicates that @widget can have a tooltip, in this case
1073 * the widget will be queried using #GtkWidget::query-tooltip to determine
1074 * whether it will provide a tooltip or not.
1076 * Note that setting this property to %TRUE for the first time will change
1077 * the event masks of the GdkWindows of this widget to include leave-notify
1078 * and motion-notify events. This cannot and will not be undone when the
1079 * property is set to %FALSE again.
1083 g_object_class_install_property (gobject_class,
1085 g_param_spec_boolean ("has-tooltip",
1087 P_("Whether this widget has a tooltip"),
1089 GTK_PARAM_READWRITE));
1091 * GtkWidget:tooltip-text:
1093 * Sets the text of tooltip to be the given string.
1095 * Also see gtk_tooltip_set_text().
1097 * This is a convenience property which will take care of getting the
1098 * tooltip shown if the given string is not %NULL: #GtkWidget:has-tooltip
1099 * will automatically be set to %TRUE and there will be taken care of
1100 * #GtkWidget::query-tooltip in the default signal handler.
1104 g_object_class_install_property (gobject_class,
1106 g_param_spec_string ("tooltip-text",
1108 P_("The contents of the tooltip for this widget"),
1110 GTK_PARAM_READWRITE));
1112 * GtkWidget:tooltip-markup:
1114 * Sets the text of tooltip to be the given string, which is marked up
1115 * with the <link linkend="PangoMarkupFormat">Pango text markup language</link>.
1116 * Also see gtk_tooltip_set_markup().
1118 * This is a convenience property which will take care of getting the
1119 * tooltip shown if the given string is not %NULL: #GtkWidget:has-tooltip
1120 * will automatically be set to %TRUE and there will be taken care of
1121 * #GtkWidget::query-tooltip in the default signal handler.
1125 g_object_class_install_property (gobject_class,
1126 PROP_TOOLTIP_MARKUP,
1127 g_param_spec_string ("tooltip-markup",
1128 P_("Tooltip markup"),
1129 P_("The contents of the tooltip for this widget"),
1131 GTK_PARAM_READWRITE));
1136 * The widget's window if it is realized, %NULL otherwise.
1140 g_object_class_install_property (gobject_class,
1142 g_param_spec_object ("window",
1144 P_("The widget's window if it is realized"),
1146 GTK_PARAM_READABLE));
1149 * GtkWidget:double-buffered
1151 * Whether the widget is double buffered.
1155 g_object_class_install_property (gobject_class,
1156 PROP_DOUBLE_BUFFERED,
1157 g_param_spec_boolean ("double-buffered",
1158 P_("Double Buffered"),
1159 P_("Whether the widget is double buffered"),
1161 GTK_PARAM_READWRITE));
1166 * How to distribute horizontal space if widget gets extra space, see #GtkAlign
1170 g_object_class_install_property (gobject_class,
1172 g_param_spec_enum ("halign",
1173 P_("Horizontal Alignment"),
1174 P_("How to position in extra horizontal space"),
1177 GTK_PARAM_READWRITE));
1182 * How to distribute vertical space if widget gets extra space, see #GtkAlign
1186 g_object_class_install_property (gobject_class,
1188 g_param_spec_enum ("valign",
1189 P_("Vertical Alignment"),
1190 P_("How to position in extra vertical space"),
1193 GTK_PARAM_READWRITE));
1196 * GtkWidget:margin-left
1198 * Margin on left side of widget.
1200 * This property adds margin outside of the widget's normal size
1201 * request, the margin will be added in addition to the size from
1202 * gtk_widget_set_size_request() for example.
1206 g_object_class_install_property (gobject_class,
1208 g_param_spec_int ("margin-left",
1209 P_("Margin on Left"),
1210 P_("Pixels of extra space on the left side"),
1214 GTK_PARAM_READWRITE));
1217 * GtkWidget:margin-right
1219 * Margin on right side of widget.
1221 * This property adds margin outside of the widget's normal size
1222 * request, the margin will be added in addition to the size from
1223 * gtk_widget_set_size_request() for example.
1227 g_object_class_install_property (gobject_class,
1229 g_param_spec_int ("margin-right",
1230 P_("Margin on Right"),
1231 P_("Pixels of extra space on the right side"),
1235 GTK_PARAM_READWRITE));
1238 * GtkWidget:margin-top
1240 * Margin on top side of widget.
1242 * This property adds margin outside of the widget's normal size
1243 * request, the margin will be added in addition to the size from
1244 * gtk_widget_set_size_request() for example.
1248 g_object_class_install_property (gobject_class,
1250 g_param_spec_int ("margin-top",
1251 P_("Margin on Top"),
1252 P_("Pixels of extra space on the top side"),
1256 GTK_PARAM_READWRITE));
1259 * GtkWidget:margin-bottom
1261 * Margin on bottom side of widget.
1263 * This property adds margin outside of the widget's normal size
1264 * request, the margin will be added in addition to the size from
1265 * gtk_widget_set_size_request() for example.
1269 g_object_class_install_property (gobject_class,
1271 g_param_spec_int ("margin-bottom",
1272 P_("Margin on Bottom"),
1273 P_("Pixels of extra space on the bottom side"),
1277 GTK_PARAM_READWRITE));
1282 * Sets all four sides' margin at once. If read, returns max
1283 * margin on any side.
1287 g_object_class_install_property (gobject_class,
1289 g_param_spec_int ("margin",
1291 P_("Pixels of extra space on all four sides"),
1295 GTK_PARAM_READWRITE));
1298 * GtkWidget::destroy:
1299 * @object: the object which received the signal
1301 * Signals that all holders of a reference to the widget should release
1302 * the reference that they hold. May result in finalization of the widget
1303 * if all references are released.
1305 widget_signals[DESTROY] =
1306 g_signal_new (I_("destroy"),
1307 G_TYPE_FROM_CLASS (gobject_class),
1308 G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
1309 G_STRUCT_OFFSET (GtkWidgetClass, destroy),
1311 _gtk_marshal_VOID__VOID,
1317 * Whether to expand horizontally. See gtk_widget_set_hexpand().
1321 g_object_class_install_property (gobject_class,
1323 g_param_spec_boolean ("hexpand",
1324 P_("Horizontal Expand"),
1325 P_("Whether widget wants more horizontal space"),
1327 GTK_PARAM_READWRITE));
1330 * GtkWidget:hexpand-set
1332 * Whether to use the GtkWidget:hexpand property. See gtk_widget_get_hexpand_set().
1336 g_object_class_install_property (gobject_class,
1338 g_param_spec_boolean ("hexpand-set",
1339 P_("Horizontal Expand Set"),
1340 P_("Whether to use the hexpand property"),
1342 GTK_PARAM_READWRITE));
1347 * Whether to expand vertically. See gtk_widget_set_vexpand().
1351 g_object_class_install_property (gobject_class,
1353 g_param_spec_boolean ("vexpand",
1354 P_("Vertical Expand"),
1355 P_("Whether widget wants more vertical space"),
1357 GTK_PARAM_READWRITE));
1360 * GtkWidget:vexpand-set
1362 * Whether to use the GtkWidget:vexpand property. See gtk_widget_get_vexpand_set().
1366 g_object_class_install_property (gobject_class,
1368 g_param_spec_boolean ("vexpand-set",
1369 P_("Vertical Expand Set"),
1370 P_("Whether to use the vexpand property"),
1372 GTK_PARAM_READWRITE));
1377 * Whether to expand in both directions. Setting this sets both GtkWidget:hexpand and GtkWidget:vexpand
1381 g_object_class_install_property (gobject_class,
1383 g_param_spec_boolean ("expand",
1385 P_("Whether widget wants to expand in both directions"),
1387 GTK_PARAM_READWRITE));
1391 * @widget: the object which received the signal.
1393 widget_signals[SHOW] =
1394 g_signal_new (I_("show"),
1395 G_TYPE_FROM_CLASS (gobject_class),
1397 G_STRUCT_OFFSET (GtkWidgetClass, show),
1399 _gtk_marshal_VOID__VOID,
1404 * @widget: the object which received the signal.
1406 widget_signals[HIDE] =
1407 g_signal_new (I_("hide"),
1408 G_TYPE_FROM_CLASS (gobject_class),
1410 G_STRUCT_OFFSET (GtkWidgetClass, hide),
1412 _gtk_marshal_VOID__VOID,
1417 * @widget: the object which received the signal.
1419 widget_signals[MAP] =
1420 g_signal_new (I_("map"),
1421 G_TYPE_FROM_CLASS (gobject_class),
1423 G_STRUCT_OFFSET (GtkWidgetClass, map),
1425 _gtk_marshal_VOID__VOID,
1430 * @widget: the object which received the signal.
1432 widget_signals[UNMAP] =
1433 g_signal_new (I_("unmap"),
1434 G_TYPE_FROM_CLASS (gobject_class),
1436 G_STRUCT_OFFSET (GtkWidgetClass, unmap),
1438 _gtk_marshal_VOID__VOID,
1442 * GtkWidget::realize:
1443 * @widget: the object which received the signal.
1445 widget_signals[REALIZE] =
1446 g_signal_new (I_("realize"),
1447 G_TYPE_FROM_CLASS (gobject_class),
1449 G_STRUCT_OFFSET (GtkWidgetClass, realize),
1451 _gtk_marshal_VOID__VOID,
1455 * GtkWidget::unrealize:
1456 * @widget: the object which received the signal.
1458 widget_signals[UNREALIZE] =
1459 g_signal_new (I_("unrealize"),
1460 G_TYPE_FROM_CLASS (gobject_class),
1462 G_STRUCT_OFFSET (GtkWidgetClass, unrealize),
1464 _gtk_marshal_VOID__VOID,
1468 * GtkWidget::size-request:
1469 * @widget: the object which received the signal.
1472 widget_signals[SIZE_REQUEST] =
1473 g_signal_new (I_("size-request"),
1474 G_TYPE_FROM_CLASS (gobject_class),
1476 G_STRUCT_OFFSET (GtkWidgetClass, size_request),
1478 _gtk_marshal_VOID__BOXED,
1480 GTK_TYPE_REQUISITION | G_SIGNAL_TYPE_STATIC_SCOPE);
1483 * GtkWidget::size-allocate:
1484 * @widget: the object which received the signal.
1487 widget_signals[SIZE_ALLOCATE] =
1488 g_signal_new (I_("size-allocate"),
1489 G_TYPE_FROM_CLASS (gobject_class),
1491 G_STRUCT_OFFSET (GtkWidgetClass, size_allocate),
1493 _gtk_marshal_VOID__BOXED,
1495 GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
1498 * GtkWidget::state-changed:
1499 * @widget: the object which received the signal.
1500 * @state: the previous state
1502 * The ::state-changed signal is emitted when the widget state changes.
1503 * See gtk_widget_get_state().
1505 widget_signals[STATE_CHANGED] =
1506 g_signal_new (I_("state-changed"),
1507 G_TYPE_FROM_CLASS (gobject_class),
1509 G_STRUCT_OFFSET (GtkWidgetClass, state_changed),
1511 _gtk_marshal_VOID__ENUM,
1513 GTK_TYPE_STATE_TYPE);
1516 * GtkWidget::parent-set:
1517 * @widget: the object on which the signal is emitted
1518 * @old_parent: (allow-none): the previous parent, or %NULL if the widget
1519 * just got its initial parent.
1521 * The ::parent-set signal is emitted when a new parent
1522 * has been set on a widget.
1524 widget_signals[PARENT_SET] =
1525 g_signal_new (I_("parent-set"),
1526 G_TYPE_FROM_CLASS (gobject_class),
1528 G_STRUCT_OFFSET (GtkWidgetClass, parent_set),
1530 _gtk_marshal_VOID__OBJECT,
1535 * GtkWidget::hierarchy-changed:
1536 * @widget: the object on which the signal is emitted
1537 * @previous_toplevel: (allow-none): the previous toplevel ancestor, or %NULL
1538 * if the widget was previously unanchored
1540 * The ::hierarchy-changed signal is emitted when the
1541 * anchored state of a widget changes. A widget is
1542 * <firstterm>anchored</firstterm> when its toplevel
1543 * ancestor is a #GtkWindow. This signal is emitted when
1544 * a widget changes from un-anchored to anchored or vice-versa.
1546 widget_signals[HIERARCHY_CHANGED] =
1547 g_signal_new (I_("hierarchy-changed"),
1548 G_TYPE_FROM_CLASS (gobject_class),
1550 G_STRUCT_OFFSET (GtkWidgetClass, hierarchy_changed),
1552 _gtk_marshal_VOID__OBJECT,
1557 * GtkWidget::style-set:
1558 * @widget: the object on which the signal is emitted
1559 * @previous_style: (allow-none): the previous style, or %NULL if the widget
1560 * just got its initial style
1562 * The ::style-set signal is emitted when a new style has been set
1563 * on a widget. Note that style-modifying functions like
1564 * gtk_widget_modify_base() also cause this signal to be emitted.
1566 widget_signals[STYLE_SET] =
1567 g_signal_new (I_("style-set"),
1568 G_TYPE_FROM_CLASS (gobject_class),
1570 G_STRUCT_OFFSET (GtkWidgetClass, style_set),
1572 _gtk_marshal_VOID__OBJECT,
1577 * GtkWidget::direction-changed:
1578 * @widget: the object on which the signal is emitted
1579 * @previous_direction: the previous text direction of @widget
1581 * The ::direction-changed signal is emitted when the text direction
1582 * of a widget changes.
1584 widget_signals[DIRECTION_CHANGED] =
1585 g_signal_new (I_("direction-changed"),
1586 G_TYPE_FROM_CLASS (gobject_class),
1588 G_STRUCT_OFFSET (GtkWidgetClass, direction_changed),
1590 _gtk_marshal_VOID__ENUM,
1592 GTK_TYPE_TEXT_DIRECTION);
1595 * GtkWidget::grab-notify:
1596 * @widget: the object which received the signal
1597 * @was_grabbed: %FALSE if the widget becomes shadowed, %TRUE
1598 * if it becomes unshadowed
1600 * The ::grab-notify signal is emitted when a widget becomes
1601 * shadowed by a GTK+ grab (not a pointer or keyboard grab) on
1602 * another widget, or when it becomes unshadowed due to a grab
1605 * A widget is shadowed by a gtk_grab_add() when the topmost
1606 * grab widget in the grab stack of its window group is not
1609 widget_signals[GRAB_NOTIFY] =
1610 g_signal_new (I_("grab-notify"),
1611 G_TYPE_FROM_CLASS (gobject_class),
1613 G_STRUCT_OFFSET (GtkWidgetClass, grab_notify),
1615 _gtk_marshal_VOID__BOOLEAN,
1620 * GtkWidget::child-notify:
1621 * @widget: the object which received the signal
1622 * @pspec: the #GParamSpec of the changed child property
1624 * The ::child-notify signal is emitted for each
1625 * <link linkend="child-properties">child property</link> that has
1626 * changed on an object. The signal's detail holds the property name.
1628 widget_signals[CHILD_NOTIFY] =
1629 g_signal_new (I_("child-notify"),
1630 G_TYPE_FROM_CLASS (gobject_class),
1631 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS,
1632 G_STRUCT_OFFSET (GtkWidgetClass, child_notify),
1634 g_cclosure_marshal_VOID__PARAM,
1640 * @widget: the object which received the signal
1641 * @cr: the cairo context to draw to
1643 * This signal is emitted when a widget is supposed to render itself.
1644 * The @widget's top left corner must be painted at the origin of
1645 * the passed in context and be sized to the values returned by
1646 * gtk_widget_get_allocated_width() and
1647 * gtk_widget_get_allocated_height().
1649 * Signal handlers connected to this signal can modify the cairo
1650 * context passed as @cr in any way they like and don't need to
1651 * restore it. The signal emission takes care of calling cairo_save()
1652 * before and cairo_restore() after invoking the handler.
1654 widget_signals[DRAW] =
1655 g_signal_new (I_("draw"),
1656 G_TYPE_FROM_CLASS (gobject_class),
1658 G_STRUCT_OFFSET (GtkWidgetClass, draw),
1659 _gtk_boolean_handled_accumulator, NULL,
1660 gtk_widget_draw_marshaller,
1662 CAIRO_GOBJECT_TYPE_CONTEXT);
1665 * GtkWidget::mnemonic-activate:
1666 * @widget: the object which received the signal.
1669 widget_signals[MNEMONIC_ACTIVATE] =
1670 g_signal_new (I_("mnemonic-activate"),
1671 G_TYPE_FROM_CLASS (gobject_class),
1673 G_STRUCT_OFFSET (GtkWidgetClass, mnemonic_activate),
1674 _gtk_boolean_handled_accumulator, NULL,
1675 _gtk_marshal_BOOLEAN__BOOLEAN,
1680 * GtkWidget::grab-focus:
1681 * @widget: the object which received the signal.
1683 widget_signals[GRAB_FOCUS] =
1684 g_signal_new (I_("grab-focus"),
1685 G_TYPE_FROM_CLASS (gobject_class),
1686 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
1687 G_STRUCT_OFFSET (GtkWidgetClass, grab_focus),
1689 _gtk_marshal_VOID__VOID,
1694 * @widget: the object which received the signal.
1697 * Returns: %TRUE to stop other handlers from being invoked for the event. %FALSE to propagate the event further.
1699 widget_signals[FOCUS] =
1700 g_signal_new (I_("focus"),
1701 G_TYPE_FROM_CLASS (klass),
1703 G_STRUCT_OFFSET (GtkWidgetClass, focus),
1704 _gtk_boolean_handled_accumulator, NULL,
1705 _gtk_marshal_BOOLEAN__ENUM,
1707 GTK_TYPE_DIRECTION_TYPE);
1710 * GtkWidget::move-focus:
1711 * @widget: the object which received the signal.
1714 widget_signals[MOVE_FOCUS] =
1715 g_signal_new (I_("move-focus"),
1716 G_TYPE_FROM_CLASS (klass),
1717 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
1718 G_STRUCT_OFFSET (GtkWidgetClass, move_focus),
1720 _gtk_marshal_VOID__ENUM,
1723 GTK_TYPE_DIRECTION_TYPE);
1726 * GtkWidget::keynav-failed:
1727 * @widget: the object which received the signal
1728 * @direction: the direction of movement
1730 * Gets emitted if keyboard navigation fails.
1731 * See gtk_widget_keynav_failed() for details.
1733 * Returns: %TRUE if stopping keyboard navigation is fine, %FALSE
1734 * if the emitting widget should try to handle the keyboard
1735 * navigation attempt in its parent container(s).
1739 widget_signals[KEYNAV_FAILED] =
1740 g_signal_new (I_("keynav-failed"),
1741 G_TYPE_FROM_CLASS (klass),
1743 G_STRUCT_OFFSET (GtkWidgetClass, keynav_failed),
1744 _gtk_boolean_handled_accumulator, NULL,
1745 _gtk_marshal_BOOLEAN__ENUM,
1747 GTK_TYPE_DIRECTION_TYPE);
1751 * @widget: the object which received the signal.
1752 * @event: the #GdkEvent which triggered this signal
1754 * The GTK+ main loop will emit three signals for each GDK event delivered
1755 * to a widget: one generic ::event signal, another, more specific,
1756 * signal that matches the type of event delivered (e.g.
1757 * #GtkWidget::key-press-event) and finally a generic
1758 * #GtkWidget::event-after signal.
1760 * Returns: %TRUE to stop other handlers from being invoked for the event
1761 * and to cancel the emission of the second specific ::event signal.
1762 * %FALSE to propagate the event further and to allow the emission of
1763 * the second signal. The ::event-after signal is emitted regardless of
1766 widget_signals[EVENT] =
1767 g_signal_new (I_("event"),
1768 G_TYPE_FROM_CLASS (klass),
1770 G_STRUCT_OFFSET (GtkWidgetClass, event),
1771 _gtk_boolean_handled_accumulator, NULL,
1772 _gtk_marshal_BOOLEAN__BOXED,
1774 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1777 * GtkWidget::event-after:
1778 * @widget: the object which received the signal.
1779 * @event: the #GdkEvent which triggered this signal
1781 * After the emission of the #GtkWidget::event signal and (optionally)
1782 * the second more specific signal, ::event-after will be emitted
1783 * regardless of the previous two signals handlers return values.
1786 widget_signals[EVENT_AFTER] =
1787 g_signal_new (I_("event-after"),
1788 G_TYPE_FROM_CLASS (klass),
1792 _gtk_marshal_VOID__BOXED,
1794 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1797 * GtkWidget::button-press-event:
1798 * @widget: the object which received the signal.
1799 * @event: (type Gdk.EventButton): the #GdkEventButton which triggered
1802 * The ::button-press-event signal will be emitted when a button
1803 * (typically from a mouse) is pressed.
1805 * To receive this signal, the #GdkWindow associated to the
1806 * widget needs to enable the #GDK_BUTTON_PRESS_MASK mask.
1808 * This signal will be sent to the grab widget if there is one.
1810 * Returns: %TRUE to stop other handlers from being invoked for the event.
1811 * %FALSE to propagate the event further.
1813 widget_signals[BUTTON_PRESS_EVENT] =
1814 g_signal_new (I_("button-press-event"),
1815 G_TYPE_FROM_CLASS (klass),
1817 G_STRUCT_OFFSET (GtkWidgetClass, button_press_event),
1818 _gtk_boolean_handled_accumulator, NULL,
1819 _gtk_marshal_BOOLEAN__BOXED,
1821 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1824 * GtkWidget::button-release-event:
1825 * @widget: the object which received the signal.
1826 * @event: (type Gdk.EventButton): the #GdkEventButton which triggered
1829 * The ::button-release-event signal will be emitted when a button
1830 * (typically from a mouse) is released.
1832 * To receive this signal, the #GdkWindow associated to the
1833 * widget needs to enable the #GDK_BUTTON_RELEASE_MASK mask.
1835 * This signal will be sent to the grab widget if there is one.
1837 * Returns: %TRUE to stop other handlers from being invoked for the event.
1838 * %FALSE to propagate the event further.
1840 widget_signals[BUTTON_RELEASE_EVENT] =
1841 g_signal_new (I_("button-release-event"),
1842 G_TYPE_FROM_CLASS (klass),
1844 G_STRUCT_OFFSET (GtkWidgetClass, button_release_event),
1845 _gtk_boolean_handled_accumulator, NULL,
1846 _gtk_marshal_BOOLEAN__BOXED,
1848 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1851 * GtkWidget::scroll-event:
1852 * @widget: the object which received the signal.
1853 * @event: (type Gdk.EventScroll): the #GdkEventScroll which triggered
1856 * The ::scroll-event signal is emitted when a button in the 4 to 7
1857 * range is pressed. Wheel mice are usually configured to generate
1858 * button press events for buttons 4 and 5 when the wheel is turned.
1860 * To receive this signal, the #GdkWindow associated to the widget needs
1861 * to enable the #GDK_BUTTON_PRESS_MASK mask.
1863 * This signal will be sent to the grab widget if there is one.
1865 * Returns: %TRUE to stop other handlers from being invoked for the event.
1866 * %FALSE to propagate the event further.
1868 widget_signals[SCROLL_EVENT] =
1869 g_signal_new (I_("scroll-event"),
1870 G_TYPE_FROM_CLASS (klass),
1872 G_STRUCT_OFFSET (GtkWidgetClass, scroll_event),
1873 _gtk_boolean_handled_accumulator, NULL,
1874 _gtk_marshal_BOOLEAN__BOXED,
1876 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1879 * GtkWidget::motion-notify-event:
1880 * @widget: the object which received the signal.
1881 * @event: (type Gdk.EventMotion): the #GdkEventMotion which triggered
1884 * The ::motion-notify-event signal is emitted when the pointer moves
1885 * over the widget's #GdkWindow.
1887 * To receive this signal, the #GdkWindow associated to the widget
1888 * needs to enable the #GDK_POINTER_MOTION_MASK mask.
1890 * This signal will be sent to the grab widget if there is one.
1892 * Returns: %TRUE to stop other handlers from being invoked for the event.
1893 * %FALSE to propagate the event further.
1895 widget_signals[MOTION_NOTIFY_EVENT] =
1896 g_signal_new (I_("motion-notify-event"),
1897 G_TYPE_FROM_CLASS (klass),
1899 G_STRUCT_OFFSET (GtkWidgetClass, motion_notify_event),
1900 _gtk_boolean_handled_accumulator, NULL,
1901 _gtk_marshal_BOOLEAN__BOXED,
1903 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1906 * GtkWidget::composited-changed:
1907 * @widget: the object on which the signal is emitted
1909 * The ::composited-changed signal is emitted when the composited
1910 * status of @widget<!-- -->s screen changes.
1911 * See gdk_screen_is_composited().
1913 widget_signals[COMPOSITED_CHANGED] =
1914 g_signal_new (I_("composited-changed"),
1915 G_TYPE_FROM_CLASS (klass),
1916 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
1917 G_STRUCT_OFFSET (GtkWidgetClass, composited_changed),
1919 _gtk_marshal_VOID__VOID,
1923 * GtkWidget::delete-event:
1924 * @widget: the object which received the signal
1925 * @event: the event which triggered this signal
1927 * The ::delete-event signal is emitted if a user requests that
1928 * a toplevel window is closed. The default handler for this signal
1929 * destroys the window. Connecting gtk_widget_hide_on_delete() to
1930 * this signal will cause the window to be hidden instead, so that
1931 * it can later be shown again without reconstructing it.
1933 * Returns: %TRUE to stop other handlers from being invoked for the event.
1934 * %FALSE to propagate the event further.
1936 widget_signals[DELETE_EVENT] =
1937 g_signal_new (I_("delete-event"),
1938 G_TYPE_FROM_CLASS (klass),
1940 G_STRUCT_OFFSET (GtkWidgetClass, delete_event),
1941 _gtk_boolean_handled_accumulator, NULL,
1942 _gtk_marshal_BOOLEAN__BOXED,
1944 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1947 * GtkWidget::destroy-event:
1948 * @widget: the object which received the signal.
1949 * @event: the event which triggered this signal
1951 * The ::destroy-event signal is emitted when a #GdkWindow is destroyed.
1952 * You rarely get this signal, because most widgets disconnect themselves
1953 * from their window before they destroy it, so no widget owns the
1954 * window at destroy time.
1956 * To receive this signal, the #GdkWindow associated to the widget needs
1957 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask
1958 * automatically for all new windows.
1960 * Returns: %TRUE to stop other handlers from being invoked for the event.
1961 * %FALSE to propagate the event further.
1963 widget_signals[DESTROY_EVENT] =
1964 g_signal_new (I_("destroy-event"),
1965 G_TYPE_FROM_CLASS (klass),
1967 G_STRUCT_OFFSET (GtkWidgetClass, destroy_event),
1968 _gtk_boolean_handled_accumulator, NULL,
1969 _gtk_marshal_BOOLEAN__BOXED,
1971 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1974 * GtkWidget::key-press-event:
1975 * @widget: the object which received the signal
1976 * @event: (type Gdk.EventKey): the #GdkEventKey which triggered this signal.
1978 * The ::key-press-event signal is emitted when a key is pressed.
1980 * To receive this signal, the #GdkWindow associated to the widget needs
1981 * to enable the #GDK_KEY_PRESS_MASK mask.
1983 * This signal will be sent to the grab widget if there is one.
1985 * Returns: %TRUE to stop other handlers from being invoked for the event.
1986 * %FALSE to propagate the event further.
1988 widget_signals[KEY_PRESS_EVENT] =
1989 g_signal_new (I_("key-press-event"),
1990 G_TYPE_FROM_CLASS (klass),
1992 G_STRUCT_OFFSET (GtkWidgetClass, key_press_event),
1993 _gtk_boolean_handled_accumulator, NULL,
1994 _gtk_marshal_BOOLEAN__BOXED,
1996 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1999 * GtkWidget::key-release-event:
2000 * @widget: the object which received the signal
2001 * @event: (type Gdk.EventKey): the #GdkEventKey which triggered this signal.
2003 * The ::key-release-event signal is emitted when a key is pressed.
2005 * To receive this signal, the #GdkWindow associated to the widget needs
2006 * to enable the #GDK_KEY_RELEASE_MASK mask.
2008 * This signal will be sent to the grab widget if there is one.
2010 * Returns: %TRUE to stop other handlers from being invoked for the event.
2011 * %FALSE to propagate the event further.
2013 widget_signals[KEY_RELEASE_EVENT] =
2014 g_signal_new (I_("key-release-event"),
2015 G_TYPE_FROM_CLASS (klass),
2017 G_STRUCT_OFFSET (GtkWidgetClass, key_release_event),
2018 _gtk_boolean_handled_accumulator, NULL,
2019 _gtk_marshal_BOOLEAN__BOXED,
2021 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2024 * GtkWidget::enter-notify-event:
2025 * @widget: the object which received the signal
2026 * @event: (type Gdk.EventCrossing): the #GdkEventCrossing which triggered
2029 * The ::enter-notify-event will be emitted when the pointer enters
2030 * the @widget's window.
2032 * To receive this signal, the #GdkWindow associated to the widget needs
2033 * to enable the #GDK_ENTER_NOTIFY_MASK mask.
2035 * This signal will be sent to the grab widget if there is one.
2037 * Returns: %TRUE to stop other handlers from being invoked for the event.
2038 * %FALSE to propagate the event further.
2040 widget_signals[ENTER_NOTIFY_EVENT] =
2041 g_signal_new (I_("enter-notify-event"),
2042 G_TYPE_FROM_CLASS (klass),
2044 G_STRUCT_OFFSET (GtkWidgetClass, enter_notify_event),
2045 _gtk_boolean_handled_accumulator, NULL,
2046 _gtk_marshal_BOOLEAN__BOXED,
2048 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2051 * GtkWidget::leave-notify-event:
2052 * @widget: the object which received the signal
2053 * @event: (type Gdk.EventCrossing): the #GdkEventCrossing which triggered
2056 * The ::leave-notify-event will be emitted when the pointer leaves
2057 * the @widget's window.
2059 * To receive this signal, the #GdkWindow associated to the widget needs
2060 * to enable the #GDK_LEAVE_NOTIFY_MASK mask.
2062 * This signal will be sent to the grab widget if there is one.
2064 * Returns: %TRUE to stop other handlers from being invoked for the event.
2065 * %FALSE to propagate the event further.
2067 widget_signals[LEAVE_NOTIFY_EVENT] =
2068 g_signal_new (I_("leave-notify-event"),
2069 G_TYPE_FROM_CLASS (klass),
2071 G_STRUCT_OFFSET (GtkWidgetClass, leave_notify_event),
2072 _gtk_boolean_handled_accumulator, NULL,
2073 _gtk_marshal_BOOLEAN__BOXED,
2075 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2078 * GtkWidget::configure-event:
2079 * @widget: the object which received the signal
2080 * @event: (type Gdk.EventConfigure): the #GdkEventConfigure which triggered
2083 * The ::configure-event signal will be emitted when the size, position or
2084 * stacking of the @widget's window has changed.
2086 * To receive this signal, the #GdkWindow associated to the widget needs
2087 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask
2088 * automatically for all new windows.
2090 * Returns: %TRUE to stop other handlers from being invoked for the event.
2091 * %FALSE to propagate the event further.
2093 widget_signals[CONFIGURE_EVENT] =
2094 g_signal_new (I_("configure-event"),
2095 G_TYPE_FROM_CLASS (klass),
2097 G_STRUCT_OFFSET (GtkWidgetClass, configure_event),
2098 _gtk_boolean_handled_accumulator, NULL,
2099 _gtk_marshal_BOOLEAN__BOXED,
2101 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2104 * GtkWidget::focus-in-event:
2105 * @widget: the object which received the signal
2106 * @event: (type Gdk.EventFocus): the #GdkEventFocus which triggered
2109 * The ::focus-in-event signal will be emitted when the keyboard focus
2110 * enters the @widget's window.
2112 * To receive this signal, the #GdkWindow associated to the widget needs
2113 * to enable the #GDK_FOCUS_CHANGE_MASK mask.
2115 * Returns: %TRUE to stop other handlers from being invoked for the event.
2116 * %FALSE to propagate the event further.
2118 widget_signals[FOCUS_IN_EVENT] =
2119 g_signal_new (I_("focus-in-event"),
2120 G_TYPE_FROM_CLASS (klass),
2122 G_STRUCT_OFFSET (GtkWidgetClass, focus_in_event),
2123 _gtk_boolean_handled_accumulator, NULL,
2124 _gtk_marshal_BOOLEAN__BOXED,
2126 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2129 * GtkWidget::focus-out-event:
2130 * @widget: the object which received the signal
2131 * @event: (type Gdk.EventFocus): the #GdkEventFocus which triggered this
2134 * The ::focus-out-event signal will be emitted when the keyboard focus
2135 * leaves the @widget's window.
2137 * To receive this signal, the #GdkWindow associated to the widget needs
2138 * to enable the #GDK_FOCUS_CHANGE_MASK mask.
2140 * Returns: %TRUE to stop other handlers from being invoked for the event.
2141 * %FALSE to propagate the event further.
2143 widget_signals[FOCUS_OUT_EVENT] =
2144 g_signal_new (I_("focus-out-event"),
2145 G_TYPE_FROM_CLASS (klass),
2147 G_STRUCT_OFFSET (GtkWidgetClass, focus_out_event),
2148 _gtk_boolean_handled_accumulator, NULL,
2149 _gtk_marshal_BOOLEAN__BOXED,
2151 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2154 * GtkWidget::map-event:
2155 * @widget: the object which received the signal
2156 * @event: (type Gdk.EventAny): the #GdkEventAny which triggered this signal.
2158 * The ::map-event signal will be emitted when the @widget's window is
2159 * mapped. A window is mapped when it becomes visible on the screen.
2161 * To receive this signal, the #GdkWindow associated to the widget needs
2162 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask
2163 * automatically for all new windows.
2165 * Returns: %TRUE to stop other handlers from being invoked for the event.
2166 * %FALSE to propagate the event further.
2168 widget_signals[MAP_EVENT] =
2169 g_signal_new (I_("map-event"),
2170 G_TYPE_FROM_CLASS (klass),
2172 G_STRUCT_OFFSET (GtkWidgetClass, map_event),
2173 _gtk_boolean_handled_accumulator, NULL,
2174 _gtk_marshal_BOOLEAN__BOXED,
2176 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2179 * GtkWidget::unmap-event:
2180 * @widget: the object which received the signal
2181 * @event: (type Gdk.EventAny): the #GdkEventAny which triggered this signal
2183 * The ::unmap-event signal may be emitted when the @widget's window is
2184 * unmapped. A window is unmapped when it becomes invisible on the screen.
2186 * For performance reasons GTK+ may not emit ::unmap-event, so one
2187 * should always also implement ::unrealize in order to release
2188 * resources and disconnect signal handlers.
2190 * To receive this signal, the #GdkWindow associated to the widget needs
2191 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask
2192 * automatically for all new windows.
2194 * Returns: %TRUE to stop other handlers from being invoked for the event.
2195 * %FALSE to propagate the event further.
2197 widget_signals[UNMAP_EVENT] =
2198 g_signal_new (I_("unmap-event"),
2199 G_TYPE_FROM_CLASS (klass),
2201 G_STRUCT_OFFSET (GtkWidgetClass, unmap_event),
2202 _gtk_boolean_handled_accumulator, NULL,
2203 _gtk_marshal_BOOLEAN__BOXED,
2205 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2208 * GtkWidget::property-notify-event:
2209 * @widget: the object which received the signal
2210 * @event: (type Gdk.EventProperty): the #GdkEventProperty which triggered
2213 * The ::property-notify-event signal will be emitted when a property on
2214 * the @widget's window has been changed or deleted.
2216 * To receive this signal, the #GdkWindow associated to the widget needs
2217 * to enable the #GDK_PROPERTY_CHANGE_MASK mask.
2219 * Returns: %TRUE to stop other handlers from being invoked for the event.
2220 * %FALSE to propagate the event further.
2222 widget_signals[PROPERTY_NOTIFY_EVENT] =
2223 g_signal_new (I_("property-notify-event"),
2224 G_TYPE_FROM_CLASS (klass),
2226 G_STRUCT_OFFSET (GtkWidgetClass, property_notify_event),
2227 _gtk_boolean_handled_accumulator, NULL,
2228 _gtk_marshal_BOOLEAN__BOXED,
2230 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2233 * GtkWidget::selection-clear-event:
2234 * @widget: the object which received the signal
2235 * @event: (type Gdk.EventSelection): the #GdkEventSelection which triggered
2238 * The ::selection-clear-event signal will be emitted when the
2239 * the @widget's window has lost ownership of a selection.
2241 * Returns: %TRUE to stop other handlers from being invoked for the event.
2242 * %FALSE to propagate the event further.
2244 widget_signals[SELECTION_CLEAR_EVENT] =
2245 g_signal_new (I_("selection-clear-event"),
2246 G_TYPE_FROM_CLASS (klass),
2248 G_STRUCT_OFFSET (GtkWidgetClass, selection_clear_event),
2249 _gtk_boolean_handled_accumulator, NULL,
2250 _gtk_marshal_BOOLEAN__BOXED,
2252 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2255 * GtkWidget::selection-request-event:
2256 * @widget: the object which received the signal
2257 * @event: (type Gdk.EventSelection): the #GdkEventSelection which triggered
2260 * The ::selection-request-event signal will be emitted when
2261 * another client requests ownership of the selection owned by
2262 * the @widget's window.
2264 * Returns: %TRUE to stop other handlers from being invoked for the event.
2265 * %FALSE to propagate the event further.
2267 widget_signals[SELECTION_REQUEST_EVENT] =
2268 g_signal_new (I_("selection-request-event"),
2269 G_TYPE_FROM_CLASS (klass),
2271 G_STRUCT_OFFSET (GtkWidgetClass, selection_request_event),
2272 _gtk_boolean_handled_accumulator, NULL,
2273 _gtk_marshal_BOOLEAN__BOXED,
2275 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2278 * GtkWidget::selection-notify-event:
2279 * @widget: the object which received the signal.
2282 * Returns: %TRUE to stop other handlers from being invoked for the event. %FALSE to propagate the event further.
2284 widget_signals[SELECTION_NOTIFY_EVENT] =
2285 g_signal_new (I_("selection-notify-event"),
2286 G_TYPE_FROM_CLASS (klass),
2288 G_STRUCT_OFFSET (GtkWidgetClass, selection_notify_event),
2289 _gtk_boolean_handled_accumulator, NULL,
2290 _gtk_marshal_BOOLEAN__BOXED,
2292 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2295 * GtkWidget::selection-received:
2296 * @widget: the object which received the signal.
2300 widget_signals[SELECTION_RECEIVED] =
2301 g_signal_new (I_("selection-received"),
2302 G_TYPE_FROM_CLASS (klass),
2304 G_STRUCT_OFFSET (GtkWidgetClass, selection_received),
2306 _gtk_marshal_VOID__BOXED_UINT,
2308 GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
2312 * GtkWidget::selection-get:
2313 * @widget: the object which received the signal.
2318 widget_signals[SELECTION_GET] =
2319 g_signal_new (I_("selection-get"),
2320 G_TYPE_FROM_CLASS (klass),
2322 G_STRUCT_OFFSET (GtkWidgetClass, selection_get),
2324 _gtk_marshal_VOID__BOXED_UINT_UINT,
2326 GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
2331 * GtkWidget::proximity-in-event:
2332 * @widget: the object which received the signal
2333 * @event: (type Gdk.EventProximity): the #GdkEventProximity which triggered
2336 * To receive this signal the #GdkWindow associated to the widget needs
2337 * to enable the #GDK_PROXIMITY_IN_MASK mask.
2339 * This signal will be sent to the grab widget if there is one.
2341 * Returns: %TRUE to stop other handlers from being invoked for the event.
2342 * %FALSE to propagate the event further.
2344 widget_signals[PROXIMITY_IN_EVENT] =
2345 g_signal_new (I_("proximity-in-event"),
2346 G_TYPE_FROM_CLASS (klass),
2348 G_STRUCT_OFFSET (GtkWidgetClass, proximity_in_event),
2349 _gtk_boolean_handled_accumulator, NULL,
2350 _gtk_marshal_BOOLEAN__BOXED,
2352 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2355 * GtkWidget::proximity-out-event:
2356 * @widget: the object which received the signal
2357 * @event: (type Gdk.EventProximity): the #GdkEventProximity which triggered
2360 * To receive this signal the #GdkWindow associated to the widget needs
2361 * to enable the #GDK_PROXIMITY_OUT_MASK mask.
2363 * This signal will be sent to the grab widget if there is one.
2365 * Returns: %TRUE to stop other handlers from being invoked for the event.
2366 * %FALSE to propagate the event further.
2368 widget_signals[PROXIMITY_OUT_EVENT] =
2369 g_signal_new (I_("proximity-out-event"),
2370 G_TYPE_FROM_CLASS (klass),
2372 G_STRUCT_OFFSET (GtkWidgetClass, proximity_out_event),
2373 _gtk_boolean_handled_accumulator, NULL,
2374 _gtk_marshal_BOOLEAN__BOXED,
2376 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2379 * GtkWidget::drag-leave:
2380 * @widget: the object which received the signal.
2381 * @drag_context: the drag context
2382 * @time: the timestamp of the motion event
2384 * The ::drag-leave signal is emitted on the drop site when the cursor
2385 * leaves the widget. A typical reason to connect to this signal is to
2386 * undo things done in #GtkWidget::drag-motion, e.g. undo highlighting
2387 * with gtk_drag_unhighlight()
2389 widget_signals[DRAG_LEAVE] =
2390 g_signal_new (I_("drag-leave"),
2391 G_TYPE_FROM_CLASS (klass),
2393 G_STRUCT_OFFSET (GtkWidgetClass, drag_leave),
2395 _gtk_marshal_VOID__OBJECT_UINT,
2397 GDK_TYPE_DRAG_CONTEXT,
2401 * GtkWidget::drag-begin:
2402 * @widget: the object which received the signal
2403 * @drag_context: the drag context
2405 * The ::drag-begin signal is emitted on the drag source when a drag is
2406 * started. A typical reason to connect to this signal is to set up a
2407 * custom drag icon with gtk_drag_source_set_icon().
2409 * Note that some widgets set up a drag icon in the default handler of
2410 * this signal, so you may have to use g_signal_connect_after() to
2411 * override what the default handler did.
2413 widget_signals[DRAG_BEGIN] =
2414 g_signal_new (I_("drag-begin"),
2415 G_TYPE_FROM_CLASS (klass),
2417 G_STRUCT_OFFSET (GtkWidgetClass, drag_begin),
2419 _gtk_marshal_VOID__OBJECT,
2421 GDK_TYPE_DRAG_CONTEXT);
2424 * GtkWidget::drag-end:
2425 * @widget: the object which received the signal
2426 * @drag_context: the drag context
2428 * The ::drag-end signal is emitted on the drag source when a drag is
2429 * finished. A typical reason to connect to this signal is to undo
2430 * things done in #GtkWidget::drag-begin.
2432 widget_signals[DRAG_END] =
2433 g_signal_new (I_("drag-end"),
2434 G_TYPE_FROM_CLASS (klass),
2436 G_STRUCT_OFFSET (GtkWidgetClass, drag_end),
2438 _gtk_marshal_VOID__OBJECT,
2440 GDK_TYPE_DRAG_CONTEXT);
2443 * GtkWidget::drag-data-delete:
2444 * @widget: the object which received the signal
2445 * @drag_context: the drag context
2447 * The ::drag-data-delete signal is emitted on the drag source when a drag
2448 * with the action %GDK_ACTION_MOVE is successfully completed. The signal
2449 * handler is responsible for deleting the data that has been dropped. What
2450 * "delete" means depends on the context of the drag operation.
2452 widget_signals[DRAG_DATA_DELETE] =
2453 g_signal_new (I_("drag-data-delete"),
2454 G_TYPE_FROM_CLASS (klass),
2456 G_STRUCT_OFFSET (GtkWidgetClass, drag_data_delete),
2458 _gtk_marshal_VOID__OBJECT,
2460 GDK_TYPE_DRAG_CONTEXT);
2463 * GtkWidget::drag-failed:
2464 * @widget: the object which received the signal
2465 * @drag_context: the drag context
2466 * @result: the result of the drag operation
2468 * The ::drag-failed signal is emitted on the drag source when a drag has
2469 * failed. The signal handler may hook custom code to handle a failed DND
2470 * operation based on the type of error, it returns %TRUE is the failure has
2471 * been already handled (not showing the default "drag operation failed"
2472 * animation), otherwise it returns %FALSE.
2474 * Return value: %TRUE if the failed drag operation has been already handled.
2478 widget_signals[DRAG_FAILED] =
2479 g_signal_new (I_("drag-failed"),
2480 G_TYPE_FROM_CLASS (klass),
2482 0, _gtk_boolean_handled_accumulator, NULL,
2483 _gtk_marshal_BOOLEAN__OBJECT_ENUM,
2485 GDK_TYPE_DRAG_CONTEXT,
2486 GTK_TYPE_DRAG_RESULT);
2489 * GtkWidget::drag-motion:
2490 * @widget: the object which received the signal
2491 * @drag_context: the drag context
2492 * @x: the x coordinate of the current cursor position
2493 * @y: the y coordinate of the current cursor position
2494 * @time: the timestamp of the motion event
2495 * @returns: whether the cursor position is in a drop zone
2497 * The drag-motion signal is emitted on the drop site when the user
2498 * moves the cursor over the widget during a drag. The signal handler
2499 * must determine whether the cursor position is in a drop zone or not.
2500 * If it is not in a drop zone, it returns %FALSE and no further processing
2501 * is necessary. Otherwise, the handler returns %TRUE. In this case, the
2502 * handler is responsible for providing the necessary information for
2503 * displaying feedback to the user, by calling gdk_drag_status().
2505 * If the decision whether the drop will be accepted or rejected can't be
2506 * made based solely on the cursor position and the type of the data, the
2507 * handler may inspect the dragged data by calling gtk_drag_get_data() and
2508 * defer the gdk_drag_status() call to the #GtkWidget::drag-data-received
2509 * handler. Note that you cannot not pass #GTK_DEST_DEFAULT_DROP,
2510 * #GTK_DEST_DEFAULT_MOTION or #GTK_DEST_DEFAULT_ALL to gtk_drag_dest_set()
2511 * when using the drag-motion signal that way.
2513 * Also note that there is no drag-enter signal. The drag receiver has to
2514 * keep track of whether he has received any drag-motion signals since the
2515 * last #GtkWidget::drag-leave and if not, treat the drag-motion signal as
2516 * an "enter" signal. Upon an "enter", the handler will typically highlight
2517 * the drop site with gtk_drag_highlight().
2520 * drag_motion (GtkWidget *widget,
2521 * GdkDragContext *context,
2528 * PrivateData *private_data = GET_PRIVATE_DATA (widget);
2530 * if (!private_data->drag_highlight)
2532 * private_data->drag_highlight = 1;
2533 * gtk_drag_highlight (widget);
2536 * target = gtk_drag_dest_find_target (widget, context, NULL);
2537 * if (target == GDK_NONE)
2538 * gdk_drag_status (context, 0, time);
2541 * private_data->pending_status = context->suggested_action;
2542 * gtk_drag_get_data (widget, context, target, time);
2549 * drag_data_received (GtkWidget *widget,
2550 * GdkDragContext *context,
2553 * GtkSelectionData *selection_data,
2557 * PrivateData *private_data = GET_PRIVATE_DATA (widget);
2559 * if (private_data->suggested_action)
2561 * private_data->suggested_action = 0;
2563 * /* We are getting this data due to a request in drag_motion,
2564 * * rather than due to a request in drag_drop, so we are just
2565 * * supposed to call gdk_drag_status (), not actually paste in
2568 * str = gtk_selection_data_get_text (selection_data);
2569 * if (!data_is_acceptable (str))
2570 * gdk_drag_status (context, 0, time);
2572 * gdk_drag_status (context, private_data->suggested_action, time);
2576 * /* accept the drop */
2581 widget_signals[DRAG_MOTION] =
2582 g_signal_new (I_("drag-motion"),
2583 G_TYPE_FROM_CLASS (klass),
2585 G_STRUCT_OFFSET (GtkWidgetClass, drag_motion),
2586 _gtk_boolean_handled_accumulator, NULL,
2587 _gtk_marshal_BOOLEAN__OBJECT_INT_INT_UINT,
2589 GDK_TYPE_DRAG_CONTEXT,
2595 * GtkWidget::drag-drop:
2596 * @widget: the object which received the signal
2597 * @drag_context: the drag context
2598 * @x: the x coordinate of the current cursor position
2599 * @y: the y coordinate of the current cursor position
2600 * @time: the timestamp of the motion event
2601 * @returns: whether the cursor position is in a drop zone
2603 * The ::drag-drop signal is emitted on the drop site when the user drops
2604 * the data onto the widget. The signal handler must determine whether
2605 * the cursor position is in a drop zone or not. If it is not in a drop
2606 * zone, it returns %FALSE and no further processing is necessary.
2607 * Otherwise, the handler returns %TRUE. In this case, the handler must
2608 * ensure that gtk_drag_finish() is called to let the source know that
2609 * the drop is done. The call to gtk_drag_finish() can be done either
2610 * directly or in a #GtkWidget::drag-data-received handler which gets
2611 * triggered by calling gtk_drag_get_data() to receive the data for one
2612 * or more of the supported targets.
2614 widget_signals[DRAG_DROP] =
2615 g_signal_new (I_("drag-drop"),
2616 G_TYPE_FROM_CLASS (klass),
2618 G_STRUCT_OFFSET (GtkWidgetClass, drag_drop),
2619 _gtk_boolean_handled_accumulator, NULL,
2620 _gtk_marshal_BOOLEAN__OBJECT_INT_INT_UINT,
2622 GDK_TYPE_DRAG_CONTEXT,
2628 * GtkWidget::drag-data-get:
2629 * @widget: the object which received the signal
2630 * @drag_context: the drag context
2631 * @data: the #GtkSelectionData to be filled with the dragged data
2632 * @info: the info that has been registered with the target in the
2634 * @time: the timestamp at which the data was requested
2636 * The ::drag-data-get signal is emitted on the drag source when the drop
2637 * site requests the data which is dragged. It is the responsibility of
2638 * the signal handler to fill @data with the data in the format which
2639 * is indicated by @info. See gtk_selection_data_set() and
2640 * gtk_selection_data_set_text().
2642 widget_signals[DRAG_DATA_GET] =
2643 g_signal_new (I_("drag-data-get"),
2644 G_TYPE_FROM_CLASS (klass),
2646 G_STRUCT_OFFSET (GtkWidgetClass, drag_data_get),
2648 _gtk_marshal_VOID__OBJECT_BOXED_UINT_UINT,
2650 GDK_TYPE_DRAG_CONTEXT,
2651 GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
2656 * GtkWidget::drag-data-received:
2657 * @widget: the object which received the signal
2658 * @drag_context: the drag context
2659 * @x: where the drop happened
2660 * @y: where the drop happened
2661 * @data: the received data
2662 * @info: the info that has been registered with the target in the
2664 * @time: the timestamp at which the data was received
2666 * The ::drag-data-received signal is emitted on the drop site when the
2667 * dragged data has been received. If the data was received in order to
2668 * determine whether the drop will be accepted, the handler is expected
2669 * to call gdk_drag_status() and <emphasis>not</emphasis> finish the drag.
2670 * If the data was received in response to a #GtkWidget::drag-drop signal
2671 * (and this is the last target to be received), the handler for this
2672 * signal is expected to process the received data and then call
2673 * gtk_drag_finish(), setting the @success parameter depending on whether
2674 * the data was processed successfully.
2676 * The handler may inspect and modify @drag_context->action before calling
2677 * gtk_drag_finish(), e.g. to implement %GDK_ACTION_ASK as shown in the
2678 * following example:
2681 * drag_data_received (GtkWidget *widget,
2682 * GdkDragContext *drag_context,
2685 * GtkSelectionData *data,
2689 * if ((data->length >= 0) && (data->format == 8))
2691 * if (drag_context->action == GDK_ACTION_ASK)
2693 * GtkWidget *dialog;
2696 * dialog = gtk_message_dialog_new (NULL,
2697 * GTK_DIALOG_MODAL |
2698 * GTK_DIALOG_DESTROY_WITH_PARENT,
2700 * GTK_BUTTONS_YES_NO,
2701 * "Move the data ?\n");
2702 * response = gtk_dialog_run (GTK_DIALOG (dialog));
2703 * gtk_widget_destroy (dialog);
2705 * if (response == GTK_RESPONSE_YES)
2706 * drag_context->action = GDK_ACTION_MOVE;
2708 * drag_context->action = GDK_ACTION_COPY;
2711 * gtk_drag_finish (drag_context, TRUE, FALSE, time);
2715 * gtk_drag_finish (drag_context, FALSE, FALSE, time);
2719 widget_signals[DRAG_DATA_RECEIVED] =
2720 g_signal_new (I_("drag-data-received"),
2721 G_TYPE_FROM_CLASS (klass),
2723 G_STRUCT_OFFSET (GtkWidgetClass, drag_data_received),
2725 _gtk_marshal_VOID__OBJECT_INT_INT_BOXED_UINT_UINT,
2727 GDK_TYPE_DRAG_CONTEXT,
2730 GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
2735 * GtkWidget::visibility-notify-event:
2736 * @widget: the object which received the signal
2737 * @event: (type Gdk.EventVisibility): the #GdkEventVisibility which
2738 * triggered this signal.
2740 * The ::visibility-notify-event will be emitted when the @widget's window
2741 * is obscured or unobscured.
2743 * To receive this signal the #GdkWindow associated to the widget needs
2744 * to enable the #GDK_VISIBILITY_NOTIFY_MASK mask.
2746 * Returns: %TRUE to stop other handlers from being invoked for the event.
2747 * %FALSE to propagate the event further.
2749 widget_signals[VISIBILITY_NOTIFY_EVENT] =
2750 g_signal_new (I_("visibility-notify-event"),
2751 G_TYPE_FROM_CLASS (klass),
2753 G_STRUCT_OFFSET (GtkWidgetClass, visibility_notify_event),
2754 _gtk_boolean_handled_accumulator, NULL,
2755 _gtk_marshal_BOOLEAN__BOXED,
2757 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2760 * GtkWidget::client-event:
2761 * @widget: the object which received the signal
2762 * @event: (type Gdk.EventClient): the #GdkEventClient which triggered
2765 * The ::client-event will be emitted when the @widget's window
2766 * receives a message (via a ClientMessage event) from another
2769 * Returns: %TRUE to stop other handlers from being invoked for
2770 * the event. %FALSE to propagate the event further.
2772 widget_signals[CLIENT_EVENT] =
2773 g_signal_new (I_("client-event"),
2774 G_TYPE_FROM_CLASS (klass),
2776 G_STRUCT_OFFSET (GtkWidgetClass, client_event),
2777 _gtk_boolean_handled_accumulator, NULL,
2778 _gtk_marshal_BOOLEAN__BOXED,
2780 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2783 * GtkWidget::no-expose-event:
2784 * @widget: the object which received the signal
2785 * @event: (type Gdk.EventNoExpose): the #GdkEventNoExpose which triggered
2788 * The ::no-expose-event will be emitted when the @widget's window is
2789 * drawn as a copy of another #GdkDrawable which was completely unobscured.
2790 * If the source window was partially obscured #GdkEventExpose events will
2791 * be generated for those areas.
2793 * Returns: %TRUE to stop other handlers from being invoked for the event.
2794 * %FALSE to propagate the event further.
2796 widget_signals[NO_EXPOSE_EVENT] =
2797 g_signal_new (I_("no-expose-event"),
2798 G_TYPE_FROM_CLASS (klass),
2800 G_STRUCT_OFFSET (GtkWidgetClass, no_expose_event),
2801 _gtk_boolean_handled_accumulator, NULL,
2802 _gtk_marshal_BOOLEAN__BOXED,
2804 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2807 * GtkWidget::window-state-event:
2808 * @widget: the object which received the signal
2809 * @event: (type Gdk.EventWindowState): the #GdkEventWindowState which
2810 * triggered this signal.
2812 * The ::window-state-event will be emitted when the state of the
2813 * toplevel window associated to the @widget changes.
2815 * To receive this signal the #GdkWindow associated to the widget
2816 * needs to enable the #GDK_STRUCTURE_MASK mask. GDK will enable
2817 * this mask automatically for all new windows.
2819 * Returns: %TRUE to stop other handlers from being invoked for the
2820 * event. %FALSE to propagate the event further.
2822 widget_signals[WINDOW_STATE_EVENT] =
2823 g_signal_new (I_("window-state-event"),
2824 G_TYPE_FROM_CLASS (klass),
2826 G_STRUCT_OFFSET (GtkWidgetClass, window_state_event),
2827 _gtk_boolean_handled_accumulator, NULL,
2828 _gtk_marshal_BOOLEAN__BOXED,
2830 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2833 * GtkWidget::damage-event:
2834 * @widget: the object which received the signal
2835 * @event: the #GdkEventExpose event
2837 * Emitted when a redirected window belonging to @widget gets drawn into.
2838 * The region/area members of the event shows what area of the redirected
2839 * drawable was drawn into.
2841 * Returns: %TRUE to stop other handlers from being invoked for the event.
2842 * %FALSE to propagate the event further.
2846 widget_signals[DAMAGE_EVENT] =
2847 g_signal_new (I_("damage-event"),
2848 G_TYPE_FROM_CLASS (klass),
2850 G_STRUCT_OFFSET (GtkWidgetClass, damage_event),
2851 _gtk_boolean_handled_accumulator, NULL,
2852 _gtk_marshal_BOOLEAN__BOXED,
2854 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2857 * GtkWidget::grab-broken-event:
2858 * @widget: the object which received the signal
2859 * @event: the #GdkEventGrabBroken event
2861 * Emitted when a pointer or keyboard grab on a window belonging
2862 * to @widget gets broken.
2864 * On X11, this happens when the grab window becomes unviewable
2865 * (i.e. it or one of its ancestors is unmapped), or if the same
2866 * application grabs the pointer or keyboard again.
2868 * Returns: %TRUE to stop other handlers from being invoked for
2869 * the event. %FALSE to propagate the event further.
2873 widget_signals[GRAB_BROKEN_EVENT] =
2874 g_signal_new (I_("grab-broken-event"),
2875 G_TYPE_FROM_CLASS (klass),
2877 G_STRUCT_OFFSET (GtkWidgetClass, grab_broken_event),
2878 _gtk_boolean_handled_accumulator, NULL,
2879 _gtk_marshal_BOOLEAN__BOXED,
2881 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
2884 * GtkWidget::query-tooltip:
2885 * @widget: the object which received the signal
2886 * @x: the x coordinate of the cursor position where the request has
2887 * been emitted, relative to @widget->window
2888 * @y: the y coordinate of the cursor position where the request has
2889 * been emitted, relative to @widget->window
2890 * @keyboard_mode: %TRUE if the tooltip was trigged using the keyboard
2891 * @tooltip: a #GtkTooltip
2893 * Emitted when #GtkWidget:has-tooltip is %TRUE and the #GtkSettings:gtk-tooltip-timeout
2894 * has expired with the cursor hovering "above" @widget; or emitted when @widget got
2895 * focus in keyboard mode.
2897 * Using the given coordinates, the signal handler should determine
2898 * whether a tooltip should be shown for @widget. If this is the case
2899 * %TRUE should be returned, %FALSE otherwise. Note that if
2900 * @keyboard_mode is %TRUE, the values of @x and @y are undefined and
2901 * should not be used.
2903 * The signal handler is free to manipulate @tooltip with the therefore
2904 * destined function calls.
2906 * Returns: %TRUE if @tooltip should be shown right now, %FALSE otherwise.
2910 widget_signals[QUERY_TOOLTIP] =
2911 g_signal_new (I_("query-tooltip"),
2912 G_TYPE_FROM_CLASS (klass),
2914 G_STRUCT_OFFSET (GtkWidgetClass, query_tooltip),
2915 _gtk_boolean_handled_accumulator, NULL,
2916 _gtk_marshal_BOOLEAN__INT_INT_BOOLEAN_OBJECT,
2924 * GtkWidget::popup-menu
2925 * @widget: the object which received the signal
2927 * This signal gets emitted whenever a widget should pop up a context
2928 * menu. This usually happens through the standard key binding mechanism;
2929 * by pressing a certain key while a widget is focused, the user can cause
2930 * the widget to pop up a menu. For example, the #GtkEntry widget creates
2931 * a menu with clipboard commands. See <xref linkend="checklist-popup-menu"/>
2932 * for an example of how to use this signal.
2934 * Returns: %TRUE if a menu was activated
2936 widget_signals[POPUP_MENU] =
2937 g_signal_new (I_("popup-menu"),
2938 G_TYPE_FROM_CLASS (klass),
2939 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
2940 G_STRUCT_OFFSET (GtkWidgetClass, popup_menu),
2941 _gtk_boolean_handled_accumulator, NULL,
2942 _gtk_marshal_BOOLEAN__VOID,
2946 * GtkWidget::show-help:
2947 * @widget: the object which received the signal.
2950 widget_signals[SHOW_HELP] =
2951 g_signal_new (I_("show-help"),
2952 G_TYPE_FROM_CLASS (klass),
2953 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
2954 G_STRUCT_OFFSET (GtkWidgetClass, show_help),
2955 _gtk_boolean_handled_accumulator, NULL,
2956 _gtk_marshal_BOOLEAN__ENUM,
2958 GTK_TYPE_WIDGET_HELP_TYPE);
2961 * GtkWidget::accel-closures-changed:
2962 * @widget: the object which received the signal.
2964 widget_signals[ACCEL_CLOSURES_CHANGED] =
2965 g_signal_new (I_("accel-closures-changed"),
2966 G_TYPE_FROM_CLASS (klass),
2970 _gtk_marshal_VOID__VOID,
2974 * GtkWidget::screen-changed:
2975 * @widget: the object on which the signal is emitted
2976 * @previous_screen: (allow-none): the previous screen, or %NULL if the
2977 * widget was not associated with a screen before
2979 * The ::screen-changed signal gets emitted when the
2980 * screen of a widget has changed.
2982 widget_signals[SCREEN_CHANGED] =
2983 g_signal_new (I_("screen-changed"),
2984 G_TYPE_FROM_CLASS (klass),
2986 G_STRUCT_OFFSET (GtkWidgetClass, screen_changed),
2988 _gtk_marshal_VOID__OBJECT,
2993 * GtkWidget::can-activate-accel:
2994 * @widget: the object which received the signal
2995 * @signal_id: the ID of a signal installed on @widget
2997 * Determines whether an accelerator that activates the signal
2998 * identified by @signal_id can currently be activated.
2999 * This signal is present to allow applications and derived
3000 * widgets to override the default #GtkWidget handling
3001 * for determining whether an accelerator can be activated.
3003 * Returns: %TRUE if the signal can be activated.
3005 widget_signals[CAN_ACTIVATE_ACCEL] =
3006 g_signal_new (I_("can-activate-accel"),
3007 G_TYPE_FROM_CLASS (klass),
3009 G_STRUCT_OFFSET (GtkWidgetClass, can_activate_accel),
3010 _gtk_boolean_handled_accumulator, NULL,
3011 _gtk_marshal_BOOLEAN__UINT,
3012 G_TYPE_BOOLEAN, 1, G_TYPE_UINT);
3014 binding_set = gtk_binding_set_by_class (klass);
3015 gtk_binding_entry_add_signal (binding_set, GDK_KEY_F10, GDK_SHIFT_MASK,
3017 gtk_binding_entry_add_signal (binding_set, GDK_KEY_Menu, 0,
3020 gtk_binding_entry_add_signal (binding_set, GDK_KEY_F1, GDK_CONTROL_MASK,
3022 GTK_TYPE_WIDGET_HELP_TYPE,
3023 GTK_WIDGET_HELP_TOOLTIP);
3024 gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_F1, GDK_CONTROL_MASK,
3026 GTK_TYPE_WIDGET_HELP_TYPE,
3027 GTK_WIDGET_HELP_TOOLTIP);
3028 gtk_binding_entry_add_signal (binding_set, GDK_KEY_F1, GDK_SHIFT_MASK,
3030 GTK_TYPE_WIDGET_HELP_TYPE,
3031 GTK_WIDGET_HELP_WHATS_THIS);
3032 gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_F1, GDK_SHIFT_MASK,
3034 GTK_TYPE_WIDGET_HELP_TYPE,
3035 GTK_WIDGET_HELP_WHATS_THIS);
3037 gtk_widget_class_install_style_property (klass,
3038 g_param_spec_boolean ("interior-focus",
3039 P_("Interior Focus"),
3040 P_("Whether to draw the focus indicator inside widgets"),
3042 GTK_PARAM_READABLE));
3044 gtk_widget_class_install_style_property (klass,
3045 g_param_spec_int ("focus-line-width",
3046 P_("Focus linewidth"),
3047 P_("Width, in pixels, of the focus indicator line"),
3049 GTK_PARAM_READABLE));
3051 gtk_widget_class_install_style_property (klass,
3052 g_param_spec_string ("focus-line-pattern",
3053 P_("Focus line dash pattern"),
3054 P_("Dash pattern used to draw the focus indicator"),
3056 GTK_PARAM_READABLE));
3057 gtk_widget_class_install_style_property (klass,
3058 g_param_spec_int ("focus-padding",
3059 P_("Focus padding"),
3060 P_("Width, in pixels, between focus indicator and the widget 'box'"),
3062 GTK_PARAM_READABLE));
3063 gtk_widget_class_install_style_property (klass,
3064 g_param_spec_boxed ("cursor-color",
3066 P_("Color with which to draw insertion cursor"),
3068 GTK_PARAM_READABLE));
3069 gtk_widget_class_install_style_property (klass,
3070 g_param_spec_boxed ("secondary-cursor-color",
3071 P_("Secondary cursor color"),
3072 P_("Color with which to draw the secondary insertion cursor when editing mixed right-to-left and left-to-right text"),
3074 GTK_PARAM_READABLE));
3075 gtk_widget_class_install_style_property (klass,
3076 g_param_spec_float ("cursor-aspect-ratio",
3077 P_("Cursor line aspect ratio"),
3078 P_("Aspect ratio with which to draw insertion cursor"),
3080 GTK_PARAM_READABLE));
3082 gtk_widget_class_install_style_property (klass,
3083 g_param_spec_boolean ("window-dragging",
3084 P_("Window dragging"),
3085 P_("Whether windows can be dragged by clicking on empty areas"),
3087 GTK_PARAM_READABLE));
3090 * GtkWidget:link-color:
3092 * The "link-color" style property defines the color of unvisited links.
3096 gtk_widget_class_install_style_property (klass,
3097 g_param_spec_boxed ("link-color",
3098 P_("Unvisited Link Color"),
3099 P_("Color of unvisited links"),
3101 GTK_PARAM_READABLE));
3104 * GtkWidget:visited-link-color:
3106 * The "visited-link-color" style property defines the color of visited links.
3110 gtk_widget_class_install_style_property (klass,
3111 g_param_spec_boxed ("visited-link-color",
3112 P_("Visited Link Color"),
3113 P_("Color of visited links"),
3115 GTK_PARAM_READABLE));
3118 * GtkWidget:wide-separators:
3120 * The "wide-separators" style property defines whether separators have
3121 * configurable width and should be drawn using a box instead of a line.
3125 gtk_widget_class_install_style_property (klass,
3126 g_param_spec_boolean ("wide-separators",
3127 P_("Wide Separators"),
3128 P_("Whether separators have configurable width and should be drawn using a box instead of a line"),
3130 GTK_PARAM_READABLE));
3133 * GtkWidget:separator-width:
3135 * The "separator-width" style property defines the width of separators.
3136 * This property only takes effect if #GtkWidget:wide-separators is %TRUE.
3140 gtk_widget_class_install_style_property (klass,
3141 g_param_spec_int ("separator-width",
3142 P_("Separator Width"),
3143 P_("The width of separators if wide-separators is TRUE"),
3145 GTK_PARAM_READABLE));
3148 * GtkWidget:separator-height:
3150 * The "separator-height" style property defines the height of separators.
3151 * This property only takes effect if #GtkWidget:wide-separators is %TRUE.
3155 gtk_widget_class_install_style_property (klass,
3156 g_param_spec_int ("separator-height",
3157 P_("Separator Height"),
3158 P_("The height of separators if \"wide-separators\" is TRUE"),
3160 GTK_PARAM_READABLE));
3163 * GtkWidget:scroll-arrow-hlength:
3165 * The "scroll-arrow-hlength" style property defines the length of
3166 * horizontal scroll arrows.
3170 gtk_widget_class_install_style_property (klass,
3171 g_param_spec_int ("scroll-arrow-hlength",
3172 P_("Horizontal Scroll Arrow Length"),
3173 P_("The length of horizontal scroll arrows"),
3175 GTK_PARAM_READABLE));
3178 * GtkWidget:scroll-arrow-vlength:
3180 * The "scroll-arrow-vlength" style property defines the length of
3181 * vertical scroll arrows.
3185 gtk_widget_class_install_style_property (klass,
3186 g_param_spec_int ("scroll-arrow-vlength",
3187 P_("Vertical Scroll Arrow Length"),
3188 P_("The length of vertical scroll arrows"),
3190 GTK_PARAM_READABLE));
3192 g_type_class_add_private (klass, sizeof (GtkWidgetPrivate));
3196 gtk_widget_base_class_finalize (GtkWidgetClass *klass)
3200 list = g_param_spec_pool_list_owned (style_property_spec_pool, G_OBJECT_CLASS_TYPE (klass));
3201 for (node = list; node; node = node->next)
3203 GParamSpec *pspec = node->data;
3205 g_param_spec_pool_remove (style_property_spec_pool, pspec);
3206 g_param_spec_unref (pspec);
3212 gtk_widget_set_property (GObject *object,
3214 const GValue *value,
3217 GtkWidget *widget = GTK_WIDGET (object);
3222 gchar *tooltip_markup;
3223 const gchar *tooltip_text;
3224 GtkWindow *tooltip_window;
3227 gtk_widget_set_name (widget, g_value_get_string (value));
3230 gtk_container_add (GTK_CONTAINER (g_value_get_object (value)), widget);
3232 case PROP_WIDTH_REQUEST:
3233 gtk_widget_set_usize_internal (widget, g_value_get_int (value), -2, 0);
3235 case PROP_HEIGHT_REQUEST:
3236 gtk_widget_set_usize_internal (widget, -2, g_value_get_int (value), 0);
3239 gtk_widget_set_visible (widget, g_value_get_boolean (value));
3241 case PROP_SENSITIVE:
3242 gtk_widget_set_sensitive (widget, g_value_get_boolean (value));
3244 case PROP_APP_PAINTABLE:
3245 gtk_widget_set_app_paintable (widget, g_value_get_boolean (value));
3247 case PROP_CAN_FOCUS:
3248 gtk_widget_set_can_focus (widget, g_value_get_boolean (value));
3250 case PROP_HAS_FOCUS:
3251 if (g_value_get_boolean (value))
3252 gtk_widget_grab_focus (widget);
3255 if (g_value_get_boolean (value))
3256 gtk_widget_grab_focus (widget);
3258 case PROP_CAN_DEFAULT:
3259 gtk_widget_set_can_default (widget, g_value_get_boolean (value));
3261 case PROP_HAS_DEFAULT:
3262 if (g_value_get_boolean (value))
3263 gtk_widget_grab_default (widget);
3265 case PROP_RECEIVES_DEFAULT:
3266 gtk_widget_set_receives_default (widget, g_value_get_boolean (value));
3269 gtk_widget_set_style (widget, g_value_get_object (value));
3272 if (!gtk_widget_get_realized (widget) && gtk_widget_get_has_window (widget))
3273 gtk_widget_set_events (widget, g_value_get_flags (value));
3275 case PROP_EXTENSION_EVENTS:
3276 gtk_widget_set_extension_events (widget, g_value_get_enum (value));
3278 case PROP_NO_SHOW_ALL:
3279 gtk_widget_set_no_show_all (widget, g_value_get_boolean (value));
3281 case PROP_HAS_TOOLTIP:
3282 gtk_widget_real_set_has_tooltip (widget,
3283 g_value_get_boolean (value), FALSE);
3285 case PROP_TOOLTIP_MARKUP:
3286 tooltip_window = g_object_get_qdata (object, quark_tooltip_window);
3287 tooltip_markup = g_value_dup_string (value);
3289 /* Treat an empty string as a NULL string,
3290 * because an empty string would be useless for a tooltip:
3292 if (tooltip_markup && (strlen (tooltip_markup) == 0))
3294 g_free (tooltip_markup);
3295 tooltip_markup = NULL;
3298 g_object_set_qdata_full (object, quark_tooltip_markup,
3299 tooltip_markup, g_free);
3301 tmp = (tooltip_window != NULL || tooltip_markup != NULL);
3302 gtk_widget_real_set_has_tooltip (widget, tmp, FALSE);
3303 if (gtk_widget_get_visible (widget))
3304 gtk_widget_queue_tooltip_query (widget);
3306 case PROP_TOOLTIP_TEXT:
3307 tooltip_window = g_object_get_qdata (object, quark_tooltip_window);
3309 tooltip_text = g_value_get_string (value);
3311 /* Treat an empty string as a NULL string,
3312 * because an empty string would be useless for a tooltip:
3314 if (tooltip_text && (strlen (tooltip_text) == 0))
3315 tooltip_text = NULL;
3317 tooltip_markup = tooltip_text ? g_markup_escape_text (tooltip_text, -1) : NULL;
3319 g_object_set_qdata_full (object, quark_tooltip_markup,
3320 tooltip_markup, g_free);
3322 tmp = (tooltip_window != NULL || tooltip_markup != NULL);
3323 gtk_widget_real_set_has_tooltip (widget, tmp, FALSE);
3324 if (gtk_widget_get_visible (widget))
3325 gtk_widget_queue_tooltip_query (widget);
3327 case PROP_DOUBLE_BUFFERED:
3328 gtk_widget_set_double_buffered (widget, g_value_get_boolean (value));
3331 gtk_widget_set_halign (widget, g_value_get_enum (value));
3334 gtk_widget_set_valign (widget, g_value_get_enum (value));
3336 case PROP_MARGIN_LEFT:
3337 gtk_widget_set_margin_left (widget, g_value_get_int (value));
3339 case PROP_MARGIN_RIGHT:
3340 gtk_widget_set_margin_right (widget, g_value_get_int (value));
3342 case PROP_MARGIN_TOP:
3343 gtk_widget_set_margin_top (widget, g_value_get_int (value));
3345 case PROP_MARGIN_BOTTOM:
3346 gtk_widget_set_margin_bottom (widget, g_value_get_int (value));
3349 g_object_freeze_notify (G_OBJECT (widget));
3350 gtk_widget_set_margin_left (widget, g_value_get_int (value));
3351 gtk_widget_set_margin_right (widget, g_value_get_int (value));
3352 gtk_widget_set_margin_top (widget, g_value_get_int (value));
3353 gtk_widget_set_margin_bottom (widget, g_value_get_int (value));
3354 g_object_thaw_notify (G_OBJECT (widget));
3357 gtk_widget_set_hexpand (widget, g_value_get_boolean (value));
3359 case PROP_HEXPAND_SET:
3360 gtk_widget_set_hexpand_set (widget, g_value_get_boolean (value));
3363 gtk_widget_set_vexpand (widget, g_value_get_boolean (value));
3365 case PROP_VEXPAND_SET:
3366 gtk_widget_set_vexpand_set (widget, g_value_get_boolean (value));
3369 g_object_freeze_notify (G_OBJECT (widget));
3370 gtk_widget_set_hexpand (widget, g_value_get_boolean (value));
3371 gtk_widget_set_vexpand (widget, g_value_get_boolean (value));
3372 g_object_thaw_notify (G_OBJECT (widget));
3375 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3381 gtk_widget_get_property (GObject *object,
3386 GtkWidget *widget = GTK_WIDGET (object);
3387 GtkWidgetPrivate *priv = widget->priv;
3396 g_value_set_string (value, priv->name);
3398 g_value_set_static_string (value, "");
3401 g_value_set_object (value, priv->parent);
3403 case PROP_WIDTH_REQUEST:
3406 gtk_widget_get_size_request (widget, &w, NULL);
3407 g_value_set_int (value, w);
3410 case PROP_HEIGHT_REQUEST:
3413 gtk_widget_get_size_request (widget, NULL, &h);
3414 g_value_set_int (value, h);
3418 g_value_set_boolean (value, (gtk_widget_get_visible (widget) != FALSE));
3420 case PROP_SENSITIVE:
3421 g_value_set_boolean (value, (gtk_widget_get_sensitive (widget) != FALSE));
3423 case PROP_APP_PAINTABLE:
3424 g_value_set_boolean (value, (gtk_widget_get_app_paintable (widget) != FALSE));
3426 case PROP_CAN_FOCUS:
3427 g_value_set_boolean (value, (gtk_widget_get_can_focus (widget) != FALSE));
3429 case PROP_HAS_FOCUS:
3430 g_value_set_boolean (value, (gtk_widget_has_focus (widget) != FALSE));
3433 g_value_set_boolean (value, (gtk_widget_is_focus (widget)));
3435 case PROP_CAN_DEFAULT:
3436 g_value_set_boolean (value, (gtk_widget_get_can_default (widget) != FALSE));
3438 case PROP_HAS_DEFAULT:
3439 g_value_set_boolean (value, (gtk_widget_has_default (widget) != FALSE));
3441 case PROP_RECEIVES_DEFAULT:
3442 g_value_set_boolean (value, (gtk_widget_get_receives_default (widget) != FALSE));
3444 case PROP_COMPOSITE_CHILD:
3445 g_value_set_boolean (value, widget->priv->composite_child);
3448 g_value_set_object (value, gtk_widget_get_style (widget));
3451 eventp = g_object_get_qdata (G_OBJECT (widget), quark_event_mask);
3452 g_value_set_flags (value, GPOINTER_TO_INT (eventp));
3454 case PROP_EXTENSION_EVENTS:
3455 modep = g_object_get_qdata (G_OBJECT (widget), quark_extension_event_mode);
3456 g_value_set_enum (value, GPOINTER_TO_INT (modep));
3458 case PROP_NO_SHOW_ALL:
3459 g_value_set_boolean (value, gtk_widget_get_no_show_all (widget));
3461 case PROP_HAS_TOOLTIP:
3462 g_value_set_boolean (value, GPOINTER_TO_UINT (g_object_get_qdata (object, quark_has_tooltip)));
3464 case PROP_TOOLTIP_TEXT:
3466 gchar *escaped = g_object_get_qdata (object, quark_tooltip_markup);
3469 if (escaped && !pango_parse_markup (escaped, -1, 0, NULL, &text, NULL, NULL))
3470 g_assert (NULL == text); /* text should still be NULL in case of markup errors */
3472 g_value_take_string (value, text);
3475 case PROP_TOOLTIP_MARKUP:
3476 g_value_set_string (value, g_object_get_qdata (object, quark_tooltip_markup));
3479 g_value_set_object (value, gtk_widget_get_window (widget));
3481 case PROP_DOUBLE_BUFFERED:
3482 g_value_set_boolean (value, gtk_widget_get_double_buffered (widget));
3485 g_value_set_enum (value, gtk_widget_get_halign (widget));
3488 g_value_set_enum (value, gtk_widget_get_valign (widget));
3490 case PROP_MARGIN_LEFT:
3491 g_value_set_int (value, gtk_widget_get_margin_left (widget));
3493 case PROP_MARGIN_RIGHT:
3494 g_value_set_int (value, gtk_widget_get_margin_right (widget));
3496 case PROP_MARGIN_TOP:
3497 g_value_set_int (value, gtk_widget_get_margin_top (widget));
3499 case PROP_MARGIN_BOTTOM:
3500 g_value_set_int (value, gtk_widget_get_margin_bottom (widget));
3504 GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (widget, FALSE);
3505 if (aux_info == NULL)
3507 g_value_set_int (value, 0);
3511 g_value_set_int (value, MAX (MAX (aux_info->margin.left,
3512 aux_info->margin.right),
3513 MAX (aux_info->margin.top,
3514 aux_info->margin.bottom)));
3519 g_value_set_boolean (value, gtk_widget_get_hexpand (widget));
3521 case PROP_HEXPAND_SET:
3522 g_value_set_boolean (value, gtk_widget_get_hexpand_set (widget));
3525 g_value_set_boolean (value, gtk_widget_get_vexpand (widget));
3527 case PROP_VEXPAND_SET:
3528 g_value_set_boolean (value, gtk_widget_get_vexpand_set (widget));
3531 g_value_set_boolean (value,
3532 gtk_widget_get_hexpand (widget) &&
3533 gtk_widget_get_vexpand (widget));
3536 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3542 gtk_widget_init (GtkWidget *widget)
3544 GtkWidgetPrivate *priv;
3546 widget->priv = G_TYPE_INSTANCE_GET_PRIVATE (widget,
3549 priv = widget->priv;
3551 priv->child_visible = TRUE;
3552 priv->state = GTK_STATE_NORMAL;
3553 priv->saved_state = GTK_STATE_NORMAL;
3555 priv->allocation.x = -1;
3556 priv->allocation.y = -1;
3557 priv->allocation.width = 1;
3558 priv->allocation.height = 1;
3559 priv->window = NULL;
3560 priv->parent = NULL;
3562 priv->sensitive = TRUE;
3563 priv->parent_sensitive = TRUE;
3564 priv->composite_child = composite_child_stack != 0;
3565 priv->double_buffered = TRUE;
3566 priv->redraw_on_alloc = TRUE;
3567 priv->width_request_needed = TRUE;
3568 priv->height_request_needed = TRUE;
3569 priv->alloc_needed = TRUE;
3571 /* this will be set to TRUE if the widget gets a child or if the
3572 * expand flag is set on the widget, but until one of those happen
3573 * we know the expand is already properly FALSE.
3575 * We really want to default FALSE here to avoid computing expand
3576 * all over the place while initially building a widget tree.
3578 priv->need_compute_expand = FALSE;
3580 priv->style = gtk_widget_get_default_style ();
3581 g_object_ref (priv->style);
3586 gtk_widget_dispatch_child_properties_changed (GtkWidget *widget,
3588 GParamSpec **pspecs)
3590 GtkWidgetPrivate *priv = widget->priv;
3591 GtkWidget *container = priv->parent;
3594 for (i = 0; widget->priv->parent == container && i < n_pspecs; i++)
3595 g_signal_emit (widget, widget_signals[CHILD_NOTIFY], g_quark_from_string (pspecs[i]->name), pspecs[i]);
3599 * gtk_widget_freeze_child_notify:
3600 * @widget: a #GtkWidget
3602 * Stops emission of #GtkWidget::child-notify signals on @widget. The
3603 * signals are queued until gtk_widget_thaw_child_notify() is called
3606 * This is the analogue of g_object_freeze_notify() for child properties.
3609 gtk_widget_freeze_child_notify (GtkWidget *widget)
3611 g_return_if_fail (GTK_IS_WIDGET (widget));
3613 if (!G_OBJECT (widget)->ref_count)
3616 g_object_ref (widget);
3617 g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
3618 g_object_unref (widget);
3622 * gtk_widget_child_notify:
3623 * @widget: a #GtkWidget
3624 * @child_property: the name of a child property installed on the
3625 * class of @widget<!-- -->'s parent
3627 * Emits a #GtkWidget::child-notify signal for the
3628 * <link linkend="child-properties">child property</link> @child_property
3631 * This is the analogue of g_object_notify() for child properties.
3634 gtk_widget_child_notify (GtkWidget *widget,
3635 const gchar *child_property)
3637 GtkWidgetPrivate *priv = widget->priv;
3640 g_return_if_fail (GTK_IS_WIDGET (widget));
3641 g_return_if_fail (child_property != NULL);
3642 if (!G_OBJECT (widget)->ref_count || !priv->parent)
3645 g_object_ref (widget);
3646 pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool,
3648 G_OBJECT_TYPE (priv->parent),
3651 g_warning ("%s: container class `%s' has no child property named `%s'",
3653 G_OBJECT_TYPE_NAME (priv->parent),
3657 GObjectNotifyQueue *nqueue = g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
3659 g_object_notify_queue_add (G_OBJECT (widget), nqueue, pspec);
3660 g_object_notify_queue_thaw (G_OBJECT (widget), nqueue);
3662 g_object_unref (widget);
3666 * gtk_widget_thaw_child_notify:
3667 * @widget: a #GtkWidget
3669 * Reverts the effect of a previous call to gtk_widget_freeze_child_notify().
3670 * This causes all queued #GtkWidget::child-notify signals on @widget to be
3674 gtk_widget_thaw_child_notify (GtkWidget *widget)
3676 GObjectNotifyQueue *nqueue;
3678 g_return_if_fail (GTK_IS_WIDGET (widget));
3680 if (!G_OBJECT (widget)->ref_count)
3683 g_object_ref (widget);
3684 nqueue = g_object_notify_queue_from_object (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
3685 if (!nqueue || !nqueue->freeze_count)
3686 g_warning (G_STRLOC ": child-property-changed notification for %s(%p) is not frozen",
3687 G_OBJECT_TYPE_NAME (widget), widget);
3689 g_object_notify_queue_thaw (G_OBJECT (widget), nqueue);
3690 g_object_unref (widget);
3696 * @type: type ID of the widget to create
3697 * @first_property_name: name of first property to set
3698 * @Varargs: value of first property, followed by more properties,
3701 * This is a convenience function for creating a widget and setting
3702 * its properties in one go. For example you might write:
3703 * <literal>gtk_widget_new (GTK_TYPE_LABEL, "label", "Hello World", "xalign",
3704 * 0.0, NULL)</literal> to create a left-aligned label. Equivalent to
3705 * g_object_new(), but returns a widget so you don't have to
3706 * cast the object yourself.
3708 * Return value: a new #GtkWidget of type @widget_type
3711 gtk_widget_new (GType type,
3712 const gchar *first_property_name,
3718 g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), NULL);
3720 va_start (var_args, first_property_name);
3721 widget = (GtkWidget *)g_object_new_valist (type, first_property_name, var_args);
3728 gtk_widget_queue_draw_child (GtkWidget *widget)
3730 GtkWidgetPrivate *priv = widget->priv;
3733 parent = priv->parent;
3734 if (parent && gtk_widget_is_drawable (parent))
3735 gtk_widget_queue_draw_area (parent,
3738 priv->allocation.width,
3739 priv->allocation.height);
3743 * gtk_widget_unparent:
3744 * @widget: a #GtkWidget
3746 * This function is only for use in widget implementations.
3747 * Should be called by implementations of the remove method
3748 * on #GtkContainer, to dissociate a child from the container.
3751 gtk_widget_unparent (GtkWidget *widget)
3753 GtkWidgetPrivate *priv;
3754 GObjectNotifyQueue *nqueue;
3755 GtkWidget *toplevel;
3756 GtkWidget *old_parent;
3758 g_return_if_fail (GTK_IS_WIDGET (widget));
3760 priv = widget->priv;
3762 if (priv->parent == NULL)
3765 /* keep this function in sync with gtk_menu_detach()
3768 g_object_freeze_notify (G_OBJECT (widget));
3769 nqueue = g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
3771 toplevel = gtk_widget_get_toplevel (widget);
3772 if (gtk_widget_is_toplevel (toplevel))
3773 _gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
3775 if (gtk_container_get_focus_child (GTK_CONTAINER (priv->parent)) == widget)
3776 gtk_container_set_focus_child (GTK_CONTAINER (priv->parent), NULL);
3778 /* If we are unanchoring the child, we save around the toplevel
3779 * to emit hierarchy changed
3781 if (priv->parent->priv->anchored)
3782 g_object_ref (toplevel);
3786 gtk_widget_queue_draw_child (widget);
3788 /* Reset the width and height here, to force reallocation if we
3789 * get added back to a new parent. This won't work if our new
3790 * allocation is smaller than 1x1 and we actually want a size of 1x1...
3791 * (would 0x0 be OK here?)
3793 priv->allocation.width = 1;
3794 priv->allocation.height = 1;
3796 if (gtk_widget_get_realized (widget))
3798 if (priv->in_reparent)
3799 gtk_widget_unmap (widget);
3801 gtk_widget_unrealize (widget);
3804 /* Removing a widget from a container restores the child visible
3805 * flag to the default state, so it doesn't affect the child
3806 * in the next parent.
3808 priv->child_visible = TRUE;
3810 old_parent = priv->parent;
3811 priv->parent = NULL;
3812 gtk_widget_set_parent_window (widget, NULL);
3814 /* parent may no longer expand if the removed
3815 * child was expand=TRUE and could therefore
3818 if (gtk_widget_get_visible (widget) &&
3819 (priv->need_compute_expand ||
3820 priv->computed_hexpand ||
3821 priv->computed_vexpand))
3823 gtk_widget_queue_compute_expand (old_parent);
3826 g_signal_emit (widget, widget_signals[PARENT_SET], 0, old_parent);
3829 _gtk_widget_propagate_hierarchy_changed (widget, toplevel);
3830 g_object_unref (toplevel);
3833 g_object_notify (G_OBJECT (widget), "parent");
3834 g_object_thaw_notify (G_OBJECT (widget));
3836 g_object_notify_queue_clear (G_OBJECT (widget), nqueue);
3837 g_object_notify_queue_thaw (G_OBJECT (widget), nqueue);
3838 g_object_unref (widget);
3842 * gtk_widget_destroy:
3843 * @widget: a #GtkWidget
3845 * Destroys a widget.
3848 * destroyed, it will break any references it holds to other objects.
3849 * If the widget is inside a container, the widget will be removed
3850 * from the container. If the widget is a toplevel (derived from
3851 * #GtkWindow), it will be removed from the list of toplevels, and the
3852 * reference GTK+ holds to it will be removed. Removing a
3853 * widget from its container or the list of toplevels results in the
3854 * widget being finalized, unless you've added additional references
3855 * to the widget with g_object_ref().
3857 * In most cases, only toplevel widgets (windows) require explicit
3858 * destruction, because when you destroy a toplevel its children will
3859 * be destroyed as well.
3862 gtk_widget_destroy (GtkWidget *widget)
3864 g_return_if_fail (GTK_IS_WIDGET (widget));
3866 if (!widget->priv->in_destruction)
3867 g_object_run_dispose (G_OBJECT (widget));
3871 * gtk_widget_destroyed:
3872 * @widget: a #GtkWidget
3873 * @widget_pointer: (inout) (transfer none): address of a variable that contains @widget
3875 * This function sets *@widget_pointer to %NULL if @widget_pointer !=
3876 * %NULL. It's intended to be used as a callback connected to the
3877 * "destroy" signal of a widget. You connect gtk_widget_destroyed()
3878 * as a signal handler, and pass the address of your widget variable
3879 * as user data. Then when the widget is destroyed, the variable will
3880 * be set to %NULL. Useful for example to avoid multiple copies
3881 * of the same dialog.
3884 gtk_widget_destroyed (GtkWidget *widget,
3885 GtkWidget **widget_pointer)
3887 /* Don't make any assumptions about the
3889 * Even check widget_pointer.
3892 *widget_pointer = NULL;
3897 * @widget: a #GtkWidget
3899 * Flags a widget to be displayed. Any widget that isn't shown will
3900 * not appear on the screen. If you want to show all the widgets in a
3901 * container, it's easier to call gtk_widget_show_all() on the
3902 * container, instead of individually showing the widgets.
3904 * Remember that you have to show the containers containing a widget,
3905 * in addition to the widget itself, before it will appear onscreen.
3907 * When a toplevel container is shown, it is immediately realized and
3908 * mapped; other shown widgets are realized and mapped when their
3909 * toplevel container is realized and mapped.
3912 gtk_widget_show (GtkWidget *widget)
3914 g_return_if_fail (GTK_IS_WIDGET (widget));
3916 if (!gtk_widget_get_visible (widget))
3918 g_object_ref (widget);
3919 if (!gtk_widget_is_toplevel (widget))
3920 gtk_widget_queue_resize (widget);
3922 /* see comment in set_parent() for why this should and can be
3925 if (widget->priv->need_compute_expand ||
3926 widget->priv->computed_hexpand ||
3927 widget->priv->computed_vexpand)
3929 if (widget->priv->parent != NULL)
3930 gtk_widget_queue_compute_expand (widget->priv->parent);
3933 g_signal_emit (widget, widget_signals[SHOW], 0);
3934 g_object_notify (G_OBJECT (widget), "visible");
3935 g_object_unref (widget);
3940 gtk_widget_real_show (GtkWidget *widget)
3942 GtkWidgetPrivate *priv = widget->priv;
3944 if (!gtk_widget_get_visible (widget))
3946 priv->visible = TRUE;
3949 gtk_widget_get_mapped (priv->parent) &&
3950 gtk_widget_get_child_visible (widget) &&
3951 !gtk_widget_get_mapped (widget))
3952 gtk_widget_map (widget);
3957 gtk_widget_show_map_callback (GtkWidget *widget, GdkEvent *event, gint *flag)
3960 g_signal_handlers_disconnect_by_func (widget,
3961 gtk_widget_show_map_callback,
3966 * gtk_widget_show_now:
3967 * @widget: a #GtkWidget
3969 * Shows a widget. If the widget is an unmapped toplevel widget
3970 * (i.e. a #GtkWindow that has not yet been shown), enter the main
3971 * loop and wait for the window to actually be mapped. Be careful;
3972 * because the main loop is running, anything can happen during
3976 gtk_widget_show_now (GtkWidget *widget)
3980 g_return_if_fail (GTK_IS_WIDGET (widget));
3982 /* make sure we will get event */
3983 if (!gtk_widget_get_mapped (widget) &&
3984 gtk_widget_is_toplevel (widget))
3986 gtk_widget_show (widget);
3988 g_signal_connect (widget, "map-event",
3989 G_CALLBACK (gtk_widget_show_map_callback),
3993 gtk_main_iteration ();
3996 gtk_widget_show (widget);
4001 * @widget: a #GtkWidget
4003 * Reverses the effects of gtk_widget_show(), causing the widget to be
4004 * hidden (invisible to the user).
4007 gtk_widget_hide (GtkWidget *widget)
4009 g_return_if_fail (GTK_IS_WIDGET (widget));
4011 if (gtk_widget_get_visible (widget))
4013 GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
4015 g_object_ref (widget);
4016 if (toplevel != widget && gtk_widget_is_toplevel (toplevel))
4017 _gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
4019 /* a parent may now be expand=FALSE since we're hidden. */
4020 if (widget->priv->need_compute_expand ||
4021 widget->priv->computed_hexpand ||
4022 widget->priv->computed_vexpand)
4024 gtk_widget_queue_compute_expand (widget);
4027 g_signal_emit (widget, widget_signals[HIDE], 0);
4028 if (!gtk_widget_is_toplevel (widget))
4029 gtk_widget_queue_resize (widget);
4030 g_object_notify (G_OBJECT (widget), "visible");
4031 g_object_unref (widget);
4036 gtk_widget_real_hide (GtkWidget *widget)
4038 if (gtk_widget_get_visible (widget))
4040 widget->priv->visible = FALSE;
4042 if (gtk_widget_get_mapped (widget))
4043 gtk_widget_unmap (widget);
4048 * gtk_widget_hide_on_delete:
4049 * @widget: a #GtkWidget
4051 * Utility function; intended to be connected to the #GtkWidget::delete-event
4052 * signal on a #GtkWindow. The function calls gtk_widget_hide() on its
4053 * argument, then returns %TRUE. If connected to ::delete-event, the
4054 * result is that clicking the close button for a window (on the
4055 * window frame, top right corner usually) will hide but not destroy
4056 * the window. By default, GTK+ destroys windows when ::delete-event
4059 * Return value: %TRUE
4062 gtk_widget_hide_on_delete (GtkWidget *widget)
4064 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
4066 gtk_widget_hide (widget);
4072 * gtk_widget_show_all:
4073 * @widget: a #GtkWidget
4075 * Recursively shows a widget, and any child widgets (if the widget is
4079 gtk_widget_show_all (GtkWidget *widget)
4081 GtkWidgetClass *class;
4083 g_return_if_fail (GTK_IS_WIDGET (widget));
4085 if (gtk_widget_get_no_show_all (widget))
4088 class = GTK_WIDGET_GET_CLASS (widget);
4090 if (class->show_all)
4091 class->show_all (widget);
4096 * @widget: a #GtkWidget
4098 * This function is only for use in widget implementations. Causes
4099 * a widget to be mapped if it isn't already.
4102 gtk_widget_map (GtkWidget *widget)
4104 GtkWidgetPrivate *priv;
4106 g_return_if_fail (GTK_IS_WIDGET (widget));
4107 g_return_if_fail (gtk_widget_get_visible (widget));
4108 g_return_if_fail (gtk_widget_get_child_visible (widget));
4110 priv = widget->priv;
4112 if (!gtk_widget_get_mapped (widget))
4114 if (!gtk_widget_get_realized (widget))
4115 gtk_widget_realize (widget);
4117 g_signal_emit (widget, widget_signals[MAP], 0);
4119 if (!gtk_widget_get_has_window (widget))
4120 gdk_window_invalidate_rect (priv->window, &priv->allocation, FALSE);
4126 * @widget: a #GtkWidget
4128 * This function is only for use in widget implementations. Causes
4129 * a widget to be unmapped if it's currently mapped.
4132 gtk_widget_unmap (GtkWidget *widget)
4134 GtkWidgetPrivate *priv;
4136 g_return_if_fail (GTK_IS_WIDGET (widget));
4138 priv = widget->priv;
4140 if (gtk_widget_get_mapped (widget))
4142 if (!gtk_widget_get_has_window (widget))
4143 gdk_window_invalidate_rect (priv->window, &priv->allocation, FALSE);
4144 _gtk_tooltip_hide (widget);
4145 g_signal_emit (widget, widget_signals[UNMAP], 0);
4150 gtk_widget_set_extension_events_internal (GtkWidget *widget,
4151 GdkExtensionMode mode,
4154 GtkWidgetPrivate *priv = widget->priv;
4155 GList *free_list = NULL;
4158 if (window_list == NULL)
4160 if (gtk_widget_get_has_window (widget))
4161 window_list = g_list_prepend (NULL, priv->window);
4163 window_list = gdk_window_get_children (priv->window);
4165 free_list = window_list;
4168 for (l = window_list; l != NULL; l = l->next)
4170 GdkWindow *window = l->data;
4173 gdk_window_get_user_data (window, &user_data);
4174 if (user_data == widget)
4178 gdk_input_set_extension_events (window,
4179 gdk_window_get_events (window),
4182 children = gdk_window_get_children (window);
4185 gtk_widget_set_extension_events_internal (widget, mode, children);
4186 g_list_free (children);
4192 g_list_free (free_list);
4196 _gtk_widget_enable_device_events (GtkWidget *widget)
4198 GHashTable *device_events;
4199 GHashTableIter iter;
4200 gpointer key, value;
4202 device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
4207 g_hash_table_iter_init (&iter, device_events);
4209 while (g_hash_table_iter_next (&iter, &key, &value))
4212 GdkEventMask event_mask;
4215 event_mask = GPOINTER_TO_UINT (value);
4216 gtk_widget_add_events_internal (widget, device, event_mask);
4221 * gtk_widget_realize:
4222 * @widget: a #GtkWidget
4224 * Creates the GDK (windowing system) resources associated with a
4225 * widget. For example, @widget->window will be created when a widget
4226 * is realized. Normally realization happens implicitly; if you show
4227 * a widget and all its parent containers, then the widget will be
4228 * realized and mapped automatically.
4230 * Realizing a widget requires all
4231 * the widget's parent widgets to be realized; calling
4232 * gtk_widget_realize() realizes the widget's parents in addition to
4233 * @widget itself. If a widget is not yet inside a toplevel window
4234 * when you realize it, bad things will happen.
4236 * This function is primarily used in widget implementations, and
4237 * isn't very useful otherwise. Many times when you think you might
4238 * need it, a better approach is to connect to a signal that will be
4239 * called after the widget is realized automatically, such as
4240 * GtkWidget::expose-event. Or simply g_signal_connect () to the
4241 * GtkWidget::realize signal.
4244 gtk_widget_realize (GtkWidget *widget)
4246 GtkWidgetPrivate *priv;
4247 GdkExtensionMode mode;
4248 cairo_region_t *region;
4250 g_return_if_fail (GTK_IS_WIDGET (widget));
4251 g_return_if_fail (widget->priv->anchored ||
4252 GTK_IS_INVISIBLE (widget));
4254 priv = widget->priv;
4256 if (!gtk_widget_get_realized (widget))
4259 if (GTK_IS_CONTAINER (widget) && gtk_widget_get_has_window (widget))
4260 g_message ("gtk_widget_realize(%s)", G_OBJECT_TYPE_NAME (widget));
4263 if (priv->parent == NULL &&
4264 !gtk_widget_is_toplevel (widget))
4265 g_warning ("Calling gtk_widget_realize() on a widget that isn't "
4266 "inside a toplevel window is not going to work very well. "
4267 "Widgets must be inside a toplevel container before realizing them.");
4269 if (priv->parent && !gtk_widget_get_realized (priv->parent))
4270 gtk_widget_realize (priv->parent);
4272 gtk_widget_ensure_style (widget);
4274 g_signal_emit (widget, widget_signals[REALIZE], 0);
4276 gtk_widget_real_set_has_tooltip (widget,
4277 GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (widget), quark_has_tooltip)),
4280 if (priv->has_shape_mask)
4282 region = g_object_get_qdata (G_OBJECT (widget), quark_shape_info);
4283 gdk_window_shape_combine_region (priv->window, region, 0, 0);
4286 region = g_object_get_qdata (G_OBJECT (widget), quark_input_shape_info);
4288 gdk_window_input_shape_combine_region (priv->window, region, 0, 0);
4290 mode = gtk_widget_get_extension_events (widget);
4291 if (mode != GDK_EXTENSION_EVENTS_NONE)
4292 gtk_widget_set_extension_events_internal (widget, mode, NULL);
4294 if (priv->multidevice)
4295 gdk_window_set_support_multidevice (priv->window, TRUE);
4297 _gtk_widget_enable_device_events (widget);
4302 * gtk_widget_unrealize:
4303 * @widget: a #GtkWidget
4305 * This function is only useful in widget implementations.
4306 * Causes a widget to be unrealized (frees all GDK resources
4307 * associated with the widget, such as @widget->window).
4310 gtk_widget_unrealize (GtkWidget *widget)
4312 g_return_if_fail (GTK_IS_WIDGET (widget));
4314 if (widget->priv->has_shape_mask)
4315 gtk_widget_shape_combine_region (widget, NULL);
4317 if (g_object_get_qdata (G_OBJECT (widget), quark_input_shape_info))
4318 gtk_widget_input_shape_combine_region (widget, NULL);
4320 if (gtk_widget_get_realized (widget))
4322 g_object_ref (widget);
4323 _gtk_tooltip_hide (widget);
4324 g_signal_emit (widget, widget_signals[UNREALIZE], 0);
4325 gtk_widget_set_realized (widget, FALSE);
4326 gtk_widget_set_mapped (widget, FALSE);
4327 g_object_unref (widget);
4331 /*****************************************
4333 *****************************************/
4336 * gtk_widget_queue_draw_region:
4337 * @widget: a #GtkWidget
4338 * @region: region to draw
4340 * Invalidates the rectangular area of @widget defined by @region by
4341 * calling gdk_window_invalidate_region() on the widget's window and
4342 * all its child windows. Once the main loop becomes idle (after the
4343 * current batch of events has been processed, roughly), the window
4344 * will receive expose events for the union of all regions that have
4347 * Normally you would only use this function in widget
4348 * implementations. You might also use it to schedule a redraw of a
4349 * #GtkDrawingArea or some portion thereof.
4352 gtk_widget_queue_draw_region (GtkWidget *widget,
4353 cairo_region_t *region)
4355 GtkWidgetPrivate *priv;
4358 g_return_if_fail (GTK_IS_WIDGET (widget));
4360 priv = widget->priv;
4362 if (!gtk_widget_get_realized (widget))
4365 /* Just return if the widget or one of its ancestors isn't mapped */
4366 for (w = widget; w != NULL; w = w->priv->parent)
4367 if (!gtk_widget_get_mapped (w))
4370 gdk_window_invalidate_region (priv->window, region, TRUE);
4374 * gtk_widget_queue_draw_area:
4375 * @widget: a #GtkWidget
4376 * @x: x coordinate of upper-left corner of rectangle to redraw
4377 * @y: y coordinate of upper-left corner of rectangle to redraw
4378 * @width: width of region to draw
4379 * @height: height of region to draw
4381 * Convenience function that calls gtk_widget_queue_draw_region() on
4382 * the region created from the given coordinates.
4385 gtk_widget_queue_draw_area (GtkWidget *widget,
4392 cairo_region_t *region;
4394 g_return_if_fail (GTK_IS_WIDGET (widget));
4399 rect.height = height;
4401 region = cairo_region_create_rectangle (&rect);
4402 gtk_widget_queue_draw_region (widget, region);
4403 cairo_region_destroy (region);
4407 * gtk_widget_queue_draw:
4408 * @widget: a #GtkWidget
4410 * Equivalent to calling gtk_widget_queue_draw_area() for the
4411 * entire area of a widget.
4414 gtk_widget_queue_draw (GtkWidget *widget)
4418 g_return_if_fail (GTK_IS_WIDGET (widget));
4420 gtk_widget_get_allocation (widget, &rect);
4422 if (!gtk_widget_get_has_window (widget))
4423 gtk_widget_queue_draw_area (widget,
4424 rect.x, rect.y, rect.width, rect.height);
4426 gtk_widget_queue_draw_area (widget,
4427 0, 0, rect.width, rect.height);
4431 * gtk_widget_queue_resize:
4432 * @widget: a #GtkWidget
4434 * This function is only for use in widget implementations.
4435 * Flags a widget to have its size renegotiated; should
4436 * be called when a widget for some reason has a new size request.
4437 * For example, when you change the text in a #GtkLabel, #GtkLabel
4438 * queues a resize to ensure there's enough space for the new text.
4441 gtk_widget_queue_resize (GtkWidget *widget)
4443 g_return_if_fail (GTK_IS_WIDGET (widget));
4445 if (gtk_widget_get_realized (widget))
4446 gtk_widget_queue_shallow_draw (widget);
4448 _gtk_size_group_queue_resize (widget, 0);
4452 * gtk_widget_queue_resize_no_redraw:
4453 * @widget: a #GtkWidget
4455 * This function works like gtk_widget_queue_resize(),
4456 * except that the widget is not invalidated.
4461 gtk_widget_queue_resize_no_redraw (GtkWidget *widget)
4463 g_return_if_fail (GTK_IS_WIDGET (widget));
4465 _gtk_size_group_queue_resize (widget, 0);
4469 * gtk_widget_size_request:
4470 * @widget: a #GtkWidget
4471 * @requisition: (out): a #GtkRequisition to be filled in
4473 * This function is typically used when implementing a #GtkContainer
4474 * subclass. Obtains the preferred size of a widget. The container
4475 * uses this information to arrange its child widgets and decide what
4476 * size allocations to give them with gtk_widget_size_allocate().
4478 * You can also call this function from an application, with some
4479 * caveats. Most notably, getting a size request requires the widget
4480 * to be associated with a screen, because font information may be
4481 * needed. Multihead-aware applications should keep this in mind.
4483 * Also remember that the size request is not necessarily the size
4484 * a widget will actually be allocated.
4486 * Deprecated: 3.0: Use gtk_widget_get_preferred_size() instead.
4489 gtk_widget_size_request (GtkWidget *widget,
4490 GtkRequisition *requisition)
4492 g_return_if_fail (GTK_IS_WIDGET (widget));
4494 gtk_widget_get_preferred_size (widget, requisition, NULL);
4498 * gtk_widget_get_child_requisition:
4499 * @widget: a #GtkWidget
4500 * @requisition: (out): a #GtkRequisition to be filled in
4502 * This function is only for use in widget implementations. Obtains
4503 * @widget->requisition, unless someone has forced a particular
4504 * geometry on the widget (e.g. with gtk_widget_set_size_request()),
4505 * in which case it returns that geometry instead of the widget's
4508 * This function differs from gtk_widget_size_request() in that
4509 * it retrieves the last size request value from @widget->requisition,
4510 * while gtk_widget_size_request() actually calls the "size_request" method
4511 * on @widget to compute the size request and fill in @widget->requisition,
4512 * and only then returns @widget->requisition.
4514 * Because this function does not call the "size_request" method, it
4515 * can only be used when you know that @widget->requisition is
4516 * up-to-date, that is, gtk_widget_size_request() has been called
4517 * since the last time a resize was queued. In general, only container
4518 * implementations have this information; applications should use
4519 * gtk_widget_size_request().
4522 * Deprecated: 3.0: Use gtk_widget_get_preferred_size() instead.
4525 gtk_widget_get_child_requisition (GtkWidget *widget,
4526 GtkRequisition *requisition)
4528 gtk_widget_get_preferred_size (widget, requisition, NULL);
4532 invalidate_predicate (GdkWindow *window,
4537 gdk_window_get_user_data (window, &user_data);
4539 return (user_data == data);
4542 /* Invalidate @region in widget->window and all children
4543 * of widget->window owned by widget. @region is in the
4544 * same coordinates as widget->allocation and will be
4545 * modified by this call.
4548 gtk_widget_invalidate_widget_windows (GtkWidget *widget,
4549 cairo_region_t *region)
4551 GtkWidgetPrivate *priv = widget->priv;
4553 if (!gtk_widget_get_realized (widget))
4556 if (gtk_widget_get_has_window (widget) && priv->parent)
4560 gdk_window_get_position (priv->window, &x, &y);
4561 cairo_region_translate (region, -x, -y);
4564 gdk_window_invalidate_maybe_recurse (priv->window, region,
4565 invalidate_predicate, widget);
4569 * gtk_widget_queue_shallow_draw:
4570 * @widget: a #GtkWidget
4572 * Like gtk_widget_queue_draw(), but only windows owned
4573 * by @widget are invalidated.
4576 gtk_widget_queue_shallow_draw (GtkWidget *widget)
4579 cairo_region_t *region;
4581 if (!gtk_widget_get_realized (widget))
4584 gtk_widget_get_allocation (widget, &rect);
4586 region = cairo_region_create_rectangle (&rect);
4587 gtk_widget_invalidate_widget_windows (widget, region);
4588 cairo_region_destroy (region);
4592 * gtk_widget_size_allocate:
4593 * @widget: a #GtkWidget
4594 * @allocation: (inout): position and size to be allocated to @widget
4596 * This function is only used by #GtkContainer subclasses, to assign a size
4597 * and position to their child widgets.
4599 * In this function, the allocation may be adjusted. It will be forced
4600 * to a 1x1 minimum size, and the adjust_size_allocation virtual
4601 * method on the child will be used to adjust the allocation. Standard
4602 * adjustments include removing the widget's margins, and applying the
4603 * widget's #GtkWidget:halign and #GtkWidget:valign properties.
4606 gtk_widget_size_allocate (GtkWidget *widget,
4607 GtkAllocation *allocation)
4609 GtkWidgetPrivate *priv;
4610 GdkRectangle real_allocation;
4611 GdkRectangle old_allocation;
4612 GdkRectangle adjusted_allocation;
4613 gboolean alloc_needed;
4614 gboolean size_changed;
4615 gboolean position_changed;
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 GTK_WIDGET_GET_CLASS (widget)->adjust_size_allocation (widget, &adjusted_allocation);
4654 if (adjusted_allocation.x < real_allocation.x ||
4655 adjusted_allocation.y < real_allocation.y ||
4656 (adjusted_allocation.x + adjusted_allocation.width) >
4657 (real_allocation.x + real_allocation.width) ||
4658 (adjusted_allocation.y + adjusted_allocation.height >
4659 real_allocation.y + real_allocation.height))
4661 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",
4662 G_OBJECT_TYPE_NAME (widget), widget,
4663 real_allocation.x, real_allocation.y, real_allocation.width, real_allocation.height,
4664 adjusted_allocation.x, adjusted_allocation.y, adjusted_allocation.width, adjusted_allocation.height);
4665 adjusted_allocation = real_allocation; /* veto it */
4669 real_allocation = adjusted_allocation;
4672 if (real_allocation.width < 0 || real_allocation.height < 0)
4674 g_warning ("gtk_widget_size_allocate(): attempt to allocate widget with width %d and height %d",
4675 real_allocation.width,
4676 real_allocation.height);
4679 real_allocation.width = MAX (real_allocation.width, 1);
4680 real_allocation.height = MAX (real_allocation.height, 1);
4682 size_changed = (old_allocation.width != real_allocation.width ||
4683 old_allocation.height != real_allocation.height);
4684 position_changed = (old_allocation.x != real_allocation.x ||
4685 old_allocation.y != real_allocation.y);
4687 if (!alloc_needed && !size_changed && !position_changed)
4690 g_signal_emit (widget, widget_signals[SIZE_ALLOCATE], 0, &real_allocation);
4692 if (gtk_widget_get_mapped (widget))
4694 if (!gtk_widget_get_has_window (widget) && priv->redraw_on_alloc && position_changed)
4696 /* Invalidate union(old_allaction,priv->allocation) in priv->window
4698 cairo_region_t *invalidate = cairo_region_create_rectangle (&priv->allocation);
4699 cairo_region_union_rectangle (invalidate, &old_allocation);
4701 gdk_window_invalidate_region (priv->window, invalidate, FALSE);
4702 cairo_region_destroy (invalidate);
4707 if (priv->redraw_on_alloc)
4709 /* Invalidate union(old_allaction,priv->allocation) in priv->window and descendents owned by widget
4711 cairo_region_t *invalidate = cairo_region_create_rectangle (&priv->allocation);
4712 cairo_region_union_rectangle (invalidate, &old_allocation);
4714 gtk_widget_invalidate_widget_windows (widget, invalidate);
4715 cairo_region_destroy (invalidate);
4720 if ((size_changed || position_changed) && priv->parent &&
4721 gtk_widget_get_realized (priv->parent) && _gtk_container_get_reallocate_redraws (GTK_CONTAINER (priv->parent)))
4723 cairo_region_t *invalidate = cairo_region_create_rectangle (&priv->parent->priv->allocation);
4724 gtk_widget_invalidate_widget_windows (priv->parent, invalidate);
4725 cairo_region_destroy (invalidate);
4730 * gtk_widget_common_ancestor:
4731 * @widget_a: a #GtkWidget
4732 * @widget_b: a #GtkWidget
4734 * Find the common ancestor of @widget_a and @widget_b that
4735 * is closest to the two widgets.
4737 * Return value: the closest common ancestor of @widget_a and
4738 * @widget_b or %NULL if @widget_a and @widget_b do not
4739 * share a common ancestor.
4742 gtk_widget_common_ancestor (GtkWidget *widget_a,
4743 GtkWidget *widget_b)
4745 GtkWidget *parent_a;
4746 GtkWidget *parent_b;
4750 parent_a = widget_a;
4751 while (parent_a->priv->parent)
4753 parent_a = parent_a->priv->parent;
4757 parent_b = widget_b;
4758 while (parent_b->priv->parent)
4760 parent_b = parent_b->priv->parent;
4764 if (parent_a != parent_b)
4767 while (depth_a > depth_b)
4769 widget_a = widget_a->priv->parent;
4773 while (depth_b > depth_a)
4775 widget_b = widget_b->priv->parent;
4779 while (widget_a != widget_b)
4781 widget_a = widget_a->priv->parent;
4782 widget_b = widget_b->priv->parent;
4789 * gtk_widget_translate_coordinates:
4790 * @src_widget: a #GtkWidget
4791 * @dest_widget: a #GtkWidget
4792 * @src_x: X position relative to @src_widget
4793 * @src_y: Y position relative to @src_widget
4794 * @dest_x: (out): location to store X position relative to @dest_widget
4795 * @dest_y: (out): location to store Y position relative to @dest_widget
4797 * Translate coordinates relative to @src_widget's allocation to coordinates
4798 * relative to @dest_widget's allocations. In order to perform this
4799 * operation, both widgets must be realized, and must share a common
4802 * Return value: %FALSE if either widget was not realized, or there
4803 * was no common ancestor. In this case, nothing is stored in
4804 * *@dest_x and *@dest_y. Otherwise %TRUE.
4807 gtk_widget_translate_coordinates (GtkWidget *src_widget,
4808 GtkWidget *dest_widget,
4814 GtkWidgetPrivate *src_priv = src_widget->priv;
4815 GtkWidgetPrivate *dest_priv = dest_widget->priv;
4816 GtkWidget *ancestor;
4818 GList *dest_list = NULL;
4820 g_return_val_if_fail (GTK_IS_WIDGET (src_widget), FALSE);
4821 g_return_val_if_fail (GTK_IS_WIDGET (dest_widget), FALSE);
4823 ancestor = gtk_widget_common_ancestor (src_widget, dest_widget);
4824 if (!ancestor || !gtk_widget_get_realized (src_widget) || !gtk_widget_get_realized (dest_widget))
4827 /* Translate from allocation relative to window relative */
4828 if (gtk_widget_get_has_window (src_widget) && src_priv->parent)
4831 gdk_window_get_position (src_priv->window, &wx, &wy);
4833 src_x -= wx - src_priv->allocation.x;
4834 src_y -= wy - src_priv->allocation.y;
4838 src_x += src_priv->allocation.x;
4839 src_y += src_priv->allocation.y;
4842 /* Translate to the common ancestor */
4843 window = src_priv->window;
4844 while (window != ancestor->priv->window)
4848 gdk_window_coords_to_parent (window, src_x, src_y, &dx, &dy);
4853 window = gdk_window_get_effective_parent (window);
4855 if (!window) /* Handle GtkHandleBox */
4860 window = dest_priv->window;
4861 while (window != ancestor->priv->window)
4863 dest_list = g_list_prepend (dest_list, window);
4865 window = gdk_window_get_effective_parent (window);
4867 if (!window) /* Handle GtkHandleBox */
4869 g_list_free (dest_list);
4878 gdk_window_coords_from_parent (dest_list->data, src_x, src_y, &dx, &dy);
4883 dest_list = g_list_remove (dest_list, dest_list->data);
4886 /* Translate from window relative to allocation relative */
4887 if (gtk_widget_get_has_window (dest_widget) && dest_priv->parent)
4890 gdk_window_get_position (dest_priv->window, &wx, &wy);
4892 src_x += wx - dest_priv->allocation.x;
4893 src_y += wy - dest_priv->allocation.y;
4897 src_x -= dest_priv->allocation.x;
4898 src_y -= dest_priv->allocation.y;
4910 gtk_widget_real_size_allocate (GtkWidget *widget,
4911 GtkAllocation *allocation)
4913 GtkWidgetPrivate *priv = widget->priv;
4915 priv->allocation = *allocation;
4917 if (gtk_widget_get_realized (widget) &&
4918 gtk_widget_get_has_window (widget))
4920 gdk_window_move_resize (priv->window,
4921 allocation->x, allocation->y,
4922 allocation->width, allocation->height);
4927 get_span_inside_border (GtkWidget *widget,
4931 int allocated_outside_size,
4932 int natural_inside_size,
4933 int *coord_inside_p,
4936 int inside_allocated;
4940 inside_allocated = allocated_outside_size - start_pad - end_pad;
4942 content_size = natural_inside_size;
4943 if (content_size > inside_allocated)
4945 /* didn't get full natural size */
4946 content_size = inside_allocated;
4949 coord = size = 0; /* silence compiler */
4952 case GTK_ALIGN_FILL:
4954 size = inside_allocated;
4956 case GTK_ALIGN_START:
4958 size = content_size;
4961 coord = allocated_outside_size - end_pad - content_size;
4962 size = content_size;
4964 case GTK_ALIGN_CENTER:
4965 coord = start_pad + (inside_allocated - content_size) / 2;
4966 size = content_size;
4971 *coord_inside_p = coord;
4974 *size_inside_p = size;
4978 get_span_inside_border_horizontal (GtkWidget *widget,
4979 const GtkWidgetAuxInfo *aux_info,
4980 int allocated_outside_width,
4981 int natural_inside_width,
4983 int *width_inside_p)
4985 get_span_inside_border (widget,
4987 aux_info->margin.left,
4988 aux_info->margin.right,
4989 allocated_outside_width,
4990 natural_inside_width,
4996 get_span_inside_border_vertical (GtkWidget *widget,
4997 const GtkWidgetAuxInfo *aux_info,
4998 int allocated_outside_height,
4999 int natural_inside_height,
5001 int *height_inside_p)
5003 get_span_inside_border (widget,
5005 aux_info->margin.top,
5006 aux_info->margin.bottom,
5007 allocated_outside_height,
5008 natural_inside_height,
5014 gtk_widget_real_adjust_size_allocation (GtkWidget *widget,
5015 GtkAllocation *allocation)
5017 const GtkWidgetAuxInfo *aux_info;
5019 gint natural_height;
5022 aux_info = _gtk_widget_get_aux_info_or_defaults (widget);
5024 if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
5026 gtk_widget_get_preferred_width (widget, NULL, &natural_width);
5027 get_span_inside_border_horizontal (widget,
5033 gtk_widget_get_preferred_height_for_width (widget, w, NULL, &natural_height);
5034 get_span_inside_border_vertical (widget,
5040 else /* GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT */
5042 gtk_widget_get_preferred_height (widget, NULL, &natural_height);
5043 get_span_inside_border_vertical (widget,
5049 gtk_widget_get_preferred_width_for_height (widget, h, NULL, &natural_width);
5050 get_span_inside_border_horizontal (widget,
5059 allocation->width = w;
5060 allocation->height = h;
5064 gtk_widget_real_can_activate_accel (GtkWidget *widget,
5067 GtkWidgetPrivate *priv = widget->priv;
5069 /* widgets must be onscreen for accels to take effect */
5070 return gtk_widget_is_sensitive (widget) &&
5071 gtk_widget_is_drawable (widget) &&
5072 gdk_window_is_viewable (priv->window);
5076 * gtk_widget_can_activate_accel:
5077 * @widget: a #GtkWidget
5078 * @signal_id: the ID of a signal installed on @widget
5080 * Determines whether an accelerator that activates the signal
5081 * identified by @signal_id can currently be activated.
5082 * This is done by emitting the #GtkWidget::can-activate-accel
5083 * signal on @widget; if the signal isn't overridden by a
5084 * handler or in a derived widget, then the default check is
5085 * that the widget must be sensitive, and the widget and all
5086 * its ancestors mapped.
5088 * Return value: %TRUE if the accelerator can be activated.
5093 gtk_widget_can_activate_accel (GtkWidget *widget,
5096 gboolean can_activate = FALSE;
5097 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
5098 g_signal_emit (widget, widget_signals[CAN_ACTIVATE_ACCEL], 0, signal_id, &can_activate);
5099 return can_activate;
5108 closure_accel_activate (GClosure *closure,
5109 GValue *return_value,
5110 guint n_param_values,
5111 const GValue *param_values,
5112 gpointer invocation_hint,
5113 gpointer marshal_data)
5115 AccelClosure *aclosure = (AccelClosure*) closure;
5116 gboolean can_activate = gtk_widget_can_activate_accel (closure->data, aclosure->signal_id);
5119 g_signal_emit (closure->data, aclosure->signal_id, 0);
5121 /* whether accelerator was handled */
5122 g_value_set_boolean (return_value, can_activate);
5126 closures_destroy (gpointer data)
5128 GSList *slist, *closures = data;
5130 for (slist = closures; slist; slist = slist->next)
5132 g_closure_invalidate (slist->data);
5133 g_closure_unref (slist->data);
5135 g_slist_free (closures);
5139 widget_new_accel_closure (GtkWidget *widget,
5142 AccelClosure *aclosure;
5143 GClosure *closure = NULL;
5144 GSList *slist, *closures;
5146 closures = g_object_steal_qdata (G_OBJECT (widget), quark_accel_closures);
5147 for (slist = closures; slist; slist = slist->next)
5148 if (!gtk_accel_group_from_accel_closure (slist->data))
5150 /* reuse this closure */
5151 closure = slist->data;
5156 closure = g_closure_new_object (sizeof (AccelClosure), G_OBJECT (widget));
5157 closures = g_slist_prepend (closures, g_closure_ref (closure));
5158 g_closure_sink (closure);
5159 g_closure_set_marshal (closure, closure_accel_activate);
5161 g_object_set_qdata_full (G_OBJECT (widget), quark_accel_closures, closures, closures_destroy);
5163 aclosure = (AccelClosure*) closure;
5164 g_assert (closure->data == widget);
5165 g_assert (closure->marshal == closure_accel_activate);
5166 aclosure->signal_id = signal_id;
5172 * gtk_widget_add_accelerator
5173 * @widget: widget to install an accelerator on
5174 * @accel_signal: widget signal to emit on accelerator activation
5175 * @accel_group: accel group for this widget, added to its toplevel
5176 * @accel_key: GDK keyval of the accelerator
5177 * @accel_mods: modifier key combination of the accelerator
5178 * @accel_flags: flag accelerators, e.g. %GTK_ACCEL_VISIBLE
5180 * Installs an accelerator for this @widget in @accel_group that causes
5181 * @accel_signal to be emitted if the accelerator is activated.
5182 * The @accel_group needs to be added to the widget's toplevel via
5183 * gtk_window_add_accel_group(), and the signal must be of type %G_RUN_ACTION.
5184 * Accelerators added through this function are not user changeable during
5185 * runtime. If you want to support accelerators that can be changed by the
5186 * user, use gtk_accel_map_add_entry() and gtk_widget_set_accel_path() or
5187 * gtk_menu_item_set_accel_path() instead.
5190 gtk_widget_add_accelerator (GtkWidget *widget,
5191 const gchar *accel_signal,
5192 GtkAccelGroup *accel_group,
5194 GdkModifierType accel_mods,
5195 GtkAccelFlags accel_flags)
5200 g_return_if_fail (GTK_IS_WIDGET (widget));
5201 g_return_if_fail (accel_signal != NULL);
5202 g_return_if_fail (GTK_IS_ACCEL_GROUP (accel_group));
5204 g_signal_query (g_signal_lookup (accel_signal, G_OBJECT_TYPE (widget)), &query);
5205 if (!query.signal_id ||
5206 !(query.signal_flags & G_SIGNAL_ACTION) ||
5207 query.return_type != G_TYPE_NONE ||
5210 /* hmm, should be elaborate enough */
5211 g_warning (G_STRLOC ": widget `%s' has no activatable signal \"%s\" without arguments",
5212 G_OBJECT_TYPE_NAME (widget), accel_signal);
5216 closure = widget_new_accel_closure (widget, query.signal_id);
5218 g_object_ref (widget);
5220 /* install the accelerator. since we don't map this onto an accel_path,
5221 * the accelerator will automatically be locked.
5223 gtk_accel_group_connect (accel_group,
5226 accel_flags | GTK_ACCEL_LOCKED,
5229 g_signal_emit (widget, widget_signals[ACCEL_CLOSURES_CHANGED], 0);
5231 g_object_unref (widget);
5235 * gtk_widget_remove_accelerator:
5236 * @widget: widget to install an accelerator on
5237 * @accel_group: accel group for this widget
5238 * @accel_key: GDK keyval of the accelerator
5239 * @accel_mods: modifier key combination of the accelerator
5240 * @returns: whether an accelerator was installed and could be removed
5242 * Removes an accelerator from @widget, previously installed with
5243 * gtk_widget_add_accelerator().
5246 gtk_widget_remove_accelerator (GtkWidget *widget,
5247 GtkAccelGroup *accel_group,
5249 GdkModifierType accel_mods)
5251 GtkAccelGroupEntry *ag_entry;
5252 GList *slist, *clist;
5255 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
5256 g_return_val_if_fail (GTK_IS_ACCEL_GROUP (accel_group), FALSE);
5258 ag_entry = gtk_accel_group_query (accel_group, accel_key, accel_mods, &n);
5259 clist = gtk_widget_list_accel_closures (widget);
5260 for (slist = clist; slist; slist = slist->next)
5264 for (i = 0; i < n; i++)
5265 if (slist->data == (gpointer) ag_entry[i].closure)
5267 gboolean is_removed = gtk_accel_group_disconnect (accel_group, slist->data);
5269 g_signal_emit (widget, widget_signals[ACCEL_CLOSURES_CHANGED], 0);
5271 g_list_free (clist);
5276 g_list_free (clist);
5278 g_warning (G_STRLOC ": no accelerator (%u,%u) installed in accel group (%p) for %s (%p)",
5279 accel_key, accel_mods, accel_group,
5280 G_OBJECT_TYPE_NAME (widget), widget);
5286 * gtk_widget_list_accel_closures:
5287 * @widget: widget to list accelerator closures for
5289 * Lists the closures used by @widget for accelerator group connections
5290 * with gtk_accel_group_connect_by_path() or gtk_accel_group_connect().
5291 * The closures can be used to monitor accelerator changes on @widget,
5292 * by connecting to the @GtkAccelGroup::accel-changed signal of the
5293 * #GtkAccelGroup of a closure which can be found out with
5294 * gtk_accel_group_from_accel_closure().
5296 * Return value: (transfer container) (element-type GClosure):
5297 * a newly allocated #GList of closures
5300 gtk_widget_list_accel_closures (GtkWidget *widget)
5303 GList *clist = NULL;
5305 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
5307 for (slist = g_object_get_qdata (G_OBJECT (widget), quark_accel_closures); slist; slist = slist->next)
5308 if (gtk_accel_group_from_accel_closure (slist->data))
5309 clist = g_list_prepend (clist, slist->data);
5315 GtkAccelGroup *accel_group;
5320 destroy_accel_path (gpointer data)
5322 AccelPath *apath = data;
5324 gtk_accel_group_disconnect (apath->accel_group, apath->closure);
5326 /* closures_destroy takes care of unrefing the closure */
5327 g_object_unref (apath->accel_group);
5329 g_slice_free (AccelPath, apath);
5334 * gtk_widget_set_accel_path:
5335 * @widget: a #GtkWidget
5336 * @accel_path: (allow-none): path used to look up the accelerator
5337 * @accel_group: (allow-none): a #GtkAccelGroup.
5339 * Given an accelerator group, @accel_group, and an accelerator path,
5340 * @accel_path, sets up an accelerator in @accel_group so whenever the
5341 * key binding that is defined for @accel_path is pressed, @widget
5342 * will be activated. This removes any accelerators (for any
5343 * accelerator group) installed by previous calls to
5344 * gtk_widget_set_accel_path(). Associating accelerators with
5345 * paths allows them to be modified by the user and the modifications
5346 * to be saved for future use. (See gtk_accel_map_save().)
5348 * This function is a low level function that would most likely
5349 * be used by a menu creation system like #GtkUIManager. If you
5350 * use #GtkUIManager, setting up accelerator paths will be done
5353 * Even when you you aren't using #GtkUIManager, if you only want to
5354 * set up accelerators on menu items gtk_menu_item_set_accel_path()
5355 * provides a somewhat more convenient interface.
5357 * Note that @accel_path string will be stored in a #GQuark. Therefore, if you
5358 * pass a static string, you can save some memory by interning it first with
5359 * g_intern_static_string().
5362 gtk_widget_set_accel_path (GtkWidget *widget,
5363 const gchar *accel_path,
5364 GtkAccelGroup *accel_group)
5368 g_return_if_fail (GTK_IS_WIDGET (widget));
5369 g_return_if_fail (GTK_WIDGET_GET_CLASS (widget)->activate_signal != 0);
5373 g_return_if_fail (GTK_IS_ACCEL_GROUP (accel_group));
5374 g_return_if_fail (_gtk_accel_path_is_valid (accel_path));
5376 gtk_accel_map_add_entry (accel_path, 0, 0);
5377 apath = g_slice_new (AccelPath);
5378 apath->accel_group = g_object_ref (accel_group);
5379 apath->path_quark = g_quark_from_string (accel_path);
5380 apath->closure = widget_new_accel_closure (widget, GTK_WIDGET_GET_CLASS (widget)->activate_signal);
5385 /* also removes possible old settings */
5386 g_object_set_qdata_full (G_OBJECT (widget), quark_accel_path, apath, destroy_accel_path);
5389 gtk_accel_group_connect_by_path (apath->accel_group, g_quark_to_string (apath->path_quark), apath->closure);
5391 g_signal_emit (widget, widget_signals[ACCEL_CLOSURES_CHANGED], 0);
5395 _gtk_widget_get_accel_path (GtkWidget *widget,
5400 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
5402 apath = g_object_get_qdata (G_OBJECT (widget), quark_accel_path);
5404 *locked = apath ? gtk_accel_group_get_is_locked (apath->accel_group) : TRUE;
5405 return apath ? g_quark_to_string (apath->path_quark) : NULL;
5409 * gtk_widget_mnemonic_activate:
5410 * @widget: a #GtkWidget
5411 * @group_cycling: %TRUE if there are other widgets with the same mnemonic
5413 * Emits the #GtkWidget::mnemonic-activate signal.
5415 * The default handler for this signal activates the @widget if
5416 * @group_cycling is %FALSE, and just grabs the focus if @group_cycling
5419 * Returns: %TRUE if the signal has been handled
5422 gtk_widget_mnemonic_activate (GtkWidget *widget,
5423 gboolean group_cycling)
5427 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
5429 group_cycling = group_cycling != FALSE;
5430 if (!gtk_widget_is_sensitive (widget))
5433 g_signal_emit (widget,
5434 widget_signals[MNEMONIC_ACTIVATE],
5442 gtk_widget_real_mnemonic_activate (GtkWidget *widget,
5443 gboolean group_cycling)
5445 if (!group_cycling && GTK_WIDGET_GET_CLASS (widget)->activate_signal)
5446 gtk_widget_activate (widget);
5447 else if (gtk_widget_get_can_focus (widget))
5448 gtk_widget_grab_focus (widget);
5451 g_warning ("widget `%s' isn't suitable for mnemonic activation",
5452 G_OBJECT_TYPE_NAME (widget));
5453 gtk_widget_error_bell (widget);
5458 static const cairo_user_data_key_t event_key;
5461 _gtk_cairo_get_event (cairo_t *cr)
5463 g_return_val_if_fail (cr != NULL, NULL);
5465 return cairo_get_user_data (cr, &event_key);
5469 gtk_cairo_set_event (cairo_t *cr,
5470 GdkEventExpose *event)
5472 cairo_set_user_data (cr, &event_key, event, NULL);
5476 * gtk_cairo_should_draw_window:
5477 * @cr: a cairo context
5478 * @window: the window to check
5480 * This function is supposed to be called in GtkWidget::draw
5481 * implementations for widgets that support multiple windows.
5482 * @cr must be untransformed from invoking of the draw function.
5483 * This function will return %TRUE if the contents of the given
5484 * @window are supposed to be drawn and %FALSE otherwise. Note
5485 * that when the drawing was not initiated by the windowing
5486 * system this function will return %TRUE for all windows, so
5487 * you need to draw the bottommost window first. Also, do not
5488 * use "else if" statements to check which window should be drawn.
5490 * Returns: %TRUE if @window should be drawn
5493 gtk_cairo_should_draw_window (cairo_t *cr,
5496 GdkEventExpose *event;
5498 g_return_val_if_fail (cr != NULL, FALSE);
5499 g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
5501 event = _gtk_cairo_get_event (cr);
5503 return event == NULL ||
5504 event->window == window;
5507 /* code shared by gtk_container_propagate_draw() and
5511 _gtk_widget_draw_internal (GtkWidget *widget,
5513 gboolean clip_to_size)
5515 if (!gtk_widget_is_drawable (widget))
5520 cairo_rectangle (cr,
5522 widget->priv->allocation.width,
5523 widget->priv->allocation.height);
5527 if (gdk_cairo_get_clip_rectangle (cr, NULL))
5531 g_signal_emit (widget, widget_signals[DRAW],
5539 * @widget: the widget to draw. It must be drawable (see
5540 * gtk_widget_is_drawable()) and a size must have been allocated.
5541 * @cr: a cairo context to draw to
5543 * Draws @widget to @cr. The top left corner of the widget will be
5544 * drawn to the currently set origin point of @cr.
5546 * You should pass a cairo context as @cr argument that is in an
5547 * original state. Otherwise the resulting drawing is undefined. For
5548 * example changing the operator using cairo_set_operator() or the
5549 * line width using cairo_set_line_width() might have unwanted side
5551 * You may however change the context's transform matrix - like with
5552 * cairo_scale(), cairo_translate() or cairo_set_matrix() and clip
5553 * region with cairo_clip() prior to calling this function. Also, it
5554 * is fine to modify the context with cairo_save() and
5555 * cairo_push_group() prior to calling this function.
5557 * <note><para>Special purpose widgets may contain special code for
5558 * rendering to the screen and might appear differently on screen
5559 * and when rendered using gtk_widget_draw().</para></note>
5562 gtk_widget_draw (GtkWidget *widget,
5565 GdkEventExpose *tmp_event;
5567 g_return_if_fail (GTK_IS_WIDGET (widget));
5568 g_return_if_fail (!widget->priv->alloc_needed);
5569 g_return_if_fail (cr != NULL);
5572 /* We have to reset the event here so that draw functions can call
5573 * gtk_widget_draw() on random other widgets and get the desired
5574 * effect: Drawing all contents, not just the current window.
5576 tmp_event = _gtk_cairo_get_event (cr);
5577 gtk_cairo_set_event (cr, NULL);
5579 _gtk_widget_draw_internal (widget, cr, TRUE);
5581 gtk_cairo_set_event (cr, tmp_event);
5586 gtk_widget_real_key_press_event (GtkWidget *widget,
5589 return gtk_bindings_activate_event (G_OBJECT (widget), event);
5593 gtk_widget_real_key_release_event (GtkWidget *widget,
5596 return gtk_bindings_activate_event (G_OBJECT (widget), event);
5600 gtk_widget_real_focus_in_event (GtkWidget *widget,
5601 GdkEventFocus *event)
5603 gtk_widget_queue_shallow_draw (widget);
5609 gtk_widget_real_focus_out_event (GtkWidget *widget,
5610 GdkEventFocus *event)
5612 gtk_widget_queue_shallow_draw (widget);
5617 #define WIDGET_REALIZED_FOR_EVENT(widget, event) \
5618 (event->type == GDK_FOCUS_CHANGE || gtk_widget_get_realized(widget))
5622 * @widget: a #GtkWidget
5623 * @event: a #GdkEvent
5625 * Rarely-used function. This function is used to emit
5626 * the event signals on a widget (those signals should never
5627 * be emitted without using this function to do so).
5628 * If you want to synthesize an event though, don't use this function;
5629 * instead, use gtk_main_do_event() so the event will behave as if
5630 * it were in the event queue. Don't synthesize expose events; instead,
5631 * use gdk_window_invalidate_rect() to invalidate a region of the
5634 * Return value: return from the event signal emission (%TRUE if
5635 * the event was handled)
5638 gtk_widget_event (GtkWidget *widget,
5641 g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
5642 g_return_val_if_fail (WIDGET_REALIZED_FOR_EVENT (widget, event), TRUE);
5644 if (event->type == GDK_EXPOSE)
5646 g_warning ("Events of type GDK_EXPOSE cannot be synthesized. To get "
5647 "the same effect, call gdk_window_invalidate_rect/region(), "
5648 "followed by gdk_window_process_updates().");
5652 return gtk_widget_event_internal (widget, event);
5655 /* Returns TRUE if a translation should be done */
5657 gtk_widget_get_translation_to_window (GtkWidget *widget,
5662 GdkWindow *w, *widget_window;
5664 if (!gtk_widget_get_has_window (widget))
5666 *x = -widget->priv->allocation.x;
5667 *y = -widget->priv->allocation.y;
5675 widget_window = gtk_widget_get_window (widget);
5677 for (w = window; w && w != widget_window; w = gdk_window_get_parent (w))
5680 gdk_window_get_position (w, &wx, &wy);
5697 * gtk_cairo_transform_to_window:
5698 * @cr: the cairo context to transform
5699 * @widget: the widget the context is currently centered for
5700 * @window: the window to transform the context to
5702 * Transforms the given cairo context @cr that from @widget-relative
5703 * coordinates to @window-relative coordinates.
5704 * If the @widget's window is not an ancestor of @window, no
5705 * modification will be applied.
5707 * This is the inverse to the transformation GTK applies when
5708 * preparing an expose event to be emitted with the GtkWidget::draw
5709 * signal. It is intended to help porting multiwindow widgets from
5710 * GTK 2 to the rendering architecture of GTK 3.
5713 gtk_cairo_transform_to_window (cairo_t *cr,
5719 g_return_if_fail (cr != NULL);
5720 g_return_if_fail (GTK_IS_WIDGET (widget));
5721 g_return_if_fail (GDK_IS_WINDOW (window));
5723 if (gtk_widget_get_translation_to_window (widget, window, &x, &y))
5724 cairo_translate (cr, x, y);
5728 * gtk_widget_send_expose:
5729 * @widget: a #GtkWidget
5730 * @event: a expose #GdkEvent
5732 * Very rarely-used function. This function is used to emit
5733 * an expose event on a widget. This function is not normally used
5734 * directly. The only time it is used is when propagating an expose
5735 * event to a child %NO_WINDOW widget, and that is normally done
5736 * using gtk_container_propagate_draw().
5738 * If you want to force an area of a window to be redrawn,
5739 * use gdk_window_invalidate_rect() or gdk_window_invalidate_region().
5740 * To cause the redraw to be done immediately, follow that call
5741 * with a call to gdk_window_process_updates().
5743 * Return value: return from the event signal emission (%TRUE if
5744 * the event was handled)
5747 gtk_widget_send_expose (GtkWidget *widget,
5750 gboolean result = FALSE;
5755 g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
5756 g_return_val_if_fail (gtk_widget_get_realized (widget), TRUE);
5757 g_return_val_if_fail (event != NULL, TRUE);
5758 g_return_val_if_fail (event->type == GDK_EXPOSE, TRUE);
5760 cr = gdk_cairo_create (event->expose.window);
5761 gtk_cairo_set_event (cr, &event->expose);
5763 gdk_cairo_region (cr, event->expose.region);
5766 do_clip = gtk_widget_get_translation_to_window (widget,
5767 event->expose.window,
5769 cairo_translate (cr, -x, -y);
5771 _gtk_widget_draw_internal (widget, cr, do_clip);
5773 /* unset here, so if someone keeps a reference to cr we
5774 * don't leak the window. */
5775 gtk_cairo_set_event (cr, NULL);
5782 event_window_is_still_viewable (GdkEvent *event)
5784 /* Check that we think the event's window is viewable before
5785 * delivering the event, to prevent suprises. We do this here
5786 * at the last moment, since the event may have been queued
5787 * up behind other events, held over a recursive main loop, etc.
5789 switch (event->type)
5792 case GDK_MOTION_NOTIFY:
5793 case GDK_BUTTON_PRESS:
5794 case GDK_2BUTTON_PRESS:
5795 case GDK_3BUTTON_PRESS:
5797 case GDK_ENTER_NOTIFY:
5798 case GDK_PROXIMITY_IN:
5800 return event->any.window && gdk_window_is_viewable (event->any.window);
5803 /* The following events are the second half of paired events;
5804 * we always deliver them to deal with widgets that clean up
5805 * on the second half.
5807 case GDK_BUTTON_RELEASE:
5808 case GDK_KEY_RELEASE:
5809 case GDK_LEAVE_NOTIFY:
5810 case GDK_PROXIMITY_OUT:
5814 /* Remaining events would make sense on an not-viewable window,
5815 * or don't have an associated window.
5822 gtk_widget_event_internal (GtkWidget *widget,
5825 gboolean return_val = FALSE;
5827 /* We check only once for is-still-visible; if someone
5828 * hides the window in on of the signals on the widget,
5829 * they are responsible for returning TRUE to terminate
5832 if (!event_window_is_still_viewable (event))
5835 g_object_ref (widget);
5837 g_signal_emit (widget, widget_signals[EVENT], 0, event, &return_val);
5838 return_val |= !WIDGET_REALIZED_FOR_EVENT (widget, event);
5843 switch (event->type)
5848 case GDK_BUTTON_PRESS:
5849 case GDK_2BUTTON_PRESS:
5850 case GDK_3BUTTON_PRESS:
5851 signal_num = BUTTON_PRESS_EVENT;
5854 signal_num = SCROLL_EVENT;
5856 case GDK_BUTTON_RELEASE:
5857 signal_num = BUTTON_RELEASE_EVENT;
5859 case GDK_MOTION_NOTIFY:
5860 signal_num = MOTION_NOTIFY_EVENT;
5863 signal_num = DELETE_EVENT;
5866 signal_num = DESTROY_EVENT;
5867 _gtk_tooltip_hide (widget);
5870 signal_num = KEY_PRESS_EVENT;
5872 case GDK_KEY_RELEASE:
5873 signal_num = KEY_RELEASE_EVENT;
5875 case GDK_ENTER_NOTIFY:
5876 signal_num = ENTER_NOTIFY_EVENT;
5878 case GDK_LEAVE_NOTIFY:
5879 signal_num = LEAVE_NOTIFY_EVENT;
5881 case GDK_FOCUS_CHANGE:
5882 signal_num = event->focus_change.in ? FOCUS_IN_EVENT : FOCUS_OUT_EVENT;
5883 if (event->focus_change.in)
5884 _gtk_tooltip_focus_in (widget);
5886 _gtk_tooltip_focus_out (widget);
5889 signal_num = CONFIGURE_EVENT;
5892 signal_num = MAP_EVENT;
5895 signal_num = UNMAP_EVENT;
5897 case GDK_WINDOW_STATE:
5898 signal_num = WINDOW_STATE_EVENT;
5900 case GDK_PROPERTY_NOTIFY:
5901 signal_num = PROPERTY_NOTIFY_EVENT;
5903 case GDK_SELECTION_CLEAR:
5904 signal_num = SELECTION_CLEAR_EVENT;
5906 case GDK_SELECTION_REQUEST:
5907 signal_num = SELECTION_REQUEST_EVENT;
5909 case GDK_SELECTION_NOTIFY:
5910 signal_num = SELECTION_NOTIFY_EVENT;
5912 case GDK_PROXIMITY_IN:
5913 signal_num = PROXIMITY_IN_EVENT;
5915 case GDK_PROXIMITY_OUT:
5916 signal_num = PROXIMITY_OUT_EVENT;
5919 signal_num = NO_EXPOSE_EVENT;
5921 case GDK_CLIENT_EVENT:
5922 signal_num = CLIENT_EVENT;
5925 signal_num = EXPOSE_EVENT;
5927 case GDK_VISIBILITY_NOTIFY:
5928 signal_num = VISIBILITY_NOTIFY_EVENT;
5930 case GDK_GRAB_BROKEN:
5931 signal_num = GRAB_BROKEN_EVENT;
5934 signal_num = DAMAGE_EVENT;
5937 g_warning ("gtk_widget_event(): unhandled event type: %d", event->type);
5941 if (signal_num != -1)
5942 g_signal_emit (widget, widget_signals[signal_num], 0, event, &return_val);
5944 if (WIDGET_REALIZED_FOR_EVENT (widget, event))
5945 g_signal_emit (widget, widget_signals[EVENT_AFTER], 0, event);
5949 g_object_unref (widget);
5955 * gtk_widget_activate:
5956 * @widget: a #GtkWidget that's activatable
5958 * For widgets that can be "activated" (buttons, menu items, etc.)
5959 * this function activates them. Activation is what happens when you
5960 * press Enter on a widget during key navigation. If @widget isn't
5961 * activatable, the function returns %FALSE.
5963 * Return value: %TRUE if the widget was activatable
5966 gtk_widget_activate (GtkWidget *widget)
5968 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
5970 if (WIDGET_CLASS (widget)->activate_signal)
5972 /* FIXME: we should eventually check the signals signature here */
5973 g_signal_emit (widget, WIDGET_CLASS (widget)->activate_signal, 0);
5982 gtk_widget_reparent_subwindows (GtkWidget *widget,
5983 GdkWindow *new_window)
5985 GtkWidgetPrivate *priv = widget->priv;
5987 if (!gtk_widget_get_has_window (widget))
5989 GList *children = gdk_window_get_children (priv->window);
5992 for (tmp_list = children; tmp_list; tmp_list = tmp_list->next)
5994 GdkWindow *window = tmp_list->data;
5997 gdk_window_get_user_data (window, &child);
5998 while (child && child != widget)
5999 child = ((GtkWidget*) child)->priv->parent;
6002 gdk_window_reparent (window, new_window, 0, 0);
6005 g_list_free (children);
6010 GList *tmp_list, *children;
6012 parent = gdk_window_get_parent (priv->window);
6015 gdk_window_reparent (priv->window, new_window, 0, 0);
6018 children = gdk_window_get_children (parent);
6020 for (tmp_list = children; tmp_list; tmp_list = tmp_list->next)
6022 GdkWindow *window = tmp_list->data;
6025 gdk_window_get_user_data (window, &child);
6027 if (child == widget)
6028 gdk_window_reparent (window, new_window, 0, 0);
6031 g_list_free (children);
6037 gtk_widget_reparent_fixup_child (GtkWidget *widget,
6038 gpointer client_data)
6040 GtkWidgetPrivate *priv = widget->priv;
6042 g_assert (client_data != NULL);
6044 if (!gtk_widget_get_has_window (widget))
6047 g_object_unref (priv->window);
6048 priv->window = (GdkWindow*) client_data;
6050 g_object_ref (priv->window);
6052 if (GTK_IS_CONTAINER (widget))
6053 gtk_container_forall (GTK_CONTAINER (widget),
6054 gtk_widget_reparent_fixup_child,
6060 * gtk_widget_reparent:
6061 * @widget: a #GtkWidget
6062 * @new_parent: a #GtkContainer to move the widget into
6064 * Moves a widget from one #GtkContainer to another, handling reference
6065 * count issues to avoid destroying the widget.
6068 gtk_widget_reparent (GtkWidget *widget,
6069 GtkWidget *new_parent)
6071 GtkWidgetPrivate *priv;
6073 g_return_if_fail (GTK_IS_WIDGET (widget));
6074 g_return_if_fail (GTK_IS_CONTAINER (new_parent));
6075 priv = widget->priv;
6076 g_return_if_fail (priv->parent != NULL);
6078 if (priv->parent != new_parent)
6080 /* First try to see if we can get away without unrealizing
6081 * the widget as we reparent it. if so we set a flag so
6082 * that gtk_widget_unparent doesn't unrealize widget
6084 if (gtk_widget_get_realized (widget) && gtk_widget_get_realized (new_parent))
6085 priv->in_reparent = TRUE;
6087 g_object_ref (widget);
6088 gtk_container_remove (GTK_CONTAINER (priv->parent), widget);
6089 gtk_container_add (GTK_CONTAINER (new_parent), widget);
6090 g_object_unref (widget);
6092 if (priv->in_reparent)
6094 priv->in_reparent = FALSE;
6096 gtk_widget_reparent_subwindows (widget, gtk_widget_get_parent_window (widget));
6097 gtk_widget_reparent_fixup_child (widget,
6098 gtk_widget_get_parent_window (widget));
6101 g_object_notify (G_OBJECT (widget), "parent");
6106 * gtk_widget_intersect:
6107 * @widget: a #GtkWidget
6108 * @area: a rectangle
6109 * @intersection: rectangle to store intersection of @widget and @area
6111 * Computes the intersection of a @widget's area and @area, storing
6112 * the intersection in @intersection, and returns %TRUE if there was
6113 * an intersection. @intersection may be %NULL if you're only
6114 * interested in whether there was an intersection.
6116 * Return value: %TRUE if there was an intersection
6119 gtk_widget_intersect (GtkWidget *widget,
6120 const GdkRectangle *area,
6121 GdkRectangle *intersection)
6123 GtkWidgetPrivate *priv;
6128 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6129 g_return_val_if_fail (area != NULL, FALSE);
6131 priv = widget->priv;
6134 dest = intersection;
6138 return_val = gdk_rectangle_intersect (&priv->allocation, area, dest);
6140 if (return_val && intersection && gtk_widget_get_has_window (widget))
6142 intersection->x -= priv->allocation.x;
6143 intersection->y -= priv->allocation.y;
6150 * gtk_widget_region_intersect:
6151 * @widget: a #GtkWidget
6152 * @region: a #cairo_region_t, in the same coordinate system as
6153 * @widget->allocation. That is, relative to @widget->window
6154 * for %NO_WINDOW widgets; relative to the parent window
6155 * of @widget->window for widgets with their own window.
6156 * @returns: A newly allocated region holding the intersection of @widget
6157 * and @region. The coordinates of the return value are
6158 * relative to @widget->window for %NO_WINDOW widgets, and
6159 * relative to the parent window of @widget->window for
6160 * widgets with their own window.
6162 * Computes the intersection of a @widget's area and @region, returning
6163 * the intersection. The result may be empty, use cairo_region_is_empty() to
6167 gtk_widget_region_intersect (GtkWidget *widget,
6168 const cairo_region_t *region)
6171 cairo_region_t *dest;
6173 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
6174 g_return_val_if_fail (region != NULL, NULL);
6176 gtk_widget_get_allocation (widget, &rect);
6178 dest = cairo_region_create_rectangle (&rect);
6180 cairo_region_intersect (dest, region);
6186 * _gtk_widget_grab_notify:
6187 * @widget: a #GtkWidget
6188 * @was_grabbed: whether a grab is now in effect
6190 * Emits the #GtkWidget::grab-notify signal on @widget.
6195 _gtk_widget_grab_notify (GtkWidget *widget,
6196 gboolean was_grabbed)
6198 g_signal_emit (widget, widget_signals[GRAB_NOTIFY], 0, was_grabbed);
6202 * gtk_widget_grab_focus:
6203 * @widget: a #GtkWidget
6205 * Causes @widget to have the keyboard focus for the #GtkWindow it's
6206 * inside. @widget must be a focusable widget, such as a #GtkEntry;
6207 * something like #GtkFrame won't work.
6209 * More precisely, it must have the %GTK_CAN_FOCUS flag set. Use
6210 * gtk_widget_set_can_focus() to modify that flag.
6212 * The widget also needs to be realized and mapped. This is indicated by the
6213 * related signals. Grabbing the focus immediately after creating the widget
6214 * will likely fail and cause critical warnings.
6217 gtk_widget_grab_focus (GtkWidget *widget)
6219 g_return_if_fail (GTK_IS_WIDGET (widget));
6221 if (!gtk_widget_is_sensitive (widget))
6224 g_object_ref (widget);
6225 g_signal_emit (widget, widget_signals[GRAB_FOCUS], 0);
6226 g_object_notify (G_OBJECT (widget), "has-focus");
6227 g_object_unref (widget);
6231 reset_focus_recurse (GtkWidget *widget,
6234 if (GTK_IS_CONTAINER (widget))
6236 GtkContainer *container;
6238 container = GTK_CONTAINER (widget);
6239 gtk_container_set_focus_child (container, NULL);
6241 gtk_container_foreach (container,
6242 reset_focus_recurse,
6248 gtk_widget_real_grab_focus (GtkWidget *focus_widget)
6250 if (gtk_widget_get_can_focus (focus_widget))
6252 GtkWidget *toplevel;
6255 /* clear the current focus setting, break if the current widget
6256 * is the focus widget's parent, since containers above that will
6257 * be set by the next loop.
6259 toplevel = gtk_widget_get_toplevel (focus_widget);
6260 if (gtk_widget_is_toplevel (toplevel) && GTK_IS_WINDOW (toplevel))
6262 widget = gtk_window_get_focus (GTK_WINDOW (toplevel));
6264 if (widget == focus_widget)
6266 /* We call _gtk_window_internal_set_focus() here so that the
6267 * toplevel window can request the focus if necessary.
6268 * This is needed when the toplevel is a GtkPlug
6270 if (!gtk_widget_has_focus (widget))
6271 _gtk_window_internal_set_focus (GTK_WINDOW (toplevel), focus_widget);
6278 while (widget->priv->parent && widget->priv->parent != focus_widget->priv->parent)
6280 widget = widget->priv->parent;
6281 gtk_container_set_focus_child (GTK_CONTAINER (widget), NULL);
6285 else if (toplevel != focus_widget)
6287 /* gtk_widget_grab_focus() operates on a tree without window...
6288 * actually, this is very questionable behaviour.
6291 gtk_container_foreach (GTK_CONTAINER (toplevel),
6292 reset_focus_recurse,
6296 /* now propagate the new focus up the widget tree and finally
6297 * set it on the window
6299 widget = focus_widget;
6300 while (widget->priv->parent)
6302 gtk_container_set_focus_child (GTK_CONTAINER (widget->priv->parent), widget);
6303 widget = widget->priv->parent;
6305 if (GTK_IS_WINDOW (widget))
6306 _gtk_window_internal_set_focus (GTK_WINDOW (widget), focus_widget);
6311 gtk_widget_real_query_tooltip (GtkWidget *widget,
6314 gboolean keyboard_tip,
6315 GtkTooltip *tooltip)
6317 gchar *tooltip_markup;
6318 gboolean has_tooltip;
6320 tooltip_markup = g_object_get_qdata (G_OBJECT (widget), quark_tooltip_markup);
6321 has_tooltip = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (widget), quark_has_tooltip));
6323 if (has_tooltip && tooltip_markup)
6325 gtk_tooltip_set_markup (tooltip, tooltip_markup);
6333 gtk_widget_real_show_help (GtkWidget *widget,
6334 GtkWidgetHelpType help_type)
6336 if (help_type == GTK_WIDGET_HELP_TOOLTIP)
6338 _gtk_tooltip_toggle_keyboard_mode (widget);
6347 gtk_widget_real_focus (GtkWidget *widget,
6348 GtkDirectionType direction)
6350 if (!gtk_widget_get_can_focus (widget))
6353 if (!gtk_widget_is_focus (widget))
6355 gtk_widget_grab_focus (widget);
6363 gtk_widget_real_move_focus (GtkWidget *widget,
6364 GtkDirectionType direction)
6366 GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
6368 if (widget != toplevel && GTK_IS_WINDOW (toplevel))
6370 g_signal_emit (toplevel, widget_signals[MOVE_FOCUS], 0,
6376 gtk_widget_real_keynav_failed (GtkWidget *widget,
6377 GtkDirectionType direction)
6379 gboolean cursor_only;
6383 case GTK_DIR_TAB_FORWARD:
6384 case GTK_DIR_TAB_BACKWARD:
6391 g_object_get (gtk_widget_get_settings (widget),
6392 "gtk-keynav-cursor-only", &cursor_only,
6399 gtk_widget_error_bell (widget);
6405 * gtk_widget_set_can_focus:
6406 * @widget: a #GtkWidget
6407 * @can_focus: whether or not @widget can own the input focus.
6409 * Specifies whether @widget can own the input focus. See
6410 * gtk_widget_grab_focus() for actually setting the input focus on a
6416 gtk_widget_set_can_focus (GtkWidget *widget,
6419 g_return_if_fail (GTK_IS_WIDGET (widget));
6421 if (widget->priv->can_focus != can_focus)
6423 widget->priv->can_focus = can_focus;
6425 gtk_widget_queue_resize (widget);
6426 g_object_notify (G_OBJECT (widget), "can-focus");
6431 * gtk_widget_get_can_focus:
6432 * @widget: a #GtkWidget
6434 * Determines whether @widget can own the input focus. See
6435 * gtk_widget_set_can_focus().
6437 * Return value: %TRUE if @widget can own the input focus, %FALSE otherwise
6442 gtk_widget_get_can_focus (GtkWidget *widget)
6444 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6446 return widget->priv->can_focus;
6450 * gtk_widget_has_focus:
6451 * @widget: a #GtkWidget
6453 * Determines if the widget has the global input focus. See
6454 * gtk_widget_is_focus() for the difference between having the global
6455 * input focus, and only having the focus within a toplevel.
6457 * Return value: %TRUE if the widget has the global input focus.
6462 gtk_widget_has_focus (GtkWidget *widget)
6464 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6466 return widget->priv->has_focus;
6470 * gtk_widget_is_focus:
6471 * @widget: a #GtkWidget
6473 * Determines if the widget is the focus widget within its
6474 * toplevel. (This does not mean that the %HAS_FOCUS flag is
6475 * necessarily set; %HAS_FOCUS will only be set if the
6476 * toplevel widget additionally has the global input focus.)
6478 * Return value: %TRUE if the widget is the focus widget.
6481 gtk_widget_is_focus (GtkWidget *widget)
6483 GtkWidget *toplevel;
6485 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6487 toplevel = gtk_widget_get_toplevel (widget);
6489 if (GTK_IS_WINDOW (toplevel))
6490 return widget == gtk_window_get_focus (GTK_WINDOW (toplevel));
6496 * gtk_widget_set_can_default:
6497 * @widget: a #GtkWidget
6498 * @can_default: whether or not @widget can be a default widget.
6500 * Specifies whether @widget can be a default widget. See
6501 * gtk_widget_grab_default() for details about the meaning of
6507 gtk_widget_set_can_default (GtkWidget *widget,
6508 gboolean can_default)
6510 g_return_if_fail (GTK_IS_WIDGET (widget));
6512 if (widget->priv->can_default != can_default)
6514 widget->priv->can_default = can_default;
6516 gtk_widget_queue_resize (widget);
6517 g_object_notify (G_OBJECT (widget), "can-default");
6522 * gtk_widget_get_can_default:
6523 * @widget: a #GtkWidget
6525 * Determines whether @widget can be a default widget. See
6526 * gtk_widget_set_can_default().
6528 * Return value: %TRUE if @widget can be a default widget, %FALSE otherwise
6533 gtk_widget_get_can_default (GtkWidget *widget)
6535 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6537 return widget->priv->can_default;
6541 * gtk_widget_has_default:
6542 * @widget: a #GtkWidget
6544 * Determines whether @widget is the current default widget within its
6545 * toplevel. See gtk_widget_set_can_default().
6547 * Return value: %TRUE if @widget is the current default widget within
6548 * its toplevel, %FALSE otherwise
6553 gtk_widget_has_default (GtkWidget *widget)
6555 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6557 return widget->priv->has_default;
6561 _gtk_widget_set_has_default (GtkWidget *widget,
6562 gboolean has_default)
6564 widget->priv->has_default = has_default;
6568 * gtk_widget_grab_default:
6569 * @widget: a #GtkWidget
6571 * Causes @widget to become the default widget. @widget must have the
6572 * %GTK_CAN_DEFAULT flag set; typically you have to set this flag
6573 * yourself by calling <literal>gtk_widget_set_can_default (@widget,
6574 * %TRUE)</literal>. The default widget is activated when
6575 * the user presses Enter in a window. Default widgets must be
6576 * activatable, that is, gtk_widget_activate() should affect them. Note
6577 * that #GtkEntry widgets require the "activates-default" property
6578 * set to %TRUE before they activate the default widget when Enter
6579 * is pressed and the #GtkEntry is focused.
6582 gtk_widget_grab_default (GtkWidget *widget)
6586 g_return_if_fail (GTK_IS_WIDGET (widget));
6587 g_return_if_fail (gtk_widget_get_can_default (widget));
6589 window = gtk_widget_get_toplevel (widget);
6591 if (window && gtk_widget_is_toplevel (window))
6592 gtk_window_set_default (GTK_WINDOW (window), widget);
6594 g_warning (G_STRLOC ": widget not within a GtkWindow");
6598 * gtk_widget_set_receives_default:
6599 * @widget: a #GtkWidget
6600 * @receives_default: whether or not @widget can be a default widget.
6602 * Specifies whether @widget will be treated as the default widget
6603 * within its toplevel when it has the focus, even if another widget
6606 * See gtk_widget_grab_default() for details about the meaning of
6612 gtk_widget_set_receives_default (GtkWidget *widget,
6613 gboolean receives_default)
6615 g_return_if_fail (GTK_IS_WIDGET (widget));
6617 if (widget->priv->receives_default != receives_default)
6619 widget->priv->receives_default = receives_default;
6621 g_object_notify (G_OBJECT (widget), "receives-default");
6626 * gtk_widget_get_receives_default:
6627 * @widget: a #GtkWidget
6629 * Determines whether @widget is alyways treated as default widget
6630 * withing its toplevel when it has the focus, even if another widget
6633 * See gtk_widget_set_receives_default().
6635 * Return value: %TRUE if @widget acts as default widget when focussed,
6641 gtk_widget_get_receives_default (GtkWidget *widget)
6643 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6645 return widget->priv->receives_default;
6649 * gtk_widget_has_grab:
6650 * @widget: a #GtkWidget
6652 * Determines whether the widget is currently grabbing events, so it
6653 * is the only widget receiving input events (keyboard and mouse).
6655 * See also gtk_grab_add().
6657 * Return value: %TRUE if the widget is in the grab_widgets stack
6662 gtk_widget_has_grab (GtkWidget *widget)
6664 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6666 return widget->priv->has_grab;
6670 _gtk_widget_set_has_grab (GtkWidget *widget,
6673 widget->priv->has_grab = has_grab;
6677 * gtk_widget_device_is_shadowed:
6678 * @widget: a #GtkWidget
6679 * @device: a #GdkDevice
6681 * Returns %TRUE if @device has been shadowed by a GTK+
6682 * device grab on another widget, so it would stop sending
6683 * events to @widget. This may be used in the
6684 * #GtkWidget::grab-notify signal to check for specific
6685 * devices. See gtk_device_grab_add().
6687 * Returns: %TRUE if there is an ongoing grab on @device
6688 * by another #GtkWidget than @widget.
6693 gtk_widget_device_is_shadowed (GtkWidget *widget,
6696 GtkWindowGroup *group;
6697 GtkWidget *grab_widget, *toplevel;
6699 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6700 g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
6702 if (!gtk_widget_get_realized (widget))
6705 toplevel = gtk_widget_get_toplevel (widget);
6707 if (GTK_IS_WINDOW (toplevel))
6708 group = gtk_window_get_group (GTK_WINDOW (toplevel));
6710 group = gtk_window_get_group (NULL);
6712 grab_widget = gtk_window_group_get_current_device_grab (group, device);
6714 /* Widget not inside the hierarchy of grab_widget */
6716 widget != grab_widget &&
6717 !gtk_widget_is_ancestor (widget, grab_widget))
6720 grab_widget = gtk_window_group_get_current_grab (group);
6721 if (grab_widget && widget != grab_widget &&
6722 !gtk_widget_is_ancestor (widget, grab_widget))
6729 * gtk_widget_set_name:
6730 * @widget: a #GtkWidget
6731 * @name: name for the widget
6733 * Widgets can be named, which allows you to refer to them from a
6734 * gtkrc file. You can apply a style to widgets with a particular name
6735 * in the gtkrc file. See the documentation for gtkrc files (on the
6736 * same page as the docs for #GtkRcStyle).
6738 * Note that widget names are separated by periods in paths (see
6739 * gtk_widget_path()), so names with embedded periods may cause confusion.
6742 gtk_widget_set_name (GtkWidget *widget,
6745 GtkWidgetPrivate *priv;
6748 g_return_if_fail (GTK_IS_WIDGET (widget));
6750 priv = widget->priv;
6752 new_name = g_strdup (name);
6753 g_free (priv->name);
6754 priv->name = new_name;
6757 gtk_widget_reset_rc_style (widget);
6759 g_object_notify (G_OBJECT (widget), "name");
6763 * gtk_widget_get_name:
6764 * @widget: a #GtkWidget
6766 * Retrieves the name of a widget. See gtk_widget_set_name() for the
6767 * significance of widget names.
6769 * Return value: name of the widget. This string is owned by GTK+ and
6770 * should not be modified or freed
6772 G_CONST_RETURN gchar*
6773 gtk_widget_get_name (GtkWidget *widget)
6775 GtkWidgetPrivate *priv;
6777 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
6779 priv = widget->priv;
6783 return G_OBJECT_TYPE_NAME (widget);
6787 * gtk_widget_set_state:
6788 * @widget: a #GtkWidget
6789 * @state: new state for @widget
6791 * This function is for use in widget implementations. Sets the state
6792 * of a widget (insensitive, prelighted, etc.) Usually you should set
6793 * the state using wrapper functions such as gtk_widget_set_sensitive().
6796 gtk_widget_set_state (GtkWidget *widget,
6799 GtkWidgetPrivate *priv;
6801 g_return_if_fail (GTK_IS_WIDGET (widget));
6803 priv = widget->priv;
6805 if (state == gtk_widget_get_state (widget))
6808 if (state == GTK_STATE_INSENSITIVE)
6809 gtk_widget_set_sensitive (widget, FALSE);
6815 data.state_restoration = FALSE;
6816 data.use_forall = FALSE;
6818 data.parent_sensitive = (gtk_widget_is_sensitive (priv->parent) != FALSE);
6820 data.parent_sensitive = TRUE;
6822 gtk_widget_propagate_state (widget, &data);
6824 if (gtk_widget_is_drawable (widget))
6825 gtk_widget_queue_draw (widget);
6830 * gtk_widget_get_state:
6831 * @widget: a #GtkWidget
6833 * Returns the widget's state. See gtk_widget_set_state().
6835 * Returns: the state of @widget.
6840 gtk_widget_get_state (GtkWidget *widget)
6842 g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_STATE_NORMAL);
6844 return widget->priv->state;
6848 * gtk_widget_set_visible:
6849 * @widget: a #GtkWidget
6850 * @visible: whether the widget should be shown or not
6852 * Sets the visibility state of @widget. Note that setting this to
6853 * %TRUE doesn't mean the widget is actually viewable, see
6854 * gtk_widget_get_visible().
6856 * This function simply calls gtk_widget_show() or gtk_widget_hide()
6857 * but is nicer to use when the visibility of the widget depends on
6863 gtk_widget_set_visible (GtkWidget *widget,
6866 g_return_if_fail (GTK_IS_WIDGET (widget));
6868 if (visible != gtk_widget_get_visible (widget))
6871 gtk_widget_show (widget);
6873 gtk_widget_hide (widget);
6878 _gtk_widget_set_visible_flag (GtkWidget *widget,
6881 widget->priv->visible = visible;
6885 * gtk_widget_get_visible:
6886 * @widget: a #GtkWidget
6888 * Determines whether the widget is visible. Note that this doesn't
6889 * take into account whether the widget's parent is also visible
6890 * or the widget is obscured in any way.
6892 * See gtk_widget_set_visible().
6894 * Return value: %TRUE if the widget is visible
6899 gtk_widget_get_visible (GtkWidget *widget)
6901 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6903 return widget->priv->visible;
6907 * gtk_widget_set_has_window:
6908 * @widget: a #GtkWidget
6909 * @has_window: whether or not @widget has a window.
6911 * Specifies whether @widget has a #GdkWindow of its own. Note that
6912 * all realized widgets have a non-%NULL "window" pointer
6913 * (gtk_widget_get_window() never returns a %NULL window when a widget
6914 * is realized), but for many of them it's actually the #GdkWindow of
6915 * one of its parent widgets. Widgets that do not create a %window for
6916 * themselves in GtkWidget::realize() must announce this by
6917 * calling this function with @has_window = %FALSE.
6919 * This function should only be called by widget implementations,
6920 * and they should call it in their init() function.
6925 gtk_widget_set_has_window (GtkWidget *widget,
6926 gboolean has_window)
6928 g_return_if_fail (GTK_IS_WIDGET (widget));
6930 widget->priv->no_window = !has_window;
6934 * gtk_widget_get_has_window:
6935 * @widget: a #GtkWidget
6937 * Determines whether @widget has a #GdkWindow of its own. See
6938 * gtk_widget_set_has_window().
6940 * Return value: %TRUE if @widget has a window, %FALSE otherwise
6945 gtk_widget_get_has_window (GtkWidget *widget)
6947 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6949 return ! widget->priv->no_window;
6953 * gtk_widget_is_toplevel:
6954 * @widget: a #GtkWidget
6956 * Determines whether @widget is a toplevel widget. Currently only
6957 * #GtkWindow and #GtkInvisible are toplevel widgets. Toplevel
6958 * widgets have no parent widget.
6960 * Return value: %TRUE if @widget is a toplevel, %FALSE otherwise
6965 gtk_widget_is_toplevel (GtkWidget *widget)
6967 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6969 return widget->priv->toplevel;
6973 _gtk_widget_set_is_toplevel (GtkWidget *widget,
6974 gboolean is_toplevel)
6976 widget->priv->toplevel = is_toplevel;
6980 * gtk_widget_is_drawable:
6981 * @widget: a #GtkWidget
6983 * Determines whether @widget can be drawn to. A widget can be drawn
6984 * to if it is mapped and visible.
6986 * Return value: %TRUE if @widget is drawable, %FALSE otherwise
6991 gtk_widget_is_drawable (GtkWidget *widget)
6993 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
6995 return (gtk_widget_get_visible (widget) &&
6996 gtk_widget_get_mapped (widget));
7000 * gtk_widget_get_realized:
7001 * @widget: a #GtkWidget
7003 * Determines whether @widget is realized.
7005 * Return value: %TRUE if @widget is realized, %FALSE otherwise
7010 gtk_widget_get_realized (GtkWidget *widget)
7012 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
7014 return widget->priv->realized;
7018 * gtk_widget_set_realized:
7019 * @widget: a #GtkWidget
7020 * @realized: %TRUE to mark the widget as realized
7022 * Marks the widget as being realized.
7024 * This function should only ever be called in a derived widget's
7025 * "realize" or "unrealize" implementation.
7030 gtk_widget_set_realized (GtkWidget *widget,
7033 g_return_if_fail (GTK_IS_WIDGET (widget));
7035 widget->priv->realized = realized;
7039 * gtk_widget_get_mapped:
7040 * @widget: a #GtkWidget
7042 * Whether the widget is mapped.
7044 * Return value: %TRUE if the widget is mapped, %FALSE otherwise.
7049 gtk_widget_get_mapped (GtkWidget *widget)
7051 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
7053 return widget->priv->mapped;
7057 * gtk_widget_set_mapped:
7058 * @widget: a #GtkWidget
7059 * @mapped: %TRUE to mark the widget as mapped
7061 * Marks the widget as being realized.
7063 * This function should only ever be called in a derived widget's
7064 * "map" or "unmap" implementation.
7069 gtk_widget_set_mapped (GtkWidget *widget,
7072 g_return_if_fail (GTK_IS_WIDGET (widget));
7074 widget->priv->mapped = mapped;
7078 * gtk_widget_set_app_paintable:
7079 * @widget: a #GtkWidget
7080 * @app_paintable: %TRUE if the application will paint on the widget
7082 * Sets whether the application intends to draw on the widget in
7083 * an #GtkWidget::draw handler.
7085 * This is a hint to the widget and does not affect the behavior of
7086 * the GTK+ core; many widgets ignore this flag entirely. For widgets
7087 * that do pay attention to the flag, such as #GtkEventBox and #GtkWindow,
7088 * the effect is to suppress default themed drawing of the widget's
7089 * background. (Children of the widget will still be drawn.) The application
7090 * is then entirely responsible for drawing the widget background.
7092 * Note that the background is still drawn when the widget is mapped.
7095 gtk_widget_set_app_paintable (GtkWidget *widget,
7096 gboolean app_paintable)
7098 g_return_if_fail (GTK_IS_WIDGET (widget));
7100 app_paintable = (app_paintable != FALSE);
7102 if (widget->priv->app_paintable != app_paintable)
7104 widget->priv->app_paintable = app_paintable;
7106 if (gtk_widget_is_drawable (widget))
7107 gtk_widget_queue_draw (widget);
7109 g_object_notify (G_OBJECT (widget), "app-paintable");
7114 * gtk_widget_get_app_paintable:
7115 * @widget: a #GtkWidget
7117 * Determines whether the application intends to draw on the widget in
7118 * an #GtkWidget::draw handler.
7120 * See gtk_widget_set_app_paintable()
7122 * Return value: %TRUE if the widget is app paintable
7127 gtk_widget_get_app_paintable (GtkWidget *widget)
7129 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
7131 return widget->priv->app_paintable;
7135 * gtk_widget_set_double_buffered:
7136 * @widget: a #GtkWidget
7137 * @double_buffered: %TRUE to double-buffer a widget
7139 * Widgets are double buffered by default; you can use this function
7140 * to turn off the buffering. "Double buffered" simply means that
7141 * gdk_window_begin_paint_region() and gdk_window_end_paint() are called
7142 * automatically around expose events sent to the
7143 * widget. gdk_window_begin_paint() diverts all drawing to a widget's
7144 * window to an offscreen buffer, and gdk_window_end_paint() draws the
7145 * buffer to the screen. The result is that users see the window
7146 * update in one smooth step, and don't see individual graphics
7147 * primitives being rendered.
7149 * In very simple terms, double buffered widgets don't flicker,
7150 * so you would only use this function to turn off double buffering
7151 * if you had special needs and really knew what you were doing.
7153 * Note: if you turn off double-buffering, you have to handle
7154 * expose events, since even the clearing to the background color or
7155 * pixmap will not happen automatically (as it is done in
7156 * gdk_window_begin_paint()).
7159 gtk_widget_set_double_buffered (GtkWidget *widget,
7160 gboolean double_buffered)
7162 g_return_if_fail (GTK_IS_WIDGET (widget));
7164 double_buffered = (double_buffered != FALSE);
7166 if (widget->priv->double_buffered != double_buffered)
7168 widget->priv->double_buffered = double_buffered;
7170 g_object_notify (G_OBJECT (widget), "double-buffered");
7175 * gtk_widget_get_double_buffered:
7176 * @widget: a #GtkWidget
7178 * Determines whether the widget is double buffered.
7180 * See gtk_widget_set_double_buffered()
7182 * Return value: %TRUE if the widget is double buffered
7187 gtk_widget_get_double_buffered (GtkWidget *widget)
7189 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
7191 return widget->priv->double_buffered;
7195 * gtk_widget_set_redraw_on_allocate:
7196 * @widget: a #GtkWidget
7197 * @redraw_on_allocate: if %TRUE, the entire widget will be redrawn
7198 * when it is allocated to a new size. Otherwise, only the
7199 * new portion of the widget will be redrawn.
7201 * Sets whether the entire widget is queued for drawing when its size
7202 * allocation changes. By default, this setting is %TRUE and
7203 * the entire widget is redrawn on every size change. If your widget
7204 * leaves the upper left unchanged when made bigger, turning this
7205 * setting off will improve performance.
7207 * Note that for %NO_WINDOW widgets setting this flag to %FALSE turns
7208 * off all allocation on resizing: the widget will not even redraw if
7209 * its position changes; this is to allow containers that don't draw
7210 * anything to avoid excess invalidations. If you set this flag on a
7211 * %NO_WINDOW widget that <emphasis>does</emphasis> draw on @widget->window,
7212 * you are responsible for invalidating both the old and new allocation
7213 * of the widget when the widget is moved and responsible for invalidating
7214 * regions newly when the widget increases size.
7217 gtk_widget_set_redraw_on_allocate (GtkWidget *widget,
7218 gboolean redraw_on_allocate)
7220 g_return_if_fail (GTK_IS_WIDGET (widget));
7222 widget->priv->redraw_on_alloc = redraw_on_allocate;
7226 * gtk_widget_set_sensitive:
7227 * @widget: a #GtkWidget
7228 * @sensitive: %TRUE to make the widget sensitive
7230 * Sets the sensitivity of a widget. A widget is sensitive if the user
7231 * can interact with it. Insensitive widgets are "grayed out" and the
7232 * user can't interact with them. Insensitive widgets are known as
7233 * "inactive", "disabled", or "ghosted" in some other toolkits.
7236 gtk_widget_set_sensitive (GtkWidget *widget,
7239 GtkWidgetPrivate *priv;
7242 g_return_if_fail (GTK_IS_WIDGET (widget));
7244 priv = widget->priv;
7246 sensitive = (sensitive != FALSE);
7248 if (widget->priv->sensitive == sensitive)
7253 widget->priv->sensitive = TRUE;
7254 data.state = priv->saved_state;
7258 widget->priv->sensitive = FALSE;
7259 data.state = gtk_widget_get_state (widget);
7261 data.state_restoration = TRUE;
7262 data.use_forall = TRUE;
7265 data.parent_sensitive = gtk_widget_is_sensitive (priv->parent);
7267 data.parent_sensitive = TRUE;
7269 gtk_widget_propagate_state (widget, &data);
7270 if (gtk_widget_is_drawable (widget))
7271 gtk_widget_queue_draw (widget);
7273 g_object_notify (G_OBJECT (widget), "sensitive");
7277 * gtk_widget_get_sensitive:
7278 * @widget: a #GtkWidget
7280 * Returns the widget's sensitivity (in the sense of returning
7281 * the value that has been set using gtk_widget_set_sensitive()).
7283 * The effective sensitivity of a widget is however determined by both its
7284 * own and its parent widget's sensitivity. See gtk_widget_is_sensitive().
7286 * Returns: %TRUE if the widget is sensitive
7291 gtk_widget_get_sensitive (GtkWidget *widget)
7293 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
7295 return widget->priv->sensitive;
7299 * gtk_widget_is_sensitive:
7300 * @widget: a #GtkWidget
7302 * Returns the widget's effective sensitivity, which means
7303 * it is sensitive itself and also its parent widget is sensntive
7305 * Returns: %TRUE if the widget is effectively sensitive
7310 gtk_widget_is_sensitive (GtkWidget *widget)
7312 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
7314 return widget->priv->sensitive && widget->priv->parent_sensitive;
7318 * gtk_widget_set_parent:
7319 * @widget: a #GtkWidget
7320 * @parent: parent container
7322 * This function is useful only when implementing subclasses of
7324 * Sets the container as the parent of @widget, and takes care of
7325 * some details such as updating the state and style of the child
7326 * to reflect its new location. The opposite function is
7327 * gtk_widget_unparent().
7330 gtk_widget_set_parent (GtkWidget *widget,
7333 GtkWidgetPrivate *priv;
7336 g_return_if_fail (GTK_IS_WIDGET (widget));
7337 g_return_if_fail (GTK_IS_WIDGET (parent));
7338 g_return_if_fail (widget != parent);
7340 priv = widget->priv;
7342 if (priv->parent != NULL)
7344 g_warning ("Can't set a parent on widget which has a parent\n");
7347 if (gtk_widget_is_toplevel (widget))
7349 g_warning ("Can't set a parent on a toplevel widget\n");
7353 /* keep this function in sync with gtk_menu_attach_to_widget()
7356 g_object_ref_sink (widget);
7357 priv->parent = parent;
7359 if (gtk_widget_get_state (parent) != GTK_STATE_NORMAL)
7360 data.state = gtk_widget_get_state (parent);
7362 data.state = gtk_widget_get_state (widget);
7363 data.state_restoration = FALSE;
7364 data.parent_sensitive = (gtk_widget_is_sensitive (parent) != FALSE);
7365 data.use_forall = gtk_widget_is_sensitive (parent) != gtk_widget_is_sensitive (widget);
7367 gtk_widget_propagate_state (widget, &data);
7369 gtk_widget_reset_rc_styles (widget);
7371 g_signal_emit (widget, widget_signals[PARENT_SET], 0, NULL);
7372 if (priv->parent->priv->anchored)
7373 _gtk_widget_propagate_hierarchy_changed (widget, NULL);
7374 g_object_notify (G_OBJECT (widget), "parent");
7376 /* Enforce realized/mapped invariants
7378 if (gtk_widget_get_realized (priv->parent))
7379 gtk_widget_realize (widget);
7381 if (gtk_widget_get_visible (priv->parent) &&
7382 gtk_widget_get_visible (widget))
7384 if (gtk_widget_get_child_visible (widget) &&
7385 gtk_widget_get_mapped (priv->parent))
7386 gtk_widget_map (widget);
7388 gtk_widget_queue_resize (widget);
7391 /* child may cause parent's expand to change, if the child is
7392 * expanded. If child is not expanded, then it can't modify the
7393 * parent's expand. If the child becomes expanded later then it will
7394 * queue compute_expand then. This optimization plus defaulting
7395 * newly-constructed widgets to need_compute_expand=FALSE should
7396 * mean that initially building a widget tree doesn't have to keep
7397 * walking up setting need_compute_expand on parents over and over.
7399 * We can't change a parent to need to expand unless we're visible.
7401 if (gtk_widget_get_visible (widget) &&
7402 (priv->need_compute_expand ||
7403 priv->computed_hexpand ||
7404 priv->computed_vexpand))
7406 gtk_widget_queue_compute_expand (parent);
7411 * gtk_widget_get_parent:
7412 * @widget: a #GtkWidget
7414 * Returns the parent container of @widget.
7416 * Return value: (transfer none): the parent container of @widget, or %NULL
7419 gtk_widget_get_parent (GtkWidget *widget)
7421 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
7423 return widget->priv->parent;
7426 /*****************************************
7428 * see docs/styles.txt
7429 *****************************************/
7432 * gtk_widget_style_attach:
7433 * @widget: a #GtkWidget
7435 * This function attaches the widget's #GtkStyle to the widget's
7436 * #GdkWindow. It is a replacement for
7439 * widget->style = gtk_style_attach (widget->style, widget->window);
7442 * and should only ever be called in a derived widget's "realize"
7443 * implementation which does not chain up to its parent class'
7444 * "realize" implementation, because one of the parent classes
7445 * (finally #GtkWidget) would attach the style itself.
7450 gtk_widget_style_attach (GtkWidget *widget)
7452 GtkWidgetPrivate *priv;
7454 g_return_if_fail (GTK_IS_WIDGET (widget));
7455 g_return_if_fail (gtk_widget_get_realized (widget));
7457 priv = widget->priv;
7459 priv->style = gtk_style_attach (priv->style, priv->window);
7463 * gtk_widget_has_rc_style:
7464 * @widget: a #GtkWidget
7466 * Determines if the widget style has been looked up through the rc mechanism.
7468 * Returns: %TRUE if the widget has been looked up through the rc
7469 * mechanism, %FALSE otherwise.
7474 gtk_widget_has_rc_style (GtkWidget *widget)
7476 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
7478 return widget->priv->rc_style;
7482 * gtk_widget_set_style:
7483 * @widget: a #GtkWidget
7484 * @style: (allow-none): a #GtkStyle, or %NULL to remove the effect of a previous
7485 * gtk_widget_set_style() and go back to the default style
7487 * Sets the #GtkStyle for a widget (@widget->style). You probably don't
7488 * want to use this function; it interacts badly with themes, because
7489 * themes work by replacing the #GtkStyle. Instead, use
7490 * gtk_widget_modify_style().
7493 gtk_widget_set_style (GtkWidget *widget,
7496 g_return_if_fail (GTK_IS_WIDGET (widget));
7500 gboolean initial_emission;
7502 initial_emission = !widget->priv->rc_style && !widget->priv->user_style;
7504 widget->priv->rc_style = FALSE;
7505 widget->priv->user_style = TRUE;
7507 gtk_widget_set_style_internal (widget, style, initial_emission);
7511 if (widget->priv->user_style)
7512 gtk_widget_reset_rc_style (widget);
7517 * gtk_widget_ensure_style:
7518 * @widget: a #GtkWidget
7520 * Ensures that @widget has a style (@widget->style). Not a very useful
7521 * function; most of the time, if you want the style, the widget is
7522 * realized, and realized widgets are guaranteed to have a style
7526 gtk_widget_ensure_style (GtkWidget *widget)
7528 g_return_if_fail (GTK_IS_WIDGET (widget));
7530 if (!widget->priv->rc_style && !widget->priv->user_style)
7531 gtk_widget_reset_rc_style (widget);
7534 /* Look up the RC style for this widget, unsetting any user style that
7535 * may be in effect currently
7538 gtk_widget_reset_rc_style (GtkWidget *widget)
7540 GtkWidgetPrivate *priv = widget->priv;
7541 GtkStyle *new_style = NULL;
7542 gboolean initial_emission;
7544 initial_emission = !priv->rc_style && !priv->user_style;
7546 priv->user_style = FALSE;
7547 priv->rc_style = TRUE;
7549 if (gtk_widget_has_screen (widget))
7550 new_style = gtk_rc_get_style (widget);
7552 new_style = gtk_widget_get_default_style ();
7554 if (initial_emission || new_style != priv->style)
7555 gtk_widget_set_style_internal (widget, new_style, initial_emission);
7559 * gtk_widget_get_style:
7560 * @widget: a #GtkWidget
7562 * Simply an accessor function that returns @widget->style.
7564 * Return value: (transfer none): the widget's #GtkStyle
7567 gtk_widget_get_style (GtkWidget *widget)
7569 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
7571 return widget->priv->style;
7575 * gtk_widget_modify_style:
7576 * @widget: a #GtkWidget
7577 * @style: the #GtkRcStyle holding the style modifications
7579 * Modifies style values on the widget. Modifications made using this
7580 * technique take precedence over style values set via an RC file,
7581 * however, they will be overriden if a style is explicitely set on
7582 * the widget using gtk_widget_set_style(). The #GtkRcStyle structure
7583 * is designed so each field can either be set or unset, so it is
7584 * possible, using this function, to modify some style values and
7585 * leave the others unchanged.
7587 * Note that modifications made with this function are not cumulative
7588 * with previous calls to gtk_widget_modify_style() or with such
7589 * functions as gtk_widget_modify_fg(). If you wish to retain
7590 * previous values, you must first call gtk_widget_get_modifier_style(),
7591 * make your modifications to the returned style, then call
7592 * gtk_widget_modify_style() with that style. On the other hand,
7593 * if you first call gtk_widget_modify_style(), subsequent calls
7594 * to such functions gtk_widget_modify_fg() will have a cumulative
7595 * effect with the initial modifications.
7598 gtk_widget_modify_style (GtkWidget *widget,
7601 g_return_if_fail (GTK_IS_WIDGET (widget));
7602 g_return_if_fail (GTK_IS_RC_STYLE (style));
7604 g_object_set_qdata_full (G_OBJECT (widget),
7606 gtk_rc_style_copy (style),
7607 (GDestroyNotify) g_object_unref);
7609 /* note that "style" may be invalid here if it was the old
7610 * modifier style and the only reference was our own.
7613 if (widget->priv->rc_style)
7614 gtk_widget_reset_rc_style (widget);
7618 * gtk_widget_get_modifier_style:
7619 * @widget: a #GtkWidget
7621 * Returns the current modifier style for the widget. (As set by
7622 * gtk_widget_modify_style().) If no style has previously set, a new
7623 * #GtkRcStyle will be created with all values unset, and set as the
7624 * modifier style for the widget. If you make changes to this rc
7625 * style, you must call gtk_widget_modify_style(), passing in the
7626 * returned rc style, to make sure that your changes take effect.
7628 * Caution: passing the style back to gtk_widget_modify_style() will
7629 * normally end up destroying it, because gtk_widget_modify_style() copies
7630 * the passed-in style and sets the copy as the new modifier style,
7631 * thus dropping any reference to the old modifier style. Add a reference
7632 * to the modifier style if you want to keep it alive.
7634 * Return value: (transfer none): the modifier style for the widget. This rc style is
7635 * owned by the widget. If you want to keep a pointer to value this
7636 * around, you must add a refcount using g_object_ref().
7639 gtk_widget_get_modifier_style (GtkWidget *widget)
7641 GtkRcStyle *rc_style;
7643 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
7645 rc_style = g_object_get_qdata (G_OBJECT (widget), quark_rc_style);
7649 rc_style = gtk_rc_style_new ();
7650 g_object_set_qdata_full (G_OBJECT (widget),
7653 (GDestroyNotify) g_object_unref);
7660 gtk_widget_modify_color_component (GtkWidget *widget,
7661 GtkRcFlags component,
7663 const GdkColor *color)
7665 GtkRcStyle *rc_style = gtk_widget_get_modifier_style (widget);
7672 rc_style->fg[state] = *color;
7675 rc_style->bg[state] = *color;
7678 rc_style->text[state] = *color;
7681 rc_style->base[state] = *color;
7684 g_assert_not_reached();
7687 rc_style->color_flags[state] |= component;
7690 rc_style->color_flags[state] &= ~component;
7692 gtk_widget_modify_style (widget, rc_style);
7696 * gtk_widget_modify_symbolic_color:
7697 * @widget: a #GtkWidget
7698 * @name: the name of the symbolic color to modify
7699 * @color: (allow-none): the color to assign (does not need to be allocated),
7700 * or %NULL to undo the effect of previous calls to
7701 * of gtk_widget_modify_symbolic_color().
7703 * Sets a symbolic color for a widget.
7704 * All other style values are left untouched. See also
7705 * gtk_widget_modify_style().
7710 gtk_widget_modify_symbolic_color (GtkWidget *widget,
7712 const GdkColor *color)
7714 GtkRcStyle *rc_style = gtk_widget_get_modifier_style (widget);
7716 _gtk_rc_style_set_symbolic_color (rc_style, name, color);
7718 gtk_widget_modify_style (widget, rc_style);
7722 * gtk_widget_modify_fg:
7723 * @widget: a #GtkWidget
7724 * @state: the state for which to set the foreground color
7725 * @color: (allow-none): the color to assign (does not need to be allocated),
7726 * or %NULL to undo the effect of previous calls to
7727 * of gtk_widget_modify_fg().
7729 * Sets the foreground color for a widget in a particular state.
7730 * All other style values are left untouched. See also
7731 * gtk_widget_modify_style().
7734 gtk_widget_modify_fg (GtkWidget *widget,
7736 const GdkColor *color)
7738 g_return_if_fail (GTK_IS_WIDGET (widget));
7739 g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE);
7741 gtk_widget_modify_color_component (widget, GTK_RC_FG, state, color);
7745 * gtk_widget_modify_bg:
7746 * @widget: a #GtkWidget
7747 * @state: the state for which to set the background color
7748 * @color: (allow-none): the color to assign (does not need to be allocated),
7749 * or %NULL to undo the effect of previous calls to
7750 * of gtk_widget_modify_bg().
7752 * Sets the background color for a widget in a particular state.
7753 * All other style values are left untouched. See also
7754 * gtk_widget_modify_style().
7756 * Note that "no window" widgets (which have the %GTK_NO_WINDOW flag set)
7757 * draw on their parent container's window and thus may not draw any
7758 * background themselves. This is the case for e.g. #GtkLabel. To modify
7759 * the background of such widgets, you have to set the background color
7760 * on their parent; if you want to set the background of a rectangular
7761 * area around a label, try placing the label in a #GtkEventBox widget
7762 * and setting the background color on that.
7765 gtk_widget_modify_bg (GtkWidget *widget,
7767 const GdkColor *color)
7769 g_return_if_fail (GTK_IS_WIDGET (widget));
7770 g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE);
7772 gtk_widget_modify_color_component (widget, GTK_RC_BG, state, color);
7776 * gtk_widget_modify_text:
7777 * @widget: a #GtkWidget
7778 * @state: the state for which to set the text color
7779 * @color: (allow-none): the color to assign (does not need to be allocated),
7780 * or %NULL to undo the effect of previous calls to
7781 * of gtk_widget_modify_text().
7783 * Sets the text color for a widget in a particular state. All other
7784 * style values are left untouched. The text color is the foreground
7785 * color used along with the base color (see gtk_widget_modify_base())
7786 * for widgets such as #GtkEntry and #GtkTextView. See also
7787 * gtk_widget_modify_style().
7790 gtk_widget_modify_text (GtkWidget *widget,
7792 const GdkColor *color)
7794 g_return_if_fail (GTK_IS_WIDGET (widget));
7795 g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE);
7797 gtk_widget_modify_color_component (widget, GTK_RC_TEXT, state, color);
7801 * gtk_widget_modify_base:
7802 * @widget: a #GtkWidget
7803 * @state: the state for which to set the base color
7804 * @color: (allow-none): the color to assign (does not need to be allocated),
7805 * or %NULL to undo the effect of previous calls to
7806 * of gtk_widget_modify_base().
7808 * Sets the base color for a widget in a particular state.
7809 * All other style values are left untouched. The base color
7810 * is the background color used along with the text color
7811 * (see gtk_widget_modify_text()) for widgets such as #GtkEntry
7812 * and #GtkTextView. See also gtk_widget_modify_style().
7814 * Note that "no window" widgets (which have the %GTK_NO_WINDOW flag set)
7815 * draw on their parent container's window and thus may not draw any
7816 * background themselves. This is the case for e.g. #GtkLabel. To modify
7817 * the background of such widgets, you have to set the base color on their
7818 * parent; if you want to set the background of a rectangular area around
7819 * a label, try placing the label in a #GtkEventBox widget and setting
7820 * the base color on that.
7823 gtk_widget_modify_base (GtkWidget *widget,
7825 const GdkColor *color)
7827 g_return_if_fail (GTK_IS_WIDGET (widget));
7828 g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE);
7830 gtk_widget_modify_color_component (widget, GTK_RC_BASE, state, color);
7834 modify_color_property (GtkWidget *widget,
7835 GtkRcStyle *rc_style,
7837 const GdkColor *color)
7839 GQuark type_name = g_type_qname (G_OBJECT_TYPE (widget));
7840 GQuark property_name = g_quark_from_string (name);
7844 GtkRcProperty rc_property = {0};
7847 rc_property.type_name = type_name;
7848 rc_property.property_name = property_name;
7849 rc_property.origin = NULL;
7851 color_name = gdk_color_to_string (color);
7852 g_value_init (&rc_property.value, G_TYPE_STRING);
7853 g_value_take_string (&rc_property.value, color_name);
7855 _gtk_rc_style_set_rc_property (rc_style, &rc_property);
7857 g_value_unset (&rc_property.value);
7860 _gtk_rc_style_unset_rc_property (rc_style, type_name, property_name);
7864 * gtk_widget_modify_cursor:
7865 * @widget: a #GtkWidget
7866 * @primary: the color to use for primary cursor (does not need to be
7867 * allocated), or %NULL to undo the effect of previous calls to
7868 * of gtk_widget_modify_cursor().
7869 * @secondary: the color to use for secondary cursor (does not need to be
7870 * allocated), or %NULL to undo the effect of previous calls to
7871 * of gtk_widget_modify_cursor().
7873 * Sets the cursor color to use in a widget, overriding the
7874 * #GtkWidget:cursor-color and #GtkWidget:secondary-cursor-color
7875 * style properties. All other style values are left untouched.
7876 * See also gtk_widget_modify_style().
7881 gtk_widget_modify_cursor (GtkWidget *widget,
7882 const GdkColor *primary,
7883 const GdkColor *secondary)
7885 GtkRcStyle *rc_style;
7887 g_return_if_fail (GTK_IS_WIDGET (widget));
7889 rc_style = gtk_widget_get_modifier_style (widget);
7891 modify_color_property (widget, rc_style, "cursor-color", primary);
7892 modify_color_property (widget, rc_style, "secondary-cursor-color", secondary);
7894 gtk_widget_modify_style (widget, rc_style);
7898 * gtk_widget_modify_font:
7899 * @widget: a #GtkWidget
7900 * @font_desc: (allow-none): the font description to use, or %NULL to undo
7901 * the effect of previous calls to gtk_widget_modify_font().
7903 * Sets the font to use for a widget. All other style values are left
7904 * untouched. See also gtk_widget_modify_style().
7907 gtk_widget_modify_font (GtkWidget *widget,
7908 PangoFontDescription *font_desc)
7910 GtkRcStyle *rc_style;
7912 g_return_if_fail (GTK_IS_WIDGET (widget));
7914 rc_style = gtk_widget_get_modifier_style (widget);
7916 if (rc_style->font_desc)
7917 pango_font_description_free (rc_style->font_desc);
7920 rc_style->font_desc = pango_font_description_copy (font_desc);
7922 rc_style->font_desc = NULL;
7924 gtk_widget_modify_style (widget, rc_style);
7928 gtk_widget_real_direction_changed (GtkWidget *widget,
7929 GtkTextDirection previous_direction)
7931 gtk_widget_queue_resize (widget);
7935 gtk_widget_real_style_set (GtkWidget *widget,
7936 GtkStyle *previous_style)
7938 GtkWidgetPrivate *priv = widget->priv;
7940 if (gtk_widget_get_realized (widget) &&
7941 gtk_widget_get_has_window (widget))
7942 gtk_style_set_background (priv->style, priv->window, priv->state);
7946 gtk_widget_set_style_internal (GtkWidget *widget,
7948 gboolean initial_emission)
7950 GtkWidgetPrivate *priv = widget->priv;
7952 g_object_ref (widget);
7953 g_object_freeze_notify (G_OBJECT (widget));
7955 if (priv->style != style)
7957 GtkStyle *previous_style;
7959 if (gtk_widget_get_realized (widget))
7961 gtk_widget_reset_shapes (widget);
7962 gtk_style_detach (priv->style);
7965 previous_style = priv->style;
7966 priv->style = style;
7967 g_object_ref (priv->style);
7969 if (gtk_widget_get_realized (widget))
7970 priv->style = gtk_style_attach (priv->style, priv->window);
7972 gtk_widget_update_pango_context (widget);
7973 g_signal_emit (widget,
7974 widget_signals[STYLE_SET],
7976 initial_emission ? NULL : previous_style);
7977 g_object_unref (previous_style);
7979 if (priv->anchored && !initial_emission)
7980 gtk_widget_queue_resize (widget);
7982 else if (initial_emission)
7984 gtk_widget_update_pango_context (widget);
7985 g_signal_emit (widget,
7986 widget_signals[STYLE_SET],
7990 g_object_notify (G_OBJECT (widget), "style");
7991 g_object_thaw_notify (G_OBJECT (widget));
7992 g_object_unref (widget);
7996 GtkWidget *previous_toplevel;
7997 GdkScreen *previous_screen;
7998 GdkScreen *new_screen;
7999 } HierarchyChangedInfo;
8002 do_screen_change (GtkWidget *widget,
8003 GdkScreen *old_screen,
8004 GdkScreen *new_screen)
8006 if (old_screen != new_screen)
8010 PangoContext *context = g_object_get_qdata (G_OBJECT (widget), quark_pango_context);
8012 g_object_set_qdata (G_OBJECT (widget), quark_pango_context, NULL);
8015 _gtk_tooltip_hide (widget);
8016 g_signal_emit (widget, widget_signals[SCREEN_CHANGED], 0, old_screen);
8021 gtk_widget_propagate_hierarchy_changed_recurse (GtkWidget *widget,
8022 gpointer client_data)
8024 GtkWidgetPrivate *priv = widget->priv;
8025 HierarchyChangedInfo *info = client_data;
8026 gboolean new_anchored = gtk_widget_is_toplevel (widget) ||
8027 (priv->parent && priv->parent->priv->anchored);
8029 if (priv->anchored != new_anchored)
8031 g_object_ref (widget);
8033 priv->anchored = new_anchored;
8035 g_signal_emit (widget, widget_signals[HIERARCHY_CHANGED], 0, info->previous_toplevel);
8036 do_screen_change (widget, info->previous_screen, info->new_screen);
8038 if (GTK_IS_CONTAINER (widget))
8039 gtk_container_forall (GTK_CONTAINER (widget),
8040 gtk_widget_propagate_hierarchy_changed_recurse,
8043 g_object_unref (widget);
8048 * _gtk_widget_propagate_hierarchy_changed:
8049 * @widget: a #GtkWidget
8050 * @previous_toplevel: Previous toplevel
8052 * Propagates changes in the anchored state to a widget and all
8053 * children, unsetting or setting the %ANCHORED flag, and
8054 * emitting #GtkWidget::hierarchy-changed.
8057 _gtk_widget_propagate_hierarchy_changed (GtkWidget *widget,
8058 GtkWidget *previous_toplevel)
8060 GtkWidgetPrivate *priv = widget->priv;
8061 HierarchyChangedInfo info;
8063 info.previous_toplevel = previous_toplevel;
8064 info.previous_screen = previous_toplevel ? gtk_widget_get_screen (previous_toplevel) : NULL;
8066 if (gtk_widget_is_toplevel (widget) ||
8067 (priv->parent && priv->parent->priv->anchored))
8068 info.new_screen = gtk_widget_get_screen (widget);
8070 info.new_screen = NULL;
8072 if (info.previous_screen)
8073 g_object_ref (info.previous_screen);
8074 if (previous_toplevel)
8075 g_object_ref (previous_toplevel);
8077 gtk_widget_propagate_hierarchy_changed_recurse (widget, &info);
8079 if (previous_toplevel)
8080 g_object_unref (previous_toplevel);
8081 if (info.previous_screen)
8082 g_object_unref (info.previous_screen);
8086 gtk_widget_propagate_screen_changed_recurse (GtkWidget *widget,
8087 gpointer client_data)
8089 HierarchyChangedInfo *info = client_data;
8091 g_object_ref (widget);
8093 do_screen_change (widget, info->previous_screen, info->new_screen);
8095 if (GTK_IS_CONTAINER (widget))
8096 gtk_container_forall (GTK_CONTAINER (widget),
8097 gtk_widget_propagate_screen_changed_recurse,
8100 g_object_unref (widget);
8104 * gtk_widget_is_composited:
8105 * @widget: a #GtkWidget
8107 * Whether @widget can rely on having its alpha channel
8108 * drawn correctly. On X11 this function returns whether a
8109 * compositing manager is running for @widget's screen.
8111 * Please note that the semantics of this call will change
8112 * in the future if used on a widget that has a composited
8113 * window in its hierarchy (as set by gdk_window_set_composited()).
8115 * Return value: %TRUE if the widget can rely on its alpha
8116 * channel being drawn correctly.
8121 gtk_widget_is_composited (GtkWidget *widget)
8125 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
8127 screen = gtk_widget_get_screen (widget);
8129 return gdk_screen_is_composited (screen);
8133 propagate_composited_changed (GtkWidget *widget,
8136 if (GTK_IS_CONTAINER (widget))
8138 gtk_container_forall (GTK_CONTAINER (widget),
8139 propagate_composited_changed,
8143 g_signal_emit (widget, widget_signals[COMPOSITED_CHANGED], 0);
8147 _gtk_widget_propagate_composited_changed (GtkWidget *widget)
8149 propagate_composited_changed (widget, NULL);
8153 * _gtk_widget_propagate_screen_changed:
8154 * @widget: a #GtkWidget
8155 * @previous_screen: Previous screen
8157 * Propagates changes in the screen for a widget to all
8158 * children, emitting #GtkWidget::screen-changed.
8161 _gtk_widget_propagate_screen_changed (GtkWidget *widget,
8162 GdkScreen *previous_screen)
8164 HierarchyChangedInfo info;
8166 info.previous_screen = previous_screen;
8167 info.new_screen = gtk_widget_get_screen (widget);
8169 if (previous_screen)
8170 g_object_ref (previous_screen);
8172 gtk_widget_propagate_screen_changed_recurse (widget, &info);
8174 if (previous_screen)
8175 g_object_unref (previous_screen);
8179 reset_rc_styles_recurse (GtkWidget *widget, gpointer data)
8181 if (widget->priv->rc_style)
8182 gtk_widget_reset_rc_style (widget);
8184 if (GTK_IS_CONTAINER (widget))
8185 gtk_container_forall (GTK_CONTAINER (widget),
8186 reset_rc_styles_recurse,
8192 * gtk_widget_reset_rc_styles:
8193 * @widget: a #GtkWidget.
8195 * Reset the styles of @widget and all descendents, so when
8196 * they are looked up again, they get the correct values
8197 * for the currently loaded RC file settings.
8199 * This function is not useful for applications.
8202 gtk_widget_reset_rc_styles (GtkWidget *widget)
8204 g_return_if_fail (GTK_IS_WIDGET (widget));
8206 reset_rc_styles_recurse (widget, NULL);
8210 * gtk_widget_get_default_style:
8212 * Returns the default style used by all widgets initially.
8214 * Returns: (transfer none): the default style. This #GtkStyle object is owned
8215 * by GTK+ and should not be modified or freed.
8218 gtk_widget_get_default_style (void)
8220 if (!gtk_default_style)
8222 gtk_default_style = gtk_style_new ();
8223 g_object_ref (gtk_default_style);
8226 return gtk_default_style;
8229 static PangoContext *
8230 gtk_widget_peek_pango_context (GtkWidget *widget)
8232 return g_object_get_qdata (G_OBJECT (widget), quark_pango_context);
8236 * gtk_widget_get_pango_context:
8237 * @widget: a #GtkWidget
8239 * Gets a #PangoContext with the appropriate font map, font description,
8240 * and base direction for this widget. Unlike the context returned
8241 * by gtk_widget_create_pango_context(), this context is owned by
8242 * the widget (it can be used until the screen for the widget changes
8243 * or the widget is removed from its toplevel), and will be updated to
8244 * match any changes to the widget's attributes.
8246 * If you create and keep a #PangoLayout using this context, you must
8247 * deal with changes to the context by calling pango_layout_context_changed()
8248 * on the layout in response to the #GtkWidget::style-set and
8249 * #GtkWidget::direction-changed signals for the widget.
8251 * Return value: (transfer none): the #PangoContext for the widget.
8254 gtk_widget_get_pango_context (GtkWidget *widget)
8256 PangoContext *context;
8258 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8260 context = g_object_get_qdata (G_OBJECT (widget), quark_pango_context);
8263 context = gtk_widget_create_pango_context (GTK_WIDGET (widget));
8264 g_object_set_qdata_full (G_OBJECT (widget),
8265 quark_pango_context,
8274 update_pango_context (GtkWidget *widget,
8275 PangoContext *context)
8277 GtkWidgetPrivate *priv = widget->priv;
8279 pango_context_set_font_description (context, priv->style->font_desc);
8280 pango_context_set_base_dir (context,
8281 gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
8282 PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
8286 gtk_widget_update_pango_context (GtkWidget *widget)
8288 PangoContext *context = gtk_widget_peek_pango_context (widget);
8294 update_pango_context (widget, context);
8296 screen = gtk_widget_get_screen_unchecked (widget);
8299 pango_cairo_context_set_resolution (context,
8300 gdk_screen_get_resolution (screen));
8301 pango_cairo_context_set_font_options (context,
8302 gdk_screen_get_font_options (screen));
8308 * gtk_widget_create_pango_context:
8309 * @widget: a #GtkWidget
8311 * Creates a new #PangoContext with the appropriate font map,
8312 * font description, and base direction for drawing text for
8313 * this widget. See also gtk_widget_get_pango_context().
8315 * Return value: (transfer full): the new #PangoContext
8318 gtk_widget_create_pango_context (GtkWidget *widget)
8321 PangoContext *context;
8323 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8325 screen = gtk_widget_get_screen_unchecked (widget);
8328 GTK_NOTE (MULTIHEAD,
8329 g_warning ("gtk_widget_create_pango_context ()) called without screen"));
8331 screen = gdk_screen_get_default ();
8334 context = gdk_pango_context_get_for_screen (screen);
8336 update_pango_context (widget, context);
8337 pango_context_set_language (context, gtk_get_default_language ());
8343 * gtk_widget_create_pango_layout:
8344 * @widget: a #GtkWidget
8345 * @text: text to set on the layout (can be %NULL)
8347 * Creates a new #PangoLayout with the appropriate font map,
8348 * font description, and base direction for drawing text for
8351 * If you keep a #PangoLayout created in this way around, in order to
8352 * notify the layout of changes to the base direction or font of this
8353 * widget, you must call pango_layout_context_changed() in response to
8354 * the #GtkWidget::style-set and #GtkWidget::direction-changed signals
8357 * Return value: (transfer full): the new #PangoLayout
8360 gtk_widget_create_pango_layout (GtkWidget *widget,
8363 PangoLayout *layout;
8364 PangoContext *context;
8366 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8368 context = gtk_widget_get_pango_context (widget);
8369 layout = pango_layout_new (context);
8372 pango_layout_set_text (layout, text, -1);
8378 * gtk_widget_render_icon:
8379 * @widget: a #GtkWidget
8380 * @stock_id: a stock ID
8381 * @size: (type int): a stock size. A size of (GtkIconSize)-1 means
8382 * render at the size of the source and don't scale (if there are
8383 * multiple source sizes, GTK+ picks one of the available sizes).
8384 * @detail: (allow-none): render detail to pass to theme engine
8386 * A convenience function that uses the theme engine and RC file
8387 * settings for @widget to look up @stock_id and render it to
8388 * a pixbuf. @stock_id should be a stock icon ID such as
8389 * #GTK_STOCK_OPEN or #GTK_STOCK_OK. @size should be a size
8390 * such as #GTK_ICON_SIZE_MENU. @detail should be a string that
8391 * identifies the widget or code doing the rendering, so that
8392 * theme engines can special-case rendering for that widget or code.
8394 * The pixels in the returned #GdkPixbuf are shared with the rest of
8395 * the application and should not be modified. The pixbuf should be freed
8396 * after use with g_object_unref().
8398 * Return value: (transfer full): a new pixbuf, or %NULL if the
8399 * stock ID wasn't known
8402 gtk_widget_render_icon (GtkWidget *widget,
8403 const gchar *stock_id,
8405 const gchar *detail)
8407 GtkWidgetPrivate *priv;
8408 GtkIconSet *icon_set;
8411 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8412 g_return_val_if_fail (stock_id != NULL, NULL);
8413 g_return_val_if_fail (size > GTK_ICON_SIZE_INVALID || size == -1, NULL);
8415 priv = widget->priv;
8417 gtk_widget_ensure_style (widget);
8419 icon_set = gtk_style_lookup_icon_set (priv->style, stock_id);
8421 if (icon_set == NULL)
8424 retval = gtk_icon_set_render_icon (icon_set,
8426 gtk_widget_get_direction (widget),
8427 gtk_widget_get_state (widget),
8436 * gtk_widget_set_parent_window:
8437 * @widget: a #GtkWidget.
8438 * @parent_window: the new parent window.
8440 * Sets a non default parent window for @widget.
8443 gtk_widget_set_parent_window (GtkWidget *widget,
8444 GdkWindow *parent_window)
8446 GdkWindow *old_parent_window;
8448 g_return_if_fail (GTK_IS_WIDGET (widget));
8450 old_parent_window = g_object_get_qdata (G_OBJECT (widget),
8451 quark_parent_window);
8453 if (parent_window != old_parent_window)
8455 g_object_set_qdata (G_OBJECT (widget), quark_parent_window,
8457 if (old_parent_window)
8458 g_object_unref (old_parent_window);
8460 g_object_ref (parent_window);
8465 * gtk_widget_get_parent_window:
8466 * @widget: a #GtkWidget.
8468 * Gets @widget's parent window.
8470 * Returns: (transfer none): the parent window of @widget.
8473 gtk_widget_get_parent_window (GtkWidget *widget)
8475 GtkWidgetPrivate *priv;
8476 GdkWindow *parent_window;
8478 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8480 priv = widget->priv;
8482 parent_window = g_object_get_qdata (G_OBJECT (widget), quark_parent_window);
8484 return (parent_window != NULL) ? parent_window :
8485 (priv->parent != NULL) ? priv->parent->priv->window : NULL;
8490 * gtk_widget_set_child_visible:
8491 * @widget: a #GtkWidget
8492 * @is_visible: if %TRUE, @widget should be mapped along with its parent.
8494 * Sets whether @widget should be mapped along with its when its parent
8495 * is mapped and @widget has been shown with gtk_widget_show().
8497 * The child visibility can be set for widget before it is added to
8498 * a container with gtk_widget_set_parent(), to avoid mapping
8499 * children unnecessary before immediately unmapping them. However
8500 * it will be reset to its default state of %TRUE when the widget
8501 * is removed from a container.
8503 * Note that changing the child visibility of a widget does not
8504 * queue a resize on the widget. Most of the time, the size of
8505 * a widget is computed from all visible children, whether or
8506 * not they are mapped. If this is not the case, the container
8507 * can queue a resize itself.
8509 * This function is only useful for container implementations and
8510 * never should be called by an application.
8513 gtk_widget_set_child_visible (GtkWidget *widget,
8514 gboolean is_visible)
8516 GtkWidgetPrivate *priv;
8518 g_return_if_fail (GTK_IS_WIDGET (widget));
8519 g_return_if_fail (!gtk_widget_is_toplevel (widget));
8521 priv = widget->priv;
8523 g_object_ref (widget);
8526 priv->child_visible = TRUE;
8529 GtkWidget *toplevel;
8531 priv->child_visible = FALSE;
8533 toplevel = gtk_widget_get_toplevel (widget);
8534 if (toplevel != widget && gtk_widget_is_toplevel (toplevel))
8535 _gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
8538 if (priv->parent && gtk_widget_get_realized (priv->parent))
8540 if (gtk_widget_get_mapped (priv->parent) &&
8541 priv->child_visible &&
8542 gtk_widget_get_visible (widget))
8543 gtk_widget_map (widget);
8545 gtk_widget_unmap (widget);
8548 g_object_unref (widget);
8552 * gtk_widget_get_child_visible:
8553 * @widget: a #GtkWidget
8555 * Gets the value set with gtk_widget_set_child_visible().
8556 * If you feel a need to use this function, your code probably
8557 * needs reorganization.
8559 * This function is only useful for container implementations and
8560 * never should be called by an application.
8562 * Return value: %TRUE if the widget is mapped with the parent.
8565 gtk_widget_get_child_visible (GtkWidget *widget)
8567 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
8569 return widget->priv->child_visible;
8573 gtk_widget_get_screen_unchecked (GtkWidget *widget)
8575 GtkWidget *toplevel;
8577 toplevel = gtk_widget_get_toplevel (widget);
8579 if (gtk_widget_is_toplevel (toplevel))
8581 if (GTK_IS_WINDOW (toplevel))
8582 return gtk_window_get_screen (GTK_WINDOW (toplevel));
8583 else if (GTK_IS_INVISIBLE (toplevel))
8584 return gtk_invisible_get_screen (GTK_INVISIBLE (widget));
8591 * gtk_widget_get_screen:
8592 * @widget: a #GtkWidget
8594 * Get the #GdkScreen from the toplevel window associated with
8595 * this widget. This function can only be called after the widget
8596 * has been added to a widget hierarchy with a #GtkWindow
8599 * In general, you should only create screen specific
8600 * resources when a widget has been realized, and you should
8601 * free those resources when the widget is unrealized.
8603 * Return value: (transfer none): the #GdkScreen for the toplevel for this widget.
8608 gtk_widget_get_screen (GtkWidget *widget)
8612 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8614 screen = gtk_widget_get_screen_unchecked (widget);
8621 g_warning (G_STRLOC ": Can't get associated screen"
8622 " for a widget unless it is inside a toplevel GtkWindow\n"
8623 " widget type is %s associated top level type is %s",
8624 g_type_name (G_OBJECT_TYPE(G_OBJECT (widget))),
8625 g_type_name (G_OBJECT_TYPE(G_OBJECT (toplevel))));
8627 return gdk_screen_get_default ();
8632 * gtk_widget_has_screen:
8633 * @widget: a #GtkWidget
8635 * Checks whether there is a #GdkScreen is associated with
8636 * this widget. All toplevel widgets have an associated
8637 * screen, and all widgets added into a hierarchy with a toplevel
8638 * window at the top.
8640 * Return value: %TRUE if there is a #GdkScreen associcated
8646 gtk_widget_has_screen (GtkWidget *widget)
8648 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
8650 return (gtk_widget_get_screen_unchecked (widget) != NULL);
8654 * gtk_widget_get_display:
8655 * @widget: a #GtkWidget
8657 * Get the #GdkDisplay for the toplevel window associated with
8658 * this widget. This function can only be called after the widget
8659 * has been added to a widget hierarchy with a #GtkWindow at the top.
8661 * In general, you should only create display specific
8662 * resources when a widget has been realized, and you should
8663 * free those resources when the widget is unrealized.
8665 * Return value: (transfer none): the #GdkDisplay for the toplevel for this widget.
8670 gtk_widget_get_display (GtkWidget *widget)
8672 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8674 return gdk_screen_get_display (gtk_widget_get_screen (widget));
8678 * gtk_widget_get_root_window:
8679 * @widget: a #GtkWidget
8681 * Get the root window where this widget is located. This function can
8682 * only be called after the widget has been added to a widget
8683 * hierarchy with #GtkWindow at the top.
8685 * The root window is useful for such purposes as creating a popup
8686 * #GdkWindow associated with the window. In general, you should only
8687 * create display specific resources when a widget has been realized,
8688 * and you should free those resources when the widget is unrealized.
8690 * Return value: (transfer none): the #GdkWindow root window for the toplevel for this widget.
8695 gtk_widget_get_root_window (GtkWidget *widget)
8697 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
8699 return gdk_screen_get_root_window (gtk_widget_get_screen (widget));
8703 * gtk_widget_child_focus:
8704 * @widget: a #GtkWidget
8705 * @direction: direction of focus movement
8707 * This function is used by custom widget implementations; if you're
8708 * writing an app, you'd use gtk_widget_grab_focus() to move the focus
8709 * to a particular widget, and gtk_container_set_focus_chain() to
8710 * change the focus tab order. So you may want to investigate those
8711 * functions instead.
8713 * gtk_widget_child_focus() is called by containers as the user moves
8714 * around the window using keyboard shortcuts. @direction indicates
8715 * what kind of motion is taking place (up, down, left, right, tab
8716 * forward, tab backward). gtk_widget_child_focus() emits the
8717 * #GtkWidget::focus signal; widgets override the default handler
8718 * for this signal in order to implement appropriate focus behavior.
8720 * The default ::focus handler for a widget should return %TRUE if
8721 * moving in @direction left the focus on a focusable location inside
8722 * that widget, and %FALSE if moving in @direction moved the focus
8723 * outside the widget. If returning %TRUE, widgets normally
8724 * call gtk_widget_grab_focus() to place the focus accordingly;
8725 * if returning %FALSE, they don't modify the current focus location.
8727 * Return value: %TRUE if focus ended up inside @widget
8730 gtk_widget_child_focus (GtkWidget *widget,
8731 GtkDirectionType direction)
8733 gboolean return_val;
8735 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
8737 if (!gtk_widget_get_visible (widget) ||
8738 !gtk_widget_is_sensitive (widget))
8741 /* child widgets must set CAN_FOCUS, containers
8742 * don't have to though.
8744 if (!GTK_IS_CONTAINER (widget) &&
8745 !gtk_widget_get_can_focus (widget))
8748 g_signal_emit (widget,
8749 widget_signals[FOCUS],
8751 direction, &return_val);
8757 * gtk_widget_keynav_failed:
8758 * @widget: a #GtkWidget
8759 * @direction: direction of focus movement
8761 * This function should be called whenever keyboard navigation within
8762 * a single widget hits a boundary. The function emits the
8763 * #GtkWidget::keynav-failed signal on the widget and its return
8764 * value should be interpreted in a way similar to the return value of
8765 * gtk_widget_child_focus():
8767 * When %TRUE is returned, stay in the widget, the failed keyboard
8768 * navigation is Ok and/or there is nowhere we can/should move the
8771 * When %FALSE is returned, the caller should continue with keyboard
8772 * navigation outside the widget, e.g. by calling
8773 * gtk_widget_child_focus() on the widget's toplevel.
8775 * The default ::keynav-failed handler returns %TRUE for
8776 * %GTK_DIR_TAB_FORWARD and %GTK_DIR_TAB_BACKWARD. For the other
8777 * values of #GtkDirectionType, it looks at the
8778 * #GtkSettings:gtk-keynav-cursor-only setting and returns %FALSE
8779 * if the setting is %TRUE. This way the entire user interface
8780 * becomes cursor-navigatable on input devices such as mobile phones
8781 * which only have cursor keys but no tab key.
8783 * Whenever the default handler returns %TRUE, it also calls
8784 * gtk_widget_error_bell() to notify the user of the failed keyboard
8787 * A use case for providing an own implementation of ::keynav-failed
8788 * (either by connecting to it or by overriding it) would be a row of
8789 * #GtkEntry widgets where the user should be able to navigate the
8790 * entire row with the cursor keys, as e.g. known from user interfaces
8791 * that require entering license keys.
8793 * Return value: %TRUE if stopping keyboard navigation is fine, %FALSE
8794 * if the emitting widget should try to handle the keyboard
8795 * navigation attempt in its parent container(s).
8800 gtk_widget_keynav_failed (GtkWidget *widget,
8801 GtkDirectionType direction)
8803 gboolean return_val;
8805 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
8807 g_signal_emit (widget, widget_signals[KEYNAV_FAILED], 0,
8808 direction, &return_val);
8814 * gtk_widget_error_bell:
8815 * @widget: a #GtkWidget
8817 * Notifies the user about an input-related error on this widget.
8818 * If the #GtkSettings:gtk-error-bell setting is %TRUE, it calls
8819 * gdk_window_beep(), otherwise it does nothing.
8821 * Note that the effect of gdk_window_beep() can be configured in many
8822 * ways, depending on the windowing backend and the desktop environment
8823 * or window manager that is used.
8828 gtk_widget_error_bell (GtkWidget *widget)
8830 GtkWidgetPrivate *priv;
8831 GtkSettings* settings;
8834 g_return_if_fail (GTK_IS_WIDGET (widget));
8836 priv = widget->priv;
8838 settings = gtk_widget_get_settings (widget);
8842 g_object_get (settings,
8843 "gtk-error-bell", &beep,
8846 if (beep && priv->window)
8847 gdk_window_beep (priv->window);
8851 gtk_widget_set_usize_internal (GtkWidget *widget,
8854 GtkQueueResizeFlags flags)
8856 GtkWidgetAuxInfo *aux_info;
8857 gboolean changed = FALSE;
8859 g_object_freeze_notify (G_OBJECT (widget));
8861 aux_info = _gtk_widget_get_aux_info (widget, TRUE);
8863 if (width > -2 && aux_info->width != width)
8865 if ((flags & GTK_QUEUE_RESIZE_INVALIDATE_ONLY) == 0)
8866 g_object_notify (G_OBJECT (widget), "width-request");
8867 aux_info->width = width;
8870 if (height > -2 && aux_info->height != height)
8872 if ((flags & GTK_QUEUE_RESIZE_INVALIDATE_ONLY) == 0)
8873 g_object_notify (G_OBJECT (widget), "height-request");
8874 aux_info->height = height;
8878 if (gtk_widget_get_visible (widget) && changed)
8880 if ((flags & GTK_QUEUE_RESIZE_INVALIDATE_ONLY) == 0)
8881 gtk_widget_queue_resize (widget);
8883 _gtk_size_group_queue_resize (widget, GTK_QUEUE_RESIZE_INVALIDATE_ONLY);
8886 g_object_thaw_notify (G_OBJECT (widget));
8890 * gtk_widget_set_size_request:
8891 * @widget: a #GtkWidget
8892 * @width: width @widget should request, or -1 to unset
8893 * @height: height @widget should request, or -1 to unset
8895 * Sets the minimum size of a widget; that is, the widget's size
8896 * request will be @width by @height. You can use this function to
8897 * force a widget to be either larger or smaller than it normally
8900 * In most cases, gtk_window_set_default_size() is a better choice for
8901 * toplevel windows than this function; setting the default size will
8902 * still allow users to shrink the window. Setting the size request
8903 * will force them to leave the window at least as large as the size
8904 * request. When dealing with window sizes,
8905 * gtk_window_set_geometry_hints() can be a useful function as well.
8907 * Note the inherent danger of setting any fixed size - themes,
8908 * translations into other languages, different fonts, and user action
8909 * can all change the appropriate size for a given widget. So, it's
8910 * basically impossible to hardcode a size that will always be
8913 * The size request of a widget is the smallest size a widget can
8914 * accept while still functioning well and drawing itself correctly.
8915 * However in some strange cases a widget may be allocated less than
8916 * its requested size, and in many cases a widget may be allocated more
8917 * space than it requested.
8919 * If the size request in a given direction is -1 (unset), then
8920 * the "natural" size request of the widget will be used instead.
8922 * Widgets can't actually be allocated a size less than 1 by 1, but
8923 * you can pass 0,0 to this function to mean "as small as possible."
8925 * The size request set here does not include any margin from the
8926 * #GtkWidget properties margin-left, margin-right, margin-top, and
8927 * margin-bottom, but it does include pretty much all other padding
8928 * or border properties set by any subclass of #GtkWidget.
8931 gtk_widget_set_size_request (GtkWidget *widget,
8935 g_return_if_fail (GTK_IS_WIDGET (widget));
8936 g_return_if_fail (width >= -1);
8937 g_return_if_fail (height >= -1);
8944 gtk_widget_set_usize_internal (widget, width, height, 0);
8949 * gtk_widget_get_size_request:
8950 * @widget: a #GtkWidget
8951 * @width: (out) (allow-none): return location for width, or %NULL
8952 * @height: (out) (allow-none): return location for height, or %NULL
8954 * Gets the size request that was explicitly set for the widget using
8955 * gtk_widget_set_size_request(). A value of -1 stored in @width or
8956 * @height indicates that that dimension has not been set explicitly
8957 * and the natural requisition of the widget will be used intead. See
8958 * gtk_widget_set_size_request(). To get the size a widget will
8959 * actually request, call gtk_widget_get_preferred_size() instead of
8963 gtk_widget_get_size_request (GtkWidget *widget,
8967 const GtkWidgetAuxInfo *aux_info;
8969 g_return_if_fail (GTK_IS_WIDGET (widget));
8971 aux_info = _gtk_widget_get_aux_info_or_defaults (widget);
8974 *width = aux_info->width;
8977 *height = aux_info->height;
8981 * _gtk_widget_override_size_request:
8982 * @widget: a #GtkWidget
8983 * @width: new forced minimum width
8984 * @height: new forced minimum height
8985 * @old_width: location to store previous forced minimum width
8986 * @old_width: location to store previous forced minumum height
8988 * Temporarily establishes a forced minimum size for a widget; this
8989 * is used by GtkWindow when calculating the size to add to the
8990 * window's geometry widget. Cached sizes for the widget and its
8991 * parents are invalidated, so that subsequent calls to the size
8992 * negotiation machinery produce the overriden result, but the
8993 * widget is not queued for relayout or redraw. The old size must
8994 * be restored with _gtk_widget_restore_size_request() or things
8998 _gtk_widget_override_size_request (GtkWidget *widget,
9004 gtk_widget_get_size_request (widget, old_width, old_height);
9005 gtk_widget_set_usize_internal (widget, width, height,
9006 GTK_QUEUE_RESIZE_INVALIDATE_ONLY);
9010 * _gtk_widget_restore_size_request:
9011 * @widget: a #GtkWidget
9012 * @old_width: saved forced minimum size
9013 * @old_height: saved forced minimum size
9015 * Undoes the operation of_gtk_widget_override_size_request().
9018 _gtk_widget_restore_size_request (GtkWidget *widget,
9022 gtk_widget_set_usize_internal (widget, old_width, old_height,
9023 GTK_QUEUE_RESIZE_INVALIDATE_ONLY);
9027 * gtk_widget_set_events:
9028 * @widget: a #GtkWidget
9029 * @events: event mask
9031 * Sets the event mask (see #GdkEventMask) for a widget. The event
9032 * mask determines which events a widget will receive. Keep in mind
9033 * that different widgets have different default event masks, and by
9034 * changing the event mask you may disrupt a widget's functionality,
9035 * so be careful. This function must be called while a widget is
9036 * unrealized. Consider gtk_widget_add_events() for widgets that are
9037 * already realized, or if you want to preserve the existing event
9038 * mask. This function can't be used with #GTK_NO_WINDOW widgets;
9039 * to get events on those widgets, place them inside a #GtkEventBox
9040 * and receive events on the event box.
9043 gtk_widget_set_events (GtkWidget *widget,
9046 g_return_if_fail (GTK_IS_WIDGET (widget));
9047 g_return_if_fail (!gtk_widget_get_realized (widget));
9049 g_object_set_qdata (G_OBJECT (widget), quark_event_mask,
9050 GINT_TO_POINTER (events));
9051 g_object_notify (G_OBJECT (widget), "events");
9055 * gtk_widget_set_device_events:
9056 * @widget: a #GtkWidget
9057 * @device: a #GdkDevice
9058 * @events: event mask
9060 * Sets the device event mask (see #GdkEventMask) for a widget. The event
9061 * mask determines which events a widget will receive from @device. Keep
9062 * in mind that different widgets have different default event masks, and by
9063 * changing the event mask you may disrupt a widget's functionality,
9064 * so be careful. This function must be called while a widget is
9065 * unrealized. Consider gtk_widget_add_device_events() for widgets that are
9066 * already realized, or if you want to preserve the existing event
9067 * mask. This function can't be used with #GTK_NO_WINDOW widgets;
9068 * to get events on those widgets, place them inside a #GtkEventBox
9069 * and receive events on the event box.
9074 gtk_widget_set_device_events (GtkWidget *widget,
9076 GdkEventMask events)
9078 GHashTable *device_events;
9080 g_return_if_fail (GTK_IS_WIDGET (widget));
9081 g_return_if_fail (GDK_IS_DEVICE (device));
9082 g_return_if_fail (!gtk_widget_get_realized (widget));
9084 device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
9086 if (G_UNLIKELY (!device_events))
9088 device_events = g_hash_table_new (NULL, NULL);
9089 g_object_set_qdata_full (G_OBJECT (widget), quark_device_event_mask, device_events,
9090 (GDestroyNotify) g_hash_table_unref);
9093 g_hash_table_insert (device_events, device, GUINT_TO_POINTER (events));
9097 gtk_widget_add_events_internal_list (GtkWidget *widget,
9104 for (l = window_list; l != NULL; l = l->next)
9106 GdkWindow *window = l->data;
9109 gdk_window_get_user_data (window, &user_data);
9110 if (user_data == widget)
9115 gdk_window_set_device_events (window, device, gdk_window_get_events (window) | events);
9117 gdk_window_set_events (window, gdk_window_get_events (window) | events);
9119 children = gdk_window_get_children (window);
9120 gtk_widget_add_events_internal_list (widget, device, events, children);
9121 g_list_free (children);
9127 gtk_widget_add_events_internal (GtkWidget *widget,
9131 GtkWidgetPrivate *priv = widget->priv;
9134 if (!gtk_widget_get_has_window (widget))
9135 window_list = gdk_window_get_children (priv->window);
9137 window_list = g_list_prepend (NULL, priv->window);
9139 gtk_widget_add_events_internal_list (widget, device, events, window_list);
9141 g_list_free (window_list);
9145 * gtk_widget_add_events:
9146 * @widget: a #GtkWidget
9147 * @events: an event mask, see #GdkEventMask
9149 * Adds the events in the bitfield @events to the event mask for
9150 * @widget. See gtk_widget_set_events() for details.
9153 gtk_widget_add_events (GtkWidget *widget,
9158 g_return_if_fail (GTK_IS_WIDGET (widget));
9160 old_events = GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), quark_event_mask));
9161 g_object_set_qdata (G_OBJECT (widget), quark_event_mask,
9162 GINT_TO_POINTER (old_events | events));
9164 if (gtk_widget_get_realized (widget))
9165 gtk_widget_add_events_internal (widget, NULL, events);
9167 g_object_notify (G_OBJECT (widget), "events");
9171 * gtk_widget_add_device_events:
9172 * @widget: a #GtkWidget
9173 * @device: a #GdkDevice
9174 * @events: an event mask, see #GdkEventMask
9176 * Adds the device events in the bitfield @events to the event mask for
9177 * @widget. See gtk_widget_set_device_events() for details.
9182 gtk_widget_add_device_events (GtkWidget *widget,
9184 GdkEventMask events)
9186 GdkEventMask old_events;
9187 GHashTable *device_events;
9189 g_return_if_fail (GTK_IS_WIDGET (widget));
9190 g_return_if_fail (GDK_IS_DEVICE (device));
9192 old_events = gtk_widget_get_device_events (widget, device);
9194 device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
9196 if (G_UNLIKELY (!device_events))
9198 device_events = g_hash_table_new (NULL, NULL);
9199 g_object_set_qdata_full (G_OBJECT (widget), quark_device_event_mask, device_events,
9200 (GDestroyNotify) g_hash_table_unref);
9203 g_hash_table_insert (device_events, device,
9204 GUINT_TO_POINTER (old_events | events));
9206 if (gtk_widget_get_realized (widget))
9207 gtk_widget_add_events_internal (widget, device, events);
9209 g_object_notify (G_OBJECT (widget), "events");
9213 * gtk_widget_set_extension_events:
9214 * @widget: a #GtkWidget
9215 * @mode: bitfield of extension events to receive
9217 * Sets the extension events mask to @mode. See #GdkExtensionMode
9218 * and gdk_input_set_extension_events().
9221 gtk_widget_set_extension_events (GtkWidget *widget,
9222 GdkExtensionMode mode)
9224 g_return_if_fail (GTK_IS_WIDGET (widget));
9226 if (gtk_widget_get_realized (widget))
9227 gtk_widget_set_extension_events_internal (widget, mode, NULL);
9229 g_object_set_qdata (G_OBJECT (widget), quark_extension_event_mode,
9230 GINT_TO_POINTER (mode));
9231 g_object_notify (G_OBJECT (widget), "extension-events");
9235 * gtk_widget_get_toplevel:
9236 * @widget: a #GtkWidget
9238 * This function returns the topmost widget in the container hierarchy
9239 * @widget is a part of. If @widget has no parent widgets, it will be
9240 * returned as the topmost widget. No reference will be added to the
9241 * returned widget; it should not be unreferenced.
9243 * Note the difference in behavior vs. gtk_widget_get_ancestor();
9244 * <literal>gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW)</literal>
9246 * %NULL if @widget wasn't inside a toplevel window, and if the
9247 * window was inside a #GtkWindow-derived widget which was in turn
9248 * inside the toplevel #GtkWindow. While the second case may
9249 * seem unlikely, it actually happens when a #GtkPlug is embedded
9250 * inside a #GtkSocket within the same application.
9252 * To reliably find the toplevel #GtkWindow, use
9253 * gtk_widget_get_toplevel() and check if the %TOPLEVEL flags
9254 * is set on the result.
9256 * GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
9257 * if (gtk_widget_is_toplevel (toplevel))
9259 * /* Perform action on toplevel. */
9263 * Return value: (transfer none): the topmost ancestor of @widget, or @widget itself
9264 * if there's no ancestor.
9267 gtk_widget_get_toplevel (GtkWidget *widget)
9269 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
9271 while (widget->priv->parent)
9272 widget = widget->priv->parent;
9278 * gtk_widget_get_ancestor:
9279 * @widget: a #GtkWidget
9280 * @widget_type: ancestor type
9282 * Gets the first ancestor of @widget with type @widget_type. For example,
9283 * <literal>gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)</literal> gets
9284 * the first #GtkBox that's an ancestor of @widget. No reference will be
9285 * added to the returned widget; it should not be unreferenced. See note
9286 * about checking for a toplevel #GtkWindow in the docs for
9287 * gtk_widget_get_toplevel().
9289 * Note that unlike gtk_widget_is_ancestor(), gtk_widget_get_ancestor()
9290 * considers @widget to be an ancestor of itself.
9292 * Return value: (transfer none): the ancestor widget, or %NULL if not found
9295 gtk_widget_get_ancestor (GtkWidget *widget,
9298 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
9300 while (widget && !g_type_is_a (G_OBJECT_TYPE (widget), widget_type))
9301 widget = widget->priv->parent;
9303 if (!(widget && g_type_is_a (G_OBJECT_TYPE (widget), widget_type)))
9310 * gtk_widget_set_visual:
9311 * @widget: a #GtkWidget
9312 * @visual: visual to be used or %NULL to unset a previous one
9314 * Sets the visual that should be used for by widget and its children for
9315 * creating #GdkWindows. The visual must be on the same #GdkScreen as
9316 * returned by gdk_widget_get_screen(), so handling the
9317 * GtkWidget::screen-changed signal is necessary.
9319 * Setting a new @visual will not cause @widget to recreate its windows,
9320 * so you should call this function before @widget is realized.
9323 gtk_widget_set_visual (GtkWidget *widget,
9326 g_return_if_fail (GTK_IS_WIDGET (widget));
9327 g_return_if_fail (visual == NULL || GDK_IS_VISUAL (visual));
9330 g_return_if_fail (gtk_widget_get_screen (widget) == gdk_visual_get_screen (visual));
9333 g_object_set_qdata_full (G_OBJECT (widget),
9335 g_object_ref (visual),
9340 * gtk_widget_get_visual:
9341 * @widget: a #GtkWidget
9343 * Gets the visual that will be used to render @widget.
9345 * Return value: (transfer none): the visual for @widget
9348 gtk_widget_get_visual (GtkWidget *widget)
9354 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
9356 if (gtk_widget_get_has_window (widget) &&
9357 widget->priv->window)
9358 return gdk_window_get_visual (widget->priv->window);
9360 screen = gtk_widget_get_screen (widget);
9362 for (w = widget; w != NULL; w = w->priv->parent)
9364 visual = g_object_get_qdata (G_OBJECT (w), quark_visual);
9367 if (gdk_visual_get_screen (visual) == screen)
9370 g_warning ("Ignoring visual set on widget `%s' that is not on the correct screen.",
9371 gtk_widget_get_name (widget));
9375 return gdk_screen_get_system_visual (screen);
9379 * gtk_widget_get_settings:
9380 * @widget: a #GtkWidget
9382 * Gets the settings object holding the settings (global property
9383 * settings, RC file information, etc) used for this widget.
9385 * Note that this function can only be called when the #GtkWidget
9386 * is attached to a toplevel, since the settings object is specific
9387 * to a particular #GdkScreen.
9389 * Return value: (transfer none): the relevant #GtkSettings object
9392 gtk_widget_get_settings (GtkWidget *widget)
9394 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
9396 return gtk_settings_get_for_screen (gtk_widget_get_screen (widget));
9400 * gtk_widget_get_events:
9401 * @widget: a #GtkWidget
9403 * Returns the event mask for the widget (a bitfield containing flags
9404 * from the #GdkEventMask enumeration). These are the events that the widget
9407 * Return value: event mask for @widget
9410 gtk_widget_get_events (GtkWidget *widget)
9412 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
9414 return GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), quark_event_mask));
9418 * gtk_widget_get_device_events:
9419 * @widget: a #GtkWidget
9420 * @device: a #GdkDevice
9422 * Returns the events mask for the widget corresponding to an specific device. These
9423 * are the events that the widget will receive when @device operates on it.
9425 * Returns: device event mask for @widget
9430 gtk_widget_get_device_events (GtkWidget *widget,
9433 GHashTable *device_events;
9435 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
9436 g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
9438 device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
9443 return GPOINTER_TO_UINT (g_hash_table_lookup (device_events, device));
9447 * gtk_widget_get_extension_events:
9448 * @widget: a #GtkWidget
9450 * Retrieves the extension events the widget will receive; see
9451 * gdk_input_set_extension_events().
9453 * Return value: extension events for @widget
9456 gtk_widget_get_extension_events (GtkWidget *widget)
9458 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
9460 return GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), quark_extension_event_mode));
9464 * gtk_widget_get_pointer:
9465 * @widget: a #GtkWidget
9466 * @x: (out) (allow-none): return location for the X coordinate, or %NULL
9467 * @y: (out) (allow-none): return location for the Y coordinate, or %NULL
9469 * Obtains the location of the mouse pointer in widget coordinates.
9470 * Widget coordinates are a bit odd; for historical reasons, they are
9471 * defined as @widget->window coordinates for widgets that are not
9472 * #GTK_NO_WINDOW widgets, and are relative to @widget->allocation.x,
9473 * @widget->allocation.y for widgets that are #GTK_NO_WINDOW widgets.
9476 gtk_widget_get_pointer (GtkWidget *widget,
9480 GtkWidgetPrivate *priv;
9482 g_return_if_fail (GTK_IS_WIDGET (widget));
9484 priv = widget->priv;
9491 if (gtk_widget_get_realized (widget))
9493 gdk_window_get_pointer (priv->window, x, y, NULL);
9495 if (!gtk_widget_get_has_window (widget))
9498 *x -= priv->allocation.x;
9500 *y -= priv->allocation.y;
9506 * gtk_widget_is_ancestor:
9507 * @widget: a #GtkWidget
9508 * @ancestor: another #GtkWidget
9510 * Determines whether @widget is somewhere inside @ancestor, possibly with
9511 * intermediate containers.
9513 * Return value: %TRUE if @ancestor contains @widget as a child,
9514 * grandchild, great grandchild, etc.
9517 gtk_widget_is_ancestor (GtkWidget *widget,
9518 GtkWidget *ancestor)
9520 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
9521 g_return_val_if_fail (ancestor != NULL, FALSE);
9525 if (widget->priv->parent == ancestor)
9527 widget = widget->priv->parent;
9533 static GQuark quark_composite_name = 0;
9536 * gtk_widget_set_composite_name:
9537 * @widget: a #GtkWidget.
9538 * @name: the name to set
9540 * Sets a widgets composite name. The widget must be
9541 * a composite child of its parent; see gtk_widget_push_composite_child().
9544 gtk_widget_set_composite_name (GtkWidget *widget,
9547 g_return_if_fail (GTK_IS_WIDGET (widget));
9548 g_return_if_fail (widget->priv->composite_child);
9549 g_return_if_fail (name != NULL);
9551 if (!quark_composite_name)
9552 quark_composite_name = g_quark_from_static_string ("gtk-composite-name");
9554 g_object_set_qdata_full (G_OBJECT (widget),
9555 quark_composite_name,
9561 * gtk_widget_get_composite_name:
9562 * @widget: a #GtkWidget
9564 * Obtains the composite name of a widget.
9566 * Returns: the composite name of @widget, or %NULL if @widget is not
9567 * a composite child. The string should be freed when it is no
9571 gtk_widget_get_composite_name (GtkWidget *widget)
9573 GtkWidgetPrivate *priv;
9575 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
9577 priv = widget->priv;
9579 if (widget->priv->composite_child && priv->parent)
9580 return _gtk_container_child_composite_name (GTK_CONTAINER (priv->parent),
9587 * gtk_widget_push_composite_child:
9589 * Makes all newly-created widgets as composite children until
9590 * the corresponding gtk_widget_pop_composite_child() call.
9592 * A composite child is a child that's an implementation detail of the
9593 * container it's inside and should not be visible to people using the
9594 * container. Composite children aren't treated differently by GTK (but
9595 * see gtk_container_foreach() vs. gtk_container_forall()), but e.g. GUI
9596 * builders might want to treat them in a different way.
9598 * Here is a simple example:
9600 * gtk_widget_push_composite_child ();
9601 * scrolled_window->hscrollbar = gtk_hscrollbar_new (hadjustment);
9602 * gtk_widget_set_composite_name (scrolled_window->hscrollbar, "hscrollbar");
9603 * gtk_widget_pop_composite_child ();
9604 * gtk_widget_set_parent (scrolled_window->hscrollbar,
9605 * GTK_WIDGET (scrolled_window));
9606 * g_object_ref (scrolled_window->hscrollbar);
9610 gtk_widget_push_composite_child (void)
9612 composite_child_stack++;
9616 * gtk_widget_pop_composite_child:
9618 * Cancels the effect of a previous call to gtk_widget_push_composite_child().
9621 gtk_widget_pop_composite_child (void)
9623 if (composite_child_stack)
9624 composite_child_stack--;
9628 gtk_widget_emit_direction_changed (GtkWidget *widget,
9629 GtkTextDirection old_dir)
9631 gtk_widget_update_pango_context (widget);
9633 g_signal_emit (widget, widget_signals[DIRECTION_CHANGED], 0, old_dir);
9637 * gtk_widget_set_direction:
9638 * @widget: a #GtkWidget
9639 * @dir: the new direction
9641 * Sets the reading direction on a particular widget. This direction
9642 * controls the primary direction for widgets containing text,
9643 * and also the direction in which the children of a container are
9644 * packed. The ability to set the direction is present in order
9645 * so that correct localization into languages with right-to-left
9646 * reading directions can be done. Generally, applications will
9647 * let the default reading direction present, except for containers
9648 * where the containers are arranged in an order that is explicitely
9649 * visual rather than logical (such as buttons for text justification).
9651 * If the direction is set to %GTK_TEXT_DIR_NONE, then the value
9652 * set by gtk_widget_set_default_direction() will be used.
9655 gtk_widget_set_direction (GtkWidget *widget,
9656 GtkTextDirection dir)
9658 GtkTextDirection old_dir;
9660 g_return_if_fail (GTK_IS_WIDGET (widget));
9661 g_return_if_fail (dir >= GTK_TEXT_DIR_NONE && dir <= GTK_TEXT_DIR_RTL);
9663 old_dir = gtk_widget_get_direction (widget);
9665 widget->priv->direction = dir;
9667 if (old_dir != gtk_widget_get_direction (widget))
9668 gtk_widget_emit_direction_changed (widget, old_dir);
9672 * gtk_widget_get_direction:
9673 * @widget: a #GtkWidget
9675 * Gets the reading direction for a particular widget. See
9676 * gtk_widget_set_direction().
9678 * Return value: the reading direction for the widget.
9681 gtk_widget_get_direction (GtkWidget *widget)
9683 g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_TEXT_DIR_LTR);
9685 if (widget->priv->direction == GTK_TEXT_DIR_NONE)
9686 return gtk_default_direction;
9688 return widget->priv->direction;
9692 gtk_widget_set_default_direction_recurse (GtkWidget *widget, gpointer data)
9694 GtkTextDirection old_dir = GPOINTER_TO_UINT (data);
9696 g_object_ref (widget);
9698 if (widget->priv->direction == GTK_TEXT_DIR_NONE)
9699 gtk_widget_emit_direction_changed (widget, old_dir);
9701 if (GTK_IS_CONTAINER (widget))
9702 gtk_container_forall (GTK_CONTAINER (widget),
9703 gtk_widget_set_default_direction_recurse,
9706 g_object_unref (widget);
9710 * gtk_widget_set_default_direction:
9711 * @dir: the new default direction. This cannot be
9712 * %GTK_TEXT_DIR_NONE.
9714 * Sets the default reading direction for widgets where the
9715 * direction has not been explicitly set by gtk_widget_set_direction().
9718 gtk_widget_set_default_direction (GtkTextDirection dir)
9720 g_return_if_fail (dir == GTK_TEXT_DIR_RTL || dir == GTK_TEXT_DIR_LTR);
9722 if (dir != gtk_default_direction)
9724 GList *toplevels, *tmp_list;
9725 GtkTextDirection old_dir = gtk_default_direction;
9727 gtk_default_direction = dir;
9729 tmp_list = toplevels = gtk_window_list_toplevels ();
9730 g_list_foreach (toplevels, (GFunc)g_object_ref, NULL);
9734 gtk_widget_set_default_direction_recurse (tmp_list->data,
9735 GUINT_TO_POINTER (old_dir));
9736 g_object_unref (tmp_list->data);
9737 tmp_list = tmp_list->next;
9740 g_list_free (toplevels);
9745 * gtk_widget_get_default_direction:
9747 * Obtains the current default reading direction. See
9748 * gtk_widget_set_default_direction().
9750 * Return value: the current default direction.
9753 gtk_widget_get_default_direction (void)
9755 return gtk_default_direction;
9759 gtk_widget_dispose (GObject *object)
9761 GtkWidget *widget = GTK_WIDGET (object);
9762 GtkWidgetPrivate *priv = widget->priv;
9765 gtk_container_remove (GTK_CONTAINER (priv->parent), widget);
9766 else if (gtk_widget_get_visible (widget))
9767 gtk_widget_hide (widget);
9769 priv->visible = FALSE;
9770 if (gtk_widget_get_realized (widget))
9771 gtk_widget_unrealize (widget);
9773 if (!priv->in_destruction)
9775 priv->in_destruction = TRUE;
9776 g_signal_emit (object, widget_signals[DESTROY], 0);
9777 priv->in_destruction = FALSE;
9780 G_OBJECT_CLASS (gtk_widget_parent_class)->dispose (object);
9784 gtk_widget_real_destroy (GtkWidget *object)
9786 /* gtk_object_destroy() will already hold a refcount on object */
9787 GtkWidget *widget = GTK_WIDGET (object);
9788 GtkWidgetPrivate *priv = widget->priv;
9790 /* wipe accelerator closures (keep order) */
9791 g_object_set_qdata (G_OBJECT (widget), quark_accel_path, NULL);
9792 g_object_set_qdata (G_OBJECT (widget), quark_accel_closures, NULL);
9794 /* Callers of add_mnemonic_label() should disconnect on ::destroy */
9795 g_object_set_qdata (G_OBJECT (widget), quark_mnemonic_labels, NULL);
9797 gtk_grab_remove (widget);
9799 g_object_unref (priv->style);
9800 priv->style = gtk_widget_get_default_style ();
9801 g_object_ref (priv->style);
9805 gtk_widget_finalize (GObject *object)
9807 GtkWidget *widget = GTK_WIDGET (object);
9808 GtkWidgetPrivate *priv = widget->priv;
9809 GtkWidgetAuxInfo *aux_info;
9810 GtkAccessible *accessible;
9812 gtk_grab_remove (widget);
9814 g_object_unref (priv->style);
9817 g_free (priv->name);
9819 aux_info =_gtk_widget_get_aux_info (widget, FALSE);
9821 gtk_widget_aux_info_destroy (aux_info);
9823 accessible = g_object_get_qdata (G_OBJECT (widget), quark_accessible_object);
9825 g_object_unref (accessible);
9827 if (g_object_is_floating (object))
9828 g_warning ("A floating object was finalized. This means that someone\n"
9829 "called g_object_unref() on an object that had only a floating\n"
9830 "reference; the initial floating reference is not owned by anyone\n"
9831 "and must be removed with g_object_ref_sink().");
9833 G_OBJECT_CLASS (gtk_widget_parent_class)->finalize (object);
9836 /*****************************************
9837 * gtk_widget_real_map:
9842 *****************************************/
9845 gtk_widget_real_map (GtkWidget *widget)
9847 GtkWidgetPrivate *priv = widget->priv;
9849 g_assert (gtk_widget_get_realized (widget));
9851 if (!gtk_widget_get_mapped (widget))
9853 gtk_widget_set_mapped (widget, TRUE);
9855 if (gtk_widget_get_has_window (widget))
9856 gdk_window_show (priv->window);
9860 /*****************************************
9861 * gtk_widget_real_unmap:
9866 *****************************************/
9869 gtk_widget_real_unmap (GtkWidget *widget)
9871 GtkWidgetPrivate *priv = widget->priv;
9873 if (gtk_widget_get_mapped (widget))
9875 gtk_widget_set_mapped (widget, FALSE);
9877 if (gtk_widget_get_has_window (widget))
9878 gdk_window_hide (priv->window);
9882 /*****************************************
9883 * gtk_widget_real_realize:
9888 *****************************************/
9891 gtk_widget_real_realize (GtkWidget *widget)
9893 GtkWidgetPrivate *priv = widget->priv;
9895 g_assert (!gtk_widget_get_has_window (widget));
9897 gtk_widget_set_realized (widget, TRUE);
9900 priv->window = gtk_widget_get_parent_window (widget);
9901 g_object_ref (priv->window);
9903 priv->style = gtk_style_attach (priv->style, priv->window);
9906 /*****************************************
9907 * gtk_widget_real_unrealize:
9912 *****************************************/
9915 gtk_widget_real_unrealize (GtkWidget *widget)
9917 GtkWidgetPrivate *priv = widget->priv;
9919 if (gtk_widget_get_mapped (widget))
9920 gtk_widget_real_unmap (widget);
9922 gtk_widget_set_mapped (widget, FALSE);
9924 /* printf ("unrealizing %s\n", g_type_name (G_TYPE_FROM_INSTANCE (widget)));
9927 /* We must do unrealize child widget BEFORE container widget.
9928 * gdk_window_destroy() destroys specified xwindow and its sub-xwindows.
9929 * So, unrealizing container widget bofore its children causes the problem
9930 * (for example, gdk_ic_destroy () with destroyed window causes crash. )
9933 if (GTK_IS_CONTAINER (widget))
9934 gtk_container_forall (GTK_CONTAINER (widget),
9935 (GtkCallback) gtk_widget_unrealize,
9938 gtk_style_detach (priv->style);
9939 if (gtk_widget_get_has_window (widget))
9941 gdk_window_set_user_data (priv->window, NULL);
9942 gdk_window_destroy (priv->window);
9943 priv->window = NULL;
9947 g_object_unref (priv->window);
9948 priv->window = NULL;
9951 gtk_selection_remove_all (widget);
9953 gtk_widget_set_realized (widget, FALSE);
9957 gtk_widget_real_size_request (GtkWidget *widget,
9958 GtkRequisition *requisition)
9960 requisition->width = 0;
9961 requisition->height = 0;
9965 gtk_widget_real_adjust_size_request (GtkWidget *widget,
9966 GtkOrientation orientation,
9971 const GtkWidgetAuxInfo *aux_info;
9973 aux_info =_gtk_widget_get_aux_info_or_defaults (widget);
9975 if (orientation == GTK_ORIENTATION_HORIZONTAL &&
9976 aux_info->width > 0)
9978 *minimum_size = MAX (*minimum_size, aux_info->width);
9980 else if (orientation == GTK_ORIENTATION_VERTICAL &&
9981 aux_info->height > 0)
9983 *minimum_size = MAX (*minimum_size, aux_info->height);
9986 /* Fix it if set_size_request made natural size smaller than min size.
9987 * This would also silently fix broken widgets, but we warn about them
9988 * in gtksizerequest.c when calling their size request vfuncs.
9990 *natural_size = MAX (*natural_size, *minimum_size);
9992 if (orientation == GTK_ORIENTATION_HORIZONTAL)
9994 *minimum_size += (aux_info->margin.left + aux_info->margin.right);
9995 *natural_size += (aux_info->margin.left + aux_info->margin.right);
9999 *minimum_size += (aux_info->margin.top + aux_info->margin.bottom);
10000 *natural_size += (aux_info->margin.top + aux_info->margin.bottom);
10005 * _gtk_widget_peek_request_cache:
10007 * Returns the address of the widget's request cache (strictly for
10008 * internal use in gtksizerequest.c)
10010 * Return value: the address of @widget's size request cache.
10013 _gtk_widget_peek_request_cache (GtkWidget *widget)
10015 /* Don't bother slowing things down with the return_if_fail guards here */
10016 return &widget->priv->requests;
10020 * _gtk_widget_set_device_window:
10021 * @widget: a #GtkWidget.
10022 * @device: a #GdkDevice.
10023 * @window: the new device window.
10025 * Sets pointer window for @widget and @device. Does not ref @window.
10026 * Actually stores it on the #GdkScreen, but you don't need to know that.
10029 _gtk_widget_set_device_window (GtkWidget *widget,
10033 GtkWidgetPrivate *priv;
10035 GHashTable *device_window;
10037 g_return_if_fail (GTK_IS_WIDGET (widget));
10038 g_return_if_fail (GDK_IS_DEVICE (device));
10039 g_return_if_fail (!window || GDK_IS_WINDOW (window));
10041 priv = widget->priv;
10043 if (!gtk_widget_get_realized (widget))
10046 screen = gdk_window_get_screen (priv->window);
10047 device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
10049 if (G_UNLIKELY (!device_window))
10051 device_window = g_hash_table_new (NULL, NULL);
10052 g_object_set_qdata_full (G_OBJECT (screen),
10053 quark_pointer_window,
10055 (GDestroyNotify) g_hash_table_destroy);
10059 g_hash_table_insert (device_window, device, window);
10061 g_hash_table_remove (device_window, device);
10065 * _gtk_widget_get_device_window:
10066 * @widget: a #GtkWidget.
10067 * @device: a #GdkDevice.
10069 * Return value: the device window set on the #GdkScreen @widget is attached
10073 _gtk_widget_get_device_window (GtkWidget *widget,
10076 GtkWidgetPrivate *priv;
10078 GHashTable *device_window;
10082 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
10083 g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
10085 priv = widget->priv;
10087 if (!gtk_widget_get_realized (widget))
10090 screen = gdk_window_get_screen (priv->window);
10091 device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
10093 if (G_UNLIKELY (!device_window))
10096 window = g_hash_table_lookup (device_window, device);
10101 gdk_window_get_user_data (window, (gpointer *) &w);
10110 * _gtk_widget_list_devices:
10111 * @widget: a #GtkWidget.
10113 * Returns the list of #GdkDevices that is currently on top of any widget #GdkWindow.
10114 * Free the list with g_list_free(), the elements are owned by GTK+ and must not
10118 _gtk_widget_list_devices (GtkWidget *widget)
10120 GtkWidgetPrivate *priv;
10122 GHashTableIter iter;
10123 GHashTable *device_window;
10124 GList *devices = NULL;
10125 gpointer key, value;
10127 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
10129 priv = widget->priv;
10131 if (!gtk_widget_get_realized (widget))
10134 screen = gdk_window_get_screen (priv->window);
10135 device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
10137 if (G_UNLIKELY (!device_window))
10140 g_hash_table_iter_init (&iter, device_window);
10142 while (g_hash_table_iter_next (&iter, &key, &value))
10144 GdkDevice *device = key;
10145 GdkWindow *window = value;
10150 gdk_window_get_user_data (window, (gpointer *) &w);
10153 devices = g_list_prepend (devices, device);
10161 synth_crossing (GtkWidget *widget,
10165 GdkCrossingMode mode,
10166 GdkNotifyType detail)
10170 event = gdk_event_new (type);
10172 event->crossing.window = g_object_ref (window);
10173 event->crossing.send_event = TRUE;
10174 event->crossing.subwindow = g_object_ref (window);
10175 event->crossing.time = GDK_CURRENT_TIME;
10176 event->crossing.x = event->crossing.y = 0;
10177 event->crossing.x_root = event->crossing.y_root = 0;
10178 event->crossing.mode = mode;
10179 event->crossing.detail = detail;
10180 event->crossing.focus = FALSE;
10181 event->crossing.state = 0;
10182 gdk_event_set_device (event, device);
10185 widget = gtk_get_event_widget (event);
10188 gtk_widget_event_internal (widget, event);
10190 gdk_event_free (event);
10194 * _gtk_widget_synthesize_crossing:
10195 * @from: the #GtkWidget the virtual pointer is leaving.
10196 * @to: the #GtkWidget the virtual pointer is moving to.
10197 * @mode: the #GdkCrossingMode to place on the synthesized events.
10199 * Generate crossing event(s) on widget state (sensitivity) or GTK+ grab change.
10201 * The real pointer window is the window that most recently received an enter notify
10202 * event. Windows that don't select for crossing events can't become the real
10203 * poiner window. The real pointer widget that owns the real pointer window. The
10204 * effective pointer window is the same as the real pointer window unless the real
10205 * pointer widget is either insensitive or there is a grab on a widget that is not
10206 * an ancestor of the real pointer widget (in which case the effective pointer
10207 * window should be the root window).
10209 * When the effective pointer window is the same as the real poiner window, we
10210 * receive crossing events from the windowing system. When the effective pointer
10211 * window changes to become different from the real pointer window we synthesize
10212 * crossing events, attempting to follow X protocol rules:
10214 * When the root window becomes the effective pointer window:
10215 * - leave notify on real pointer window, detail Ancestor
10216 * - leave notify on all of its ancestors, detail Virtual
10217 * - enter notify on root window, detail Inferior
10219 * When the root window ceases to be the effective pointer window:
10220 * - leave notify on root window, detail Inferior
10221 * - enter notify on all ancestors of real pointer window, detail Virtual
10222 * - enter notify on real pointer window, detail Ancestor
10225 _gtk_widget_synthesize_crossing (GtkWidget *from,
10228 GdkCrossingMode mode)
10230 GdkWindow *from_window = NULL, *to_window = NULL;
10232 g_return_if_fail (from != NULL || to != NULL);
10236 from_window = _gtk_widget_get_device_window (from, device);
10239 from_window = from->priv->window;
10244 to_window = _gtk_widget_get_device_window (to, device);
10247 to_window = to->priv->window;
10250 if (from_window == NULL && to_window == NULL)
10252 else if (from_window != NULL && to_window == NULL)
10254 GList *from_ancestors = NULL, *list;
10255 GdkWindow *from_ancestor = from_window;
10257 while (from_ancestor != NULL)
10259 from_ancestor = gdk_window_get_effective_parent (from_ancestor);
10260 if (from_ancestor == NULL)
10262 from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
10265 synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
10266 device, mode, GDK_NOTIFY_ANCESTOR);
10267 for (list = g_list_last (from_ancestors); list; list = list->prev)
10269 synth_crossing (NULL, GDK_LEAVE_NOTIFY, (GdkWindow *) list->data,
10270 device, mode, GDK_NOTIFY_VIRTUAL);
10273 /* XXX: enter/inferior on root window? */
10275 g_list_free (from_ancestors);
10277 else if (from_window == NULL && to_window != NULL)
10279 GList *to_ancestors = NULL, *list;
10280 GdkWindow *to_ancestor = to_window;
10282 while (to_ancestor != NULL)
10284 to_ancestor = gdk_window_get_effective_parent (to_ancestor);
10285 if (to_ancestor == NULL)
10287 to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
10290 /* XXX: leave/inferior on root window? */
10292 for (list = to_ancestors; list; list = list->next)
10294 synth_crossing (NULL, GDK_ENTER_NOTIFY, (GdkWindow *) list->data,
10295 device, mode, GDK_NOTIFY_VIRTUAL);
10297 synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
10298 device, mode, GDK_NOTIFY_ANCESTOR);
10300 g_list_free (to_ancestors);
10302 else if (from_window == to_window)
10306 GList *from_ancestors = NULL, *to_ancestors = NULL, *list;
10307 GdkWindow *from_ancestor = from_window, *to_ancestor = to_window;
10309 while (from_ancestor != NULL || to_ancestor != NULL)
10311 if (from_ancestor != NULL)
10313 from_ancestor = gdk_window_get_effective_parent (from_ancestor);
10314 if (from_ancestor == to_window)
10317 from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
10319 if (to_ancestor != NULL)
10321 to_ancestor = gdk_window_get_effective_parent (to_ancestor);
10322 if (to_ancestor == from_window)
10325 to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
10328 if (to_ancestor == from_window)
10330 if (mode != GDK_CROSSING_GTK_UNGRAB)
10331 synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
10332 device, mode, GDK_NOTIFY_INFERIOR);
10333 for (list = to_ancestors; list; list = list->next)
10334 synth_crossing (NULL, GDK_ENTER_NOTIFY, (GdkWindow *) list->data,
10335 device, mode, GDK_NOTIFY_VIRTUAL);
10336 synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
10337 device, mode, GDK_NOTIFY_ANCESTOR);
10339 else if (from_ancestor == to_window)
10341 synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
10342 device, mode, GDK_NOTIFY_ANCESTOR);
10343 for (list = g_list_last (from_ancestors); list; list = list->prev)
10345 synth_crossing (NULL, GDK_LEAVE_NOTIFY, (GdkWindow *) list->data,
10346 device, mode, GDK_NOTIFY_VIRTUAL);
10348 if (mode != GDK_CROSSING_GTK_GRAB)
10349 synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
10350 device, mode, GDK_NOTIFY_INFERIOR);
10354 while (from_ancestors != NULL && to_ancestors != NULL
10355 && from_ancestors->data == to_ancestors->data)
10357 from_ancestors = g_list_delete_link (from_ancestors,
10359 to_ancestors = g_list_delete_link (to_ancestors, to_ancestors);
10362 synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
10363 device, mode, GDK_NOTIFY_NONLINEAR);
10365 for (list = g_list_last (from_ancestors); list; list = list->prev)
10367 synth_crossing (NULL, GDK_LEAVE_NOTIFY, (GdkWindow *) list->data,
10368 device, mode, GDK_NOTIFY_NONLINEAR_VIRTUAL);
10370 for (list = to_ancestors; list; list = list->next)
10372 synth_crossing (NULL, GDK_ENTER_NOTIFY, (GdkWindow *) list->data,
10373 device, mode, GDK_NOTIFY_NONLINEAR_VIRTUAL);
10375 synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
10376 device, mode, GDK_NOTIFY_NONLINEAR);
10378 g_list_free (from_ancestors);
10379 g_list_free (to_ancestors);
10384 gtk_widget_propagate_state (GtkWidget *widget,
10385 GtkStateData *data)
10387 GtkWidgetPrivate *priv = widget->priv;
10388 guint8 old_state = gtk_widget_get_state (widget);
10389 guint8 old_saved_state = priv->saved_state;
10391 /* don't call this function with state==GTK_STATE_INSENSITIVE,
10392 * parent_sensitive==TRUE on a sensitive widget
10396 priv->parent_sensitive = data->parent_sensitive;
10398 if (gtk_widget_is_sensitive (widget))
10400 if (data->state_restoration)
10401 priv->state = priv->saved_state;
10403 priv->state = data->state;
10407 if (!data->state_restoration)
10409 if (data->state != GTK_STATE_INSENSITIVE)
10410 priv->saved_state = data->state;
10412 else if (gtk_widget_get_state (widget) != GTK_STATE_INSENSITIVE)
10413 priv->saved_state = gtk_widget_get_state (widget);
10414 priv->state = GTK_STATE_INSENSITIVE;
10417 if (gtk_widget_is_focus (widget) && !gtk_widget_is_sensitive (widget))
10421 window = gtk_widget_get_toplevel (widget);
10422 if (window && gtk_widget_is_toplevel (window))
10423 gtk_window_set_focus (GTK_WINDOW (window), NULL);
10426 if (old_state != gtk_widget_get_state (widget) ||
10427 old_saved_state != priv->saved_state)
10429 g_object_ref (widget);
10431 if (!gtk_widget_is_sensitive (widget) && gtk_widget_has_grab (widget))
10432 gtk_grab_remove (widget);
10434 g_signal_emit (widget, widget_signals[STATE_CHANGED], 0, old_state);
10436 if (!priv->shadowed)
10438 GList *event_windows = NULL;
10439 GList *devices, *d;
10441 devices = _gtk_widget_list_devices (widget);
10443 for (d = devices; d; d = d->next)
10449 window = _gtk_widget_get_device_window (widget, device);
10451 /* Do not propagate more than once to the
10452 * same window if non-multidevice aware.
10454 if (!gdk_window_get_support_multidevice (window) &&
10455 g_list_find (event_windows, window))
10458 if (!gtk_widget_is_sensitive (widget))
10459 _gtk_widget_synthesize_crossing (widget, NULL, d->data,
10460 GDK_CROSSING_STATE_CHANGED);
10461 else if (old_state == GTK_STATE_INSENSITIVE)
10462 _gtk_widget_synthesize_crossing (NULL, widget, d->data,
10463 GDK_CROSSING_STATE_CHANGED);
10465 event_windows = g_list_prepend (event_windows, window);
10468 g_list_free (event_windows);
10469 g_list_free (devices);
10472 if (GTK_IS_CONTAINER (widget))
10474 data->parent_sensitive = (gtk_widget_is_sensitive (widget) != FALSE);
10475 if (data->use_forall)
10476 gtk_container_forall (GTK_CONTAINER (widget),
10477 (GtkCallback) gtk_widget_propagate_state,
10480 gtk_container_foreach (GTK_CONTAINER (widget),
10481 (GtkCallback) gtk_widget_propagate_state,
10484 g_object_unref (widget);
10488 static const GtkWidgetAuxInfo default_aux_info = {
10496 * _gtk_widget_get_aux_info:
10497 * @widget: a #GtkWidget
10498 * @create: if %TRUE, create the structure if it doesn't exist
10500 * Get the #GtkWidgetAuxInfo structure for the widget.
10502 * Return value: the #GtkAuxInfo structure for the widget, or
10503 * %NULL if @create is %FALSE and one doesn't already exist.
10506 _gtk_widget_get_aux_info (GtkWidget *widget,
10509 GtkWidgetAuxInfo *aux_info;
10511 aux_info = g_object_get_qdata (G_OBJECT (widget), quark_aux_info);
10512 if (!aux_info && create)
10514 aux_info = g_slice_new0 (GtkWidgetAuxInfo);
10516 *aux_info = default_aux_info;
10518 g_object_set_qdata (G_OBJECT (widget), quark_aux_info, aux_info);
10524 static const GtkWidgetAuxInfo*
10525 _gtk_widget_get_aux_info_or_defaults (GtkWidget *widget)
10527 GtkWidgetAuxInfo *aux_info;
10529 aux_info = _gtk_widget_get_aux_info (widget, FALSE);
10530 if (aux_info == NULL)
10532 return &default_aux_info;
10540 /*****************************************
10541 * gtk_widget_aux_info_destroy:
10546 *****************************************/
10549 gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info)
10551 g_slice_free (GtkWidgetAuxInfo, aux_info);
10555 * gtk_widget_shape_combine_region:
10556 * @widget: a #GtkWidget
10557 * @region: (allow-none): shape to be added, or %NULL to remove an existing shape
10559 * Sets a shape for this widget's GDK window. This allows for
10560 * transparent windows etc., see gdk_window_shape_combine_region()
10561 * for more information.
10566 gtk_widget_shape_combine_region (GtkWidget *widget,
10567 cairo_region_t *region)
10569 GtkWidgetPrivate *priv;
10571 g_return_if_fail (GTK_IS_WIDGET (widget));
10572 /* set_shape doesn't work on widgets without gdk window */
10573 g_return_if_fail (gtk_widget_get_has_window (widget));
10575 priv = widget->priv;
10577 if (region == NULL)
10579 priv->has_shape_mask = FALSE;
10582 gdk_window_shape_combine_region (priv->window, NULL, 0, 0);
10584 g_object_set_qdata (G_OBJECT (widget), quark_shape_info, NULL);
10588 priv->has_shape_mask = TRUE;
10590 g_object_set_qdata_full (G_OBJECT (widget), quark_shape_info,
10591 cairo_region_copy (region),
10592 (GDestroyNotify) cairo_region_destroy);
10594 /* set shape if widget has a gdk window already.
10595 * otherwise the shape is scheduled to be set by gtk_widget_realize().
10598 gdk_window_shape_combine_region (priv->window, region, 0, 0);
10603 * gtk_widget_input_shape_combine_region:
10604 * @widget: a #GtkWidget
10605 * @region: (allow-none): shape to be added, or %NULL to remove an existing shape
10607 * Sets an input shape for this widget's GDK window. This allows for
10608 * windows which react to mouse click in a nonrectangular region, see
10609 * gdk_window_input_shape_combine_region() for more information.
10614 gtk_widget_input_shape_combine_region (GtkWidget *widget,
10615 cairo_region_t *region)
10617 GtkWidgetPrivate *priv;
10619 g_return_if_fail (GTK_IS_WIDGET (widget));
10620 /* set_shape doesn't work on widgets without gdk window */
10621 g_return_if_fail (gtk_widget_get_has_window (widget));
10623 priv = widget->priv;
10625 if (region == NULL)
10628 gdk_window_input_shape_combine_region (priv->window, NULL, 0, 0);
10630 g_object_set_qdata (G_OBJECT (widget), quark_input_shape_info, NULL);
10634 g_object_set_qdata_full (G_OBJECT (widget), quark_input_shape_info,
10635 cairo_region_copy (region),
10636 (GDestroyNotify) cairo_region_destroy);
10638 /* set shape if widget has a gdk window already.
10639 * otherwise the shape is scheduled to be set by gtk_widget_realize().
10642 gdk_window_input_shape_combine_region (priv->window, region, 0, 0);
10648 gtk_reset_shapes_recurse (GtkWidget *widget,
10654 gdk_window_get_user_data (window, &data);
10655 if (data != widget)
10658 gdk_window_shape_combine_region (window, NULL, 0, 0);
10659 for (list = gdk_window_peek_children (window); list; list = list->next)
10660 gtk_reset_shapes_recurse (widget, list->data);
10664 * gtk_widget_reset_shapes:
10665 * @widget: a #GtkWidget
10667 * Recursively resets the shape on this widget and its descendants.
10670 gtk_widget_reset_shapes (GtkWidget *widget)
10672 GtkWidgetPrivate *priv;
10674 g_return_if_fail (GTK_IS_WIDGET (widget));
10675 g_return_if_fail (gtk_widget_get_realized (widget));
10677 priv = widget->priv;
10679 if (!priv->has_shape_mask)
10680 gtk_reset_shapes_recurse (widget, priv->window);
10683 /* style properties
10687 * gtk_widget_class_install_style_property_parser:
10688 * @klass: a #GtkWidgetClass
10689 * @pspec: the #GParamSpec for the style property
10690 * @parser: the parser for the style property
10692 * Installs a style property on a widget class.
10695 gtk_widget_class_install_style_property_parser (GtkWidgetClass *klass,
10697 GtkRcPropertyParser parser)
10699 g_return_if_fail (GTK_IS_WIDGET_CLASS (klass));
10700 g_return_if_fail (G_IS_PARAM_SPEC (pspec));
10701 g_return_if_fail (pspec->flags & G_PARAM_READABLE);
10702 g_return_if_fail (!(pspec->flags & (G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT)));
10704 if (g_param_spec_pool_lookup (style_property_spec_pool, pspec->name, G_OBJECT_CLASS_TYPE (klass), FALSE))
10706 g_warning (G_STRLOC ": class `%s' already contains a style property named `%s'",
10707 G_OBJECT_CLASS_NAME (klass),
10712 g_param_spec_ref_sink (pspec);
10713 g_param_spec_set_qdata (pspec, quark_property_parser, (gpointer) parser);
10714 g_param_spec_pool_insert (style_property_spec_pool, pspec, G_OBJECT_CLASS_TYPE (klass));
10718 * gtk_widget_class_install_style_property:
10719 * @klass: a #GtkWidgetClass
10720 * @pspec: the #GParamSpec for the property
10722 * Installs a style property on a widget class. The parser for the
10723 * style property is determined by the value type of @pspec.
10726 gtk_widget_class_install_style_property (GtkWidgetClass *klass,
10729 GtkRcPropertyParser parser;
10731 g_return_if_fail (GTK_IS_WIDGET_CLASS (klass));
10732 g_return_if_fail (G_IS_PARAM_SPEC (pspec));
10734 parser = _gtk_rc_property_parser_from_type (G_PARAM_SPEC_VALUE_TYPE (pspec));
10736 gtk_widget_class_install_style_property_parser (klass, pspec, parser);
10740 * gtk_widget_class_find_style_property:
10741 * @klass: a #GtkWidgetClass
10742 * @property_name: the name of the style property to find
10743 * @returns: (allow-none): the #GParamSpec of the style property or %NULL if @class has no
10744 * style property with that name.
10746 * Finds a style property of a widget class by name.
10751 gtk_widget_class_find_style_property (GtkWidgetClass *klass,
10752 const gchar *property_name)
10754 g_return_val_if_fail (property_name != NULL, NULL);
10756 return g_param_spec_pool_lookup (style_property_spec_pool,
10758 G_OBJECT_CLASS_TYPE (klass),
10763 * gtk_widget_class_list_style_properties:
10764 * @klass: a #GtkWidgetClass
10765 * @n_properties: location to return the number of style properties found
10766 * @returns: an newly allocated array of #GParamSpec*. The array must
10767 * be freed with g_free().
10769 * Returns all style properties of a widget class.
10774 gtk_widget_class_list_style_properties (GtkWidgetClass *klass,
10775 guint *n_properties)
10777 GParamSpec **pspecs;
10780 pspecs = g_param_spec_pool_list (style_property_spec_pool,
10781 G_OBJECT_CLASS_TYPE (klass),
10790 * gtk_widget_style_get_property:
10791 * @widget: a #GtkWidget
10792 * @property_name: the name of a style property
10793 * @value: location to return the property value
10795 * Gets the value of a style property of @widget.
10798 gtk_widget_style_get_property (GtkWidget *widget,
10799 const gchar *property_name,
10802 GtkWidgetPrivate *priv;
10805 g_return_if_fail (GTK_IS_WIDGET (widget));
10806 g_return_if_fail (property_name != NULL);
10807 g_return_if_fail (G_IS_VALUE (value));
10809 priv = widget->priv;
10811 g_object_ref (widget);
10812 pspec = g_param_spec_pool_lookup (style_property_spec_pool,
10814 G_OBJECT_TYPE (widget),
10817 g_warning ("%s: widget class `%s' has no property named `%s'",
10819 G_OBJECT_TYPE_NAME (widget),
10823 const GValue *peek_value;
10825 peek_value = _gtk_style_peek_property_value (priv->style,
10826 G_OBJECT_TYPE (widget),
10828 (GtkRcPropertyParser) g_param_spec_get_qdata (pspec, quark_property_parser));
10830 /* auto-conversion of the caller's value type
10832 if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec))
10833 g_value_copy (peek_value, value);
10834 else if (g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), G_VALUE_TYPE (value)))
10835 g_value_transform (peek_value, value);
10837 g_warning ("can't retrieve style property `%s' of type `%s' as value of type `%s'",
10839 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
10840 G_VALUE_TYPE_NAME (value));
10842 g_object_unref (widget);
10846 * gtk_widget_style_get_valist:
10847 * @widget: a #GtkWidget
10848 * @first_property_name: the name of the first property to get
10849 * @var_args: a <type>va_list</type> of pairs of property names and
10850 * locations to return the property values, starting with the location
10851 * for @first_property_name.
10853 * Non-vararg variant of gtk_widget_style_get(). Used primarily by language
10857 gtk_widget_style_get_valist (GtkWidget *widget,
10858 const gchar *first_property_name,
10861 GtkWidgetPrivate *priv;
10864 g_return_if_fail (GTK_IS_WIDGET (widget));
10866 priv = widget->priv;
10868 g_object_ref (widget);
10870 name = first_property_name;
10873 const GValue *peek_value;
10877 pspec = g_param_spec_pool_lookup (style_property_spec_pool,
10879 G_OBJECT_TYPE (widget),
10883 g_warning ("%s: widget class `%s' has no property named `%s'",
10885 G_OBJECT_TYPE_NAME (widget),
10889 /* style pspecs are always readable so we can spare that check here */
10891 peek_value = _gtk_style_peek_property_value (priv->style,
10892 G_OBJECT_TYPE (widget),
10894 (GtkRcPropertyParser) g_param_spec_get_qdata (pspec, quark_property_parser));
10895 G_VALUE_LCOPY (peek_value, var_args, 0, &error);
10898 g_warning ("%s: %s", G_STRLOC, error);
10903 name = va_arg (var_args, gchar*);
10906 g_object_unref (widget);
10910 * gtk_widget_style_get:
10911 * @widget: a #GtkWidget
10912 * @first_property_name: the name of the first property to get
10913 * @Varargs: pairs of property names and locations to
10914 * return the property values, starting with the location for
10915 * @first_property_name, terminated by %NULL.
10917 * Gets the values of a multiple style properties of @widget.
10920 gtk_widget_style_get (GtkWidget *widget,
10921 const gchar *first_property_name,
10926 g_return_if_fail (GTK_IS_WIDGET (widget));
10928 va_start (var_args, first_property_name);
10929 gtk_widget_style_get_valist (widget, first_property_name, var_args);
10935 * @widget: a #GtkWidget
10936 * @path_length: (out) (allow-none): location to store length of the path, or %NULL
10937 * @path: (out) (allow-none): location to store allocated path string, or %NULL
10938 * @path_reversed: (out) (allow-none): location to store allocated reverse path string, or %NULL
10940 * Obtains the full path to @widget. The path is simply the name of a
10941 * widget and all its parents in the container hierarchy, separated by
10942 * periods. The name of a widget comes from
10943 * gtk_widget_get_name(). Paths are used to apply styles to a widget
10944 * in gtkrc configuration files. Widget names are the type of the
10945 * widget by default (e.g. "GtkButton") or can be set to an
10946 * application-specific value with gtk_widget_set_name(). By setting
10947 * the name of a widget, you allow users or theme authors to apply
10948 * styles to that specific widget in their gtkrc
10949 * file. @path_reversed_p fills in the path in reverse order,
10950 * i.e. starting with @widget's name instead of starting with the name
10951 * of @widget's outermost ancestor.
10954 gtk_widget_path (GtkWidget *widget,
10955 guint *path_length,
10957 gchar **path_reversed)
10959 static gchar *rev_path = NULL;
10960 static guint tmp_path_len = 0;
10963 g_return_if_fail (GTK_IS_WIDGET (widget));
10968 const gchar *string;
10973 string = gtk_widget_get_name (widget);
10974 l = strlen (string);
10975 while (tmp_path_len <= len + l + 1)
10977 tmp_path_len += INIT_PATH_SIZE;
10978 rev_path = g_realloc (rev_path, tmp_path_len);
10980 s = string + l - 1;
10981 d = rev_path + len;
10982 while (s >= string)
10986 widget = widget->priv->parent;
10989 rev_path[len++] = '.';
10991 rev_path[len++] = 0;
10996 *path_length = len - 1;
10998 *path_reversed = g_strdup (rev_path);
11001 *path = g_strdup (rev_path);
11002 g_strreverse (*path);
11007 * gtk_widget_class_path:
11008 * @widget: a #GtkWidget
11009 * @path_length: (out) (allow-none): location to store the length of the class path, or %NULL
11010 * @path: (out) (allow-none): location to store the class path as an allocated string, or %NULL
11011 * @path_reversed: (out) (allow-none): location to store the reverse class path as an allocated
11014 * Same as gtk_widget_path(), but always uses the name of a widget's type,
11015 * never uses a custom name set with gtk_widget_set_name().
11019 gtk_widget_class_path (GtkWidget *widget,
11020 guint *path_length,
11022 gchar **path_reversed)
11024 static gchar *rev_path = NULL;
11025 static guint tmp_path_len = 0;
11028 g_return_if_fail (GTK_IS_WIDGET (widget));
11033 const gchar *string;
11038 string = g_type_name (G_OBJECT_TYPE (widget));
11039 l = strlen (string);
11040 while (tmp_path_len <= len + l + 1)
11042 tmp_path_len += INIT_PATH_SIZE;
11043 rev_path = g_realloc (rev_path, tmp_path_len);
11045 s = string + l - 1;
11046 d = rev_path + len;
11047 while (s >= string)
11051 widget = widget->priv->parent;
11054 rev_path[len++] = '.';
11056 rev_path[len++] = 0;
11061 *path_length = len - 1;
11063 *path_reversed = g_strdup (rev_path);
11066 *path = g_strdup (rev_path);
11067 g_strreverse (*path);
11072 * gtk_requisition_new:
11074 * Allocates a new #GtkRequisition structure and initializes its elements to zero.
11076 * Returns: a new empty #GtkRequisition. The newly allocated #GtkRequisition should
11077 * be freed with gtk_requisition_free().
11082 gtk_requisition_new (void)
11084 return g_slice_new0 (GtkRequisition);
11088 * gtk_requisition_copy:
11089 * @requisition: a #GtkRequisition
11091 * Copies a #GtkRequisition.
11093 * Returns: a copy of @requisition
11096 gtk_requisition_copy (const GtkRequisition *requisition)
11098 return g_slice_dup (GtkRequisition, requisition);
11102 * gtk_requisition_free:
11103 * @requisition: a #GtkRequisition
11105 * Frees a #GtkRequisition.
11108 gtk_requisition_free (GtkRequisition *requisition)
11110 g_slice_free (GtkRequisition, requisition);
11113 G_DEFINE_BOXED_TYPE (GtkRequisition, gtk_requisition,
11114 gtk_requisition_copy,
11115 gtk_requisition_free)
11118 * gtk_widget_get_accessible:
11119 * @widget: a #GtkWidget
11121 * Returns the accessible object that describes the widget to an
11122 * assistive technology.
11124 * If no accessibility library is loaded (i.e. no ATK implementation library is
11125 * loaded via <envar>GTK_MODULES</envar> or via another application library,
11126 * such as libgnome), then this #AtkObject instance may be a no-op. Likewise,
11127 * if no class-specific #AtkObject implementation is available for the widget
11128 * instance in question, it will inherit an #AtkObject implementation from the
11129 * first ancestor class for which such an implementation is defined.
11131 * The documentation of the <ulink url="http://developer.gnome.org/doc/API/2.0/atk/index.html">ATK</ulink>
11132 * library contains more information about accessible objects and their uses.
11134 * Returns: (transfer none): the #AtkObject associated with @widget
11137 gtk_widget_get_accessible (GtkWidget *widget)
11139 GtkWidgetClass *klass;
11141 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
11143 klass = GTK_WIDGET_GET_CLASS (widget);
11145 g_return_val_if_fail (klass->get_accessible != NULL, NULL);
11147 return klass->get_accessible (widget);
11151 gtk_widget_real_get_accessible (GtkWidget *widget)
11153 AtkObject* accessible;
11155 accessible = g_object_get_qdata (G_OBJECT (widget),
11156 quark_accessible_object);
11159 AtkObjectFactory *factory;
11160 AtkRegistry *default_registry;
11162 default_registry = atk_get_default_registry ();
11163 factory = atk_registry_get_factory (default_registry,
11164 G_TYPE_FROM_INSTANCE (widget));
11166 atk_object_factory_create_accessible (factory,
11167 G_OBJECT (widget));
11168 g_object_set_qdata (G_OBJECT (widget),
11169 quark_accessible_object,
11176 * Initialize a AtkImplementorIface instance's virtual pointers as
11177 * appropriate to this implementor's class (GtkWidget).
11180 gtk_widget_accessible_interface_init (AtkImplementorIface *iface)
11182 iface->ref_accessible = gtk_widget_ref_accessible;
11186 gtk_widget_ref_accessible (AtkImplementor *implementor)
11188 AtkObject *accessible;
11190 accessible = gtk_widget_get_accessible (GTK_WIDGET (implementor));
11192 g_object_ref (accessible);
11197 * Expand flag management
11201 gtk_widget_update_computed_expand (GtkWidget *widget)
11203 GtkWidgetPrivate *priv;
11205 priv = widget->priv;
11207 if (priv->need_compute_expand)
11211 if (priv->hexpand_set)
11216 if (priv->vexpand_set)
11221 /* we don't need to use compute_expand if both expands are
11222 * forced by the app
11224 if (!(priv->hexpand_set && priv->vexpand_set))
11226 if (GTK_WIDGET_GET_CLASS (widget)->compute_expand != NULL)
11230 GTK_WIDGET_GET_CLASS (widget)->compute_expand (widget,
11231 priv->hexpand_set ? &ignored : &h,
11232 priv->vexpand_set ? &ignored : &v);
11236 priv->need_compute_expand = FALSE;
11237 priv->computed_hexpand = h != FALSE;
11238 priv->computed_vexpand = v != FALSE;
11243 gtk_widget_queue_compute_expand (GtkWidget *widget)
11246 gboolean changed_anything;
11248 if (widget->priv->need_compute_expand)
11251 changed_anything = FALSE;
11253 while (parent != NULL)
11255 if (!parent->priv->need_compute_expand)
11257 parent->priv->need_compute_expand = TRUE;
11258 changed_anything = TRUE;
11261 /* Note: if we had an invariant that "if a child needs to
11262 * compute expand, its parents also do" then we could stop going
11263 * up when we got to a parent that already needed to
11264 * compute. However, in general we compute expand lazily (as
11265 * soon as we see something in a subtree that is expand, we know
11266 * we're expanding) and so this invariant does not hold and we
11267 * have to always walk all the way up in case some ancestor
11268 * is not currently need_compute_expand.
11271 parent = parent->priv->parent;
11274 /* recomputing expand always requires
11275 * a relayout as well
11277 if (changed_anything)
11278 gtk_widget_queue_resize (widget);
11282 * gtk_widget_compute_expand:
11283 * @widget: the widget
11284 * @orientation: expand direction
11286 * Computes whether a container should give this widget extra space
11287 * when possible. Containers should check this, rather than
11288 * looking at gtk_widget_get_hexpand() or gtk_widget_get_vexpand().
11290 * This function already checks whether the widget is visible, so
11291 * visibility does not need to be checked separately. Non-visible
11292 * widgets are not expanded.
11294 * The computed expand value uses either the expand setting explicitly
11295 * set on the widget itself, or, if none has been explicitly set,
11296 * the widget may expand if some of its children do.
11298 * Return value: whether widget tree rooted here should be expanded
11301 gtk_widget_compute_expand (GtkWidget *widget,
11302 GtkOrientation orientation)
11304 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
11306 /* We never make a widget expand if not even showing. */
11307 if (!gtk_widget_get_visible (widget))
11310 gtk_widget_update_computed_expand (widget);
11312 if (orientation == GTK_ORIENTATION_HORIZONTAL)
11314 return widget->priv->computed_hexpand;
11318 return widget->priv->computed_vexpand;
11323 gtk_widget_set_expand (GtkWidget *widget,
11324 GtkOrientation orientation,
11327 const char *expand_prop;
11328 const char *expand_set_prop;
11330 GtkWidgetPrivate *priv;
11332 g_return_if_fail (GTK_IS_WIDGET (widget));
11334 priv = widget->priv;
11336 expand = expand != FALSE;
11338 was_both = priv->hexpand && priv->vexpand;
11340 if (orientation == GTK_ORIENTATION_HORIZONTAL)
11342 if (priv->hexpand_set &&
11343 priv->hexpand == expand)
11346 priv->hexpand_set = TRUE;
11347 priv->hexpand = expand;
11349 expand_prop = "hexpand";
11350 expand_set_prop = "hexpand-set";
11354 if (priv->vexpand_set &&
11355 priv->vexpand == expand)
11358 priv->vexpand_set = TRUE;
11359 priv->vexpand = expand;
11361 expand_prop = "vexpand";
11362 expand_set_prop = "vexpand-set";
11365 gtk_widget_queue_compute_expand (widget);
11367 g_object_freeze_notify (G_OBJECT (widget));
11368 g_object_notify (G_OBJECT (widget), expand_prop);
11369 g_object_notify (G_OBJECT (widget), expand_set_prop);
11370 if (was_both != (priv->hexpand && priv->vexpand))
11371 g_object_notify (G_OBJECT (widget), "expand");
11372 g_object_thaw_notify (G_OBJECT (widget));
11376 gtk_widget_set_expand_set (GtkWidget *widget,
11377 GtkOrientation orientation,
11380 GtkWidgetPrivate *priv;
11383 priv = widget->priv;
11385 set = set != FALSE;
11387 if (orientation == GTK_ORIENTATION_HORIZONTAL)
11389 if (set == priv->hexpand_set)
11392 priv->hexpand_set = set;
11393 prop = "hexpand-set";
11397 if (set == priv->vexpand_set)
11400 priv->vexpand_set = set;
11401 prop = "vexpand-set";
11404 gtk_widget_queue_compute_expand (widget);
11406 g_object_notify (G_OBJECT (widget), prop);
11410 * gtk_widget_get_hexpand:
11411 * @widget: the widget
11413 * Gets whether the widget would like any available extra horizontal
11414 * space. When a user resizes a #GtkWindow, widgets with expand=TRUE
11415 * generally receive the extra space. For example, a list or
11416 * scrollable area or document in your window would often be set to
11419 * Containers should use gtk_widget_compute_expand() rather than
11420 * this function, to see whether a widget, or any of its children,
11421 * has the expand flag set. If any child of a widget wants to
11422 * expand, the parent may ask to expand also.
11424 * This function only looks at the widget's own hexpand flag, rather
11425 * than computing whether the entire widget tree rooted at this widget
11428 * Return value: whether hexpand flag is set
11431 gtk_widget_get_hexpand (GtkWidget *widget)
11433 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
11435 return widget->priv->hexpand;
11439 * gtk_widget_set_hexpand:
11440 * @widget: the widget
11441 * @expand: whether to expand
11443 * Sets whether the widget would like any available extra horizontal
11444 * space. When a user resizes a #GtkWindow, widgets with expand=TRUE
11445 * generally receive the extra space. For example, a list or
11446 * scrollable area or document in your window would often be set to
11449 * Call this function to set the expand flag if you would like your
11450 * widget to become larger horizontally when the window has extra
11453 * By default, widgets automatically expand if any of their children
11454 * want to expand. (To see if a widget will automatically expand given
11455 * its current children and state, call gtk_widget_compute_expand(). A
11456 * container can decide how the expandability of children affects the
11457 * expansion of the container by overriding the compute_expand virtual
11458 * method on #GtkWidget.).
11460 * Setting hexpand explicitly with this function will override the
11461 * automatic expand behavior.
11463 * This function forces the widget to expand or not to expand,
11464 * regardless of children. The override occurs because
11465 * gtk_widget_set_hexpand() sets the hexpand-set property (see
11466 * gtk_widget_set_hexpand_set()) which causes the widget's hexpand
11467 * value to be used, rather than looking at children and widget state.
11470 gtk_widget_set_hexpand (GtkWidget *widget,
11473 g_return_if_fail (GTK_IS_WIDGET (widget));
11475 gtk_widget_set_expand (widget, GTK_ORIENTATION_HORIZONTAL, expand);
11479 * gtk_widget_get_hexpand_set:
11480 * @widget: the widget
11482 * Gets whether gtk_widget_set_hexpand() has been used to
11483 * explicitly set the expand flag on this widget.
11485 * If hexpand is set, then it overrides any computed
11486 * expand value based on child widgets. If hexpand is not
11487 * set, then the expand value depends on whether any
11488 * children of the widget would like to expand.
11490 * There are few reasons to use this function, but it's here
11491 * for completeness and consistency.
11493 * Return value: whether hexpand has been explicitly set
11496 gtk_widget_get_hexpand_set (GtkWidget *widget)
11498 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
11500 return widget->priv->hexpand_set;
11504 * gtk_widget_set_hexpand_set:
11505 * @widget: the widget
11506 * @set: value for hexpand-set property
11508 * Sets whether the hexpand flag (see gtk_widget_get_hexpand()) will
11511 * The hexpand-set property will be set automatically when you call
11512 * gtk_widget_set_hexpand() to set hexpand, so the most likely
11513 * reason to use this function would be to unset an explicit expand
11516 * If hexpand is set, then it overrides any computed
11517 * expand value based on child widgets. If hexpand is not
11518 * set, then the expand value depends on whether any
11519 * children of the widget would like to expand.
11521 * There are few reasons to use this function, but it's here
11522 * for completeness and consistency.
11524 * Return value: whether hexpand has been explicitly set
11527 gtk_widget_set_hexpand_set (GtkWidget *widget,
11530 g_return_if_fail (GTK_IS_WIDGET (widget));
11532 gtk_widget_set_expand_set (widget, GTK_ORIENTATION_HORIZONTAL, set);
11537 * gtk_widget_get_vexpand:
11538 * @widget: the widget
11540 * Gets whether the widget would like any available extra vertical
11543 * See gtk_widget_get_hexpand() for more detail.
11545 * Return value: whether vexpand flag is set
11548 gtk_widget_get_vexpand (GtkWidget *widget)
11550 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
11552 return widget->priv->vexpand;
11556 * gtk_widget_set_vexpand:
11557 * @widget: the widget
11558 * @expand: whether to expand
11560 * Sets whether the widget would like any available extra vertical
11563 * See gtk_widget_set_hexpand() for more detail.
11566 gtk_widget_set_vexpand (GtkWidget *widget,
11569 g_return_if_fail (GTK_IS_WIDGET (widget));
11571 gtk_widget_set_expand (widget, GTK_ORIENTATION_VERTICAL, expand);
11575 * gtk_widget_get_vexpand_set:
11576 * @widget: the widget
11578 * Gets whether gtk_widget_set_vexpand() has been used to
11579 * explicitly set the expand flag on this widget.
11581 * See gtk_widget_get_hexpand_set() for more detail.
11583 * Return value: whether vexpand has been explicitly set
11586 gtk_widget_get_vexpand_set (GtkWidget *widget)
11588 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
11590 return widget->priv->vexpand_set;
11594 * gtk_widget_set_vexpand_set:
11595 * @widget: the widget
11596 * @set: value for vexpand-set property
11598 * Sets whether the vexpand flag (see gtk_widget_get_vexpand()) will
11601 * See gtk_widget_set_hexpand_set() for more detail.
11603 * Return value: whether vexpand has been explicitly set
11606 gtk_widget_set_vexpand_set (GtkWidget *widget,
11609 g_return_if_fail (GTK_IS_WIDGET (widget));
11611 gtk_widget_set_expand_set (widget, GTK_ORIENTATION_VERTICAL, set);
11615 * GtkBuildable implementation
11617 static GQuark quark_builder_has_default = 0;
11618 static GQuark quark_builder_has_focus = 0;
11619 static GQuark quark_builder_atk_relations = 0;
11620 static GQuark quark_builder_set_name = 0;
11623 gtk_widget_buildable_interface_init (GtkBuildableIface *iface)
11625 quark_builder_has_default = g_quark_from_static_string ("gtk-builder-has-default");
11626 quark_builder_has_focus = g_quark_from_static_string ("gtk-builder-has-focus");
11627 quark_builder_atk_relations = g_quark_from_static_string ("gtk-builder-atk-relations");
11628 quark_builder_set_name = g_quark_from_static_string ("gtk-builder-set-name");
11630 iface->set_name = gtk_widget_buildable_set_name;
11631 iface->get_name = gtk_widget_buildable_get_name;
11632 iface->get_internal_child = gtk_widget_buildable_get_internal_child;
11633 iface->set_buildable_property = gtk_widget_buildable_set_buildable_property;
11634 iface->parser_finished = gtk_widget_buildable_parser_finished;
11635 iface->custom_tag_start = gtk_widget_buildable_custom_tag_start;
11636 iface->custom_finished = gtk_widget_buildable_custom_finished;
11640 gtk_widget_buildable_set_name (GtkBuildable *buildable,
11643 g_object_set_qdata_full (G_OBJECT (buildable), quark_builder_set_name,
11644 g_strdup (name), g_free);
11647 static const gchar *
11648 gtk_widget_buildable_get_name (GtkBuildable *buildable)
11650 return g_object_get_qdata (G_OBJECT (buildable), quark_builder_set_name);
11654 gtk_widget_buildable_get_internal_child (GtkBuildable *buildable,
11655 GtkBuilder *builder,
11656 const gchar *childname)
11658 if (strcmp (childname, "accessible") == 0)
11659 return G_OBJECT (gtk_widget_get_accessible (GTK_WIDGET (buildable)));
11665 gtk_widget_buildable_set_buildable_property (GtkBuildable *buildable,
11666 GtkBuilder *builder,
11668 const GValue *value)
11670 if (strcmp (name, "has-default") == 0 && g_value_get_boolean (value))
11671 g_object_set_qdata (G_OBJECT (buildable), quark_builder_has_default,
11672 GINT_TO_POINTER (TRUE));
11673 else if (strcmp (name, "has-focus") == 0 && g_value_get_boolean (value))
11674 g_object_set_qdata (G_OBJECT (buildable), quark_builder_has_focus,
11675 GINT_TO_POINTER (TRUE));
11677 g_object_set_property (G_OBJECT (buildable), name, value);
11682 gchar *action_name;
11683 GString *description;
11685 gboolean translatable;
11695 free_action (AtkActionData *data, gpointer user_data)
11697 g_free (data->action_name);
11698 g_string_free (data->description, TRUE);
11699 g_free (data->context);
11700 g_slice_free (AtkActionData, data);
11704 free_relation (AtkRelationData *data, gpointer user_data)
11706 g_free (data->target);
11707 g_free (data->type);
11708 g_slice_free (AtkRelationData, data);
11712 gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
11713 GtkBuilder *builder)
11715 GSList *atk_relations;
11717 if (g_object_get_qdata (G_OBJECT (buildable), quark_builder_has_default))
11718 gtk_widget_grab_default (GTK_WIDGET (buildable));
11719 if (g_object_get_qdata (G_OBJECT (buildable), quark_builder_has_focus))
11720 gtk_widget_grab_focus (GTK_WIDGET (buildable));
11722 atk_relations = g_object_get_qdata (G_OBJECT (buildable),
11723 quark_builder_atk_relations);
11726 AtkObject *accessible;
11727 AtkRelationSet *relation_set;
11730 AtkRelationType relation_type;
11731 AtkObject *target_accessible;
11733 accessible = gtk_widget_get_accessible (GTK_WIDGET (buildable));
11734 relation_set = atk_object_ref_relation_set (accessible);
11736 for (l = atk_relations; l; l = l->next)
11738 AtkRelationData *relation = (AtkRelationData*)l->data;
11740 target = gtk_builder_get_object (builder, relation->target);
11743 g_warning ("Target object %s in <relation> does not exist",
11747 target_accessible = gtk_widget_get_accessible (GTK_WIDGET (target));
11748 g_assert (target_accessible != NULL);
11750 relation_type = atk_relation_type_for_name (relation->type);
11751 if (relation_type == ATK_RELATION_NULL)
11753 g_warning ("<relation> type %s not found",
11757 atk_relation_set_add_relation_by_type (relation_set, relation_type,
11758 target_accessible);
11760 g_object_unref (relation_set);
11762 g_slist_foreach (atk_relations, (GFunc)free_relation, NULL);
11763 g_slist_free (atk_relations);
11764 g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations,
11773 } AccessibilitySubParserData;
11776 accessibility_start_element (GMarkupParseContext *context,
11777 const gchar *element_name,
11778 const gchar **names,
11779 const gchar **values,
11780 gpointer user_data,
11783 AccessibilitySubParserData *data = (AccessibilitySubParserData*)user_data;
11785 gint line_number, char_number;
11787 if (strcmp (element_name, "relation") == 0)
11789 gchar *target = NULL;
11790 gchar *type = NULL;
11791 AtkRelationData *relation;
11793 for (i = 0; names[i]; i++)
11795 if (strcmp (names[i], "target") == 0)
11796 target = g_strdup (values[i]);
11797 else if (strcmp (names[i], "type") == 0)
11798 type = g_strdup (values[i]);
11801 g_markup_parse_context_get_position (context,
11804 g_set_error (error,
11806 GTK_BUILDER_ERROR_INVALID_ATTRIBUTE,
11807 "%s:%d:%d '%s' is not a valid attribute of <%s>",
11809 line_number, char_number, names[i], "relation");
11816 if (!target || !type)
11818 g_markup_parse_context_get_position (context,
11821 g_set_error (error,
11823 GTK_BUILDER_ERROR_MISSING_ATTRIBUTE,
11824 "%s:%d:%d <%s> requires attribute \"%s\"",
11826 line_number, char_number, "relation",
11827 type ? "target" : "type");
11833 relation = g_slice_new (AtkRelationData);
11834 relation->target = target;
11835 relation->type = type;
11837 data->relations = g_slist_prepend (data->relations, relation);
11839 else if (strcmp (element_name, "action") == 0)
11841 const gchar *action_name = NULL;
11842 const gchar *description = NULL;
11843 const gchar *msg_context = NULL;
11844 gboolean translatable = FALSE;
11845 AtkActionData *action;
11847 for (i = 0; names[i]; i++)
11849 if (strcmp (names[i], "action_name") == 0)
11850 action_name = values[i];
11851 else if (strcmp (names[i], "description") == 0)
11852 description = values[i];
11853 else if (strcmp (names[i], "translatable") == 0)
11855 if (!_gtk_builder_boolean_from_string (values[i], &translatable, error))
11858 else if (strcmp (names[i], "comments") == 0)
11860 /* do nothing, comments are for translators */
11862 else if (strcmp (names[i], "context") == 0)
11863 msg_context = values[i];
11866 g_markup_parse_context_get_position (context,
11869 g_set_error (error,
11871 GTK_BUILDER_ERROR_INVALID_ATTRIBUTE,
11872 "%s:%d:%d '%s' is not a valid attribute of <%s>",
11874 line_number, char_number, names[i], "action");
11881 g_markup_parse_context_get_position (context,
11884 g_set_error (error,
11886 GTK_BUILDER_ERROR_MISSING_ATTRIBUTE,
11887 "%s:%d:%d <%s> requires attribute \"%s\"",
11889 line_number, char_number, "action",
11894 action = g_slice_new (AtkActionData);
11895 action->action_name = g_strdup (action_name);
11896 action->description = g_string_new (description);
11897 action->context = g_strdup (msg_context);
11898 action->translatable = translatable;
11900 data->actions = g_slist_prepend (data->actions, action);
11902 else if (strcmp (element_name, "accessibility") == 0)
11905 g_warning ("Unsupported tag for GtkWidget: %s\n", element_name);
11909 accessibility_text (GMarkupParseContext *context,
11912 gpointer user_data,
11915 AccessibilitySubParserData *data = (AccessibilitySubParserData*)user_data;
11917 if (strcmp (g_markup_parse_context_get_element (context), "action") == 0)
11919 AtkActionData *action = data->actions->data;
11921 g_string_append_len (action->description, text, text_len);
11925 static const GMarkupParser accessibility_parser =
11927 accessibility_start_element,
11929 accessibility_text,
11938 } AccelGroupParserData;
11941 accel_group_start_element (GMarkupParseContext *context,
11942 const gchar *element_name,
11943 const gchar **names,
11944 const gchar **values,
11945 gpointer user_data,
11950 guint modifiers = 0;
11951 gchar *signal = NULL;
11952 AccelGroupParserData *parser_data = (AccelGroupParserData*)user_data;
11954 for (i = 0; names[i]; i++)
11956 if (strcmp (names[i], "key") == 0)
11957 key = gdk_keyval_from_name (values[i]);
11958 else if (strcmp (names[i], "modifiers") == 0)
11960 if (!_gtk_builder_flags_from_string (GDK_TYPE_MODIFIER_TYPE,
11966 else if (strcmp (names[i], "signal") == 0)
11967 signal = g_strdup (values[i]);
11970 if (key == 0 || signal == NULL)
11972 g_warning ("<accelerator> requires key and signal attributes");
11975 parser_data->key = key;
11976 parser_data->modifiers = modifiers;
11977 parser_data->signal = signal;
11980 static const GMarkupParser accel_group_parser =
11982 accel_group_start_element,
11986 gtk_widget_buildable_custom_tag_start (GtkBuildable *buildable,
11987 GtkBuilder *builder,
11989 const gchar *tagname,
11990 GMarkupParser *parser,
11993 g_assert (buildable);
11995 if (strcmp (tagname, "accelerator") == 0)
11997 AccelGroupParserData *parser_data;
11999 parser_data = g_slice_new0 (AccelGroupParserData);
12000 parser_data->object = g_object_ref (buildable);
12001 *parser = accel_group_parser;
12002 *data = parser_data;
12005 if (strcmp (tagname, "accessibility") == 0)
12007 AccessibilitySubParserData *parser_data;
12009 parser_data = g_slice_new0 (AccessibilitySubParserData);
12010 *parser = accessibility_parser;
12011 *data = parser_data;
12018 _gtk_widget_buildable_finish_accelerator (GtkWidget *widget,
12019 GtkWidget *toplevel,
12020 gpointer user_data)
12022 AccelGroupParserData *accel_data;
12023 GSList *accel_groups;
12024 GtkAccelGroup *accel_group;
12026 g_return_if_fail (GTK_IS_WIDGET (widget));
12027 g_return_if_fail (GTK_IS_WIDGET (toplevel));
12028 g_return_if_fail (user_data != NULL);
12030 accel_data = (AccelGroupParserData*)user_data;
12031 accel_groups = gtk_accel_groups_from_object (G_OBJECT (toplevel));
12032 if (g_slist_length (accel_groups) == 0)
12034 accel_group = gtk_accel_group_new ();
12035 gtk_window_add_accel_group (GTK_WINDOW (toplevel), accel_group);
12039 g_assert (g_slist_length (accel_groups) == 1);
12040 accel_group = g_slist_nth_data (accel_groups, 0);
12043 gtk_widget_add_accelerator (GTK_WIDGET (accel_data->object),
12044 accel_data->signal,
12047 accel_data->modifiers,
12048 GTK_ACCEL_VISIBLE);
12050 g_object_unref (accel_data->object);
12051 g_free (accel_data->signal);
12052 g_slice_free (AccelGroupParserData, accel_data);
12056 gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
12057 GtkBuilder *builder,
12059 const gchar *tagname,
12060 gpointer user_data)
12062 AccelGroupParserData *accel_data;
12063 AccessibilitySubParserData *a11y_data;
12064 GtkWidget *toplevel;
12066 if (strcmp (tagname, "accelerator") == 0)
12068 accel_data = (AccelGroupParserData*)user_data;
12069 g_assert (accel_data->object);
12071 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (accel_data->object));
12073 _gtk_widget_buildable_finish_accelerator (GTK_WIDGET (buildable), toplevel, user_data);
12075 else if (strcmp (tagname, "accessibility") == 0)
12077 a11y_data = (AccessibilitySubParserData*)user_data;
12079 if (a11y_data->actions)
12081 AtkObject *accessible;
12086 accessible = gtk_widget_get_accessible (GTK_WIDGET (buildable));
12088 action = ATK_ACTION (accessible);
12089 n_actions = atk_action_get_n_actions (action);
12091 for (l = a11y_data->actions; l; l = l->next)
12093 AtkActionData *action_data = (AtkActionData*)l->data;
12095 for (i = 0; i < n_actions; i++)
12096 if (strcmp (atk_action_get_name (action, i),
12097 action_data->action_name) == 0)
12102 gchar *description;
12104 if (action_data->translatable && action_data->description->len)
12105 description = _gtk_builder_parser_translate (gtk_builder_get_translation_domain (builder),
12106 action_data->context,
12107 action_data->description->str);
12109 description = action_data->description->str;
12111 atk_action_set_description (action, i, description);
12115 g_slist_foreach (a11y_data->actions, (GFunc)free_action, NULL);
12116 g_slist_free (a11y_data->actions);
12119 if (a11y_data->relations)
12120 g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations,
12121 a11y_data->relations);
12123 g_slice_free (AccessibilitySubParserData, a11y_data);
12128 gtk_widget_real_get_width (GtkWidget *widget,
12129 gint *minimum_size,
12130 gint *natural_size)
12140 gtk_widget_real_get_height (GtkWidget *widget,
12141 gint *minimum_size,
12142 gint *natural_size)
12152 gtk_widget_real_get_height_for_width (GtkWidget *widget,
12154 gint *minimum_height,
12155 gint *natural_height)
12157 GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, minimum_height, natural_height);
12161 gtk_widget_real_get_width_for_height (GtkWidget *widget,
12163 gint *minimum_width,
12164 gint *natural_width)
12166 GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_width, natural_width);
12170 * gtk_widget_get_halign:
12171 * @widget: a #GtkWidget
12173 * Gets the value of the #GtkWidget:halign property.
12175 * Returns: the horizontal alignment of @widget
12178 gtk_widget_get_halign (GtkWidget *widget)
12180 g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_ALIGN_FILL);
12181 return _gtk_widget_get_aux_info_or_defaults (widget)->halign;
12185 * gtk_widget_set_halign:
12186 * @widget: a #GtkWidget
12187 * @align: the horizontal alignment
12189 * Sets the horizontal alignment of @widget.
12190 * See the #GtkWidget:halign property.
12193 gtk_widget_set_halign (GtkWidget *widget,
12196 GtkWidgetAuxInfo *aux_info;
12198 g_return_if_fail (GTK_IS_WIDGET (widget));
12200 aux_info = _gtk_widget_get_aux_info (widget, TRUE);
12202 if (aux_info->halign == align)
12205 aux_info->halign = align;
12206 gtk_widget_queue_resize (widget);
12207 g_object_notify (G_OBJECT (widget), "halign");
12211 * gtk_widget_get_valign:
12212 * @widget: a #GtkWidget
12214 * Gets the value of the #GtkWidget:valign property.
12216 * Returns: the vertical alignment of @widget
12219 gtk_widget_get_valign (GtkWidget *widget)
12221 g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_ALIGN_FILL);
12222 return _gtk_widget_get_aux_info_or_defaults (widget)->valign;
12226 * gtk_widget_set_valign:
12227 * @widget: a #GtkWidget
12228 * @align: the vertical alignment
12230 * Sets the vertical alignment of @widget.
12231 * See the #GtkWidget:valign property.
12234 gtk_widget_set_valign (GtkWidget *widget,
12237 GtkWidgetAuxInfo *aux_info;
12239 g_return_if_fail (GTK_IS_WIDGET (widget));
12241 aux_info = _gtk_widget_get_aux_info (widget, TRUE);
12243 if (aux_info->valign == align)
12246 aux_info->valign = align;
12247 gtk_widget_queue_resize (widget);
12248 g_object_notify (G_OBJECT (widget), "valign");
12252 * gtk_widget_get_margin_left:
12253 * @widget: a #GtkWidget
12255 * Gets the value of the #GtkWidget:margin-left property.
12257 * Returns: The left margin of @widget
12260 gtk_widget_get_margin_left (GtkWidget *widget)
12262 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
12264 return _gtk_widget_get_aux_info_or_defaults (widget)->margin.left;
12268 * gtk_widget_set_margin_left:
12269 * @widget: a #GtkWidget
12270 * @margin: the left margin
12272 * Sets the left margin of @widget.
12273 * See the #GtkWidget:margin-left property.
12276 gtk_widget_set_margin_left (GtkWidget *widget,
12279 GtkWidgetAuxInfo *aux_info;
12281 g_return_if_fail (GTK_IS_WIDGET (widget));
12282 g_return_if_fail (margin <= G_MAXINT16);
12284 aux_info = _gtk_widget_get_aux_info (widget, TRUE);
12286 if (aux_info->margin.left == margin)
12289 aux_info->margin.left = margin;
12290 gtk_widget_queue_resize (widget);
12291 g_object_notify (G_OBJECT (widget), "margin-left");
12295 * gtk_widget_get_margin_right:
12296 * @widget: a #GtkWidget
12298 * Gets the value of the #GtkWidget:margin-right property.
12300 * Returns: The left margin of @widget
12303 gtk_widget_get_margin_right (GtkWidget *widget)
12305 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
12307 return _gtk_widget_get_aux_info_or_defaults (widget)->margin.right;
12311 * gtk_widget_set_margin_right:
12312 * @widget: a #GtkWidget
12313 * @margin: the right margin
12315 * Sets the right margin of @widget.
12316 * See the #GtkWidget:margin-right property.
12319 gtk_widget_set_margin_right (GtkWidget *widget,
12322 GtkWidgetAuxInfo *aux_info;
12324 g_return_if_fail (GTK_IS_WIDGET (widget));
12325 g_return_if_fail (margin <= G_MAXINT16);
12327 aux_info = _gtk_widget_get_aux_info (widget, TRUE);
12329 if (aux_info->margin.right == margin)
12332 aux_info->margin.right = margin;
12333 gtk_widget_queue_resize (widget);
12334 g_object_notify (G_OBJECT (widget), "margin-right");
12338 * gtk_widget_get_margin_top:
12339 * @widget: a #GtkWidget
12341 * Gets the value of the #GtkWidget:margin-top property.
12343 * Returns: The top margin of @widget
12346 gtk_widget_get_margin_top (GtkWidget *widget)
12348 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
12350 return _gtk_widget_get_aux_info_or_defaults (widget)->margin.top;
12354 * gtk_widget_set_margin_top:
12355 * @widget: a #GtkWidget
12356 * @margin: the top margin
12358 * Sets the top margin of @widget.
12359 * See the #GtkWidget:margin-top property.
12362 gtk_widget_set_margin_top (GtkWidget *widget,
12365 GtkWidgetAuxInfo *aux_info;
12367 g_return_if_fail (GTK_IS_WIDGET (widget));
12368 g_return_if_fail (margin <= G_MAXINT16);
12370 aux_info = _gtk_widget_get_aux_info (widget, TRUE);
12372 if (aux_info->margin.top == margin)
12375 aux_info->margin.top = margin;
12376 gtk_widget_queue_resize (widget);
12377 g_object_notify (G_OBJECT (widget), "margin-top");
12381 * gtk_widget_get_margin_bottom:
12382 * @widget: a #GtkWidget
12384 * Gets the value of the #GtkWidget:margin-bottom property.
12386 * Returns: The bottom margin of @widget
12389 gtk_widget_get_margin_bottom (GtkWidget *widget)
12391 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
12393 return _gtk_widget_get_aux_info_or_defaults (widget)->margin.bottom;
12397 * gtk_widget_set_margin_bottom:
12398 * @widget: a #GtkWidget
12399 * @margin: the bottom margin
12401 * Sets the bottom margin of @widget.
12402 * See the #GtkWidget:margin-bottom property.
12405 gtk_widget_set_margin_bottom (GtkWidget *widget,
12408 GtkWidgetAuxInfo *aux_info;
12410 g_return_if_fail (GTK_IS_WIDGET (widget));
12411 g_return_if_fail (margin <= G_MAXINT16);
12413 aux_info = _gtk_widget_get_aux_info (widget, TRUE);
12415 if (aux_info->margin.bottom == margin)
12418 aux_info->margin.bottom = margin;
12419 gtk_widget_queue_resize (widget);
12420 g_object_notify (G_OBJECT (widget), "margin-bottom");
12424 * gtk_widget_get_clipboard:
12425 * @widget: a #GtkWidget
12426 * @selection: a #GdkAtom which identifies the clipboard
12427 * to use. %GDK_SELECTION_CLIPBOARD gives the
12428 * default clipboard. Another common value
12429 * is %GDK_SELECTION_PRIMARY, which gives
12430 * the primary X selection.
12432 * Returns the clipboard object for the given selection to
12433 * be used with @widget. @widget must have a #GdkDisplay
12434 * associated with it, so must be attached to a toplevel
12437 * Return value: (transfer none): the appropriate clipboard object. If no
12438 * clipboard already exists, a new one will
12439 * be created. Once a clipboard object has
12440 * been created, it is persistent for all time.
12445 gtk_widget_get_clipboard (GtkWidget *widget, GdkAtom selection)
12447 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
12448 g_return_val_if_fail (gtk_widget_has_screen (widget), NULL);
12450 return gtk_clipboard_get_for_display (gtk_widget_get_display (widget),
12455 * gtk_widget_list_mnemonic_labels:
12456 * @widget: a #GtkWidget
12458 * Returns a newly allocated list of the widgets, normally labels, for
12459 * which this widget is the target of a mnemonic (see for example,
12460 * gtk_label_set_mnemonic_widget()).
12462 * The widgets in the list are not individually referenced. If you
12463 * want to iterate through the list and perform actions involving
12464 * callbacks that might destroy the widgets, you
12465 * <emphasis>must</emphasis> call <literal>g_list_foreach (result,
12466 * (GFunc)g_object_ref, NULL)</literal> first, and then unref all the
12467 * widgets afterwards.
12469 * Return value: (element-type GtkWidget) (transfer container): the list of
12470 * mnemonic labels; free this list
12471 * with g_list_free() when you are done with it.
12476 gtk_widget_list_mnemonic_labels (GtkWidget *widget)
12478 GList *list = NULL;
12481 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
12483 for (l = g_object_get_qdata (G_OBJECT (widget), quark_mnemonic_labels); l; l = l->next)
12484 list = g_list_prepend (list, l->data);
12490 * gtk_widget_add_mnemonic_label:
12491 * @widget: a #GtkWidget
12492 * @label: a #GtkWidget that acts as a mnemonic label for @widget
12494 * Adds a widget to the list of mnemonic labels for
12495 * this widget. (See gtk_widget_list_mnemonic_labels()). Note the
12496 * list of mnemonic labels for the widget is cleared when the
12497 * widget is destroyed, so the caller must make sure to update
12498 * its internal state at this point as well, by using a connection
12499 * to the #GtkWidget::destroy signal or a weak notifier.
12504 gtk_widget_add_mnemonic_label (GtkWidget *widget,
12507 GSList *old_list, *new_list;
12509 g_return_if_fail (GTK_IS_WIDGET (widget));
12510 g_return_if_fail (GTK_IS_WIDGET (label));
12512 old_list = g_object_steal_qdata (G_OBJECT (widget), quark_mnemonic_labels);
12513 new_list = g_slist_prepend (old_list, label);
12515 g_object_set_qdata_full (G_OBJECT (widget), quark_mnemonic_labels,
12516 new_list, (GDestroyNotify) g_slist_free);
12520 * gtk_widget_remove_mnemonic_label:
12521 * @widget: a #GtkWidget
12522 * @label: a #GtkWidget that was previously set as a mnemnic label for
12523 * @widget with gtk_widget_add_mnemonic_label().
12525 * Removes a widget from the list of mnemonic labels for
12526 * this widget. (See gtk_widget_list_mnemonic_labels()). The widget
12527 * must have previously been added to the list with
12528 * gtk_widget_add_mnemonic_label().
12533 gtk_widget_remove_mnemonic_label (GtkWidget *widget,
12536 GSList *old_list, *new_list;
12538 g_return_if_fail (GTK_IS_WIDGET (widget));
12539 g_return_if_fail (GTK_IS_WIDGET (label));
12541 old_list = g_object_steal_qdata (G_OBJECT (widget), quark_mnemonic_labels);
12542 new_list = g_slist_remove (old_list, label);
12545 g_object_set_qdata_full (G_OBJECT (widget), quark_mnemonic_labels,
12546 new_list, (GDestroyNotify) g_slist_free);
12550 * gtk_widget_get_no_show_all:
12551 * @widget: a #GtkWidget
12553 * Returns the current value of the GtkWidget:no-show-all property,
12554 * which determines whether calls to gtk_widget_show_all()
12555 * will affect this widget.
12557 * Return value: the current value of the "no-show-all" property.
12562 gtk_widget_get_no_show_all (GtkWidget *widget)
12564 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
12566 return widget->priv->no_show_all;
12570 * gtk_widget_set_no_show_all:
12571 * @widget: a #GtkWidget
12572 * @no_show_all: the new value for the "no-show-all" property
12574 * Sets the #GtkWidget:no-show-all property, which determines whether
12575 * calls to gtk_widget_show_all() will affect this widget.
12577 * This is mostly for use in constructing widget hierarchies with externally
12578 * controlled visibility, see #GtkUIManager.
12583 gtk_widget_set_no_show_all (GtkWidget *widget,
12584 gboolean no_show_all)
12586 g_return_if_fail (GTK_IS_WIDGET (widget));
12588 no_show_all = (no_show_all != FALSE);
12590 if (widget->priv->no_show_all != no_show_all)
12592 widget->priv->no_show_all = no_show_all;
12594 g_object_notify (G_OBJECT (widget), "no-show-all");
12600 gtk_widget_real_set_has_tooltip (GtkWidget *widget,
12601 gboolean has_tooltip,
12604 GtkWidgetPrivate *priv = widget->priv;
12605 gboolean priv_has_tooltip;
12607 priv_has_tooltip = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (widget),
12608 quark_has_tooltip));
12610 if (priv_has_tooltip != has_tooltip || force)
12612 priv_has_tooltip = has_tooltip;
12614 if (priv_has_tooltip)
12616 if (gtk_widget_get_realized (widget) && !gtk_widget_get_has_window (widget))
12617 gdk_window_set_events (priv->window,
12618 gdk_window_get_events (priv->window) |
12619 GDK_LEAVE_NOTIFY_MASK |
12620 GDK_POINTER_MOTION_MASK |
12621 GDK_POINTER_MOTION_HINT_MASK);
12623 if (gtk_widget_get_has_window (widget))
12624 gtk_widget_add_events (widget,
12625 GDK_LEAVE_NOTIFY_MASK |
12626 GDK_POINTER_MOTION_MASK |
12627 GDK_POINTER_MOTION_HINT_MASK);
12630 g_object_set_qdata (G_OBJECT (widget), quark_has_tooltip,
12631 GUINT_TO_POINTER (priv_has_tooltip));
12636 * gtk_widget_set_tooltip_window:
12637 * @widget: a #GtkWidget
12638 * @custom_window: (allow-none): a #GtkWindow, or %NULL
12640 * Replaces the default, usually yellow, window used for displaying
12641 * tooltips with @custom_window. GTK+ will take care of showing and
12642 * hiding @custom_window at the right moment, to behave likewise as
12643 * the default tooltip window. If @custom_window is %NULL, the default
12644 * tooltip window will be used.
12646 * If the custom window should have the default theming it needs to
12647 * have the name "gtk-tooltip", see gtk_widget_set_name().
12652 gtk_widget_set_tooltip_window (GtkWidget *widget,
12653 GtkWindow *custom_window)
12655 gboolean has_tooltip;
12656 gchar *tooltip_markup;
12658 g_return_if_fail (GTK_IS_WIDGET (widget));
12659 g_return_if_fail (custom_window == NULL || GTK_IS_WINDOW (custom_window));
12661 tooltip_markup = g_object_get_qdata (G_OBJECT (widget), quark_tooltip_markup);
12664 g_object_ref (custom_window);
12666 g_object_set_qdata_full (G_OBJECT (widget), quark_tooltip_window,
12667 custom_window, g_object_unref);
12669 has_tooltip = (custom_window != NULL || tooltip_markup != NULL);
12670 gtk_widget_real_set_has_tooltip (widget, has_tooltip, FALSE);
12672 if (has_tooltip && gtk_widget_get_visible (widget))
12673 gtk_widget_queue_tooltip_query (widget);
12677 * gtk_widget_get_tooltip_window:
12678 * @widget: a #GtkWidget
12680 * Returns the #GtkWindow of the current tooltip. This can be the
12681 * GtkWindow created by default, or the custom tooltip window set
12682 * using gtk_widget_set_tooltip_window().
12684 * Return value: (transfer none): The #GtkWindow of the current tooltip.
12689 gtk_widget_get_tooltip_window (GtkWidget *widget)
12691 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
12693 return g_object_get_qdata (G_OBJECT (widget), quark_tooltip_window);
12697 * gtk_widget_trigger_tooltip_query:
12698 * @widget: a #GtkWidget
12700 * Triggers a tooltip query on the display where the toplevel of @widget
12701 * is located. See gtk_tooltip_trigger_tooltip_query() for more
12707 gtk_widget_trigger_tooltip_query (GtkWidget *widget)
12709 gtk_tooltip_trigger_tooltip_query (gtk_widget_get_display (widget));
12712 static guint tooltip_query_id;
12713 static GSList *tooltip_query_displays;
12716 tooltip_query_idle (gpointer data)
12718 g_slist_foreach (tooltip_query_displays, (GFunc)gtk_tooltip_trigger_tooltip_query, NULL);
12719 g_slist_foreach (tooltip_query_displays, (GFunc)g_object_unref, NULL);
12720 g_slist_free (tooltip_query_displays);
12722 tooltip_query_displays = NULL;
12723 tooltip_query_id = 0;
12729 gtk_widget_queue_tooltip_query (GtkWidget *widget)
12731 GdkDisplay *display;
12733 display = gtk_widget_get_display (widget);
12735 if (!g_slist_find (tooltip_query_displays, display))
12736 tooltip_query_displays = g_slist_prepend (tooltip_query_displays, g_object_ref (display));
12738 if (tooltip_query_id == 0)
12739 tooltip_query_id = gdk_threads_add_idle (tooltip_query_idle, NULL);
12743 * gtk_widget_set_tooltip_text:
12744 * @widget: a #GtkWidget
12745 * @text: the contents of the tooltip for @widget
12747 * Sets @text as the contents of the tooltip. This function will take
12748 * care of setting GtkWidget:has-tooltip to %TRUE and of the default
12749 * handler for the GtkWidget::query-tooltip signal.
12751 * See also the GtkWidget:tooltip-text property and gtk_tooltip_set_text().
12756 gtk_widget_set_tooltip_text (GtkWidget *widget,
12759 g_return_if_fail (GTK_IS_WIDGET (widget));
12761 g_object_set (G_OBJECT (widget), "tooltip-text", text, NULL);
12765 * gtk_widget_get_tooltip_text:
12766 * @widget: a #GtkWidget
12768 * Gets the contents of the tooltip for @widget.
12770 * Return value: the tooltip text, or %NULL. You should free the
12771 * returned string with g_free() when done.
12776 gtk_widget_get_tooltip_text (GtkWidget *widget)
12778 gchar *text = NULL;
12780 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
12782 g_object_get (G_OBJECT (widget), "tooltip-text", &text, NULL);
12788 * gtk_widget_set_tooltip_markup:
12789 * @widget: a #GtkWidget
12790 * @markup: (allow-none): the contents of the tooltip for @widget, or %NULL
12792 * Sets @markup as the contents of the tooltip, which is marked up with
12793 * the <link linkend="PangoMarkupFormat">Pango text markup language</link>.
12795 * This function will take care of setting GtkWidget:has-tooltip to %TRUE
12796 * and of the default handler for the GtkWidget::query-tooltip signal.
12798 * See also the GtkWidget:tooltip-markup property and
12799 * gtk_tooltip_set_markup().
12804 gtk_widget_set_tooltip_markup (GtkWidget *widget,
12805 const gchar *markup)
12807 g_return_if_fail (GTK_IS_WIDGET (widget));
12809 g_object_set (G_OBJECT (widget), "tooltip-markup", markup, NULL);
12813 * gtk_widget_get_tooltip_markup:
12814 * @widget: a #GtkWidget
12816 * Gets the contents of the tooltip for @widget.
12818 * Return value: the tooltip text, or %NULL. You should free the
12819 * returned string with g_free() when done.
12824 gtk_widget_get_tooltip_markup (GtkWidget *widget)
12826 gchar *text = NULL;
12828 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
12830 g_object_get (G_OBJECT (widget), "tooltip-markup", &text, NULL);
12836 * gtk_widget_set_has_tooltip:
12837 * @widget: a #GtkWidget
12838 * @has_tooltip: whether or not @widget has a tooltip.
12840 * Sets the has-tooltip property on @widget to @has_tooltip. See
12841 * GtkWidget:has-tooltip for more information.
12846 gtk_widget_set_has_tooltip (GtkWidget *widget,
12847 gboolean has_tooltip)
12849 g_return_if_fail (GTK_IS_WIDGET (widget));
12851 g_object_set (G_OBJECT (widget), "has-tooltip", has_tooltip, NULL);
12855 * gtk_widget_get_has_tooltip:
12856 * @widget: a #GtkWidget
12858 * Returns the current value of the has-tooltip property. See
12859 * GtkWidget:has-tooltip for more information.
12861 * Return value: current value of has-tooltip on @widget.
12866 gtk_widget_get_has_tooltip (GtkWidget *widget)
12868 gboolean has_tooltip = FALSE;
12870 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
12872 g_object_get (G_OBJECT (widget), "has-tooltip", &has_tooltip, NULL);
12874 return has_tooltip;
12878 * gtk_widget_get_allocation:
12879 * @widget: a #GtkWidget
12880 * @allocation: (out): a pointer to a #GtkAllocation to copy to
12882 * Retrieves the widget's allocation.
12884 * Note, when implementing a #GtkContainer: a widget's allocation will
12885 * be its "adjusted" allocation, that is, the widget's parent
12886 * container typically calls gtk_widget_size_allocate() with an
12887 * allocation, and that allocation is then adjusted (to handle margin
12888 * and alignment for example) before assignment to the widget.
12889 * gtk_widget_get_allocation() returns the adjusted allocation that
12890 * was actually assigned to the widget. The adjusted allocation is
12891 * guaranteed to be completely contained within the
12892 * gtk_widget_size_allocate() allocation, however. So a #GtkContainer
12893 * is guaranteed that its children stay inside the assigned bounds,
12894 * but not that they have exactly the bounds the container assigned.
12895 * There is no way to get the original allocation assigned by
12896 * gtk_widget_size_allocate(), since it isn't stored; if a container
12897 * implementation needs that information it will have to track it itself.
12902 gtk_widget_get_allocation (GtkWidget *widget,
12903 GtkAllocation *allocation)
12905 GtkWidgetPrivate *priv;
12907 g_return_if_fail (GTK_IS_WIDGET (widget));
12908 g_return_if_fail (allocation != NULL);
12910 priv = widget->priv;
12912 *allocation = priv->allocation;
12916 * gtk_widget_set_allocation:
12917 * @widget: a #GtkWidget
12918 * @allocation: a pointer to a #GtkAllocation to copy from
12920 * Sets the widget's allocation. This should not be used
12921 * directly, but from within a widget's size_allocate method.
12923 * The allocation set should be the "adjusted" or actual
12924 * allocation. If you're implementing a #GtkContainer, you want to use
12925 * gtk_widget_size_allocate() instead of gtk_widget_set_allocation().
12926 * The GtkWidgetClass::adjust_size_allocation virtual method adjusts the
12927 * allocation inside gtk_widget_size_allocate() to create an adjusted
12933 gtk_widget_set_allocation (GtkWidget *widget,
12934 const GtkAllocation *allocation)
12936 GtkWidgetPrivate *priv;
12938 g_return_if_fail (GTK_IS_WIDGET (widget));
12939 g_return_if_fail (allocation != NULL);
12941 priv = widget->priv;
12943 priv->allocation = *allocation;
12947 * gtk_widget_get_allocated_width:
12948 * @widget: the widget to query
12950 * Returns the width that has currently been allocated to @widget.
12951 * This function is intended to be used when implementing handlers
12952 * for the GtkWidget::draw function.
12954 * Returns: the width of the @widget
12957 gtk_widget_get_allocated_width (GtkWidget *widget)
12959 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
12961 return widget->priv->allocation.width;
12965 * gtk_widget_get_allocated_height:
12966 * @widget: the widget to query
12968 * Returns the height that has currently been allocated to @widget.
12969 * This function is intended to be used when implementing handlers
12970 * for the GtkWidget::draw function.
12972 * Returns: the height of the @widget
12975 gtk_widget_get_allocated_height (GtkWidget *widget)
12977 g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
12979 return widget->priv->allocation.height;
12983 * gtk_widget_get_requisition:
12984 * @widget: a #GtkWidget
12985 * @requisition: (out): a pointer to a #GtkRequisition to copy to
12987 * Retrieves the widget's requisition.
12989 * This function should only be used by widget implementations in
12990 * order to figure whether the widget's requisition has actually
12991 * changed after some internal state change (so that they can call
12992 * gtk_widget_queue_resize() instead of gtk_widget_queue_draw()).
12994 * Normally, gtk_widget_size_request() should be used.
12998 * Deprecated: 3.0: The #GtkRequisition cache on the widget was
12999 * removed, If you need to cache sizes across requests and allocations,
13000 * add an explicit cache to the widget in question instead.
13003 gtk_widget_get_requisition (GtkWidget *widget,
13004 GtkRequisition *requisition)
13006 g_return_if_fail (GTK_IS_WIDGET (widget));
13007 g_return_if_fail (requisition != NULL);
13009 gtk_widget_get_preferred_size (widget, requisition, NULL);
13013 * gtk_widget_set_window:
13014 * @widget: a #GtkWidget
13015 * @window: a #GdkWindow
13017 * Sets a widget's window. This function should only be used in a
13018 * widget's GtkWidget::realize() implementation. The %window passed is
13019 * usually either new window created with gdk_window_new(), or the
13020 * window of its parent widget as returned by
13021 * gtk_widget_get_parent_window().
13023 * Widgets must indicate whether they will create their own #GdkWindow
13024 * by calling gtk_widget_set_has_window(). This is usually done in the
13025 * widget's init() function.
13027 * <note><para>This function does not add any reference to @window.</para></note>
13032 gtk_widget_set_window (GtkWidget *widget,
13035 GtkWidgetPrivate *priv;
13037 g_return_if_fail (GTK_IS_WIDGET (widget));
13038 g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
13040 priv = widget->priv;
13042 if (priv->window != window)
13044 priv->window = window;
13045 g_object_notify (G_OBJECT (widget), "window");
13050 * gtk_widget_get_window:
13051 * @widget: a #GtkWidget
13053 * Returns the widget's window if it is realized, %NULL otherwise
13055 * Return value: (transfer none): @widget's window.
13060 gtk_widget_get_window (GtkWidget *widget)
13062 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
13064 return widget->priv->window;
13068 * gtk_widget_get_support_multidevice:
13069 * @widget: a #GtkWidget
13071 * Returns %TRUE if @widget is multiple pointer aware. See
13072 * gtk_widget_set_support_multidevice() for more information.
13074 * Returns: %TRUE is @widget is multidevice aware.
13077 gtk_widget_get_support_multidevice (GtkWidget *widget)
13079 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
13081 return widget->priv->multidevice;
13085 * gtk_widget_set_support_multidevice:
13086 * @widget: a #GtkWidget
13087 * @support_multidevice: %TRUE to support input from multiple devices.
13089 * Enables or disables multiple pointer awareness. If this setting is %TRUE,
13090 * @widget will start receiving multiple, per device enter/leave events. Note
13091 * that if custom #GdkWindow<!-- -->s are created in #GtkWidget::realize,
13092 * gdk_window_set_support_multidevice() will have to be called manually on them.
13097 gtk_widget_set_support_multidevice (GtkWidget *widget,
13098 gboolean support_multidevice)
13100 GtkWidgetPrivate *priv;
13102 g_return_if_fail (GTK_IS_WIDGET (widget));
13104 priv = widget->priv;
13106 if (support_multidevice)
13108 priv->multidevice = TRUE;
13109 gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_ALL);
13113 priv->multidevice = FALSE;
13114 gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_NONE);
13117 if (gtk_widget_get_realized (widget))
13118 gdk_window_set_support_multidevice (priv->window, support_multidevice);
13122 _gtk_widget_set_has_focus (GtkWidget *widget,
13123 gboolean has_focus)
13125 widget->priv->has_focus = has_focus;
13129 * gtk_widget_send_focus_change:
13130 * @widget: a #GtkWidget
13131 * @event: a #GdkEvent of type GDK_FOCUS_CHANGE
13133 * Sends the focus change @event to @widget
13135 * This function is not meant to be used by applications. The only time it
13136 * should be used is when it is necessary for a #GtkWidget to assign focus
13137 * to a widget that is semantically owned by the first widget even though
13138 * it's not a direct child - for instance, a search entry in a floating
13139 * window similar to the quick search in #GtkTreeView.
13141 * An example of its usage is:
13144 * GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE);
13146 * fevent->focus_change.type = GDK_FOCUS_CHANGE;
13147 * fevent->focus_change.in = TRUE;
13148 * fevent->focus_change.window = gtk_widget_get_window (widget);
13149 * if (fevent->focus_change.window != NULL)
13150 * g_object_ref (fevent->focus_change.window);
13152 * gtk_widget_send_focus_change (widget, fevent);
13154 * gdk_event_free (event);
13157 * Return value: the return value from the event signal emission: %TRUE
13158 * if the event was handled, and %FALSE otherwise
13163 gtk_widget_send_focus_change (GtkWidget *widget,
13168 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
13169 g_return_val_if_fail (event != NULL && event->type == GDK_FOCUS_CHANGE, FALSE);
13171 g_object_ref (widget);
13173 _gtk_widget_set_has_focus (widget, event->focus_change.in);
13175 res = gtk_widget_event (widget, event);
13177 g_object_notify (G_OBJECT (widget), "has-focus");
13179 g_object_unref (widget);
13185 gtk_widget_in_destruction (GtkWidget *widget)
13187 return widget->priv->in_destruction;
13191 _gtk_widget_get_resize_pending (GtkWidget *widget)
13193 return widget->priv->resize_pending;
13197 _gtk_widget_set_resize_pending (GtkWidget *widget,
13198 gboolean resize_pending)
13200 widget->priv->resize_pending = resize_pending;
13204 _gtk_widget_get_in_reparent (GtkWidget *widget)
13206 return widget->priv->in_reparent;
13210 _gtk_widget_set_in_reparent (GtkWidget *widget,
13211 gboolean in_reparent)
13213 widget->priv->in_reparent = in_reparent;
13217 _gtk_widget_get_anchored (GtkWidget *widget)
13219 return widget->priv->anchored;
13223 _gtk_widget_set_anchored (GtkWidget *widget,
13226 widget->priv->anchored = anchored;
13230 _gtk_widget_get_shadowed (GtkWidget *widget)
13232 return widget->priv->shadowed;
13236 _gtk_widget_set_shadowed (GtkWidget *widget,
13239 widget->priv->shadowed = shadowed;
13243 _gtk_widget_get_alloc_needed (GtkWidget *widget)
13245 return widget->priv->alloc_needed;
13249 _gtk_widget_set_alloc_needed (GtkWidget *widget,
13250 gboolean alloc_needed)
13252 widget->priv->alloc_needed = alloc_needed;
13256 _gtk_widget_get_width_request_needed (GtkWidget *widget)
13258 return widget->priv->width_request_needed;
13262 _gtk_widget_set_width_request_needed (GtkWidget *widget,
13263 gboolean width_request_needed)
13265 widget->priv->width_request_needed = width_request_needed;
13269 _gtk_widget_get_height_request_needed (GtkWidget *widget)
13271 return widget->priv->height_request_needed;
13275 _gtk_widget_set_height_request_needed (GtkWidget *widget,
13276 gboolean height_request_needed)
13278 widget->priv->height_request_needed = height_request_needed;