{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- /No description available in the introspection data./

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

module GI.Gtk.Structs.SettingsValue
    ( 

-- * Exported types
    SettingsValue(..)                       ,
    newZeroSettingsValue                    ,
    noSettingsValue                         ,


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

#if defined(ENABLE_OVERLOADING)
    ResolveSettingsValueMethod              ,
#endif




 -- * Properties
-- ** origin #attr:origin#
-- | Origin should be something like “filename:linenumber” for
--    rc files, or e.g. “XProperty” for other sources.

    clearSettingsValueOrigin                ,
    getSettingsValueOrigin                  ,
    setSettingsValueOrigin                  ,
#if defined(ENABLE_OVERLOADING)
    settingsValue_origin                    ,
#endif


-- ** value #attr:value#
-- | Valid types are LONG, DOUBLE and STRING corresponding to
--    the token parsed, or a GSTRING holding an unparsed statement

    getSettingsValueValue                   ,
#if defined(ENABLE_OVERLOADING)
    settingsValue_value                     ,
#endif




    ) 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


-- | Memory-managed wrapper type.
newtype SettingsValue = SettingsValue (ManagedPtr SettingsValue)
    deriving (SettingsValue -> SettingsValue -> Bool
(SettingsValue -> SettingsValue -> Bool)
-> (SettingsValue -> SettingsValue -> Bool) -> Eq SettingsValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SettingsValue -> SettingsValue -> Bool
$c/= :: SettingsValue -> SettingsValue -> Bool
== :: SettingsValue -> SettingsValue -> Bool
$c== :: SettingsValue -> SettingsValue -> Bool
Eq)
instance WrappedPtr SettingsValue where
    wrappedPtrCalloc :: IO (Ptr SettingsValue)
wrappedPtrCalloc = Int -> IO (Ptr SettingsValue)
forall a. Int -> IO (Ptr a)
callocBytes 32
    wrappedPtrCopy :: SettingsValue -> IO SettingsValue
wrappedPtrCopy = \p :: SettingsValue
p -> SettingsValue
-> (Ptr SettingsValue -> IO SettingsValue) -> IO SettingsValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr SettingsValue
p (Int -> Ptr SettingsValue -> IO (Ptr SettingsValue)
forall a. WrappedPtr a => Int -> Ptr a -> IO (Ptr a)
copyBytes 32 (Ptr SettingsValue -> IO (Ptr SettingsValue))
-> (Ptr SettingsValue -> IO SettingsValue)
-> Ptr SettingsValue
-> IO SettingsValue
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr SettingsValue -> SettingsValue)
-> Ptr SettingsValue -> IO SettingsValue
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr SettingsValue -> SettingsValue
SettingsValue)
    wrappedPtrFree :: Maybe (GDestroyNotify SettingsValue)
wrappedPtrFree = GDestroyNotify SettingsValue
-> Maybe (GDestroyNotify SettingsValue)
forall a. a -> Maybe a
Just GDestroyNotify SettingsValue
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free

-- | Construct a `SettingsValue` struct initialized to zero.
newZeroSettingsValue :: MonadIO m => m SettingsValue
newZeroSettingsValue :: m SettingsValue
newZeroSettingsValue = IO SettingsValue -> m SettingsValue
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SettingsValue -> m SettingsValue)
-> IO SettingsValue -> m SettingsValue
forall a b. (a -> b) -> a -> b
$ IO (Ptr SettingsValue)
forall a. WrappedPtr a => IO (Ptr a)
wrappedPtrCalloc IO (Ptr SettingsValue)
-> (Ptr SettingsValue -> IO SettingsValue) -> IO SettingsValue
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr SettingsValue -> SettingsValue)
-> Ptr SettingsValue -> IO SettingsValue
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr SettingsValue -> SettingsValue
SettingsValue

instance tag ~ 'AttrSet => Constructible SettingsValue tag where
    new :: (ManagedPtr SettingsValue -> SettingsValue)
-> [AttrOp SettingsValue tag] -> m SettingsValue
new _ attrs :: [AttrOp SettingsValue tag]
attrs = do
        SettingsValue
o <- m SettingsValue
forall (m :: * -> *). MonadIO m => m SettingsValue
newZeroSettingsValue
        SettingsValue -> [AttrOp SettingsValue 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set SettingsValue
o [AttrOp SettingsValue tag]
[AttrOp SettingsValue 'AttrSet]
attrs
        SettingsValue -> m SettingsValue
forall (m :: * -> *) a. Monad m => a -> m a
return SettingsValue
o


-- | A convenience alias for `Nothing` :: `Maybe` `SettingsValue`.
noSettingsValue :: Maybe SettingsValue
noSettingsValue :: Maybe SettingsValue
noSettingsValue = Maybe SettingsValue
forall a. Maybe a
Nothing

-- | Get the value of the “@origin@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' settingsValue #origin
-- @
getSettingsValueOrigin :: MonadIO m => SettingsValue -> m (Maybe T.Text)
getSettingsValueOrigin :: SettingsValue -> m (Maybe Text)
getSettingsValueOrigin s :: SettingsValue
s = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ SettingsValue
-> (Ptr SettingsValue -> IO (Maybe Text)) -> IO (Maybe Text)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr SettingsValue
s ((Ptr SettingsValue -> IO (Maybe Text)) -> IO (Maybe Text))
-> (Ptr SettingsValue -> IO (Maybe Text)) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr SettingsValue
ptr -> do
    CString
val <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek (Ptr SettingsValue
ptr Ptr SettingsValue -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) :: IO CString
    Maybe Text
result <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
SP.convertIfNonNull CString
val ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \val' :: CString
val' -> do
        Text
val'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
val'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
val''
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
result

-- | Set the value of the “@origin@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' settingsValue [ #origin 'Data.GI.Base.Attributes.:=' value ]
-- @
setSettingsValueOrigin :: MonadIO m => SettingsValue -> CString -> m ()
setSettingsValueOrigin :: SettingsValue -> CString -> m ()
setSettingsValueOrigin s :: SettingsValue
s val :: CString
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ SettingsValue -> (Ptr SettingsValue -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr SettingsValue
s ((Ptr SettingsValue -> IO ()) -> IO ())
-> (Ptr SettingsValue -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr SettingsValue
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr SettingsValue
ptr Ptr SettingsValue -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) (CString
val :: CString)

-- | Set the value of the “@origin@” field to `Nothing`.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.clear' #origin
-- @
clearSettingsValueOrigin :: MonadIO m => SettingsValue -> m ()
clearSettingsValueOrigin :: SettingsValue -> m ()
clearSettingsValueOrigin s :: SettingsValue
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ SettingsValue -> (Ptr SettingsValue -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr SettingsValue
s ((Ptr SettingsValue -> IO ()) -> IO ())
-> (Ptr SettingsValue -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr SettingsValue
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr SettingsValue
ptr Ptr SettingsValue -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) (CString
forall a. Ptr a
FP.nullPtr :: CString)

#if defined(ENABLE_OVERLOADING)
data SettingsValueOriginFieldInfo
instance AttrInfo SettingsValueOriginFieldInfo where
    type AttrBaseTypeConstraint SettingsValueOriginFieldInfo = (~) SettingsValue
    type AttrAllowedOps SettingsValueOriginFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint SettingsValueOriginFieldInfo = (~) CString
    type AttrTransferTypeConstraint SettingsValueOriginFieldInfo = (~)CString
    type AttrTransferType SettingsValueOriginFieldInfo = CString
    type AttrGetType SettingsValueOriginFieldInfo = Maybe T.Text
    type AttrLabel SettingsValueOriginFieldInfo = "origin"
    type AttrOrigin SettingsValueOriginFieldInfo = SettingsValue
    attrGet = getSettingsValueOrigin
    attrSet = setSettingsValueOrigin
    attrConstruct = undefined
    attrClear = clearSettingsValueOrigin
    attrTransfer _ v = do
        return v

settingsValue_origin :: AttrLabelProxy "origin"
settingsValue_origin = AttrLabelProxy

#endif


-- | Get the value of the “@value@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' settingsValue #value
-- @
getSettingsValueValue :: MonadIO m => SettingsValue -> m GValue
getSettingsValueValue :: SettingsValue -> m GValue
getSettingsValueValue s :: SettingsValue
s = IO GValue -> m GValue
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GValue -> m GValue) -> IO GValue -> m GValue
forall a b. (a -> b) -> a -> b
$ SettingsValue -> (Ptr SettingsValue -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr SettingsValue
s ((Ptr SettingsValue -> IO GValue) -> IO GValue)
-> (Ptr SettingsValue -> IO GValue) -> IO GValue
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr SettingsValue
ptr -> do
    let val :: Ptr GValue
val = Ptr SettingsValue
ptr Ptr SettingsValue -> Int -> Ptr GValue
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: (Ptr GValue)
    GValue
val' <- ((ManagedPtr GValue -> GValue) -> Ptr GValue -> IO GValue
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr GValue -> GValue
GValue) Ptr GValue
val
    GValue -> IO GValue
forall (m :: * -> *) a. Monad m => a -> m a
return GValue
val'

#if defined(ENABLE_OVERLOADING)
data SettingsValueValueFieldInfo
instance AttrInfo SettingsValueValueFieldInfo where
    type AttrBaseTypeConstraint SettingsValueValueFieldInfo = (~) SettingsValue
    type AttrAllowedOps SettingsValueValueFieldInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint SettingsValueValueFieldInfo = (~) (Ptr GValue)
    type AttrTransferTypeConstraint SettingsValueValueFieldInfo = (~)(Ptr GValue)
    type AttrTransferType SettingsValueValueFieldInfo = (Ptr GValue)
    type AttrGetType SettingsValueValueFieldInfo = GValue
    type AttrLabel SettingsValueValueFieldInfo = "value"
    type AttrOrigin SettingsValueValueFieldInfo = SettingsValue
    attrGet = getSettingsValueValue
    attrSet = undefined
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer = undefined

settingsValue_value :: AttrLabelProxy "value"
settingsValue_value = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList SettingsValue
type instance O.AttributeList SettingsValue = SettingsValueAttributeList
type SettingsValueAttributeList = ('[ '("origin", SettingsValueOriginFieldInfo), '("value", SettingsValueValueFieldInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveSettingsValueMethod (t :: Symbol) (o :: *) :: * where
    ResolveSettingsValueMethod l o = O.MethodResolutionFailed l o

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

#endif