Gtk.CssProvider
Description: Reference for Gtk.CssProvider

### Class

# GtkCssProvider

since: 4.0

#### Description [src]

    final class Gtk.CssProvider : GObject.Object
      implements Gtk.StyleProvider {
      /* No available fields */
    }

`GtkCssProvider` is an object implementing the `GtkStyleProvider` interface 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 `gtk_css_provider_load_from_file()` or `gtk_css_provider_load_from_resource()` and adding the provider with `gtk_style_context_add_provider()` or `gtk_style_context_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 `GtkSettings:gtk-theme-name` setting), `VARIANT` is the variant to load (see the `GtkSettings: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 `GtkCssProvider::parsing-error` signal.

Available since: 4.0

#### Ancestors

- GObject

#### Implements

- GtkStyleProvider

#### Constructors

###### gtk_css_provider_new

Returns a newly created `GtkCssProvider`.

since: 4.0

#### Instance methods

###### gtk_css_provider_load_from_bytes

Loads `data` into `css_provider`.

since: 4.12

###### gtk_css_provider_load_from_data

Loads `data` into `css_provider`.

deprecated: 4.12 since: 4.0

###### gtk_css_provider_load_from_file

Loads the data contained in `file` into `css_provider`.

since: 4.0

###### gtk_css_provider_load_from_path

Loads the data contained in `path` into `css_provider`.

since: 4.0

###### gtk_css_provider_load_from_resource

Loads the data contained in the resource at `resource_path` into the `css_provider`.

since: 4.0

###### gtk_css_provider_load_from_string

Loads `string` into `css_provider`.

since: 4.12

###### gtk_css_provider_load_named

Loads a theme from the usual theme paths.

since: 4.0

###### gtk_css_provider_to_string

Converts the `provider` into a string representation in CSS format.

since: 4.0

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Signals

###### Gtk.CssProvider::parsing-error

Signals that a parsing error occurred.

since: 4.0

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

since: 2.0

##### Signals inherited from GtkStyleProvider (1)

###### GtkStyleProvider::gtk-private-changed

No description available.

since: 4.0

#### Class structure

    struct GtkCssProviderClass {
      /* no available fields */
    }

No description available.