{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Poppler.Objects.PSFile
(
PSFile(..) ,
IsPSFile ,
toPSFile ,
#if defined(ENABLE_OVERLOADING)
ResolvePSFileMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
PSFileFreeMethodInfo ,
#endif
pSFileFree ,
pSFileNew ,
#if defined(ENABLE_OVERLOADING)
PSFileSetDuplexMethodInfo ,
#endif
pSFileSetDuplex ,
#if defined(ENABLE_OVERLOADING)
PSFileSetPaperSizeMethodInfo ,
#endif
pSFileSetPaperSize ,
) 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 {-# SOURCE #-} qualified GI.Poppler.Objects.Document as Poppler.Document
newtype PSFile = PSFile (ManagedPtr PSFile)
deriving (PSFile -> PSFile -> Bool
(PSFile -> PSFile -> Bool)
-> (PSFile -> PSFile -> Bool) -> Eq PSFile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PSFile -> PSFile -> Bool
$c/= :: PSFile -> PSFile -> Bool
== :: PSFile -> PSFile -> Bool
$c== :: PSFile -> PSFile -> Bool
Eq)
foreign import ccall "poppler_ps_file_get_type"
c_poppler_ps_file_get_type :: IO GType
instance GObject PSFile where
gobjectType :: IO GType
gobjectType = IO GType
c_poppler_ps_file_get_type
instance B.GValue.IsGValue PSFile where
toGValue :: PSFile -> IO GValue
toGValue PSFile
o = do
GType
gtype <- IO GType
c_poppler_ps_file_get_type
PSFile -> (Ptr PSFile -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr PSFile
o (GType -> (GValue -> Ptr PSFile -> IO ()) -> Ptr PSFile -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr PSFile -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
fromGValue :: GValue -> IO PSFile
fromGValue GValue
gv = do
Ptr PSFile
ptr <- GValue -> IO (Ptr PSFile)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr PSFile)
(ManagedPtr PSFile -> PSFile) -> Ptr PSFile -> IO PSFile
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr PSFile -> PSFile
PSFile Ptr PSFile
ptr
class (GObject o, O.IsDescendantOf PSFile o) => IsPSFile o
instance (GObject o, O.IsDescendantOf PSFile o) => IsPSFile o
instance O.HasParentTypes PSFile
type instance O.ParentTypes PSFile = '[GObject.Object.Object]
toPSFile :: (MonadIO m, IsPSFile o) => o -> m PSFile
toPSFile :: o -> m PSFile
toPSFile = IO PSFile -> m PSFile
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO PSFile -> m PSFile) -> (o -> IO PSFile) -> o -> m PSFile
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr PSFile -> PSFile) -> o -> IO PSFile
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr PSFile -> PSFile
PSFile
#if defined(ENABLE_OVERLOADING)
type family ResolvePSFileMethod (t :: Symbol) (o :: *) :: * where
ResolvePSFileMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolvePSFileMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolvePSFileMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolvePSFileMethod "free" o = PSFileFreeMethodInfo
ResolvePSFileMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolvePSFileMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolvePSFileMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolvePSFileMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolvePSFileMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolvePSFileMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolvePSFileMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolvePSFileMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolvePSFileMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolvePSFileMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolvePSFileMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolvePSFileMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolvePSFileMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolvePSFileMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolvePSFileMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolvePSFileMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolvePSFileMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolvePSFileMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolvePSFileMethod "setDuplex" o = PSFileSetDuplexMethodInfo
ResolvePSFileMethod "setPaperSize" o = PSFileSetPaperSizeMethodInfo
ResolvePSFileMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolvePSFileMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolvePSFileMethod t PSFile, O.MethodInfo info PSFile p) => OL.IsLabel t (PSFile -> 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 PSFile
type instance O.AttributeList PSFile = PSFileAttributeList
type PSFileAttributeList = ('[ ] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList PSFile = PSFileSignalList
type PSFileSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "poppler_ps_file_new" poppler_ps_file_new ::
Ptr Poppler.Document.Document ->
CString ->
Int32 ->
Int32 ->
IO (Ptr PSFile)
pSFileNew ::
(B.CallStack.HasCallStack, MonadIO m, Poppler.Document.IsDocument a) =>
a
-> T.Text
-> Int32
-> Int32
-> m PSFile
pSFileNew :: a -> Text -> Int32 -> Int32 -> m PSFile
pSFileNew a
document Text
filename Int32
firstPage Int32
nPages = IO PSFile -> m PSFile
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO PSFile -> m PSFile) -> IO PSFile -> m PSFile
forall a b. (a -> b) -> a -> b
$ do
Ptr Document
document' <- a -> IO (Ptr Document)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
document
CString
filename' <- Text -> IO CString
textToCString Text
filename
Ptr PSFile
result <- Ptr Document -> CString -> Int32 -> Int32 -> IO (Ptr PSFile)
poppler_ps_file_new Ptr Document
document' CString
filename' Int32
firstPage Int32
nPages
Text -> Ptr PSFile -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"pSFileNew" Ptr PSFile
result
PSFile
result' <- ((ManagedPtr PSFile -> PSFile) -> Ptr PSFile -> IO PSFile
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr PSFile -> PSFile
PSFile) Ptr PSFile
result
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
document
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
PSFile -> IO PSFile
forall (m :: * -> *) a. Monad m => a -> m a
return PSFile
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "poppler_ps_file_free" poppler_ps_file_free ::
Ptr PSFile ->
IO ()
pSFileFree ::
(B.CallStack.HasCallStack, MonadIO m, IsPSFile a) =>
a
-> m ()
pSFileFree :: a -> m ()
pSFileFree a
psFile = 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 PSFile
psFile' <- a -> IO (Ptr PSFile)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
psFile
Ptr PSFile -> IO ()
poppler_ps_file_free Ptr PSFile
psFile'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
psFile
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data PSFileFreeMethodInfo
instance (signature ~ (m ()), MonadIO m, IsPSFile a) => O.MethodInfo PSFileFreeMethodInfo a signature where
overloadedMethod = pSFileFree
#endif
foreign import ccall "poppler_ps_file_set_duplex" poppler_ps_file_set_duplex ::
Ptr PSFile ->
CInt ->
IO ()
pSFileSetDuplex ::
(B.CallStack.HasCallStack, MonadIO m, IsPSFile a) =>
a
-> Bool
-> m ()
pSFileSetDuplex :: a -> Bool -> m ()
pSFileSetDuplex a
psFile Bool
duplex = 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 PSFile
psFile' <- a -> IO (Ptr PSFile)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
psFile
let duplex' :: CInt
duplex' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
duplex
Ptr PSFile -> CInt -> IO ()
poppler_ps_file_set_duplex Ptr PSFile
psFile' CInt
duplex'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
psFile
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data PSFileSetDuplexMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsPSFile a) => O.MethodInfo PSFileSetDuplexMethodInfo a signature where
overloadedMethod = pSFileSetDuplex
#endif
foreign import ccall "poppler_ps_file_set_paper_size" poppler_ps_file_set_paper_size ::
Ptr PSFile ->
CDouble ->
CDouble ->
IO ()
pSFileSetPaperSize ::
(B.CallStack.HasCallStack, MonadIO m, IsPSFile a) =>
a
-> Double
-> Double
-> m ()
pSFileSetPaperSize :: a -> Double -> Double -> m ()
pSFileSetPaperSize a
psFile Double
width Double
height = 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 PSFile
psFile' <- a -> IO (Ptr PSFile)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
psFile
let width' :: CDouble
width' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
width
let height' :: CDouble
height' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
height
Ptr PSFile -> CDouble -> CDouble -> IO ()
poppler_ps_file_set_paper_size Ptr PSFile
psFile' CDouble
width' CDouble
height'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
psFile
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data PSFileSetPaperSizeMethodInfo
instance (signature ~ (Double -> Double -> m ()), MonadIO m, IsPSFile a) => O.MethodInfo PSFileSetPaperSizeMethodInfo a signature where
overloadedMethod = pSFileSetPaperSize
#endif