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

module GI.Poppler.Structs.ActionGotoDest
    ( 

-- * Exported types
    ActionGotoDest(..)                      ,
    newZeroActionGotoDest                   ,
    noActionGotoDest                        ,


 -- * Properties
-- ** dest #attr:dest#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    actionGotoDest_dest                     ,
#endif
    clearActionGotoDestDest                 ,
    getActionGotoDestDest                   ,
    setActionGotoDestDest                   ,


-- ** title #attr:title#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    actionGotoDest_title                    ,
#endif
    clearActionGotoDestTitle                ,
    getActionGotoDestTitle                  ,
    setActionGotoDestTitle                  ,


-- ** type #attr:type#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    actionGotoDest_type                     ,
#endif
    getActionGotoDestType                   ,
    setActionGotoDestType                   ,




    ) 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.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.Poppler.Enums as Poppler.Enums
import {-# SOURCE #-} qualified GI.Poppler.Structs.Dest as Poppler.Dest

newtype ActionGotoDest = ActionGotoDest (ManagedPtr ActionGotoDest)
instance WrappedPtr ActionGotoDest where
    wrappedPtrCalloc = callocBytes 24
    wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 24 >=> wrapPtr ActionGotoDest)
    wrappedPtrFree = Just ptr_to_g_free

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

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


noActionGotoDest :: Maybe ActionGotoDest
noActionGotoDest = Nothing

getActionGotoDestType :: MonadIO m => ActionGotoDest -> m Poppler.Enums.ActionType
getActionGotoDestType s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO CUInt
    let val' = (toEnum . fromIntegral) val
    return val'

setActionGotoDestType :: MonadIO m => ActionGotoDest -> Poppler.Enums.ActionType -> m ()
setActionGotoDestType s val = liftIO $ withManagedPtr s $ \ptr -> do
    let val' = (fromIntegral . fromEnum) val
    poke (ptr `plusPtr` 0) (val' :: CUInt)

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data ActionGotoDestTypeFieldInfo
instance AttrInfo ActionGotoDestTypeFieldInfo where
    type AttrAllowedOps ActionGotoDestTypeFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint ActionGotoDestTypeFieldInfo = (~) Poppler.Enums.ActionType
    type AttrBaseTypeConstraint ActionGotoDestTypeFieldInfo = (~) ActionGotoDest
    type AttrGetType ActionGotoDestTypeFieldInfo = Poppler.Enums.ActionType
    type AttrLabel ActionGotoDestTypeFieldInfo = "type"
    type AttrOrigin ActionGotoDestTypeFieldInfo = ActionGotoDest
    attrGet _ = getActionGotoDestType
    attrSet _ = setActionGotoDestType
    attrConstruct = undefined
    attrClear _ = undefined

actionGotoDest_type :: AttrLabelProxy "type"
actionGotoDest_type = AttrLabelProxy

#endif


getActionGotoDestTitle :: MonadIO m => ActionGotoDest -> m (Maybe T.Text)
getActionGotoDestTitle s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO CString
    result <- SP.convertIfNonNull val $ \val' -> do
        val'' <- cstringToText val'
        return val''
    return result

setActionGotoDestTitle :: MonadIO m => ActionGotoDest -> CString -> m ()
setActionGotoDestTitle s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (val :: CString)

clearActionGotoDestTitle :: MonadIO m => ActionGotoDest -> m ()
clearActionGotoDestTitle s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (FP.nullPtr :: CString)

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data ActionGotoDestTitleFieldInfo
instance AttrInfo ActionGotoDestTitleFieldInfo where
    type AttrAllowedOps ActionGotoDestTitleFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint ActionGotoDestTitleFieldInfo = (~) CString
    type AttrBaseTypeConstraint ActionGotoDestTitleFieldInfo = (~) ActionGotoDest
    type AttrGetType ActionGotoDestTitleFieldInfo = Maybe T.Text
    type AttrLabel ActionGotoDestTitleFieldInfo = "title"
    type AttrOrigin ActionGotoDestTitleFieldInfo = ActionGotoDest
    attrGet _ = getActionGotoDestTitle
    attrSet _ = setActionGotoDestTitle
    attrConstruct = undefined
    attrClear _ = clearActionGotoDestTitle

actionGotoDest_title :: AttrLabelProxy "title"
actionGotoDest_title = AttrLabelProxy

#endif


getActionGotoDestDest :: MonadIO m => ActionGotoDest -> m (Maybe Poppler.Dest.Dest)
getActionGotoDestDest s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO (Ptr Poppler.Dest.Dest)
    result <- SP.convertIfNonNull val $ \val' -> do
        val'' <- (newBoxed Poppler.Dest.Dest) val'
        return val''
    return result

setActionGotoDestDest :: MonadIO m => ActionGotoDest -> Ptr Poppler.Dest.Dest -> m ()
setActionGotoDestDest s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 16) (val :: Ptr Poppler.Dest.Dest)

clearActionGotoDestDest :: MonadIO m => ActionGotoDest -> m ()
clearActionGotoDestDest s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 16) (FP.nullPtr :: Ptr Poppler.Dest.Dest)

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data ActionGotoDestDestFieldInfo
instance AttrInfo ActionGotoDestDestFieldInfo where
    type AttrAllowedOps ActionGotoDestDestFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint ActionGotoDestDestFieldInfo = (~) (Ptr Poppler.Dest.Dest)
    type AttrBaseTypeConstraint ActionGotoDestDestFieldInfo = (~) ActionGotoDest
    type AttrGetType ActionGotoDestDestFieldInfo = Maybe Poppler.Dest.Dest
    type AttrLabel ActionGotoDestDestFieldInfo = "dest"
    type AttrOrigin ActionGotoDestDestFieldInfo = ActionGotoDest
    attrGet _ = getActionGotoDestDest
    attrSet _ = setActionGotoDestDest
    attrConstruct = undefined
    attrClear _ = clearActionGotoDestDest

actionGotoDest_dest :: AttrLabelProxy "dest"
actionGotoDest_dest = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
instance O.HasAttributeList ActionGotoDest
type instance O.AttributeList ActionGotoDest = ActionGotoDestAttributeList
type ActionGotoDestAttributeList = ('[ '("type", ActionGotoDestTypeFieldInfo), '("title", ActionGotoDestTitleFieldInfo), '("dest", ActionGotoDestDestFieldInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveActionGotoDestMethod (t :: Symbol) (o :: *) :: * where
    ResolveActionGotoDestMethod l o = O.MethodResolutionFailed l o

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

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveActionGotoDestMethod t ActionGotoDest, O.MethodInfo info ActionGotoDest p) => O.IsLabel t (ActionGotoDest -> 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