class Gtk::CssProvider
- Gtk::CssProvider
- GObject::Object
- Reference
- Object
Overview
Gtk::CssProvider
is an object implementing the Gtk::StyleProvider
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::CssProvider#load_from_file
or
Gtk::CssProvider#load_from_resource
and adding the provider with Gtk::StyleContext#add_provider
or
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.
Included Modules
Defined in:
lib/gi-crystal/src/auto/gtk-4.0/css_provider.crConstructors
-
.new : self
Returns a newly created
Gtk::CssProvider
.
Class Method Summary
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
Instance Method Summary
-
#==(other : self)
Returns
true
if this reference is the same as other. -
#hash(hasher)
See
Object#hash(hasher)
-
#load_from_data(data : Bytes) : Nil
Loads data into css_provider.
- #load_from_data(*data : UInt8)
-
#load_from_file(file : Gio::File) : Nil
Loads the data contained in file into css_provider.
-
#load_from_path(path : String) : Nil
Loads the data contained in path into css_provider.
-
#load_from_resource(resource_path : String) : Nil
Loads the data contained in the resource at resource_path into the css_provider.
-
#load_named(name : String, variant : String | Nil) : Nil
Loads a theme from the usual theme paths.
- #parsing_error_signal
-
#to_string : String
Converts the provider into a string representation in CSS format.
Instance methods inherited from module Gtk::StyleProvider
gtk_private_changed_signal
gtk_private_changed_signal,
to_unsafe
to_unsafe
Constructor methods inherited from module Gtk::StyleProvider
cast(obj : GObject::Object) : self
cast
Class methods inherited from module Gtk::StyleProvider
cast?(obj : GObject::Object) : self | Nil
cast?,
g_type : UInt64
g_type
Instance methods inherited from class GObject::Object
==(other : self)
==,
bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
bind_property,
bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
bind_property_full,
data(key : String) : Pointer(Void) | Nil
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
hash(hasher)
hash,
notify(property_name : String) : Nil
notify,
notify_by_pspec(pspec : GObject::ParamSpec) : Nil
notify_by_pspec,
notify_signal
notify_signal,
property(property_name : String, value : _) : Nil
property,
qdata(quark : UInt32) : Pointer(Void) | Nil
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void) | Nil) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void) | Nil
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void) | Nil
steal_qdata,
thaw_notify : Nil
thaw_notify,
to_unsafe : Pointer(Void)
to_unsafe,
watch_closure(closure : GObject::Closure) : Nil
watch_closure
Constructor methods inherited from class GObject::Object
cast(obj : GObject::Object) : self
cast,
new(pointer : Pointer(Void), transfer : GICrystal::Transfer)new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv
Class methods inherited from class GObject::Object
cast?(obj : GObject::Object) : self | Nil
cast?,
compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64
compat_control,
g_type : UInt64
g_type,
interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
interface_find_property,
interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
interface_list_properties
Macros inherited from class GObject::Object
previous_vfunc(*args)
previous_vfunc,
previous_vfunc!(*args)
previous_vfunc!,
signal(signature)
signal
Constructor Detail
Class Method Detail
Returns the type id (GType) registered in GLib type system.
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Loads data into css_provider.
This clears any previously loaded information.
Loads the data contained in file into css_provider.
This clears any previously loaded information.
Loads the data contained in path into css_provider.
This clears any previously loaded information.
Loads the data contained in the resource at resource_path into the css_provider.
This clears any previously loaded information.
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.
Converts the provider into a string representation in CSS format.
Using Gtk::CssProvider#load_from_data
with the return
value from this function on a new provider created with
Gtk::CssProvider.new
will basically create a duplicate
of this provider.