    {-# LINE 2 "./Graphics/UI/Gtk/General/CssProvider.chs" #-}
    -- -*-haskell-*-
    -- GIMP Toolkit (GTK) Styles
    --
    -- Author : Axel Simon
    --
    -- Created: 13 February 2003
    --
    -- Copyright (C) 1999-2005 Axel Simon
    --
    -- This library is free software; you can redistribute it and/or
    -- modify it under the terms of the GNU Lesser General Public
    -- License as published by the Free Software Foundation; either
    -- version 2.1 of the License, or (at your option) any later version.
    --
    -- This library is distributed in the hope that it will be useful,
    -- but WITHOUT ANY WARRANTY; without even the implied warranty of
    -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    -- Lesser General Public License for more details.
    --
    -- |
    -- Maintainer : gtk2hs-users@lists.sourceforge.net
    -- Stability : provisional
    -- Portability : portable (depends on GHC)
    --
    -- CSS-like styling for widgets.
    --
    module Graphics.UI.Gtk.General.CssProvider (
    -- * Description
    --
    -- | @CssProvider@ is an object implementing the @StyleProvider@ interface.
    -- It is able to parse CSS-like input in order to style widgets.
    --

    -- * Types
      CssProvider,
      CssProviderClass,
      castToCssProvider, gTypeCssProvider,
      toCssProvider,

    -- * Enums
      CssProviderError(..),

    -- * Constructors
      cssProviderNew,

    -- * Methods
      cssProviderGetDefault,
      cssProviderGetNamed,
      cssProviderLoadFromData,
      cssProviderLoadFromString,
      cssProviderLoadFromPath,

      cssProviderToString,

      ) where

    {-# LINE 63 "./Graphics/UI/Gtk/General/CssProvider.chs" #-}

    import System.Glib.FFI
    import System.Glib.UTFString
    import Graphics.UI.Gtk.Types
    {-# LINE 67 "./Graphics/UI/Gtk/General/CssProvider.chs" #-}
    import System.Glib.GError (propagateGError)

    data CssProviderError = CssProviderErrorFailed
                          | CssProviderErrorSyntax
                          | CssProviderErrorImport
                          | CssProviderErrorName
                          | CssProviderErrorDeprecated
                          | CssProviderErrorUnknownValue
                          deriving (Int -> CssProviderError
    CssProviderError -> Int
    CssProviderError -> [CssProviderError]
    CssProviderError -> CssProviderError
    CssProviderError -> CssProviderError -> [CssProviderError]
    CssProviderError
    -> CssProviderError -> CssProviderError -> [CssProviderError]
    (CssProviderError -> CssProviderError)
    -> (CssProviderError -> CssProviderError)
    -> (Int -> CssProviderError)
    -> (CssProviderError -> Int)
    -> (CssProviderError -> [CssProviderError])
    -> (CssProviderError -> CssProviderError -> [CssProviderError])
    -> (CssProviderError -> CssProviderError -> [CssProviderError])
    -> (CssProviderError
        -> CssProviderError -> CssProviderError -> [CssProviderError])
    -> Enum CssProviderError
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: CssProviderError -> CssProviderError
    succ :: CssProviderError -> CssProviderError
    $cpred :: CssProviderError -> CssProviderError
    pred :: CssProviderError -> CssProviderError
    $ctoEnum :: Int -> CssProviderError
    toEnum :: Int -> CssProviderError
    $cfromEnum :: CssProviderError -> Int
    fromEnum :: CssProviderError -> Int
    $cenumFrom :: CssProviderError -> [CssProviderError]
    enumFrom :: CssProviderError -> [CssProviderError]
    $cenumFromThen :: CssProviderError -> CssProviderError -> [CssProviderError]
    enumFromThen :: CssProviderError -> CssProviderError -> [CssProviderError]
    $cenumFromTo :: CssProviderError -> CssProviderError -> [CssProviderError]
    enumFromTo :: CssProviderError -> CssProviderError -> [CssProviderError]
    $cenumFromThenTo :: CssProviderError
    -> CssProviderError -> CssProviderError -> [CssProviderError]
    enumFromThenTo :: CssProviderError
    -> CssProviderError -> CssProviderError -> [CssProviderError]
    Enum,CssProviderError
    CssProviderError -> CssProviderError -> Bounded CssProviderError
    forall a. a -> a -> Bounded a
    $cminBound :: CssProviderError
    minBound :: CssProviderError
    $cmaxBound :: CssProviderError
    maxBound :: CssProviderError
    Bounded,CssProviderError -> CssProviderError -> Bool
    (CssProviderError -> CssProviderError -> Bool)
    -> (CssProviderError -> CssProviderError -> Bool)
    -> Eq CssProviderError
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: CssProviderError -> CssProviderError -> Bool
    == :: CssProviderError -> CssProviderError -> Bool
    $c/= :: CssProviderError -> CssProviderError -> Bool
    /= :: CssProviderError -> CssProviderError -> Bool
    Eq,Int -> CssProviderError -> ShowS
    [CssProviderError] -> ShowS
    CssProviderError -> String
    (Int -> CssProviderError -> ShowS)
    -> (CssProviderError -> String)
    -> ([CssProviderError] -> ShowS)
    -> Show CssProviderError
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> CssProviderError -> ShowS
    showsPrec :: Int -> CssProviderError -> ShowS
    $cshow :: CssProviderError -> String
    show :: CssProviderError -> String
    $cshowList :: [CssProviderError] -> ShowS
    showList :: [CssProviderError] -> ShowS
    Show)

    {-# LINE 70 "./Graphics/UI/Gtk/General/CssProvider.chs" #-}

    --------------------
    -- Interfaces

    instance StyleProviderClass CssProvider

    --------------------
    -- Constructors

    -- | Returns a newly created CssProvider
    cssProviderNew :: IO CssProvider -- ^ A new CssProvider
    cssProviderNew :: IO CssProvider
    cssProviderNew =
      (ForeignPtr CssProvider -> CssProvider, FinalizerPtr CssProvider)
    -> IO (Ptr CssProvider) -> IO CssProvider
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    wrapNewGObject (ForeignPtr CssProvider -> CssProvider, FinalizerPtr CssProvider)
    forall {a}. (ForeignPtr CssProvider -> CssProvider, FinalizerPtr a)
    mkCssProvider IO (Ptr CssProvider)
    gtk_css_provider_new
    {-# LINE 83 "./Graphics/UI/Gtk/General/CssProvider.chs" #-}

    --------------------
    -- Methods

    -- | Returns the provider containing the style settings used as a fallback for all widgets.
    cssProviderGetDefault :: IO CssProvider -- ^ The provider used for fallback styling
    cssProviderGetDefault :: IO CssProvider
    cssProviderGetDefault =
      (ForeignPtr CssProvider -> CssProvider, FinalizerPtr CssProvider)
    -> IO (Ptr CssProvider) -> IO CssProvider
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    makeNewGObject (ForeignPtr CssProvider -> CssProvider, FinalizerPtr CssProvider)
    forall {a}. (ForeignPtr CssProvider -> CssProvider, FinalizerPtr a)
    mkCssProvider IO (Ptr CssProvider)
    gtk_css_provider_get_default
    {-# LINE 91 "./Graphics/UI/Gtk/General/CssProvider.chs" #-}

    -- | Loads a theme from the usual theme paths
    cssProviderGetNamed :: GlibString string
                        => string -- ^ @name@ : A theme name
                        -> Maybe string -- ^ @variant@ to load, for example, "dark"
                        -> IO (Maybe CssProvider) -- ^ a @CssProvider@ with the theme loaded
    cssProviderGetNamed :: forall string.
    GlibString string =>
    string -> Maybe string -> IO (Maybe CssProvider)
    cssProviderGetNamed string
    name Maybe string
    variant =
      (IO (Ptr CssProvider) -> IO CssProvider)
    -> IO (Ptr CssProvider) -> IO (Maybe CssProvider)
    forall a. (IO (Ptr a) -> IO a) -> IO (Ptr a) -> IO (Maybe a)
    maybeNull ((ForeignPtr CssProvider -> CssProvider, FinalizerPtr CssProvider)
    -> IO (Ptr CssProvider) -> IO CssProvider
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    makeNewGObject (ForeignPtr CssProvider -> CssProvider, FinalizerPtr CssProvider)
    forall {a}. (ForeignPtr CssProvider -> CssProvider, FinalizerPtr a)
    mkCssProvider) (IO (Ptr CssProvider) -> IO (Maybe CssProvider))
    -> IO (Ptr CssProvider) -> IO (Maybe CssProvider)
    forall a b. (a -> b) -> a -> b
    $
      string -> (CString -> IO (Ptr CssProvider)) -> IO (Ptr CssProvider)
    forall a. string -> (CString -> IO a) -> IO a
    forall s a. GlibString s => s -> (CString -> IO a) -> IO a
    withUTFString string
    name ((CString -> IO (Ptr CssProvider)) -> IO (Ptr CssProvider))
    -> (CString -> IO (Ptr CssProvider)) -> IO (Ptr CssProvider)
    forall a b. (a -> b) -> a -> b
    $ \CString
    namePtr ->
      (string
     -> (CString -> IO (Ptr CssProvider)) -> IO (Ptr CssProvider))
    -> Maybe string
    -> (CString -> IO (Ptr CssProvider))
    -> IO (Ptr CssProvider)
    forall a b c.
    (a -> (Ptr b -> IO c) -> IO c)
    -> Maybe a -> (Ptr b -> IO c) -> IO c
    maybeWith string -> (CString -> IO (Ptr CssProvider)) -> IO (Ptr CssProvider)
    forall a. string -> (CString -> IO a) -> IO a
    forall s a. GlibString s => s -> (CString -> IO a) -> IO a
    withUTFString Maybe string
    variant ((CString -> IO (Ptr CssProvider)) -> IO (Ptr CssProvider))
    -> (CString -> IO (Ptr CssProvider)) -> IO (Ptr CssProvider)
    forall a b. (a -> b) -> a -> b
    $ \CString
    variantPtr ->
      CString -> CString -> IO (Ptr CssProvider)
    gtk_css_provider_get_named CString
    namePtr CString
    variantPtr

    -- | Loads @_data@ into @cssProvider@, making it clear any previously loaded information.
    cssProviderLoadFromData :: CssProviderClass cssProvider
                          => cssProvider -- ^ @cssProvider@ : a @CssProvider@
                          -> Ptr CChar -- ^ @_data@ : CSS data loaded in memory. [array length=length][element-type guint8]
                          -> Int -- ^ @length@ : 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.
                          -> IO ()
    cssProviderLoadFromData :: forall cssProvider.
    CssProviderClass cssProvider =>
    cssProvider -> CString -> Int -> IO ()
    cssProviderLoadFromData cssProvider
    cssProvider CString
    _data Int
    length =
      (Ptr (Ptr ()) -> IO ()) -> IO ()
    forall a. (Ptr (Ptr ()) -> IO a) -> IO a
    propagateGError ((Ptr (Ptr ()) -> IO ()) -> IO ())
    -> (Ptr (Ptr ()) -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr (Ptr ())
    errPtrPtr ->
      (\(CssProvider ForeignPtr CssProvider
    arg1) CString
    arg2 CLong
    arg3 Ptr (Ptr ())
    arg4 -> ForeignPtr CssProvider -> (Ptr CssProvider -> IO CInt) -> IO CInt
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr CssProvider
    arg1 ((Ptr CssProvider -> IO CInt) -> IO CInt)
    -> (Ptr CssProvider -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \Ptr CssProvider
    argPtr1 ->Ptr CssProvider -> CString -> CLong -> Ptr (Ptr ()) -> IO CInt
    gtk_css_provider_load_from_data Ptr CssProvider
    argPtr1 CString
    arg2 CLong
    arg3 Ptr (Ptr ())
    arg4)
    {-# LINE 114 "./Graphics/UI/Gtk/General/CssProvider.chs" #-}
      (toCssProvider cssProvider)
      CString
    _data
      (Int -> CLong
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    length)
      Ptr (Ptr ())
    errPtrPtr IO CInt -> IO () -> IO ()
    forall a b. IO a -> IO b -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> () -> IO ()
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    -- | Loads @css@ into @cssProvider@, making it clear any previously loaded information.
    cssProviderLoadFromString :: (CssProviderClass cssProvider, GlibString string)
                              => cssProvider -- ^ @cssProvider@ : a @CssProvider@
                              -> string -- ^ @css@ : CSS data loaded in memory.
                              -> IO ()
    cssProviderLoadFromString :: forall cssProvider string.
    (CssProviderClass cssProvider, GlibString string) =>
    cssProvider -> string -> IO ()
    cssProviderLoadFromString cssProvider
    cssProvider string
    css =
      string -> (CStringLen -> IO ()) -> IO ()
    forall a. string -> (CStringLen -> IO a) -> IO a
    forall s a. GlibString s => s -> (CStringLen -> IO a) -> IO a
    withUTFStringLen string
    css ((CStringLen -> IO ()) -> IO ()) -> (CStringLen -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \(CString
    cssPtr, Int
    len) ->
      cssProvider -> CString -> Int -> IO ()
    forall cssProvider.
    CssProviderClass cssProvider =>
    cssProvider -> CString -> Int -> IO ()
    cssProviderLoadFromData cssProvider
    cssProvider CString
    cssPtr Int
    len

    -- |Loads the data contained in @path@ into @cssProvider@, making it clear any previously
    -- loaded information
    cssProviderLoadFromPath :: (CssProviderClass cssProvider, GlibFilePath fp)
                            => cssProvider -- ^ @cssProvider@ a @CssProvider@
                            -> fp -- ^ the path of a filename to load
                            -> IO ()
    cssProviderLoadFromPath :: forall cssProvider fp.
    (CssProviderClass cssProvider, GlibFilePath fp) =>
    cssProvider -> fp -> IO ()
    cssProviderLoadFromPath cssProvider
    cssProvider fp
    path =
      (Ptr (Ptr ()) -> IO ()) -> IO ()
    forall a. (Ptr (Ptr ()) -> IO a) -> IO a
    propagateGError ((Ptr (Ptr ()) -> IO ()) -> IO ())
    -> (Ptr (Ptr ()) -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr (Ptr ())
    errPtrPtr ->
      fp -> (CString -> IO ()) -> IO ()
    forall a. fp -> (CString -> IO a) -> IO a
    forall fp a. GlibFilePath fp => fp -> (CString -> IO a) -> IO a
    withUTFFilePath fp
    path ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \CString
    pathPtr ->
      (\(CssProvider ForeignPtr CssProvider
    arg1) CString
    arg2 Ptr (Ptr ())
    arg3 -> ForeignPtr CssProvider -> (Ptr CssProvider -> IO CInt) -> IO CInt
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr CssProvider
    arg1 ((Ptr CssProvider -> IO CInt) -> IO CInt)
    -> (Ptr CssProvider -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \Ptr CssProvider
    argPtr1 ->Ptr CssProvider -> CString -> Ptr (Ptr ()) -> IO CInt
    gtk_css_provider_load_from_path Ptr CssProvider
    argPtr1 CString
    arg2 Ptr (Ptr ())
    arg3)
    {-# LINE 138 "./Graphics/UI/Gtk/General/CssProvider.chs" #-}
      (toCssProvider cssProvider)
      CString
    pathPtr
      Ptr (Ptr ())
    errPtrPtr IO CInt -> IO () -> IO ()
    forall a b. IO a -> IO b -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> () -> IO ()
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    -- | Convertes the @provider@ into a string representation in CSS format.
    --
    -- Using @cssProviderLoadFromString@ with the return value from this function
    -- on a new provider created with @cssProviderNew@ will basically create a
    -- duplicate of this @provider@.
    cssProviderToString :: (CssProviderClass cssProvider, GlibString string)
                        => cssProvider -- ^ @provider@ a @CssProvider@
                        -> IO string
    cssProviderToString :: forall cssProvider string.
    (CssProviderClass cssProvider, GlibString string) =>
    cssProvider -> IO string
    cssProviderToString cssProvider
    provider =
      (\(CssProvider ForeignPtr CssProvider
    arg1) -> ForeignPtr CssProvider
    -> (Ptr CssProvider -> IO CString) -> IO CString
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr CssProvider
    arg1 ((Ptr CssProvider -> IO CString) -> IO CString)
    -> (Ptr CssProvider -> IO CString) -> IO CString
    forall a b. (a -> b) -> a -> b
    $ \Ptr CssProvider
    argPtr1 ->Ptr CssProvider -> IO CString
    gtk_css_provider_to_string Ptr CssProvider
    argPtr1)
    {-# LINE 153 "./Graphics/UI/Gtk/General/CssProvider.chs" #-}
      (toCssProvider provider) IO CString -> (CString -> IO string) -> IO string
    forall a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= CString -> IO string
    forall s. GlibString s => CString -> IO s
    peekUTFString

    foreign import ccall safe "gtk_css_provider_new"
      gtk_css_provider_new :: (IO (Ptr CssProvider))

    foreign import ccall safe "gtk_css_provider_get_default"
      gtk_css_provider_get_default :: (IO (Ptr CssProvider))

    foreign import ccall safe "gtk_css_provider_get_named"
      gtk_css_provider_get_named :: ((Ptr CChar) -> ((Ptr CChar) -> (IO (Ptr CssProvider))))

    foreign import ccall safe "gtk_css_provider_load_from_data"
      gtk_css_provider_load_from_data :: ((Ptr CssProvider) -> ((Ptr CChar) -> (CLong -> ((Ptr (Ptr ())) -> (IO CInt)))))

    foreign import ccall safe "gtk_css_provider_load_from_path"
      gtk_css_provider_load_from_path :: ((Ptr CssProvider) -> ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO CInt))))

    foreign import ccall safe "gtk_css_provider_to_string"
      gtk_css_provider_to_string :: ((Ptr CssProvider) -> (IO (Ptr CChar)))