{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Poppler.Objects.Media
(
Media(..) ,
IsMedia ,
toMedia ,
#if defined(ENABLE_OVERLOADING)
ResolveMediaMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
MediaGetFilenameMethodInfo ,
#endif
mediaGetFilename ,
#if defined(ENABLE_OVERLOADING)
MediaGetMimeTypeMethodInfo ,
#endif
mediaGetMimeType ,
#if defined(ENABLE_OVERLOADING)
MediaIsEmbeddedMethodInfo ,
#endif
mediaIsEmbedded ,
#if defined(ENABLE_OVERLOADING)
MediaSaveMethodInfo ,
#endif
mediaSave ,
#if defined(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.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
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)
deriving (Media -> Media -> Bool
(Media -> Media -> Bool) -> (Media -> Media -> Bool) -> Eq Media
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Media -> Media -> Bool
$c/= :: Media -> Media -> Bool
== :: Media -> Media -> Bool
$c== :: Media -> Media -> Bool
Eq)
foreign import ccall "poppler_media_get_type"
c_poppler_media_get_type :: IO GType
instance GObject Media where
gobjectType :: IO GType
gobjectType = IO GType
c_poppler_media_get_type
instance B.GValue.IsGValue Media where
toGValue :: Media -> IO GValue
toGValue Media
o = do
GType
gtype <- IO GType
c_poppler_media_get_type
Media -> (Ptr Media -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Media
o (GType -> (GValue -> Ptr Media -> IO ()) -> Ptr Media -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Media -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
fromGValue :: GValue -> IO Media
fromGValue GValue
gv = do
Ptr Media
ptr <- GValue -> IO (Ptr Media)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr Media)
(ManagedPtr Media -> Media) -> Ptr Media -> IO Media
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Media -> Media
Media Ptr Media
ptr
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 :: o -> m Media
toMedia = IO Media -> m Media
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Media -> m Media) -> (o -> IO Media) -> o -> m Media
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Media -> Media) -> o -> IO Media
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr Media -> Media
Media
#if defined(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 "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
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 @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Media
type instance O.AttributeList Media = MediaAttributeList
type MediaAttributeList = ('[ ] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(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 :: a -> m Text
mediaGetFilename a
popplerMedia = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
Ptr Media
popplerMedia' <- a -> IO (Ptr Media)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
popplerMedia
CString
result <- Ptr Media -> IO CString
poppler_media_get_filename Ptr Media
popplerMedia'
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"mediaGetFilename" CString
result
Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
popplerMedia
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(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 :: a -> m Text
mediaGetMimeType a
popplerMedia = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
Ptr Media
popplerMedia' <- a -> IO (Ptr Media)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
popplerMedia
CString
result <- Ptr Media -> IO CString
poppler_media_get_mime_type Ptr Media
popplerMedia'
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"mediaGetMimeType" CString
result
Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
popplerMedia
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(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 :: a -> m Bool
mediaIsEmbedded a
popplerMedia = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
Ptr Media
popplerMedia' <- a -> IO (Ptr Media)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
popplerMedia
CInt
result <- Ptr Media -> IO CInt
poppler_media_is_embedded Ptr Media
popplerMedia'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
popplerMedia
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(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 :: a -> Text -> m ()
mediaSave a
popplerMedia Text
filename = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Media
popplerMedia' <- a -> IO (Ptr Media)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
popplerMedia
CString
filename' <- Text -> IO CString
textToCString Text
filename
IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Media -> CString -> Ptr (Ptr GError) -> IO CInt
poppler_media_save Ptr Media
popplerMedia' CString
filename'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
popplerMedia
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
) (do
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
)
#if defined(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 :: a -> FunPtr C_MediaSaveFunc -> m ()
mediaSaveToCallback a
popplerMedia FunPtr C_MediaSaveFunc
saveFunc = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Media
popplerMedia' <- a -> IO (Ptr Media)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
popplerMedia
let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Media
-> FunPtr C_MediaSaveFunc -> Ptr () -> Ptr (Ptr GError) -> IO CInt
poppler_media_save_to_callback Ptr Media
popplerMedia' FunPtr C_MediaSaveFunc
saveFunc Ptr ()
forall a. Ptr a
userData
Ptr Any -> IO ()
forall a. Ptr a -> IO ()
safeFreeFunPtr (Ptr Any -> IO ()) -> Ptr Any -> IO ()
forall a b. (a -> b) -> a -> b
$ FunPtr C_MediaSaveFunc -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_MediaSaveFunc
saveFunc
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
popplerMedia
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
) (do
Ptr Any -> IO ()
forall a. Ptr a -> IO ()
safeFreeFunPtr (Ptr Any -> IO ()) -> Ptr Any -> IO ()
forall a b. (a -> b) -> a -> b
$ FunPtr C_MediaSaveFunc -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_MediaSaveFunc
saveFunc
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(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