## GtkWidget GtkWidget — Base class for all widgets |

## Functions

void | (*GtkCallback) ()
GtkWidget * | gtk_widget_new ()
void | gtk_widget_destroy ()
gboolean | gtk_widget_in_destruction ()
void | gtk_widget_destroyed ()
void | gtk_widget_unparent ()
void | gtk_widget_show ()
void | gtk_widget_show_now ()
void | gtk_widget_hide ()
void | gtk_widget_show_all ()
void | gtk_widget_map ()
void | gtk_widget_unmap ()
void | gtk_widget_realize ()
void | gtk_widget_unrealize ()
void | gtk_widget_draw ()
void | gtk_widget_queue_draw ()
void | gtk_widget_queue_resize ()
void | gtk_widget_queue_resize_no_redraw ()
void | gtk_widget_queue_allocate ()
GdkFrameClock * | gtk_widget_get_frame_clock ()
gint | gtk_widget_get_scale_factor ()
gboolean | (*GtkTickCallback) ()
guint | gtk_widget_add_tick_callback ()
void | gtk_widget_remove_tick_callback ()
void | gtk_widget_size_request ()
void | gtk_widget_get_child_requisition ()
void | gtk_widget_size_allocate ()
void | gtk_widget_size_allocate_with_baseline ()
void | gtk_widget_add_accelerator ()
gboolean | gtk_widget_remove_accelerator ()
void | gtk_widget_set_accel_path ()
GList * | gtk_widget_list_accel_closures ()
gboolean | gtk_widget_can_activate_accel ()
gboolean | gtk_widget_event ()
gboolean | gtk_widget_activate ()
void | gtk_widget_reparent ()
gboolean | gtk_widget_intersect ()
gboolean | gtk_widget_is_focus ()
void | gtk_widget_grab_focus ()
void | gtk_widget_grab_default ()
void | gtk_widget_set_name ()
const gchar * | gtk_widget_get_name ()
void | gtk_widget_set_state ()
void | gtk_widget_set_sensitive ()
void | gtk_widget_set_parent ()
void | gtk_widget_set_parent_window ()
GdkWindow * | gtk_widget_get_parent_window ()
void | gtk_widget_set_events ()
gint | gtk_widget_get_events ()
void | gtk_widget_add_events ()
void | gtk_widget_set_device_events ()
GdkEventMask | gtk_widget_get_device_events ()
void | gtk_widget_add_device_events ()
void | gtk_widget_set_device_enabled ()
gboolean | gtk_widget_get_device_enabled ()
GtkWidget * | gtk_widget_get_toplevel ()
GtkWidget * | gtk_widget_get_ancestor ()
GdkVisual * | gtk_widget_get_visual ()
void | gtk_widget_set_visual ()
void | gtk_widget_get_pointer ()
gboolean | gtk_widget_is_ancestor ()
gboolean | gtk_widget_translate_coordinates ()
gboolean | gtk_widget_hide_on_delete ()
void | gtk_widget_set_style ()
void | gtk_widget_ensure_style ()
GtkStyle * | gtk_widget_get_style ()
void | gtk_widget_reset_rc_styles ()
GtkStyle * | gtk_widget_get_default_style ()
void | gtk_widget_set_direction ()
GtkTextDirection | gtk_widget_get_direction ()
void | gtk_widget_set_default_direction ()
GtkTextDirection | gtk_widget_get_default_direction ()
void | gtk_widget_shape_combine_region ()
void | gtk_widget_input_shape_combine_region ()
void | gtk_widget_path ()
void | gtk_widget_class_path ()
gchar * | gtk_widget_get_composite_name ()
void | gtk_widget_override_background_color ()
void | gtk_widget_override_color ()
void | gtk_widget_override_font ()
void | gtk_widget_override_symbolic_color ()
void | gtk_widget_override_cursor ()
void | gtk_widget_modify_style ()
GtkRcStyle * | gtk_widget_get_modifier_style ()
void | gtk_widget_modify_fg ()
void | gtk_widget_modify_bg ()
void | gtk_widget_modify_text ()
void | gtk_widget_modify_base ()
void | gtk_widget_modify_font ()
void | gtk_widget_modify_cursor ()
PangoContext * | gtk_widget_create_pango_context ()
PangoContext * | gtk_widget_get_pango_context ()
void | gtk_widget_set_font_options ()
const cairo_font_options_t * | gtk_widget_get_font_options ()
void | gtk_widget_set_font_map ()
PangoFontMap * | gtk_widget_get_font_map ()
PangoLayout * | gtk_widget_create_pango_layout ()
GdkPixbuf * | gtk_widget_render_icon ()
GdkPixbuf * | gtk_widget_render_icon_pixbuf ()
void | gtk_widget_pop_composite_child ()
void | gtk_widget_push_composite_child ()
void | gtk_widget_queue_draw_area ()
void | gtk_widget_queue_draw_region ()
void | gtk_widget_set_app_paintable ()
void | gtk_widget_set_double_buffered ()
void | gtk_widget_set_redraw_on_allocate ()
void | gtk_widget_set_composite_name ()
gboolean | gtk_widget_mnemonic_activate ()
void | gtk_widget_class_install_style_property ()
void | gtk_widget_class_install_style_property_parser ()
GParamSpec * | gtk_widget_class_find_style_property ()
GParamSpec ** | gtk_widget_class_list_style_properties ()
cairo_region_t * | gtk_widget_region_intersect ()
gint | gtk_widget_send_expose ()
gboolean | gtk_widget_send_focus_change ()
void | gtk_widget_style_get ()
void | gtk_widget_style_get_property ()
void | gtk_widget_style_get_valist ()
void | gtk_widget_style_attach ()
void | gtk_widget_class_set_accessible_type ()
void | gtk_widget_class_set_accessible_role ()
AtkObject * | gtk_widget_get_accessible ()
gboolean | gtk_widget_child_focus ()
void | gtk_widget_child_notify ()
void | gtk_widget_freeze_child_notify ()
gboolean | gtk_widget_get_child_visible ()
GtkWidget * | gtk_widget_get_parent ()
GtkSettings * | gtk_widget_get_settings ()
GtkClipboard * | gtk_widget_get_clipboard ()
GdkDisplay * | gtk_widget_get_display ()
GdkWindow * | gtk_widget_get_root_window ()
GdkScreen * | gtk_widget_get_screen ()
gboolean | gtk_widget_has_screen ()
void | gtk_widget_get_size_request ()
void | gtk_widget_set_child_visible ()
void | gtk_widget_set_size_request ()
void | gtk_widget_thaw_child_notify ()
void | gtk_widget_set_no_show_all ()
gboolean | gtk_widget_get_no_show_all ()
GList * | gtk_widget_list_mnemonic_labels ()
void | gtk_widget_add_mnemonic_label ()
void | gtk_widget_remove_mnemonic_label ()
gboolean | gtk_widget_is_composited ()
void | gtk_widget_error_bell ()
gboolean | gtk_widget_keynav_failed ()
gchar * | gtk_widget_get_tooltip_markup ()
void | gtk_widget_set_tooltip_markup ()
gchar * | gtk_widget_get_tooltip_text ()
void | gtk_widget_set_tooltip_text ()
GtkWindow * | gtk_widget_get_tooltip_window ()
void | gtk_widget_set_tooltip_window ()
gboolean | gtk_widget_get_has_tooltip ()
void | gtk_widget_set_has_tooltip ()
void | gtk_widget_trigger_tooltip_query ()
GdkWindow * | gtk_widget_get_window ()
void | gtk_widget_register_window ()
void | gtk_widget_unregister_window ()
gboolean | gtk_cairo_should_draw_window ()
void | gtk_cairo_transform_to_window ()
int | gtk_widget_get_allocated_width ()
int | gtk_widget_get_allocated_height ()
void | gtk_widget_get_allocation ()
void | gtk_widget_set_allocation ()
int | gtk_widget_get_allocated_baseline ()
void | gtk_widget_get_allocated_size ()
void | gtk_widget_get_clip ()
void | gtk_widget_set_clip ()
gboolean | gtk_widget_get_app_paintable ()
gboolean | gtk_widget_get_can_default ()
void | gtk_widget_set_can_default ()
gboolean | gtk_widget_get_can_focus ()
void | gtk_widget_set_can_focus ()
gboolean | gtk_widget_get_focus_on_click ()
void | gtk_widget_set_focus_on_click ()
gboolean | gtk_widget_get_double_buffered ()
gboolean | gtk_widget_get_has_window ()
void | gtk_widget_set_has_window ()
gboolean | gtk_widget_get_sensitive ()
gboolean | gtk_widget_is_sensitive ()
GtkStateType | gtk_widget_get_state ()
gboolean | gtk_widget_get_visible ()
gboolean | gtk_widget_is_visible ()
void | gtk_widget_set_visible ()
void | gtk_widget_set_state_flags ()
void | gtk_widget_unset_state_flags ()
GtkStateFlags | gtk_widget_get_state_flags ()
gboolean | gtk_widget_has_default ()
gboolean | gtk_widget_has_focus ()
gboolean | gtk_widget_has_visible_focus ()
gboolean | gtk_widget_has_grab ()
gboolean | gtk_widget_has_rc_style ()
gboolean | gtk_widget_is_drawable ()
gboolean | gtk_widget_is_toplevel ()
void | gtk_widget_set_window ()
void | gtk_widget_set_receives_default ()
gboolean | gtk_widget_get_receives_default ()
void | gtk_widget_set_support_multidevice ()
gboolean | gtk_widget_get_support_multidevice ()
void | gtk_widget_set_realized ()
gboolean | gtk_widget_get_realized ()
void | gtk_widget_set_mapped ()
gboolean | gtk_widget_get_mapped ()
void | gtk_widget_get_requisition ()
gboolean | gtk_widget_device_is_shadowed ()
GdkModifierType | gtk_widget_get_modifier_mask ()
void | gtk_widget_insert_action_group ()
double | gtk_widget_get_opacity ()
void | gtk_widget_set_opacity ()
const gchar ** | gtk_widget_list_action_prefixes ()
GActionGroup * | gtk_widget_get_action_group ()
GtkWidgetPath * | gtk_widget_get_path ()
GtkStyleContext * | gtk_widget_get_style_context ()
void | gtk_widget_reset_style ()
const char * | gtk_widget_class_get_css_name ()
void | gtk_widget_class_set_css_name ()
GtkRequisition * | gtk_requisition_new ()
GtkRequisition * | gtk_requisition_copy ()
void | gtk_requisition_free ()
void | gtk_widget_get_preferred_height ()
void | gtk_widget_get_preferred_width ()
void | gtk_widget_get_preferred_height_for_width ()
void | gtk_widget_get_preferred_width_for_height ()
void | gtk_widget_get_preferred_height_and_baseline_for_width ()
GtkSizeRequestMode | gtk_widget_get_request_mode ()
void | gtk_widget_get_preferred_size ()
gint | gtk_distribute_natural_allocation ()
GtkAlign | gtk_widget_get_halign ()
void | gtk_widget_set_halign ()
GtkAlign | gtk_widget_get_valign ()
GtkAlign | gtk_widget_get_valign_with_baseline ()
void | gtk_widget_set_valign ()
gint | gtk_widget_get_margin_left ()
void | gtk_widget_set_margin_left ()
gint | gtk_widget_get_margin_right ()
void | gtk_widget_set_margin_right ()
gint | gtk_widget_get_margin_start ()
void | gtk_widget_set_margin_start ()
gint | gtk_widget_get_margin_end ()
void | gtk_widget_set_margin_end ()
gint | gtk_widget_get_margin_top ()
void | gtk_widget_set_margin_top ()
gint | gtk_widget_get_margin_bottom ()
void | gtk_widget_set_margin_bottom ()
gboolean | gtk_widget_get_hexpand ()
void | gtk_widget_set_hexpand ()
gboolean | gtk_widget_get_hexpand_set ()
void | gtk_widget_set_hexpand_set ()
gboolean | gtk_widget_get_vexpand ()
void | gtk_widget_set_vexpand ()
gboolean | gtk_widget_get_vexpand_set ()
void | gtk_widget_set_vexpand_set ()
void | gtk_widget_queue_compute_expand ()
gboolean | gtk_widget_compute_expand ()
void | gtk_widget_init_template ()
void | gtk_widget_class_set_template ()
void | gtk_widget_class_set_template_from_resource ()
GObject * | gtk_widget_get_template_child ()
#define | gtk_widget_class_bind_template_child()
#define | gtk_widget_class_bind_template_child_internal()
#define | gtk_widget_class_bind_template_child_private()
#define | gtk_widget_class_bind_template_child_internal_private()
void | gtk_widget_class_bind_template_child_full ()
#define | gtk_widget_class_bind_template_callback()
void | gtk_widget_class_bind_template_callback_full ()
void | gtk_widget_class_set_connect_func ()

## Properties

gboolean | app-paintable | Read / Write
gboolean | can-default | Read / Write
gboolean | can-focus | Read / Write
gboolean | composite-child | Read
gboolean | double-buffered | Read / Write
GdkEventMask | events | Read / Write
gboolean | expand | Read / Write
gboolean | focus-on-click | Read / Write
GtkAlign | halign | Read / Write
gboolean | has-default | Read / Write
gboolean | has-focus | Read / Write
gboolean | has-tooltip | Read / Write
gint | height-request | Read / Write
gboolean | hexpand | Read / Write
gboolean | hexpand-set | Read / Write
gboolean | is-focus | Read / Write
gint | margin | Read / Write
gint | margin-bottom | Read / Write
gint | margin-end | Read / Write
gint | margin-left | Read / Write
gint | margin-right | Read / Write
gint | margin-start | Read / Write
gint | margin-top | Read / Write
gchar * | name | Read / Write
gboolean | no-show-all | Read / Write
gdouble | opacity | Read / Write
GtkContainer * | parent | Read / Write
gboolean | receives-default | Read / Write
gint | scale-factor | Read
gboolean | sensitive | Read / Write
GtkStyle * | style | Read / Write
gchar * | tooltip-markup | Read / Write
gchar * | tooltip-text | Read / Write
GtkAlign | valign | Read / Write
gboolean | vexpand | Read / Write
gboolean | vexpand-set | Read / Write
gboolean | visible | Read / Write
gint | width-request | Read / Write
GdkWindow * | window | Read

## Style Properties

gfloat | cursor-aspect-ratio | Read
GdkColor * | cursor-color | Read
gchar * | focus-line-pattern | Read
gint | focus-line-width | Read
gint | focus-padding | Read
gboolean | interior-focus | Read
GdkColor * | link-color | Read
gint | scroll-arrow-hlength | Read
gint | scroll-arrow-vlength | Read
GdkColor * | secondary-cursor-color | Read
gint | separator-height | Read
gint | separator-width | Read
gint | text-handle-height | Read
gint | text-handle-width | Read
GdkColor * | visited-link-color | Read
gboolean | wide-separators | Read
gboolean | window-dragging | Read

## Signals

void | accel-closures-changed |
gboolean | button-press-event | Run Last
gboolean | button-release-event | Run Last
gboolean | can-activate-accel | Run Last
void | child-notify | No Hooks
void | composited-changed | Action
gboolean | configure-event | Run Last
gboolean | damage-event | Run Last
gboolean | delete-event | Run Last
void | destroy | No Hooks
gboolean | destroy-event | Run Last
void | direction-changed | Run First
void | drag-begin | Run Last
void | drag-data-delete | Run Last
void | drag-data-get | Run Last
void | drag-data-received | Run Last
gboolean | drag-drop | Run Last
void | drag-end | Run Last
gboolean | drag-failed | Run Last
void | drag-leave | Run Last
gboolean | drag-motion | Run Last
gboolean | draw | Run Last
gboolean | enter-notify-event | Run Last
gboolean | event | Run Last
void | event-after |
gboolean | focus | Run Last
gboolean | focus-in-event | Run Last
gboolean | focus-out-event | Run Last
gboolean | grab-broken-event | Run Last
void | grab-focus | Action
void | grab-notify | Run First
void | hide | Run First
void | hierarchy-changed | Run Last
gboolean | key-press-event | Run Last
gboolean | key-release-event | Run Last
gboolean | keynav-failed | Run Last
gboolean | leave-notify-event | Run Last
void | map | Run First
gboolean | map-event | Run Last
gboolean | mnemonic-activate | Run Last
gboolean | motion-notify-event | Run Last
void | move-focus | Action
void | parent-set | Run First
gboolean | popup-menu | Action
gboolean | property-notify-event | Run Last
gboolean | proximity-in-event | Run Last
gboolean | proximity-out-event | Run Last
gboolean | query-tooltip | Run Last
void | realize | Run First
void | screen-changed | Run Last
gboolean | scroll-event | Run Last
gboolean | selection-clear-event | Run Last
void | selection-get | Run Last
gboolean | selection-notify-event | Run Last
void | selection-received | Run Last
gboolean | selection-request-event | Run Last
void | show | Run First
gboolean | show-help | Action
void | size-allocate | Run First
void | state-changed | Run First
void | state-flags-changed | Run First
void | style-set | Run First
void | style-updated | Run First
gboolean | touch-event | Run Last
void | unmap | Run First
gboolean | unmap-event | Run Last
void | unrealize | Run Last
gboolean | visibility-notify-event | Run Last
gboolean | window-state-event | Run Last

## Types and Values

| GtkWidget
struct | GtkWidgetClass
| GtkRequisition
typedef | GtkAllocation
enum | GtkWidgetHelpType
enum | GtkTextDirection
enum | GtkStateType
enum | GtkSizeRequestMode
struct | GtkRequestedSize
enum | GtkAlign

## Object Hierarchy

        GBoxed
        ╰── GtkRequisition
        GObject
        ╰── GInitiallyUnowned
            ╰── GtkWidget
                ├── GtkContainer
                ├── GtkMisc
                ├── GtkCalendar
                ├── GtkCellView
                ├── GtkDrawingArea
                ├── GtkEntry
                ├── GtkGLArea
                ├── GtkRange
                ├── GtkSeparator
                ├── GtkHSV
                ├── GtkInvisible
                ├── GtkProgressBar
                ├── GtkSpinner
                ├── GtkSwitch
                ╰── GtkLevelBar

## Known Derived Interfaces

GtkWidget is required by GtkActionable, GtkAppChooser, GtkCellEditable and GtkToolShell.

## Implemented Interfaces

GtkWidget implements AtkImplementorIface and GtkBuildable.

## Includes

    #include <gtk/gtk.h>

## Description

GtkWidget is the base class all widgets in GTK+ derive from. It manages the widget lifecycle, states and style.

### Height-for-width Geometry Management

GTK+ uses a height-for-width (and width-for-height) geometry management system. Height-for-width means that a widget can change how much vertical space it needs, depending on the amount of horizontal space that it is given (and similar for width-for-height). The most common example is a label that reflows to fill up the available width, wraps to fewer lines, and therefore needs less height.

Height-for-width geometry management is implemented in GTK+ by way of five virtual methods:

- `GtkWidgetClass.get_request_mode()`

- `GtkWidgetClass.get_preferred_width()`

- `GtkWidgetClass.get_preferred_height()`

- `GtkWidgetClass.get_preferred_height_for_width()`

- `GtkWidgetClass.get_preferred_width_for_height()`

- `GtkWidgetClass.get_preferred_height_and_baseline_for_width()`

There are some important things to keep in mind when implementing height-for-width and when using it in container implementations.

The geometry management system will query a widget hierarchy in only one orientation at a time. When widgets are initially queried for their minimum sizes it is generally done in two initial passes in the GtkSizeRequestMode chosen by the toplevel.

For example, when queried in the normal `GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH` mode: First, the default minimum and natural width for each widget in the interface will be computed using `gtk_widget_get_preferred_width()`. Because the preferred widths for each container depend on the preferred widths of their children, this information propagates up the hierarchy, and finally a minimum and natural width is determined for the entire toplevel. Next, the toplevel will use the minimum width to query for the minimum height contextual to that width using `gtk_widget_get_preferred_height_for_width()`, which will also be a highly recursive operation. The minimum height for the minimum width is normally used to set the minimum size constraint on the toplevel (unless `gtk_window_set_geometry_hints()` is explicitly used instead).

After the toplevel window has initially requested its size in both dimensions it can go on to allocate itself a reasonable size (or a size previously specified with `gtk_window_set_default_size()`). During the recursive allocation process it’s important to note that request cycles will be recursively executed while container widgets allocate their children. Each container widget, once allocated a size, will go on to first share the space in one orientation among its children and then request each child's height for its target allocated width or its width for allocated height, depending. In this way a GtkWidget will typically be requested its size a number of times before actually being allocated a size. The size a widget is finally allocated can of course differ from the size it has requested. For this reason, GtkWidget caches a small number of results to avoid re-querying for the same sizes in one allocation cycle.

See GtkContainer’s geometry management section to learn more about how height-for-width allocations are performed by container widgets.

If a widget does move content around to intelligently use up the allocated size then it must support the request in both GtkSizeRequestModes even if the widget in question only trades sizes in a single orientation.

For instance, a GtkLabel that does height-for-width word wrapping will not expect to have `GtkWidgetClass.get_preferred_height()` called because that call is specific to a width-for-height request. In this case the label must return the height required for its own minimum possible width. By following this rule any widget that handles height-for-width or width-for-height requests will always be allocated at least enough space to fit its own content.

Here are some examples of how a `GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH` widget generally deals with width-for-height requests, for `GtkWidgetClass.get_preferred_height()` it will do:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    static void
    foo_widget_get_preferred_height (GtkWidget *widget,
                                     gint *min_height,
                                     gint *nat_height)
    {
       if (i_am_in_height_for_width_mode)
         {
           gint min_width, nat_width;

           GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget,
                                                               &min_width,
                                                               &nat_width);
           GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width
                                                              (widget,
                                                               min_width,
                                                               min_height,
                                                               nat_height);
         }
       else
         {
            ... some widgets do both. For instance, if a GtkLabel is
            rotated to 90 degrees it will return the minimum and
            natural height for the rotated label here.
         }
    }

And in `GtkWidgetClass.get_preferred_width_for_height()` it will simply return the minimum and natural width:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    static void
    foo_widget_get_preferred_width_for_height (GtkWidget *widget,
                                               gint for_height,
                                               gint *min_width,
                                               gint *nat_width)
    {
       if (i_am_in_height_for_width_mode)
         {
           GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget,
                                                               min_width,
                                                               nat_width);
         }
       else
         {
            ... again if a widget is sometimes operating in
            width-for-height mode (like a rotated GtkLabel) it can go
            ahead and do its real width for height calculation here.
         }
    }

Often a widget needs to get its own request during size request or allocation. For example, when computing height it may need to also compute width. Or when deciding how to use an allocation, the widget may need to know its natural size. In these cases, the widget should be careful to call its virtual methods directly, like this:

    1
    2
    3
    GTK_WIDGET_GET_CLASS(widget)->get_preferred_width (widget,
                                                       &min,
                                                       &natural);

It will not work to use the wrapper functions, such as `gtk_widget_get_preferred_width()` inside your own size request implementation. These return a request adjusted by GtkSizeGroup and by the `GtkWidgetClass.adjust_size_request()` virtual method. If a widget used the wrappers inside its virtual method implementations, then the adjustments (such as widget margins) would be applied twice. GTK+ therefore does not allow this and will warn if you try to do it.

Of course if you are getting the size request for another widget, such as a child of a container, you must use the wrapper APIs. Otherwise, you would not properly consider widget margins, GtkSizeGroup, and so forth.

Since 3.10 GTK+ also supports baseline vertical alignment of widgets. This means that widgets are positioned such that the typographical baseline of widgets in the same row are aligned. This happens if a widget supports baselines, has a vertical alignment of `GTK_ALIGN_BASELINE`, and is inside a container that supports baselines and has a natural “row” that it aligns to the baseline, or a baseline assigned to it by the grandparent.

Baseline alignment support for a widget is done by the `GtkWidgetClass.get_preferred_height_and_baseline_for_width()` virtual function. It allows you to report a baseline in combination with the minimum and natural height. If there is no baseline you can return -1 to indicate this. The default implementation of this virtual function calls into the `GtkWidgetClass.get_preferred_height()` and `GtkWidgetClass.get_preferred_height_for_width()`, so if baselines are not supported it doesn’t need to be implemented.

If a widget ends up baseline aligned it will be allocated all the space in the parent as if it was `GTK_ALIGN_FILL`, but the selected baseline can be found via `gtk_widget_get_allocated_baseline()`. If this has a value other than -1 you need to align the widget such that the baseline appears at the position.

### Style Properties

GtkWidget introduces “style properties” - these are basically object properties that are stored not on the object, but in the style object associated to the widget. Style properties are set in resource files. This mechanism is used for configuring such things as the location of the scrollbar arrows through the theme, giving theme authors more control over the look of applications without the need to write a theme engine in C.

Use `gtk_widget_class_install_style_property()` to install style properties for a widget class, `gtk_widget_class_find_style_property()` or `gtk_widget_class_list_style_properties()` to get information about existing style properties and `gtk_widget_style_get_property()`, `gtk_widget_style_get()` or `gtk_widget_style_get_valist()` to obtain the value of a style property.

### GtkWidget as GtkBuildable

The GtkWidget implementation of the GtkBuildable interface supports a custom <accelerator> element, which has attributes named ”key”, ”modifiers” and ”signal” and allows to specify accelerators.

An example of a UI definition fragment specifying an accelerator:

    1
    2
    3
    <object class="GtkButton">
      <accelerator key="q" modifiers="GDK_CONTROL_MASK" signal="clicked"/>
    </object>

In addition to accelerators, GtkWidget also support a custom <accessible> element, which supports actions and relations. Properties on the accessible implementation of an object can be set by accessing the internal child “accessible” of a GtkWidget.

An example of a UI definition fragment specifying an accessible:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <object class="GtkButton" id="label1"/>
      <property name="label">I am a Label for a Button</property>
    </object>
    <object class="GtkButton" id="button1">
      <accessibility>
        <action action_name="click" translatable="yes">Click the button.</action>
        <relation target="label1" type="labelled-by"/>
      </accessibility>
      <child internal-child="accessible">
        <object class="AtkObject" id="a11y-button1">
          <property name="accessible-name">Clickable Button</property>
        </object>
      </child>
    </object>

Finally, GtkWidget allows style information such as style classes to be associated with widgets, using the custom <style> element:

    1
    2
    3
    4
    5
    6
    <object class="GtkButton" id="button1">
      <style>
        <class name="my-special-button-class"/>
        <class name="dark-button"/>
      </style>
    </object>

### Building composite widgets from template XML

GtkWidget exposes some facilities to automate the procedure of creating composite widgets using GtkBuilder interface description language.

To create composite widgets with GtkBuilder XML, one must associate the interface description with the widget class at class initialization time using `gtk_widget_class_set_template()`.

The interface description semantics expected in composite template descriptions is slightly different from regular GtkBuilder XML.

Unlike regular interface descriptions, `gtk_widget_class_set_template()` will expect a <template> tag as a direct child of the toplevel <interface> tag. The <template> tag must specify the “class” attribute which must be the type name of the widget. Optionally, the “parent” attribute may be specified to specify the direct parent type of the widget type, this is ignored by the GtkBuilder but required for Glade to introspect what kind of properties and internal children exist for a given type when the actual type does not exist.

The XML which is contained inside the <template> tag behaves as if it were added to the <object> tag defining `widget` itself. You may set properties on `widget` by inserting <property> tags into the <template> tag, and also add <child> tags to add children and extend `widget` in the normal way you would with <object> tags.

Additionally, <object> tags can also be added before and after the initial <template> tag in the normal way, allowing one to define auxiliary objects which might be referenced by other widgets declared as children of the <template> tag.

An example of a GtkBuilder Template Definition:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    <interface>
      <template class="FooWidget" parent="GtkBox">
        <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
        <property name="spacing">4</property>
        <child>
          <object class="GtkButton" id="hello_button">
            <property name="label">Hello World</property>
            <signal name="clicked" handler="hello_button_clicked" object="FooWidget" swapped="yes"/>
          </object>
        </child>
        <child>
          <object class="GtkButton" id="goodbye_button">
            <property name="label">Goodbye World</property>
          </object>
        </child>
      </template>
    </interface>

Typically, you'll place the template fragment into a file that is bundled with your project, using GResource. In order to load the template, you need to call `gtk_widget_class_set_template_from_resource()` from the class initialization of your GtkWidget type:

    1
    2
    3
    4
    5
    6
    7
    8
    static void
    foo_widget_class_init (FooWidgetClass *klass)
    {
      // ...

      gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
                                                   "/com/example/ui/foowidget.ui");
    }

You will also need to call `gtk_widget_init_template()` from the instance initialization function:

    1
    2
    3
    4
    5
    6
    static void
    foo_widget_init (FooWidget *self)
    {
      // ...
      gtk_widget_init_template (GTK_WIDGET (self));
    }

You can access widgets defined in the template using the `gtk_widget_get_template_child()` function, but you will typically declare a pointer in the instance private data structure of your type using the same name as the widget in the template definition, and call `gtk_widget_class_bind_template_child_private()` with that name, e.g.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    typedef struct {
      GtkWidget *hello_button;
      GtkWidget *goodbye_button;
    } FooWidgetPrivate;

    G_DEFINE_TYPE_WITH_PRIVATE (FooWidget, foo_widget, GTK_TYPE_BOX)

    static void
    foo_widget_class_init (FooWidgetClass *klass)
    {
      // ...
      gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
                                                   "/com/example/ui/foowidget.ui");
      gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
                                                    FooWidget, hello_button);
      gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
                                                    FooWidget, goodbye_button);
    }

You can also use `gtk_widget_class_bind_template_callback()` to connect a signal callback defined in the template with a function visible in the scope of the class, e.g.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    // the signal handler has the instance and user data swapped
    // because of the swapped="yes" attribute in the template XML
    static void
    hello_button_clicked (FooWidget *self,
                          GtkButton *button)
    {
      g_print ("Hello, world!\n");
    }

    static void
    foo_widget_class_init (FooWidgetClass *klass)
    {
      // ...
      gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
                                                   "/com/example/ui/foowidget.ui");
      gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), hello_button_clicked);
    }

## Functions

### GtkCallback ()

    void
    (*GtkCallback) (GtkWidget *widget,
                    gpointer data);

The type of the callback functions used for e.g. iterating over the children of a container, see `gtk_container_foreach()`.

#### Parameters

widget | the widget to operate on |
data | user-supplied data. | [closure]

### gtk_widget_new ()

    GtkWidget *
    gtk_widget_new (GType type,
                    const gchar *first_property_name,
                    ...);

This is a convenience function for creating a widget and setting its properties in one go. For example you might write: `gtk_widget_new (GTK_TYPE_LABEL, "label", "Hello World", "xalign", 0.0, NULL)` to create a left-aligned label. Equivalent to `g_object_new()`, but returns a widget so you don’t have to cast the object yourself.

#### Parameters

type | type ID of the widget to create |
first_property_name | name of first property to set |
... | value of first property, followed by more properties, `NULL`-terminated |

#### Returns

a new GtkWidget of type `widget_type`

### gtk_widget_destroy ()

    void
    gtk_widget_destroy (GtkWidget *widget);

Destroys a widget.

When a widget is destroyed all references it holds on other objects will be released:

- if the widget is inside a container, it will be removed from its parent

- if the widget is a container, all its children will be destroyed, recursively

- if the widget is a top level, it will be removed from the list of top level widgets that GTK+ maintains internally

It's expected that all references held on the widget will also be released; you should connect to the “destroy” signal if you hold a reference to `widget` and you wish to remove it when this function is called. It is not necessary to do so if you are implementing a GtkContainer, as you'll be able to use the `GtkContainerClass.remove()` virtual function for that.

It's important to notice that `gtk_widget_destroy()` will only cause the `widget` to be finalized if no additional references, acquired using `g_object_ref()`, are held on it. In case additional references are in place, the `widget` will be in an "inert" state after calling this function; `widget` will still point to valid memory, allowing you to release the references you hold, but you may not query the widget's own state.

You should typically call this function on top level widgets, and rarely on child widgets.

See also: `gtk_container_remove()`

#### Parameters

widget | a GtkWidget |

### gtk_widget_in_destruction ()

    gboolean
    gtk_widget_in_destruction (GtkWidget *widget);

Returns whether the widget is currently being destroyed. This information can sometimes be used to avoid doing unnecessary work.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if `widget` is being destroyed

### gtk_widget_destroyed ()

    void
    gtk_widget_destroyed (GtkWidget *widget,
                          GtkWidget **widget_pointer);

This function sets *`widget_pointer` to `NULL` if `widget_pointer` != `NULL`. It’s intended to be used as a callback connected to the “destroy” signal of a widget. You connect `gtk_widget_destroyed()` as a signal handler, and pass the address of your widget variable as user data. Then when the widget is destroyed, the variable will be set to `NULL`. Useful for example to avoid multiple copies of the same dialog.

#### Parameters

widget | a GtkWidget |
widget_pointer | address of a variable that contains `widget` . | [inout][transfer none]

### gtk_widget_unparent ()

    void
    gtk_widget_unparent (GtkWidget *widget);

This function is only for use in widget implementations. Should be called by implementations of the remove method on GtkContainer, to dissociate a child from the container.

#### Parameters

widget | a GtkWidget |

### gtk_widget_show ()

    void
    gtk_widget_show (GtkWidget *widget);

Flags a widget to be displayed. Any widget that isn’t shown will not appear on the screen. If you want to show all the widgets in a container, it’s easier to call `gtk_widget_show_all()` on the container, instead of individually showing the widgets.

Remember that you have to show the containers containing a widget, in addition to the widget itself, before it will appear onscreen.

When a toplevel container is shown, it is immediately realized and mapped; other shown widgets are realized and mapped when their toplevel container is realized and mapped.

#### Parameters

widget | a GtkWidget |

### gtk_widget_show_now ()

    void
    gtk_widget_show_now (GtkWidget *widget);

Shows a widget. If the widget is an unmapped toplevel widget (i.e. a GtkWindow that has not yet been shown), enter the main loop and wait for the window to actually be mapped. Be careful; because the main loop is running, anything can happen during this function.

#### Parameters

widget | a GtkWidget |

### gtk_widget_hide ()

    void
    gtk_widget_hide (GtkWidget *widget);

Reverses the effects of `gtk_widget_show()`, causing the widget to be hidden (invisible to the user).

#### Parameters

widget | a GtkWidget |

### gtk_widget_show_all ()

    void
    gtk_widget_show_all (GtkWidget *widget);

Recursively shows a widget, and any child widgets (if the widget is a container).

#### Parameters

widget | a GtkWidget |

### gtk_widget_map ()

    void
    gtk_widget_map (GtkWidget *widget);

This function is only for use in widget implementations. Causes a widget to be mapped if it isn’t already.

#### Parameters

widget | a GtkWidget |

### gtk_widget_unmap ()

    void
    gtk_widget_unmap (GtkWidget *widget);

This function is only for use in widget implementations. Causes a widget to be unmapped if it’s currently mapped.

#### Parameters

widget | a GtkWidget |

### gtk_widget_realize ()

    void
    gtk_widget_realize (GtkWidget *widget);

Creates the GDK (windowing system) resources associated with a widget. For example, `widget->window` will be created when a widget is realized. Normally realization happens implicitly; if you show a widget and all its parent containers, then the widget will be realized and mapped automatically.

Realizing a widget requires all the widget’s parent widgets to be realized; calling `gtk_widget_realize()` realizes the widget’s parents in addition to `widget` itself. If a widget is not yet inside a toplevel window when you realize it, bad things will happen.

This function is primarily used in widget implementations, and isn’t very useful otherwise. Many times when you think you might need it, a better approach is to connect to a signal that will be called after the widget is realized automatically, such as “draw”. Or simply `g_signal_connect()` to the “realize” signal.

#### Parameters

widget | a GtkWidget |

### gtk_widget_unrealize ()

    void
    gtk_widget_unrealize (GtkWidget *widget);

This function is only useful in widget implementations. Causes a widget to be unrealized (frees all GDK resources associated with the widget, such as `widget->window` ).

#### Parameters

widget | a GtkWidget |

### gtk_widget_draw ()

    void
    gtk_widget_draw (GtkWidget *widget,
                     cairo_t *cr);

Draws `widget` to `cr` . The top left corner of the widget will be drawn to the currently set origin point of `cr` .

You should pass a cairo context as `cr` argument that is in an original state. Otherwise the resulting drawing is undefined. For example changing the operator using `cairo_set_operator()` or the line width using `cairo_set_line_width()` might have unwanted side effects. You may however change the context’s transform matrix - like with `cairo_scale()`, `cairo_translate()` or `cairo_set_matrix()` and clip region with `cairo_clip()` prior to calling this function. Also, it is fine to modify the context with `cairo_save()` and `cairo_push_group()` prior to calling this function.

Note that special-purpose widgets may contain special code for rendering to the screen and might appear differently on screen and when rendered using `gtk_widget_draw()`.

#### Parameters

widget | the widget to draw. It must be drawable (see `gtk_widget_is_drawable()`) and a size must have been allocated. |
cr | a cairo context to draw to |

Since: 3.0

### gtk_widget_queue_draw ()

    void
    gtk_widget_queue_draw (GtkWidget *widget);

Equivalent to calling `gtk_widget_queue_draw_area()` for the entire area of a widget.

#### Parameters

widget | a GtkWidget |

### gtk_widget_queue_resize ()

    void
    gtk_widget_queue_resize (GtkWidget *widget);

This function is only for use in widget implementations. Flags a widget to have its size renegotiated; should be called when a widget for some reason has a new size request. For example, when you change the text in a GtkLabel, GtkLabel queues a resize to ensure there’s enough space for the new text.

Note that you cannot call `gtk_widget_queue_resize()` on a widget from inside its implementation of the GtkWidgetClass::size_allocate virtual method. Calls to `gtk_widget_queue_resize()` from inside GtkWidgetClass::size_allocate will be silently ignored.

#### Parameters

widget | a GtkWidget |

### gtk_widget_queue_resize_no_redraw ()

    void
    gtk_widget_queue_resize_no_redraw (GtkWidget *widget);

This function works like `gtk_widget_queue_resize()`, except that the widget is not invalidated.

#### Parameters

widget | a GtkWidget |

Since: 2.4

### gtk_widget_queue_allocate ()

    void
    gtk_widget_queue_allocate (GtkWidget *widget);

This function is only for use in widget implementations.

Flags the widget for a rerun of the GtkWidgetClass::size_allocate function. Use this function instead of `gtk_widget_queue_resize()` when the `widget` 's size request didn't change but it wants to reposition its contents.

An example user of this function is `gtk_widget_set_halign()`.

#### Parameters

widget | a GtkWidget |

Since: 3.20

### gtk_widget_get_frame_clock ()

    GdkFrameClock *
    gtk_widget_get_frame_clock (GtkWidget *widget);

Obtains the frame clock for a widget. The frame clock is a global “ticker” that can be used to drive animations and repaints. The most common reason to get the frame clock is to call `gdk_frame_clock_get_frame_time()`, in order to get a time to use for animating. For example you might record the start of the animation with an initial value from `gdk_frame_clock_get_frame_time()`, and then update the animation by calling `gdk_frame_clock_get_frame_time()` again during each repaint.

gdk_frame_clock_request_phase() will result in a new frame on the clock, but won’t necessarily repaint any widgets. To repaint a widget, you have to use `gtk_widget_queue_draw()` which invalidates the widget (thus scheduling it to receive a draw on the next frame). `gtk_widget_queue_draw()` will also end up requesting a frame on the appropriate frame clock.

A widget’s frame clock will not change while the widget is mapped. Reparenting a widget (which implies a temporary unmap) can change the widget’s frame clock.

Unrealized widgets do not have a frame clock.

#### Parameters

widget | a GtkWidget |

#### Returns

a GdkFrameClock, or NULL if widget is unrealized.

[nullable][transfer none]

Since: 3.8

### gtk_widget_get_scale_factor ()

    gint
    gtk_widget_get_scale_factor (GtkWidget *widget);

Retrieves the internal scale factor that maps from window coordinates to the actual device pixels. On traditional systems this is 1, on high density outputs, it can be a higher value (typically 2).

See `gdk_window_get_scale_factor()`.

#### Parameters

widget | a GtkWidget |

#### Returns

the scale factor for `widget`

Since: 3.10

### GtkTickCallback ()

    gboolean
    (*GtkTickCallback) (GtkWidget *widget,
                        GdkFrameClock *frame_clock,
                        gpointer user_data);

Callback type for adding a function to update animations. See `gtk_widget_add_tick_callback()`.

#### Parameters

widget | the widget |
frame_clock | the frame clock for the widget (same as calling `gtk_widget_get_frame_clock()`) |
user_data | user data passed to `gtk_widget_add_tick_callback()`. |

#### Returns

`G_SOURCE_CONTINUE` if the tick callback should continue to be called, `G_SOURCE_REMOVE` if the tick callback should be removed.

Since: 3.8

### gtk_widget_add_tick_callback ()

    guint
    gtk_widget_add_tick_callback (GtkWidget *widget,
                                  GtkTickCallback callback,
                                  gpointer user_data,
                                  GDestroyNotify notify);

Queues an animation frame update and adds a callback to be called before each frame. Until the tick callback is removed, it will be called frequently (usually at the frame rate of the output device or as quickly as the application can be repainted, whichever is slower). For this reason, is most suitable for handling graphics that change every frame or every few frames. The tick callback does not automatically imply a relayout or repaint. If you want a repaint or relayout, and aren’t changing widget properties that would trigger that (for example, changing the text of a GtkLabel), then you will have to call `gtk_widget_queue_resize()` or `gtk_widget_queue_draw_area()` yourself.

gdk_frame_clock_get_frame_time() should generally be used for timing continuous animations and `gdk_frame_timings_get_predicted_presentation_time()` if you are trying to display isolated frames at particular times.

This is a more convenient alternative to connecting directly to the “update” signal of GdkFrameClock, since you don't have to worry about when a GdkFrameClock is assigned to a widget.

#### Parameters

widget | a GtkWidget |
callback | function to call for updating animations |
user_data | data to pass to `callback` |
notify | function to call to free `user_data` when the callback is removed. |

#### Returns

an id for the connection of this callback. Remove the callback by passing it to `gtk_widget_remove_tick_callback()`

Since: 3.8

### gtk_widget_remove_tick_callback ()

    void
    gtk_widget_remove_tick_callback (GtkWidget *widget,
                                     guint id);

Removes a tick callback previously registered with `gtk_widget_add_tick_callback()`.

#### Parameters

widget | a GtkWidget |
id | an id returned by `gtk_widget_add_tick_callback()` |

Since: 3.8

### gtk_widget_size_request ()

    void
    gtk_widget_size_request (GtkWidget *widget,
                             GtkRequisition *requisition);

`gtk_widget_size_request` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gtk_widget_get_preferred_size()` instead.

This function is typically used when implementing a GtkContainer subclass. Obtains the preferred size of a widget. The container uses this information to arrange its child widgets and decide what size allocations to give them with `gtk_widget_size_allocate()`.

You can also call this function from an application, with some caveats. Most notably, getting a size request requires the widget to be associated with a screen, because font information may be needed. Multihead-aware applications should keep this in mind.

Also remember that the size request is not necessarily the size a widget will actually be allocated.

#### Parameters

widget | a GtkWidget |
requisition | a GtkRequisition to be filled in. | [out]

### gtk_widget_get_child_requisition ()

    void
    gtk_widget_get_child_requisition (GtkWidget *widget,
                                      GtkRequisition *requisition);

`gtk_widget_get_child_requisition` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gtk_widget_get_preferred_size()` instead.

This function is only for use in widget implementations. Obtains `widget->requisition` , unless someone has forced a particular geometry on the widget (e.g. with `gtk_widget_set_size_request()`), in which case it returns that geometry instead of the widget's requisition.

This function differs from `gtk_widget_size_request()` in that it retrieves the last size request value from `widget->requisition` , while `gtk_widget_size_request()` actually calls the "size_request" method on `widget` to compute the size request and fill in `widget->requisition` , and only then returns `widget->requisition` .

Because this function does not call the “size_request” method, it can only be used when you know that `widget->requisition` is up-to-date, that is, `gtk_widget_size_request()` has been called since the last time a resize was queued. In general, only container implementations have this information; applications should use `gtk_widget_size_request()`.

#### Parameters

widget | a GtkWidget |
requisition | a GtkRequisition to be filled in. | [out]

### gtk_widget_size_allocate ()

    void
    gtk_widget_size_allocate (GtkWidget *widget,
                              GtkAllocation *allocation);

This function is only used by GtkContainer subclasses, to assign a size and position to their child widgets.

In this function, the allocation may be adjusted. It will be forced to a 1x1 minimum size, and the adjust_size_allocation virtual method on the child will be used to adjust the allocation. Standard adjustments include removing the widget’s margins, and applying the widget’s “halign” and “valign” properties.

For baseline support in containers you need to use `gtk_widget_size_allocate_with_baseline()` instead.

#### Parameters

widget | a GtkWidget |
allocation | position and size to be allocated to `widget` |

### gtk_widget_size_allocate_with_baseline ()

    void
    gtk_widget_size_allocate_with_baseline
                                   (GtkWidget *widget,
                                    GtkAllocation *allocation,
                                    gint baseline);

This function is only used by GtkContainer subclasses, to assign a size, position and (optionally) baseline to their child widgets.

In this function, the allocation and baseline may be adjusted. It will be forced to a 1x1 minimum size, and the adjust_size_allocation virtual and adjust_baseline_allocation methods on the child will be used to adjust the allocation and baseline. Standard adjustments include removing the widget's margins, and applying the widget’s “halign” and “valign” properties.

If the child widget does not have a valign of `GTK_ALIGN_BASELINE` the baseline argument is ignored and -1 is used instead.

#### Parameters

widget | a GtkWidget |
allocation | position and size to be allocated to `widget` |
baseline | The baseline of the child, or -1 |

Since: 3.10

### gtk_widget_add_accelerator ()

    void
    gtk_widget_add_accelerator (GtkWidget *widget,
                                const gchar *accel_signal,
                                GtkAccelGroup *accel_group,
                                guint accel_key,
                                GdkModifierType accel_mods,
                                GtkAccelFlags accel_flags);

Installs an accelerator for this `widget` in `accel_group` that causes `accel_signal` to be emitted if the accelerator is activated. The `accel_group` needs to be added to the widget’s toplevel via `gtk_window_add_accel_group()`, and the signal must be of type `G_SIGNAL_ACTION`. Accelerators added through this function are not user changeable during runtime. If you want to support accelerators that can be changed by the user, use `gtk_accel_map_add_entry()` and `gtk_widget_set_accel_path()` or `gtk_menu_item_set_accel_path()` instead.

#### Parameters

widget | widget to install an accelerator on |
accel_signal | widget signal to emit on accelerator activation |
accel_group | accel group for this widget, added to its toplevel |
accel_key | GDK keyval of the accelerator |
accel_mods | modifier key combination of the accelerator |
accel_flags | flag accelerators, e.g. `GTK_ACCEL_VISIBLE` |

### gtk_widget_remove_accelerator ()

    gboolean
    gtk_widget_remove_accelerator (GtkWidget *widget,
                                   GtkAccelGroup *accel_group,
                                   guint accel_key,
                                   GdkModifierType accel_mods);

Removes an accelerator from `widget` , previously installed with `gtk_widget_add_accelerator()`.

#### Parameters

widget | widget to install an accelerator on |
accel_group | accel group for this widget |
accel_key | GDK keyval of the accelerator |
accel_mods | modifier key combination of the accelerator |

#### Returns

whether an accelerator was installed and could be removed

### gtk_widget_set_accel_path ()

    void
    gtk_widget_set_accel_path (GtkWidget *widget,
                               const gchar *accel_path,
                               GtkAccelGroup *accel_group);

Given an accelerator group, `accel_group` , and an accelerator path, `accel_path` , sets up an accelerator in `accel_group` so whenever the key binding that is defined for `accel_path` is pressed, `widget` will be activated. This removes any accelerators (for any accelerator group) installed by previous calls to `gtk_widget_set_accel_path()`. Associating accelerators with paths allows them to be modified by the user and the modifications to be saved for future use. (See `gtk_accel_map_save()`.)

This function is a low level function that would most likely be used by a menu creation system like GtkUIManager. If you use GtkUIManager, setting up accelerator paths will be done automatically.

Even when you you aren’t using GtkUIManager, if you only want to set up accelerators on menu items `gtk_menu_item_set_accel_path()` provides a somewhat more convenient interface.

Note that `accel_path` string will be stored in a GQuark. Therefore, if you pass a static string, you can save some memory by interning it first with `g_intern_static_string()`.

#### Parameters

widget | a GtkWidget |
accel_path | path used to look up the accelerator. | [allow-none]
accel_group | a GtkAccelGroup. | [allow-none]

### gtk_widget_list_accel_closures ()

    GList *
    gtk_widget_list_accel_closures (GtkWidget *widget);

Lists the closures used by `widget` for accelerator group connections with `gtk_accel_group_connect_by_path()` or `gtk_accel_group_connect()`. The closures can be used to monitor accelerator changes on `widget` , by connecting to the `GtkAccelGroup` ::accel-changed signal of the GtkAccelGroup of a closure which can be found out with `gtk_accel_group_from_accel_closure()`.

#### Parameters

widget | widget to list accelerator closures for |

#### Returns

a newly allocated GList of closures.

[transfer container][element-type GClosure]

### gtk_widget_can_activate_accel ()

    gboolean
    gtk_widget_can_activate_accel (GtkWidget *widget,
                                   guint signal_id);

Determines whether an accelerator that activates the signal identified by `signal_id` can currently be activated. This is done by emitting the “can-activate-accel” signal on `widget` ; if the signal isn’t overridden by a handler or in a derived widget, then the default check is that the widget must be sensitive, and the widget and all its ancestors mapped.

#### Parameters

widget | a GtkWidget |
signal_id | the ID of a signal installed on `widget` |

#### Returns

`TRUE` if the accelerator can be activated.

Since: 2.4

### gtk_widget_event ()

    gboolean
    gtk_widget_event (GtkWidget *widget,
                      GdkEvent *event);

Rarely-used function. This function is used to emit the event signals on a widget (those signals should never be emitted without using this function to do so). If you want to synthesize an event though, don’t use this function; instead, use `gtk_main_do_event()` so the event will behave as if it were in the event queue. Don’t synthesize expose events; instead, use `gdk_window_invalidate_rect()` to invalidate a region of the window.

#### Parameters

widget | a GtkWidget |
event | a GdkEvent |

#### Returns

return from the event signal emission (`TRUE` if the event was handled)

### gtk_widget_activate ()

    gboolean
    gtk_widget_activate (GtkWidget *widget);

For widgets that can be “activated” (buttons, menu items, etc.) this function activates them. Activation is what happens when you press Enter on a widget during key navigation. If `widget` isn't activatable, the function returns `FALSE`.

#### Parameters

widget | a GtkWidget that’s activatable |

#### Returns

`TRUE` if the widget was activatable

### gtk_widget_reparent ()

    void
    gtk_widget_reparent (GtkWidget *widget,
                         GtkWidget *new_parent);

`gtk_widget_reparent` has been deprecated since version 3.14 and should not be used in newly-written code.

Use `gtk_container_remove()` and `gtk_container_add()`.

Moves a widget from one GtkContainer to another, handling reference count issues to avoid destroying the widget.

#### Parameters

widget | a GtkWidget |
new_parent | a GtkContainer to move the widget into |

### gtk_widget_intersect ()

    gboolean
    gtk_widget_intersect (GtkWidget *widget,
                          const GdkRectangle *area,
                          GdkRectangle *intersection);

Computes the intersection of a `widget` ’s area and `area` , storing the intersection in `intersection` , and returns `TRUE` if there was an intersection. `intersection` may be `NULL` if you’re only interested in whether there was an intersection.

#### Parameters

widget | a GtkWidget |
area | a rectangle |
intersection | rectangle to store intersection of `widget` and `area` . | [out caller-allocates][optional]

#### Returns

`TRUE` if there was an intersection

### gtk_widget_is_focus ()

    gboolean
    gtk_widget_is_focus (GtkWidget *widget);

Determines if the widget is the focus widget within its toplevel. (This does not mean that the “has-focus” property is necessarily set; “has-focus” will only be set if the toplevel widget additionally has the global input focus.)

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget is the focus widget.

### gtk_widget_grab_focus ()

    void
    gtk_widget_grab_focus (GtkWidget *widget);

Causes `widget` to have the keyboard focus for the GtkWindow it's inside. `widget` must be a focusable widget, such as a GtkEntry; something like GtkFrame won’t work.

More precisely, it must have the `GTK_CAN_FOCUS` flag set. Use `gtk_widget_set_can_focus()` to modify that flag.

The widget also needs to be realized and mapped. This is indicated by the related signals. Grabbing the focus immediately after creating the widget will likely fail and cause critical warnings.

#### Parameters

widget | a GtkWidget |

### gtk_widget_grab_default ()

    void
    gtk_widget_grab_default (GtkWidget *widget);

Causes `widget` to become the default widget. `widget` must be able to be a default widget; typically you would ensure this yourself by calling `gtk_widget_set_can_default()` with a `TRUE` value. The default widget is activated when the user presses Enter in a window. Default widgets must be activatable, that is, `gtk_widget_activate()` should affect them. Note that GtkEntry widgets require the “activates-default” property set to `TRUE` before they activate the default widget when Enter is pressed and the GtkEntry is focused.

#### Parameters

widget | a GtkWidget |

### gtk_widget_set_name ()

    void
    gtk_widget_set_name (GtkWidget *widget,
                         const gchar *name);

Widgets can be named, which allows you to refer to them from a CSS file. You can apply a style to widgets with a particular name in the CSS file. See the documentation for the CSS syntax (on the same page as the docs for GtkStyleContext).

Note that the CSS syntax has certain special characters to delimit and represent elements in a selector (period, #, >, *...), so using these will make your widget impossible to match by name. Any combination of alphanumeric symbols, dashes and underscores will suffice.

#### Parameters

widget | a GtkWidget |
name | name for the widget |

### gtk_widget_get_name ()

    const gchar *
    gtk_widget_get_name (GtkWidget *widget);

Retrieves the name of a widget. See `gtk_widget_set_name()` for the significance of widget names.

#### Parameters

widget | a GtkWidget |

#### Returns

name of the widget. This string is owned by GTK+ and should not be modified or freed

### gtk_widget_set_state ()

    void
    gtk_widget_set_state (GtkWidget *widget,
                          GtkStateType state);

`gtk_widget_set_state` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gtk_widget_set_state_flags()` instead.

This function is for use in widget implementations. Sets the state of a widget (insensitive, prelighted, etc.) Usually you should set the state using wrapper functions such as `gtk_widget_set_sensitive()`.

#### Parameters

widget | a GtkWidget |
state | new state for `widget` |

### gtk_widget_set_sensitive ()

    void
    gtk_widget_set_sensitive (GtkWidget *widget,
                              gboolean sensitive);

Sets the sensitivity of a widget. A widget is sensitive if the user can interact with it. Insensitive widgets are “grayed out” and the user can’t interact with them. Insensitive widgets are known as “inactive”, “disabled”, or “ghosted” in some other toolkits.

#### Parameters

widget | a GtkWidget |
sensitive | `TRUE` to make the widget sensitive |

### gtk_widget_set_parent ()

    void
    gtk_widget_set_parent (GtkWidget *widget,
                           GtkWidget *parent);

This function is useful only when implementing subclasses of GtkContainer. Sets the container as the parent of `widget` , and takes care of some details such as updating the state and style of the child to reflect its new location. The opposite function is `gtk_widget_unparent()`.

#### Parameters

widget | a GtkWidget |
parent | parent container |

### gtk_widget_set_parent_window ()

    void
    gtk_widget_set_parent_window (GtkWidget *widget,
                                  GdkWindow *parent_window);

Sets a non default parent window for `widget` .

For GtkWindow classes, setting a `parent_window` effects whether the window is a toplevel window or can be embedded into other widgets.

For GtkWindow classes, this needs to be called before the window is realized.

#### Parameters

widget | a GtkWidget. |
parent_window | the new parent window. |

### gtk_widget_get_parent_window ()

    GdkWindow *
    gtk_widget_get_parent_window (GtkWidget *widget);

Gets `widget` ’s parent window.

#### Parameters

widget | a GtkWidget. |

#### Returns

the parent window of `widget` .

[transfer none]

### gtk_widget_set_events ()

    void
    gtk_widget_set_events (GtkWidget *widget,
                           gint events);

Sets the event mask (see GdkEventMask) for a widget. The event mask determines which events a widget will receive. Keep in mind that different widgets have different default event masks, and by changing the event mask you may disrupt a widget’s functionality, so be careful. This function must be called while a widget is unrealized. Consider `gtk_widget_add_events()` for widgets that are already realized, or if you want to preserve the existing event mask. This function can’t be used with widgets that have no window. (See `gtk_widget_get_has_window()`). To get events on those widgets, place them inside a GtkEventBox and receive events on the event box.

#### Parameters

widget | a GtkWidget |
events | event mask |

### gtk_widget_get_events ()

    gint
    gtk_widget_get_events (GtkWidget *widget);

Returns the event mask (see GdkEventMask) for the widget. These are the events that the widget will receive.

Note: Internally, the widget event mask will be the logical OR of the event mask set through `gtk_widget_set_events()` or `gtk_widget_add_events()`, and the event mask necessary to cater for every GtkEventController created for the widget.

#### Parameters

widget | a GtkWidget |

#### Returns

event mask for `widget`

### gtk_widget_add_events ()

    void
    gtk_widget_add_events (GtkWidget *widget,
                           gint events);

Adds the events in the bitfield `events` to the event mask for `widget` . See `gtk_widget_set_events()` and the input handling overview for details.

#### Parameters

widget | a GtkWidget |
events | an event mask, see GdkEventMask |

### gtk_widget_set_device_events ()

    void
    gtk_widget_set_device_events (GtkWidget *widget,
                                  GdkDevice *device,
                                  GdkEventMask events);

Sets the device event mask (see GdkEventMask) for a widget. The event mask determines which events a widget will receive from `device` . Keep in mind that different widgets have different default event masks, and by changing the event mask you may disrupt a widget’s functionality, so be careful. This function must be called while a widget is unrealized. Consider `gtk_widget_add_device_events()` for widgets that are already realized, or if you want to preserve the existing event mask. This function can’t be used with windowless widgets (which return `FALSE` from `gtk_widget_get_has_window()`); to get events on those widgets, place them inside a GtkEventBox and receive events on the event box.

#### Parameters

widget | a GtkWidget |
device | a GdkDevice |
events | event mask |

Since: 3.0

### gtk_widget_get_device_events ()

    GdkEventMask
    gtk_widget_get_device_events (GtkWidget *widget,
                                  GdkDevice *device);

Returns the events mask for the widget corresponding to an specific device. These are the events that the widget will receive when `device` operates on it.

#### Parameters

widget | a GtkWidget |
device | a GdkDevice |

#### Returns

device event mask for `widget`

Since: 3.0

### gtk_widget_add_device_events ()

    void
    gtk_widget_add_device_events (GtkWidget *widget,
                                  GdkDevice *device,
                                  GdkEventMask events);

Adds the device events in the bitfield `events` to the event mask for `widget` . See `gtk_widget_set_device_events()` for details.

#### Parameters

widget | a GtkWidget |
device | a GdkDevice |
events | an event mask, see GdkEventMask |

Since: 3.0

### gtk_widget_set_device_enabled ()

    void
    gtk_widget_set_device_enabled (GtkWidget *widget,
                                   GdkDevice *device,
                                   gboolean enabled);

Enables or disables a GdkDevice to interact with `widget` and all its children.

It does so by descending through the GdkWindow hierarchy and enabling the same mask that is has for core events (i.e. the one that `gdk_window_get_events()` returns).

#### Parameters

widget | a GtkWidget |
device | a GdkDevice |
enabled | whether to enable the device |

Since: 3.0

### gtk_widget_get_device_enabled ()

    gboolean
    gtk_widget_get_device_enabled (GtkWidget *widget,
                                   GdkDevice *device);

Returns whether `device` can interact with `widget` and its children. See `gtk_widget_set_device_enabled()`.

#### Parameters

widget | a GtkWidget |
device | a GdkDevice |

#### Returns

`TRUE` is `device` is enabled for `widget`

Since: 3.0

### gtk_widget_get_toplevel ()

    GtkWidget *
    gtk_widget_get_toplevel (GtkWidget *widget);

This function returns the topmost widget in the container hierarchy `widget` is a part of. If `widget` has no parent widgets, it will be returned as the topmost widget. No reference will be added to the returned widget; it should not be unreferenced.

Note the difference in behavior vs. `gtk_widget_get_ancestor()`; `gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW)` would return `NULL` if `widget` wasn’t inside a toplevel window, and if the window was inside a GtkWindow-derived widget which was in turn inside the toplevel GtkWindow. While the second case may seem unlikely, it actually happens when a GtkPlug is embedded inside a GtkSocket within the same application.

To reliably find the toplevel GtkWindow, use `gtk_widget_get_toplevel()` and call `gtk_widget_is_toplevel()` on the result.

    1
    2
    3
    4
    5
    GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
    if (gtk_widget_is_toplevel (toplevel))
      {
        // Perform action on toplevel.
      }

#### Parameters

widget | a GtkWidget |

#### Returns

the topmost ancestor of `widget` , or `widget` itself if there’s no ancestor.

[transfer none]

### gtk_widget_get_ancestor ()

    GtkWidget *
    gtk_widget_get_ancestor (GtkWidget *widget,
                             GType widget_type);

Gets the first ancestor of `widget` with type `widget_type` . For example, `gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)` gets the first GtkBox that’s an ancestor of `widget` . No reference will be added to the returned widget; it should not be unreferenced. See note about checking for a toplevel GtkWindow in the docs for `gtk_widget_get_toplevel()`.

Note that unlike `gtk_widget_is_ancestor()`, `gtk_widget_get_ancestor()` considers `widget` to be an ancestor of itself.

#### Parameters

widget | a GtkWidget |
widget_type | ancestor type |

#### Returns

the ancestor widget, or `NULL` if not found.

[transfer none][nullable]

### gtk_widget_get_visual ()

    GdkVisual *
    gtk_widget_get_visual (GtkWidget *widget);

Gets the visual that will be used to render `widget` .

#### Parameters

widget | a GtkWidget |

#### Returns

the visual for `widget` .

[transfer none]

### gtk_widget_set_visual ()

    void
    gtk_widget_set_visual (GtkWidget *widget,
                           GdkVisual *visual);

Sets the visual that should be used for by widget and its children for creating GdkWindows. The visual must be on the same GdkScreen as returned by `gtk_widget_get_screen()`, so handling the “screen-changed” signal is necessary.

Setting a new `visual` will not cause `widget` to recreate its windows, so you should call this function before `widget` is realized.

#### Parameters

widget | a GtkWidget |
visual | visual to be used or `NULL` to unset a previous one. | [allow-none]

### gtk_widget_get_pointer ()

    void
    gtk_widget_get_pointer (GtkWidget *widget,
                            gint *x,
                            gint *y);

`gtk_widget_get_pointer` has been deprecated since version 3.4 and should not be used in newly-written code.

Use `gdk_window_get_device_position()` instead.

Obtains the location of the mouse pointer in widget coordinates. Widget coordinates are a bit odd; for historical reasons, they are defined as `widget->window` coordinates for widgets that return `TRUE` for `gtk_widget_get_has_window()`; and are relative to `widget->allocation.x` , `widget->allocation.y` otherwise.

#### Parameters

widget | a GtkWidget |
x | return location for the X coordinate, or `NULL`. | [out][allow-none]
y | return location for the Y coordinate, or `NULL`. | [out][allow-none]

### gtk_widget_is_ancestor ()

    gboolean
    gtk_widget_is_ancestor (GtkWidget *widget,
                            GtkWidget *ancestor);

Determines whether `widget` is somewhere inside `ancestor` , possibly with intermediate containers.

#### Parameters

widget | a GtkWidget |
ancestor | another GtkWidget |

#### Returns

`TRUE` if `ancestor` contains `widget` as a child, grandchild, great grandchild, etc.

### gtk_widget_translate_coordinates ()

    gboolean
    gtk_widget_translate_coordinates (GtkWidget *src_widget,
                                      GtkWidget *dest_widget,
                                      gint src_x,
                                      gint src_y,
                                      gint *dest_x,
                                      gint *dest_y);

Translate coordinates relative to `src_widget` ’s allocation to coordinates relative to `dest_widget` ’s allocations. In order to perform this operation, both widgets must be realized, and must share a common toplevel.

#### Parameters

src_widget | a GtkWidget |
dest_widget | a GtkWidget |
src_x | X position relative to `src_widget` |
src_y | Y position relative to `src_widget` |
dest_x | location to store X position relative to `dest_widget` . | [out][optional]
dest_y | location to store Y position relative to `dest_widget` . | [out][optional]

#### Returns

`FALSE` if either widget was not realized, or there was no common ancestor. In this case, nothing is stored in *`dest_x` and *`dest_y` . Otherwise `TRUE`.

### gtk_widget_hide_on_delete ()

    gboolean
    gtk_widget_hide_on_delete (GtkWidget *widget);

Utility function; intended to be connected to the “delete-event” signal on a GtkWindow. The function calls `gtk_widget_hide()` on its argument, then returns `TRUE`. If connected to ::delete-event, the result is that clicking the close button for a window (on the window frame, top right corner usually) will hide but not destroy the window. By default, GTK+ destroys windows when ::delete-event is received.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE`

### gtk_widget_set_style ()

    void
    gtk_widget_set_style (GtkWidget *widget,
                          GtkStyle *style);

`gtk_widget_set_style` has been deprecated since version 3.0 and should not be used in newly-written code.

Use GtkStyleContext instead

Used to set the GtkStyle for a widget (`widget->style` ). Since GTK 3, this function does nothing, the passed in style is ignored.

#### Parameters

widget | a GtkWidget |
style | a GtkStyle, or `NULL` to remove the effect of a previous call to `gtk_widget_set_style()` and go back to the default style. | [allow-none]

### gtk_widget_ensure_style ()

    void
    gtk_widget_ensure_style (GtkWidget *widget);

`gtk_widget_ensure_style` has been deprecated since version 3.0 and should not be used in newly-written code.

Use GtkStyleContext instead

Ensures that `widget` has a style (`widget->style` ).

Not a very useful function; most of the time, if you want the style, the widget is realized, and realized widgets are guaranteed to have a style already.

#### Parameters

widget | a GtkWidget |

### gtk_widget_get_style ()

    GtkStyle *
    gtk_widget_get_style (GtkWidget *widget);

`gtk_widget_get_style` has been deprecated since version 3.0 and should not be used in newly-written code.

Use GtkStyleContext instead

Simply an accessor function that returns `widget->style` .

#### Parameters

widget | a GtkWidget |

#### Returns

the widget’s GtkStyle.

[transfer none]

### gtk_widget_reset_rc_styles ()

    void
    gtk_widget_reset_rc_styles (GtkWidget *widget);

`gtk_widget_reset_rc_styles` has been deprecated since version 3.0 and should not be used in newly-written code.

Use GtkStyleContext instead, and `gtk_widget_reset_style()`

Reset the styles of `widget` and all descendents, so when they are looked up again, they get the correct values for the currently loaded RC file settings.

This function is not useful for applications.

#### Parameters

widget | a GtkWidget. |

### gtk_widget_get_default_style ()

    GtkStyle *
    gtk_widget_get_default_style (void);

`gtk_widget_get_default_style` has been deprecated since version 3.0 and should not be used in newly-written code.

Use GtkStyleContext instead, and `gtk_css_provider_get_default()` to obtain a GtkStyleProvider with the default widget style information.

Returns the default style used by all widgets initially.

#### Returns

the default style. This GtkStyle object is owned by GTK+ and should not be modified or freed.

[transfer none]

### gtk_widget_set_direction ()

    void
    gtk_widget_set_direction (GtkWidget *widget,
                              GtkTextDirection dir);

Sets the reading direction on a particular widget. This direction controls the primary direction for widgets containing text, and also the direction in which the children of a container are packed. The ability to set the direction is present in order so that correct localization into languages with right-to-left reading directions can be done. Generally, applications will let the default reading direction present, except for containers where the containers are arranged in an order that is explicitly visual rather than logical (such as buttons for text justification).

If the direction is set to `GTK_TEXT_DIR_NONE`, then the value set by `gtk_widget_set_default_direction()` will be used.

#### Parameters

widget | a GtkWidget |
dir | the new direction |

### gtk_widget_get_direction ()

    GtkTextDirection
    gtk_widget_get_direction (GtkWidget *widget);

Gets the reading direction for a particular widget. See `gtk_widget_set_direction()`.

#### Parameters

widget | a GtkWidget |

#### Returns

the reading direction for the widget.

### gtk_widget_set_default_direction ()

    void
    gtk_widget_set_default_direction (GtkTextDirection dir);

Sets the default reading direction for widgets where the direction has not been explicitly set by `gtk_widget_set_direction()`.

#### Parameters

dir | the new default direction. This cannot be `GTK_TEXT_DIR_NONE`. |

### gtk_widget_get_default_direction ()

    GtkTextDirection
    gtk_widget_get_default_direction (void);

Obtains the current default reading direction. See `gtk_widget_set_default_direction()`.

#### Returns

the current default direction.

### gtk_widget_shape_combine_region ()

    void
    gtk_widget_shape_combine_region (GtkWidget *widget,
                                     cairo_region_t *region);

Sets a shape for this widget’s GDK window. This allows for transparent windows etc., see `gdk_window_shape_combine_region()` for more information.

#### Parameters

widget | a GtkWidget |
region | shape to be added, or `NULL` to remove an existing shape. | [allow-none]

Since: 3.0

### gtk_widget_input_shape_combine_region ()

    void
    gtk_widget_input_shape_combine_region (GtkWidget *widget,
                                           cairo_region_t *region);

Sets an input shape for this widget’s GDK window. This allows for windows which react to mouse click in a nonrectangular region, see `gdk_window_input_shape_combine_region()` for more information.

#### Parameters

widget | a GtkWidget |
region | shape to be added, or `NULL` to remove an existing shape. | [allow-none]

Since: 3.0

### gtk_widget_path ()

    void
    gtk_widget_path (GtkWidget *widget,
                     guint *path_length,
                     gchar **path,
                     gchar **path_reversed);

`gtk_widget_path` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gtk_widget_get_path()` instead

Obtains the full path to `widget` . The path is simply the name of a widget and all its parents in the container hierarchy, separated by periods. The name of a widget comes from `gtk_widget_get_name()`. Paths are used to apply styles to a widget in gtkrc configuration files. Widget names are the type of the widget by default (e.g. “GtkButton”) or can be set to an application-specific value with `gtk_widget_set_name()`. By setting the name of a widget, you allow users or theme authors to apply styles to that specific widget in their gtkrc file. `path_reversed_p` fills in the path in reverse order, i.e. starting with `widget` ’s name instead of starting with the name of `widget` ’s outermost ancestor.

#### Parameters

widget | a GtkWidget |
path_length | location to store length of the path, or `NULL`. | [out][allow-none]
path | location to store allocated path string, or `NULL`. | [out][allow-none]
path_reversed | location to store allocated reverse path string, or `NULL`. | [out][allow-none]

### gtk_widget_class_path ()

    void
    gtk_widget_class_path (GtkWidget *widget,
                           guint *path_length,
                           gchar **path,
                           gchar **path_reversed);

`gtk_widget_class_path` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gtk_widget_get_path()` instead

Same as `gtk_widget_path()`, but always uses the name of a widget’s type, never uses a custom name set with `gtk_widget_set_name()`.

#### Parameters

widget | a GtkWidget |
path_length | location to store the length of the class path, or `NULL`. | [out][optional]
path | location to store the class path as an allocated string, or `NULL`. | [out][optional]
path_reversed | location to store the reverse class path as an allocated string, or `NULL`. | [out][optional]

### gtk_widget_get_composite_name ()

    gchar *
    gtk_widget_get_composite_name (GtkWidget *widget);

`gtk_widget_get_composite_name` has been deprecated since version 3.10 and should not be used in newly-written code.

Use `gtk_widget_class_set_template()`, or don’t use this API at all.

Obtains the composite name of a widget.

#### Parameters

widget | a GtkWidget |

#### Returns

the composite name of `widget` , or `NULL` if `widget` is not a composite child. The string should be freed when it is no longer needed.

### gtk_widget_override_background_color ()

    void
    gtk_widget_override_background_color (GtkWidget *widget,
                                          GtkStateFlags state,
                                          const GdkRGBA *color);

`gtk_widget_override_background_color` has been deprecated since version 3.16 and should not be used in newly-written code.

This function is not useful in the context of CSS-based rendering. If you wish to change the way a widget renders its background you should use a custom CSS style, through an application-specific GtkStyleProvider and a CSS style class. You can also override the default drawing of a widget through the “draw” signal, and use Cairo to draw a specific color, regardless of the CSS style.

Sets the background color to use for a widget.

All other style values are left untouched. See `gtk_widget_override_color()`.

#### Parameters

widget | a GtkWidget |
state | the state for which to set the background color |
color | the color to assign, or `NULL` to undo the effect of previous calls to `gtk_widget_override_background_color()`. | [allow-none]

Since: 3.0

### gtk_widget_override_color ()

    void
    gtk_widget_override_color (GtkWidget *widget,
                               GtkStateFlags state,
                               const GdkRGBA *color);

`gtk_widget_override_color` has been deprecated since version 3.16 and should not be used in newly-written code.

Use a custom style provider and style classes instead

Sets the color to use for a widget.

All other style values are left untouched.

This function does not act recursively. Setting the color of a container does not affect its children. Note that some widgets that you may not think of as containers, for instance GtkButtons, are actually containers.

This API is mostly meant as a quick way for applications to change a widget appearance. If you are developing a widgets library and intend this change to be themeable, it is better done by setting meaningful CSS classes in your widget/container implementation through `gtk_style_context_add_class()`.

This way, your widget library can install a GtkCssProvider with the `GTK_STYLE_PROVIDER_PRIORITY_FALLBACK` priority in order to provide a default styling for those widgets that need so, and this theming may fully overridden by the user’s theme.

Note that for complex widgets this may bring in undesired results (such as uniform background color everywhere), in these cases it is better to fully style such widgets through a GtkCssProvider with the `GTK_STYLE_PROVIDER_PRIORITY_APPLICATION` priority.

#### Parameters

widget | a GtkWidget |
state | the state for which to set the color |
color | the color to assign, or `NULL` to undo the effect of previous calls to `gtk_widget_override_color()`. | [allow-none]

Since: 3.0

### gtk_widget_override_font ()

    void
    gtk_widget_override_font (GtkWidget *widget,
                              const PangoFontDescription *font_desc);

`gtk_widget_override_font` has been deprecated since version 3.16 and should not be used in newly-written code.

This function is not useful in the context of CSS-based rendering. If you wish to change the font a widget uses to render its text you should use a custom CSS style, through an application-specific GtkStyleProvider and a CSS style class.

Sets the font to use for a widget. All other style values are left untouched. See `gtk_widget_override_color()`.

#### Parameters

widget | a GtkWidget |
font_desc | the font description to use, or `NULL` to undo the effect of previous calls to `gtk_widget_override_font()`. | [allow-none]

Since: 3.0

### gtk_widget_override_symbolic_color ()

    void
    gtk_widget_override_symbolic_color (GtkWidget *widget,
                                        const gchar *name,
                                        const GdkRGBA *color);

`gtk_widget_override_symbolic_color` has been deprecated since version 3.16 and should not be used in newly-written code.

This function is not useful in the context of CSS-based rendering. If you wish to change the color used to render symbolic icons you should use a custom CSS style, through an application-specific GtkStyleProvider and a CSS style class.

Sets a symbolic color for a widget.

All other style values are left untouched. See `gtk_widget_override_color()` for overriding the foreground or background color.

#### Parameters

widget | a GtkWidget |
name | the name of the symbolic color to modify |
color | the color to assign (does not need to be allocated), or `NULL` to undo the effect of previous calls to `gtk_widget_override_symbolic_color()`. | [allow-none]

Since: 3.0

### gtk_widget_override_cursor ()

    void
    gtk_widget_override_cursor (GtkWidget *widget,
                                const GdkRGBA *cursor,
                                const GdkRGBA *secondary_cursor);

`gtk_widget_override_cursor` has been deprecated since version 3.16 and should not be used in newly-written code.

This function is not useful in the context of CSS-based rendering. If you wish to change the color used to render the primary and secondary cursors you should use a custom CSS style, through an application-specific GtkStyleProvider and a CSS style class.

Sets the cursor color to use in a widget, overriding the cursor-color and secondary-cursor-color style properties. All other style values are left untouched. See also `gtk_widget_modify_style()`.

Note that the underlying properties have the GdkColor type, so the alpha value in `primary` and `secondary` will be ignored.

#### Parameters

widget | a GtkWidget |
cursor | the color to use for primary cursor (does not need to be allocated), or `NULL` to undo the effect of previous calls to of `gtk_widget_override_cursor()`. | [allow-none]
secondary_cursor | the color to use for secondary cursor (does not need to be allocated), or `NULL` to undo the effect of previous calls to of `gtk_widget_override_cursor()`. | [allow-none]

Since: 3.0

### gtk_widget_modify_style ()

    void
    gtk_widget_modify_style (GtkWidget *widget,
                             GtkRcStyle *style);

`gtk_widget_modify_style` has been deprecated since version 3.0 and should not be used in newly-written code.

Use GtkStyleContext with a custom GtkStyleProvider instead

Modifies style values on the widget.

Modifications made using this technique take precedence over style values set via an RC file, however, they will be overridden if a style is explicitly set on the widget using `gtk_widget_set_style()`. The GtkRcStyle is designed so each field can either be set or unset, so it is possible, using this function, to modify some style values and leave the others unchanged.

Note that modifications made with this function are not cumulative with previous calls to `gtk_widget_modify_style()` or with such functions as `gtk_widget_modify_fg()`. If you wish to retain previous values, you must first call `gtk_widget_get_modifier_style()`, make your modifications to the returned style, then call `gtk_widget_modify_style()` with that style. On the other hand, if you first call `gtk_widget_modify_style()`, subsequent calls to such functions `gtk_widget_modify_fg()` will have a cumulative effect with the initial modifications.

#### Parameters

widget | a GtkWidget |
style | the GtkRcStyle holding the style modifications |

### gtk_widget_get_modifier_style ()

    GtkRcStyle *
    gtk_widget_get_modifier_style (GtkWidget *widget);

`gtk_widget_get_modifier_style` has been deprecated since version 3.0 and should not be used in newly-written code.

Use GtkStyleContext with a custom GtkStyleProvider instead

Returns the current modifier style for the widget. (As set by `gtk_widget_modify_style()`.) If no style has previously set, a new GtkRcStyle will be created with all values unset, and set as the modifier style for the widget. If you make changes to this rc style, you must call `gtk_widget_modify_style()`, passing in the returned rc style, to make sure that your changes take effect.

Caution: passing the style back to `gtk_widget_modify_style()` will normally end up destroying it, because `gtk_widget_modify_style()` copies the passed-in style and sets the copy as the new modifier style, thus dropping any reference to the old modifier style. Add a reference to the modifier style if you want to keep it alive.

#### Parameters

widget | a GtkWidget |

#### Returns

the modifier style for the widget. This rc style is owned by the widget. If you want to keep a pointer to value this around, you must add a refcount using `g_object_ref()`.

[transfer none]

### gtk_widget_modify_fg ()

    void
    gtk_widget_modify_fg (GtkWidget *widget,
                          GtkStateType state,
                          const GdkColor *color);

`gtk_widget_modify_fg` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gtk_widget_override_color()` instead

Sets the foreground color for a widget in a particular state.

All other style values are left untouched. See also `gtk_widget_modify_style()`.

#### Parameters

widget | a GtkWidget |
state | the state for which to set the foreground color |
color | the color to assign (does not need to be allocated), or `NULL` to undo the effect of previous calls to of `gtk_widget_modify_fg()`. | [allow-none]

### gtk_widget_modify_bg ()

    void
    gtk_widget_modify_bg (GtkWidget *widget,
                          GtkStateType state,
                          const GdkColor *color);

`gtk_widget_modify_bg` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gtk_widget_override_background_color()` instead

Sets the background color for a widget in a particular state.

All other style values are left untouched. See also `gtk_widget_modify_style()`.

> Note that “no window” widgets (which have the `GTK_NO_WINDOW` flag set) draw on their parent container’s window and thus may not draw any background themselves. This is the case for e.g. GtkLabel.

> To modify the background of such widgets, you have to set the background color on their parent; if you want to set the background of a rectangular area around a label, try placing the label in a GtkEventBox widget and setting the background color on that.

#### Parameters

widget | a GtkWidget |
state | the state for which to set the background color |
color | the color to assign (does not need to be allocated), or `NULL` to undo the effect of previous calls to of `gtk_widget_modify_bg()`. | [allow-none]

### gtk_widget_modify_text ()

    void
    gtk_widget_modify_text (GtkWidget *widget,
                            GtkStateType state,
                            const GdkColor *color);

`gtk_widget_modify_text` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gtk_widget_override_color()` instead

Sets the text color for a widget in a particular state.

All other style values are left untouched. The text color is the foreground color used along with the base color (see `gtk_widget_modify_base()`) for widgets such as GtkEntry and GtkTextView. See also `gtk_widget_modify_style()`.

#### Parameters

widget | a GtkWidget |
state | the state for which to set the text color |
color | the color to assign (does not need to be allocated), or `NULL` to undo the effect of previous calls to of `gtk_widget_modify_text()`. | [allow-none]

### gtk_widget_modify_base ()

    void
    gtk_widget_modify_base (GtkWidget *widget,
                            GtkStateType state,
                            const GdkColor *color);

`gtk_widget_modify_base` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gtk_widget_override_background_color()` instead

Sets the base color for a widget in a particular state. All other style values are left untouched. The base color is the background color used along with the text color (see `gtk_widget_modify_text()`) for widgets such as GtkEntry and GtkTextView. See also `gtk_widget_modify_style()`.

> Note that “no window” widgets (which have the `GTK_NO_WINDOW` flag set) draw on their parent container’s window and thus may not draw any background themselves. This is the case for e.g. GtkLabel.

> To modify the background of such widgets, you have to set the base color on their parent; if you want to set the background of a rectangular area around a label, try placing the label in a GtkEventBox widget and setting the base color on that.

#### Parameters

widget | a GtkWidget |
state | the state for which to set the base color |
color | the color to assign (does not need to be allocated), or `NULL` to undo the effect of previous calls to of `gtk_widget_modify_base()`. | [allow-none]

### gtk_widget_modify_font ()

    void
    gtk_widget_modify_font (GtkWidget *widget,
                            PangoFontDescription *font_desc);

`gtk_widget_modify_font` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gtk_widget_override_font()` instead

Sets the font to use for a widget.

All other style values are left untouched. See also `gtk_widget_modify_style()`.

#### Parameters

widget | a GtkWidget |
font_desc | the font description to use, or `NULL` to undo the effect of previous calls to `gtk_widget_modify_font()`. | [allow-none]

### gtk_widget_modify_cursor ()

    void
    gtk_widget_modify_cursor (GtkWidget *widget,
                              const GdkColor *primary,
                              const GdkColor *secondary);

`gtk_widget_modify_cursor` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gtk_widget_override_cursor()` instead.

Sets the cursor color to use in a widget, overriding the GtkWidget cursor-color and secondary-cursor-color style properties.

All other style values are left untouched. See also `gtk_widget_modify_style()`.

#### Parameters

widget | a GtkWidget |
primary | the color to use for primary cursor (does not need to be allocated), or `NULL` to undo the effect of previous calls to of `gtk_widget_modify_cursor()`. | [nullable]
secondary | the color to use for secondary cursor (does not need to be allocated), or `NULL` to undo the effect of previous calls to of `gtk_widget_modify_cursor()`. | [nullable]

Since: 2.12

### gtk_widget_create_pango_context ()

    PangoContext *
    gtk_widget_create_pango_context (GtkWidget *widget);

Creates a new PangoContext with the appropriate font map, font options, font description, and base direction for drawing text for this widget. See also `gtk_widget_get_pango_context()`.

#### Parameters

widget | a GtkWidget |

#### Returns

the new PangoContext.

[transfer full]

### gtk_widget_get_pango_context ()

    PangoContext *
    gtk_widget_get_pango_context (GtkWidget *widget);

Gets a PangoContext with the appropriate font map, font description, and base direction for this widget. Unlike the context returned by `gtk_widget_create_pango_context()`, this context is owned by the widget (it can be used until the screen for the widget changes or the widget is removed from its toplevel), and will be updated to match any changes to the widget’s attributes. This can be tracked by using the “screen-changed” signal on the widget.

#### Parameters

widget | a GtkWidget |

#### Returns

the PangoContext for the widget.

[transfer none]

### gtk_widget_set_font_options ()

    void
    gtk_widget_set_font_options (GtkWidget *widget,
                                 const cairo_font_options_t *options);

Sets the cairo_font_options_t used for Pango rendering in this widget. When not set, the default font options for the GdkScreen will be used.

#### Parameters

widget | a GtkWidget |
options | a cairo_font_options_t, or `NULL` to unset any previously set default font options. | [allow-none]

Since: 3.18

### gtk_widget_get_font_options ()

    const cairo_font_options_t *
    gtk_widget_get_font_options (GtkWidget *widget);

Returns the cairo_font_options_t used for Pango rendering. When not set, the defaults font options for the GdkScreen will be used.

#### Parameters

widget | a GtkWidget |

#### Returns

the cairo_font_options_t or `NULL` if not set.

[transfer none][nullable]

Since: 3.18

### gtk_widget_set_font_map ()

    void
    gtk_widget_set_font_map (GtkWidget *widget,
                             PangoFontMap *font_map);

Sets the font map to use for Pango rendering. When not set, the widget will inherit the font map from its parent.

#### Parameters

widget | a GtkWidget |
font_map | a PangoFontMap, or `NULL` to unset any previously set font map. | [allow-none]

Since: 3.18

### gtk_widget_get_font_map ()

    PangoFontMap *
    gtk_widget_get_font_map (GtkWidget *widget);

Gets the font map that has been set with `gtk_widget_set_font_map()`.

#### Parameters

widget | a GtkWidget |

#### Returns

A PangoFontMap, or `NULL`.

[transfer none][nullable]

Since: 3.18

### gtk_widget_create_pango_layout ()

    PangoLayout *
    gtk_widget_create_pango_layout (GtkWidget *widget,
                                    const gchar *text);

Creates a new PangoLayout with the appropriate font map, font description, and base direction for drawing text for this widget.

If you keep a PangoLayout created in this way around, you need to re-create it when the widget PangoContext is replaced. This can be tracked by using the “screen-changed” signal on the widget.

#### Parameters

widget | a GtkWidget |
text | text to set on the layout (can be `NULL`). | [nullable]

#### Returns

the new PangoLayout.

[transfer full]

### gtk_widget_render_icon ()

    GdkPixbuf *
    gtk_widget_render_icon (GtkWidget *widget,
                            const gchar *stock_id,
                            GtkIconSize size,
                            const gchar *detail);

`gtk_widget_render_icon` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gtk_widget_render_icon_pixbuf()` instead.

A convenience function that uses the theme settings for `widget` to look up `stock_id` and render it to a pixbuf. `stock_id` should be a stock icon ID such as GTK_STOCK_OPEN or GTK_STOCK_OK. `size` should be a size such as GTK_ICON_SIZE_MENU. `detail` should be a string that identifies the widget or code doing the rendering, so that theme engines can special-case rendering for that widget or code.

The pixels in the returned GdkPixbuf are shared with the rest of the application and should not be modified. The pixbuf should be freed after use with `g_object_unref()`.

#### Parameters

widget | a GtkWidget |
stock_id | a stock ID |
size | a stock size (GtkIconSize). A size of `(GtkIconSize)-1` means render at the size of the source and don’t scale (if there are multiple source sizes, GTK+ picks one of the available sizes). | [type int]
detail | render detail to pass to theme engine. | [allow-none]

#### Returns

a new pixbuf, or `NULL` if the stock ID wasn’t known.

[nullable][transfer full]

### gtk_widget_render_icon_pixbuf ()

    GdkPixbuf *
    gtk_widget_render_icon_pixbuf (GtkWidget *widget,
                                   const gchar *stock_id,
                                   GtkIconSize size);

`gtk_widget_render_icon_pixbuf` has been deprecated since version 3.10 and should not be used in newly-written code.

Use `gtk_icon_theme_load_icon()` instead.

A convenience function that uses the theme engine and style settings for `widget` to look up `stock_id` and render it to a pixbuf. `stock_id` should be a stock icon ID such as GTK_STOCK_OPEN or GTK_STOCK_OK. `size` should be a size such as GTK_ICON_SIZE_MENU.

The pixels in the returned GdkPixbuf are shared with the rest of the application and should not be modified. The pixbuf should be freed after use with `g_object_unref()`.

#### Parameters

widget | a GtkWidget |
stock_id | a stock ID |
size | a stock size (GtkIconSize). A size of `(GtkIconSize)-1` means render at the size of the source and don’t scale (if there are multiple source sizes, GTK+ picks one of the available sizes). | [type int]

#### Returns

a new pixbuf, or `NULL` if the stock ID wasn’t known.

[transfer full][nullable]

Since: 3.0

### gtk_widget_pop_composite_child ()

    void
    gtk_widget_pop_composite_child (void);

`gtk_widget_pop_composite_child` has been deprecated since version 3.10 and should not be used in newly-written code.

Use `gtk_widget_class_set_template()`, or don’t use this API at all.

Cancels the effect of a previous call to `gtk_widget_push_composite_child()`.

### gtk_widget_push_composite_child ()

    void
    gtk_widget_push_composite_child (void);

`gtk_widget_push_composite_child` has been deprecated since version 3.10 and should not be used in newly-written code.

This API never really worked well and was mostly unused, now we have a more complete mechanism for composite children, see `gtk_widget_class_set_template()`.

Makes all newly-created widgets as composite children until the corresponding `gtk_widget_pop_composite_child()` call.

A composite child is a child that’s an implementation detail of the container it’s inside and should not be visible to people using the container. Composite children aren’t treated differently by GTK+ (but see `gtk_container_foreach()` vs. `gtk_container_forall()`), but e.g. GUI builders might want to treat them in a different way.

### gtk_widget_queue_draw_area ()

    void
    gtk_widget_queue_draw_area (GtkWidget *widget,
                                gint x,
                                gint y,
                                gint width,
                                gint height);

Convenience function that calls `gtk_widget_queue_draw_region()` on the region created from the given coordinates.

The region here is specified in widget coordinates. Widget coordinates are a bit odd; for historical reasons, they are defined as `widget->window` coordinates for widgets that return `TRUE` for `gtk_widget_get_has_window()`, and are relative to `widget->allocation.x` , `widget->allocation.y` otherwise.

`width` or `height` may be 0, in this case this function does nothing. Negative values for `width` and `height` are not allowed.

#### Parameters

widget | a GtkWidget |
x | x coordinate of upper-left corner of rectangle to redraw |
y | y coordinate of upper-left corner of rectangle to redraw |
width | width of region to draw |
height | height of region to draw |

### gtk_widget_queue_draw_region ()

    void
    gtk_widget_queue_draw_region (GtkWidget *widget,
                                  const cairo_region_t *region);

Invalidates the area of `widget` defined by `region` by calling `gdk_window_invalidate_region()` on the widget’s window and all its child windows. Once the main loop becomes idle (after the current batch of events has been processed, roughly), the window will receive expose events for the union of all regions that have been invalidated.

Normally you would only use this function in widget implementations. You might also use it to schedule a redraw of a GtkDrawingArea or some portion thereof.

#### Parameters

widget | a GtkWidget |
region | region to draw |

Since: 3.0

### gtk_widget_set_app_paintable ()

    void
    gtk_widget_set_app_paintable (GtkWidget *widget,
                                  gboolean app_paintable);

Sets whether the application intends to draw on the widget in an “draw” handler.

This is a hint to the widget and does not affect the behavior of the GTK+ core; many widgets ignore this flag entirely. For widgets that do pay attention to the flag, such as GtkEventBox and GtkWindow, the effect is to suppress default themed drawing of the widget's background. (Children of the widget will still be drawn.) The application is then entirely responsible for drawing the widget background.

Note that the background is still drawn when the widget is mapped.

#### Parameters

widget | a GtkWidget |
app_paintable | `TRUE` if the application will paint on the widget |

### gtk_widget_set_double_buffered ()

    void
    gtk_widget_set_double_buffered (GtkWidget *widget,
                                    gboolean double_buffered);

`gtk_widget_set_double_buffered` has been deprecated since version 3.14 and should not be used in newly-written code.

This function does not work under non-X11 backends or with non-native windows. It should not be used in newly written code.

Widgets are double buffered by default; you can use this function to turn off the buffering. “Double buffered” simply means that `gdk_window_begin_draw_frame()` and `gdk_window_end_draw_frame()` are called automatically around expose events sent to the widget. `gdk_window_begin_draw_frame()` diverts all drawing to a widget's window to an offscreen buffer, and `gdk_window_end_draw_frame()` draws the buffer to the screen. The result is that users see the window update in one smooth step, and don’t see individual graphics primitives being rendered.

In very simple terms, double buffered widgets don’t flicker, so you would only use this function to turn off double buffering if you had special needs and really knew what you were doing.

Note: if you turn off double-buffering, you have to handle expose events, since even the clearing to the background color or pixmap will not happen automatically (as it is done in `gdk_window_begin_draw_frame()`).

In 3.10 GTK and GDK have been restructured for translucent drawing. Since then expose events for double-buffered widgets are culled into a single event to the toplevel GDK window. If you now unset double buffering, you will cause a separate rendering pass for every widget. This will likely cause rendering problems - in particular related to stacking - and usually increases rendering times significantly.

#### Parameters

widget | a GtkWidget |
double_buffered | `TRUE` to double-buffer a widget |

### gtk_widget_set_redraw_on_allocate ()

    void
    gtk_widget_set_redraw_on_allocate (GtkWidget *widget,
                                       gboolean redraw_on_allocate);

Sets whether the entire widget is queued for drawing when its size allocation changes. By default, this setting is `TRUE` and the entire widget is redrawn on every size change. If your widget leaves the upper left unchanged when made bigger, turning this setting off will improve performance.

Note that for widgets where `gtk_widget_get_has_window()` is `FALSE` setting this flag to `FALSE` turns off all allocation on resizing: the widget will not even redraw if its position changes; this is to allow containers that don’t draw anything to avoid excess invalidations. If you set this flag on a widget with no window that does draw on `widget->window` , you are responsible for invalidating both the old and new allocation of the widget when the widget is moved and responsible for invalidating regions newly when the widget increases size.

#### Parameters

widget | a GtkWidget |
redraw_on_allocate | if `TRUE`, the entire widget will be redrawn when it is allocated to a new size. Otherwise, only the new portion of the widget will be redrawn. |

### gtk_widget_set_composite_name ()

    void
    gtk_widget_set_composite_name (GtkWidget *widget,
                                   const gchar *name);

`gtk_widget_set_composite_name` has been deprecated since version 3.10 and should not be used in newly-written code.

Use `gtk_widget_class_set_template()`, or don’t use this API at all.

Sets a widgets composite name. The widget must be a composite child of its parent; see `gtk_widget_push_composite_child()`.

#### Parameters

widget | a GtkWidget. |
name | the name to set |

### gtk_widget_mnemonic_activate ()

    gboolean
    gtk_widget_mnemonic_activate (GtkWidget *widget,
                                  gboolean group_cycling);

Emits the “mnemonic-activate” signal.

#### Parameters

widget | a GtkWidget |
group_cycling | `TRUE` if there are other widgets with the same mnemonic |

#### Returns

`TRUE` if the signal has been handled

### gtk_widget_class_install_style_property ()

    void
    gtk_widget_class_install_style_property
                                   (GtkWidgetClass *klass,
                                    GParamSpec *pspec);

Installs a style property on a widget class. The parser for the style property is determined by the value type of `pspec` .

#### Parameters

klass | a GtkWidgetClass |
pspec | the GParamSpec for the property |

### gtk_widget_class_install_style_property_parser ()

    void
    gtk_widget_class_install_style_property_parser
                                   (GtkWidgetClass *klass,
                                    GParamSpec *pspec,
                                    GtkRcPropertyParser parser);

Installs a style property on a widget class.

[skip]

#### Parameters

klass | a GtkWidgetClass |
pspec | the GParamSpec for the style property |
parser | the parser for the style property |

### gtk_widget_class_find_style_property ()

    GParamSpec *
    gtk_widget_class_find_style_property (GtkWidgetClass *klass,
                                          const gchar *property_name);

Finds a style property of a widget class by name.

#### Parameters

klass | a GtkWidgetClass |
property_name | the name of the style property to find |

#### Returns

the GParamSpec of the style property or `NULL` if `class` has no style property with that name.

[transfer none]

Since: 2.2

### gtk_widget_class_list_style_properties ()

    GParamSpec **
    gtk_widget_class_list_style_properties
                                   (GtkWidgetClass *klass,
                                    guint *n_properties);

Returns all style properties of a widget class.

#### Parameters

klass | a GtkWidgetClass |
n_properties | location to return the number of style properties found. | [out]

#### Returns

a newly allocated array of GParamSpec*. The array must be freed with `g_free()`.

[array length=n_properties][transfer container]

Since: 2.2

### gtk_widget_region_intersect ()

    cairo_region_t *
    gtk_widget_region_intersect (GtkWidget *widget,
                                 const cairo_region_t *region);

`gtk_widget_region_intersect` has been deprecated since version 3.14 and should not be used in newly-written code.

Use `gtk_widget_get_allocation()` and `cairo_region_intersect_rectangle()` to get the same behavior.

Computes the intersection of a `widget` ’s area and `region` , returning the intersection. The result may be empty, use `cairo_region_is_empty()` to check.

#### Parameters

widget | a GtkWidget |
region | a cairo_region_t, in the same coordinate system as `widget->allocation` . That is, relative to `widget->window` for widgets which return `FALSE` from `gtk_widget_get_has_window()`; relative to the parent window of `widget->window` otherwise. |

#### Returns

A newly allocated region holding the intersection of `widget` and `region` .

### gtk_widget_send_expose ()

    gint
    gtk_widget_send_expose (GtkWidget *widget,
                            GdkEvent *event);

`gtk_widget_send_expose` has been deprecated since version 3.22 and should not be used in newly-written code.

Application and widget code should not handle expose events directly; invalidation should use the GtkWidget API, and drawing should only happen inside “draw” implementations

Very rarely-used function. This function is used to emit an expose event on a widget. This function is not normally used directly. The only time it is used is when propagating an expose event to a windowless child widget (`gtk_widget_get_has_window()` is `FALSE`), and that is normally done using `gtk_container_propagate_draw()`.

If you want to force an area of a window to be redrawn, use `gdk_window_invalidate_rect()` or `gdk_window_invalidate_region()`. To cause the redraw to be done immediately, follow that call with a call to `gdk_window_process_updates()`.

#### Parameters

widget | a GtkWidget |
event | a expose GdkEvent |

#### Returns

return from the event signal emission (`TRUE` if the event was handled)

### gtk_widget_send_focus_change ()

    gboolean
    gtk_widget_send_focus_change (GtkWidget *widget,
                                  GdkEvent *event);

Sends the focus change `event` to `widget`

This function is not meant to be used by applications. The only time it should be used is when it is necessary for a GtkWidget to assign focus to a widget that is semantically owned by the first widget even though it’s not a direct child - for instance, a search entry in a floating window similar to the quick search in GtkTreeView.

An example of its usage is:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE);

    fevent->focus_change.type = GDK_FOCUS_CHANGE;
    fevent->focus_change.in = TRUE;
    fevent->focus_change.window = _gtk_widget_get_window (widget);
    if (fevent->focus_change.window != NULL)
      g_object_ref (fevent->focus_change.window);

    gtk_widget_send_focus_change (widget, fevent);

    gdk_event_free (event);

#### Parameters

widget | a GtkWidget |
event | a GdkEvent of type GDK_FOCUS_CHANGE |

#### Returns

the return value from the event signal emission: `TRUE` if the event was handled, and `FALSE` otherwise

Since: 2.20

### gtk_widget_style_get ()

    void
    gtk_widget_style_get (GtkWidget *widget,
                          const gchar *first_property_name,
                          ...);

Gets the values of a multiple style properties of `widget` .

#### Parameters

widget | a GtkWidget |
first_property_name | the name of the first property to get |
... | pairs of property names and locations to return the property values, starting with the location for `first_property_name` , terminated by `NULL`. |

### gtk_widget_style_get_property ()

    void
    gtk_widget_style_get_property (GtkWidget *widget,
                                   const gchar *property_name,
                                   GValue *value);

Gets the value of a style property of `widget` .

#### Parameters

widget | a GtkWidget |
property_name | the name of a style property |
value | location to return the property value |

### gtk_widget_style_get_valist ()

    void
    gtk_widget_style_get_valist (GtkWidget *widget,
                                 const gchar *first_property_name,
                                 va_list var_args);

Non-vararg variant of `gtk_widget_style_get()`. Used primarily by language bindings.

#### Parameters

widget | a GtkWidget |
first_property_name | the name of the first property to get |
var_args | a va_list of pairs of property names and locations to return the property values, starting with the location for `first_property_name` . |

### gtk_widget_style_attach ()

    void
    gtk_widget_style_attach (GtkWidget *widget);

`gtk_widget_style_attach` has been deprecated since version 3.0 and should not be used in newly-written code.

This step is unnecessary with GtkStyleContext.

This function attaches the widget’s GtkStyle to the widget's GdkWindow. It is a replacement for

    1
    widget->style = gtk_style_attach (widget->style, widget->window);

and should only ever be called in a derived widget’s “realize” implementation which does not chain up to its parent class' “realize” implementation, because one of the parent classes (finally GtkWidget) would attach the style itself.

#### Parameters

widget | a GtkWidget |

Since: 2.20

### gtk_widget_class_set_accessible_type ()

    void
    gtk_widget_class_set_accessible_type (GtkWidgetClass *widget_class,
                                          GType type);

Sets the type to be used for creating accessibles for widgets of `widget_class` . The given `type` must be a subtype of the type used for accessibles of the parent class.

This function should only be called from class init functions of widgets.

#### Parameters

widget_class | class to set the accessible type for |
type | The object type that implements the accessible for `widget_class` |

Since: 3.2

### gtk_widget_class_set_accessible_role ()

    void
    gtk_widget_class_set_accessible_role (GtkWidgetClass *widget_class,
                                          AtkRole role);

Sets the default AtkRole to be set on accessibles created for widgets of `widget_class` . Accessibles may decide to not honor this setting if their role reporting is more refined. Calls to `gtk_widget_class_set_accessible_type()` will reset this value.

In cases where you want more fine-grained control over the role of accessibles created for `widget_class` , you should provide your own accessible type and use `gtk_widget_class_set_accessible_type()` instead.

If `role` is ATK_ROLE_INVALID, the default role will not be changed and the accessible’s default role will be used instead.

This function should only be called from class init functions of widgets.

#### Parameters

widget_class | class to set the accessible role for |
role | The role to use for accessibles created for `widget_class` |

Since: 3.2

### gtk_widget_get_accessible ()

    AtkObject *
    gtk_widget_get_accessible (GtkWidget *widget);

Returns the accessible object that describes the widget to an assistive technology.

If accessibility support is not available, this AtkObject instance may be a no-op. Likewise, if no class-specific AtkObject implementation is available for the widget instance in question, it will inherit an AtkObject implementation from the first ancestor class for which such an implementation is defined.

The documentation of the ATK library contains more information about accessible objects and their uses.

#### Parameters

widget | a GtkWidget |

#### Returns

the AtkObject associated with `widget` .

[transfer none]

### gtk_widget_child_focus ()

    gboolean
    gtk_widget_child_focus (GtkWidget *widget,
                            GtkDirectionType direction);

This function is used by custom widget implementations; if you're writing an app, you’d use `gtk_widget_grab_focus()` to move the focus to a particular widget, and `gtk_container_set_focus_chain()` to change the focus tab order. So you may want to investigate those functions instead.

gtk_widget_child_focus() is called by containers as the user moves around the window using keyboard shortcuts. `direction` indicates what kind of motion is taking place (up, down, left, right, tab forward, tab backward). `gtk_widget_child_focus()` emits the “focus” signal; widgets override the default handler for this signal in order to implement appropriate focus behavior.

The default ::focus handler for a widget should return `TRUE` if moving in `direction` left the focus on a focusable location inside that widget, and `FALSE` if moving in `direction` moved the focus outside the widget. If returning `TRUE`, widgets normally call `gtk_widget_grab_focus()` to place the focus accordingly; if returning `FALSE`, they don’t modify the current focus location.

#### Parameters

widget | a GtkWidget |
direction | direction of focus movement |

#### Returns

`TRUE` if focus ended up inside `widget`

### gtk_widget_child_notify ()

    void
    gtk_widget_child_notify (GtkWidget *widget,
                             const gchar *child_property);

Emits a “child-notify” signal for the child property `child_property` on `widget` .

This is the analogue of `g_object_notify()` for child properties.

Also see `gtk_container_child_notify()`.

#### Parameters

widget | a GtkWidget |
child_property | the name of a child property installed on the class of `widget` ’s parent |

### gtk_widget_freeze_child_notify ()

    void
    gtk_widget_freeze_child_notify (GtkWidget *widget);

Stops emission of “child-notify” signals on `widget` . The signals are queued until `gtk_widget_thaw_child_notify()` is called on `widget` .

This is the analogue of `g_object_freeze_notify()` for child properties.

#### Parameters

widget | a GtkWidget |

### gtk_widget_get_child_visible ()

    gboolean
    gtk_widget_get_child_visible (GtkWidget *widget);

Gets the value set with `gtk_widget_set_child_visible()`. If you feel a need to use this function, your code probably needs reorganization.

This function is only useful for container implementations and never should be called by an application.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget is mapped with the parent.

### gtk_widget_get_parent ()

    GtkWidget *
    gtk_widget_get_parent (GtkWidget *widget);

Returns the parent container of `widget` .

#### Parameters

widget | a GtkWidget |

#### Returns

the parent container of `widget` , or `NULL`.

[transfer none][nullable]

### gtk_widget_get_settings ()

    GtkSettings *
    gtk_widget_get_settings (GtkWidget *widget);

Gets the settings object holding the settings used for this widget.

Note that this function can only be called when the GtkWidget is attached to a toplevel, since the settings object is specific to a particular GdkScreen.

#### Parameters

widget | a GtkWidget |

#### Returns

the relevant GtkSettings object.

[transfer none]

### gtk_widget_get_clipboard ()

    GtkClipboard *
    gtk_widget_get_clipboard (GtkWidget *widget,
                              GdkAtom selection);

Returns the clipboard object for the given selection to be used with `widget` . `widget` must have a GdkDisplay associated with it, so must be attached to a toplevel window.

#### Parameters

widget | a GtkWidget |
selection | a GdkAtom which identifies the clipboard to use. `GDK_SELECTION_CLIPBOARD` gives the default clipboard. Another common value is `GDK_SELECTION_PRIMARY`, which gives the primary X selection. |

#### Returns

the appropriate clipboard object. If no clipboard already exists, a new one will be created. Once a clipboard object has been created, it is persistent for all time.

[transfer none]

Since: 2.2

### gtk_widget_get_display ()

    GdkDisplay *
    gtk_widget_get_display (GtkWidget *widget);

Get the GdkDisplay for the toplevel window associated with this widget. This function can only be called after the widget has been added to a widget hierarchy with a GtkWindow at the top.

In general, you should only create display specific resources when a widget has been realized, and you should free those resources when the widget is unrealized.

#### Parameters

widget | a GtkWidget |

#### Returns

the GdkDisplay for the toplevel for this widget.

[transfer none]

Since: 2.2

### gtk_widget_get_root_window ()

    GdkWindow *
    gtk_widget_get_root_window (GtkWidget *widget);

`gtk_widget_get_root_window` has been deprecated since version 3.12 and should not be used in newly-written code.

Use `gdk_screen_get_root_window()` instead

Get the root window where this widget is located. This function can only be called after the widget has been added to a widget hierarchy with GtkWindow at the top.

The root window is useful for such purposes as creating a popup GdkWindow associated with the window. In general, you should only create display specific resources when a widget has been realized, and you should free those resources when the widget is unrealized.

#### Parameters

widget | a GtkWidget |

#### Returns

the GdkWindow root window for the toplevel for this widget.

[transfer none]

Since: 2.2

### gtk_widget_get_screen ()

    GdkScreen *
    gtk_widget_get_screen (GtkWidget *widget);

Get the GdkScreen from the toplevel window associated with this widget. This function can only be called after the widget has been added to a widget hierarchy with a GtkWindow at the top.

In general, you should only create screen specific resources when a widget has been realized, and you should free those resources when the widget is unrealized.

#### Parameters

widget | a GtkWidget |

#### Returns

the GdkScreen for the toplevel for this widget.

[transfer none]

Since: 2.2

### gtk_widget_has_screen ()

    gboolean
    gtk_widget_has_screen (GtkWidget *widget);

Checks whether there is a GdkScreen is associated with this widget. All toplevel widgets have an associated screen, and all widgets added into a hierarchy with a toplevel window at the top.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if there is a GdkScreen associated with the widget.

Since: 2.2

### gtk_widget_get_size_request ()

    void
    gtk_widget_get_size_request (GtkWidget *widget,
                                 gint *width,
                                 gint *height);

Gets the size request that was explicitly set for the widget using `gtk_widget_set_size_request()`. A value of -1 stored in `width` or `height` indicates that that dimension has not been set explicitly and the natural requisition of the widget will be used instead. See `gtk_widget_set_size_request()`. To get the size a widget will actually request, call `gtk_widget_get_preferred_size()` instead of this function.

#### Parameters

widget | a GtkWidget |
width | return location for width, or `NULL`. | [out][allow-none]
height | return location for height, or `NULL`. | [out][allow-none]

### gtk_widget_set_child_visible ()

    void
    gtk_widget_set_child_visible (GtkWidget *widget,
                                  gboolean is_visible);

Sets whether `widget` should be mapped along with its when its parent is mapped and `widget` has been shown with `gtk_widget_show()`.

The child visibility can be set for widget before it is added to a container with `gtk_widget_set_parent()`, to avoid mapping children unnecessary before immediately unmapping them. However it will be reset to its default state of `TRUE` when the widget is removed from a container.

Note that changing the child visibility of a widget does not queue a resize on the widget. Most of the time, the size of a widget is computed from all visible children, whether or not they are mapped. If this is not the case, the container can queue a resize itself.

This function is only useful for container implementations and never should be called by an application.

#### Parameters

widget | a GtkWidget |
is_visible | if `TRUE`, `widget` should be mapped along with its parent. |

### gtk_widget_set_size_request ()

    void
    gtk_widget_set_size_request (GtkWidget *widget,
                                 gint width,
                                 gint height);

Sets the minimum size of a widget; that is, the widget’s size request will be at least `width` by `height` . You can use this function to force a widget to be larger than it normally would be.

In most cases, `gtk_window_set_default_size()` is a better choice for toplevel windows than this function; setting the default size will still allow users to shrink the window. Setting the size request will force them to leave the window at least as large as the size request. When dealing with window sizes, `gtk_window_set_geometry_hints()` can be a useful function as well.

Note the inherent danger of setting any fixed size - themes, translations into other languages, different fonts, and user action can all change the appropriate size for a given widget. So, it's basically impossible to hardcode a size that will always be correct.

The size request of a widget is the smallest size a widget can accept while still functioning well and drawing itself correctly. However in some strange cases a widget may be allocated less than its requested size, and in many cases a widget may be allocated more space than it requested.

If the size request in a given direction is -1 (unset), then the “natural” size request of the widget will be used instead.

The size request set here does not include any margin from the GtkWidget properties margin-left, margin-right, margin-top, and margin-bottom, but it does include pretty much all other padding or border properties set by any subclass of GtkWidget.

#### Parameters

widget | a GtkWidget |
width | width `widget` should request, or -1 to unset |
height | height `widget` should request, or -1 to unset |

### gtk_widget_thaw_child_notify ()

    void
    gtk_widget_thaw_child_notify (GtkWidget *widget);

Reverts the effect of a previous call to `gtk_widget_freeze_child_notify()`. This causes all queued “child-notify” signals on `widget` to be emitted.

#### Parameters

widget | a GtkWidget |

### gtk_widget_set_no_show_all ()

    void
    gtk_widget_set_no_show_all (GtkWidget *widget,
                                gboolean no_show_all);

Sets the “no-show-all” property, which determines whether calls to `gtk_widget_show_all()` will affect this widget.

This is mostly for use in constructing widget hierarchies with externally controlled visibility, see GtkUIManager.

#### Parameters

widget | a GtkWidget |
no_show_all | the new value for the “no-show-all” property |

Since: 2.4

### gtk_widget_get_no_show_all ()

    gboolean
    gtk_widget_get_no_show_all (GtkWidget *widget);

Returns the current value of the “no-show-all” property, which determines whether calls to `gtk_widget_show_all()` will affect this widget.

#### Parameters

widget | a GtkWidget |

#### Returns

the current value of the “no-show-all” property.

Since: 2.4

### gtk_widget_list_mnemonic_labels ()

    GList *
    gtk_widget_list_mnemonic_labels (GtkWidget *widget);

Returns a newly allocated list of the widgets, normally labels, for which this widget is the target of a mnemonic (see for example, `gtk_label_set_mnemonic_widget()`).

The widgets in the list are not individually referenced. If you want to iterate through the list and perform actions involving callbacks that might destroy the widgets, you must call `g_list_foreach (result, (GFunc)g_object_ref, NULL)` first, and then unref all the widgets afterwards.

#### Parameters

widget | a GtkWidget |

#### Returns

the list of mnemonic labels; free this list with `g_list_free()` when you are done with it.

[element-type GtkWidget][transfer container]

Since: 2.4

### gtk_widget_add_mnemonic_label ()

    void
    gtk_widget_add_mnemonic_label (GtkWidget *widget,
                                   GtkWidget *label);

Adds a widget to the list of mnemonic labels for this widget. (See `gtk_widget_list_mnemonic_labels()`). Note the list of mnemonic labels for the widget is cleared when the widget is destroyed, so the caller must make sure to update its internal state at this point as well, by using a connection to the “destroy” signal or a weak notifier.

#### Parameters

widget | a GtkWidget |
label | a GtkWidget that acts as a mnemonic label for `widget` |

Since: 2.4

### gtk_widget_remove_mnemonic_label ()

    void
    gtk_widget_remove_mnemonic_label (GtkWidget *widget,
                                      GtkWidget *label);

Removes a widget from the list of mnemonic labels for this widget. (See `gtk_widget_list_mnemonic_labels()`). The widget must have previously been added to the list with `gtk_widget_add_mnemonic_label()`.

#### Parameters

widget | a GtkWidget |
label | a GtkWidget that was previously set as a mnemonic label for `widget` with `gtk_widget_add_mnemonic_label()`. |

Since: 2.4

### gtk_widget_is_composited ()

    gboolean
    gtk_widget_is_composited (GtkWidget *widget);

`gtk_widget_is_composited` has been deprecated since version 3.22 and should not be used in newly-written code.

Use `gdk_screen_is_composited()` instead.

Whether `widget` can rely on having its alpha channel drawn correctly. On X11 this function returns whether a compositing manager is running for `widget` ’s screen.

Please note that the semantics of this call will change in the future if used on a widget that has a composited window in its hierarchy (as set by `gdk_window_set_composited()`).

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget can rely on its alpha channel being drawn correctly.

Since: 2.10

### gtk_widget_error_bell ()

    void
    gtk_widget_error_bell (GtkWidget *widget);

Notifies the user about an input-related error on this widget. If the “gtk-error-bell” setting is `TRUE`, it calls `gdk_window_beep()`, otherwise it does nothing.

Note that the effect of `gdk_window_beep()` can be configured in many ways, depending on the windowing backend and the desktop environment or window manager that is used.

#### Parameters

widget | a GtkWidget |

Since: 2.12

### gtk_widget_keynav_failed ()

    gboolean
    gtk_widget_keynav_failed (GtkWidget *widget,
                              GtkDirectionType direction);

This function should be called whenever keyboard navigation within a single widget hits a boundary. The function emits the “keynav-failed” signal on the widget and its return value should be interpreted in a way similar to the return value of `gtk_widget_child_focus()`:

When `TRUE` is returned, stay in the widget, the failed keyboard navigation is OK and/or there is nowhere we can/should move the focus to.

When `FALSE` is returned, the caller should continue with keyboard navigation outside the widget, e.g. by calling `gtk_widget_child_focus()` on the widget’s toplevel.

The default ::keynav-failed handler returns `TRUE` for `GTK_DIR_TAB_FORWARD` and `GTK_DIR_TAB_BACKWARD`. For the other values of GtkDirectionType it returns `FALSE`.

Whenever the default handler returns `TRUE`, it also calls `gtk_widget_error_bell()` to notify the user of the failed keyboard navigation.

A use case for providing an own implementation of ::keynav-failed (either by connecting to it or by overriding it) would be a row of GtkEntry widgets where the user should be able to navigate the entire row with the cursor keys, as e.g. known from user interfaces that require entering license keys.

#### Parameters

widget | a GtkWidget |
direction | direction of focus movement |

#### Returns

`TRUE` if stopping keyboard navigation is fine, `FALSE` if the emitting widget should try to handle the keyboard navigation attempt in its parent container(s).

Since: 2.12

### gtk_widget_get_tooltip_markup ()

    gchar *
    gtk_widget_get_tooltip_markup (GtkWidget *widget);

Gets the contents of the tooltip for `widget` .

#### Parameters

widget | a GtkWidget |

#### Returns

the tooltip text, or `NULL`. You should free the returned string with `g_free()` when done.

[nullable]

Since: 2.12

### gtk_widget_set_tooltip_markup ()

    void
    gtk_widget_set_tooltip_markup (GtkWidget *widget,
                                   const gchar *markup);

Sets `markup` as the contents of the tooltip, which is marked up with the Pango text markup language.

This function will take care of setting “has-tooltip” to `TRUE` and of the default handler for the “query-tooltip” signal.

See also the “tooltip-markup” property and `gtk_tooltip_set_markup()`.

#### Parameters

widget | a GtkWidget |
markup | the contents of the tooltip for `widget` , or `NULL`. | [allow-none]

Since: 2.12

### gtk_widget_get_tooltip_text ()

    gchar *
    gtk_widget_get_tooltip_text (GtkWidget *widget);

Gets the contents of the tooltip for `widget` .

#### Parameters

widget | a GtkWidget |

#### Returns

the tooltip text, or `NULL`. You should free the returned string with `g_free()` when done.

[nullable]

Since: 2.12

### gtk_widget_set_tooltip_text ()

    void
    gtk_widget_set_tooltip_text (GtkWidget *widget,
                                 const gchar *text);

Sets `text` as the contents of the tooltip. This function will take care of setting “has-tooltip” to `TRUE` and of the default handler for the “query-tooltip” signal.

See also the “tooltip-text” property and `gtk_tooltip_set_text()`.

#### Parameters

widget | a GtkWidget |
text | the contents of the tooltip for `widget` . | [allow-none]

Since: 2.12

### gtk_widget_get_tooltip_window ()

    GtkWindow *
    gtk_widget_get_tooltip_window (GtkWidget *widget);

Returns the GtkWindow of the current tooltip. This can be the GtkWindow created by default, or the custom tooltip window set using `gtk_widget_set_tooltip_window()`.

#### Parameters

widget | a GtkWidget |

#### Returns

The GtkWindow of the current tooltip.

[transfer none]

Since: 2.12

### gtk_widget_set_tooltip_window ()

    void
    gtk_widget_set_tooltip_window (GtkWidget *widget,
                                   GtkWindow *custom_window);

Replaces the default, usually yellow, window used for displaying tooltips with `custom_window` . GTK+ will take care of showing and hiding `custom_window` at the right moment, to behave likewise as the default tooltip window. If `custom_window` is `NULL`, the default tooltip window will be used.

If the custom window should have the default theming it needs to have the name “gtk-tooltip”, see `gtk_widget_set_name()`.

#### Parameters

widget | a GtkWidget |
custom_window | a GtkWindow, or `NULL`. | [allow-none]

Since: 2.12

### gtk_widget_get_has_tooltip ()

    gboolean
    gtk_widget_get_has_tooltip (GtkWidget *widget);

Returns the current value of the has-tooltip property. See “has-tooltip” for more information.

#### Parameters

widget | a GtkWidget |

#### Returns

current value of has-tooltip on `widget` .

Since: 2.12

### gtk_widget_set_has_tooltip ()

    void
    gtk_widget_set_has_tooltip (GtkWidget *widget,
                                gboolean has_tooltip);

Sets the has-tooltip property on `widget` to `has_tooltip` . See “has-tooltip” for more information.

#### Parameters

widget | a GtkWidget |
has_tooltip | whether or not `widget` has a tooltip. |

Since: 2.12

### gtk_widget_trigger_tooltip_query ()

    void
    gtk_widget_trigger_tooltip_query (GtkWidget *widget);

Triggers a tooltip query on the display where the toplevel of `widget` is located. See `gtk_tooltip_trigger_tooltip_query()` for more information.

#### Parameters

widget | a GtkWidget |

Since: 2.12

### gtk_widget_get_window ()

    GdkWindow *
    gtk_widget_get_window (GtkWidget *widget);

Returns the widget’s window if it is realized, `NULL` otherwise

#### Parameters

widget | a GtkWidget |

#### Returns

`widget` ’s window.

[transfer none][nullable]

Since: 2.14

### gtk_widget_register_window ()

    void
    gtk_widget_register_window (GtkWidget *widget,
                                GdkWindow *window);

Registers a GdkWindow with the widget and sets it up so that the widget receives events for it. Call `gtk_widget_unregister_window()` when destroying the window.

Before 3.8 you needed to call `gdk_window_set_user_data()` directly to set this up. This is now deprecated and you should use `gtk_widget_register_window()` instead. Old code will keep working as is, although some new features like transparency might not work perfectly.

#### Parameters

widget | a GtkWidget |
window | a GdkWindow |

Since: 3.8

### gtk_widget_unregister_window ()

    void
    gtk_widget_unregister_window (GtkWidget *widget,
                                  GdkWindow *window);

Unregisters a GdkWindow from the widget that was previously set up with `gtk_widget_register_window()`. You need to call this when the window is no longer used by the widget, such as when you destroy it.

#### Parameters

widget | a GtkWidget |
window | a GdkWindow |

Since: 3.8

### gtk_cairo_should_draw_window ()

    gboolean
    gtk_cairo_should_draw_window (cairo_t *cr,
                                  GdkWindow *window);

This function is supposed to be called in “draw” implementations for widgets that support multiple windows. `cr` must be untransformed from invoking of the draw function. This function will return `TRUE` if the contents of the given `window` are supposed to be drawn and `FALSE` otherwise. Note that when the drawing was not initiated by the windowing system this function will return `TRUE` for all windows, so you need to draw the bottommost window first. Also, do not use “else if” statements to check which window should be drawn.

#### Parameters

cr | a cairo context |
window | the window to check. `window` may not be an input-only window. |

#### Returns

`TRUE` if `window` should be drawn

Since: 3.0

### gtk_cairo_transform_to_window ()

    void
    gtk_cairo_transform_to_window (cairo_t *cr,
                                   GtkWidget *widget,
                                   GdkWindow *window);

Transforms the given cairo context `cr` that from `widget` -relative coordinates to `window` -relative coordinates. If the `widget` ’s window is not an ancestor of `window` , no modification will be applied.

This is the inverse to the transformation GTK applies when preparing an expose event to be emitted with the “draw” signal. It is intended to help porting multiwindow widgets from GTK+ 2 to the rendering architecture of GTK+ 3.

#### Parameters

cr | the cairo context to transform |
widget | the widget the context is currently centered for |
window | the window to transform the context to |

Since: 3.0

### gtk_widget_get_allocated_width ()

    int
    gtk_widget_get_allocated_width (GtkWidget *widget);

Returns the width that has currently been allocated to `widget` . This function is intended to be used when implementing handlers for the “draw” function.

#### Parameters

widget | the widget to query |

#### Returns

the width of the `widget`

### gtk_widget_get_allocated_height ()

    int
    gtk_widget_get_allocated_height (GtkWidget *widget);

Returns the height that has currently been allocated to `widget` . This function is intended to be used when implementing handlers for the “draw” function.

#### Parameters

widget | the widget to query |

#### Returns

the height of the `widget`

### gtk_widget_get_allocation ()

    void
    gtk_widget_get_allocation (GtkWidget *widget,
                               GtkAllocation *allocation);

Retrieves the widget’s allocation.

Note, when implementing a GtkContainer: a widget’s allocation will be its “adjusted” allocation, that is, the widget’s parent container typically calls `gtk_widget_size_allocate()` with an allocation, and that allocation is then adjusted (to handle margin and alignment for example) before assignment to the widget. `gtk_widget_get_allocation()` returns the adjusted allocation that was actually assigned to the widget. The adjusted allocation is guaranteed to be completely contained within the `gtk_widget_size_allocate()` allocation, however. So a GtkContainer is guaranteed that its children stay inside the assigned bounds, but not that they have exactly the bounds the container assigned. There is no way to get the original allocation assigned by `gtk_widget_size_allocate()`, since it isn’t stored; if a container implementation needs that information it will have to track it itself.

#### Parameters

widget | a GtkWidget |
allocation | a pointer to a GtkAllocation to copy to. | [out]

Since: 2.18

### gtk_widget_set_allocation ()

    void
    gtk_widget_set_allocation (GtkWidget *widget,
                               const GtkAllocation *allocation);

Sets the widget’s allocation. This should not be used directly, but from within a widget’s size_allocate method.

The allocation set should be the “adjusted” or actual allocation. If you’re implementing a GtkContainer, you want to use `gtk_widget_size_allocate()` instead of `gtk_widget_set_allocation()`. The GtkWidgetClass::adjust_size_allocation virtual method adjusts the allocation inside `gtk_widget_size_allocate()` to create an adjusted allocation.

#### Parameters

widget | a GtkWidget |
allocation | a pointer to a GtkAllocation to copy from |

Since: 2.18

### gtk_widget_get_allocated_baseline ()

    int
    gtk_widget_get_allocated_baseline (GtkWidget *widget);

Returns the baseline that has currently been allocated to `widget` . This function is intended to be used when implementing handlers for the “draw” function, and when allocating child widgets in “size_allocate”.

#### Parameters

widget | the widget to query |

#### Returns

the baseline of the `widget` , or -1 if none

Since: 3.10

### gtk_widget_get_allocated_size ()

    void
    gtk_widget_get_allocated_size (GtkWidget *widget,
                                   GtkAllocation *allocation,
                                   int *baseline);

Retrieves the widget’s allocated size.

This function returns the last values passed to `gtk_widget_size_allocate_with_baseline()`. The value differs from the size returned in `gtk_widget_get_allocation()` in that functions like `gtk_widget_set_halign()` can adjust the allocation, but not the value returned by this function.

If a widget is not visible, its allocated size is 0.

#### Parameters

widget | a GtkWidget |
allocation | a pointer to a GtkAllocation to copy to. | [out]
baseline | a pointer to an integer to copy to. | [out][allow-none]

Since: 3.20

### gtk_widget_get_clip ()

    void
    gtk_widget_get_clip (GtkWidget *widget,
                         GtkAllocation *clip);

Retrieves the widget’s clip area.

The clip area is the area in which all of `widget` 's drawing will happen. Other toolkits call it the bounding box.

Historically, in GTK+ the clip area has been equal to the allocation retrieved via `gtk_widget_get_allocation()`.

#### Parameters

widget | a GtkWidget |
clip | a pointer to a GtkAllocation to copy to. | [out]

Since: 3.14

### gtk_widget_set_clip ()

    void
    gtk_widget_set_clip (GtkWidget *widget,
                         const GtkAllocation *clip);

Sets the widget’s clip. This must not be used directly, but from within a widget’s size_allocate method. It must be called after `gtk_widget_set_allocation()` (or after chaining up to the parent class), because that function resets the clip.

The clip set should be the area that `widget` draws on. If `widget` is a GtkContainer, the area must contain all children's clips.

If this function is not called by `widget` during a ::size-allocate handler, the clip will be set to `widget` 's allocation.

#### Parameters

widget | a GtkWidget |
clip | a pointer to a GtkAllocation to copy from |

Since: 3.14

### gtk_widget_get_app_paintable ()

    gboolean
    gtk_widget_get_app_paintable (GtkWidget *widget);

Determines whether the application intends to draw on the widget in an “draw” handler.

See `gtk_widget_set_app_paintable()`

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget is app paintable

Since: 2.18

### gtk_widget_get_can_default ()

    gboolean
    gtk_widget_get_can_default (GtkWidget *widget);

Determines whether `widget` can be a default widget. See `gtk_widget_set_can_default()`.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if `widget` can be a default widget, `FALSE` otherwise

Since: 2.18

### gtk_widget_set_can_default ()

    void
    gtk_widget_set_can_default (GtkWidget *widget,
                                gboolean can_default);

Specifies whether `widget` can be a default widget. See `gtk_widget_grab_default()` for details about the meaning of “default”.

#### Parameters

widget | a GtkWidget |
can_default | whether or not `widget` can be a default widget. |

Since: 2.18

### gtk_widget_get_can_focus ()

    gboolean
    gtk_widget_get_can_focus (GtkWidget *widget);

Determines whether `widget` can own the input focus. See `gtk_widget_set_can_focus()`.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if `widget` can own the input focus, `FALSE` otherwise

Since: 2.18

### gtk_widget_set_can_focus ()

    void
    gtk_widget_set_can_focus (GtkWidget *widget,
                              gboolean can_focus);

Specifies whether `widget` can own the input focus. See `gtk_widget_grab_focus()` for actually setting the input focus on a widget.

#### Parameters

widget | a GtkWidget |
can_focus | whether or not `widget` can own the input focus. |

Since: 2.18

### gtk_widget_get_focus_on_click ()

    gboolean
    gtk_widget_get_focus_on_click (GtkWidget *widget);

Returns whether the widget should grab focus when it is clicked with the mouse. See `gtk_widget_set_focus_on_click()`.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget should grab focus when it is clicked with the mouse.

Since: 3.20

### gtk_widget_set_focus_on_click ()

    void
    gtk_widget_set_focus_on_click (GtkWidget *widget,
                                   gboolean focus_on_click);

Sets whether the widget should grab focus when it is clicked with the mouse. Making mouse clicks not grab focus is useful in places like toolbars where you don’t want the keyboard focus removed from the main area of the application.

#### Parameters

widget | a GtkWidget |
focus_on_click | whether the widget should grab focus when clicked with the mouse |

Since: 3.20

### gtk_widget_get_double_buffered ()

    gboolean
    gtk_widget_get_double_buffered (GtkWidget *widget);

`gtk_widget_get_double_buffered` is deprecated and should not be used in newly-written code.

Determines whether the widget is double buffered.

See `gtk_widget_set_double_buffered()`

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget is double buffered

Since: 2.18

### gtk_widget_get_has_window ()

    gboolean
    gtk_widget_get_has_window (GtkWidget *widget);

Determines whether `widget` has a GdkWindow of its own. See `gtk_widget_set_has_window()`.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if `widget` has a window, `FALSE` otherwise

Since: 2.18

### gtk_widget_set_has_window ()

    void
    gtk_widget_set_has_window (GtkWidget *widget,
                               gboolean has_window);

Specifies whether `widget` has a GdkWindow of its own. Note that all realized widgets have a non-`NULL` “window” pointer (`gtk_widget_get_window()` never returns a `NULL` window when a widget is realized), but for many of them it’s actually the GdkWindow of one of its parent widgets. Widgets that do not create a `window` for themselves in “realize” must announce this by calling this function with `has_window` = `FALSE`.

This function should only be called by widget implementations, and they should call it in their `init()` function.

#### Parameters

widget | a GtkWidget |
has_window | whether or not `widget` has a window. |

Since: 2.18

### gtk_widget_get_sensitive ()

    gboolean
    gtk_widget_get_sensitive (GtkWidget *widget);

Returns the widget’s sensitivity (in the sense of returning the value that has been set using `gtk_widget_set_sensitive()`).

The effective sensitivity of a widget is however determined by both its own and its parent widget’s sensitivity. See `gtk_widget_is_sensitive()`.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget is sensitive

Since: 2.18

### gtk_widget_is_sensitive ()

    gboolean
    gtk_widget_is_sensitive (GtkWidget *widget);

Returns the widget’s effective sensitivity, which means it is sensitive itself and also its parent widget is sensitive

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget is effectively sensitive

Since: 2.18

### gtk_widget_get_state ()

    GtkStateType
    gtk_widget_get_state (GtkWidget *widget);

`gtk_widget_get_state` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gtk_widget_get_state_flags()` instead.

Returns the widget’s state. See `gtk_widget_set_state()`.

#### Parameters

widget | a GtkWidget |

#### Returns

the state of `widget` .

Since: 2.18

### gtk_widget_get_visible ()

    gboolean
    gtk_widget_get_visible (GtkWidget *widget);

Determines whether the widget is visible. If you want to take into account whether the widget’s parent is also marked as visible, use `gtk_widget_is_visible()` instead.

This function does not check if the widget is obscured in any way.

See `gtk_widget_set_visible()`.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget is visible

Since: 2.18

### gtk_widget_is_visible ()

    gboolean
    gtk_widget_is_visible (GtkWidget *widget);

Determines whether the widget and all its parents are marked as visible.

This function does not check if the widget is obscured in any way.

See also `gtk_widget_get_visible()` and `gtk_widget_set_visible()`

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget and all its parents are visible

Since: 3.8

### gtk_widget_set_visible ()

    void
    gtk_widget_set_visible (GtkWidget *widget,
                            gboolean visible);

Sets the visibility state of `widget` . Note that setting this to `TRUE` doesn’t mean the widget is actually viewable, see `gtk_widget_get_visible()`.

This function simply calls `gtk_widget_show()` or `gtk_widget_hide()` but is nicer to use when the visibility of the widget depends on some condition.

#### Parameters

widget | a GtkWidget |
visible | whether the widget should be shown or not |

Since: 2.18

### gtk_widget_set_state_flags ()

    void
    gtk_widget_set_state_flags (GtkWidget *widget,
                                GtkStateFlags flags,
                                gboolean clear);

This function is for use in widget implementations. Turns on flag values in the current widget state (insensitive, prelighted, etc.).

This function accepts the values `GTK_STATE_FLAG_DIR_LTR` and `GTK_STATE_FLAG_DIR_RTL` but ignores them. If you want to set the widget's direction, use `gtk_widget_set_direction()`.

It is worth mentioning that any other state than `GTK_STATE_FLAG_INSENSITIVE`, will be propagated down to all non-internal children if `widget` is a GtkContainer, while `GTK_STATE_FLAG_INSENSITIVE` itself will be propagated down to all GtkContainer children by different means than turning on the state flag down the hierarchy, both `gtk_widget_get_state_flags()` and `gtk_widget_is_sensitive()` will make use of these.

#### Parameters

widget | a GtkWidget |
flags | State flags to turn on |
clear | Whether to clear state before turning on `flags` |

Since: 3.0

### gtk_widget_unset_state_flags ()

    void
    gtk_widget_unset_state_flags (GtkWidget *widget,
                                  GtkStateFlags flags);

This function is for use in widget implementations. Turns off flag values for the current widget state (insensitive, prelighted, etc.). See `gtk_widget_set_state_flags()`.

#### Parameters

widget | a GtkWidget |
flags | State flags to turn off |

Since: 3.0

### gtk_widget_get_state_flags ()

    GtkStateFlags
    gtk_widget_get_state_flags (GtkWidget *widget);

Returns the widget state as a flag set. It is worth mentioning that the effective `GTK_STATE_FLAG_INSENSITIVE` state will be returned, that is, also based on parent insensitivity, even if `widget` itself is sensitive.

Also note that if you are looking for a way to obtain the GtkStateFlags to pass to a GtkStyleContext method, you should look at `gtk_style_context_get_state()`.

#### Parameters

widget | a GtkWidget |

#### Returns

The state flags for widget

Since: 3.0

### gtk_widget_has_default ()

    gboolean
    gtk_widget_has_default (GtkWidget *widget);

Determines whether `widget` is the current default widget within its toplevel. See `gtk_widget_set_can_default()`.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if `widget` is the current default widget within its toplevel, `FALSE` otherwise

Since: 2.18

### gtk_widget_has_focus ()

    gboolean
    gtk_widget_has_focus (GtkWidget *widget);

Determines if the widget has the global input focus. See `gtk_widget_is_focus()` for the difference between having the global input focus, and only having the focus within a toplevel.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget has the global input focus.

Since: 2.18

### gtk_widget_has_visible_focus ()

    gboolean
    gtk_widget_has_visible_focus (GtkWidget *widget);

Determines if the widget should show a visible indication that it has the global input focus. This is a convenience function for use in ::draw handlers that takes into account whether focus indication should currently be shown in the toplevel window of `widget` . See `gtk_window_get_focus_visible()` for more information about focus indication.

To find out if the widget has the global input focus, use `gtk_widget_has_focus()`.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget should display a “focus rectangle”

Since: 3.2

### gtk_widget_has_grab ()

    gboolean
    gtk_widget_has_grab (GtkWidget *widget);

Determines whether the widget is currently grabbing events, so it is the only widget receiving input events (keyboard and mouse).

See also `gtk_grab_add()`.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget is in the grab_widgets stack

Since: 2.18

### gtk_widget_has_rc_style ()

    gboolean
    gtk_widget_has_rc_style (GtkWidget *widget);

`gtk_widget_has_rc_style` has been deprecated since version 3.0 and should not be used in newly-written code.

Use GtkStyleContext instead

Determines if the widget style has been looked up through the rc mechanism.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget has been looked up through the rc mechanism, `FALSE` otherwise.

Since: 2.20

### gtk_widget_is_drawable ()

    gboolean
    gtk_widget_is_drawable (GtkWidget *widget);

Determines whether `widget` can be drawn to. A widget can be drawn to if it is mapped and visible.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if `widget` is drawable, `FALSE` otherwise

Since: 2.18

### gtk_widget_is_toplevel ()

    gboolean
    gtk_widget_is_toplevel (GtkWidget *widget);

Determines whether `widget` is a toplevel widget.

Currently only GtkWindow and GtkInvisible (and out-of-process GtkPlugs) are toplevel widgets. Toplevel widgets have no parent widget.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if `widget` is a toplevel, `FALSE` otherwise

Since: 2.18

### gtk_widget_set_window ()

    void
    gtk_widget_set_window (GtkWidget *widget,
                           GdkWindow *window);

Sets a widget’s window. This function should only be used in a widget’s “realize” implementation. The `window` passed is usually either new window created with `gdk_window_new()`, or the window of its parent widget as returned by `gtk_widget_get_parent_window()`.

Widgets must indicate whether they will create their own GdkWindow by calling `gtk_widget_set_has_window()`. This is usually done in the widget’s `init()` function.

Note that this function does not add any reference to `window` .

#### Parameters

widget | a GtkWidget |
window | a GdkWindow. | [transfer full]

Since: 2.18

### gtk_widget_set_receives_default ()

    void
    gtk_widget_set_receives_default (GtkWidget *widget,
                                     gboolean receives_default);

Specifies whether `widget` will be treated as the default widget within its toplevel when it has the focus, even if another widget is the default.

See `gtk_widget_grab_default()` for details about the meaning of “default”.

#### Parameters

widget | a GtkWidget |
receives_default | whether or not `widget` can be a default widget. |

Since: 2.18

### gtk_widget_get_receives_default ()

    gboolean
    gtk_widget_get_receives_default (GtkWidget *widget);

Determines whether `widget` is always treated as the default widget within its toplevel when it has the focus, even if another widget is the default.

See `gtk_widget_set_receives_default()`.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if `widget` acts as the default widget when focused, `FALSE` otherwise

Since: 2.18

### gtk_widget_set_support_multidevice ()

    void
    gtk_widget_set_support_multidevice (GtkWidget *widget,
                                        gboolean support_multidevice);

Enables or disables multiple pointer awareness. If this setting is `TRUE`, `widget` will start receiving multiple, per device enter/leave events. Note that if custom GdkWindows are created in “realize”, `gdk_window_set_support_multidevice()` will have to be called manually on them.

#### Parameters

widget | a GtkWidget |
support_multidevice | `TRUE` to support input from multiple devices. |

Since: 3.0

### gtk_widget_get_support_multidevice ()

    gboolean
    gtk_widget_get_support_multidevice (GtkWidget *widget);

Returns `TRUE` if `widget` is multiple pointer aware. See `gtk_widget_set_support_multidevice()` for more information.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if `widget` is multidevice aware.

### gtk_widget_set_realized ()

    void
    gtk_widget_set_realized (GtkWidget *widget,
                             gboolean realized);

Marks the widget as being realized. This function must only be called after all GdkWindows for the `widget` have been created and registered.

This function should only ever be called in a derived widget's “realize” or “unrealize” implementation.

#### Parameters

widget | a GtkWidget |
realized | `TRUE` to mark the widget as realized |

Since: 2.20

### gtk_widget_get_realized ()

    gboolean
    gtk_widget_get_realized (GtkWidget *widget);

Determines whether `widget` is realized.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if `widget` is realized, `FALSE` otherwise

Since: 2.20

### gtk_widget_set_mapped ()

    void
    gtk_widget_set_mapped (GtkWidget *widget,
                           gboolean mapped);

Marks the widget as being realized.

This function should only ever be called in a derived widget's “map” or “unmap” implementation.

#### Parameters

widget | a GtkWidget |
mapped | `TRUE` to mark the widget as mapped |

Since: 2.20

### gtk_widget_get_mapped ()

    gboolean
    gtk_widget_get_mapped (GtkWidget *widget);

Whether the widget is mapped.

#### Parameters

widget | a GtkWidget |

#### Returns

`TRUE` if the widget is mapped, `FALSE` otherwise.

Since: 2.20

### gtk_widget_get_requisition ()

    void
    gtk_widget_get_requisition (GtkWidget *widget,
                                GtkRequisition *requisition);

`gtk_widget_get_requisition` has been deprecated since version 3.0 and should not be used in newly-written code.

The GtkRequisition cache on the widget was removed, If you need to cache sizes across requests and allocations, add an explicit cache to the widget in question instead.

Retrieves the widget’s requisition.

This function should only be used by widget implementations in order to figure whether the widget’s requisition has actually changed after some internal state change (so that they can call `gtk_widget_queue_resize()` instead of `gtk_widget_queue_draw()`).

Normally, `gtk_widget_size_request()` should be used.

#### Parameters

widget | a GtkWidget |
requisition | a pointer to a GtkRequisition to copy to. | [out]

Since: 2.20

### gtk_widget_device_is_shadowed ()

    gboolean
    gtk_widget_device_is_shadowed (GtkWidget *widget,
                                   GdkDevice *device);

Returns `TRUE` if `device` has been shadowed by a GTK+ device grab on another widget, so it would stop sending events to `widget` . This may be used in the “grab-notify” signal to check for specific devices. See `gtk_device_grab_add()`.

#### Parameters

widget | a GtkWidget |
device | a GdkDevice |

#### Returns

`TRUE` if there is an ongoing grab on `device` by another GtkWidget than `widget` .

Since: 3.0

### gtk_widget_get_modifier_mask ()

    GdkModifierType
    gtk_widget_get_modifier_mask (GtkWidget *widget,
                                  GdkModifierIntent intent);

Returns the modifier mask the `widget` ’s windowing system backend uses for a particular purpose.

See `gdk_keymap_get_modifier_mask()`.

#### Parameters

widget | a GtkWidget |
intent | the use case for the modifier mask |

#### Returns

the modifier mask used for `intent` .

Since: 3.4

### gtk_widget_insert_action_group ()

    void
    gtk_widget_insert_action_group (GtkWidget *widget,
                                    const gchar *name,
                                    GActionGroup *group);

Inserts `group` into `widget` . Children of `widget` that implement GtkActionable can then be associated with actions in `group` by setting their “action-name” to `prefix` .`action-name`.

If `group` is `NULL`, a previously inserted group for `name` is removed from `widget` .

#### Parameters

widget | a GtkWidget |
name | the prefix for actions in `group` |
group | a GActionGroup, or `NULL`. | [allow-none]

Since: 3.6

### gtk_widget_get_opacity ()

    double
    gtk_widget_get_opacity (GtkWidget *widget);

Fetches the requested opacity for this widget. See `gtk_widget_set_opacity()`.

#### Parameters

widget | a GtkWidget |

#### Returns

the requested opacity for this widget.

Since: 3.8

### gtk_widget_set_opacity ()

    void
    gtk_widget_set_opacity (GtkWidget *widget,
                            double opacity);

Request the `widget` to be rendered partially transparent, with opacity 0 being fully transparent and 1 fully opaque. (Opacity values are clamped to the [0,1] range.). This works on both toplevel widget, and child widgets, although there are some limitations:

For toplevel widgets this depends on the capabilities of the windowing system. On X11 this has any effect only on X screens with a compositing manager running. See `gtk_widget_is_composited()`. On Windows it should work always, although setting a window’s opacity after the window has been shown causes it to flicker once on Windows.

For child widgets it doesn’t work if any affected widget has a native window, or disables double buffering.

#### Parameters

widget | a GtkWidget |
opacity | desired opacity, between 0 and 1 |

Since: 3.8

### gtk_widget_list_action_prefixes ()

    const gchar **
    gtk_widget_list_action_prefixes (GtkWidget *widget);

Retrieves a `NULL`-terminated array of strings containing the prefixes of GActionGroup's available to `widget` .

#### Parameters

widget | A GtkWidget |

#### Returns

a `NULL`-terminated array of strings.

[transfer container]

Since: 3.16

### gtk_widget_get_action_group ()

    GActionGroup *
    gtk_widget_get_action_group (GtkWidget *widget,
                                 const gchar *prefix);

Retrieves the GActionGroup that was registered using `prefix` . The resulting GActionGroup may have been registered to `widget` or any GtkWidget in its ancestry.

If no action group was found matching `prefix` , then `NULL` is returned.

#### Parameters

widget | A GtkWidget |
prefix | The “prefix” of the action group. |

#### Returns

A GActionGroup or `NULL`.

[transfer none][nullable]

Since: 3.16

### gtk_widget_get_path ()

    GtkWidgetPath *
    gtk_widget_get_path (GtkWidget *widget);

Returns the GtkWidgetPath representing `widget` , if the widget is not connected to a toplevel widget, a partial path will be created.

#### Parameters

widget | a GtkWidget |

#### Returns

The GtkWidgetPath representing `widget` .

[transfer none]

### gtk_widget_get_style_context ()

    GtkStyleContext *
    gtk_widget_get_style_context (GtkWidget *widget);

Returns the style context associated to `widget` . The returned object is guaranteed to be the same for the lifetime of `widget` .

#### Parameters

widget | a GtkWidget |

#### Returns

a GtkStyleContext. This memory is owned by `widget` and must not be freed.

[transfer none]

### gtk_widget_reset_style ()

    void
    gtk_widget_reset_style (GtkWidget *widget);

Updates the style context of `widget` and all descendants by updating its widget path. GtkContainers may want to use this on a child when reordering it in a way that a different style might apply to it. See also `gtk_container_get_path_for_child()`.

#### Parameters

widget | a GtkWidget |

Since: 3.0

### gtk_widget_class_get_css_name ()

    const char *
    gtk_widget_class_get_css_name (GtkWidgetClass *widget_class);

Gets the name used by this class for matching in CSS code. See `gtk_widget_class_set_css_name()` for details.

#### Parameters

widget_class | class to set the name on |

#### Returns

the CSS name of the given class

Since: 3.20

### gtk_widget_class_set_css_name ()

    void
    gtk_widget_class_set_css_name (GtkWidgetClass *widget_class,
                                   const char *name);

Sets the name to be used for CSS matching of widgets.

If this function is not called for a given class, the name of the parent class is used.

#### Parameters

widget_class | class to set the name on |
name | name to use |

Since: 3.20

### gtk_requisition_new ()

    GtkRequisition *
    gtk_requisition_new (void);

Allocates a new GtkRequisition and initializes its elements to zero.

#### Returns

a new empty GtkRequisition. The newly allocated GtkRequisition should be freed with `gtk_requisition_free()`.

Since: 3.0

### gtk_requisition_copy ()

    GtkRequisition *
    gtk_requisition_copy (const GtkRequisition *requisition);

Copies a GtkRequisition.

#### Parameters

requisition | a GtkRequisition |

#### Returns

a copy of `requisition`

### gtk_requisition_free ()

    void
    gtk_requisition_free (GtkRequisition *requisition);

Frees a GtkRequisition.

#### Parameters

requisition | a GtkRequisition |

### gtk_widget_get_preferred_height ()

    void
    gtk_widget_get_preferred_height (GtkWidget *widget,
                                     gint *minimum_height,
                                     gint *natural_height);

Retrieves a widget’s initial minimum and natural height.

This call is specific to width-for-height requests.

The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any GtkSizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.

#### Parameters

widget | a GtkWidget instance |
minimum_height | location to store the minimum height, or `NULL`. | [out][allow-none]
natural_height | location to store the natural height, or `NULL`. | [out][allow-none]

Since: 3.0

### gtk_widget_get_preferred_width ()

    void
    gtk_widget_get_preferred_width (GtkWidget *widget,
                                    gint *minimum_width,
                                    gint *natural_width);

Retrieves a widget’s initial minimum and natural width.

This call is specific to height-for-width requests.

The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any GtkSizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.

#### Parameters

widget | a GtkWidget instance |
minimum_width | location to store the minimum width, or `NULL`. | [out][allow-none]
natural_width | location to store the natural width, or `NULL`. | [out][allow-none]

Since: 3.0

### gtk_widget_get_preferred_height_for_width ()

    void
    gtk_widget_get_preferred_height_for_width
                                   (GtkWidget *widget,
                                    gint width,
                                    gint *minimum_height,
                                    gint *natural_height);

Retrieves a widget’s minimum and natural height if it would be given the specified `width` .

The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any GtkSizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.

#### Parameters

widget | a GtkWidget instance |
width | the width which is available for allocation |
minimum_height | location for storing the minimum height, or `NULL`. | [out][allow-none]
natural_height | location for storing the natural height, or `NULL`. | [out][allow-none]

Since: 3.0

### gtk_widget_get_preferred_width_for_height ()

    void
    gtk_widget_get_preferred_width_for_height
                                   (GtkWidget *widget,
                                    gint height,
                                    gint *minimum_width,
                                    gint *natural_width);

Retrieves a widget’s minimum and natural width if it would be given the specified `height` .

The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any GtkSizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.

#### Parameters

widget | a GtkWidget instance |
height | the height which is available for allocation |
minimum_width | location for storing the minimum width, or `NULL`. | [out][allow-none]
natural_width | location for storing the natural width, or `NULL`. | [out][allow-none]

Since: 3.0

### gtk_widget_get_preferred_height_and_baseline_for_width ()

    void
    gtk_widget_get_preferred_height_and_baseline_for_width
                                   (GtkWidget *widget,
                                    gint width,
                                    gint *minimum_height,
                                    gint *natural_height,
                                    gint *minimum_baseline,
                                    gint *natural_baseline);

Retrieves a widget’s minimum and natural height and the corresponding baselines if it would be given the specified `width` , or the default height if `width` is -1. The baselines may be -1 which means that no baseline is requested for this widget.

The returned request will be modified by the GtkWidgetClass::adjust_size_request and GtkWidgetClass::adjust_baseline_request virtual methods and by any GtkSizeGroups that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.

#### Parameters

widget | a GtkWidget instance |
width | the width which is available for allocation, or -1 if none |
minimum_height | location for storing the minimum height, or `NULL`. | [out][allow-none]
natural_height | location for storing the natural height, or `NULL`. | [out][allow-none]
minimum_baseline | location for storing the baseline for the minimum height, or `NULL`. | [out][allow-none]
natural_baseline | location for storing the baseline for the natural height, or `NULL`. | [out][allow-none]

Since: 3.10

### gtk_widget_get_request_mode ()

    GtkSizeRequestMode
    gtk_widget_get_request_mode (GtkWidget *widget);

Gets whether the widget prefers a height-for-width layout or a width-for-height layout.

GtkBin widgets generally propagate the preference of their child, container widgets need to request something either in context of their children or in context of their allocation capabilities.

#### Parameters

widget | a GtkWidget instance |

#### Returns

The GtkSizeRequestMode preferred by `widget` .

Since: 3.0

### gtk_widget_get_preferred_size ()

    void
    gtk_widget_get_preferred_size (GtkWidget *widget,
                                   GtkRequisition *minimum_size,
                                   GtkRequisition *natural_size);

Retrieves the minimum and natural size of a widget, taking into account the widget’s preference for height-for-width management.

This is used to retrieve a suitable size by container widgets which do not impose any restrictions on the child placement. It can be used to deduce toplevel window and menu sizes as well as child widgets in free-form containers such as GtkLayout.

Handle with care. Note that the natural height of a height-for-width widget will generally be a smaller size than the minimum height, since the required height for the natural width is generally smaller than the required height for the minimum width.

Use `gtk_widget_get_preferred_height_and_baseline_for_width()` if you want to support baseline alignment.

#### Parameters

widget | a GtkWidget instance |
minimum_size | location for storing the minimum size, or `NULL`. | [out][allow-none]
natural_size | location for storing the natural size, or `NULL`. | [out][allow-none]

Since: 3.0

### gtk_distribute_natural_allocation ()

    gint
    gtk_distribute_natural_allocation (gint extra_space,
                                       guint n_requested_sizes,
                                       GtkRequestedSize *sizes);

Distributes `extra_space` to child `sizes` by bringing smaller children up to natural size first.

The remaining space will be added to the `minimum_size` member of the GtkRequestedSize struct. If all sizes reach their natural size then the remaining space is returned.

#### Parameters

extra_space | Extra space to redistribute among children after subtracting minimum sizes and any child padding from the overall allocation |
n_requested_sizes | Number of requests to fit into the allocation |
sizes | An array of structs with a client pointer and a minimum/natural size in the orientation of the allocation. |

#### Returns

The remainder of `extra_space` after redistributing space to `sizes` .

### gtk_widget_get_halign ()

    GtkAlign
    gtk_widget_get_halign (GtkWidget *widget);

Gets the value of the “halign” property.

For backwards compatibility reasons this method will never return `GTK_ALIGN_BASELINE`, but instead it will convert it to `GTK_ALIGN_FILL`. Baselines are not supported for horizontal alignment.

#### Parameters

widget | a GtkWidget |

#### Returns

the horizontal alignment of `widget`

### gtk_widget_set_halign ()

    void
    gtk_widget_set_halign (GtkWidget *widget,
                           GtkAlign align);

Sets the horizontal alignment of `widget` . See the “halign” property.

#### Parameters

widget | a GtkWidget |
align | the horizontal alignment |

### gtk_widget_get_valign ()

    GtkAlign
    gtk_widget_get_valign (GtkWidget *widget);

Gets the value of the “valign” property.

For backwards compatibility reasons this method will never return `GTK_ALIGN_BASELINE`, but instead it will convert it to `GTK_ALIGN_FILL`. If your widget want to support baseline aligned children it must use `gtk_widget_get_valign_with_baseline()`, or `g_object_get (widget, "valign", &value, NULL)`, which will also report the true value.

#### Parameters

widget | a GtkWidget |

#### Returns

the vertical alignment of `widget` , ignoring baseline alignment

### gtk_widget_get_valign_with_baseline ()

    GtkAlign
    gtk_widget_get_valign_with_baseline (GtkWidget *widget);

Gets the value of the “valign” property, including `GTK_ALIGN_BASELINE`.

#### Parameters

widget | a GtkWidget |

#### Returns

the vertical alignment of `widget`

Since: 3.10

### gtk_widget_set_valign ()

    void
    gtk_widget_set_valign (GtkWidget *widget,
                           GtkAlign align);

Sets the vertical alignment of `widget` . See the “valign” property.

#### Parameters

widget | a GtkWidget |
align | the vertical alignment |

### gtk_widget_get_margin_left ()

    gint
    gtk_widget_get_margin_left (GtkWidget *widget);

`gtk_widget_get_margin_left` has been deprecated since version 3.12 and should not be used in newly-written code.

Use `gtk_widget_get_margin_start()` instead.

Gets the value of the “margin-left” property.

#### Parameters

widget | a GtkWidget |

#### Returns

The left margin of `widget`

Since: 3.0

### gtk_widget_set_margin_left ()

    void
    gtk_widget_set_margin_left (GtkWidget *widget,
                                gint margin);

`gtk_widget_set_margin_left` has been deprecated since version 3.12 and should not be used in newly-written code.

Use `gtk_widget_set_margin_start()` instead.

Sets the left margin of `widget` . See the “margin-left” property.

#### Parameters

widget | a GtkWidget |
margin | the left margin |

Since: 3.0

### gtk_widget_get_margin_right ()

    gint
    gtk_widget_get_margin_right (GtkWidget *widget);

`gtk_widget_get_margin_right` has been deprecated since version 3.12 and should not be used in newly-written code.

Use `gtk_widget_get_margin_end()` instead.

Gets the value of the “margin-right” property.

#### Parameters

widget | a GtkWidget |

#### Returns

The right margin of `widget`

Since: 3.0

### gtk_widget_set_margin_right ()

    void
    gtk_widget_set_margin_right (GtkWidget *widget,
                                 gint margin);

`gtk_widget_set_margin_right` has been deprecated since version 3.12 and should not be used in newly-written code.

Use `gtk_widget_set_margin_end()` instead.

Sets the right margin of `widget` . See the “margin-right” property.

#### Parameters

widget | a GtkWidget |
margin | the right margin |

Since: 3.0

### gtk_widget_get_margin_start ()

    gint
    gtk_widget_get_margin_start (GtkWidget *widget);

Gets the value of the “margin-start” property.

#### Parameters

widget | a GtkWidget |

#### Returns

The start margin of `widget`

Since: 3.12

### gtk_widget_set_margin_start ()

    void
    gtk_widget_set_margin_start (GtkWidget *widget,
                                 gint margin);

Sets the start margin of `widget` . See the “margin-start” property.

#### Parameters

widget | a GtkWidget |
margin | the start margin |

Since: 3.12

### gtk_widget_get_margin_end ()

    gint
    gtk_widget_get_margin_end (GtkWidget *widget);

Gets the value of the “margin-end” property.

#### Parameters

widget | a GtkWidget |

#### Returns

The end margin of `widget`

Since: 3.12

### gtk_widget_set_margin_end ()

    void
    gtk_widget_set_margin_end (GtkWidget *widget,
                               gint margin);

Sets the end margin of `widget` . See the “margin-end” property.

#### Parameters

widget | a GtkWidget |
margin | the end margin |

Since: 3.12

### gtk_widget_get_margin_top ()

    gint
    gtk_widget_get_margin_top (GtkWidget *widget);

Gets the value of the “margin-top” property.

#### Parameters

widget | a GtkWidget |

#### Returns

The top margin of `widget`

Since: 3.0

### gtk_widget_set_margin_top ()

    void
    gtk_widget_set_margin_top (GtkWidget *widget,
                               gint margin);

Sets the top margin of `widget` . See the “margin-top” property.

#### Parameters

widget | a GtkWidget |
margin | the top margin |

Since: 3.0

### gtk_widget_get_margin_bottom ()

    gint
    gtk_widget_get_margin_bottom (GtkWidget *widget);

Gets the value of the “margin-bottom” property.

#### Parameters

widget | a GtkWidget |

#### Returns

The bottom margin of `widget`

Since: 3.0

### gtk_widget_set_margin_bottom ()

    void
    gtk_widget_set_margin_bottom (GtkWidget *widget,
                                  gint margin);

Sets the bottom margin of `widget` . See the “margin-bottom” property.

#### Parameters

widget | a GtkWidget |
margin | the bottom margin |

Since: 3.0

### gtk_widget_get_hexpand ()

    gboolean
    gtk_widget_get_hexpand (GtkWidget *widget);

Gets whether the widget would like any available extra horizontal space. When a user resizes a GtkWindow, widgets with expand=TRUE generally receive the extra space. For example, a list or scrollable area or document in your window would often be set to expand.

Containers should use `gtk_widget_compute_expand()` rather than this function, to see whether a widget, or any of its children, has the expand flag set. If any child of a widget wants to expand, the parent may ask to expand also.

This function only looks at the widget’s own hexpand flag, rather than computing whether the entire widget tree rooted at this widget wants to expand.

#### Parameters

widget | the widget |

#### Returns

whether hexpand flag is set

### gtk_widget_set_hexpand ()

    void
    gtk_widget_set_hexpand (GtkWidget *widget,
                            gboolean expand);

Sets whether the widget would like any available extra horizontal space. When a user resizes a GtkWindow, widgets with expand=TRUE generally receive the extra space. For example, a list or scrollable area or document in your window would often be set to expand.

Call this function to set the expand flag if you would like your widget to become larger horizontally when the window has extra room.

By default, widgets automatically expand if any of their children want to expand. (To see if a widget will automatically expand given its current children and state, call `gtk_widget_compute_expand()`. A container can decide how the expandability of children affects the expansion of the container by overriding the compute_expand virtual method on GtkWidget.).

Setting hexpand explicitly with this function will override the automatic expand behavior.

This function forces the widget to expand or not to expand, regardless of children. The override occurs because `gtk_widget_set_hexpand()` sets the hexpand-set property (see `gtk_widget_set_hexpand_set()`) which causes the widget’s hexpand value to be used, rather than looking at children and widget state.

#### Parameters

widget | the widget |
expand | whether to expand |

### gtk_widget_get_hexpand_set ()

    gboolean
    gtk_widget_get_hexpand_set (GtkWidget *widget);

Gets whether `gtk_widget_set_hexpand()` has been used to explicitly set the expand flag on this widget.

If hexpand is set, then it overrides any computed expand value based on child widgets. If hexpand is not set, then the expand value depends on whether any children of the widget would like to expand.

There are few reasons to use this function, but it’s here for completeness and consistency.

#### Parameters

widget | the widget |

#### Returns

whether hexpand has been explicitly set

### gtk_widget_set_hexpand_set ()

    void
    gtk_widget_set_hexpand_set (GtkWidget *widget,
                                gboolean set);

Sets whether the hexpand flag (see `gtk_widget_get_hexpand()`) will be used.

The hexpand-set property will be set automatically when you call `gtk_widget_set_hexpand()` to set hexpand, so the most likely reason to use this function would be to unset an explicit expand flag.

If hexpand is set, then it overrides any computed expand value based on child widgets. If hexpand is not set, then the expand value depends on whether any children of the widget would like to expand.

There are few reasons to use this function, but it’s here for completeness and consistency.

#### Parameters

widget | the widget |
set | value for hexpand-set property |

### gtk_widget_get_vexpand ()

    gboolean
    gtk_widget_get_vexpand (GtkWidget *widget);

Gets whether the widget would like any available extra vertical space.

See `gtk_widget_get_hexpand()` for more detail.

#### Parameters

widget | the widget |

#### Returns

whether vexpand flag is set

### gtk_widget_set_vexpand ()

    void
    gtk_widget_set_vexpand (GtkWidget *widget,
                            gboolean expand);

Sets whether the widget would like any available extra vertical space.

See `gtk_widget_set_hexpand()` for more detail.

#### Parameters

widget | the widget |
expand | whether to expand |

### gtk_widget_get_vexpand_set ()

    gboolean
    gtk_widget_get_vexpand_set (GtkWidget *widget);

Gets whether `gtk_widget_set_vexpand()` has been used to explicitly set the expand flag on this widget.

See `gtk_widget_get_hexpand_set()` for more detail.

#### Parameters

widget | the widget |

#### Returns

whether vexpand has been explicitly set

### gtk_widget_set_vexpand_set ()

    void
    gtk_widget_set_vexpand_set (GtkWidget *widget,
                                gboolean set);

Sets whether the vexpand flag (see `gtk_widget_get_vexpand()`) will be used.

See `gtk_widget_set_hexpand_set()` for more detail.

#### Parameters

widget | the widget |
set | value for vexpand-set property |

### gtk_widget_queue_compute_expand ()

    void
    gtk_widget_queue_compute_expand (GtkWidget *widget);

Mark `widget` as needing to recompute its expand flags. Call this function when setting legacy expand child properties on the child of a container.

See `gtk_widget_compute_expand()`.

#### Parameters

widget | a GtkWidget |

### gtk_widget_compute_expand ()

    gboolean
    gtk_widget_compute_expand (GtkWidget *widget,
                               GtkOrientation orientation);

Computes whether a container should give this widget extra space when possible. Containers should check this, rather than looking at `gtk_widget_get_hexpand()` or `gtk_widget_get_vexpand()`.

This function already checks whether the widget is visible, so visibility does not need to be checked separately. Non-visible widgets are not expanded.

The computed expand value uses either the expand setting explicitly set on the widget itself, or, if none has been explicitly set, the widget may expand if some of its children do.

#### Parameters

widget | the widget |
orientation | expand direction |

#### Returns

whether widget tree rooted here should be expanded

### gtk_widget_init_template ()

    void
    gtk_widget_init_template (GtkWidget *widget);

Creates and initializes child widgets defined in templates. This function must be called in the instance initializer for any class which assigned itself a template using `gtk_widget_class_set_template()`

It is important to call this function in the instance initializer of a GtkWidget subclass and not in `GObject.constructed()` or `GObject.constructor()` for two reasons.

One reason is that generally derived widgets will assume that parent class composite widgets have been created in their instance initializers.

Another reason is that when calling `g_object_new()` on a widget with composite templates, it’s important to build the composite widgets before the construct properties are set. Properties passed to `g_object_new()` should take precedence over properties set in the private template XML.

#### Parameters

widget | a GtkWidget |

Since: 3.10

### gtk_widget_class_set_template ()

    void
    gtk_widget_class_set_template (GtkWidgetClass *widget_class,
                                   GBytes *template_bytes);

This should be called at class initialization time to specify the GtkBuilder XML to be used to extend a widget.

For convenience, `gtk_widget_class_set_template_from_resource()` is also provided.

Note that any class that installs templates must call `gtk_widget_init_template()` in the widget’s instance initializer.

#### Parameters

widget_class | A GtkWidgetClass |
template_bytes | A GBytes holding the GtkBuilder XML |

Since: 3.10

### gtk_widget_class_set_template_from_resource ()

    void
    gtk_widget_class_set_template_from_resource
                                   (GtkWidgetClass *widget_class,
                                    const gchar *resource_name);

A convenience function to call `gtk_widget_class_set_template()`.

Note that any class that installs templates must call `gtk_widget_init_template()` in the widget’s instance initializer.

#### Parameters

widget_class | A GtkWidgetClass |
resource_name | The name of the resource to load the template from |

Since: 3.10

### gtk_widget_get_template_child ()

    GObject *
    gtk_widget_get_template_child (GtkWidget *widget,
                                   GType widget_type,
                                   const gchar *name);

Fetch an object build from the template XML for `widget_type` in this `widget` instance.

This will only report children which were previously declared with `gtk_widget_class_bind_template_child_full()` or one of its variants.

This function is only meant to be called for code which is private to the `widget_type` which declared the child and is meant for language bindings which cannot easily make use of the GObject structure offsets.

#### Parameters

widget | A GtkWidget |
widget_type | The GType to get a template child for |
name | The “id” of the child defined in the template XML |

#### Returns

The object built in the template XML with the id `name` .

[transfer none]

### gtk_widget_class_bind_template_child()

    #define             gtk_widget_class_bind_template_child(widget_class, TypeName, member_name)

Binds a child widget defined in a template to the `widget_class` .

This macro is a convenience wrapper around the `gtk_widget_class_bind_template_child_full()` function.

This macro will use the offset of the `member_name` inside the `TypeName` instance structure.

#### Parameters

widget_class | a GtkWidgetClass |
TypeName | the type name of this widget |
member_name | name of the instance member in the instance struct for `data_type` |

Since: 3.10

### gtk_widget_class_bind_template_child_internal()

    #define             gtk_widget_class_bind_template_child_internal(widget_class, TypeName, member_name)

Binds a child widget defined in a template to the `widget_class` , and also makes it available as an internal child in GtkBuilder, under the name `member_name` .

This macro is a convenience wrapper around the `gtk_widget_class_bind_template_child_full()` function.

This macro will use the offset of the `member_name` inside the `TypeName` instance structure.

#### Parameters

widget_class | a GtkWidgetClass |
TypeName | the type name, in CamelCase |
member_name | name of the instance member in the instance struct for `data_type` |

Since: 3.10

### gtk_widget_class_bind_template_child_private()

    #define             gtk_widget_class_bind_template_child_private(widget_class, TypeName, member_name)

Binds a child widget defined in a template to the `widget_class` .

This macro is a convenience wrapper around the `gtk_widget_class_bind_template_child_full()` function.

This macro will use the offset of the `member_name` inside the `TypeName` private data structure (it uses `G_PRIVATE_OFFSET()`, so the private struct must be added with `G_ADD_PRIVATE()`).

#### Parameters

widget_class | a GtkWidgetClass |
TypeName | the type name of this widget |
member_name | name of the instance private member in the private struct for `data_type` |

Since: 3.10

### gtk_widget_class_bind_template_child_internal_private()

    #define             gtk_widget_class_bind_template_child_internal_private(widget_class, TypeName, member_name)

Binds a child widget defined in a template to the `widget_class` , and also makes it available as an internal child in GtkBuilder, under the name `member_name` .

This macro is a convenience wrapper around the `gtk_widget_class_bind_template_child_full()` function.

This macro will use the offset of the `member_name` inside the `TypeName` private data structure.

#### Parameters

widget_class | a GtkWidgetClass |
TypeName | the type name, in CamelCase |
member_name | name of the instance private member on the private struct for `data_type` |

Since: 3.10

### gtk_widget_class_bind_template_child_full ()

    void
    gtk_widget_class_bind_template_child_full
                                   (GtkWidgetClass *widget_class,
                                    const gchar *name,
                                    gboolean internal_child,
                                    gssize struct_offset);

Automatically assign an object declared in the class template XML to be set to a location on a freshly built instance’s private data, or alternatively accessible via `gtk_widget_get_template_child()`.

The struct can point either into the public instance, then you should use G_STRUCT_OFFSET(WidgetType, member) for `struct_offset` , or in the private struct, then you should use G_PRIVATE_OFFSET(WidgetType, member).

An explicit strong reference will be held automatically for the duration of your instance’s life cycle, it will be released automatically when `GObjectClass.dispose()` runs on your instance and if a `struct_offset` that is != 0 is specified, then the automatic location in your instance public or private data will be set to `NULL`. You can however access an automated child pointer the first time your classes `GObjectClass.dispose()` runs, or alternatively in `GtkWidgetClass.destroy()`.

If `internal_child` is specified, `GtkBuildableIface.get_internal_child()` will be automatically implemented by the GtkWidget class so there is no need to implement it manually.

The wrapper macros `gtk_widget_class_bind_template_child()`, `gtk_widget_class_bind_template_child_internal()`, `gtk_widget_class_bind_template_child_private()` and `gtk_widget_class_bind_template_child_internal_private()` might be more convenient to use.

Note that this must be called from a composite widget classes class initializer after calling `gtk_widget_class_set_template()`.

#### Parameters

widget_class | A GtkWidgetClass |
name | The “id” of the child defined in the template XML |
internal_child | Whether the child should be accessible as an “internal-child” when this class is used in GtkBuilder XML |
struct_offset | The structure offset into the composite widget’s instance public or private structure where the automated child pointer should be set, or 0 to not assign the pointer. |

Since: 3.10

### gtk_widget_class_bind_template_callback()

    #define             gtk_widget_class_bind_template_callback(widget_class, callback)

Binds a callback function defined in a template to the `widget_class` .

This macro is a convenience wrapper around the `gtk_widget_class_bind_template_callback_full()` function.

#### Parameters

widget_class | a GtkWidgetClass |
callback | the callback symbol |

Since: 3.10

### gtk_widget_class_bind_template_callback_full ()

    void
    gtk_widget_class_bind_template_callback_full
                                   (GtkWidgetClass *widget_class,
                                    const gchar *callback_name,
                                    GCallback callback_symbol);

Declares a `callback_symbol` to handle `callback_name` from the template XML defined for `widget_type` . See `gtk_builder_add_callback_symbol()`.

Note that this must be called from a composite widget classes class initializer after calling `gtk_widget_class_set_template()`.

#### Parameters

widget_class | A GtkWidgetClass |
callback_name | The name of the callback as expected in the template XML |
callback_symbol | The callback symbol. | [scope async]

Since: 3.10

### gtk_widget_class_set_connect_func ()

    void
    gtk_widget_class_set_connect_func (GtkWidgetClass *widget_class,
                                       GtkBuilderConnectFunc connect_func,
                                       gpointer connect_data,
                                       GDestroyNotify connect_data_destroy);

For use in language bindings, this will override the default GtkBuilderConnectFunc to be used when parsing GtkBuilder XML from this class’s template data.

Note that this must be called from a composite widget classes class initializer after calling `gtk_widget_class_set_template()`.

#### Parameters

widget_class | A GtkWidgetClass |
connect_func | The GtkBuilderConnectFunc to use when connecting signals in the class template |
connect_data | The data to pass to `connect_func` |
connect_data_destroy | The GDestroyNotify to free `connect_data` , this will only be used at class finalization time, when no classes of type `widget_type` are in use anymore. |

Since: 3.10

## Types and Values

### GtkWidget

    typedef struct _GtkWidget GtkWidget;

### struct GtkWidgetClass

    struct GtkWidgetClass {
      GInitiallyUnownedClass parent_class;

      guint activate_signal;

      /* seldomly overidden */
      void (*dispatch_child_properties_changed) (GtkWidget   *widget,
    					     guint        n_pspecs,
    					     GParamSpec **pspecs);

      /* basics */
      void (* destroy)             (GtkWidget        *widget);
      void (* show)		       (GtkWidget        *widget);
      void (* show_all)            (GtkWidget        *widget);
      void (* hide)		       (GtkWidget        *widget);
      void (* map)		       (GtkWidget        *widget);
      void (* unmap)	       (GtkWidget        *widget);
      void (* realize)	       (GtkWidget        *widget);
      void (* unrealize)	       (GtkWidget        *widget);
      void (* size_allocate)       (GtkWidget        *widget,
    				GtkAllocation    *allocation);
      void (* state_changed)       (GtkWidget        *widget,
    				GtkStateType   	  previous_state);
      void (* state_flags_changed) (GtkWidget        *widget,
    				GtkStateFlags  	  previous_state_flags);
      void (* parent_set)	       (GtkWidget        *widget,
    				GtkWidget        *previous_parent);
      void (* hierarchy_changed)   (GtkWidget        *widget,
    				GtkWidget        *previous_toplevel);
      void (* style_set)	       (GtkWidget        *widget,
    				GtkStyle         *previous_style);
      void (* direction_changed)   (GtkWidget        *widget,
    				GtkTextDirection  previous_direction);
      void (* grab_notify)         (GtkWidget        *widget,
    				gboolean          was_grabbed);
      void (* child_notify)        (GtkWidget	 *widget,
    				GParamSpec       *child_property);
      gboolean (* draw)	       (GtkWidget	 *widget,
                                    cairo_t          *cr);

      /* size requests */
      GtkSizeRequestMode (* get_request_mode)               (GtkWidget      *widget);

      void               (* get_preferred_height)           (GtkWidget       *widget,
                                                             gint            *minimum_height,
                                                             gint            *natural_height);
      void               (* get_preferred_width_for_height) (GtkWidget       *widget,
                                                             gint             height,
                                                             gint            *minimum_width,
                                                             gint            *natural_width);
      void               (* get_preferred_width)            (GtkWidget       *widget,
                                                             gint            *minimum_width,
                                                             gint            *natural_width);
      void               (* get_preferred_height_for_width) (GtkWidget       *widget,
                                                             gint             width,
                                                             gint            *minimum_height,
                                                             gint            *natural_height);

      /* Mnemonics */
      gboolean (* mnemonic_activate)        (GtkWidget           *widget,
                                             gboolean             group_cycling);

      /* explicit focus */
      void     (* grab_focus)               (GtkWidget           *widget);
      gboolean (* focus)                    (GtkWidget           *widget,
                                             GtkDirectionType     direction);

      /* keyboard navigation */
      void     (* move_focus)               (GtkWidget           *widget,
                                             GtkDirectionType     direction);
      gboolean (* keynav_failed)            (GtkWidget           *widget,
                                             GtkDirectionType     direction);

      /* events */
      gboolean (* event)			(GtkWidget	     *widget,
    					 GdkEvent	     *event);
      gboolean (* button_press_event) (GtkWidget	     *widget,
    					 GdkEventButton      *event);
      gboolean (* button_release_event) (GtkWidget	     *widget,
    					 GdkEventButton      *event);
      gboolean (* scroll_event)		(GtkWidget           *widget,
    					 GdkEventScroll      *event);
      gboolean (* motion_notify_event) (GtkWidget	     *widget,
    					 GdkEventMotion      *event);
      gboolean (* delete_event)		(GtkWidget	     *widget,
    					 GdkEventAny	     *event);
      gboolean (* destroy_event)		(GtkWidget	     *widget,
    					 GdkEventAny	     *event);
      gboolean (* key_press_event)		(GtkWidget	     *widget,
    					 GdkEventKey	     *event);
      gboolean (* key_release_event) (GtkWidget	     *widget,
    					 GdkEventKey	     *event);
      gboolean (* enter_notify_event) (GtkWidget	     *widget,
    					 GdkEventCrossing    *event);
      gboolean (* leave_notify_event) (GtkWidget	     *widget,
    					 GdkEventCrossing    *event);
      gboolean (* configure_event)		(GtkWidget	     *widget,
    					 GdkEventConfigure   *event);
      gboolean (* focus_in_event)		(GtkWidget	     *widget,
    					 GdkEventFocus       *event);
      gboolean (* focus_out_event)		(GtkWidget	     *widget,
    					 GdkEventFocus       *event);
      gboolean (* map_event)		(GtkWidget	     *widget,
    					 GdkEventAny	     *event);
      gboolean (* unmap_event)		(GtkWidget	     *widget,
    					 GdkEventAny	     *event);
      gboolean (* property_notify_event) (GtkWidget	     *widget,
    					 GdkEventProperty    *event);
      gboolean (* selection_clear_event) (GtkWidget	     *widget,
    					 GdkEventSelection   *event);
      gboolean (* selection_request_event) (GtkWidget	     *widget,
    					 GdkEventSelection   *event);
      gboolean (* selection_notify_event) (GtkWidget	     *widget,
    					 GdkEventSelection   *event);
      gboolean (* proximity_in_event) (GtkWidget	     *widget,
    					 GdkEventProximity   *event);
      gboolean (* proximity_out_event) (GtkWidget	     *widget,
    					 GdkEventProximity   *event);
      gboolean (* visibility_notify_event) (GtkWidget	     *widget,
    					 GdkEventVisibility  *event);
      gboolean (* window_state_event) (GtkWidget	     *widget,
    					 GdkEventWindowState *event);
      gboolean (* damage_event)             (GtkWidget           *widget,
                                             GdkEventExpose      *event);
      gboolean (* grab_broken_event)        (GtkWidget           *widget,
                                             GdkEventGrabBroken  *event);

      /* selection */
      void     (* selection_get)       (GtkWidget          *widget,
    				    GtkSelectionData   *selection_data,
    				    guint               info,
    				    guint               time_);
      void     (* selection_received)  (GtkWidget          *widget,
    				    GtkSelectionData   *selection_data,
    				    guint               time_);

      /* Source side drag signals */
      void     (* drag_begin)          (GtkWidget         *widget,
    				    GdkDragContext     *context);
      void     (* drag_end)	           (GtkWidget	       *widget,
    				    GdkDragContext     *context);
      void     (* drag_data_get)       (GtkWidget          *widget,
    				    GdkDragContext     *context,
    				    GtkSelectionData   *selection_data,
    				    guint               info,
    				    guint               time_);
      void     (* drag_data_delete)    (GtkWidget          *widget,
    				    GdkDragContext     *context);

      /* Target side drag signals */
      void     (* drag_leave)          (GtkWidget          *widget,
    				    GdkDragContext     *context,
    				    guint               time_);
      gboolean (* drag_motion)         (GtkWidget	       *widget,
    				    GdkDragContext     *context,
    				    gint                x,
    				    gint                y,
    				    guint               time_);
      gboolean (* drag_drop)           (GtkWidget	       *widget,
    				    GdkDragContext     *context,
    				    gint                x,
    				    gint                y,
    				    guint               time_);
      void     (* drag_data_received)  (GtkWidget          *widget,
    				    GdkDragContext     *context,
    				    gint                x,
    				    gint                y,
    				    GtkSelectionData   *selection_data,
    				    guint               info,
    				    guint               time_);
      gboolean (* drag_failed)         (GtkWidget          *widget,
                                        GdkDragContext     *context,
                                        GtkDragResult       result);

      /* Signals used only for keybindings */
      gboolean (* popup_menu)          (GtkWidget          *widget);

      /* If a widget has multiple tooltips/whatsthis, it should show the
       * one for the current focus location, or if that doesn't make
       * sense, should cycle through them showing each tip alongside
       * whatever piece of the widget it applies to.
       */
      gboolean (* show_help)           (GtkWidget          *widget,
                                        GtkWidgetHelpType   help_type);

      /* accessibility support
       */
      AtkObject *  (* get_accessible)     (GtkWidget *widget);

      void         (* screen_changed)     (GtkWidget *widget,
                                           GdkScreen *previous_screen);
      gboolean     (* can_activate_accel) (GtkWidget *widget,
                                           guint      signal_id);

      void         (* composited_changed) (GtkWidget *widget);

      gboolean     (* query_tooltip)      (GtkWidget  *widget,
    				       gint        x,
    				       gint        y,
    				       gboolean    keyboard_tooltip,
    				       GtkTooltip *tooltip);

      void         (* compute_expand)     (GtkWidget  *widget,
                                           gboolean   *hexpand_p,
                                           gboolean   *vexpand_p);

      void         (* adjust_size_request)    (GtkWidget         *widget,
                                               GtkOrientation     orientation,
                                               gint              *minimum_size,
                                               gint              *natural_size);
      void         (* adjust_size_allocation) (GtkWidget         *widget,
                                               GtkOrientation     orientation,
                                               gint              *minimum_size,
                                               gint              *natural_size,
                                               gint              *allocated_pos,
                                               gint              *allocated_size);

      void         (* style_updated)          (GtkWidget *widget);

      gboolean     (* touch_event)            (GtkWidget     *widget,
                                               GdkEventTouch *event);

      void         (* get_preferred_height_and_baseline_for_width)  (GtkWidget     *widget,
    								 gint           width,
    								 gint          *minimum_height,
    								 gint          *natural_height,
    								 gint          *minimum_baseline,
    								 gint          *natural_baseline);
      void         (* adjust_baseline_request)(GtkWidget         *widget,
                                               gint              *minimum_baseline,
                                               gint              *natural_baseline);
      void         (* adjust_baseline_allocation) (GtkWidget         *widget,
    					       gint              *baseline);
      void         (*queue_draw_region)           (GtkWidget         *widget,
    					       const cairo_region_t *region);
    };

#### Members

guint `activate_signal`; | The signal to emit when a widget of this class is activated, `gtk_widget_activate()` handles the emission. Implementation of this signal is optional. |
`dispatch_child_properties_changed` () | Seldomly overidden. |
`destroy` () | Signals that all holders of a reference to the widget should release the reference that they hold. |
`show` () | Signal emitted when widget is shown |
`show_all` () | Recursively shows a widget, and any child widgets (if the widget is a container). |
`hide` () | Signal emitted when widget is hidden. |
`map` () | Signal emitted when widget is going to be mapped, that is when the widget is visible (which is controlled with `gtk_widget_set_visible()`) and all its parents up to the toplevel widget are also visible. |
`unmap` () | Signal emitted when widget is going to be unmapped, which means that either it or any of its parents up to the toplevel widget have been set as hidden. |
`realize` () | Signal emitted when widget is associated with a GdkWindow, which means that `gtk_widget_realize()` has been called or the widget has been mapped (that is, it is going to be drawn). |
`unrealize` () | Signal emitted when the GdkWindow associated with widget is destroyed, which means that `gtk_widget_unrealize()` has been called or the widget has been unmapped (that is, it is going to be hidden). |
`size_allocate` () | Signal emitted to get the widget allocation. |
`state_changed` () | Signal emitted when the widget state changes. Deprecated: 3.0 |
`state_flags_changed` () | Signal emitted when the widget state changes, see `gtk_widget_get_state_flags()`. |
`parent_set` () | Signal emitted when a new parent has been set on a widget. |
`hierarchy_changed` () | Signal emitted when the anchored state of a widget changes. |
`style_set` () | Signal emitted when a new style has been set on a widget. Deprecated: 3.0 |
`direction_changed` () | Signal emitted when the text direction of a widget changes. |
`grab_notify` () | Signal emitted when a widget becomes shadowed by a GTK+ grab (not a pointer or keyboard grab) on another widget, or when it becomes unshadowed due to a grab being removed. |
`child_notify` () | Signal emitted for each child property that has changed on an object. |
`draw` () | Signal emitted when a widget is supposed to render itself. |
`get_request_mode` () | This allows a widget to tell its parent container whether it prefers to be allocated in `GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH` or `GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT` mode. `GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH` means the widget prefers to have `GtkWidgetClass.get_preferred_width()` called and then `GtkWidgetClass.get_preferred_height_for_width()`. `GTK_SIZE_REQUEST_CONSTANT_SIZE` disables any height-for-width or width-for-height geometry management for a said widget and is the default return. It’s important to note (as described below) that any widget which trades height-for-width or width-for-height must respond properly to both of the virtual methods `GtkWidgetClass.get_preferred_height_for_width()` and `GtkWidgetClass.get_preferred_width_for_height()` since it might be queried in either GtkSizeRequestMode by its parent container. |
`get_preferred_height` () | This is called by containers to obtain the minimum and natural height of a widget. A widget that does not actually trade any height for width or width for height only has to implement these two virtual methods (`GtkWidgetClass.get_preferred_width()` and `GtkWidgetClass.get_preferred_height()`). |
`get_preferred_width_for_height` () | This is analogous to `GtkWidgetClass.get_preferred_height_for_width()` except that it operates in the oposite orientation. It’s rare that a widget actually does `GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT` requests but this can happen when, for example, a widget or container gets additional columns to compensate for a smaller allocated height. |
`get_preferred_width` () | This is called by containers to obtain the minimum and natural width of a widget. A widget will never be allocated a width less than its minimum and will only ever be allocated a width greater than the natural width once all of the said widget’s siblings have received their natural widths. Furthermore, a widget will only ever be allocated a width greater than its natural width if it was configured to receive extra expand space from its parent container. |
`get_preferred_height_for_width` () | This is similar to `GtkWidgetClass.get_preferred_height()` except that it is passed a contextual width to request height for. By implementing this virtual method it is possible for a GtkLabel to tell its parent how much height would be required if the label were to be allocated a said width. |
`mnemonic_activate` () | Activates the `widget` if `group_cycling` is `FALSE`, and just grabs the focus if `group_cycling` is `TRUE`. |
`grab_focus` () | Causes `widget` to have the keyboard focus for the GtkWindow it’s inside. |
`focus` () |  |
`move_focus` () | Signal emitted when a change of focus is requested |
`keynav_failed` () | Signal emitted if keyboard navigation fails. |
`event` () | The GTK+ main loop will emit three signals for each GDK event delivered to a widget: one generic ::event signal, another, more specific, signal that matches the type of event delivered (e.g. "key-press-event") and finally a generic "event-after" signal. |
`button_press_event` () | Signal will be emitted when a button (typically from a mouse) is pressed. |
`button_release_event` () | Signal will be emitted when a button (typically from a mouse) is released. |
`scroll_event` () | Signal emitted when a button in the 4 to 7 range is pressed. |
`motion_notify_event` () | Signal emitted when the pointer moves over the widget’s GdkWindow. |
`delete_event` () | Signal emitted if a user requests that a toplevel window is closed. |
`destroy_event` () | Signal is emitted when a GdkWindow is destroyed. |
`key_press_event` () | Signal emitted when a key is pressed. |
`key_release_event` () | Signal is emitted when a key is released. |
`enter_notify_event` () | Signal event will be emitted when the pointer enters the widget’s window. |
`leave_notify_event` () | Will be emitted when the pointer leaves the widget’s window. |
`configure_event` () | Signal will be emitted when the size, position or stacking of the widget’s window has changed. |
`focus_in_event` () | Signal emitted when the keyboard focus enters the widget’s window. |
`focus_out_event` () | Signal emitted when the keyboard focus leaves the widget’s window. |
`map_event` () | Signal emitted when the widget’s window is mapped. |
`unmap_event` () | Signal will be emitted when the widget’s window is unmapped. |
`property_notify_event` () | Signal will be emitted when a property on the widget’s window has been changed or deleted. |
`selection_clear_event` () | Signal will be emitted when the the widget’s window has lost ownership of a selection. |
`selection_request_event` () | Signal will be emitted when another client requests ownership of the selection owned by the widget's window. |
`selection_notify_event` () |  |
`proximity_in_event` () |  |
`proximity_out_event` () |  |
`visibility_notify_event` () | Signal emitted when the widget’s window is obscured or unobscured. |
`window_state_event` () | Signal emitted when the state of the toplevel window associated to the widget changes. |
`damage_event` () | Signal emitted when a redirected window belonging to widget gets drawn into. |
`grab_broken_event` () | Signal emitted when a pointer or keyboard grab on a window belonging to widget gets broken. |
`selection_get` () |  |
`selection_received` () |  |
`drag_begin` () | Signal emitted on the drag source when a drag is started. |
`drag_end` () | Signal emitted on the drag source when a drag is finished. |
`drag_data_get` () | Signal emitted on the drag source when the drop site requests the data which is dragged. |
`drag_data_delete` () | Signal emitted on the drag source when a drag with the action `GDK_ACTION_MOVE` is successfully completed. |
`drag_leave` () | Signal emitted on the drop site when the cursor leaves the widget. |
`drag_motion` () | signal emitted on the drop site when the user moves the cursor over the widget during a drag. |
`drag_drop` () | Signal emitted on the drop site when the user drops the data onto the widget. |
`drag_data_received` () | Signal emitted on the drop site when the dragged data has been received. |
`drag_failed` () | Signal emitted on the drag source when a drag has failed. |
`popup_menu` () | Signal emitted whenever a widget should pop up a context menu. |
`show_help` () |  |
`get_accessible` () | Returns the accessible object that describes the widget to an assistive technology. |
`screen_changed` () | Signal emitted when the screen of a widget has changed. |
`can_activate_accel` () | Signal allows applications and derived widgets to override the default GtkWidget handling for determining whether an accelerator can be activated. |
`composited_changed` () | Signal emitted when the composited status of widgets screen changes. See `gdk_screen_is_composited()`. |
`query_tooltip` () | Signal emitted when “has-tooltip” is `TRUE` and the hover timeout has expired with the cursor hovering “above” widget; or emitted when widget got focus in keyboard mode. |
`compute_expand` () | Computes whether a container should give this widget extra space when possible. |
`adjust_size_request` () | Convert an initial size request from a widget's GtkSizeRequestMode virtual method implementations into a size request to be used by parent containers in laying out the widget. adjust_size_request adjusts from a child widget's original request to what a parent container should use for layout. The `for_size` argument will be -1 if the request should not be for a particular size in the opposing orientation, i.e. if the request is not height-for-width or width-for-height. If `for_size` is greater than -1, it is the proposed allocation in the opposing orientation that we need the request for. Implementations of adjust_size_request should chain up to the default implementation, which applies GtkWidget’s margin properties and imposes any values from `gtk_widget_set_size_request()`. Chaining up should be last, after your subclass adjusts the request, so GtkWidget can apply constraints and add the margin properly. |
`adjust_size_allocation` () | Convert an initial size allocation assigned by a GtkContainer using `gtk_widget_size_allocate()`, into an actual size allocation to be used by the widget. adjust_size_allocation adjusts to a child widget’s actual allocation from what a parent container computed for the child. The adjusted allocation must be entirely within the original allocation. In any custom implementation, chain up to the default GtkWidget implementation of this method, which applies the margin and alignment properties of GtkWidget. Chain up before performing your own adjustments so your own adjustments remove more allocation after the GtkWidget base class has already removed margin and alignment. The natural size passed in should be adjusted in the same way as the allocated size, which allows adjustments to perform alignments or other changes based on natural size. |
`style_updated` () | Signal emitted when the GtkStyleContext of a widget is changed. |
`touch_event` () |  |
`get_preferred_height_and_baseline_for_width` () |  |
`adjust_baseline_request` () |  |
`adjust_baseline_allocation` () |  |
`queue_draw_region` () | Invalidates the area of widget defined by region by calling `gdk_window_invalidate_region()` on the widget's window and all its child windows. |

### GtkRequisition

    typedef struct {
      gint width;
      gint height;
    } GtkRequisition;

A GtkRequisition represents the desired size of a widget. See GtkWidget’s geometry management section for more information.

#### Members

gint `width`; | the widget’s desired width |
gint `height`; | the widget’s desired height |

### GtkAllocation

    typedef 	GdkRectangle	   GtkAllocation;

A GtkAllocation of a widget represents region which has been allocated to the widget by its parent. It is a subregion of its parents allocation. See GtkWidget’s geometry management section for more information.

### enum GtkWidgetHelpType

Kinds of widget-specific help. Used by the ::show-help signal.

#### Members

GTK_WIDGET_HELP_TOOLTIP | Tooltip. |
GTK_WIDGET_HELP_WHATS_THIS | What’s this. |

### enum GtkTextDirection

Reading directions for text.

#### Members

GTK_TEXT_DIR_NONE | No direction. |
GTK_TEXT_DIR_LTR | Left to right text direction. |
GTK_TEXT_DIR_RTL | Right to left text direction. |

### enum GtkStateType

`GtkStateType` has been deprecated since version 3.14 and should not be used in newly-written code.

All APIs that are using this enumeration have been deprecated in favor of alternatives using GtkStateFlags.

This type indicates the current state of a widget; the state determines how the widget is drawn. The GtkStateType enumeration is also used to identify different colors in a GtkStyle for drawing, so states can be used for subparts of a widget as well as entire widgets.

#### Members

GTK_STATE_NORMAL | State during normal operation. |
GTK_STATE_ACTIVE | State of a currently active widget, such as a depressed button. |
GTK_STATE_PRELIGHT | State indicating that the mouse pointer is over the widget and the widget will respond to mouse clicks. |
GTK_STATE_SELECTED | State of a selected item, such the selected row in a list. |
GTK_STATE_INSENSITIVE | State indicating that the widget is unresponsive to user actions. |
GTK_STATE_INCONSISTENT | The widget is inconsistent, such as checkbuttons or radiobuttons that aren’t either set to `TRUE` nor `FALSE`, or buttons requiring the user attention. |
GTK_STATE_FOCUSED | The widget has the keyboard focus. |

### enum GtkSizeRequestMode

Specifies a preference for height-for-width or width-for-height geometry management.

#### Members

GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH | Prefer height-for-width geometry management |
GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT | Prefer width-for-height geometry management |
GTK_SIZE_REQUEST_CONSTANT_SIZE | Don’t trade height-for-width or width-for-height |

### struct GtkRequestedSize

    struct GtkRequestedSize {
      gpointer data;
      gint     minimum_size;
      gint     natural_size;
    };

Represents a request of a screen object in a given orientation. These are primarily used in container implementations when allocating a natural size for children calling. See `gtk_distribute_natural_allocation()`.

#### Members

gpointer `data`; | A client pointer |
gint `minimum_size`; | The minimum size needed for allocation in a given orientation |
gint `natural_size`; | The natural size for allocation in a given orientation |

### enum GtkAlign

Controls how a widget deals with extra space in a single (x or y) dimension.

Alignment only matters if the widget receives a “too large” allocation, for example if you packed the widget with the “expand” flag inside a GtkBox, then the widget might get extra space. If you have for example a 16x16 icon inside a 32x32 space, the icon could be scaled and stretched, it could be centered, or it could be positioned to one side of the space.

Note that in horizontal context `GTK_ALIGN_START` and `GTK_ALIGN_END` are interpreted relative to text direction.

GTK_ALIGN_BASELINE support for it is optional for containers and widgets, and it is only supported for vertical alignment. When its not supported by a child or a container it is treated as `GTK_ALIGN_FILL` .

#### Members

GTK_ALIGN_FILL | stretch to fill all space if possible, center if no meaningful way to stretch |
GTK_ALIGN_START | snap to left or top side, leaving space on right or bottom |
GTK_ALIGN_END | snap to right or bottom side, leaving space on left or top |
GTK_ALIGN_CENTER | center natural width of widget inside the allocation |
GTK_ALIGN_BASELINE | align the widget according to the baseline. Since 3.10. |

## Property Details

### The `“app-paintable”` property

      “app-paintable”            gboolean

Whether the application will paint directly on the widget.

Flags: Read / Write

Default value: FALSE

### The `“can-default”` property

      “can-default”              gboolean

Whether the widget can be the default widget.

Flags: Read / Write

Default value: FALSE

### The `“can-focus”` property

      “can-focus”                gboolean

Whether the widget can accept the input focus.

Flags: Read / Write

Default value: FALSE

### The `“composite-child”` property

      “composite-child”          gboolean

Whether the widget is part of a composite widget.

Flags: Read

Default value: FALSE

### The `“double-buffered”` property

      “double-buffered”          gboolean

Whether the widget is double buffered.

`GtkWidget:double-buffered` has been deprecated since version 3.14 and should not be used in newly-written code.

Widgets should not use this property.

Flags: Read / Write

Default value: TRUE

Since: 2.18

### The `“events”` property

      “events”                   GdkEventMask

The event mask that decides what kind of GdkEvents this widget gets.

Flags: Read / Write

Default value: GDK_STRUCTURE_MASK

### The `“expand”` property

      “expand”                   gboolean

Whether to expand in both directions. Setting this sets both “hexpand” and “vexpand”

Flags: Read / Write

Default value: FALSE

Since: 3.0

### The `“focus-on-click”` property

      “focus-on-click”           gboolean

Whether the widget should grab focus when it is clicked with the mouse.

This property is only relevant for widgets that can take focus.

Before 3.20, several widgets (GtkButton, GtkFileChooserButton, GtkComboBox) implemented this property individually.

Flags: Read / Write

Default value: TRUE

Since: 3.20

### The `“halign”` property

      “halign”                   GtkAlign

How to distribute horizontal space if widget gets extra space, see GtkAlign

Flags: Read / Write

Default value: GTK_ALIGN_FILL

Since: 3.0

### The `“has-default”` property

      “has-default”              gboolean

Whether the widget is the default widget.

Flags: Read / Write

Default value: FALSE

### The `“has-focus”` property

      “has-focus”                gboolean

Whether the widget has the input focus.

Flags: Read / Write

Default value: FALSE

### The `“has-tooltip”` property

      “has-tooltip”              gboolean

Enables or disables the emission of “query-tooltip” on `widget` . A value of `TRUE` indicates that `widget` can have a tooltip, in this case the widget will be queried using “query-tooltip” to determine whether it will provide a tooltip or not.

Note that setting this property to `TRUE` for the first time will change the event masks of the GdkWindows of this widget to include leave-notify and motion-notify events. This cannot and will not be undone when the property is set to `FALSE` again.

Flags: Read / Write

Default value: FALSE

Since: 2.12

### The `“height-request”` property

      “height-request”           gint

Override for height request of the widget, or -1 if natural request should be used.

Flags: Read / Write

Allowed values: >= -1

Default value: -1

### The `“hexpand”` property

      “hexpand”                  gboolean

Whether to expand horizontally. See `gtk_widget_set_hexpand()`.

Flags: Read / Write

Default value: FALSE

Since: 3.0

### The `“hexpand-set”` property

      “hexpand-set”              gboolean

Whether to use the “hexpand” property. See `gtk_widget_get_hexpand_set()`.

Flags: Read / Write

Default value: FALSE

Since: 3.0

### The `“is-focus”` property

      “is-focus”                 gboolean

Whether the widget is the focus widget within the toplevel.

Flags: Read / Write

Default value: FALSE

### The `“margin”` property

      “margin”                   gint

Sets all four sides' margin at once. If read, returns max margin on any side.

Flags: Read / Write

Allowed values: [0,32767]

Default value: 0

Since: 3.0

### The `“margin-bottom”` property

      “margin-bottom”            gint

Margin on bottom side of widget.

This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from `gtk_widget_set_size_request()` for example.

Flags: Read / Write

Allowed values: [0,32767]

Default value: 0

Since: 3.0

### The `“margin-end”` property

      “margin-end”               gint

Margin on end of widget, horizontally. This property supports left-to-right and right-to-left text directions.

This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from `gtk_widget_set_size_request()` for example.

Flags: Read / Write

Allowed values: [0,32767]

Default value: 0

Since: 3.12

### The `“margin-left”` property

      “margin-left”              gint

Margin on left side of widget.

This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from `gtk_widget_set_size_request()` for example.

`GtkWidget:margin-left` has been deprecated since version 3.12 and should not be used in newly-written code.

Use “margin-start” instead.

Flags: Read / Write

Allowed values: [0,32767]

Default value: 0

Since: 3.0

### The `“margin-right”` property

      “margin-right”             gint

Margin on right side of widget.

This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from `gtk_widget_set_size_request()` for example.

`GtkWidget:margin-right` has been deprecated since version 3.12 and should not be used in newly-written code.

Use “margin-end” instead.

Flags: Read / Write

Allowed values: [0,32767]

Default value: 0

Since: 3.0

### The `“margin-start”` property

      “margin-start”             gint

Margin on start of widget, horizontally. This property supports left-to-right and right-to-left text directions.

This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from `gtk_widget_set_size_request()` for example.

Flags: Read / Write

Allowed values: [0,32767]

Default value: 0

Since: 3.12

### The `“margin-top”` property

      “margin-top”               gint

Margin on top side of widget.

This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from `gtk_widget_set_size_request()` for example.

Flags: Read / Write

Allowed values: [0,32767]

Default value: 0

Since: 3.0

### The `“name”` property

      “name”                     gchar *

The name of the widget.

Flags: Read / Write

Default value: NULL

### The `“no-show-all”` property

      “no-show-all”              gboolean

Whether gtk_widget_show_all() should not affect this widget.

Flags: Read / Write

Default value: FALSE

### The `“opacity”` property

      “opacity”                  gdouble

The requested opacity of the widget. See `gtk_widget_set_opacity()` for more details about window opacity.

Before 3.8 this was only available in GtkWindow

Flags: Read / Write

Allowed values: [0,1]

Default value: 1

Since: 3.8

### The `“parent”` property

      “parent”                   GtkContainer *

The parent widget of this widget. Must be a Container widget.

Flags: Read / Write

### The `“receives-default”` property

      “receives-default”         gboolean

If TRUE, the widget will receive the default action when it is focused.

Flags: Read / Write

Default value: FALSE

### The `“scale-factor”` property

      “scale-factor”             gint

The scale factor of the widget. See `gtk_widget_get_scale_factor()` for more details about widget scaling.

Flags: Read

Allowed values: >= 1

Default value: 1

Since: 3.10

### The `“sensitive”` property

      “sensitive”                gboolean

Whether the widget responds to input.

Flags: Read / Write

Default value: TRUE

### The `“style”` property

      “style”                    GtkStyle *

The style of the widget, which contains information about how it will look (colors, etc).

`GtkWidget:style` is deprecated and should not be used in newly-written code.

Use GtkStyleContext instead

Flags: Read / Write

### The `“tooltip-markup”` property

      “tooltip-markup”           gchar *

Sets the text of tooltip to be the given string, which is marked up with the Pango text markup language. Also see `gtk_tooltip_set_markup()`.

This is a convenience property which will take care of getting the tooltip shown if the given string is not `NULL`: “has-tooltip” will automatically be set to `TRUE` and there will be taken care of “query-tooltip” in the default signal handler.

Note that if both “tooltip-text” and “tooltip-markup” are set, the last one wins.

Flags: Read / Write

Default value: NULL

Since: 2.12

### The `“tooltip-text”` property

      “tooltip-text”             gchar *

Sets the text of tooltip to be the given string.

Also see `gtk_tooltip_set_text()`.

This is a convenience property which will take care of getting the tooltip shown if the given string is not `NULL`: “has-tooltip” will automatically be set to `TRUE` and there will be taken care of “query-tooltip” in the default signal handler.

Note that if both “tooltip-text” and “tooltip-markup” are set, the last one wins.

Flags: Read / Write

Default value: NULL

Since: 2.12

### The `“valign”` property

      “valign”                   GtkAlign

How to distribute vertical space if widget gets extra space, see GtkAlign

Flags: Read / Write

Default value: GTK_ALIGN_FILL

Since: 3.0

### The `“vexpand”` property

      “vexpand”                  gboolean

Whether to expand vertically. See `gtk_widget_set_vexpand()`.

Flags: Read / Write

Default value: FALSE

Since: 3.0

### The `“vexpand-set”` property

      “vexpand-set”              gboolean

Whether to use the “vexpand” property. See `gtk_widget_get_vexpand_set()`.

Flags: Read / Write

Default value: FALSE

Since: 3.0

### The `“visible”` property

      “visible”                  gboolean

Whether the widget is visible.

Flags: Read / Write

Default value: FALSE

### The `“width-request”` property

      “width-request”            gint

Override for width request of the widget, or -1 if natural request should be used.

Flags: Read / Write

Allowed values: >= -1

Default value: -1

### The `“window”` property

      “window”                   GdkWindow *

The widget's window if it is realized, `NULL` otherwise.

Flags: Read

Since: 2.14

## Style Property Details

### The `“cursor-aspect-ratio”` style property

      “cursor-aspect-ratio”      gfloat

Aspect ratio with which to draw insertion cursor.

Flags: Read

Allowed values: [0,1]

Default value: 0.04

### The `“cursor-color”` style property

      “cursor-color”             GdkColor *

The color with which to draw the insertion cursor in entries and text views.

`GtkWidget:cursor-color` has been deprecated since version 3.20 and should not be used in newly-written code.

Use the caret-color CSS property

Flags: Read

### The `“focus-line-pattern”` style property

      “focus-line-pattern”       gchar *

The "focus-line-pattern" style property defines the dash pattern used to draw the focus indicator. The character values are interpreted as pixel widths of alternating on and off segments of the line.

`GtkWidget:focus-line-pattern` has been deprecated since version 3.14 and should not be used in newly-written code.

use the outline-style CSS property instead.

Flags: Read

Default value: "\001\001"

### The `“focus-line-width”` style property

      “focus-line-width”         gint

The "focus-line-width" style property defines the width, in pixels, of the focus indicator line

`GtkWidget:focus-line-width` has been deprecated since version 3.14 and should not be used in newly-written code.

use the outline-width and padding CSS properties instead.

Flags: Read

Allowed values: >= 0

Default value: 1

### The `“focus-padding”` style property

      “focus-padding”            gint

The "focus-padding" style property defines the width, in pixels, between focus indicator and the widget 'box'.

`GtkWidget:focus-padding` has been deprecated since version 3.14 and should not be used in newly-written code.

use the outline-offset CSS properties instead.

Flags: Read

Allowed values: >= 0

Default value: 1

### The `“interior-focus”` style property

      “interior-focus”           gboolean

The "interior-focus" style property defines whether to draw the focus indicator inside widgets.

`GtkWidget:interior-focus` has been deprecated since version 3.14 and should not be used in newly-written code.

use the outline CSS properties instead.

Flags: Read

Default value: TRUE

### The `“link-color”` style property

      “link-color”               GdkColor *

The "link-color" style property defines the color of unvisited links.

`GtkWidget:link-color` has been deprecated since version 3.12 and should not be used in newly-written code.

Links now use a separate state flags for selecting different theming, this style property is ignored

Flags: Read

Since: 2.10

### The `“scroll-arrow-hlength”` style property

      “scroll-arrow-hlength”     gint

The "scroll-arrow-hlength" style property defines the length of horizontal scroll arrows.

Flags: Read

Allowed values: >= 1

Default value: 16

Since: 2.10

### The `“scroll-arrow-vlength”` style property

      “scroll-arrow-vlength”     gint

The "scroll-arrow-vlength" style property defines the length of vertical scroll arrows.

Flags: Read

Allowed values: >= 1

Default value: 16

Since: 2.10

### The `“secondary-cursor-color”` style property

      “secondary-cursor-color”   GdkColor *

The color with which to draw the secondary insertion cursor in entries and text views when editing mixed right-to-left and left-to-right text.

`GtkWidget:secondary-cursor-color` has been deprecated since version 3.20 and should not be used in newly-written code.

Use the -gtk-secondary-caret-color CSS property

Flags: Read

### The `“separator-height”` style property

      “separator-height”         gint

The "separator-height" style property defines the height of separators. This property only takes effect if the "wide-separators" style property is `TRUE`.

`GtkWidget:separator-height` has been deprecated since version 3.20 and should not be used in newly-written code.

Use the standard min-height CSS property on the separator elements to size separators; the value of this style property is ignored.

Flags: Read

Allowed values: >= 0

Default value: 0

Since: 2.10

### The `“separator-width”` style property

      “separator-width”          gint

The "separator-width" style property defines the width of separators. This property only takes effect if the "wide-separators" style property is `TRUE`.

`GtkWidget:separator-width` has been deprecated since version 3.20 and should not be used in newly-written code.

Use the standard min-width CSS property on the separator elements to size separators; the value of this style property is ignored.

Flags: Read

Allowed values: >= 0

Default value: 0

Since: 2.10

### The `“text-handle-height”` style property

      “text-handle-height”       gint

Height of text selection handles.

Flags: Read

Allowed values: >= 1

Default value: 20

### The `“text-handle-width”` style property

      “text-handle-width”        gint

Width of text selection handles.

Flags: Read

Allowed values: >= 1

Default value: 16

### The `“visited-link-color”` style property

      “visited-link-color”       GdkColor *

The "visited-link-color" style property defines the color of visited links.

`GtkWidget:visited-link-color` has been deprecated since version 3.12 and should not be used in newly-written code.

Links now use a separate state flags for selecting different theming, this style property is ignored

Flags: Read

Since: 2.10

### The `“wide-separators”` style property

      “wide-separators”          gboolean

The "wide-separators" style property defines whether separators have configurable width and should be drawn using a box instead of a line.

`GtkWidget:wide-separators` has been deprecated since version 3.20 and should not be used in newly-written code.

Use CSS properties on the separator elements to style separators; the value of this style property is ignored.

Flags: Read

Default value: FALSE

Since: 2.10

### The `“window-dragging”` style property

      “window-dragging”          gboolean

Whether windows can be dragged and maximized by clicking on empty areas.

Flags: Read

Default value: FALSE

## Signal Details

### The `“accel-closures-changed”` signal

    void
    user_function (GtkWidget *widget,
                   gpointer   user_data)

#### Parameters

widget | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

### The `“button-press-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::button-press-event signal will be emitted when a button (typically from a mouse) is pressed.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_BUTTON_PRESS_MASK mask.

This signal will be sent to the grab widget if there is one.

#### Parameters

widget | the object which received the signal. |
event | the GdkEventButton which triggered this signal. | [type Gdk.EventButton]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“button-release-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::button-release-event signal will be emitted when a button (typically from a mouse) is released.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_BUTTON_RELEASE_MASK mask.

This signal will be sent to the grab widget if there is one.

#### Parameters

widget | the object which received the signal. |
event | the GdkEventButton which triggered this signal. | [type Gdk.EventButton]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“can-activate-accel”` signal

    gboolean
    user_function (GtkWidget *widget,
                   guint      signal_id,
                   gpointer   user_data)

Determines whether an accelerator that activates the signal identified by `signal_id` can currently be activated. This signal is present to allow applications and derived widgets to override the default GtkWidget handling for determining whether an accelerator can be activated.

#### Parameters

widget | the object which received the signal |
signal_id | the ID of a signal installed on `widget` |
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` if the signal can be activated.

Flags: Run Last

### The `“child-notify”` signal

    void
    user_function (GtkWidget  *widget,
                   GParamSpec *child_property,
                   gpointer    user_data)

The ::child-notify signal is emitted for each child property that has changed on an object. The signal's detail holds the property name.

#### Parameters

widget | the object which received the signal |
child_property | the GParamSpec of the changed child property |
user_data | user data set when the signal handler was connected. |

Flags: No Hooks

### The `“composited-changed”` signal

    void
    user_function (GtkWidget *widget,
                   gpointer   user_data)

The ::composited-changed signal is emitted when the composited status of `widgets` screen changes. See `gdk_screen_is_composited()`.

`GtkWidget::composited-changed` has been deprecated since version 3.22 and should not be used in newly-written code.

Use GdkScreen::composited-changed instead.

#### Parameters

widget | the object on which the signal is emitted |
user_data | user data set when the signal handler was connected. |

Flags: Action

### The `“configure-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::configure-event signal will be emitted when the size, position or stacking of the `widget` 's window has changed.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_STRUCTURE_MASK mask. GDK will enable this mask automatically for all new windows.

#### Parameters

widget | the object which received the signal |
event | the GdkEventConfigure which triggered this signal. | [type Gdk.EventConfigure]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“damage-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

Emitted when a redirected window belonging to `widget` gets drawn into. The region/area members of the event shows what area of the redirected drawable was drawn into.

#### Parameters

widget | the object which received the signal |
event | the GdkEventExpose event. | [type Gdk.EventExpose]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

Since: 2.14

### The `“delete-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::delete-event signal is emitted if a user requests that a toplevel window is closed. The default handler for this signal destroys the window. Connecting `gtk_widget_hide_on_delete()` to this signal will cause the window to be hidden instead, so that it can later be shown again without reconstructing it.

#### Parameters

widget | the object which received the signal |
event | the event which triggered this signal |
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“destroy”` signal

    void
    user_function (GtkWidget *object,
                   gpointer   user_data)

Signals that all holders of a reference to the widget should release the reference that they hold. May result in finalization of the widget if all references are released.

This signal is not suitable for saving widget state.

#### Parameters

object | the object which received the signal |
user_data | user data set when the signal handler was connected. |

Flags: No Hooks

### The `“destroy-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::destroy-event signal is emitted when a GdkWindow is destroyed. You rarely get this signal, because most widgets disconnect themselves from their window before they destroy it, so no widget owns the window at destroy time.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_STRUCTURE_MASK mask. GDK will enable this mask automatically for all new windows.

#### Parameters

widget | the object which received the signal. |
event | the event which triggered this signal |
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“direction-changed”` signal

    void
    user_function (GtkWidget       *widget,
                   GtkTextDirection previous_direction,
                   gpointer         user_data)

The ::direction-changed signal is emitted when the text direction of a widget changes.

#### Parameters

widget | the object on which the signal is emitted |
previous_direction | the previous text direction of `widget` |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“drag-begin”` signal

    void
    user_function (GtkWidget      *widget,
                   GdkDragContext *context,
                   gpointer        user_data)

The ::drag-begin signal is emitted on the drag source when a drag is started. A typical reason to connect to this signal is to set up a custom drag icon with e.g. `gtk_drag_source_set_icon_pixbuf()`.

Note that some widgets set up a drag icon in the default handler of this signal, so you may have to use `g_signal_connect_after()` to override what the default handler did.

#### Parameters

widget | the object which received the signal |
context | the drag context |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“drag-data-delete”` signal

    void
    user_function (GtkWidget      *widget,
                   GdkDragContext *context,
                   gpointer        user_data)

The ::drag-data-delete signal is emitted on the drag source when a drag with the action `GDK_ACTION_MOVE` is successfully completed. The signal handler is responsible for deleting the data that has been dropped. What "delete" means depends on the context of the drag operation.

#### Parameters

widget | the object which received the signal |
context | the drag context |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“drag-data-get”` signal

    void
    user_function (GtkWidget        *widget,
                   GdkDragContext   *context,
                   GtkSelectionData *data,
                   guint             info,
                   guint             time,
                   gpointer          user_data)

The ::drag-data-get signal is emitted on the drag source when the drop site requests the data which is dragged. It is the responsibility of the signal handler to fill `data` with the data in the format which is indicated by `info` . See `gtk_selection_data_set()` and `gtk_selection_data_set_text()`.

#### Parameters

widget | the object which received the signal |
context | the drag context |
data | the GtkSelectionData to be filled with the dragged data |
info | the info that has been registered with the target in the GtkTargetList |
time | the timestamp at which the data was requested |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“drag-data-received”` signal

    void
    user_function (GtkWidget        *widget,
                   GdkDragContext   *context,
                   gint              x,
                   gint              y,
                   GtkSelectionData *data,
                   guint             info,
                   guint             time,
                   gpointer          user_data)

The ::drag-data-received signal is emitted on the drop site when the dragged data has been received. If the data was received in order to determine whether the drop will be accepted, the handler is expected to call `gdk_drag_status()` and not finish the drag. If the data was received in response to a “drag-drop” signal (and this is the last target to be received), the handler for this signal is expected to process the received data and then call `gtk_drag_finish()`, setting the `success` parameter depending on whether the data was processed successfully.

Applications must create some means to determine why the signal was emitted and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.

The handler may inspect the selected action with `gdk_drag_context_get_selected_action()` before calling `gtk_drag_finish()`, e.g. to implement `GDK_ACTION_ASK` as shown in the following example:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    void
    drag_data_received (GtkWidget          *widget,
                        GdkDragContext     *context,
                        gint                x,
                        gint                y,
                        GtkSelectionData   *data,
                        guint               info,
                        guint               time)
    {
      if ((data->length >= 0) && (data->format == 8))
        {
          GdkDragAction action;

          // handle data here

          action = gdk_drag_context_get_selected_action (context);
          if (action == GDK_ACTION_ASK)
            {
              GtkWidget *dialog;
              gint response;

              dialog = gtk_message_dialog_new (NULL,
                                               GTK_DIALOG_MODAL |
                                               GTK_DIALOG_DESTROY_WITH_PARENT,
                                               GTK_MESSAGE_INFO,
                                               GTK_BUTTONS_YES_NO,
                                               "Move the data ?\n");
              response = gtk_dialog_run (GTK_DIALOG (dialog));
              gtk_widget_destroy (dialog);

              if (response == GTK_RESPONSE_YES)
                action = GDK_ACTION_MOVE;
              else
                action = GDK_ACTION_COPY;
             }

          gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
        }
      else
        gtk_drag_finish (context, FALSE, FALSE, time);
     }

#### Parameters

widget | the object which received the signal |
context | the drag context |
x | where the drop happened |
y | where the drop happened |
data | the received data |
info | the info that has been registered with the target in the GtkTargetList |
time | the timestamp at which the data was received |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“drag-drop”` signal

    gboolean
    user_function (GtkWidget      *widget,
                   GdkDragContext *context,
                   gint            x,
                   gint            y,
                   guint           time,
                   gpointer        user_data)

The ::drag-drop signal is emitted on the drop site when the user drops the data onto the widget. The signal handler must determine whether the cursor position is in a drop zone or not. If it is not in a drop zone, it returns `FALSE` and no further processing is necessary. Otherwise, the handler returns `TRUE`. In this case, the handler must ensure that `gtk_drag_finish()` is called to let the source know that the drop is done. The call to `gtk_drag_finish()` can be done either directly or in a “drag-data-received” handler which gets triggered by calling `gtk_drag_get_data()` to receive the data for one or more of the supported targets.

#### Parameters

widget | the object which received the signal |
context | the drag context |
x | the x coordinate of the current cursor position |
y | the y coordinate of the current cursor position |
time | the timestamp of the motion event |
user_data | user data set when the signal handler was connected. |

#### Returns

whether the cursor position is in a drop zone

Flags: Run Last

### The `“drag-end”` signal

    void
    user_function (GtkWidget      *widget,
                   GdkDragContext *context,
                   gpointer        user_data)

The ::drag-end signal is emitted on the drag source when a drag is finished. A typical reason to connect to this signal is to undo things done in “drag-begin”.

#### Parameters

widget | the object which received the signal |
context | the drag context |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“drag-failed”` signal

    gboolean
    user_function (GtkWidget      *widget,
                   GdkDragContext *context,
                   GtkDragResult   result,
                   gpointer        user_data)

The ::drag-failed signal is emitted on the drag source when a drag has failed. The signal handler may hook custom code to handle a failed DnD operation based on the type of error, it returns `TRUE` is the failure has been already handled (not showing the default "drag operation failed" animation), otherwise it returns `FALSE`.

#### Parameters

widget | the object which received the signal |
context | the drag context |
result | the result of the drag operation |
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` if the failed drag operation has been already handled.

Flags: Run Last

Since: 2.12

### The `“drag-leave”` signal

    void
    user_function (GtkWidget      *widget,
                   GdkDragContext *context,
                   guint           time,
                   gpointer        user_data)

The ::drag-leave signal is emitted on the drop site when the cursor leaves the widget. A typical reason to connect to this signal is to undo things done in “drag-motion”, e.g. undo highlighting with `gtk_drag_unhighlight()`.

Likewise, the “drag-leave” signal is also emitted before the ::drag-drop signal, for instance to allow cleaning up of a preview item created in the “drag-motion” signal handler.

#### Parameters

widget | the object which received the signal. |
context | the drag context |
time | the timestamp of the motion event |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“drag-motion”` signal

    gboolean
    user_function (GtkWidget      *widget,
                   GdkDragContext *context,
                   gint            x,
                   gint            y,
                   guint           time,
                   gpointer        user_data)

The ::drag-motion signal is emitted on the drop site when the user moves the cursor over the widget during a drag. The signal handler must determine whether the cursor position is in a drop zone or not. If it is not in a drop zone, it returns `FALSE` and no further processing is necessary. Otherwise, the handler returns `TRUE`. In this case, the handler is responsible for providing the necessary information for displaying feedback to the user, by calling `gdk_drag_status()`.

If the decision whether the drop will be accepted or rejected can't be made based solely on the cursor position and the type of the data, the handler may inspect the dragged data by calling `gtk_drag_get_data()` and defer the `gdk_drag_status()` call to the “drag-data-received” handler. Note that you must pass GTK_DEST_DEFAULT_DROP, GTK_DEST_DEFAULT_MOTION or GTK_DEST_DEFAULT_ALL to `gtk_drag_dest_set()` when using the drag-motion signal that way.

Also note that there is no drag-enter signal. The drag receiver has to keep track of whether he has received any drag-motion signals since the last “drag-leave” and if not, treat the drag-motion signal as an "enter" signal. Upon an "enter", the handler will typically highlight the drop site with `gtk_drag_highlight()`.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    static void
    drag_motion (GtkWidget      *widget,
                 GdkDragContext *context,
                 gint            x,
                 gint            y,
                 guint           time)
    {
      GdkAtom target;

      PrivateData *private_data = GET_PRIVATE_DATA (widget);

      if (!private_data->drag_highlight)
       {
         private_data->drag_highlight = 1;
         gtk_drag_highlight (widget);
       }

      target = gtk_drag_dest_find_target (widget, context, NULL);
      if (target == GDK_NONE)
        gdk_drag_status (context, 0, time);
      else
       {
         private_data->pending_status
            = gdk_drag_context_get_suggested_action (context);
         gtk_drag_get_data (widget, context, target, time);
       }

      return TRUE;
    }

    static void
    drag_data_received (GtkWidget        *widget,
                        GdkDragContext   *context,
                        gint              x,
                        gint              y,
                        GtkSelectionData *selection_data,
                        guint             info,
                        guint             time)
    {
      PrivateData *private_data = GET_PRIVATE_DATA (widget);

      if (private_data->suggested_action)
       {
         private_data->suggested_action = 0;

         // We are getting this data due to a request in drag_motion,
         // rather than due to a request in drag_drop, so we are just
         // supposed to call gdk_drag_status(), not actually paste in
         // the data.

         str = gtk_selection_data_get_text (selection_data);
         if (!data_is_acceptable (str))
           gdk_drag_status (context, 0, time);
         else
           gdk_drag_status (context,
                            private_data->suggested_action,
                            time);
       }
      else
       {
         // accept the drop
       }
    }

#### Parameters

widget | the object which received the signal |
context | the drag context |
x | the x coordinate of the current cursor position |
y | the y coordinate of the current cursor position |
time | the timestamp of the motion event |
user_data | user data set when the signal handler was connected. |

#### Returns

whether the cursor position is in a drop zone

Flags: Run Last

### The `“draw”` signal

    gboolean
    user_function (GtkWidget    *widget,
                   CairoContext *cr,
                   gpointer      user_data)

This signal is emitted when a widget is supposed to render itself. The `widget` 's top left corner must be painted at the origin of the passed in context and be sized to the values returned by `gtk_widget_get_allocated_width()` and `gtk_widget_get_allocated_height()`.

Signal handlers connected to this signal can modify the cairo context passed as `cr` in any way they like and don't need to restore it. The signal emission takes care of calling `cairo_save()` before and `cairo_restore()` after invoking the handler.

The signal handler will get a `cr` with a clip region already set to the widget's dirty region, i.e. to the area that needs repainting. Complicated widgets that want to avoid redrawing themselves completely can get the full extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can get a finer-grained representation of the dirty region with `cairo_copy_clip_rectangle_list()`.

#### Parameters

widget | the object which received the signal |
cr | the cairo context to draw to |
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

Since: 3.0

### The `“enter-notify-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::enter-notify-event will be emitted when the pointer enters the `widget` 's window.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_ENTER_NOTIFY_MASK mask.

This signal will be sent to the grab widget if there is one.

#### Parameters

widget | the object which received the signal |
event | the GdkEventCrossing which triggered this signal. | [type Gdk.EventCrossing]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The GTK+ main loop will emit three signals for each GDK event delivered to a widget: one generic ::event signal, another, more specific, signal that matches the type of event delivered (e.g. “key-press-event”) and finally a generic “event-after” signal.

#### Parameters

widget | the object which received the signal. |
event | the GdkEvent which triggered this signal |
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event and to cancel the emission of the second specific ::event signal. `FALSE` to propagate the event further and to allow the emission of the second signal. The ::event-after signal is emitted regardless of the return value.

Flags: Run Last

### The `“event-after”` signal

    void
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

After the emission of the “event” signal and (optionally) the second more specific signal, ::event-after will be emitted regardless of the previous two signals handlers return values.

#### Parameters

widget | the object which received the signal. |
event | the GdkEvent which triggered this signal |
user_data | user data set when the signal handler was connected. |

### The `“focus”` signal

    gboolean
    user_function (GtkWidget       *widget,
                   GtkDirectionType direction,
                   gpointer         user_data)

#### Parameters

widget | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“focus-in-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::focus-in-event signal will be emitted when the keyboard focus enters the `widget` 's window.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_FOCUS_CHANGE_MASK mask.

#### Parameters

widget | the object which received the signal |
event | the GdkEventFocus which triggered this signal. | [type Gdk.EventFocus]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“focus-out-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::focus-out-event signal will be emitted when the keyboard focus leaves the `widget` 's window.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_FOCUS_CHANGE_MASK mask.

#### Parameters

widget | the object which received the signal |
event | the GdkEventFocus which triggered this signal. | [type Gdk.EventFocus]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“grab-broken-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

Emitted when a pointer or keyboard grab on a window belonging to `widget` gets broken.

On X11, this happens when the grab window becomes unviewable (i.e. it or one of its ancestors is unmapped), or if the same application grabs the pointer or keyboard again.

#### Parameters

widget | the object which received the signal |
event | the GdkEventGrabBroken event. | [type Gdk.EventGrabBroken]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

Since: 2.8

### The `“grab-focus”` signal

    void
    user_function (GtkWidget *widget,
                   gpointer   user_data)

#### Parameters

widget | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Action

### The `“grab-notify”` signal

    void
    user_function (GtkWidget *widget,
                   gboolean   was_grabbed,
                   gpointer   user_data)

The ::grab-notify signal is emitted when a widget becomes shadowed by a GTK+ grab (not a pointer or keyboard grab) on another widget, or when it becomes unshadowed due to a grab being removed.

A widget is shadowed by a `gtk_grab_add()` when the topmost grab widget in the grab stack of its window group is not its ancestor.

#### Parameters

widget | the object which received the signal |
was_grabbed | `FALSE` if the widget becomes shadowed, `TRUE` if it becomes unshadowed |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“hide”` signal

    void
    user_function (GtkWidget *widget,
                   gpointer   user_data)

The ::hide signal is emitted when `widget` is hidden, for example with `gtk_widget_hide()`.

#### Parameters

widget | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“hierarchy-changed”` signal

    void
    user_function (GtkWidget *widget,
                   GtkWidget *previous_toplevel,
                   gpointer   user_data)

The ::hierarchy-changed signal is emitted when the anchored state of a widget changes. A widget is “anchored” when its toplevel ancestor is a GtkWindow. This signal is emitted when a widget changes from un-anchored to anchored or vice-versa.

#### Parameters

widget | the object on which the signal is emitted |
previous_toplevel | the previous toplevel ancestor, or `NULL` if the widget was previously unanchored. | [allow-none]
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“key-press-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::key-press-event signal is emitted when a key is pressed. The signal emission will reoccur at the key-repeat rate when the key is kept pressed.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_KEY_PRESS_MASK mask.

This signal will be sent to the grab widget if there is one.

#### Parameters

widget | the object which received the signal |
event | the GdkEventKey which triggered this signal. | [type Gdk.EventKey]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“key-release-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::key-release-event signal is emitted when a key is released.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_KEY_RELEASE_MASK mask.

This signal will be sent to the grab widget if there is one.

#### Parameters

widget | the object which received the signal |
event | the GdkEventKey which triggered this signal. | [type Gdk.EventKey]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“keynav-failed”` signal

    gboolean
    user_function (GtkWidget       *widget,
                   GtkDirectionType direction,
                   gpointer         user_data)

Gets emitted if keyboard navigation fails. See `gtk_widget_keynav_failed()` for details.

#### Parameters

widget | the object which received the signal |
direction | the direction of movement |
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` if stopping keyboard navigation is fine, `FALSE` if the emitting widget should try to handle the keyboard navigation attempt in its parent container(s).

Flags: Run Last

Since: 2.12

### The `“leave-notify-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::leave-notify-event will be emitted when the pointer leaves the `widget` 's window.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_LEAVE_NOTIFY_MASK mask.

This signal will be sent to the grab widget if there is one.

#### Parameters

widget | the object which received the signal |
event | the GdkEventCrossing which triggered this signal. | [type Gdk.EventCrossing]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“map”` signal

    void
    user_function (GtkWidget *widget,
                   gpointer   user_data)

The ::map signal is emitted when `widget` is going to be mapped, that is when the widget is visible (which is controlled with `gtk_widget_set_visible()`) and all its parents up to the toplevel widget are also visible. Once the map has occurred, “map-event” will be emitted.

The ::map signal can be used to determine whether a widget will be drawn, for instance it can resume an animation that was stopped during the emission of “unmap”.

#### Parameters

widget | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“map-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::map-event signal will be emitted when the `widget` 's window is mapped. A window is mapped when it becomes visible on the screen.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_STRUCTURE_MASK mask. GDK will enable this mask automatically for all new windows.

#### Parameters

widget | the object which received the signal |
event | the GdkEventAny which triggered this signal. | [type Gdk.EventAny]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“mnemonic-activate”` signal

    gboolean
    user_function (GtkWidget *widget,
                   gboolean   group_cycling,
                   gpointer   user_data)

The default handler for this signal activates `widget` if `group_cycling` is `FALSE`, or just makes `widget` grab focus if `group_cycling` is `TRUE`.

#### Parameters

widget | the object which received the signal. |
group_cycling | `TRUE` if there are other widgets with the same mnemonic |
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“motion-notify-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::motion-notify-event signal is emitted when the pointer moves over the widget's GdkWindow.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_POINTER_MOTION_MASK mask.

This signal will be sent to the grab widget if there is one.

#### Parameters

widget | the object which received the signal. |
event | the GdkEventMotion which triggered this signal. | [type Gdk.EventMotion]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“move-focus”` signal

    void
    user_function (GtkWidget       *widget,
                   GtkDirectionType direction,
                   gpointer         user_data)

#### Parameters

widget | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Action

### The `“parent-set”` signal

    void
    user_function (GtkWidget *widget,
                   GtkWidget *old_parent,
                   gpointer   user_data)

The ::parent-set signal is emitted when a new parent has been set on a widget.

#### Parameters

widget | the object on which the signal is emitted |
old_parent | the previous parent, or `NULL` if the widget just got its initial parent. | [allow-none]
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“popup-menu”` signal

    gboolean
    user_function (GtkWidget *widget,
                   gpointer   user_data)

This signal gets emitted whenever a widget should pop up a context menu. This usually happens through the standard key binding mechanism; by pressing a certain key while a widget is focused, the user can cause the widget to pop up a menu. For example, the GtkEntry widget creates a menu with clipboard commands. See the Popup Menu Migration Checklist for an example of how to use this signal.

#### Parameters

widget | the object which received the signal |
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` if a menu was activated

Flags: Action

### The `“property-notify-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::property-notify-event signal will be emitted when a property on the `widget` 's window has been changed or deleted.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_PROPERTY_CHANGE_MASK mask.

#### Parameters

widget | the object which received the signal |
event | the GdkEventProperty which triggered this signal. | [type Gdk.EventProperty]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“proximity-in-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

To receive this signal the GdkWindow associated to the widget needs to enable the GDK_PROXIMITY_IN_MASK mask.

This signal will be sent to the grab widget if there is one.

#### Parameters

widget | the object which received the signal |
event | the GdkEventProximity which triggered this signal. | [type Gdk.EventProximity]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“proximity-out-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

To receive this signal the GdkWindow associated to the widget needs to enable the GDK_PROXIMITY_OUT_MASK mask.

This signal will be sent to the grab widget if there is one.

#### Parameters

widget | the object which received the signal |
event | the GdkEventProximity which triggered this signal. | [type Gdk.EventProximity]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“query-tooltip”` signal

    gboolean
    user_function (GtkWidget  *widget,
                   gint        x,
                   gint        y,
                   gboolean    keyboard_mode,
                   GtkTooltip *tooltip,
                   gpointer    user_data)

Emitted when “has-tooltip” is `TRUE` and the hover timeout has expired with the cursor hovering "above" `widget` ; or emitted when `widget` got focus in keyboard mode.

Using the given coordinates, the signal handler should determine whether a tooltip should be shown for `widget` . If this is the case `TRUE` should be returned, `FALSE` otherwise. Note that if `keyboard_mode` is `TRUE`, the values of `x` and `y` are undefined and should not be used.

The signal handler is free to manipulate `tooltip` with the therefore destined function calls.

#### Parameters

widget | the object which received the signal |
x | the x coordinate of the cursor position where the request has been emitted, relative to `widget` 's left side |
y | the y coordinate of the cursor position where the request has been emitted, relative to `widget` 's top |
keyboard_mode | `TRUE` if the tooltip was triggered using the keyboard |
tooltip | a GtkTooltip |
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` if `tooltip` should be shown right now, `FALSE` otherwise.

Flags: Run Last

Since: 2.12

### The `“realize”` signal

    void
    user_function (GtkWidget *widget,
                   gpointer   user_data)

The ::realize signal is emitted when `widget` is associated with a GdkWindow, which means that `gtk_widget_realize()` has been called or the widget has been mapped (that is, it is going to be drawn).

#### Parameters

widget | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“screen-changed”` signal

    void
    user_function (GtkWidget *widget,
                   GdkScreen *previous_screen,
                   gpointer   user_data)

The ::screen-changed signal gets emitted when the screen of a widget has changed.

#### Parameters

widget | the object on which the signal is emitted |
previous_screen | the previous screen, or `NULL` if the widget was not associated with a screen before. | [allow-none]
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“scroll-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::scroll-event signal is emitted when a button in the 4 to 7 range is pressed. Wheel mice are usually configured to generate button press events for buttons 4 and 5 when the wheel is turned.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_SCROLL_MASK mask.

This signal will be sent to the grab widget if there is one.

#### Parameters

widget | the object which received the signal. |
event | the GdkEventScroll which triggered this signal. | [type Gdk.EventScroll]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“selection-clear-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::selection-clear-event signal will be emitted when the the `widget` 's window has lost ownership of a selection.

#### Parameters

widget | the object which received the signal |
event | the GdkEventSelection which triggered this signal. | [type Gdk.EventSelection]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“selection-get”` signal

    void
    user_function (GtkWidget        *widget,
                   GtkSelectionData *data,
                   guint             info,
                   guint             time,
                   gpointer          user_data)

#### Parameters

widget | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“selection-notify-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

#### Parameters

widget | the object which received the signal. |
event | . | [type Gdk.EventSelection]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“selection-received”` signal

    void
    user_function (GtkWidget        *widget,
                   GtkSelectionData *data,
                   guint             time,
                   gpointer          user_data)

#### Parameters

widget | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“selection-request-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::selection-request-event signal will be emitted when another client requests ownership of the selection owned by the `widget` 's window.

#### Parameters

widget | the object which received the signal |
event | the GdkEventSelection which triggered this signal. | [type Gdk.EventSelection]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“show”` signal

    void
    user_function (GtkWidget *widget,
                   gpointer   user_data)

The ::show signal is emitted when `widget` is shown, for example with `gtk_widget_show()`.

#### Parameters

widget | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“show-help”` signal

    gboolean
    user_function (GtkWidget        *widget,
                   GtkWidgetHelpType help_type,
                   gpointer          user_data)

#### Parameters

widget | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Action

### The `“size-allocate”` signal

    void
    user_function (GtkWidget    *widget,
                   GdkRectangle *allocation,
                   gpointer      user_data)

#### Parameters

widget | the object which received the signal. |
allocation | the region which has been allocated to the widget. | [type Gtk.Allocation]
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“state-changed”` signal

    void
    user_function (GtkWidget   *widget,
                   GtkStateType state,
                   gpointer     user_data)

The ::state-changed signal is emitted when the widget state changes. See `gtk_widget_get_state()`.

`GtkWidget::state-changed` has been deprecated since version 3.0 and should not be used in newly-written code.

Use “state-flags-changed” instead.

#### Parameters

widget | the object which received the signal. |
state | the previous state |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“state-flags-changed”` signal

    void
    user_function (GtkWidget    *widget,
                   GtkStateFlags flags,
                   gpointer      user_data)

The ::state-flags-changed signal is emitted when the widget state changes, see `gtk_widget_get_state_flags()`.

#### Parameters

widget | the object which received the signal. |
flags | The previous state flags. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

Since: 3.0

### The `“style-set”` signal

    void
    user_function (GtkWidget *widget,
                   GtkStyle  *previous_style,
                   gpointer   user_data)

The ::style-set signal is emitted when a new style has been set on a widget. Note that style-modifying functions like `gtk_widget_modify_base()` also cause this signal to be emitted.

Note that this signal is emitted for changes to the deprecated GtkStyle. To track changes to the GtkStyleContext associated with a widget, use the “style-updated” signal.

`GtkWidget::style-set` has been deprecated since version 3.0 and should not be used in newly-written code.

Use the “style-updated” signal

#### Parameters

widget | the object on which the signal is emitted |
previous_style | the previous style, or `NULL` if the widget just got its initial style. | [allow-none]
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“style-updated”` signal

    void
    user_function (GtkWidget *widget,
                   gpointer   user_data)

The ::style-updated signal is a convenience signal that is emitted when the “changed” signal is emitted on the `widget` 's associated GtkStyleContext as returned by `gtk_widget_get_style_context()`.

Note that style-modifying functions like `gtk_widget_override_color()` also cause this signal to be emitted.

#### Parameters

widget | the object on which the signal is emitted |
user_data | user data set when the signal handler was connected. |

Flags: Run First

Since: 3.0

### The `“touch-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *arg1,
                   gpointer   user_data)

Flags: Run Last

### The `“unmap”` signal

    void
    user_function (GtkWidget *widget,
                   gpointer   user_data)

The ::unmap signal is emitted when `widget` is going to be unmapped, which means that either it or any of its parents up to the toplevel widget have been set as hidden.

As ::unmap indicates that a widget will not be shown any longer, it can be used to, for example, stop an animation on the widget.

#### Parameters

widget | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“unmap-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::unmap-event signal will be emitted when the `widget` 's window is unmapped. A window is unmapped when it becomes invisible on the screen.

To receive this signal, the GdkWindow associated to the widget needs to enable the GDK_STRUCTURE_MASK mask. GDK will enable this mask automatically for all new windows.

#### Parameters

widget | the object which received the signal |
event | the GdkEventAny which triggered this signal. | [type Gdk.EventAny]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“unrealize”` signal

    void
    user_function (GtkWidget *widget,
                   gpointer   user_data)

The ::unrealize signal is emitted when the GdkWindow associated with `widget` is destroyed, which means that `gtk_widget_unrealize()` has been called or the widget has been unmapped (that is, it is going to be hidden).

#### Parameters

widget | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“visibility-notify-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::visibility-notify-event will be emitted when the `widget` 's window is obscured or unobscured.

To receive this signal the GdkWindow associated to the widget needs to enable the GDK_VISIBILITY_NOTIFY_MASK mask.

`GtkWidget::visibility-notify-event` has been deprecated since version 3.12 and should not be used in newly-written code.

Modern composited windowing systems with pervasive transparency make it impossible to track the visibility of a window reliably, so this signal can not be guaranteed to provide useful information.

#### Parameters

widget | the object which received the signal |
event | the GdkEventVisibility which triggered this signal. | [type Gdk.EventVisibility]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last

### The `“window-state-event”` signal

    gboolean
    user_function (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)

The ::window-state-event will be emitted when the state of the toplevel window associated to the `widget` changes.

To receive this signal the GdkWindow associated to the widget needs to enable the GDK_STRUCTURE_MASK mask. GDK will enable this mask automatically for all new windows.

#### Parameters

widget | the object which received the signal |
event | the GdkEventWindowState which triggered this signal. | [type Gdk.EventWindowState]
user_data | user data set when the signal handler was connected. |

#### Returns

`TRUE` to stop other handlers from being invoked for the event. `FALSE` to propagate the event further.

Flags: Run Last