{- | 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.Media ( -- * Exported types Media(..) , MediaK , toMedia , noMedia , -- * Methods -- ** mediaGetFilename mediaGetFilename , -- ** mediaGetMimeType mediaGetMimeType , -- ** mediaIsEmbedded mediaIsEmbedded , -- ** mediaSave mediaSave , -- ** mediaSaveToCallback mediaSaveToCallback , ) 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 Media = Media (ForeignPtr Media) foreign import ccall "poppler_media_get_type" c_poppler_media_get_type :: IO GType type instance ParentTypes Media = MediaParentTypes type MediaParentTypes = '[GObject.Object] instance GObject Media where gobjectIsInitiallyUnowned _ = False gobjectType _ = c_poppler_media_get_type class GObject o => MediaK o instance (GObject o, IsDescendantOf Media o) => MediaK o toMedia :: MediaK o => o -> IO Media toMedia = unsafeCastTo Media noMedia :: Maybe Media noMedia = Nothing type instance AttributeList Media = MediaAttributeList type MediaAttributeList = ('[ ] :: [(Symbol, *)]) type instance SignalList Media = MediaSignalList type MediaSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)]) -- method Media::get_filename -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "Media", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Poppler" "Media", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TUTF8 -- throws : False -- Skip return : False foreign import ccall "poppler_media_get_filename" poppler_media_get_filename :: Ptr Media -> -- _obj : TInterface "Poppler" "Media" IO CString mediaGetFilename :: (MonadIO m, MediaK a) => a -> -- _obj m T.Text mediaGetFilename _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- poppler_media_get_filename _obj' checkUnexpectedReturnNULL "poppler_media_get_filename" result result' <- cstringToText result touchManagedPtr _obj return result' -- method Media::get_mime_type -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "Media", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Poppler" "Media", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TUTF8 -- throws : False -- Skip return : False foreign import ccall "poppler_media_get_mime_type" poppler_media_get_mime_type :: Ptr Media -> -- _obj : TInterface "Poppler" "Media" IO CString mediaGetMimeType :: (MonadIO m, MediaK a) => a -> -- _obj m T.Text mediaGetMimeType _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- poppler_media_get_mime_type _obj' checkUnexpectedReturnNULL "poppler_media_get_mime_type" result result' <- cstringToText result touchManagedPtr _obj return result' -- method Media::is_embedded -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "Media", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Poppler" "Media", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : False -- Skip return : False foreign import ccall "poppler_media_is_embedded" poppler_media_is_embedded :: Ptr Media -> -- _obj : TInterface "Poppler" "Media" IO CInt mediaIsEmbedded :: (MonadIO m, MediaK a) => a -> -- _obj m Bool mediaIsEmbedded _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- poppler_media_is_embedded _obj' let result' = (/= 0) result touchManagedPtr _obj return result' -- method Media::save -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "Media", 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" "Media", 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_media_save" poppler_media_save :: Ptr Media -> -- _obj : TInterface "Poppler" "Media" CString -> -- filename : TBasicType TUTF8 Ptr (Ptr GError) -> -- error IO CInt mediaSave :: (MonadIO m, MediaK a) => a -> -- _obj T.Text -> -- filename m () mediaSave _obj filename = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj filename' <- textToCString filename onException (do _ <- propagateGError $ poppler_media_save _obj' filename' touchManagedPtr _obj freeMem filename' return () ) (do freeMem filename' ) -- method Media::save_to_callback -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "Media", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "save_func", argType = TInterface "Poppler" "MediaSaveFunc", 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" "Media", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "save_func", argType = TInterface "Poppler" "MediaSaveFunc", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeCall, argClosure = 2, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : True -- Skip return : False foreign import ccall "poppler_media_save_to_callback" poppler_media_save_to_callback :: Ptr Media -> -- _obj : TInterface "Poppler" "Media" FunPtr MediaSaveFuncC -> -- save_func : TInterface "Poppler" "MediaSaveFunc" Ptr () -> -- user_data : TBasicType TVoid Ptr (Ptr GError) -> -- error IO CInt mediaSaveToCallback :: (MonadIO m, MediaK a) => a -> -- _obj MediaSaveFunc -> -- save_func m () mediaSaveToCallback _obj save_func = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj save_func' <- mkMediaSaveFunc (mediaSaveFuncWrapper Nothing save_func) let user_data = nullPtr onException (do _ <- propagateGError $ poppler_media_save_to_callback _obj' save_func' user_data safeFreeFunPtr $ castFunPtrToPtr save_func' touchManagedPtr _obj return () ) (do safeFreeFunPtr $ castFunPtrToPtr save_func' return () )