{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- The t'GI.Gio.Objects.SettingsBackend.SettingsBackend' interface defines a generic interface for
-- non-strictly-typed data that is stored in a hierarchy. To implement
-- an alternative storage backend for t'GI.Gio.Objects.Settings.Settings', you need to implement
-- the t'GI.Gio.Objects.SettingsBackend.SettingsBackend' interface and then make it implement the
-- extension point 'GI.Gio.Constants.SETTINGS_BACKEND_EXTENSION_POINT_NAME'.
-- 
-- The interface defines methods for reading and writing values, a
-- method for determining if writing of certain values will fail
-- (lockdown) and a change notification mechanism.
-- 
-- The semantics of the interface are very precisely defined and
-- implementations must carefully adhere to the expectations of
-- callers that are documented on each of the interface methods.
-- 
-- Some of the t'GI.Gio.Objects.SettingsBackend.SettingsBackend' functions accept or return a t'GI.GLib.Structs.Tree.Tree'.
-- These trees always have strings as keys and t'GVariant' as values.
-- @/g_settings_backend_create_tree()/@ is a convenience function to create
-- suitable trees.
-- 
-- The t'GI.Gio.Objects.SettingsBackend.SettingsBackend' API is exported to allow third-party
-- implementations, but does not carry the same stability guarantees
-- as the public GIO API. For this reason, you have to define the
-- C preprocessor symbol @/G_SETTINGS_ENABLE_BACKEND/@ before including
-- @gio\/gsettingsbackend.h@.

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

module GI.Gio.Objects.SettingsBackend
    ( 
#if defined(ENABLE_OVERLOADING)
    SettingsBackendFlattenTreeMethodInfo    ,
#endif

-- * Exported types
    SettingsBackend(..)                     ,
    IsSettingsBackend                       ,
    toSettingsBackend                       ,
    noSettingsBackend                       ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveSettingsBackendMethod            ,
#endif


-- ** changed #method:changed#

#if defined(ENABLE_OVERLOADING)
    SettingsBackendChangedMethodInfo        ,
#endif
    settingsBackendChanged                  ,


-- ** changedTree #method:changedTree#

#if defined(ENABLE_OVERLOADING)
    SettingsBackendChangedTreeMethodInfo    ,
#endif
    settingsBackendChangedTree              ,


-- ** getDefault #method:getDefault#

    settingsBackendGetDefault               ,


-- ** keysChanged #method:keysChanged#

#if defined(ENABLE_OVERLOADING)
    SettingsBackendKeysChangedMethodInfo    ,
#endif
    settingsBackendKeysChanged              ,


-- ** pathChanged #method:pathChanged#

#if defined(ENABLE_OVERLOADING)
    SettingsBackendPathChangedMethodInfo    ,
#endif
    settingsBackendPathChanged              ,


-- ** pathWritableChanged #method:pathWritableChanged#

#if defined(ENABLE_OVERLOADING)
    SettingsBackendPathWritableChangedMethodInfo,
#endif
    settingsBackendPathWritableChanged      ,


-- ** writableChanged #method:writableChanged#

#if defined(ENABLE_OVERLOADING)
    SettingsBackendWritableChangedMethodInfo,
#endif
    settingsBackendWritableChanged          ,




    ) 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.ManagedPtr as B.ManagedPtr
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 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 GI.GLib.Structs.Tree as GLib.Tree
import qualified GI.GObject.Objects.Object as GObject.Object

-- | Memory-managed wrapper type.
newtype SettingsBackend = SettingsBackend (ManagedPtr SettingsBackend)
    deriving (SettingsBackend -> SettingsBackend -> Bool
(SettingsBackend -> SettingsBackend -> Bool)
-> (SettingsBackend -> SettingsBackend -> Bool)
-> Eq SettingsBackend
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SettingsBackend -> SettingsBackend -> Bool
$c/= :: SettingsBackend -> SettingsBackend -> Bool
== :: SettingsBackend -> SettingsBackend -> Bool
$c== :: SettingsBackend -> SettingsBackend -> Bool
Eq)
foreign import ccall "g_settings_backend_get_type"
    c_g_settings_backend_get_type :: IO GType

instance GObject SettingsBackend where
    gobjectType :: IO GType
gobjectType = IO GType
c_g_settings_backend_get_type
    

-- | Convert 'SettingsBackend' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue SettingsBackend where
    toGValue :: SettingsBackend -> IO GValue
toGValue o :: SettingsBackend
o = do
        GType
gtype <- IO GType
c_g_settings_backend_get_type
        SettingsBackend -> (Ptr SettingsBackend -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr SettingsBackend
o (GType
-> (GValue -> Ptr SettingsBackend -> IO ())
-> Ptr SettingsBackend
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr SettingsBackend -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO SettingsBackend
fromGValue gv :: GValue
gv = do
        Ptr SettingsBackend
ptr <- GValue -> IO (Ptr SettingsBackend)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr SettingsBackend)
        (ManagedPtr SettingsBackend -> SettingsBackend)
-> Ptr SettingsBackend -> IO SettingsBackend
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr SettingsBackend -> SettingsBackend
SettingsBackend Ptr SettingsBackend
ptr
        
    

-- | Type class for types which can be safely cast to `SettingsBackend`, for instance with `toSettingsBackend`.
class (GObject o, O.IsDescendantOf SettingsBackend o) => IsSettingsBackend o
instance (GObject o, O.IsDescendantOf SettingsBackend o) => IsSettingsBackend o

instance O.HasParentTypes SettingsBackend
type instance O.ParentTypes SettingsBackend = '[GObject.Object.Object]

-- | Cast to `SettingsBackend`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toSettingsBackend :: (MonadIO m, IsSettingsBackend o) => o -> m SettingsBackend
toSettingsBackend :: o -> m SettingsBackend
toSettingsBackend = IO SettingsBackend -> m SettingsBackend
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SettingsBackend -> m SettingsBackend)
-> (o -> IO SettingsBackend) -> o -> m SettingsBackend
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr SettingsBackend -> SettingsBackend)
-> o -> IO SettingsBackend
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr SettingsBackend -> SettingsBackend
SettingsBackend

-- | A convenience alias for `Nothing` :: `Maybe` `SettingsBackend`.
noSettingsBackend :: Maybe SettingsBackend
noSettingsBackend :: Maybe SettingsBackend
noSettingsBackend = Maybe SettingsBackend
forall a. Maybe a
Nothing

#if defined(ENABLE_OVERLOADING)
type family ResolveSettingsBackendMethod (t :: Symbol) (o :: *) :: * where
    ResolveSettingsBackendMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveSettingsBackendMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveSettingsBackendMethod "changed" o = SettingsBackendChangedMethodInfo
    ResolveSettingsBackendMethod "changedTree" o = SettingsBackendChangedTreeMethodInfo
    ResolveSettingsBackendMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveSettingsBackendMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveSettingsBackendMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveSettingsBackendMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveSettingsBackendMethod "keysChanged" o = SettingsBackendKeysChangedMethodInfo
    ResolveSettingsBackendMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveSettingsBackendMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveSettingsBackendMethod "pathChanged" o = SettingsBackendPathChangedMethodInfo
    ResolveSettingsBackendMethod "pathWritableChanged" o = SettingsBackendPathWritableChangedMethodInfo
    ResolveSettingsBackendMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveSettingsBackendMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveSettingsBackendMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveSettingsBackendMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveSettingsBackendMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveSettingsBackendMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveSettingsBackendMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveSettingsBackendMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveSettingsBackendMethod "writableChanged" o = SettingsBackendWritableChangedMethodInfo
    ResolveSettingsBackendMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveSettingsBackendMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveSettingsBackendMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveSettingsBackendMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveSettingsBackendMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveSettingsBackendMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveSettingsBackendMethod l o = O.MethodResolutionFailed l o

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

#endif

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

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList SettingsBackend = SettingsBackendSignalList
type SettingsBackendSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method SettingsBackend::changed
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "backend"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SettingsBackend" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSettingsBackend implementation"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "key"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the name of the key"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "origin_tag"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the origin tag" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_settings_backend_changed" g_settings_backend_changed :: 
    Ptr SettingsBackend ->                  -- backend : TInterface (Name {namespace = "Gio", name = "SettingsBackend"})
    CString ->                              -- key : TBasicType TUTF8
    Ptr () ->                               -- origin_tag : TBasicType TPtr
    IO ()

-- | Signals that a single key has possibly changed.  Backend
-- implementations should call this if a key has possibly changed its
-- value.
-- 
-- /@key@/ must be a valid key (ie starting with a slash, not containing
-- \'\/\/\', and not ending with a slash).
-- 
-- The implementation must call this function during any call to
-- @/g_settings_backend_write()/@, before the call returns (except in the
-- case that no keys are actually changed and it cares to detect this
-- fact).  It may not rely on the existence of a mainloop for
-- dispatching the signal later.
-- 
-- The implementation may call this function at any other time it likes
-- in response to other events (such as changes occurring outside of the
-- program).  These calls may originate from a mainloop or may originate
-- in response to any other action (including from calls to
-- @/g_settings_backend_write()/@).
-- 
-- In the case that this call is in response to a call to
-- @/g_settings_backend_write()/@ then /@originTag@/ must be set to the same
-- value that was passed to that call.
-- 
-- /Since: 2.26/
settingsBackendChanged ::
    (B.CallStack.HasCallStack, MonadIO m, IsSettingsBackend a) =>
    a
    -- ^ /@backend@/: a t'GI.Gio.Objects.SettingsBackend.SettingsBackend' implementation
    -> T.Text
    -- ^ /@key@/: the name of the key
    -> Ptr ()
    -- ^ /@originTag@/: the origin tag
    -> m ()
settingsBackendChanged :: a -> Text -> Ptr () -> m ()
settingsBackendChanged backend :: a
backend key :: Text
key originTag :: Ptr ()
originTag = 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 SettingsBackend
backend' <- a -> IO (Ptr SettingsBackend)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
backend
    CString
key' <- Text -> IO CString
textToCString Text
key
    Ptr SettingsBackend -> CString -> Ptr () -> IO ()
g_settings_backend_changed Ptr SettingsBackend
backend' CString
key' Ptr ()
originTag
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
backend
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
key'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data SettingsBackendChangedMethodInfo
instance (signature ~ (T.Text -> Ptr () -> m ()), MonadIO m, IsSettingsBackend a) => O.MethodInfo SettingsBackendChangedMethodInfo a signature where
    overloadedMethod = settingsBackendChanged

#endif

-- method SettingsBackend::changed_tree
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "backend"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SettingsBackend" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSettingsBackend implementation"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "tree"
--           , argType = TInterface Name { namespace = "GLib" , name = "Tree" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTree containing the changes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "origin_tag"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the origin tag" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_settings_backend_changed_tree" g_settings_backend_changed_tree :: 
    Ptr SettingsBackend ->                  -- backend : TInterface (Name {namespace = "Gio", name = "SettingsBackend"})
    Ptr GLib.Tree.Tree ->                   -- tree : TInterface (Name {namespace = "GLib", name = "Tree"})
    Ptr () ->                               -- origin_tag : TBasicType TPtr
    IO ()

-- | This call is a convenience wrapper.  It gets the list of changes from
-- /@tree@/, computes the longest common prefix and calls
-- 'GI.Gio.Objects.SettingsBackend.settingsBackendChanged'.
-- 
-- /Since: 2.26/
settingsBackendChangedTree ::
    (B.CallStack.HasCallStack, MonadIO m, IsSettingsBackend a) =>
    a
    -- ^ /@backend@/: a t'GI.Gio.Objects.SettingsBackend.SettingsBackend' implementation
    -> GLib.Tree.Tree
    -- ^ /@tree@/: a t'GI.GLib.Structs.Tree.Tree' containing the changes
    -> Ptr ()
    -- ^ /@originTag@/: the origin tag
    -> m ()
settingsBackendChangedTree :: a -> Tree -> Ptr () -> m ()
settingsBackendChangedTree backend :: a
backend tree :: Tree
tree originTag :: Ptr ()
originTag = 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 SettingsBackend
backend' <- a -> IO (Ptr SettingsBackend)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
backend
    Ptr Tree
tree' <- Tree -> IO (Ptr Tree)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Tree
tree
    Ptr SettingsBackend -> Ptr Tree -> Ptr () -> IO ()
g_settings_backend_changed_tree Ptr SettingsBackend
backend' Ptr Tree
tree' Ptr ()
originTag
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
backend
    Tree -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Tree
tree
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data SettingsBackendChangedTreeMethodInfo
instance (signature ~ (GLib.Tree.Tree -> Ptr () -> m ()), MonadIO m, IsSettingsBackend a) => O.MethodInfo SettingsBackendChangedTreeMethodInfo a signature where
    overloadedMethod = settingsBackendChangedTree

#endif

-- method SettingsBackend::keys_changed
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "backend"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SettingsBackend" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSettingsBackend implementation"
--                 , 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 containing the changes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "items"
--           , argType = TCArray True (-1) (-1) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the %NULL-terminated list of changed keys"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "origin_tag"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the origin tag" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_settings_backend_keys_changed" g_settings_backend_keys_changed :: 
    Ptr SettingsBackend ->                  -- backend : TInterface (Name {namespace = "Gio", name = "SettingsBackend"})
    CString ->                              -- path : TBasicType TUTF8
    Ptr CString ->                          -- items : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr () ->                               -- origin_tag : TBasicType TPtr
    IO ()

-- | Signals that a list of keys have possibly changed.  Backend
-- implementations should call this if keys have possibly changed their
-- values.
-- 
-- /@path@/ must be a valid path (ie starting and ending with a slash and
-- not containing \'\/\/\').  Each string in /@items@/ must form a valid key
-- name when /@path@/ is prefixed to it (ie: each item must not start or
-- end with \'\/\' and must not contain \'\/\/\').
-- 
-- The meaning of this signal is that any of the key names resulting
-- from the contatenation of /@path@/ with each item in /@items@/ may have
-- changed.
-- 
-- The same rules for when notifications must occur apply as per
-- 'GI.Gio.Objects.SettingsBackend.settingsBackendChanged'.  These two calls can be used
-- interchangeably if exactly one item has changed (although in that
-- case 'GI.Gio.Objects.SettingsBackend.settingsBackendChanged' is definitely preferred).
-- 
-- For efficiency reasons, the implementation should strive for /@path@/ to
-- be as long as possible (ie: the longest common prefix of all of the
-- keys that were changed) but this is not strictly required.
-- 
-- /Since: 2.26/
settingsBackendKeysChanged ::
    (B.CallStack.HasCallStack, MonadIO m, IsSettingsBackend a) =>
    a
    -- ^ /@backend@/: a t'GI.Gio.Objects.SettingsBackend.SettingsBackend' implementation
    -> T.Text
    -- ^ /@path@/: the path containing the changes
    -> [T.Text]
    -- ^ /@items@/: the 'P.Nothing'-terminated list of changed keys
    -> Ptr ()
    -- ^ /@originTag@/: the origin tag
    -> m ()
settingsBackendKeysChanged :: a -> Text -> [Text] -> Ptr () -> m ()
settingsBackendKeysChanged backend :: a
backend path :: Text
path items :: [Text]
items originTag :: Ptr ()
originTag = 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 SettingsBackend
backend' <- a -> IO (Ptr SettingsBackend)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
backend
    CString
path' <- Text -> IO CString
textToCString Text
path
    Ptr CString
items' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
items
    Ptr SettingsBackend -> CString -> Ptr CString -> Ptr () -> IO ()
g_settings_backend_keys_changed Ptr SettingsBackend
backend' CString
path' Ptr CString
items' Ptr ()
originTag
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
backend
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
path'
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
items'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
items'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data SettingsBackendKeysChangedMethodInfo
instance (signature ~ (T.Text -> [T.Text] -> Ptr () -> m ()), MonadIO m, IsSettingsBackend a) => O.MethodInfo SettingsBackendKeysChangedMethodInfo a signature where
    overloadedMethod = settingsBackendKeysChanged

#endif

-- method SettingsBackend::path_changed
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "backend"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SettingsBackend" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSettingsBackend implementation"
--                 , 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 containing the changes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "origin_tag"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the origin tag" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_settings_backend_path_changed" g_settings_backend_path_changed :: 
    Ptr SettingsBackend ->                  -- backend : TInterface (Name {namespace = "Gio", name = "SettingsBackend"})
    CString ->                              -- path : TBasicType TUTF8
    Ptr () ->                               -- origin_tag : TBasicType TPtr
    IO ()

-- | Signals that all keys below a given path may have possibly changed.
-- Backend implementations should call this if an entire path of keys
-- have possibly changed their values.
-- 
-- /@path@/ must be a valid path (ie starting and ending with a slash and
-- not containing \'\/\/\').
-- 
-- The meaning of this signal is that any of the key which has a name
-- starting with /@path@/ may have changed.
-- 
-- The same rules for when notifications must occur apply as per
-- 'GI.Gio.Objects.SettingsBackend.settingsBackendChanged'.  This call might be an appropriate
-- reasponse to a \'reset\' call but implementations are also free to
-- explicitly list the keys that were affected by that call if they can
-- easily do so.
-- 
-- For efficiency reasons, the implementation should strive for /@path@/ to
-- be as long as possible (ie: the longest common prefix of all of the
-- keys that were changed) but this is not strictly required.  As an
-- example, if this function is called with the path of \"\/\" then every
-- single key in the application will be notified of a possible change.
-- 
-- /Since: 2.26/
settingsBackendPathChanged ::
    (B.CallStack.HasCallStack, MonadIO m, IsSettingsBackend a) =>
    a
    -- ^ /@backend@/: a t'GI.Gio.Objects.SettingsBackend.SettingsBackend' implementation
    -> T.Text
    -- ^ /@path@/: the path containing the changes
    -> Ptr ()
    -- ^ /@originTag@/: the origin tag
    -> m ()
settingsBackendPathChanged :: a -> Text -> Ptr () -> m ()
settingsBackendPathChanged backend :: a
backend path :: Text
path originTag :: Ptr ()
originTag = 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 SettingsBackend
backend' <- a -> IO (Ptr SettingsBackend)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
backend
    CString
path' <- Text -> IO CString
textToCString Text
path
    Ptr SettingsBackend -> CString -> Ptr () -> IO ()
g_settings_backend_path_changed Ptr SettingsBackend
backend' CString
path' Ptr ()
originTag
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
backend
    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 SettingsBackendPathChangedMethodInfo
instance (signature ~ (T.Text -> Ptr () -> m ()), MonadIO m, IsSettingsBackend a) => O.MethodInfo SettingsBackendPathChangedMethodInfo a signature where
    overloadedMethod = settingsBackendPathChanged

#endif

-- method SettingsBackend::path_writable_changed
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "backend"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SettingsBackend" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSettingsBackend implementation"
--                 , 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 name of the path"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_settings_backend_path_writable_changed" g_settings_backend_path_writable_changed :: 
    Ptr SettingsBackend ->                  -- backend : TInterface (Name {namespace = "Gio", name = "SettingsBackend"})
    CString ->                              -- path : TBasicType TUTF8
    IO ()

-- | Signals that the writability of all keys below a given path may have
-- changed.
-- 
-- Since GSettings performs no locking operations for itself, this call
-- will always be made in response to external events.
-- 
-- /Since: 2.26/
settingsBackendPathWritableChanged ::
    (B.CallStack.HasCallStack, MonadIO m, IsSettingsBackend a) =>
    a
    -- ^ /@backend@/: a t'GI.Gio.Objects.SettingsBackend.SettingsBackend' implementation
    -> T.Text
    -- ^ /@path@/: the name of the path
    -> m ()
settingsBackendPathWritableChanged :: a -> Text -> m ()
settingsBackendPathWritableChanged backend :: a
backend path :: 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 SettingsBackend
backend' <- a -> IO (Ptr SettingsBackend)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
backend
    CString
path' <- Text -> IO CString
textToCString Text
path
    Ptr SettingsBackend -> CString -> IO ()
g_settings_backend_path_writable_changed Ptr SettingsBackend
backend' CString
path'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
backend
    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 SettingsBackendPathWritableChangedMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsSettingsBackend a) => O.MethodInfo SettingsBackendPathWritableChangedMethodInfo a signature where
    overloadedMethod = settingsBackendPathWritableChanged

#endif

-- method SettingsBackend::writable_changed
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "backend"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SettingsBackend" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSettingsBackend implementation"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "key"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the name of the key"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_settings_backend_writable_changed" g_settings_backend_writable_changed :: 
    Ptr SettingsBackend ->                  -- backend : TInterface (Name {namespace = "Gio", name = "SettingsBackend"})
    CString ->                              -- key : TBasicType TUTF8
    IO ()

-- | Signals that the writability of a single key has possibly changed.
-- 
-- Since GSettings performs no locking operations for itself, this call
-- will always be made in response to external events.
-- 
-- /Since: 2.26/
settingsBackendWritableChanged ::
    (B.CallStack.HasCallStack, MonadIO m, IsSettingsBackend a) =>
    a
    -- ^ /@backend@/: a t'GI.Gio.Objects.SettingsBackend.SettingsBackend' implementation
    -> T.Text
    -- ^ /@key@/: the name of the key
    -> m ()
settingsBackendWritableChanged :: a -> Text -> m ()
settingsBackendWritableChanged backend :: a
backend key :: Text
key = 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 SettingsBackend
backend' <- a -> IO (Ptr SettingsBackend)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
backend
    CString
key' <- Text -> IO CString
textToCString Text
key
    Ptr SettingsBackend -> CString -> IO ()
g_settings_backend_writable_changed Ptr SettingsBackend
backend' CString
key'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
backend
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
key'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data SettingsBackendWritableChangedMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsSettingsBackend a) => O.MethodInfo SettingsBackendWritableChangedMethodInfo a signature where
    overloadedMethod = settingsBackendWritableChanged

#endif

-- XXX Could not generate method SettingsBackend::flatten_tree
-- Error was : Not implemented: "Don't know how to unpack C array of type TCArray True (-1) (-1) TVariant"
#if defined(ENABLE_OVERLOADING)
-- XXX: Dummy instance, since code generation failed.
-- Please file a bug at http://github.com/haskell-gi/haskell-gi.
data SettingsBackendFlattenTreeMethodInfo
instance (p ~ (), o ~ O.UnsupportedMethodError "flattenTree" SettingsBackend) => O.MethodInfo SettingsBackendFlattenTreeMethodInfo o p where
    overloadedMethod = undefined
#endif

-- method SettingsBackend::get_default
-- method type : MemberFunction
-- Args: []
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "Gio" , name = "SettingsBackend" })
-- throws : False
-- Skip return : False

foreign import ccall "g_settings_backend_get_default" g_settings_backend_get_default :: 
    IO (Ptr SettingsBackend)

-- | Returns the default t'GI.Gio.Objects.SettingsBackend.SettingsBackend'. It is possible to override
-- the default by setting the @GSETTINGS_BACKEND@ environment variable
-- to the name of a settings backend.
-- 
-- The user gets a reference to the backend.
-- 
-- /Since: 2.28/
settingsBackendGetDefault ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m SettingsBackend
    -- ^ __Returns:__ the default t'GI.Gio.Objects.SettingsBackend.SettingsBackend'
settingsBackendGetDefault :: m SettingsBackend
settingsBackendGetDefault  = IO SettingsBackend -> m SettingsBackend
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SettingsBackend -> m SettingsBackend)
-> IO SettingsBackend -> m SettingsBackend
forall a b. (a -> b) -> a -> b
$ do
    Ptr SettingsBackend
result <- IO (Ptr SettingsBackend)
g_settings_backend_get_default
    Text -> Ptr SettingsBackend -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "settingsBackendGetDefault" Ptr SettingsBackend
result
    SettingsBackend
result' <- ((ManagedPtr SettingsBackend -> SettingsBackend)
-> Ptr SettingsBackend -> IO SettingsBackend
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr SettingsBackend -> SettingsBackend
SettingsBackend) Ptr SettingsBackend
result
    SettingsBackend -> IO SettingsBackend
forall (m :: * -> *) a. Monad m => a -> m a
return SettingsBackend
result'

#if defined(ENABLE_OVERLOADING)
#endif