{-# 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.GObject.Structs.SignalInvocationHint.SignalInvocationHint' structure is used to pass on additional information
-- to callbacks during a signal emission.

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

module GI.GObject.Structs.SignalInvocationHint
    ( 

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


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

#if defined(ENABLE_OVERLOADING)
    ResolveSignalInvocationHintMethod       ,
#endif




 -- * Properties
-- ** detail #attr:detail#
-- | The detail passed on for this emission

    getSignalInvocationHintDetail           ,
    setSignalInvocationHintDetail           ,
#if defined(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 defined(ENABLE_OVERLOADING)
    signalInvocationHint_runType            ,
#endif


-- ** signalId #attr:signalId#
-- | The signal id of the signal invoking the callback

    getSignalInvocationHintSignalId         ,
    setSignalInvocationHintSignalId         ,
#if defined(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.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 {-# SOURCE #-} qualified GI.GObject.Flags as GObject.Flags

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

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

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


-- | A convenience alias for `Nothing` :: `Maybe` `SignalInvocationHint`.
noSignalInvocationHint :: Maybe SignalInvocationHint
noSignalInvocationHint :: Maybe SignalInvocationHint
noSignalInvocationHint = Maybe SignalInvocationHint
forall a. Maybe a
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 :: SignalInvocationHint -> m Word32
getSignalInvocationHintSignalId s :: SignalInvocationHint
s = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ SignalInvocationHint
-> (Ptr SignalInvocationHint -> IO Word32) -> IO Word32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr SignalInvocationHint
s ((Ptr SignalInvocationHint -> IO Word32) -> IO Word32)
-> (Ptr SignalInvocationHint -> IO Word32) -> IO Word32
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr SignalInvocationHint
ptr -> do
    Word32
val <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek (Ptr SignalInvocationHint
ptr Ptr SignalInvocationHint -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) :: IO Word32
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: SignalInvocationHint -> Word32 -> m ()
setSignalInvocationHintSignalId s :: SignalInvocationHint
s val :: Word32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ SignalInvocationHint
-> (Ptr SignalInvocationHint -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr SignalInvocationHint
s ((Ptr SignalInvocationHint -> IO ()) -> IO ())
-> (Ptr SignalInvocationHint -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr SignalInvocationHint
ptr -> do
    Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr SignalInvocationHint
ptr Ptr SignalInvocationHint -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) (Word32
val :: Word32)

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

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 :: SignalInvocationHint -> m Word32
getSignalInvocationHintDetail s :: SignalInvocationHint
s = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ SignalInvocationHint
-> (Ptr SignalInvocationHint -> IO Word32) -> IO Word32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr SignalInvocationHint
s ((Ptr SignalInvocationHint -> IO Word32) -> IO Word32)
-> (Ptr SignalInvocationHint -> IO Word32) -> IO Word32
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr SignalInvocationHint
ptr -> do
    Word32
val <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek (Ptr SignalInvocationHint
ptr Ptr SignalInvocationHint -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4) :: IO Word32
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: SignalInvocationHint -> Word32 -> m ()
setSignalInvocationHintDetail s :: SignalInvocationHint
s val :: Word32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ SignalInvocationHint
-> (Ptr SignalInvocationHint -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr SignalInvocationHint
s ((Ptr SignalInvocationHint -> IO ()) -> IO ())
-> (Ptr SignalInvocationHint -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr SignalInvocationHint
ptr -> do
    Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr SignalInvocationHint
ptr Ptr SignalInvocationHint -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4) (Word32
val :: Word32)

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

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 :: SignalInvocationHint -> m [SignalFlags]
getSignalInvocationHintRunType s :: SignalInvocationHint
s = IO [SignalFlags] -> m [SignalFlags]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [SignalFlags] -> m [SignalFlags])
-> IO [SignalFlags] -> m [SignalFlags]
forall a b. (a -> b) -> a -> b
$ SignalInvocationHint
-> (Ptr SignalInvocationHint -> IO [SignalFlags])
-> IO [SignalFlags]
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr SignalInvocationHint
s ((Ptr SignalInvocationHint -> IO [SignalFlags])
 -> IO [SignalFlags])
-> (Ptr SignalInvocationHint -> IO [SignalFlags])
-> IO [SignalFlags]
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr SignalInvocationHint
ptr -> do
    CUInt
val <- Ptr CUInt -> IO CUInt
forall a. Storable a => Ptr a -> IO a
peek (Ptr SignalInvocationHint
ptr Ptr SignalInvocationHint -> Int -> Ptr CUInt
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8) :: IO CUInt
    let val' :: [SignalFlags]
val' = CUInt -> [SignalFlags]
forall a b. (Storable a, Integral a, Bits a, IsGFlag b) => a -> [b]
wordToGFlags CUInt
val
    [SignalFlags] -> IO [SignalFlags]
forall (m :: * -> *) a. Monad m => a -> m a
return [SignalFlags]
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 :: SignalInvocationHint -> [SignalFlags] -> m ()
setSignalInvocationHintRunType s :: SignalInvocationHint
s val :: [SignalFlags]
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ SignalInvocationHint
-> (Ptr SignalInvocationHint -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr SignalInvocationHint
s ((Ptr SignalInvocationHint -> IO ()) -> IO ())
-> (Ptr SignalInvocationHint -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr SignalInvocationHint
ptr -> do
    let val' :: CUInt
val' = [SignalFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [SignalFlags]
val
    Ptr CUInt -> CUInt -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr SignalInvocationHint
ptr Ptr SignalInvocationHint -> Int -> Ptr CUInt
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8) (CUInt
val' :: CUInt)

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

signalInvocationHint_runType :: AttrLabelProxy "runType"
signalInvocationHint_runType = AttrLabelProxy

#endif



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

#if defined(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) => OL.IsLabel t (SignalInvocationHint -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif