CssProviderProtocol
public protocol CssProviderProtocol : ObjectProtocol, StyleProviderProtocol
GtkCssProvider is an object implementing the GtkStyleProvider interface.
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_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 GtkSettings: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 GtkSettings:gtk-key-theme-name.
The CssProviderProtocol protocol exposes the methods and properties of an underlying GtkCssProvider instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see CssProvider.
Alternatively, use CssProviderRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkCssProviderinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
css_provider_ptrDefault implementationTyped pointer to the underlying
GtkCssProviderinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkCssProviderinstance.Declaration
Swift
var css_provider_ptr: UnsafeMutablePointer<GtkCssProvider>! { get } -
Required Initialiser for types conforming to
CssProviderProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer) -
styleProviderExtension methodReturn the CSS provider as a style provider
Declaration
Swift
@inlinable var styleProvider: StyleProviderRef { get } -
load(from:Extension method) Loads the data provided in the given string into the CSS Provider
Throws
anErrorTypeif there is an issue with the CSSDeclaration
Swift
@discardableResult @inlinable func load(from data: String) throws -> BoolParameters
datathe CSS data represented as a String
Return Value
trueiff successful
-
connect(signal:Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
CssProviderSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: CssProviderSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatahandlerThe Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
CssProviderSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: CssProviderSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatasignalHandlerThe C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onParsingError(flags:Extension methodhandler: ) Signals that a parsing error occurred. the
path,lineandpositiondescribe 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.
Note
This represents the underlyingparsing-errorsignalDeclaration
Swift
@discardableResult @inlinable func onParsingError(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CssProviderRef, _ section: CssSectionRef, _ error: GLib.ErrorRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
sectionsection the error happened in
errorThe parsing error
handlerThe signal handler to call Run the given callback whenever the
parsingErrorsignal is emitted -
parsingErrorSignalExtension methodTyped
parsing-errorsignal for using theconnect(signal:)methodsDeclaration
Swift
static var parsingErrorSignal: CssProviderSignalName { get }
-
loadFrom(data:Extension methodlength: ) Loads
dataintocss_provider, and by doing so clears any previously loaded information.Declaration
Swift
@inlinable func loadFrom(data: UnsafePointer<gchar>!, length: gssize) throws -> Bool -
loadFrom(file:Extension method) Loads the data contained in
fileintocss_provider, making it clear any previously loaded information.Declaration
Swift
@inlinable func loadFrom<FileT>(file: FileT) throws -> Bool where FileT : FileProtocol -
loadFrom(path:Extension method) Loads the data contained in
pathintocss_provider, making it clear any previously loaded information.Declaration
Swift
@inlinable func loadFrom(path: UnsafePointer<gchar>!) throws -> Bool -
loadFrom(resourcePath:Extension method) Loads the data contained in the resource at
resource_pathinto theGtkCssProvider, clearing any previously loaded information.To track errors while loading CSS, connect to the
GtkCssProvider::parsing-errorsignal.Declaration
Swift
@inlinable func loadFrom(resourcePath: UnsafePointer<gchar>!) -
toString()Extension methodConverts the
providerinto 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 withgtk_css_provider_new()will basically create a duplicate of thisprovider.Declaration
Swift
@inlinable func toString() -> String! -
parentInstanceExtension methodUndocumented
Declaration
Swift
@inlinable var parentInstance: GObject { get }
View on GitHub
Install in Dash
CssProviderProtocol Protocol Reference