{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- GtkCssProvider is an object implementing the t'GI.Gtk.Interfaces.StyleProvider.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
-- 'GI.Gtk.Objects.CssProvider.cssProviderLoadFromFile' or 'GI.Gtk.Objects.CssProvider.cssProviderLoadFromResource'
-- and adding the provider with 'GI.Gtk.Objects.StyleContext.styleContextAddProvider' or
-- 'GI.Gtk.Objects.StyleContext.styleContextAddProviderForDisplay'.
-- 
-- 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 t'GI.Gtk.Objects.Settings.Settings':@/gtk-theme-name/@
-- setting), VARIANT is the variant to load (see the
-- t'GI.Gtk.Objects.Settings.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.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Gtk.Objects.CssProvider
    ( 

-- * Exported types
    CssProvider(..)                         ,
    IsCssProvider                           ,
    toCssProvider                           ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [loadFromData]("GI.Gtk.Objects.CssProvider#g:method:loadFromData"), [loadFromFile]("GI.Gtk.Objects.CssProvider#g:method:loadFromFile"), [loadFromPath]("GI.Gtk.Objects.CssProvider#g:method:loadFromPath"), [loadFromResource]("GI.Gtk.Objects.CssProvider#g:method:loadFromResource"), [loadNamed]("GI.Gtk.Objects.CssProvider#g:method:loadNamed"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [stealData]("GI.GObject.Objects.Object#g:method:stealData"), [stealQdata]("GI.GObject.Objects.Object#g:method:stealQdata"), [thawNotify]("GI.GObject.Objects.Object#g:method:thawNotify"), [toString]("GI.Gtk.Objects.CssProvider#g:method:toString"), [unref]("GI.GObject.Objects.Object#g:method:unref"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure").
-- 
-- ==== Getters
-- [getData]("GI.GObject.Objects.Object#g:method:getData"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata").
-- 
-- ==== Setters
-- [setData]("GI.GObject.Objects.Object#g:method:setData"), [setDataFull]("GI.GObject.Objects.Object#g:method:setDataFull"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty").

#if defined(ENABLE_OVERLOADING)
    ResolveCssProviderMethod                ,
#endif

-- ** loadFromData #method:loadFromData#

#if defined(ENABLE_OVERLOADING)
    CssProviderLoadFromDataMethodInfo       ,
#endif
    cssProviderLoadFromData                 ,


-- ** loadFromFile #method:loadFromFile#

#if defined(ENABLE_OVERLOADING)
    CssProviderLoadFromFileMethodInfo       ,
#endif
    cssProviderLoadFromFile                 ,


-- ** loadFromPath #method:loadFromPath#

#if defined(ENABLE_OVERLOADING)
    CssProviderLoadFromPathMethodInfo       ,
#endif
    cssProviderLoadFromPath                 ,


-- ** loadFromResource #method:loadFromResource#

#if defined(ENABLE_OVERLOADING)
    CssProviderLoadFromResourceMethodInfo   ,
#endif
    cssProviderLoadFromResource             ,


-- ** loadNamed #method:loadNamed#

#if defined(ENABLE_OVERLOADING)
    CssProviderLoadNamedMethodInfo          ,
#endif
    cssProviderLoadNamed                    ,


-- ** new #method:new#

    cssProviderNew                          ,


-- ** toString #method:toString#

#if defined(ENABLE_OVERLOADING)
    CssProviderToStringMethodInfo           ,
#endif
    cssProviderToString                     ,




 -- * Signals


-- ** parsingError #signal:parsingError#

    C_CssProviderParsingErrorCallback       ,
    CssProviderParsingErrorCallback         ,
#if defined(ENABLE_OVERLOADING)
    CssProviderParsingErrorSignalInfo       ,
#endif
    afterCssProviderParsingError            ,
    genClosure_CssProviderParsingError      ,
    mk_CssProviderParsingErrorCallback      ,
    noCssProviderParsingErrorCallback       ,
    onCssProviderParsingError               ,
    wrap_CssProviderParsingErrorCallback    ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Interfaces.File as Gio.File
import {-# SOURCE #-} qualified GI.Gtk.Interfaces.StyleProvider as Gtk.StyleProvider
import {-# SOURCE #-} qualified GI.Gtk.Structs.CssSection as Gtk.CssSection

-- | Memory-managed wrapper type.
newtype CssProvider = CssProvider (SP.ManagedPtr CssProvider)
    deriving (CssProvider -> CssProvider -> Bool
(CssProvider -> CssProvider -> Bool)
-> (CssProvider -> CssProvider -> Bool) -> Eq CssProvider
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CssProvider -> CssProvider -> Bool
$c/= :: CssProvider -> CssProvider -> Bool
== :: CssProvider -> CssProvider -> Bool
$c== :: CssProvider -> CssProvider -> Bool
Eq)

instance SP.ManagedPtrNewtype CssProvider where
    toManagedPtr :: CssProvider -> ManagedPtr CssProvider
toManagedPtr (CssProvider ManagedPtr CssProvider
p) = ManagedPtr CssProvider
p

foreign import ccall "gtk_css_provider_get_type"
    c_gtk_css_provider_get_type :: IO B.Types.GType

instance B.Types.TypedObject CssProvider where
    glibType :: IO GType
glibType = IO GType
c_gtk_css_provider_get_type

instance B.Types.GObject CssProvider

-- | Type class for types which can be safely cast to `CssProvider`, for instance with `toCssProvider`.
class (SP.GObject o, O.IsDescendantOf CssProvider o) => IsCssProvider o
instance (SP.GObject o, O.IsDescendantOf CssProvider o) => IsCssProvider o

instance O.HasParentTypes CssProvider
type instance O.ParentTypes CssProvider = '[GObject.Object.Object, Gtk.StyleProvider.StyleProvider]

-- | Cast to `CssProvider`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toCssProvider :: (MIO.MonadIO m, IsCssProvider o) => o -> m CssProvider
toCssProvider :: forall (m :: * -> *) o.
(MonadIO m, IsCssProvider o) =>
o -> m CssProvider
toCssProvider = IO CssProvider -> m CssProvider
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO CssProvider -> m CssProvider)
-> (o -> IO CssProvider) -> o -> m CssProvider
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr CssProvider -> CssProvider) -> o -> IO CssProvider
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr CssProvider -> CssProvider
CssProvider

-- | Convert 'CssProvider' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe CssProvider) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_gtk_css_provider_get_type
    gvalueSet_ :: Ptr GValue -> Maybe CssProvider -> IO ()
gvalueSet_ Ptr GValue
gv Maybe CssProvider
P.Nothing = Ptr GValue -> Ptr CssProvider -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr CssProvider
forall a. Ptr a
FP.nullPtr :: FP.Ptr CssProvider)
    gvalueSet_ Ptr GValue
gv (P.Just CssProvider
obj) = CssProvider -> (Ptr CssProvider -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr CssProvider
obj (Ptr GValue -> Ptr CssProvider -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe CssProvider)
gvalueGet_ Ptr GValue
gv = do
        Ptr CssProvider
ptr <- Ptr GValue -> IO (Ptr CssProvider)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr CssProvider)
        if Ptr CssProvider
ptr Ptr CssProvider -> Ptr CssProvider -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr CssProvider
forall a. Ptr a
FP.nullPtr
        then CssProvider -> Maybe CssProvider
forall a. a -> Maybe a
P.Just (CssProvider -> Maybe CssProvider)
-> IO CssProvider -> IO (Maybe CssProvider)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr CssProvider -> CssProvider)
-> Ptr CssProvider -> IO CssProvider
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr CssProvider -> CssProvider
CssProvider Ptr CssProvider
ptr
        else Maybe CssProvider -> IO (Maybe CssProvider)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe CssProvider
forall a. Maybe a
P.Nothing
        
    

#if defined(ENABLE_OVERLOADING)
type family ResolveCssProviderMethod (t :: Symbol) (o :: *) :: * where
    ResolveCssProviderMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveCssProviderMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveCssProviderMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveCssProviderMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveCssProviderMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveCssProviderMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveCssProviderMethod "loadFromData" o = CssProviderLoadFromDataMethodInfo
    ResolveCssProviderMethod "loadFromFile" o = CssProviderLoadFromFileMethodInfo
    ResolveCssProviderMethod "loadFromPath" o = CssProviderLoadFromPathMethodInfo
    ResolveCssProviderMethod "loadFromResource" o = CssProviderLoadFromResourceMethodInfo
    ResolveCssProviderMethod "loadNamed" o = CssProviderLoadNamedMethodInfo
    ResolveCssProviderMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveCssProviderMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveCssProviderMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveCssProviderMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveCssProviderMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveCssProviderMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveCssProviderMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveCssProviderMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveCssProviderMethod "toString" o = CssProviderToStringMethodInfo
    ResolveCssProviderMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveCssProviderMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveCssProviderMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveCssProviderMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveCssProviderMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveCssProviderMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveCssProviderMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveCssProviderMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveCssProviderMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveCssProviderMethod t CssProvider, O.OverloadedMethod info CssProvider p) => OL.IsLabel t (CssProvider -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveCssProviderMethod t CssProvider, O.OverloadedMethod info CssProvider p, R.HasField t CssProvider p) => R.HasField t CssProvider p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveCssProviderMethod t CssProvider, O.OverloadedMethodInfo info CssProvider) => OL.IsLabel t (O.MethodProxy info CssProvider) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif

-- signal CssProvider::parsing-error
-- | 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.
type CssProviderParsingErrorCallback =
    Gtk.CssSection.CssSection
    -- ^ /@section@/: section the error happened in
    -> GError
    -- ^ /@error@/: The parsing error
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `CssProviderParsingErrorCallback`@.
noCssProviderParsingErrorCallback :: Maybe CssProviderParsingErrorCallback
noCssProviderParsingErrorCallback :: Maybe CssProviderParsingErrorCallback
noCssProviderParsingErrorCallback = Maybe CssProviderParsingErrorCallback
forall a. Maybe a
Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_CssProviderParsingErrorCallback =
    Ptr () ->                               -- object
    Ptr Gtk.CssSection.CssSection ->
    Ptr GError ->
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_CssProviderParsingErrorCallback`.
foreign import ccall "wrapper"
    mk_CssProviderParsingErrorCallback :: C_CssProviderParsingErrorCallback -> IO (FunPtr C_CssProviderParsingErrorCallback)

-- | Wrap the callback into a `GClosure`.
genClosure_CssProviderParsingError :: MonadIO m => CssProviderParsingErrorCallback -> m (GClosure C_CssProviderParsingErrorCallback)
genClosure_CssProviderParsingError :: forall (m :: * -> *).
MonadIO m =>
CssProviderParsingErrorCallback
-> m (GClosure C_CssProviderParsingErrorCallback)
genClosure_CssProviderParsingError CssProviderParsingErrorCallback
cb = IO (GClosure C_CssProviderParsingErrorCallback)
-> m (GClosure C_CssProviderParsingErrorCallback)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_CssProviderParsingErrorCallback)
 -> m (GClosure C_CssProviderParsingErrorCallback))
-> IO (GClosure C_CssProviderParsingErrorCallback)
-> m (GClosure C_CssProviderParsingErrorCallback)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_CssProviderParsingErrorCallback
cb' = CssProviderParsingErrorCallback
-> C_CssProviderParsingErrorCallback
wrap_CssProviderParsingErrorCallback CssProviderParsingErrorCallback
cb
    C_CssProviderParsingErrorCallback
-> IO (FunPtr C_CssProviderParsingErrorCallback)
mk_CssProviderParsingErrorCallback C_CssProviderParsingErrorCallback
cb' IO (FunPtr C_CssProviderParsingErrorCallback)
-> (FunPtr C_CssProviderParsingErrorCallback
    -> IO (GClosure C_CssProviderParsingErrorCallback))
-> IO (GClosure C_CssProviderParsingErrorCallback)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_CssProviderParsingErrorCallback
-> IO (GClosure C_CssProviderParsingErrorCallback)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `CssProviderParsingErrorCallback` into a `C_CssProviderParsingErrorCallback`.
wrap_CssProviderParsingErrorCallback ::
    CssProviderParsingErrorCallback ->
    C_CssProviderParsingErrorCallback
wrap_CssProviderParsingErrorCallback :: CssProviderParsingErrorCallback
-> C_CssProviderParsingErrorCallback
wrap_CssProviderParsingErrorCallback CssProviderParsingErrorCallback
_cb Ptr ()
_ Ptr CssSection
section Ptr GError
error_ Ptr ()
_ = do
    (ManagedPtr CssSection -> CssSection)
-> Ptr CssSection -> (CssSection -> IO ()) -> IO ()
forall a b.
(HasCallStack, ManagedPtrNewtype a) =>
(ManagedPtr a -> a) -> Ptr a -> (a -> IO b) -> IO b
B.ManagedPtr.withTransient ManagedPtr CssSection -> CssSection
Gtk.CssSection.CssSection Ptr CssSection
section ((CssSection -> IO ()) -> IO ()) -> (CssSection -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CssSection
section' -> do
        GError
error_' <- ((ManagedPtr GError -> GError) -> Ptr GError -> IO GError
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr GError -> GError
GError) Ptr GError
error_
        CssProviderParsingErrorCallback
_cb  CssSection
section' GError
error_'


-- | Connect a signal handler for the [parsingError](#signal:parsingError) signal, to be run before the default handler.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Signals.on' cssProvider #parsingError callback
-- @
-- 
-- 
onCssProviderParsingError :: (IsCssProvider a, MonadIO m) => a -> CssProviderParsingErrorCallback -> m SignalHandlerId
onCssProviderParsingError :: forall a (m :: * -> *).
(IsCssProvider a, MonadIO m) =>
a -> CssProviderParsingErrorCallback -> m SignalHandlerId
onCssProviderParsingError a
obj CssProviderParsingErrorCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_CssProviderParsingErrorCallback
cb' = CssProviderParsingErrorCallback
-> C_CssProviderParsingErrorCallback
wrap_CssProviderParsingErrorCallback CssProviderParsingErrorCallback
cb
    FunPtr C_CssProviderParsingErrorCallback
cb'' <- C_CssProviderParsingErrorCallback
-> IO (FunPtr C_CssProviderParsingErrorCallback)
mk_CssProviderParsingErrorCallback C_CssProviderParsingErrorCallback
cb'
    a
-> Text
-> FunPtr C_CssProviderParsingErrorCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"parsing-error" FunPtr C_CssProviderParsingErrorCallback
cb'' SignalConnectMode
SignalConnectBefore Maybe Text
forall a. Maybe a
Nothing

-- | Connect a signal handler for the [parsingError](#signal:parsingError) signal, to be run after the default handler.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Signals.after' cssProvider #parsingError callback
-- @
-- 
-- 
afterCssProviderParsingError :: (IsCssProvider a, MonadIO m) => a -> CssProviderParsingErrorCallback -> m SignalHandlerId
afterCssProviderParsingError :: forall a (m :: * -> *).
(IsCssProvider a, MonadIO m) =>
a -> CssProviderParsingErrorCallback -> m SignalHandlerId
afterCssProviderParsingError a
obj CssProviderParsingErrorCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_CssProviderParsingErrorCallback
cb' = CssProviderParsingErrorCallback
-> C_CssProviderParsingErrorCallback
wrap_CssProviderParsingErrorCallback CssProviderParsingErrorCallback
cb
    FunPtr C_CssProviderParsingErrorCallback
cb'' <- C_CssProviderParsingErrorCallback
-> IO (FunPtr C_CssProviderParsingErrorCallback)
mk_CssProviderParsingErrorCallback C_CssProviderParsingErrorCallback
cb'
    a
-> Text
-> FunPtr C_CssProviderParsingErrorCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"parsing-error" FunPtr C_CssProviderParsingErrorCallback
cb'' SignalConnectMode
SignalConnectAfter Maybe Text
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
data CssProviderParsingErrorSignalInfo
instance SignalInfo CssProviderParsingErrorSignalInfo where
    type HaskellCallbackType CssProviderParsingErrorSignalInfo = CssProviderParsingErrorCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_CssProviderParsingErrorCallback cb
        cb'' <- mk_CssProviderParsingErrorCallback cb'
        connectSignalFunPtr obj "parsing-error" cb'' connectMode detail

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList CssProvider
type instance O.AttributeList CssProvider = CssProviderAttributeList
type CssProviderAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList CssProvider = CssProviderSignalList
type CssProviderSignalList = ('[ '("gtkPrivateChanged", Gtk.StyleProvider.StyleProviderGtkPrivateChangedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("parsingError", CssProviderParsingErrorSignalInfo)] :: [(Symbol, *)])

#endif

-- method CssProvider::new
-- method type : Constructor
-- Args: []
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gtk" , name = "CssProvider" })
-- throws : False
-- Skip return : False

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

-- | Returns a newly created t'GI.Gtk.Objects.CssProvider.CssProvider'.
cssProviderNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m CssProvider
    -- ^ __Returns:__ A new t'GI.Gtk.Objects.CssProvider.CssProvider'
cssProviderNew :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m CssProvider
cssProviderNew  = IO CssProvider -> m CssProvider
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CssProvider -> m CssProvider)
-> IO CssProvider -> m CssProvider
forall a b. (a -> b) -> a -> b
$ do
    Ptr CssProvider
result <- IO (Ptr CssProvider)
gtk_css_provider_new
    Text -> Ptr CssProvider -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"cssProviderNew" Ptr CssProvider
result
    CssProvider
result' <- ((ManagedPtr CssProvider -> CssProvider)
-> Ptr CssProvider -> IO CssProvider
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr CssProvider -> CssProvider
CssProvider) Ptr CssProvider
result
    CssProvider -> IO CssProvider
forall (m :: * -> *) a. Monad m => a -> m a
return CssProvider
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method CssProvider::load_from_data
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "css_provider"
--           , argType =
--               TInterface Name { namespace = "Gtk" , name = "CssProvider" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GtkCssProvider" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "data"
--           , argType = TCArray False (-1) 2 (TBasicType TUInt8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "CSS data loaded in memory"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "length"
--           , argType = TBasicType TInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the length of @data in bytes, or -1 for NUL terminated strings. If\n  @length is not -1, the code will assume it is not NUL terminated and will\n  potentially do a copy."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "length"
--              , argType = TBasicType TInt64
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText =
--                        Just
--                          "the length of @data in bytes, or -1 for NUL terminated strings. If\n  @length is not -1, the code will assume it is not NUL terminated and will\n  potentially do a copy."
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_css_provider_load_from_data" gtk_css_provider_load_from_data :: 
    Ptr CssProvider ->                      -- css_provider : TInterface (Name {namespace = "Gtk", name = "CssProvider"})
    Ptr Word8 ->                            -- data : TCArray False (-1) 2 (TBasicType TUInt8)
    Int64 ->                                -- length : TBasicType TInt64
    IO ()

-- | Loads /@data@/ into /@cssProvider@/, and by doing so clears any previously loaded
-- information.
cssProviderLoadFromData ::
    (B.CallStack.HasCallStack, MonadIO m, IsCssProvider a) =>
    a
    -- ^ /@cssProvider@/: a t'GI.Gtk.Objects.CssProvider.CssProvider'
    -> ByteString
    -- ^ /@data@/: CSS data loaded in memory
    -> m ()
cssProviderLoadFromData :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCssProvider a) =>
a -> ByteString -> m ()
cssProviderLoadFromData a
cssProvider ByteString
data_ = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    let length_ :: Int64
length_ = Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int64) -> Int -> Int64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
data_
    Ptr CssProvider
cssProvider' <- a -> IO (Ptr CssProvider)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cssProvider
    Ptr Word8
data_' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
data_
    Ptr CssProvider -> Ptr Word8 -> Int64 -> IO ()
gtk_css_provider_load_from_data Ptr CssProvider
cssProvider' Ptr Word8
data_' Int64
length_
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cssProvider
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
data_'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data CssProviderLoadFromDataMethodInfo
instance (signature ~ (ByteString -> m ()), MonadIO m, IsCssProvider a) => O.OverloadedMethod CssProviderLoadFromDataMethodInfo a signature where
    overloadedMethod = cssProviderLoadFromData

instance O.OverloadedMethodInfo CssProviderLoadFromDataMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Gtk.Objects.CssProvider.cssProviderLoadFromData",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-gtk-4.0.4/docs/GI-Gtk-Objects-CssProvider.html#v:cssProviderLoadFromData"
        }


#endif

-- method CssProvider::load_from_file
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "css_provider"
--           , argType =
--               TInterface Name { namespace = "Gtk" , name = "CssProvider" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GtkCssProvider" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "file"
--           , argType = TInterface Name { namespace = "Gio" , name = "File" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GFile pointing to a file to load"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_css_provider_load_from_file" gtk_css_provider_load_from_file :: 
    Ptr CssProvider ->                      -- css_provider : TInterface (Name {namespace = "Gtk", name = "CssProvider"})
    Ptr Gio.File.File ->                    -- file : TInterface (Name {namespace = "Gio", name = "File"})
    IO ()

-- | Loads the data contained in /@file@/ into /@cssProvider@/, making it
-- clear any previously loaded information.
cssProviderLoadFromFile ::
    (B.CallStack.HasCallStack, MonadIO m, IsCssProvider a, Gio.File.IsFile b) =>
    a
    -- ^ /@cssProvider@/: a t'GI.Gtk.Objects.CssProvider.CssProvider'
    -> b
    -- ^ /@file@/: t'GI.Gio.Interfaces.File.File' pointing to a file to load
    -> m ()
cssProviderLoadFromFile :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsCssProvider a, IsFile b) =>
a -> b -> m ()
cssProviderLoadFromFile a
cssProvider b
file = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr CssProvider
cssProvider' <- a -> IO (Ptr CssProvider)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cssProvider
    Ptr File
file' <- b -> IO (Ptr File)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
file
    Ptr CssProvider -> Ptr File -> IO ()
gtk_css_provider_load_from_file Ptr CssProvider
cssProvider' Ptr File
file'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cssProvider
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
file
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data CssProviderLoadFromFileMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsCssProvider a, Gio.File.IsFile b) => O.OverloadedMethod CssProviderLoadFromFileMethodInfo a signature where
    overloadedMethod = cssProviderLoadFromFile

instance O.OverloadedMethodInfo CssProviderLoadFromFileMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Gtk.Objects.CssProvider.cssProviderLoadFromFile",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-gtk-4.0.4/docs/GI-Gtk-Objects-CssProvider.html#v:cssProviderLoadFromFile"
        }


#endif

-- method CssProvider::load_from_path
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "css_provider"
--           , argType =
--               TInterface Name { namespace = "Gtk" , name = "CssProvider" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GtkCssProvider" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "path"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the path of a filename to load, in the GLib filename encoding"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_css_provider_load_from_path" gtk_css_provider_load_from_path :: 
    Ptr CssProvider ->                      -- css_provider : TInterface (Name {namespace = "Gtk", name = "CssProvider"})
    CString ->                              -- path : TBasicType TUTF8
    IO ()

-- | Loads the data contained in /@path@/ into /@cssProvider@/, making it clear
-- any previously loaded information.
cssProviderLoadFromPath ::
    (B.CallStack.HasCallStack, MonadIO m, IsCssProvider a) =>
    a
    -- ^ /@cssProvider@/: a t'GI.Gtk.Objects.CssProvider.CssProvider'
    -> T.Text
    -- ^ /@path@/: the path of a filename to load, in the GLib filename encoding
    -> m ()
cssProviderLoadFromPath :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCssProvider a) =>
a -> Text -> m ()
cssProviderLoadFromPath a
cssProvider Text
path = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr CssProvider
cssProvider' <- a -> IO (Ptr CssProvider)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cssProvider
    CString
path' <- Text -> IO CString
textToCString Text
path
    Ptr CssProvider -> CString -> IO ()
gtk_css_provider_load_from_path Ptr CssProvider
cssProvider' CString
path'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cssProvider
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
path'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data CssProviderLoadFromPathMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsCssProvider a) => O.OverloadedMethod CssProviderLoadFromPathMethodInfo a signature where
    overloadedMethod = cssProviderLoadFromPath

instance O.OverloadedMethodInfo CssProviderLoadFromPathMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Gtk.Objects.CssProvider.cssProviderLoadFromPath",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-gtk-4.0.4/docs/GI-Gtk-Objects-CssProvider.html#v:cssProviderLoadFromPath"
        }


#endif

-- method CssProvider::load_from_resource
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "css_provider"
--           , argType =
--               TInterface Name { namespace = "Gtk" , name = "CssProvider" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GtkCssProvider" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "resource_path"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResource resource path"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_css_provider_load_from_resource" gtk_css_provider_load_from_resource :: 
    Ptr CssProvider ->                      -- css_provider : TInterface (Name {namespace = "Gtk", name = "CssProvider"})
    CString ->                              -- resource_path : TBasicType TUTF8
    IO ()

-- | Loads the data contained in the resource at /@resourcePath@/ into
-- the t'GI.Gtk.Objects.CssProvider.CssProvider', clearing any previously loaded information.
-- 
-- To track errors while loading CSS, connect to the
-- [parsingError]("GI.Gtk.Objects.CssProvider#g:signal:parsingError") signal.
cssProviderLoadFromResource ::
    (B.CallStack.HasCallStack, MonadIO m, IsCssProvider a) =>
    a
    -- ^ /@cssProvider@/: a t'GI.Gtk.Objects.CssProvider.CssProvider'
    -> T.Text
    -- ^ /@resourcePath@/: a t'GI.Gio.Structs.Resource.Resource' resource path
    -> m ()
cssProviderLoadFromResource :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCssProvider a) =>
a -> Text -> m ()
cssProviderLoadFromResource a
cssProvider Text
resourcePath = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr CssProvider
cssProvider' <- a -> IO (Ptr CssProvider)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cssProvider
    CString
resourcePath' <- Text -> IO CString
textToCString Text
resourcePath
    Ptr CssProvider -> CString -> IO ()
gtk_css_provider_load_from_resource Ptr CssProvider
cssProvider' CString
resourcePath'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cssProvider
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
resourcePath'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data CssProviderLoadFromResourceMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsCssProvider a) => O.OverloadedMethod CssProviderLoadFromResourceMethodInfo a signature where
    overloadedMethod = cssProviderLoadFromResource

instance O.OverloadedMethodInfo CssProviderLoadFromResourceMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Gtk.Objects.CssProvider.cssProviderLoadFromResource",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-gtk-4.0.4/docs/GI-Gtk-Objects-CssProvider.html#v:cssProviderLoadFromResource"
        }


#endif

-- method CssProvider::load_named
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "provider"
--           , argType =
--               TInterface Name { namespace = "Gtk" , name = "CssProvider" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GtkCssProvider" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A theme name" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "variant"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "variant to load, for example, \"dark\", or\n    %NULL for the default"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_css_provider_load_named" gtk_css_provider_load_named :: 
    Ptr CssProvider ->                      -- provider : TInterface (Name {namespace = "Gtk", name = "CssProvider"})
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- variant : TBasicType TUTF8
    IO ()

-- | 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.
cssProviderLoadNamed ::
    (B.CallStack.HasCallStack, MonadIO m, IsCssProvider a) =>
    a
    -- ^ /@provider@/: a t'GI.Gtk.Objects.CssProvider.CssProvider'
    -> T.Text
    -- ^ /@name@/: A theme name
    -> Maybe (T.Text)
    -- ^ /@variant@/: variant to load, for example, \"dark\", or
    --     'P.Nothing' for the default
    -> m ()
cssProviderLoadNamed :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCssProvider a) =>
a -> Text -> Maybe Text -> m ()
cssProviderLoadNamed a
provider Text
name Maybe Text
variant = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr CssProvider
provider' <- a -> IO (Ptr CssProvider)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
provider
    CString
name' <- Text -> IO CString
textToCString Text
name
    CString
maybeVariant <- case Maybe Text
variant of
        Maybe Text
Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just Text
jVariant -> do
            CString
jVariant' <- Text -> IO CString
textToCString Text
jVariant
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jVariant'
    Ptr CssProvider -> CString -> CString -> IO ()
gtk_css_provider_load_named Ptr CssProvider
provider' CString
name' CString
maybeVariant
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
provider
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeVariant
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data CssProviderLoadNamedMethodInfo
instance (signature ~ (T.Text -> Maybe (T.Text) -> m ()), MonadIO m, IsCssProvider a) => O.OverloadedMethod CssProviderLoadNamedMethodInfo a signature where
    overloadedMethod = cssProviderLoadNamed

instance O.OverloadedMethodInfo CssProviderLoadNamedMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Gtk.Objects.CssProvider.cssProviderLoadNamed",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-gtk-4.0.4/docs/GI-Gtk-Objects-CssProvider.html#v:cssProviderLoadNamed"
        }


#endif

-- method CssProvider::to_string
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "provider"
--           , argType =
--               TInterface Name { namespace = "Gtk" , name = "CssProvider" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the provider to write to a string"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_css_provider_to_string" gtk_css_provider_to_string :: 
    Ptr CssProvider ->                      -- provider : TInterface (Name {namespace = "Gtk", name = "CssProvider"})
    IO CString

-- | Converts the /@provider@/ into a string representation in CSS
-- format.
-- 
-- Using 'GI.Gtk.Objects.CssProvider.cssProviderLoadFromData' with the return value
-- from this function on a new provider created with
-- 'GI.Gtk.Objects.CssProvider.cssProviderNew' will basically create a duplicate of
-- this /@provider@/.
cssProviderToString ::
    (B.CallStack.HasCallStack, MonadIO m, IsCssProvider a) =>
    a
    -- ^ /@provider@/: the provider to write to a string
    -> m T.Text
    -- ^ __Returns:__ a new string representing the /@provider@/.
cssProviderToString :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCssProvider a) =>
a -> m Text
cssProviderToString a
provider = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr CssProvider
provider' <- a -> IO (Ptr CssProvider)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
provider
    CString
result <- Ptr CssProvider -> IO CString
gtk_css_provider_to_string Ptr CssProvider
provider'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"cssProviderToString" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
provider
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if defined(ENABLE_OVERLOADING)
data CssProviderToStringMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsCssProvider a) => O.OverloadedMethod CssProviderToStringMethodInfo a signature where
    overloadedMethod = cssProviderToString

instance O.OverloadedMethodInfo CssProviderToStringMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Gtk.Objects.CssProvider.cssProviderToString",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-gtk-4.0.4/docs/GI-Gtk-Objects-CssProvider.html#v:cssProviderToString"
        }


#endif