{- |
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.Unions.Action
    ( 

-- * Exported types
    Action(..)                              ,
    noAction                                ,


 -- * Methods
-- ** actionCopy
    actionCopy                              ,


-- ** actionFree
    actionFree                              ,




 -- * Properties
-- ** Any
    actionReadAny                           ,


-- ** GotoDest
    actionReadGotoDest                      ,


-- ** GotoRemote
    actionReadGotoRemote                    ,


-- ** Javascript
    actionReadJavascript                    ,


-- ** Launch
    actionReadLaunch                        ,


-- ** Movie
    actionReadMovie                         ,


-- ** Named
    actionReadNamed                         ,


-- ** OcgState
    actionReadOcgState                      ,


-- ** Rendition
    actionReadRendition                     ,


-- ** Type
    actionReadType                          ,


-- ** Uri
    actionReadUri                           ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Poppler.Types
import GI.Poppler.Callbacks

newtype Action = Action (ForeignPtr Action)
foreign import ccall "poppler_action_get_type" c_poppler_action_get_type :: 
    IO GType

instance BoxedObject Action where
    boxedType _ = c_poppler_action_get_type

noAction :: Maybe Action
noAction = Nothing

actionReadType :: Action -> IO ActionType
actionReadType s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO CUInt
    let val' = (toEnum . fromIntegral) val
    return val'

actionReadAny :: Action -> IO ActionAny
actionReadAny s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr ActionAny)
    val' <- (newPtr 16 ActionAny) val
    return val'

actionReadGotoDest :: Action -> IO ActionGotoDest
actionReadGotoDest s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr ActionGotoDest)
    val' <- (newPtr 24 ActionGotoDest) val
    return val'

actionReadGotoRemote :: Action -> IO ActionGotoRemote
actionReadGotoRemote s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr ActionGotoRemote)
    val' <- (newPtr 32 ActionGotoRemote) val
    return val'

actionReadLaunch :: Action -> IO ActionLaunch
actionReadLaunch s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr ActionLaunch)
    val' <- (newPtr 32 ActionLaunch) val
    return val'

actionReadUri :: Action -> IO ActionUri
actionReadUri s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr ActionUri)
    val' <- (newPtr 24 ActionUri) val
    return val'

actionReadNamed :: Action -> IO ActionNamed
actionReadNamed s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr ActionNamed)
    val' <- (newPtr 24 ActionNamed) val
    return val'

actionReadMovie :: Action -> IO ActionMovie
actionReadMovie s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr ActionMovie)
    val' <- (newPtr 32 ActionMovie) val
    return val'

actionReadRendition :: Action -> IO ActionRendition
actionReadRendition s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr ActionRendition)
    val' <- (newPtr 32 ActionRendition) val
    return val'

actionReadOcgState :: Action -> IO ActionOCGState
actionReadOcgState s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr ActionOCGState)
    val' <- (newPtr 24 ActionOCGState) val
    return val'

actionReadJavascript :: Action -> IO ActionJavascript
actionReadJavascript s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr ActionJavascript)
    val' <- (newPtr 24 ActionJavascript) val
    return val'

-- method Action::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "Action", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Poppler" "Action", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Poppler" "Action"
-- throws : False
-- Skip return : False

foreign import ccall "poppler_action_copy" poppler_action_copy :: 
    Ptr Action ->                           -- _obj : TInterface "Poppler" "Action"
    IO (Ptr Action)


actionCopy ::
    (MonadIO m) =>
    Action ->                               -- _obj
    m Action
actionCopy _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- poppler_action_copy _obj'
    checkUnexpectedReturnNULL "poppler_action_copy" result
    result' <- (wrapBoxed Action) result
    touchManagedPtr _obj
    return result'

-- method Action::free
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "Action", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Poppler" "Action", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "poppler_action_free" poppler_action_free :: 
    Ptr Action ->                           -- _obj : TInterface "Poppler" "Action"
    IO ()


actionFree ::
    (MonadIO m) =>
    Action ->                               -- _obj
    m ()
actionFree _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    poppler_action_free _obj'
    touchManagedPtr _obj
    return ()