gi-poppler-0.0.30.12: GI/Poppler/Objects/Attachment.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.Objects.Attachment
(
-- * Exported types
Attachment(..) ,
AttachmentK ,
toAttachment ,
noAttachment ,
-- * Methods
-- ** attachmentSave
attachmentSave ,
-- ** attachmentSaveToCallback
attachmentSaveToCallback ,
) 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
import qualified GI.GObject as GObject
newtype Attachment = Attachment (ForeignPtr Attachment)
foreign import ccall "poppler_attachment_get_type"
c_poppler_attachment_get_type :: IO GType
type instance ParentTypes Attachment = AttachmentParentTypes
type AttachmentParentTypes = '[GObject.Object]
instance GObject Attachment where
gobjectIsInitiallyUnowned _ = False
gobjectType _ = c_poppler_attachment_get_type
class GObject o => AttachmentK o
instance (GObject o, IsDescendantOf Attachment o) => AttachmentK o
toAttachment :: AttachmentK o => o -> IO Attachment
toAttachment = unsafeCastTo Attachment
noAttachment :: Maybe Attachment
noAttachment = Nothing
type instance AttributeList Attachment = AttachmentAttributeList
type AttachmentAttributeList = ('[ ] :: [(Symbol, *)])
type instance SignalList Attachment = AttachmentSignalList
type AttachmentSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])
-- method Attachment::save
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "Attachment", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "filename", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Poppler" "Attachment", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "filename", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False
foreign import ccall "poppler_attachment_save" poppler_attachment_save ::
Ptr Attachment -> -- _obj : TInterface "Poppler" "Attachment"
CString -> -- filename : TBasicType TUTF8
Ptr (Ptr GError) -> -- error
IO CInt
attachmentSave ::
(MonadIO m, AttachmentK a) =>
a -> -- _obj
T.Text -> -- filename
m ()
attachmentSave _obj filename = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
filename' <- textToCString filename
onException (do
_ <- propagateGError $ poppler_attachment_save _obj' filename'
touchManagedPtr _obj
freeMem filename'
return ()
) (do
freeMem filename'
)
-- method Attachment::save_to_callback
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "Attachment", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "save_func", argType = TInterface "Poppler" "AttachmentSaveFunc", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeCall, argClosure = 2, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Poppler" "Attachment", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "save_func", argType = TInterface "Poppler" "AttachmentSaveFunc", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeCall, argClosure = 2, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False
foreign import ccall "poppler_attachment_save_to_callback" poppler_attachment_save_to_callback ::
Ptr Attachment -> -- _obj : TInterface "Poppler" "Attachment"
FunPtr AttachmentSaveFuncC -> -- save_func : TInterface "Poppler" "AttachmentSaveFunc"
Ptr () -> -- user_data : TBasicType TVoid
Ptr (Ptr GError) -> -- error
IO CInt
attachmentSaveToCallback ::
(MonadIO m, AttachmentK a) =>
a -> -- _obj
AttachmentSaveFunc -> -- save_func
m ()
attachmentSaveToCallback _obj save_func = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
save_func' <- mkAttachmentSaveFunc (attachmentSaveFuncWrapper Nothing save_func)
let user_data = nullPtr
onException (do
_ <- propagateGError $ poppler_attachment_save_to_callback _obj' save_func' user_data
safeFreeFunPtr $ castFunPtrToPtr save_func'
touchManagedPtr _obj
return ()
) (do
safeFreeFunPtr $ castFunPtrToPtr save_func'
return ()
)