Package: gtk
Class gtk:widget
Superclassesgobject:initially-unowned, gtk:accessible, gtk:buildable, gtk:constraint-target, gobject:object, common-lisp:standard-object, common-lisp:t Documented Subclassesgtk:action-bar, gtk:app-chooser-button, gtk:app-chooser-widget, gtk:aspect-frame, gtk:box, gtk:button, gtk:calendar, gtk:cell-view, gtk:center-box, gtk:check-button, gtk:color-button, gtk:color-chooser-widget, gtk:color-dialog-button, gtk:column-view, gtk:combo-box, gtk:drag-icon, gtk:drawing-area, gtk:drop-down, gtk:editable-label, gtk:entry, gtk:expander, gtk:file-chooser-widget, gtk:fixed, gtk:flow-box, gtk:flow-box-child, gtk:font-button, gtk:font-chooser-widget, gtk:font-dialog-button, gtk:frame, gtk:gl-area, gtk:graphics-offload, gtk:grid, gtk:header-bar, gtk:icon-view, gtk:image, gtk:info-bar, gtk:inscription, gtk:label, gtk:level-bar, gtk:list-base, gtk:list-box, gtk:list-box-row, gtk:media-controls, gtk:menu-button, gtk:notebook, gtk:overlay, gtk:paned, gtk:password-entry, gtk:picture, gtk:popover, gtk:popover-menu-bar, gtk:progress-bar, gtk:range, gtk:revealer, gtk:scale-button, gtk:scrollbar, gtk:scrolled-window, gtk:search-bar, gtk:search-entry, gtk:separator, gtk:shortcut-label, gtk:shortcuts-shortcut, gtk:spin-button, gtk:spinner, gtk:stack, gtk:stack-sidebar, gtk:stack-switcher, gtk:statusbar, gtk:switch, gtk:text, gtk:text-view, gtk:tree-expander, gtk:tree-view, gtk:video, gtk:viewport, gtk:window, gtk:window-controls, gtk:window-handle Direct SlotsDetails The gtk:widget class is the base class all widgets in GTK derive
from. It manages the widget life cycle, layout, states and style. Height-for-width Geometry ManagementGTK 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.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 :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. If a widget ends up baseline aligned it will be allocated all the space in the parent as if it was :fill, but the selected baseline can be found via the gtk:widget-allocated-baseline function. If this has a value other than -1 you need to align the widget such that the baseline appears at the position. GtkWidget as GtkBuildableThe gtk:widget implementation of the gtk:buildable interface supports various custom elements to specify additional aspects of widgets that are not directly expressed as properties.If the widget uses a gtk:layout-manager object, the gtk:widget implementation supports a custom <layout> element, used to define layout properties: <object class="GtkGrid" id="my_grid"> <child> <object class="GtkLabel" id="label1"> <property name="label">Description</property> <layout> <property name="column">0</property> <property name="row">0</property> <property name="row-span">1</property> <property name="column-span">1</property> </layout> </object> </child> <child> <object class="GtkEntry" id="description_entry"> <layout> <property name="column">1</property> <property name="row">0</property> <property name="row-span">1</property> <property name="column-span">1</property> </layout> </object> </child> </object>The gtk:widget implementation 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>The gtk:widget implementation allows defining accessibility information, such as properties, relations, and states, using the custom <accessibility> element: <object class="GtkButton" id="button1"> <accessibility> <property name="label">Download</property> <relation name="labelled-by">label1</relation> </accessibility> </object> Building composite widgets from template XMLThe gtk:widget implementation exposes some facilities to automate the proceedure of creating composite widgets using templates.To create composite widgets with gtk:builder XML, one must associate the interface description with the widget class at class initialization time using the gtk:widget-class-set-template function. The interface description semantics expected in composite template descriptions is slightly different from regulare gtk:builder XML. Unlike regular interface descriptions, the gtk:widget-class-set-template function 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 gtk:builder object but can be used by UI design tools 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 the widget itself. You may set properties on the widget by inserting <property> tags into the <template> tag, and also add <child> tags to add children and extend the 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 auxilary objects which might be referenced by other widgets declared as children of the <template> tag. Example: A gtk:builder 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> </object> </child> <child> <object class="GtkButton" id="goodbye_button"> <property name="label">Goodbye World</property> </object> </child> </template> </interface> Signal DetailsThe "destroy" signallambda (widget) :no-hooks
The "direction-changed" signallambda (widget direction) :run-first
The "hide" signallambda (widget) :run-first
The "keynav-failed" signallambda (widget direction) :run-last
The "map" signallambda (widget) :run-first
The "mnemonic-activate" signallambda (widget cycling) :run-last
The "move-focus" signallambda (widget direction) :action
The "query-tooltip" signallambda (widget x y mode tooltip) :run-last
The "realize" signallambda (widget) :run-first
The "show" signallambda (widget)
The "state-flags-changed" signallambda (widget flags) :run-first
The "unmap" signallambda (widget) :run-first
The "unrealize" signallambda (widget) :run-last
| Slot Access FunctionsInherited Slot Access FunctionsSee also |
2025-2-13