3.20 <GtkWidgetClass>

Structure: <GtkWidgetClass>

Fields

parent-class

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.

show

Signal emitted when widget is shown

hide

Signal emitted when widget is hidden.

map

Signal emitted when widget is going to be mapped, that is when the widget is visible (which is controlled with widget:set-visible) and all its parents up to the toplevel widget are also visible.

unmap

Signal emitted when widget is going to be unmapped, which means that either it or any of its parents up to the toplevel widget have been set as hidden.

realize

Signal emitted when widget is associated with a <GdkSurface>, which means that widget:realize has been called or the widget has been mapped (that is, it is going to be drawn).

unrealize

Signal emitted when the GdkSurface associated with widget is destroyed, which means that widget:unrealize has been called or the widget has been unmapped (that is, it is going to be hidden).

root

Called when the widget gets added to a <GtkRoot> widget. Must chain up

unroot

Called when the widget is about to be removed from its <GtkRoot> widget. Must chain up

size-allocate

Called to set the allocation, if the widget does not have a layout manager.

state-flags-changed

Signal emitted when the widget state changes, see widget:get-state-flags.

direction-changed

Signal emitted when the text direction of a widget changes.

get-request-mode

Called to get the request mode, if the widget does not have a layout manager. This allows a widget to tell its parent container whether it prefers to be allocated in height-for-width or width-for-height mode. height-for-width means the widget prefers to have GtkWidgetClass.measure() called first to get the default width (passing a for_size of -1), then again to get the height for said default width. constant-size disables any height-for-width or width-for-height geometry management for said widget and is the default return. It’s important to note that any widget which trades height-for-width or width-for-height must respond properly to a for_size value >= -1 passed to GtkWidgetClass.measure, for both possible orientations.

measure

Called to obtain the minimum and natural size of the widget, if the widget does not have a layout manager. Depending on the orientation parameter, the passed for_size can be interpreted as width or height. A widget will never be allocated less than its minimum size.

mnemonic-activate

Activates the widget if group-cycling is #f, and just grabs the focus if group-cycling is #t.

grab-focus

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

focus

Vfunc for widget:child-focus?

set-focus-child

Sets the focused child of a widget. Must chain up

move-focus

Signal emitted when a change of focus is requested

keynav-failed

Signal emitted if keyboard navigation fails.

query-tooltip

Signal emitted when “has-tooltip” is #t and the hover timeout has expired with the cursor hovering “above” widget; or emitted when widget got focus in keyboard mode.

compute-expand

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

css-changed

Vfunc called when the CSS used by widget was changed. Widgets should then discard their caches that depend on CSS and queue resizes or redraws accordingly. The default implementation will take care of this for all the default CSS properties, so implementations must chain up.

system-setting-changed

Emitted when a system setting was changed. Must chain up.

snapshot

Vfunc called when a new snapshot of the widget has to be taken.

contains

Vfunc for widget:contains?.

Procedures

Procedure: pointer->widget-class pointer ⇒ struct
Method: widget-class:add-shortcut self shortcut
Method: add-shortcut self shortcut

Installs a shortcut in self.

Every instance created for self or its subclasses will inherit this shortcut and trigger it.

Shortcuts added this way will be triggered in the Gtk.PropagationPhase.bubble phase, which means they may also trigger if child widgets have focus.

This function must only be used in class initialization functions otherwise it is not guaranteed that the shortcut will be installed.

self

Passed: a <GtkWidgetClass>.

the class to add the shortcut to

shortcut

Passed: a <GtkShortcut>.

the shortcut to add

Method: widget-class:bind-template-callback-full self callback-name callback-symbol
Method: bind-template-callback-full self callback-name callback-symbol

Associates a name to be used in GtkBuilder XML with a symbol.

This function is not supported after widget-class:set-template-scope has been used on self.

See builder-cscope:add-callback-symbol.

Note that this must be called from a composite widget classes class initializer after calling widget-class:set-template.

self

Passed: a <GtkWidgetClass>.

a widget class

callback-name

Passed: a string.

name of the callback as expected in the template XML

callback-symbol

Passed: a procedure.

the callback symbol

See GCallback for how it is called.

Method: widget-class:bind-template-child-full self name internal-child struct-offset
Method: bind-template-child-full self name internal-child struct-offset

Assigns 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 widget:get-template-child.

The struct can point either into the public instance, then you should use G_STRUCT_OFFSET(WidgetType, member) for struct-offset, or in the private struct, then you should use G_PRIVATE_OFFSET(WidgetType, member).

An explicit strong reference will be held automatically for the duration of your instance’s life cycle, it will be released automatically when GObjectClass.dispose() runs on your instance and if a nonzero struct-offset is specified, then the automatic location in your instance public or private data will be set to NULL. You can however access an automated child pointer the first time your classes GObjectClass.dispose() runs, or alternatively in widget:destroy.

If internal-child is specified, buildable:do-get-internal-child will be automatically implemented by the widget class so there is no need to implement it manually.

The wrapper macros Gtk.widget_class_bind_template_child, Gtk.widget_class_bind_template_child_internal, Gtk.widget_class_bind_template_child_private and Gtk.widget_class_bind_template_child_internal_private might be more convenient to use.

Note that this must be called from a composite widget classes class initializer after calling widget-class:set-template.

self

Passed: a <GtkWidgetClass>.

a widget class

name

Passed: a string.

ID of the child defined in the template XML

internal-child

Passed: a boolean.

whether the child should be accessible as an “internal-child” when this class is used in GtkBuilder XML

struct-offset

Passed: a 64-bit integer.

The offset into the composite widget’s instance public or private structure where the automated child pointer should be set, or 0 to not assign the pointer

Method: widget-class:get-accessible-role self ⇒ %return
Method: get-accessible-role self ⇒ %return

Retrieves the accessible role used by the given widget class.

Different accessible roles have different states, and are rendered differently by assistive technologies.

See also: accessible:get-accessible-role.

self

Passed: a <GtkWidgetClass>.

a widget class

%return

Returned: a <GtkAccessibleRole>.

the accessible role for the widget class

Method: widget-class:get-activate-signal self ⇒ %return
Method: get-activate-signal self ⇒ %return

Retrieves the signal id for the activation signal.

The activation signal is set using widget-class:set-activate-signal.

self

Passed: a <GtkWidgetClass>.

a widget class

%return

Returned: an unsigned 32-bit integer.

a signal id, or 0 if the widget class does not specify an activation signal

Method: widget-class:get-css-name self ⇒ %return
Method: get-css-name self ⇒ %return

Gets the name used by this class for matching in CSS code.

See widget-class:set-css-name for details.

self

Passed: a <GtkWidgetClass>.

class to set the name on

%return

Returned: a string.

the CSS name of the given class

Method: widget-class:get-layout-manager-type self ⇒ %return
Method: get-layout-manager-type self ⇒ %return

Retrieves the type of the <GtkLayoutManager> used by widgets of class self.

See also: widget-class:set-layout-manager-type.

self

Passed: a <GtkWidgetClass>.

a widget class

%return

Returned: a class, or a GType number.

type of a <GtkLayoutManager> subclass, or G_TYPE_INVALID

Method: widget-class:install-action self action-name parameter-type activate
Method: install-action self action-name parameter-type activate

Adds an action for all instances of a widget class.

This function should be called at class initialization time.

Actions installed by this function are stateless. The only state they have is whether they are enabled or not (which can be changed with widget:action-set-enabled).

self

Passed: a <GtkWidgetClass>.

a widget class

action-name

Passed: a string.

a prefixed action name, such as "clipboard.paste"

parameter-type

Passed: a string, or #f.

the parameter type

activate

Passed: a procedure.

callback to use when the action is activated

See GtkWidgetActionActivateFunc for how it is called.

Method: widget-class:install-property-action self action-name property-name
Method: install-property-action self action-name property-name

Installs an action called action-name on self and binds its state to the value of the property-name property.

This function will perform a few sanity checks on the property selected via property-name. Namely, the property must exist, must be readable, writable and must not be construct-only. There are also restrictions on the type of the given property, it must be boolean, int, unsigned int, double or string. If any of these conditions are not met, a critical warning will be printed and no action will be added.

The state type of the action matches the property type.

If the property is boolean, the action will have no parameter and toggle the property value. Otherwise, the action will have a parameter of the same type as the property.

self

Passed: a <GtkWidgetClass>.

a widget class

action-name

Passed: a string.

name of the action

property-name

Passed: a string.

name of a property in instances of self or any parent class

Method: widget-class:query-action self index- ⇒ %return owner action-name parameter-type property-name
Method: query-action self index- ⇒ %return owner action-name parameter-type property-name

Returns details about an action that has been installed for self.

See widget-class:install-action for details on how to install actions.

Note that this function will also return actions defined by parent classes. You can identify those by looking at owner.

self

Passed: a <GtkWidgetClass>.

a widget class

index-

Passed: an unsigned 32-bit integer.

position of the action to query

%return

Returned: a boolean.

true if the action was found

owner

Returned: a class, or a GType number.

return location for the type where the action was defined

action-name

Returned: a string.

return location for the action name

parameter-type

Returned: a <GVariantType>, or #f.

return location for the parameter type

property-name

Returned: a string, or #f.

return location for the property name

Method: widget-class:set-accessible-role self accessible-role
Method: set-accessible-role self accessible-role

Sets the accessible role used by the given widget class.

Different accessible roles have different states, and are rendered differently by assistive technologies.

self

Passed: a <GtkWidgetClass>.

a widget class

accessible-role

Passed: a <GtkAccessibleRole>, or one of its symbols.

the accessible role to use

Method: widget-class:set-activate-signal self signal-id
Method: set-activate-signal self signal-id

Sets the activation signal for a widget class.

The signal will be emitted when calling widget:activate?.

The signal-id must have been registered with [function.GObject.signal_new] or GObject.signal_newv before calling this function.

self

Passed: a <GtkWidgetClass>.

a widget class

signal-id

Passed: an unsigned 32-bit integer.

the id for the activate signal

Method: widget-class:set-activate-signal-from-name self signal-name
Method: set-activate-signal-from-name self signal-name

Sets the activation signal for a widget class.

The signal id will by looked up by signal-name.

The signal will be emitted when calling widget:activate?.

The signal-name must have been registered with [function.GObject.signal_new] or GObject.signal_newv before calling this function.

self

Passed: a <GtkWidgetClass>.

a widget class

signal-name

Passed: a string.

the name of the activate signal of widget-type

Method: widget-class:set-css-name self name
Method: set-css-name self name

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

If this function is not called for a given class, the name set on the parent class is used. By default, <GtkWidget> uses the name "widget".

self

Passed: a <GtkWidgetClass>.

class to set the name on

name

Passed: a string.

name to use

Method: widget-class:set-layout-manager-type self type
Method: set-layout-manager-type self type

Sets the type to be used for creating layout managers for widgets of self.

The given type must be a subtype of <GtkLayoutManager>.

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

self

Passed: a <GtkWidgetClass>.

a widget class

type

Passed: a class, or a GType number.

the object type that implements the <GtkLayoutManager> for self

Method: widget-class:set-template self template-bytes
Method: set-template self template-bytes

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

For convenience, widget-class:set-template-from-resource is also provided.

Note that any class that installs templates must call widget:init-template in the widget’s instance initializer.

self

Passed: a <GtkWidgetClass>.

a widget class

template-bytes

Passed: a <GBytes>.

<GBytes> holding the <GtkBuilder> XML

Method: widget-class:set-template-from-resource self resource-name
Method: set-template-from-resource self resource-name

A convenience function that calls widget-class:set-template with the contents of a resource.

Note that any class that installs templates must call widget:init-template in the widget’s instance initializer.

self

Passed: a <GtkWidgetClass>.

a widget class

resource-name

Passed: a string.

resource path to load the template from

Method: widget-class:set-template-scope self scope
Method: set-template-scope self scope

Overrides the default scope to be used when parsing the class template.

This function is intended for language bindings.

Note that this must be called from a composite widget classes class initializer after calling widget-class:set-template.

self

Passed: a <GtkWidgetClass>.

a widget class

scope

Passed: a <GtkBuilderScope>.

<GtkBuilderScope> to use when loading the class template