Package ch.bailu.gtk.gtk
Class CssProvider
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gtk.CssProvider
- All Implemented Interfaces:
PointerInterface
`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
[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.
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
ConstructorDescriptionReturns a newly created `GtkCssProvider`.CssProvider
(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptionImplements interfaceStyleProvider
.static ClassHandler
static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
void
loadFromData
(Str data, long length) Loads @data into @css_provider.void
loadFromData
(String data, long length) Loads @data into @css_provider.void
loadFromFile
(File file) Loads the data contained in @file into @css_provider.void
loadFromPath
(Str path) Loads the data contained in @path into @css_provider.void
loadFromPath
(String path) Loads the data contained in @path into @css_provider.void
loadFromResource
(Str resource_path) Loads the data contained in the resource at @resource_path into
the @css_provider.void
loadFromResource
(String resource_path) Loads the data contained in the resource at @resource_path into
the @css_provider.void
Loads a theme from the usual theme paths.void
Loads a theme from the usual theme paths.Connect to signal "parsing-error".toStr()
Converts the @provider into a string representation in CSS
format.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_PARSING_ERROR
- See Also:
-
-
Constructor Details
-
CssProvider
-
CssProvider
public CssProvider()Returns a newly created `GtkCssProvider`.
-
-
Method Details
-
getClassHandler
-
loadFromData
Loads @data into @css_provider.
This clears any previously loaded information.- Parameters:
data
- CSS data loaded in memorylength
- the length of @data in bytes, or -1 for NUL terminated strings. If @length is not -1, the code will assume it is not NUL terminated and will potentially do a copy.
-
loadFromData
Loads @data into @css_provider.
This clears any previously loaded information.- Parameters:
data
- CSS data loaded in memorylength
- the length of @data in bytes, or -1 for NUL terminated strings. If @length is not -1, the code will assume it is not NUL terminated and will potentially do a copy.
-
loadFromFile
Loads the data contained in @file into @css_provider.
This clears any previously loaded information.- Parameters:
file
- `GFile` pointing to a file to load
-
loadFromPath
Loads the data contained in @path into @css_provider.
This clears any previously loaded information.- Parameters:
path
- the path of a filename to load, in the GLib filename encoding
-
loadFromPath
Loads the data contained in @path into @css_provider.
This clears any previously loaded information.- Parameters:
path
- the path of a filename to load, in the GLib filename encoding
-
loadFromResource
Loads the data contained in the resource at @resource_path into
the @css_provider.
This clears any previously loaded information.- Parameters:
resource_path
- a `GResource` resource path
-
loadFromResource
Loads the data contained in the resource at @resource_path into
the @css_provider.
This clears any previously loaded information.- Parameters:
resource_path
- a `GResource` resource path
-
loadNamed
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.- Parameters:
name
- A theme namevariant
- variant to load, for example, "dark", or %NULL for the default
-
loadNamed
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.- Parameters:
name
- A theme namevariant
- variant to load, for example, "dark", or %NULL for the default
-
toStr
Converts the @provider into a string representation in CSS
format.
Using [method@Gtk.CssProvider.load_from_data] 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.- Returns:
- a new string representing the @provider.
-
onParsingError
Connect to signal "parsing-error".
SeeCssProvider.OnParsingError.onParsingError(ch.bailu.gtk.gtk.CssSection, ch.bailu.gtk.glib.Error)
for signal description.
FieldSIGNAL_ON_PARSING_ERROR
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
asStyleProvider
Implements interfaceStyleProvider
. Call this to get access to interface functions.- Returns:
StyleProvider
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-