Class

GtkWidget

Description [src]

abstract class Gtk.Widget : GObject.InitiallyUnowned
  implements Atk.ImplementorIface, Gtk.Buildable {
  /* No available fields */
}

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

Height-for-width Geometry Management # {#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][container-geometry-management] 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:

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:

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:

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][gtk3-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:

<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:

<object class="GtkLabel" 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:

<object class="GtkButton" id="button1">
  <style>
    <class name="my-special-button-class"/>
    <class name="dark-button"/>
  </style>
</object>

Building composite widgets from template XML ## {#composite-templates}

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:

<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:

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:

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.

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);
}

static void
foo_widget_init (FooWidget *widget)
{

}

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.

// 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);
}

Hierarchy

hierarchy this GtkWidget implements_0 AtkImplementorIface this--implements_0 implements_1 GtkBuildable this--implements_1 ancestor_0 GInitiallyUnowned ancestor_0--this ancestor_1 GObject ancestor_1--ancestor_0

Constructors

gtk_widget_new

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.

Functions

gtk_widget_get_default_direction

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

gtk_widget_get_default_style

Returns the default style used by all widgets initially.

deprecated: 3.0 

gtk_widget_pop_composite_child

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

deprecated: 3.10 

gtk_widget_push_composite_child

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

deprecated: 3.10 

gtk_widget_set_default_direction

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

Instance methods

gtk_widget_activate

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.

gtk_widget_add_accelerator

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.

gtk_widget_add_device_events

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

since: 3.0

gtk_widget_add_events

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

gtk_widget_add_mnemonic_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 GtkWidget::destroy signal or a weak notifier.

since: 2.4

gtk_widget_add_tick_callback

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.

since: 3.8

gtk_widget_can_activate_accel

Determines whether an accelerator that activates the signal identified by signal_id can currently be activated. This is done by emitting the GtkWidget::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.

since: 2.4

gtk_widget_child_focus

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_notify

Emits a GtkWidget::child-notify signal for the [child property][child-properties] child_property on widget.

gtk_widget_class_path

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().

deprecated: 3.0 

gtk_widget_compute_expand

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().

gtk_widget_create_pango_context

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().

gtk_widget_create_pango_layout

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

gtk_widget_destroy

Destroys a widget.

gtk_widget_destroyed

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.

gtk_widget_device_is_shadowed

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 GtkWidget::grab-notify signal to check for specific devices. See gtk_device_grab_add().

since: 3.0

gtk_drag_begin

This function is equivalent to gtk_drag_begin_with_coordinates(), passing -1, -1 as coordinates.

deprecated: 3.10 

gtk_drag_begin_with_coordinates

Initiates a drag on the source side. The function only needs to be used when the application is starting drags itself, and is not needed when gtk_drag_source_set() is used.

since: 3.10

gtk_drag_check_threshold

Checks to see if a mouse drag starting at (start_x, start_y) and ending at (current_x, current_y) has passed the GTK+ drag threshold, and thus should trigger the beginning of a drag-and-drop operation.

gtk_drag_dest_add_image_targets

Add the image targets supported by GtkSelectionData to the target list of the drag destination. The targets are added with info = 0. If you need another value, use gtk_target_list_add_image_targets() and gtk_drag_dest_set_target_list().

since: 2.6

gtk_drag_dest_add_text_targets

Add the text targets supported by GtkSelectionData to the target list of the drag destination. The targets are added with info = 0. If you need another value, use gtk_target_list_add_text_targets() and gtk_drag_dest_set_target_list().

since: 2.6

gtk_drag_dest_add_uri_targets

Add the URI targets supported by GtkSelectionData to the target list of the drag destination. The targets are added with info = 0. If you need another value, use gtk_target_list_add_uri_targets() and gtk_drag_dest_set_target_list().

since: 2.6

gtk_drag_dest_find_target

Looks for a match between the supported targets of context and the dest_target_list, returning the first matching target, otherwise returning GDK_NONE. dest_target_list should usually be the return value from gtk_drag_dest_get_target_list(), but some widgets may have different valid targets for different parts of the widget; in that case, they will have to implement a drag_motion handler that passes the correct target list to this function.

gtk_drag_dest_get_target_list

Returns the list of targets this widget can accept from drag-and-drop.

gtk_drag_dest_get_track_motion

Returns whether the widget has been configured to always emit GtkWidget::drag-motion signals.

since: 2.10

gtk_drag_dest_set

Sets a widget as a potential drop destination, and adds default behaviors.

gtk_drag_dest_set_proxy

Sets this widget as a proxy for drops to another window.

deprecated: 3.22 

gtk_drag_dest_set_target_list

Sets the target types that this widget can accept from drag-and-drop. The widget must first be made into a drag destination with gtk_drag_dest_set().

gtk_drag_dest_set_track_motion

Tells the widget to emit GtkWidget::drag-motion and GtkWidget::drag-leave events regardless of the targets and the GTK_DEST_DEFAULT_MOTION flag.

since: 2.10

gtk_drag_dest_unset

Clears information about a drop destination set with gtk_drag_dest_set(). The widget will no longer receive notification of drags.

gtk_drag_get_data

Gets the data associated with a drag. When the data is received or the retrieval fails, GTK+ will emit a GtkWidget::drag-data-received signal. Failure of the retrieval is indicated by the length field of the selection_data signal parameter being negative. However, when gtk_drag_get_data() is called implicitely because the GTK_DEST_DEFAULT_DROP was set, then the widget will not receive notification of failed drops.

gtk_drag_highlight

Highlights a widget as a currently hovered drop target. To end the highlight, call gtk_drag_unhighlight(). GTK+ calls this automatically if GTK_DEST_DEFAULT_HIGHLIGHT is set.

gtk_drag_source_add_image_targets

Add the writable image targets supported by GtkSelectionData to the target list of the drag source. The targets are added with info = 0. If you need another value, use gtk_target_list_add_image_targets() and gtk_drag_source_set_target_list().

since: 2.6

gtk_drag_source_add_text_targets

Add the text targets supported by GtkSelectionData to the target list of the drag source. The targets are added with info = 0. If you need another value, use gtk_target_list_add_text_targets() and gtk_drag_source_set_target_list().

since: 2.6

gtk_drag_source_add_uri_targets

Add the URI targets supported by GtkSelectionData to the target list of the drag source. The targets are added with info = 0. If you need another value, use gtk_target_list_add_uri_targets() and gtk_drag_source_set_target_list().

since: 2.6

gtk_drag_source_get_target_list

Gets the list of targets this widget can provide for drag-and-drop.

since: 2.4

gtk_drag_source_set

Sets up a widget so that GTK+ will start a drag operation when the user clicks and drags on the widget. The widget must have a window.

gtk_drag_source_set_icon_gicon

Sets the icon that will be used for drags from a particular source to icon. See the docs for GtkIconTheme for more details.

since: 3.2

gtk_drag_source_set_icon_name

Sets the icon that will be used for drags from a particular source to a themed icon. See the docs for GtkIconTheme for more details.

since: 2.8

gtk_drag_source_set_icon_pixbuf

Sets the icon that will be used for drags from a particular widget from a GdkPixbuf. GTK+ retains a reference for pixbuf and will release it when it is no longer needed.

gtk_drag_source_set_icon_stock

Sets the icon that will be used for drags from a particular source to a stock icon.

deprecated: 3.10 

gtk_drag_source_set_target_list

Changes the target types that this widget offers for drag-and-drop. The widget must first be made into a drag source with gtk_drag_source_set().

since: 2.4

gtk_drag_source_unset

Undoes the effects of gtk_drag_source_set().

gtk_drag_unhighlight

Removes a highlight set by gtk_drag_highlight() from a widget.

gtk_widget_draw

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

since: 3.0

gtk_widget_ensure_style

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

deprecated: 3.0 

gtk_widget_error_bell

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

since: 2.12

gtk_widget_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.

gtk_widget_freeze_child_notify

Stops emission of GtkWidget::child-notify signals on widget. The signals are queued until gtk_widget_thaw_child_notify() is called on widget.

gtk_widget_get_accessible

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

gtk_widget_get_action_group

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

since: 3.16

gtk_widget_get_allocated_baseline

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

since: 3.10

gtk_widget_get_allocated_height

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

gtk_widget_get_allocated_size

Retrieves the widget’s allocated size.

since: 3.20

gtk_widget_get_allocated_width

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

gtk_widget_get_allocation

Retrieves the widget’s allocation.

since: 2.18

gtk_widget_get_ancestor

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().

gtk_widget_get_app_paintable

Determines whether the application intends to draw on the widget in an GtkWidget::draw handler.

since: 2.18

gtk_widget_get_can_default

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

since: 2.18

gtk_widget_get_can_focus

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

since: 2.18

gtk_widget_get_child_requisition

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.

deprecated: 3.0 

gtk_widget_get_child_visible

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

gtk_widget_get_clip

Retrieves the widget’s clip area.

since: 3.14

gtk_widget_get_clipboard

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.

since: 2.2

gtk_widget_get_composite_name

Obtains the composite name of a widget.

deprecated: 3.10 

gtk_widget_get_device_enabled

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

since: 3.0

gtk_widget_get_device_events

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.

since: 3.0

gtk_widget_get_direction

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

gtk_widget_get_display

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.

since: 2.2

gtk_widget_get_double_buffered

Determines whether the widget is double buffered.

since: 2.18

gtk_widget_get_events

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

gtk_widget_get_focus_on_click

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

since: 3.20

gtk_widget_get_font_map

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

since: 3.18

gtk_widget_get_font_options

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

since: 3.18

gtk_widget_get_frame_clock

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.

since: 3.8

gtk_widget_get_halign

Gets the value of the GtkWidget:halign property.

gtk_widget_get_has_tooltip

Returns the current value of the has-tooltip property. See GtkWidget:has-tooltip for more information.

since: 2.12

gtk_widget_get_has_window

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

since: 2.18

gtk_widget_get_hexpand

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.

gtk_widget_get_hexpand_set

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

gtk_widget_get_mapped

Whether the widget is mapped.

since: 2.20

gtk_widget_get_margin_bottom

Gets the value of the GtkWidget:margin-bottom property.

since: 3.0

gtk_widget_get_margin_end

Gets the value of the GtkWidget:margin-end property.

since: 3.12

gtk_widget_get_margin_left

Gets the value of the GtkWidget:margin-left property.

deprecated: 3.12 since: 3.0

gtk_widget_get_margin_right

Gets the value of the GtkWidget:margin-right property.

deprecated: 3.12 since: 3.0

gtk_widget_get_margin_start

Gets the value of the GtkWidget:margin-start property.

since: 3.12

gtk_widget_get_margin_top

Gets the value of the GtkWidget:margin-top property.

since: 3.0

gtk_widget_get_modifier_mask

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

since: 3.4

gtk_widget_get_modifier_style

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.

deprecated: 3.0 

gtk_widget_get_name

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

gtk_widget_get_no_show_all

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

since: 2.4

gtk_widget_get_opacity

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

since: 3.8

gtk_widget_get_pango_context

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 GtkWidget::screen-changed signal on the widget.

gtk_widget_get_parent

Returns the parent container of widget.

gtk_widget_get_parent_window

Gets widget’s parent window, or NULL if it does not have one.

gtk_widget_get_path

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

gtk_widget_get_pointer

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.

deprecated: 3.4 

gtk_widget_get_preferred_height

Retrieves a widget’s initial minimum and natural height.

since: 3.0

gtk_widget_get_preferred_height_and_baseline_for_width

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.

since: 3.10

gtk_widget_get_preferred_height_for_width

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

since: 3.0

gtk_widget_get_preferred_size

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

since: 3.0

gtk_widget_get_preferred_width

Retrieves a widget’s initial minimum and natural width.

since: 3.0

gtk_widget_get_preferred_width_for_height

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

since: 3.0

gtk_widget_get_realized

Determines whether widget is realized.

since: 2.20

gtk_widget_get_receives_default

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.

since: 2.18

gtk_widget_get_request_mode

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

since: 3.0

gtk_widget_get_requisition

Retrieves the widget’s requisition.

deprecated: 3.0 since: 2.20

gtk_widget_get_root_window

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.

deprecated: 3.12 since: 2.2

gtk_widget_get_scale_factor

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).

since: 3.10

gtk_widget_get_screen

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.

since: 2.2

gtk_widget_get_sensitive

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

since: 2.18

gtk_widget_get_settings

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

gtk_widget_get_size_request

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.

gtk_widget_get_state

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

deprecated: 3.0 since: 2.18

gtk_widget_get_state_flags

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.

since: 3.0

gtk_widget_get_style

Simply an accessor function that returns widget->style.

deprecated: 3.0 

gtk_widget_get_style_context

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

gtk_widget_get_support_multidevice

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

gtk_widget_get_template_child

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

gtk_widget_get_tooltip_markup

Gets the contents of the tooltip for widget.

since: 2.12

gtk_widget_get_tooltip_text

Gets the contents of the tooltip for widget.

since: 2.12

gtk_widget_get_tooltip_window

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().

since: 2.12

gtk_widget_get_toplevel

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.

gtk_widget_get_valign

Gets the value of the GtkWidget:valign property.

gtk_widget_get_valign_with_baseline

Gets the value of the GtkWidget:valign property, including GTK_ALIGN_BASELINE.

since: 3.10

gtk_widget_get_vexpand

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

gtk_widget_get_vexpand_set

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

gtk_widget_get_visible

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.

since: 2.18

gtk_widget_get_visual

Gets the visual that will be used to render widget.

gtk_widget_get_window

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

since: 2.14

gtk_grab_add

Makes widget the current grabbed widget.

gtk_widget_grab_default

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.

gtk_widget_grab_focus

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.

gtk_grab_remove

Removes the grab from the given widget.

gtk_widget_has_default

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

since: 2.18

gtk_widget_has_focus

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.

since: 2.18

gtk_widget_has_grab

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

since: 2.18

gtk_widget_has_rc_style

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

deprecated: 3.0 since: 2.20

gtk_widget_has_screen

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.

since: 2.2

gtk_widget_has_visible_focus

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.

since: 3.2

gtk_widget_hide

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

gtk_widget_hide_on_delete

Utility function; intended to be connected to the GtkWidget::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.

gtk_widget_in_destruction

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

gtk_widget_init_template

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().

since: 3.10

gtk_widget_input_shape_combine_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.

since: 3.0

gtk_widget_insert_action_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.

since: 3.6

gtk_widget_intersect

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.

gtk_widget_is_ancestor

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

gtk_widget_is_composited

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.

deprecated: 3.22 since: 2.10

gtk_widget_is_drawable

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

since: 2.18

gtk_widget_is_focus

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

gtk_widget_is_sensitive

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

since: 2.18

gtk_widget_is_toplevel

Determines whether widget is a toplevel widget.

since: 2.18

gtk_widget_is_visible

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

since: 3.8

gtk_widget_keynav_failed

This function should be called whenever keyboard navigation within a single widget hits a boundary. The function emits the GtkWidget::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():.

since: 2.12

gtk_widget_list_accel_closures

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().

gtk_widget_list_action_prefixes

Retrieves a NULL-terminated array of strings containing the prefixes of GActionGroups available to widget.

since: 3.16

gtk_widget_list_mnemonic_labels

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()).

since: 2.4

gtk_widget_map

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

gtk_widget_mnemonic_activate

Emits the GtkWidget::mnemonic-activate signal.

gtk_widget_modify_base

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

deprecated: 3.0 

gtk_widget_modify_bg

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

deprecated: 3.0 

gtk_widget_modify_cursor

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

deprecated: 3.0 since: 2.12

gtk_widget_modify_fg

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

deprecated: 3.0 

gtk_widget_modify_font

Sets the font to use for a widget.

deprecated: 3.0 

gtk_widget_modify_style

Modifies style values on the widget.

deprecated: 3.0 

gtk_widget_modify_text

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

deprecated: 3.0 

gtk_widget_override_background_color

Sets the background color to use for a widget.

deprecated: 3.16 since: 3.0

gtk_widget_override_color

Sets the color to use for a widget.

deprecated: 3.16 since: 3.0

gtk_widget_override_cursor

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().

deprecated: 3.16 since: 3.0

gtk_widget_override_font

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

deprecated: 3.16 since: 3.0

gtk_widget_override_symbolic_color

Sets a symbolic color for a widget.

deprecated: 3.16 since: 3.0

gtk_widget_path

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.

deprecated: 3.0 

gtk_widget_queue_allocate

This function is only for use in widget implementations.

since: 3.20

gtk_widget_queue_compute_expand

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

gtk_widget_queue_draw

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

gtk_widget_queue_draw_area

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

gtk_widget_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. 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.

since: 3.0

gtk_widget_queue_resize

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.

gtk_widget_queue_resize_no_redraw

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

since: 2.4

gtk_widget_realize

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.

gtk_widget_region_intersect

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.

deprecated: 3.14 

gtk_widget_register_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.

since: 3.8

gtk_widget_remove_accelerator

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

gtk_widget_remove_mnemonic_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().

since: 2.4

gtk_widget_remove_tick_callback

Removes a tick callback previously registered with gtk_widget_add_tick_callback().

since: 3.8

gtk_widget_render_icon

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.

deprecated: 3.0 

gtk_widget_render_icon_pixbuf

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.

deprecated: 3.10 since: 3.0

gtk_widget_reparent

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

deprecated: 3.14 

gtk_widget_reset_rc_styles

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.

deprecated: 3.0 

gtk_widget_reset_style

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().

since: 3.0

gtk_widget_send_expose

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().

deprecated: 3.22 

gtk_widget_send_focus_change

Sends the focus change event to widget.

since: 2.20

gtk_widget_set_accel_path

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().).

gtk_widget_set_allocation

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

since: 2.18

gtk_widget_set_app_paintable

Sets whether the application intends to draw on the widget in an GtkWidget::draw handler.

gtk_widget_set_can_default

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

since: 2.18

gtk_widget_set_can_focus

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

since: 2.18

gtk_widget_set_child_visible

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

gtk_widget_set_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.

since: 3.14

gtk_widget_set_composite_name

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

deprecated: 3.10 

gtk_widget_set_device_enabled

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

since: 3.0

gtk_widget_set_device_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.

since: 3.0

gtk_widget_set_direction

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).

gtk_widget_set_double_buffered

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.

deprecated: 3.14 

gtk_widget_set_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.

gtk_widget_set_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.

since: 3.20

gtk_widget_set_font_map

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

since: 3.18

gtk_widget_set_font_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.

since: 3.18

gtk_widget_set_halign

Sets the horizontal alignment of widget. See the GtkWidget:halign property.

gtk_widget_set_has_tooltip

Sets the has-tooltip property on widget to has_tooltip. See GtkWidget:has-tooltip for more information.

since: 2.12

gtk_widget_set_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 GtkWidget::realize must announce this by calling this function with has_window = FALSE.

since: 2.18

gtk_widget_set_hexpand

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.

gtk_widget_set_hexpand_set

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

gtk_widget_set_mapped

Marks the widget as being mapped.

since: 2.20

gtk_widget_set_margin_bottom

Sets the bottom margin of widget. See the GtkWidget:margin-bottom property.

since: 3.0

gtk_widget_set_margin_end

Sets the end margin of widget. See the GtkWidget:margin-end property.

since: 3.12

gtk_widget_set_margin_left

Sets the left margin of widget. See the GtkWidget:margin-left property.

deprecated: 3.12 since: 3.0

gtk_widget_set_margin_right

Sets the right margin of widget. See the GtkWidget:margin-right property.

deprecated: 3.12 since: 3.0

gtk_widget_set_margin_start

Sets the start margin of widget. See the GtkWidget:margin-start property.

since: 3.12

gtk_widget_set_margin_top

Sets the top margin of widget. See the GtkWidget:margin-top property.

since: 3.0

gtk_widget_set_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).

gtk_widget_set_no_show_all

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

since: 2.4

gtk_widget_set_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:.

since: 3.8

gtk_widget_set_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().

gtk_widget_set_parent_window

Sets a non default parent window for widget.

gtk_widget_set_realized

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

since: 2.20

gtk_widget_set_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.

since: 2.18

gtk_widget_set_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.

gtk_widget_set_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.

gtk_widget_set_size_request

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.

gtk_widget_set_state

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().

deprecated: 3.0 

gtk_widget_set_state_flags

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

since: 3.0

gtk_widget_set_style

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

deprecated: 3.0 

gtk_widget_set_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 GtkWidget::realize, gdk_window_set_support_multidevice() will have to be called manually on them.

since: 3.0

gtk_widget_set_tooltip_markup

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

since: 2.12

gtk_widget_set_tooltip_text

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

since: 2.12

gtk_widget_set_tooltip_window

Replaces the default 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.

since: 2.12

gtk_widget_set_valign

Sets the vertical alignment of widget. See the GtkWidget:valign property.

gtk_widget_set_vexpand

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

gtk_widget_set_vexpand_set

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

gtk_widget_set_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().

since: 2.18

gtk_widget_set_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 GtkWidget::screen-changed signal is necessary.

gtk_widget_set_window

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

since: 2.18

gtk_widget_shape_combine_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.

since: 3.0

gtk_widget_show

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.

gtk_widget_show_all

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

gtk_widget_show_now

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.

gtk_widget_size_allocate

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

gtk_widget_size_allocate_with_baseline

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

since: 3.10

gtk_widget_size_request

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().

deprecated: 3.0 

gtk_widget_style_attach

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

deprecated: 3.0 since: 2.20

gtk_widget_style_get

Gets the values of a multiple style properties of widget.

gtk_widget_style_get_property

Gets the value of a style property of widget.

gtk_widget_style_get_valist

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

gtk_widget_thaw_child_notify

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

gtk_widget_translate_coordinates

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.

gtk_widget_trigger_tooltip_query

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

since: 2.12

gtk_widget_unmap

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

gtk_widget_unparent

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.

gtk_widget_unrealize

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).

gtk_widget_unregister_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.

since: 3.8

gtk_widget_unset_state_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().

since: 3.0

Methods inherited from GObject (43)

Please see GObject for a full list of methods.

Methods inherited from GtkBuildable (10)
gtk_buildable_add_child

Adds a child to buildable. type is an optional string describing how the child should be added.

since: 2.12

gtk_buildable_construct_child

Constructs a child of buildable with the name name.

since: 2.12

gtk_buildable_custom_finished

This is similar to gtk_buildable_parser_finished() but is called once for each custom tag handled by the buildable.

since: 2.12

gtk_buildable_custom_tag_end

This is called at the end of each custom element handled by the buildable.

since: 2.12

gtk_buildable_custom_tag_start

This is called for each unknown element under <child>.

since: 2.12

gtk_buildable_get_internal_child

Get the internal child called childname of the buildable object.

since: 2.12

gtk_buildable_get_name

Gets the name of the buildable object.

since: 2.12

gtk_buildable_parser_finished

Called when the builder finishes the parsing of a [GtkBuilder UI definition][BUILDER-UI]. Note that this will be called once for each time gtk_builder_add_from_file() or gtk_builder_add_from_string() is called on a builder.

since: 2.12

gtk_buildable_set_buildable_property

Sets the property name name to value on the buildable object.

since: 2.12

gtk_buildable_set_name

Sets the name of the buildable object.

since: 2.12

Properties

Gtk.Widget:app-paintable
No description available.

Gtk.Widget:can-default
No description available.

Gtk.Widget:can-focus
No description available.

Gtk.Widget:composite-child
No description available.

Gtk.Widget:double-buffered

Whether the widget is double buffered.

deprecated: 3.14 since: 2.18

Gtk.Widget:events
No description available.

Gtk.Widget:expand

Whether to expand in both directions. Setting this sets both GtkWidget:hexpand and GtkWidget:vexpand.

since: 3.0

Gtk.Widget:focus-on-click

Whether the widget should grab focus when it is clicked with the mouse.

since: 3.20

Gtk.Widget:halign

How to distribute horizontal space if widget gets extra space, see GtkAlign.

since: 3.0

Gtk.Widget:has-default
No description available.

Gtk.Widget:has-focus
No description available.

Gtk.Widget:has-tooltip

Enables or disables the emission of GtkWidget::query-tooltip on widget. A value of TRUE indicates that widget can have a tooltip, in this case the widget will be queried using GtkWidget::query-tooltip to determine whether it will provide a tooltip or not.

since: 2.12

Gtk.Widget:height-request
No description available.

Gtk.Widget:hexpand

Whether to expand horizontally. See gtk_widget_set_hexpand().

since: 3.0

Gtk.Widget:hexpand-set

Whether to use the GtkWidget:hexpand property. See gtk_widget_get_hexpand_set().

since: 3.0

Gtk.Widget:is-focus
No description available.

Gtk.Widget:margin

Sets all four sides’ margin at once. If read, returns max margin on any side.

since: 3.0

Gtk.Widget:margin-bottom

Margin on bottom side of widget.

since: 3.0

Gtk.Widget:margin-end

Margin on end of widget, horizontally. This property supports left-to-right and right-to-left text directions.

since: 3.12

Gtk.Widget:margin-left

Margin on left side of widget.

deprecated: 3.12 since: 3.0

Gtk.Widget:margin-right

Margin on right side of widget.

deprecated: 3.12 since: 3.0

Gtk.Widget:margin-start

Margin on start of widget, horizontally. This property supports left-to-right and right-to-left text directions.

since: 3.12

Gtk.Widget:margin-top

Margin on top side of widget.

since: 3.0

Gtk.Widget:name
No description available.

Gtk.Widget:no-show-all
No description available.

Gtk.Widget:opacity

The requested opacity of the widget. See gtk_widget_set_opacity() for more details about window opacity.

since: 3.8

Gtk.Widget:parent
No description available.

Gtk.Widget:receives-default
No description available.

Gtk.Widget:scale-factor

The scale factor of the widget. See gtk_widget_get_scale_factor() for more details about widget scaling.

since: 3.10

Gtk.Widget:sensitive
No description available.

Gtk.Widget:style

The style of the widget, which contains information about how it will look (colors, etc).

deprecated: Unknown 

Gtk.Widget:tooltip-markup

Sets the text of tooltip to be the given string, which is marked up with the [Pango text markup language][PangoMarkupFormat]. Also see gtk_tooltip_set_markup().

since: 2.12

Gtk.Widget:tooltip-text

Sets the text of tooltip to be the given string.

since: 2.12

Gtk.Widget:valign

How to distribute vertical space if widget gets extra space, see GtkAlign.

since: 3.0

Gtk.Widget:vexpand

Whether to expand vertically. See gtk_widget_set_vexpand().

since: 3.0

Gtk.Widget:vexpand-set

Whether to use the GtkWidget:vexpand property. See gtk_widget_get_vexpand_set().

since: 3.0

Gtk.Widget:visible
No description available.

Gtk.Widget:width-request
No description available.

Gtk.Widget:window

The widget’s window if it is realized, NULL otherwise.

since: 2.14

Signals

Gtk.Widget::accel-closures-changed
No description available.

Gtk.Widget::button-press-event

The ::button-press-event signal will be emitted when a button (typically from a mouse) is pressed.

Gtk.Widget::button-release-event

The ::button-release-event signal will be emitted when a button (typically from a mouse) is released.

Gtk.Widget::can-activate-accel

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.

Gtk.Widget::child-notify

The ::child-notify signal is emitted for each [child property][child-properties] that has changed on an object. The signal’s detail holds the property name.

Gtk.Widget::composited-changed

The ::composited-changed signal is emitted when the composited status of widgets screen changes. See gdk_screen_is_composited().

deprecated: 3.22 

Gtk.Widget::configure-event

The ::configure-event signal will be emitted when the size, position or stacking of the widgets window has changed.

Gtk.Widget::damage-event

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.

since: 2.14

Gtk.Widget::delete-event

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.

Gtk.Widget::destroy

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.

Gtk.Widget::destroy-event

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.

Gtk.Widget::direction-changed

The ::direction-changed signal is emitted when the text direction of a widget changes.

Gtk.Widget::drag-begin

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().

Gtk.Widget::drag-data-delete

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.

Gtk.Widget::drag-data-get

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().

Gtk.Widget::drag-data-received

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 GtkWidget::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.

Gtk.Widget::drag-drop

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 GtkWidget::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.

Gtk.Widget::drag-end

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 GtkWidget::drag-begin.

Gtk.Widget::drag-failed

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.

since: 2.12

Gtk.Widget::drag-leave

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 GtkWidget::drag-motion, e.g. undo highlighting with gtk_drag_unhighlight().

Gtk.Widget::drag-motion

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().

Gtk.Widget::draw

This signal is emitted when a widget is supposed to render itself. The widgets 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().

since: 3.0

Gtk.Widget::enter-notify-event

The ::enter-notify-event will be emitted when the pointer enters the widgets window.

Gtk.Widget::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. GtkWidget::key-press-event) and finally a generic GtkWidget::event-after signal.

Gtk.Widget::event-after

After the emission of the GtkWidget::event signal and (optionally) the second more specific signal, ::event-after will be emitted regardless of the previous two signals handlers return values.

Gtk.Widget::focus
No description available.

Gtk.Widget::focus-in-event

The ::focus-in-event signal will be emitted when the keyboard focus enters the widgets window.

Gtk.Widget::focus-out-event

The ::focus-out-event signal will be emitted when the keyboard focus leaves the widgets window.

Gtk.Widget::grab-broken-event

Emitted when a pointer or keyboard grab on a window belonging to widget gets broken.

since: 2.8

Gtk.Widget::grab-focus
No description available.

Gtk.Widget::grab-notify

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.

Gtk.Widget::hide

The ::hide signal is emitted when widget is hidden, for example with gtk_widget_hide().

Gtk.Widget::hierarchy-changed

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.

Gtk.Widget::key-press-event

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.

Gtk.Widget::key-release-event

The ::key-release-event signal is emitted when a key is released.

Gtk.Widget::keynav-failed

Gets emitted if keyboard navigation fails. See gtk_widget_keynav_failed() for details.

since: 2.12

Gtk.Widget::leave-notify-event

The ::leave-notify-event will be emitted when the pointer leaves the widgets window.

Gtk.Widget::map

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, GtkWidget::map-event will be emitted.

Gtk.Widget::map-event

The ::map-event signal will be emitted when the widgets window is mapped. A window is mapped when it becomes visible on the screen.

Gtk.Widget::mnemonic-activate

The default handler for this signal activates widget if group_cycling is FALSE, or just makes widget grab focus if group_cycling is TRUE.

Gtk.Widget::motion-notify-event

The ::motion-notify-event signal is emitted when the pointer moves over the widget’s GdkWindow.

Gtk.Widget::move-focus
No description available.

Gtk.Widget::parent-set

The ::parent-set signal is emitted when a new parent has been set on a widget.

Gtk.Widget::popup-menu

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][checklist-popup-menu] for an example of how to use this signal.

Gtk.Widget::property-notify-event

The ::property-notify-event signal will be emitted when a property on the widgets window has been changed or deleted.

Gtk.Widget::proximity-in-event

To receive this signal the GdkWindow associated to the widget needs to enable the #GDK_PROXIMITY_IN_MASK mask.

Gtk.Widget::proximity-out-event

To receive this signal the GdkWindow associated to the widget needs to enable the #GDK_PROXIMITY_OUT_MASK mask.

Gtk.Widget::query-tooltip

Emitted when GtkWidget: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.

since: 2.12

Gtk.Widget::realize

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).

Gtk.Widget::screen-changed

The ::screen-changed signal gets emitted when the screen of a widget has changed.

Gtk.Widget::scroll-event

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.

Gtk.Widget::selection-clear-event

The ::selection-clear-event signal will be emitted when the the widgets window has lost ownership of a selection.

Gtk.Widget::selection-get
No description available.

Gtk.Widget::selection-notify-event
No description available.

Gtk.Widget::selection-received
No description available.

Gtk.Widget::selection-request-event

The ::selection-request-event signal will be emitted when another client requests ownership of the selection owned by the widgets window.

Gtk.Widget::show

The ::show signal is emitted when widget is shown, for example with gtk_widget_show().

Gtk.Widget::show-help
No description available.

Gtk.Widget::size-allocate
No description available.

Gtk.Widget::state-changed

The ::state-changed signal is emitted when the widget state changes. See gtk_widget_get_state().

deprecated: 3.0 

Gtk.Widget::state-flags-changed

The ::state-flags-changed signal is emitted when the widget state changes, see gtk_widget_get_state_flags().

since: 3.0

Gtk.Widget::style-set

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.

deprecated: 3.0 

Gtk.Widget::style-updated

The ::style-updated signal is a convenience signal that is emitted when the GtkStyleContext::changed signal is emitted on the widgets associated GtkStyleContext as returned by gtk_widget_get_style_context().

since: 3.0

Gtk.Widget::touch-event
No description available.

Gtk.Widget::unmap

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.

Gtk.Widget::unmap-event

The ::unmap-event signal will be emitted when the widgets window is unmapped. A window is unmapped when it becomes invisible on the screen.

Gtk.Widget::unrealize

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).

Gtk.Widget::visibility-notify-event

The ::visibility-notify-event will be emitted when the widgets window is obscured or unobscured.

deprecated: 3.12 

Gtk.Widget::window-state-event

The ::window-state-event will be emitted when the state of the toplevel window associated to the widget changes.

Signals inherited from GObject (1)
GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

Class structure

struct GtkWidgetClass {
  GInitiallyUnownedClass parent_class;
  guint activate_signal;
  void (* dispatch_child_properties_changed) (
    GtkWidget* widget,
    guint n_pspecs,
    GParamSpec** pspecs
  );
  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
  );
  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
  );
  gboolean (* mnemonic_activate) (
    GtkWidget* widget,
    gboolean group_cycling
  );
  void (* grab_focus) (
    GtkWidget* widget
  );
  gboolean (* focus) (
    GtkWidget* widget,
    GtkDirectionType direction
  );
  void (* move_focus) (
    GtkWidget* widget,
    GtkDirectionType direction
  );
  gboolean (* keynav_failed) (
    GtkWidget* widget,
    GtkDirectionType direction
  );
  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
  );
  void (* selection_get) (
    GtkWidget* widget,
    GtkSelectionData* selection_data,
    guint info,
    guint time_
  );
  void (* selection_received) (
    GtkWidget* widget,
    GtkSelectionData* selection_data,
    guint time_
  );
  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
  );
  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
  );
  gboolean (* popup_menu) (
    GtkWidget* widget
  );
  gboolean (* show_help) (
    GtkWidget* widget,
    GtkWidgetHelpType help_type
  );
  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
  );
  void (* _gtk_reserved6) (
void
  );
  void (* _gtk_reserved7) (
void
  );
  
}

No description available.

Class members
parent_class: GInitiallyUnownedClass

The object class structure needs to be the first element in the widget class structure in order for the class mechanism to work correctly. This allows a GtkWidgetClass pointer to be cast to a GObjectClass pointer.

activate_signal: guint

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: void (* dispatch_child_properties_changed) ( GtkWidget* widget, guint n_pspecs, GParamSpec** pspecs )

Seldomly overidden.

destroy: void (* destroy) ( GtkWidget* widget )

Signals that all holders of a reference to the widget should release the reference that they hold.

show: void (* show) ( GtkWidget* widget )

Signal emitted when widget is shown.

show_all: void (* show_all) ( GtkWidget* widget )

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

hide: void (* hide) ( GtkWidget* widget )

Signal emitted when widget is hidden.

map: void (* map) ( GtkWidget* widget )

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: void (* unmap) ( GtkWidget* widget )

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: void (* realize) ( GtkWidget* widget )

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: void (* unrealize) ( GtkWidget* widget )

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: void (* size_allocate) ( GtkWidget* widget, GtkAllocation* allocation )

Signal emitted to get the widget allocation.

state_changed: void (* state_changed) ( GtkWidget* widget, GtkStateType previous_state )

Signal emitted when the widget state changes. Deprecated: 3.0.

state_flags_changed: void (* state_flags_changed) ( GtkWidget* widget, GtkStateFlags previous_state_flags )

Signal emitted when the widget state changes, see gtk_widget_get_state_flags().

parent_set: void (* parent_set) ( GtkWidget* widget, GtkWidget* previous_parent )

Signal emitted when a new parent has been set on a widget.

hierarchy_changed: void (* hierarchy_changed) ( GtkWidget* widget, GtkWidget* previous_toplevel )

Signal emitted when the anchored state of a widget changes.

style_set: void (* style_set) ( GtkWidget* widget, GtkStyle* previous_style )

Signal emitted when a new style has been set on a widget. Deprecated: 3.0.

direction_changed: void (* direction_changed) ( GtkWidget* widget, GtkTextDirection previous_direction )

Signal emitted when the text direction of a widget changes.

grab_notify: void (* grab_notify) ( GtkWidget* widget, gboolean was_grabbed )

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: void (* child_notify) ( GtkWidget* widget, GParamSpec* child_property )

Signal emitted for each child property that has changed on an object.

draw: gboolean (* draw) ( GtkWidget* widget, cairo_t* cr )

Signal emitted when a widget is supposed to render itself.

get_request_mode: GtkSizeRequestMode (* get_request_mode) ( GtkWidget* widget )

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: void (* get_preferred_height) ( GtkWidget* widget, gint* minimum_height, gint* natural_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: void (* get_preferred_width_for_height) ( GtkWidget* widget, gint height, gint* minimum_width, gint* natural_width )

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: void (* get_preferred_width) ( GtkWidget* widget, gint* minimum_width, gint* natural_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: void (* get_preferred_height_for_width) ( GtkWidget* widget, gint width, gint* minimum_height, gint* natural_height )

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: gboolean (* mnemonic_activate) ( GtkWidget* widget, gboolean group_cycling )

Activates the widget if group_cycling is FALSE, and just grabs the focus if group_cycling is TRUE.

grab_focus: void (* grab_focus) ( GtkWidget* widget )

Causes widget to have the keyboard focus for the GtkWindow it’s inside.

focus: gboolean (* focus) ( GtkWidget* widget, GtkDirectionType direction )

No description available.

move_focus: void (* move_focus) ( GtkWidget* widget, GtkDirectionType direction )

Signal emitted when a change of focus is requested.

keynav_failed: gboolean (* keynav_failed) ( GtkWidget* widget, GtkDirectionType direction )

Signal emitted if keyboard navigation fails.

event: gboolean (* event) ( GtkWidget* widget, GdkEvent* 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: gboolean (* button_press_event) ( GtkWidget* widget, GdkEventButton* event )

Signal will be emitted when a button (typically from a mouse) is pressed.

button_release_event: gboolean (* button_release_event) ( GtkWidget* widget, GdkEventButton* event )

Signal will be emitted when a button (typically from a mouse) is released.

scroll_event: gboolean (* scroll_event) ( GtkWidget* widget, GdkEventScroll* event )

Signal emitted when a button in the 4 to 7 range is pressed.

motion_notify_event: gboolean (* motion_notify_event) ( GtkWidget* widget, GdkEventMotion* event )

Signal emitted when the pointer moves over the widget’s GdkWindow.

delete_event: gboolean (* delete_event) ( GtkWidget* widget, GdkEventAny* event )

Signal emitted if a user requests that a toplevel window is closed.

destroy_event: gboolean (* destroy_event) ( GtkWidget* widget, GdkEventAny* event )

Signal is emitted when a GdkWindow is destroyed.

key_press_event: gboolean (* key_press_event) ( GtkWidget* widget, GdkEventKey* event )

Signal emitted when a key is pressed.

key_release_event: gboolean (* key_release_event) ( GtkWidget* widget, GdkEventKey* event )

Signal is emitted when a key is released.

enter_notify_event: gboolean (* enter_notify_event) ( GtkWidget* widget, GdkEventCrossing* event )

Signal event will be emitted when the pointer enters the widget’s window.

leave_notify_event: gboolean (* leave_notify_event) ( GtkWidget* widget, GdkEventCrossing* event )

Will be emitted when the pointer leaves the widget’s window.

configure_event: gboolean (* configure_event) ( GtkWidget* widget, GdkEventConfigure* event )

Signal will be emitted when the size, position or stacking of the widget’s window has changed.

focus_in_event: gboolean (* focus_in_event) ( GtkWidget* widget, GdkEventFocus* event )

Signal emitted when the keyboard focus enters the widget’s window.

focus_out_event: gboolean (* focus_out_event) ( GtkWidget* widget, GdkEventFocus* event )

Signal emitted when the keyboard focus leaves the widget’s window.

map_event: gboolean (* map_event) ( GtkWidget* widget, GdkEventAny* event )

Signal emitted when the widget’s window is mapped.

unmap_event: gboolean (* unmap_event) ( GtkWidget* widget, GdkEventAny* event )

Signal will be emitted when the widget’s window is unmapped.

property_notify_event: gboolean (* property_notify_event) ( GtkWidget* widget, GdkEventProperty* event )

Signal will be emitted when a property on the widget’s window has been changed or deleted.

selection_clear_event: gboolean (* selection_clear_event) ( GtkWidget* widget, GdkEventSelection* event )

Signal will be emitted when the the widget’s window has lost ownership of a selection.

selection_request_event: gboolean (* selection_request_event) ( GtkWidget* widget, GdkEventSelection* event )

Signal will be emitted when another client requests ownership of the selection owned by the widget’s window.

selection_notify_event: gboolean (* selection_notify_event) ( GtkWidget* widget, GdkEventSelection* event )

No description available.

proximity_in_event: gboolean (* proximity_in_event) ( GtkWidget* widget, GdkEventProximity* event )

No description available.

proximity_out_event: gboolean (* proximity_out_event) ( GtkWidget* widget, GdkEventProximity* event )

No description available.

visibility_notify_event: gboolean (* visibility_notify_event) ( GtkWidget* widget, GdkEventVisibility* event )

Signal emitted when the widget’s window is obscured or unobscured.

window_state_event: gboolean (* window_state_event) ( GtkWidget* widget, GdkEventWindowState* event )

Signal emitted when the state of the toplevel window associated to the widget changes.

damage_event: gboolean (* damage_event) ( GtkWidget* widget, GdkEventExpose* event )

Signal emitted when a redirected window belonging to widget gets drawn into.

grab_broken_event: gboolean (* grab_broken_event) ( GtkWidget* widget, GdkEventGrabBroken* event )

Signal emitted when a pointer or keyboard grab on a window belonging to widget gets broken.

selection_get: void (* selection_get) ( GtkWidget* widget, GtkSelectionData* selection_data, guint info, guint time_ )

No description available.

selection_received: void (* selection_received) ( GtkWidget* widget, GtkSelectionData* selection_data, guint time_ )

No description available.

drag_begin: void (* drag_begin) ( GtkWidget* widget, GdkDragContext* context )

Signal emitted on the drag source when a drag is started.

drag_end: void (* drag_end) ( GtkWidget* widget, GdkDragContext* context )

Signal emitted on the drag source when a drag is finished.

drag_data_get: void (* drag_data_get) ( GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selection_data, guint info, guint time_ )

Signal emitted on the drag source when the drop site requests the data which is dragged.

drag_data_delete: void (* drag_data_delete) ( GtkWidget* widget, GdkDragContext* context )

Signal emitted on the drag source when a drag with the action GDK_ACTION_MOVE is successfully completed.

drag_leave: void (* drag_leave) ( GtkWidget* widget, GdkDragContext* context, guint time_ )

Signal emitted on the drop site when the cursor leaves the widget.

drag_motion: gboolean (* drag_motion) ( GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time_ )

Signal emitted on the drop site when the user moves the cursor over the widget during a drag.

drag_drop: gboolean (* drag_drop) ( GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time_ )

Signal emitted on the drop site when the user drops the data onto the widget.

drag_data_received: void (* drag_data_received) ( GtkWidget* widget, GdkDragContext* context, gint x, gint y, GtkSelectionData* selection_data, guint info, guint time_ )

Signal emitted on the drop site when the dragged data has been received.

drag_failed: gboolean (* drag_failed) ( GtkWidget* widget, GdkDragContext* context, GtkDragResult result )

Signal emitted on the drag source when a drag has failed.

popup_menu: gboolean (* popup_menu) ( GtkWidget* widget )

Signal emitted whenever a widget should pop up a context menu.

show_help: gboolean (* show_help) ( GtkWidget* widget, GtkWidgetHelpType help_type )

No description available.

get_accessible: AtkObject* (* get_accessible) ( GtkWidget* widget )

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

screen_changed: void (* screen_changed) ( GtkWidget* widget, GdkScreen* previous_screen )

Signal emitted when the screen of a widget has changed.

can_activate_accel: gboolean (* can_activate_accel) ( GtkWidget* widget, guint signal_id )

Signal allows applications and derived widgets to override the default GtkWidget handling for determining whether an accelerator can be activated.

composited_changed: void (* composited_changed) ( GtkWidget* widget )

Signal emitted when the composited status of widgets screen changes. See gdk_screen_is_composited().

query_tooltip: gboolean (* query_tooltip) ( GtkWidget* widget, gint x, gint y, gboolean keyboard_tooltip, GtkTooltip* 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: void (* compute_expand) ( GtkWidget* widget, gboolean* hexpand_p, gboolean* vexpand_p )

Computes whether a container should give this widget extra space when possible.

adjust_size_request: void (* adjust_size_request) ( GtkWidget* widget, GtkOrientation orientation, gint* minimum_size, gint* natural_size )

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: void (* adjust_size_allocation) ( GtkWidget* widget, GtkOrientation orientation, gint* minimum_size, gint* natural_size, gint* allocated_pos, gint* allocated_size )

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: void (* style_updated) ( GtkWidget* widget )

Signal emitted when the GtkStyleContext of a widget is changed.

touch_event: gboolean (* touch_event) ( GtkWidget* widget, GdkEventTouch* event )

Signal emitted when a touch event happens.

get_preferred_height_and_baseline_for_width: void (* get_preferred_height_and_baseline_for_width) ( GtkWidget* widget, gint width, gint* minimum_height, gint* natural_height, gint* minimum_baseline, gint* natural_baseline )

No description available.

adjust_baseline_request: void (* adjust_baseline_request) ( GtkWidget* widget, gint* minimum_baseline, gint* natural_baseline )

No description available.

adjust_baseline_allocation: void (* adjust_baseline_allocation) ( GtkWidget* widget, gint* baseline )

No description available.

queue_draw_region: void (* 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.

_gtk_reserved6: void (* _gtk_reserved6) ( void )

No description available.

_gtk_reserved7: void (* _gtk_reserved7) ( void )

No description available.

Virtual methods

Gtk.WidgetClass.adjust_baseline_allocation
No description available.

Gtk.WidgetClass.adjust_baseline_request
No description available.

Gtk.WidgetClass.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.

Gtk.WidgetClass.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.

Gtk.WidgetClass.button_press_event

Signal will be emitted when a button (typically from a mouse) is pressed.

Gtk.WidgetClass.button_release_event

Signal will be emitted when a button (typically from a mouse) is released.

Gtk.WidgetClass.can_activate_accel

Determines whether an accelerator that activates the signal identified by signal_id can currently be activated. This is done by emitting the GtkWidget::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.

since: 2.4

Gtk.WidgetClass.child_notify

Emits a GtkWidget::child-notify signal for the [child property][child-properties] child_property on widget.

Gtk.WidgetClass.composited_changed

Signal emitted when the composited status of widgets screen changes. See gdk_screen_is_composited().

Gtk.WidgetClass.compute_expand

Computes whether a container should give this widget extra space when possible.

Gtk.WidgetClass.configure_event

Signal will be emitted when the size, position or stacking of the widget’s window has changed.

Gtk.WidgetClass.damage_event

Signal emitted when a redirected window belonging to widget gets drawn into.

Gtk.WidgetClass.delete_event

Signal emitted if a user requests that a toplevel window is closed.

Gtk.WidgetClass.destroy

Destroys a widget.

Gtk.WidgetClass.destroy_event

Signal is emitted when a GdkWindow is destroyed.

Gtk.WidgetClass.direction_changed

Signal emitted when the text direction of a widget changes.

Gtk.WidgetClass.drag_begin

Signal emitted on the drag source when a drag is started.

Gtk.WidgetClass.drag_data_delete

Signal emitted on the drag source when a drag with the action GDK_ACTION_MOVE is successfully completed.

Gtk.WidgetClass.drag_data_get

Signal emitted on the drag source when the drop site requests the data which is dragged.

Gtk.WidgetClass.drag_data_received

Signal emitted on the drop site when the dragged data has been received.

Gtk.WidgetClass.drag_drop

Signal emitted on the drop site when the user drops the data onto the widget.

Gtk.WidgetClass.drag_end

Signal emitted on the drag source when a drag is finished.

Gtk.WidgetClass.drag_failed

Signal emitted on the drag source when a drag has failed.

Gtk.WidgetClass.drag_leave

Signal emitted on the drop site when the cursor leaves the widget.

Gtk.WidgetClass.drag_motion

Signal emitted on the drop site when the user moves the cursor over the widget during a drag.

Gtk.WidgetClass.draw

Signal emitted when a widget is supposed to render itself.

Gtk.WidgetClass.enter_notify_event

Signal event will be emitted when the pointer enters the widget’s window.

Gtk.WidgetClass.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.

Gtk.WidgetClass.focus
No description available.

Gtk.WidgetClass.focus_in_event

Signal emitted when the keyboard focus enters the widget’s window.

Gtk.WidgetClass.focus_out_event

Signal emitted when the keyboard focus leaves the widget’s window.

Gtk.WidgetClass.get_accessible

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

Gtk.WidgetClass.get_preferred_height

Retrieves a widget’s initial minimum and natural height.

since: 3.0

Gtk.WidgetClass.get_preferred_height_and_baseline_for_width

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.

since: 3.10

Gtk.WidgetClass.get_preferred_height_for_width

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

since: 3.0

Gtk.WidgetClass.get_preferred_width

Retrieves a widget’s initial minimum and natural width.

since: 3.0

Gtk.WidgetClass.get_preferred_width_for_height

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

since: 3.0

Gtk.WidgetClass.get_request_mode

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

since: 3.0

Gtk.WidgetClass.grab_broken_event

Signal emitted when a pointer or keyboard grab on a window belonging to widget gets broken.

Gtk.WidgetClass.grab_focus

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.

Gtk.WidgetClass.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.

Gtk.WidgetClass.hide

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

Gtk.WidgetClass.hierarchy_changed

Signal emitted when the anchored state of a widget changes.

Gtk.WidgetClass.key_press_event

Signal emitted when a key is pressed.

Gtk.WidgetClass.key_release_event

Signal is emitted when a key is released.

Gtk.WidgetClass.keynav_failed

This function should be called whenever keyboard navigation within a single widget hits a boundary. The function emits the GtkWidget::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():.

since: 2.12

Gtk.WidgetClass.leave_notify_event

Will be emitted when the pointer leaves the widget’s window.

Gtk.WidgetClass.map

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

Gtk.WidgetClass.map_event

Signal emitted when the widget’s window is mapped.

Gtk.WidgetClass.mnemonic_activate

Emits the GtkWidget::mnemonic-activate signal.

Gtk.WidgetClass.motion_notify_event

Signal emitted when the pointer moves over the widget’s GdkWindow.

Gtk.WidgetClass.move_focus

Signal emitted when a change of focus is requested.

Gtk.WidgetClass.parent_set

Signal emitted when a new parent has been set on a widget.

Gtk.WidgetClass.popup_menu

Signal emitted whenever a widget should pop up a context menu.

Gtk.WidgetClass.property_notify_event

Signal will be emitted when a property on the widget’s window has been changed or deleted.

Gtk.WidgetClass.proximity_in_event
No description available.

Gtk.WidgetClass.proximity_out_event
No description available.

Gtk.WidgetClass.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.

Gtk.WidgetClass.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. 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.

since: 3.0

Gtk.WidgetClass.realize

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.

Gtk.WidgetClass.screen_changed

Signal emitted when the screen of a widget has changed.

Gtk.WidgetClass.scroll_event

Signal emitted when a button in the 4 to 7 range is pressed.

Gtk.WidgetClass.selection_clear_event

Signal will be emitted when the the widget’s window has lost ownership of a selection.

Gtk.WidgetClass.selection_get
No description available.

Gtk.WidgetClass.selection_notify_event
No description available.

Gtk.WidgetClass.selection_received
No description available.

Gtk.WidgetClass.selection_request_event

Signal will be emitted when another client requests ownership of the selection owned by the widget’s window.

Gtk.WidgetClass.show

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.

Gtk.WidgetClass.show_all

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

Gtk.WidgetClass.show_help
No description available.

Gtk.WidgetClass.size_allocate

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

Gtk.WidgetClass.state_changed

Signal emitted when the widget state changes. Deprecated: 3.0.

Gtk.WidgetClass.state_flags_changed

Signal emitted when the widget state changes, see gtk_widget_get_state_flags().

Gtk.WidgetClass.style_set

Signal emitted when a new style has been set on a widget. Deprecated: 3.0.

Gtk.WidgetClass.style_updated

Signal emitted when the GtkStyleContext of a widget is changed.

Gtk.WidgetClass.touch_event

Signal emitted when a touch event happens.

Gtk.WidgetClass.unmap

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

Gtk.WidgetClass.unmap_event

Signal will be emitted when the widget’s window is unmapped.

Gtk.WidgetClass.unrealize

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).

Gtk.WidgetClass.visibility_notify_event

Signal emitted when the widget’s window is obscured or unobscured.

Gtk.WidgetClass.window_state_event

Signal emitted when the state of the toplevel window associated to the widget changes.

Class methods

gtk_widget_class_bind_template_callback_full

Declares a callback_symbol to handle callback_name from the template XML defined for widget_type. See gtk_builder_add_callback_symbol().

since: 3.10

gtk_widget_class_bind_template_child_full

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().

since: 3.10

gtk_widget_class_find_style_property

Finds a style property of a widget class by name.

since: 2.2

gtk_widget_class_get_css_name

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

since: 3.20

gtk_widget_class_install_style_property

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

gtk_widget_class_install_style_property_parser

Installs a style property on a widget class.

gtk_widget_class_list_style_properties

Returns all style properties of a widget class.

since: 2.2

gtk_widget_class_set_accessible_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.

since: 3.2

gtk_widget_class_set_accessible_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.

since: 3.2

gtk_widget_class_set_connect_func

For use in language bindings, this will override the default GtkBuilderConnectFunc to be used when parsing GtkBuilder XML from this class’s template data.

since: 3.10

gtk_widget_class_set_css_name

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

since: 3.20

gtk_widget_class_set_template

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

since: 3.10

gtk_widget_class_set_template_from_resource

A convenience function to call gtk_widget_class_set_template().

since: 3.10