Gtk.Css_Provider

Entities

Tagged Types

Access Types

Constants

Subprograms

Generic Instantiations

Description

GtkCssProvider is an object implementing the Gtk.Style_Provider.Gtk_Style_Provider interface. It is able to parse [CSS-like][css-overview] 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_Screen.

In addition, certain files will be read when GTK+ is initialized. First, the file $XDG_CONFIG_HOME/gtk-3.0/gtk.css is loaded if it exists. Then, GTK+ loads the first existing file among XDG_DATA_HOME/themes/THEME/gtk-VERSION/gtk.css, $HOME/.themes/THEME/gtk-VERSION/gtk.css, $XDG_DATA_DIRS/themes/THEME/gtk-VERSION/gtk.css and DATADIR/share/themes/THEME/gtk-VERSION/gtk.css, where THEME is the name of the current theme (see the Gtk.Settings.Gtk_Settings:gtk-theme-name 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 3.0.

In the same way, GTK+ tries to load a gtk-keys.css file for the current key theme, as defined by Gtk.Settings.Gtk_Settings:gtk-key-theme-name.

"+"

function "+"
  (Widget : access Gtk_Css_Provider_Record'Class)
return Gtk.Style_Provider.Gtk_Style_Provider
Parameters
Widget
Return Value

"-"

function "-"
  (Interf : Gtk.Style_Provider.Gtk_Style_Provider)
return Gtk_Css_Provider
Parameters
Interf
Return Value

Get_Default

function Get_Default return Gtk_Css_Provider

Returns the provider containing the style settings used as a fallback for all widgets. Deprecated since 3.24, 1

Return Value

The provider used for fallback styling. This memory is owned by GTK+, and you must not free it.

Get_Named

function Get_Named
   (Name    : UTF8_String;
    Variant : UTF8_String := "") return Gtk_Css_Provider

Loads a theme from the usual theme paths

Parameters
Name

A theme name

Variant

variant to load, for example, "dark", or null for the default

Return Value

a Gtk.Css_Provider.Gtk_Css_Provider with the theme loaded. This memory is owned by GTK+, and you must not free it.

Get_Style_Property

procedure Get_Style_Property
   (Self  : not null access Gtk_Css_Provider_Record;
    Path  : Gtk.Widget.Gtk_Widget_Path;
    State : Gtk.Enums.Gtk_State_Flags;
    Pspec : in out Glib.Param_Spec;
    Value : out Glib.Values.GValue;
    Found : out Boolean)
Parameters
Self
Path
State
Pspec
Value
Found

Get_Type

function Get_Type return Glib.GType
Return Value

Gtk_Css_Provider

type Gtk_Css_Provider is access all Gtk_Css_Provider_Record'Class;

Gtk_Css_Provider_New

function Gtk_Css_Provider_New return Gtk_Css_Provider

Returns a newly created Gtk.Css_Provider.Gtk_Css_Provider.

Return Value

Gtk_Css_Provider_Record

type Gtk_Css_Provider_Record is new GObject_Record with null record;

Gtk_New

procedure Gtk_New (Self : out Gtk_Css_Provider)

Returns a newly created Gtk.Css_Provider.Gtk_Css_Provider. Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Self

Implements_Gtk_Style_Provider

package Implements_Gtk_Style_Provider is new Glib.Types.Implements
  (Gtk.Style_Provider.Gtk_Style_Provider, Gtk_Css_Provider_Record, Gtk_Css_Provider);

Initialize

procedure Initialize
   (Self : not null access Gtk_Css_Provider_Record'Class)

Returns a newly created Gtk.Css_Provider.Gtk_Css_Provider. Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Self

Load_From_Data

function Load_From_Data
   (Self  : not null access Gtk_Css_Provider_Record;
    Data  : UTF8_String;
    Error : access Glib.Error.GError) return Boolean

Loads Data into Css_Provider, and by doing so clears any previously loaded information.

Parameters
Self
Data

CSS data loaded in memory

Error
Return Value

True. The return value is deprecated and False will only be returned for backwards compatibility reasons if an Error is not null and a loading error occurred. To track errors while loading CSS, connect to the Gtk.Css_Provider.Gtk_Css_Provider::parsing-error signal.

Load_From_Path

function Load_From_Path
   (Self  : not null access Gtk_Css_Provider_Record;
    Path  : UTF8_String;
    Error : access Glib.Error.GError) return Boolean

Loads the data contained in Path into Css_Provider, making it clear any previously loaded information.

Parameters
Self
Path

the path of a filename to load, in the GLib filename encoding

Error
Return Value

True. The return value is deprecated and False will only be returned for backwards compatibility reasons if an Error is not null and a loading error occurred. To track errors while loading CSS, connect to the Gtk.Css_Provider.Gtk_Css_Provider::parsing-error signal.

Load_From_Resource

procedure Load_From_Resource
   (Self          : not null access Gtk_Css_Provider_Record;
    Resource_Path : UTF8_String)

Loads the data contained in the resource at Resource_Path into the Gtk.Css_Provider.Gtk_Css_Provider, clearing any previously loaded information. To track errors while loading CSS, connect to the Gtk.Css_Provider.Gtk_Css_Provider::parsing-error signal. Since: gtk+ 3.16

Parameters
Self
Resource_Path

a Gresource.Gresource resource path

Signal_Parsing_Error

Signal_Parsing_Error : constant Glib.Signal_Name := "parsing-error";

Signals that a parsing error occurred. 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.

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. procedure Handler (Self : access Gtk_Css_Provider_Record'Class; Section : Gtk.Css_Section.Gtk_Css_Section; Error : GLib.Error)

Callback parameters: -- @param Section section the error happened in -- @param Error The parsing error

To_String

function To_String
   (Self : not null access Gtk_Css_Provider_Record) return UTF8_String

Converts the Provider into a string representation in CSS format. Using Gtk.Css_Provider.Load_From_Data with the return value from this function on a new provider created with Gtk.Css_Provider.Gtk_New will basically create a duplicate of this Provider. Since: gtk+ 3.2

Parameters
Self
Return Value

a new string representing the Provider.