Package: gtk

Class gtk:style-context

Superclasses

gobject:object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

display
The display property of type gdk:display (Read / Write)
The associated display of the style context.

Details

The gtk:style-context object stores styling information affecting a widget. In order to construct the final style information, the gtk:style-context object queries information from all attached gtk:style-provider objects. Style providers can be either attached explicitly to the style context through the gtk:style-context-add-provider function, or to the display through the gtk:style-context-add-provider-for-display function. The resulting style is a combination of all information of the style provider in priority order.

For GTK widgets, any gtk:style-context object returned by the gtk:widget-style-context function will already have a gdk:display instance and a text direction information set. The style context will be also updated automatically if any of these settings change on the widget.

Style Classes
Widgets can add style classes to their style context, which can be used to associate different styles by class. The documentation for individual widgets lists which style classes it uses itself, and which style classes may be added by applications to affect their appearance.

Custom styling in UI libraries and applications
If you are developing a library with custom widgets that render differently than standard components, you may need to add a gtk:style-provider object yourself with the gtk:+priority-fallback+ priority, either a gtk:css-provider object or a custom object implementing the gtk:style-provider interface. This way themes may still attempt to style your UI elements in a different way if needed so.

If you are using custom styling on an application, you probably want then to make your style information prevail to the style information of the theme, so you must use a gtk:style-provider object with the gtk:+priority-application+ priority. Keep in mind that the user settings in XDG_CONFIG_HOME/gtk-4.0/gtk.css will still take precedence over your changes, as it uses the gtk:+priority-user+ priority.

Warning

The gtk:style-context implementation is deprecated since 4.10. The relevant API has been moved to the gtk:widget implementation where applicable. Otherwise, there is no replacement for querying the style machinery. Stylable UI elements should use widgets.
 

Slot Access Functions

Inherited Slot Access Functions

See also

2023-8-30