{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

The 'GI.GObject.Structs.SignalInvocationHint.SignalInvocationHint' structure is used to pass on additional information
to callbacks during a signal emission.
-}

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

module GI.GObject.Structs.SignalInvocationHint
    (

-- * Exported types
    SignalInvocationHint(..)                ,
    newZeroSignalInvocationHint             ,
    noSignalInvocationHint                  ,


 -- * Properties
-- ** detail #attr:detail#
{- | The detail passed on for this emission
-}
    getSignalInvocationHintDetail           ,
    setSignalInvocationHintDetail           ,
#if ENABLE_OVERLOADING
    signalInvocationHint_detail             ,
#endif


-- ** runType #attr:runType#
{- | The stage the signal emission is currently in, this
 field will contain one of 'GI.GObject.Flags.SignalFlagsRunFirst',
 'GI.GObject.Flags.SignalFlagsRunLast' or 'GI.GObject.Flags.SignalFlagsRunCleanup'.
-}
    getSignalInvocationHintRunType          ,
    setSignalInvocationHintRunType          ,
#if ENABLE_OVERLOADING
    signalInvocationHint_runType            ,
#endif


-- ** signalId #attr:signalId#
{- | The signal id of the signal invoking the callback
-}
    getSignalInvocationHintSignalId         ,
    setSignalInvocationHintSignalId         ,
#if ENABLE_OVERLOADING
    signalInvocationHint_signalId           ,
#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.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import {-# SOURCE #-} qualified GI.GObject.Flags as GObject.Flags

-- | Memory-managed wrapper type.
newtype SignalInvocationHint = SignalInvocationHint (ManagedPtr SignalInvocationHint)
instance WrappedPtr SignalInvocationHint where
    wrappedPtrCalloc = callocBytes 12
    wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 12 >=> wrapPtr SignalInvocationHint)
    wrappedPtrFree = Just ptr_to_g_free

-- | Construct a `SignalInvocationHint` struct initialized to zero.
newZeroSignalInvocationHint :: MonadIO m => m SignalInvocationHint
newZeroSignalInvocationHint = liftIO $ wrappedPtrCalloc >>= wrapPtr SignalInvocationHint

instance tag ~ 'AttrSet => Constructible SignalInvocationHint tag where
    new _ attrs = do
        o <- newZeroSignalInvocationHint
        GI.Attributes.set o attrs
        return o


-- | A convenience alias for `Nothing` :: `Maybe` `SignalInvocationHint`.
noSignalInvocationHint :: Maybe SignalInvocationHint
noSignalInvocationHint = Nothing

{- |
Get the value of the “@signal_id@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' signalInvocationHint #signalId
@
-}
getSignalInvocationHintSignalId :: MonadIO m => SignalInvocationHint -> m Word32
getSignalInvocationHintSignalId s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Word32
    return val

{- |
Set the value of the “@signal_id@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' signalInvocationHint [ #signalId 'Data.GI.Base.Attributes.:=' value ]
@
-}
setSignalInvocationHintSignalId :: MonadIO m => SignalInvocationHint -> Word32 -> m ()
setSignalInvocationHintSignalId s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 0) (val :: Word32)

#if ENABLE_OVERLOADING
data SignalInvocationHintSignalIdFieldInfo
instance AttrInfo SignalInvocationHintSignalIdFieldInfo where
    type AttrAllowedOps SignalInvocationHintSignalIdFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint SignalInvocationHintSignalIdFieldInfo = (~) Word32
    type AttrBaseTypeConstraint SignalInvocationHintSignalIdFieldInfo = (~) SignalInvocationHint
    type AttrGetType SignalInvocationHintSignalIdFieldInfo = Word32
    type AttrLabel SignalInvocationHintSignalIdFieldInfo = "signal_id"
    type AttrOrigin SignalInvocationHintSignalIdFieldInfo = SignalInvocationHint
    attrGet _ = getSignalInvocationHintSignalId
    attrSet _ = setSignalInvocationHintSignalId
    attrConstruct = undefined
    attrClear _ = undefined

signalInvocationHint_signalId :: AttrLabelProxy "signalId"
signalInvocationHint_signalId = AttrLabelProxy

#endif


{- |
Get the value of the “@detail@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' signalInvocationHint #detail
@
-}
getSignalInvocationHintDetail :: MonadIO m => SignalInvocationHint -> m Word32
getSignalInvocationHintDetail s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 4) :: IO Word32
    return val

{- |
Set the value of the “@detail@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' signalInvocationHint [ #detail 'Data.GI.Base.Attributes.:=' value ]
@
-}
setSignalInvocationHintDetail :: MonadIO m => SignalInvocationHint -> Word32 -> m ()
setSignalInvocationHintDetail s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 4) (val :: Word32)

#if ENABLE_OVERLOADING
data SignalInvocationHintDetailFieldInfo
instance AttrInfo SignalInvocationHintDetailFieldInfo where
    type AttrAllowedOps SignalInvocationHintDetailFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint SignalInvocationHintDetailFieldInfo = (~) Word32
    type AttrBaseTypeConstraint SignalInvocationHintDetailFieldInfo = (~) SignalInvocationHint
    type AttrGetType SignalInvocationHintDetailFieldInfo = Word32
    type AttrLabel SignalInvocationHintDetailFieldInfo = "detail"
    type AttrOrigin SignalInvocationHintDetailFieldInfo = SignalInvocationHint
    attrGet _ = getSignalInvocationHintDetail
    attrSet _ = setSignalInvocationHintDetail
    attrConstruct = undefined
    attrClear _ = undefined

signalInvocationHint_detail :: AttrLabelProxy "detail"
signalInvocationHint_detail = AttrLabelProxy

#endif


{- |
Get the value of the “@run_type@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' signalInvocationHint #runType
@
-}
getSignalInvocationHintRunType :: MonadIO m => SignalInvocationHint -> m [GObject.Flags.SignalFlags]
getSignalInvocationHintRunType s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO CUInt
    let val' = wordToGFlags val
    return val'

{- |
Set the value of the “@run_type@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' signalInvocationHint [ #runType 'Data.GI.Base.Attributes.:=' value ]
@
-}
setSignalInvocationHintRunType :: MonadIO m => SignalInvocationHint -> [GObject.Flags.SignalFlags] -> m ()
setSignalInvocationHintRunType s val = liftIO $ withManagedPtr s $ \ptr -> do
    let val' = gflagsToWord val
    poke (ptr `plusPtr` 8) (val' :: CUInt)

#if ENABLE_OVERLOADING
data SignalInvocationHintRunTypeFieldInfo
instance AttrInfo SignalInvocationHintRunTypeFieldInfo where
    type AttrAllowedOps SignalInvocationHintRunTypeFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint SignalInvocationHintRunTypeFieldInfo = (~) [GObject.Flags.SignalFlags]
    type AttrBaseTypeConstraint SignalInvocationHintRunTypeFieldInfo = (~) SignalInvocationHint
    type AttrGetType SignalInvocationHintRunTypeFieldInfo = [GObject.Flags.SignalFlags]
    type AttrLabel SignalInvocationHintRunTypeFieldInfo = "run_type"
    type AttrOrigin SignalInvocationHintRunTypeFieldInfo = SignalInvocationHint
    attrGet _ = getSignalInvocationHintRunType
    attrSet _ = setSignalInvocationHintRunType
    attrConstruct = undefined
    attrClear _ = undefined

signalInvocationHint_runType :: AttrLabelProxy "runType"
signalInvocationHint_runType = AttrLabelProxy

#endif



#if ENABLE_OVERLOADING
instance O.HasAttributeList SignalInvocationHint
type instance O.AttributeList SignalInvocationHint = SignalInvocationHintAttributeList
type SignalInvocationHintAttributeList = ('[ '("signalId", SignalInvocationHintSignalIdFieldInfo), '("detail", SignalInvocationHintDetailFieldInfo), '("runType", SignalInvocationHintRunTypeFieldInfo)] :: [(Symbol, *)])
#endif

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

instance (info ~ ResolveSignalInvocationHintMethod t SignalInvocationHint, O.MethodInfo info SignalInvocationHint p) => O.IsLabelProxy t (SignalInvocationHint -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveSignalInvocationHintMethod t SignalInvocationHint, O.MethodInfo info SignalInvocationHint p) => O.IsLabel t (SignalInvocationHint -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif