StyleContextRef
public struct StyleContextRef : StyleContextProtocol, GWeakCapturing
GtkStyleContext stores styling information affecting a widget.
In order to construct the final style information, GtkStyleContext
queries information from all attached GtkStyleProviders. Style
providers can be either attached explicitly to the context through
[methodGtk.StyleContext.add_provider], or to the display through
[funcGtk.StyleContext.add_provider_for_display]. The resulting
style is a combination of all providers’ information in priority order.
For GTK widgets, any GtkStyleContext returned by
[methodGtk.Widget.get_style_context] will already have a GdkDisplay
and RTL/LTR information set. The style context will also be updated
automatically if any of these settings change on the widget.
Style Classes
Widgets can add style classes to their 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 GtkStyleProvider yourself
with the GTK_STYLE_PROVIDER_PRIORITY_FALLBACK priority, either a
GtkCssProvider or a custom object implementing the GtkStyleProvider
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 applications, you probably want then
to make your style information prevail to the theme’s, so you must use
a GtkStyleProvider with the GTK_STYLE_PROVIDER_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_STYLE_PROVIDER_PRIORITY_USER priority.
The StyleContextRef type acts as a lightweight Swift reference to an underlying GtkStyleContext instance.
It exposes methods that can operate on this data type through StyleContextProtocol conformance.
Use StyleContextRef only as an unowned reference to an existing GtkStyleContext instance.
-
Untyped pointer to the underlying `GtkStyleContext` instance.For type-safe access, use the generated, typed pointer
style_context_ptrproperty instead.Declaration
Swift
public let ptr: UnsafeMutableRawPointer!
-
Designated initialiser from the underlying
Cdata typeDeclaration
Swift
@inlinable init(_ p: UnsafeMutablePointer<GtkStyleContext>) -
Designated initialiser from a constant pointer to the underlying
Cdata typeDeclaration
Swift
@inlinable init(_ p: UnsafePointer<GtkStyleContext>) -
Conditional initialiser from an optional pointer to the underlying
Cdata typeDeclaration
Swift
@inlinable init!(_ maybePointer: UnsafeMutablePointer<GtkStyleContext>?) -
Conditional initialiser from an optional, non-mutable pointer to the underlying
Cdata typeDeclaration
Swift
@inlinable init!(_ maybePointer: UnsafePointer<GtkStyleContext>?) -
Conditional initialiser from an optional
gpointerDeclaration
Swift
@inlinable init!(gpointer g: gpointer?) -
Conditional initialiser from an optional, non-mutable
gconstpointerDeclaration
Swift
@inlinable init!(gconstpointer g: gconstpointer?) -
Reference intialiser for a related type that implements
StyleContextProtocolDeclaration
Swift
@inlinable init<T>(_ other: T) where T : StyleContextProtocol -
This factory is syntactic sugar for setting weak pointers wrapped in
GWeak<T>Declaration
Swift
@inlinable static func unowned<T>(_ other: T) -> StyleContextRef where T : StyleContextProtocol -
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
StyleContextProtocol.Declaration
Swift
@inlinable init<T>(cPointer: UnsafeMutablePointer<T>) -
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
StyleContextProtocol.Declaration
Swift
@inlinable init<T>(constPointer: UnsafePointer<T>) -
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
StyleContextProtocol.Declaration
Swift
@inlinable init(mutating raw: UnsafeRawPointer) -
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
StyleContextProtocol.Declaration
Swift
@inlinable init(raw: UnsafeMutableRawPointer) -
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
StyleContextProtocol.Declaration
Swift
@inlinable init(opaquePointer: OpaquePointer)
View on GitHub
Install in Dash
StyleContextRef Structure Reference