packages feed

gi-poppler-0.0.34.13: GI/Poppler/Structs/ActionNamed.hs


{- |
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.ActionNamed
    ( 

-- * Exported types
    ActionNamed(..)                         ,
    newZeroActionNamed                      ,
    noActionNamed                           ,


 -- * Properties
-- ** NamedDest
    actionNamedReadNamedDest                ,


-- ** Title
    actionNamedReadTitle                    ,


-- ** Type
    actionNamedReadType                     ,




    ) 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 ActionNamed = ActionNamed (ForeignPtr ActionNamed)
-- | Construct a `ActionNamed` struct initialized to zero.
newZeroActionNamed :: MonadIO m => m ActionNamed
newZeroActionNamed = liftIO $ callocBytes 24 >>= wrapPtr ActionNamed

noActionNamed :: Maybe ActionNamed
noActionNamed = Nothing

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

actionNamedReadTitle :: ActionNamed -> IO T.Text
actionNamedReadTitle s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO CString
    val' <- cstringToText val
    return val'

actionNamedReadNamedDest :: ActionNamed -> IO T.Text
actionNamedReadNamedDest s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO CString
    val' <- cstringToText val
    return val'

type family ResolveActionNamedMethod (t :: Symbol) (o :: *) :: * where
    ResolveActionNamedMethod l o = MethodResolutionFailed l o

instance (info ~ ResolveActionNamedMethod t ActionNamed, MethodInfo info ActionNamed p) => IsLabelProxy t (ActionNamed -> p) where
    fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveActionNamedMethod t ActionNamed, MethodInfo info ActionNamed p) => IsLabel t (ActionNamed -> p) where
    fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif