Basics
Guides
API Reference
Basics
Guides
API Reference
[33:7] extends: object
A style provider for CSS. It is able to parse CSS-like input in order to
style widgets. An application can make GTK parse a specific CSS style sheet
by calling [method@Gtk.CssProvider.load_from_file] or
[method@Gtk.CssProvider.load_from_resource] and adding the provider with
[method@Gtk.StyleContext.add_provider] or
[func@Gtk.StyleContext.add_provider_for_display]. In addition, certain files
will be read when GTK is initialized. First, the file
$XDG_CONFIG_HOME/gtk-4.0/gtk.css is loaded if it exists. Then, GTK loads
the first existing file among
XDG_DATA_HOME/themes/THEME/gtk-VERSION/gtk-VARIANT.css,
$HOME/.themes/THEME/gtk-VERSION/gtk-VARIANT.css,
$XDG_DATA_DIRS/themes/THEME/gtk-VERSION/gtk-VARIANT.css and
DATADIR/share/themes/THEME/gtk-VERSION/gtk-VARIANT.css, where THEME is
the name of the current theme (see the [property@Gtk.Settings:gtk-theme-name]
setting), VARIANT is the variant to load (see the
[property@Gtk.Settings:gtk-application-prefer-dark-theme] setting), DATADIR
is the prefix configured when GTK was compiled (unless overridden by the
GTK_DATA_PREFIX environment variable), and VERSION is the GTK version
number. If no file is found for the current version, GTK tries older versions
all the way back to 4.0. To track errors while loading CSS, connect to the
[signal@Gtk.CssProvider::parsing-error] signal.
CssProvider ()
Returns a newly created
GtkCssProvider.
toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from
fn.call(...), another generated wrapper exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.asObject ()
Wraps this handle as
Object.
A Object object.asStyleProvider ()
Wraps this handle as
StyleProvider.
A StyleProvider object.connectSignal (string Name, CallbackObj)
Connects one generated callback wrapper to a named signal.
Name is the signal name.CallbackObj is the generated callback wrapper to connect.The connected handler id.disconnectSignalHandler (int HandlerId)
Disconnects one retained signal handler id.
HandlerId is the signal handler id to disconnect.None.setOnParsingerror (callback Fn, UserData = null)
Signals that a parsing error occurred. The expected error values are in the [error@Gtk.CssParserError] and [enum@Gtk.CssParserWarning] enumerations. The @path, @line and @position describe the actual location of the error as accurately as possible. Parsing errors are never fatal, so the parsing will resume after the error. Errors may however cause parts of the given data or even all of it to not be parsed at all. So it is a useful idea to check that the parsing succeeds by connecting to this signal. Errors in the [enum@Gtk.CssParserWarning] enumeration should not be treated as fatal errors. Note that this signal may be emitted at any time as the css provider may opt to defer parsing parts or all of the input to a later time than when a loading function was called.
Fn is the Aussom callback.Fn is called with (CssProvider Self, CssSection Section, Error Error).UserData is retained and passed through to the generated callback wrapper when provided.The connected handler id.getProperty (string Name)
Reads one generated property by name.
setProperty (string Name, Value)
Writes one generated property by name.
setPreferscolorscheme (string Value)
Define the color scheme used for rendering the user interface. The UI can be set to either [enum@Gtk.InterfaceColorScheme.LIGHT], or [enum@Gtk.InterfaceColorScheme.DARK] mode. Other values will be interpreted the same as [enum@Gtk.InterfaceColorScheme.LIGHT]. This setting is be available for media queries in CSS:
css @media (prefers-color-scheme: dark) { // some dark mode styling }Changing this setting will reload the style sheet.
Value is the new property value.None.setPreferscontrast (string Value)
Define the contrast mode to use for the user interface. When set to [enum@Gtk.InterfaceContrast.MORE] or [enum@Gtk.InterfaceContrast.LESS], the UI is rendered in high or low contrast. When set to [enum@Gtk.InterfaceContrast.NO_PREFERENCE] (the default), the user interface will be rendered in default mode. This setting is be available for media queries in CSS:
css @media (prefers-contrast: more) { // some style with high contrast }Changing this setting will reload the style sheet.
Value is the new property value.None.setPrefersreducedmotion (string Value)
Define the type of reduced motion to use for the user interface. When set to [enum@Gtk.ReducedMotion.REDUCE] the UI is rendered in with reduced motion animations. When set to [enum@Gtk.ReducedMotion.NO_PREFERENCE] (the default), the user interface will be rendered in default mode. This setting is be available for media queries in CSS:
css @media (prefers-reduced-motion: reduce) { // some style with reduced motion }Changing this setting will reload the style sheet.
Value is the new property value.None.load_from_bytes (object data)
Loads @data into @css_provider. This clears any previously loaded information.
data is GBytes containing the data to load.None.load_from_data (string data, int length)
Loads @data into @css_provider. This clears any previously loaded information.
data is CSS data to be parsed.length is the length of @data in bytes, or -1 for NUL terminated strings.None.load_from_file (object file)
Loads the data contained in @file into @css_provider. This clears any previously loaded information.
file is GFile pointing to a file to load.None.load_from_path (string path)
Loads the data contained in @path into @css_provider. This clears any previously loaded information.
path is the path of a filename to load, in the GLib filename encoding.None.load_from_resource (string resource_path)
Loads the data contained in the resource at @resource_path into the
This clears any previously loaded information.resource_path is a GResource resource path.None.load_from_string (string arg1String)
Loads @string into @css_provider. This clears any previously loaded information.
string is the CSS to load.None.load_named (string name, string variant)
Loads a theme from the usual theme paths. The actual process of finding the theme might change between releases, but it is guaranteed that this function uses the same mechanism to load the theme that GTK uses for loading its own theme.
name is A theme name.variant is variant to load, for example, "dark", or %NULL for the default.None.to_string ()
Converts the @provider into a string representation in CSS format. Using [method@Gtk.CssProvider.load_from_string] with the return value from this function on a new provider created with [ctor@Gtk.CssProvider.new] will basically create a duplicate of this @provider.
[365:7] extends: object
Generated low-level callback wrapper for GIR callback parsing-error.
CssProviderParsingerrorCallback (callback Fn, UserData = null)
Creates one native callback wrapper. The wrapper owns a trampoline that converts native pointers into generated wrapper objects before invoking
Fn.
Fn is the Aussom callback implementation.UserData is retained and passed through to Fn on each invocation when provided.trampoline (nativeSelf, section, error, nativeUserData)
Internal trampoline. Converts native pointer arguments into generated wrapper instances, then invokes the user's callback.
callback ()
Returns the wrapped NativeCallback.
handle ()
Returns the callback as a NativeHandle.
close ()
Closes the underlying NativeCallback.
isClosed ()
Returns true when the callback has been closed.
[437:14] static extends: object
Generated metadata helpers for CssProvider class surfaces.
properties ()
Returns property metadata for
CssProvider.
A list.signals ()
Returns signal metadata for
CssProvider.
A list.
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.