Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
GtkCssProvider is an object implementing the StyleProvider
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
cssProviderLoadFromFile
or cssProviderLoadFromResource
and adding the provider with styleContextAddProvider
or
styleContextAddProviderForScreen
.
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 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 Settings
:gtk-key-theme-name
.
Synopsis
- newtype CssProvider = CssProvider (ManagedPtr CssProvider)
- class GObject o => IsCssProvider o
- toCssProvider :: (MonadIO m, IsCssProvider o) => o -> m CssProvider
- noCssProvider :: Maybe CssProvider
- cssProviderGetDefault :: (HasCallStack, MonadIO m) => m CssProvider
- cssProviderGetNamed :: (HasCallStack, MonadIO m) => Text -> Maybe Text -> m CssProvider
- cssProviderLoadFromData :: (HasCallStack, MonadIO m, IsCssProvider a) => a -> ByteString -> m ()
- cssProviderLoadFromFile :: (HasCallStack, MonadIO m, IsCssProvider a, IsFile b) => a -> b -> m ()
- cssProviderLoadFromPath :: (HasCallStack, MonadIO m, IsCssProvider a) => a -> Text -> m ()
- cssProviderLoadFromResource :: (HasCallStack, MonadIO m, IsCssProvider a) => a -> Text -> m ()
- cssProviderNew :: (HasCallStack, MonadIO m) => m CssProvider
- cssProviderToString :: (HasCallStack, MonadIO m, IsCssProvider a) => a -> m Text
- type C_CssProviderParsingErrorCallback = Ptr () -> Ptr CssSection -> Ptr GError -> Ptr () -> IO ()
- type CssProviderParsingErrorCallback = CssSection -> GError -> IO ()
- afterCssProviderParsingError :: (IsCssProvider a, MonadIO m) => a -> CssProviderParsingErrorCallback -> m SignalHandlerId
- genClosure_CssProviderParsingError :: CssProviderParsingErrorCallback -> IO Closure
- mk_CssProviderParsingErrorCallback :: C_CssProviderParsingErrorCallback -> IO (FunPtr C_CssProviderParsingErrorCallback)
- noCssProviderParsingErrorCallback :: Maybe CssProviderParsingErrorCallback
- onCssProviderParsingError :: (IsCssProvider a, MonadIO m) => a -> CssProviderParsingErrorCallback -> m SignalHandlerId
- wrap_CssProviderParsingErrorCallback :: CssProviderParsingErrorCallback -> C_CssProviderParsingErrorCallback
Exported types
newtype CssProvider Source #
Memory-managed wrapper type.
Instances
GObject CssProvider Source # | |
Defined in GI.Gtk.Objects.CssProvider gobjectType :: CssProvider -> IO GType # | |
IsObject CssProvider Source # | |
Defined in GI.Gtk.Objects.CssProvider | |
IsStyleProvider CssProvider Source # | |
Defined in GI.Gtk.Objects.CssProvider | |
IsCssProvider CssProvider Source # | |
Defined in GI.Gtk.Objects.CssProvider |
class GObject o => IsCssProvider o Source #
Type class for types which can be safely cast to CssProvider
, for instance with toCssProvider
.
Instances
(GObject a, (UnknownAncestorError CssProvider a :: Constraint)) => IsCssProvider a Source # | |
Defined in GI.Gtk.Objects.CssProvider | |
IsCssProvider CssProvider Source # | |
Defined in GI.Gtk.Objects.CssProvider |
toCssProvider :: (MonadIO m, IsCssProvider o) => o -> m CssProvider Source #
Cast to CssProvider
, for types for which this is known to be safe. For general casts, use castTo
.
noCssProvider :: Maybe CssProvider Source #
A convenience alias for Nothing
:: Maybe
CssProvider
.
Methods
getDefault
cssProviderGetDefault Source #
:: (HasCallStack, MonadIO m) | |
=> m CssProvider | Returns: The provider used for fallback styling. This memory is owned by GTK+, and you must not free it. |
Deprecated: (Since version 3.24)Use cssProviderNew
instead.
Returns the provider containing the style settings used as a fallback for all widgets.
getNamed
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> Maybe Text |
|
-> m CssProvider | Returns: a |
Loads a theme from the usual theme paths
loadFromData
cssProviderLoadFromData Source #
:: (HasCallStack, MonadIO m, IsCssProvider a) | |
=> a |
|
-> ByteString |
|
-> m () | (Can throw |
Loads data
into cssProvider
, and by doing so clears any previously loaded
information.
loadFromFile
cssProviderLoadFromFile Source #
:: (HasCallStack, MonadIO m, IsCssProvider a, IsFile b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Loads the data contained in file
into cssProvider
, making it
clear any previously loaded information.
loadFromPath
cssProviderLoadFromPath Source #
:: (HasCallStack, MonadIO m, IsCssProvider a) | |
=> a |
|
-> Text |
|
-> m () | (Can throw |
Loads the data contained in path
into cssProvider
, making it clear
any previously loaded information.
loadFromResource
cssProviderLoadFromResource Source #
:: (HasCallStack, MonadIO m, IsCssProvider a) | |
=> a |
|
-> Text |
|
-> m () |
Loads the data contained in the resource at resourcePath
into
the CssProvider
, clearing any previously loaded information.
To track errors while loading CSS, connect to the
CssProvider
::parsing-error
signal.
Since: 3.16
new
:: (HasCallStack, MonadIO m) | |
=> m CssProvider | Returns: A new |
Returns a newly created CssProvider
.
toString
:: (HasCallStack, MonadIO m, IsCssProvider a) | |
=> a |
|
-> m Text | Returns: a new string representing the |
Converts the provider
into a string representation in CSS
format.
Using cssProviderLoadFromData
with the return value
from this function on a new provider created with
cssProviderNew
will basically create a duplicate of
this provider
.
Since: 3.2
Signals
parsingError
type C_CssProviderParsingErrorCallback = Ptr () -> Ptr CssSection -> Ptr GError -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type CssProviderParsingErrorCallback Source #
= CssSection |
|
-> GError |
|
-> IO () |
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.
afterCssProviderParsingError :: (IsCssProvider a, MonadIO m) => a -> CssProviderParsingErrorCallback -> m SignalHandlerId Source #
Connect a signal handler for the “parsing-error
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
cssProvider #parsingError callback
genClosure_CssProviderParsingError :: CssProviderParsingErrorCallback -> IO Closure Source #
Wrap the callback into a Closure
.
mk_CssProviderParsingErrorCallback :: C_CssProviderParsingErrorCallback -> IO (FunPtr C_CssProviderParsingErrorCallback) Source #
Generate a function pointer callable from C code, from a C_CssProviderParsingErrorCallback
.
noCssProviderParsingErrorCallback :: Maybe CssProviderParsingErrorCallback Source #
A convenience synonym for
.Nothing
:: Maybe
CssProviderParsingErrorCallback
onCssProviderParsingError :: (IsCssProvider a, MonadIO m) => a -> CssProviderParsingErrorCallback -> m SignalHandlerId Source #
Connect a signal handler for the “parsing-error
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
cssProvider #parsingError callback