#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Poppler.Objects.Media
(
Media(..) ,
IsMedia ,
toMedia ,
noMedia ,
#if ENABLE_OVERLOADING
MediaGetFilenameMethodInfo ,
#endif
mediaGetFilename ,
#if ENABLE_OVERLOADING
MediaGetMimeTypeMethodInfo ,
#endif
mediaGetMimeType ,
#if ENABLE_OVERLOADING
MediaIsEmbeddedMethodInfo ,
#endif
mediaIsEmbedded ,
#if ENABLE_OVERLOADING
MediaSaveMethodInfo ,
#endif
mediaSave ,
#if ENABLE_OVERLOADING
MediaSaveToCallbackMethodInfo ,
#endif
mediaSaveToCallback ,
) 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.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
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 qualified GHC.OverloadedLabels as OL
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Poppler.Callbacks as Poppler.Callbacks
newtype Media = Media (ManagedPtr Media)
foreign import ccall "poppler_media_get_type"
c_poppler_media_get_type :: IO GType
instance GObject Media where
gobjectType = c_poppler_media_get_type
class (GObject o, O.IsDescendantOf Media o) => IsMedia o
instance (GObject o, O.IsDescendantOf Media o) => IsMedia o
instance O.HasParentTypes Media
type instance O.ParentTypes Media = '[GObject.Object.Object]
toMedia :: (MonadIO m, IsMedia o) => o -> m Media
toMedia = liftIO . unsafeCastTo Media
noMedia :: Maybe Media
noMedia = Nothing
#if ENABLE_OVERLOADING
type family ResolveMediaMethod (t :: Symbol) (o :: *) :: * where
ResolveMediaMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveMediaMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveMediaMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveMediaMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveMediaMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveMediaMethod "isEmbedded" o = MediaIsEmbeddedMethodInfo
ResolveMediaMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveMediaMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveMediaMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveMediaMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveMediaMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveMediaMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveMediaMethod "save" o = MediaSaveMethodInfo
ResolveMediaMethod "saveToCallback" o = MediaSaveToCallbackMethodInfo
ResolveMediaMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveMediaMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveMediaMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveMediaMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveMediaMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveMediaMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveMediaMethod "getFilename" o = MediaGetFilenameMethodInfo
ResolveMediaMethod "getMimeType" o = MediaGetMimeTypeMethodInfo
ResolveMediaMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveMediaMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveMediaMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveMediaMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveMediaMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveMediaMethod t Media, O.MethodInfo info Media p) => OL.IsLabel t (Media -> 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
#if ENABLE_OVERLOADING
instance O.HasAttributeList Media
type instance O.AttributeList Media = MediaAttributeList
type MediaAttributeList = ('[ ] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
#endif
#if ENABLE_OVERLOADING
type instance O.SignalList Media = MediaSignalList
type MediaSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "poppler_media_get_filename" poppler_media_get_filename ::
Ptr Media ->
IO CString
mediaGetFilename ::
(B.CallStack.HasCallStack, MonadIO m, IsMedia a) =>
a
-> m T.Text
mediaGetFilename popplerMedia = liftIO $ do
popplerMedia' <- unsafeManagedPtrCastPtr popplerMedia
result <- poppler_media_get_filename popplerMedia'
checkUnexpectedReturnNULL "mediaGetFilename" result
result' <- cstringToText result
touchManagedPtr popplerMedia
return result'
#if ENABLE_OVERLOADING
data MediaGetFilenameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsMedia a) => O.MethodInfo MediaGetFilenameMethodInfo a signature where
overloadedMethod _ = mediaGetFilename
#endif
foreign import ccall "poppler_media_get_mime_type" poppler_media_get_mime_type ::
Ptr Media ->
IO CString
mediaGetMimeType ::
(B.CallStack.HasCallStack, MonadIO m, IsMedia a) =>
a
-> m T.Text
mediaGetMimeType popplerMedia = liftIO $ do
popplerMedia' <- unsafeManagedPtrCastPtr popplerMedia
result <- poppler_media_get_mime_type popplerMedia'
checkUnexpectedReturnNULL "mediaGetMimeType" result
result' <- cstringToText result
touchManagedPtr popplerMedia
return result'
#if ENABLE_OVERLOADING
data MediaGetMimeTypeMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsMedia a) => O.MethodInfo MediaGetMimeTypeMethodInfo a signature where
overloadedMethod _ = mediaGetMimeType
#endif
foreign import ccall "poppler_media_is_embedded" poppler_media_is_embedded ::
Ptr Media ->
IO CInt
mediaIsEmbedded ::
(B.CallStack.HasCallStack, MonadIO m, IsMedia a) =>
a
-> m Bool
mediaIsEmbedded popplerMedia = liftIO $ do
popplerMedia' <- unsafeManagedPtrCastPtr popplerMedia
result <- poppler_media_is_embedded popplerMedia'
let result' = (/= 0) result
touchManagedPtr popplerMedia
return result'
#if ENABLE_OVERLOADING
data MediaIsEmbeddedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsMedia a) => O.MethodInfo MediaIsEmbeddedMethodInfo a signature where
overloadedMethod _ = mediaIsEmbedded
#endif
foreign import ccall "poppler_media_save" poppler_media_save ::
Ptr Media ->
CString ->
Ptr (Ptr GError) ->
IO CInt
mediaSave ::
(B.CallStack.HasCallStack, MonadIO m, IsMedia a) =>
a
-> T.Text
-> m ()
mediaSave popplerMedia filename = liftIO $ do
popplerMedia' <- unsafeManagedPtrCastPtr popplerMedia
filename' <- textToCString filename
onException (do
_ <- propagateGError $ poppler_media_save popplerMedia' filename'
touchManagedPtr popplerMedia
freeMem filename'
return ()
) (do
freeMem filename'
)
#if ENABLE_OVERLOADING
data MediaSaveMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsMedia a) => O.MethodInfo MediaSaveMethodInfo a signature where
overloadedMethod _ = mediaSave
#endif
foreign import ccall "poppler_media_save_to_callback" poppler_media_save_to_callback ::
Ptr Media ->
FunPtr Poppler.Callbacks.C_MediaSaveFunc ->
Ptr () ->
Ptr (Ptr GError) ->
IO CInt
mediaSaveToCallback ::
(B.CallStack.HasCallStack, MonadIO m, IsMedia a) =>
a
-> FunPtr Poppler.Callbacks.C_MediaSaveFunc
-> m ()
mediaSaveToCallback popplerMedia saveFunc = liftIO $ do
popplerMedia' <- unsafeManagedPtrCastPtr popplerMedia
let userData = nullPtr
onException (do
_ <- propagateGError $ poppler_media_save_to_callback popplerMedia' saveFunc userData
safeFreeFunPtr $ castFunPtrToPtr saveFunc
touchManagedPtr popplerMedia
return ()
) (do
safeFreeFunPtr $ castFunPtrToPtr saveFunc
return ()
)
#if ENABLE_OVERLOADING
data MediaSaveToCallbackMethodInfo
instance (signature ~ (FunPtr Poppler.Callbacks.C_MediaSaveFunc -> m ()), MonadIO m, IsMedia a) => O.MethodInfo MediaSaveToCallbackMethodInfo a signature where
overloadedMethod _ = mediaSaveToCallback
#endif