{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Poppler.Objects.Attachment
(
Attachment(..) ,
IsAttachment ,
toAttachment ,
#if defined(ENABLE_OVERLOADING)
ResolveAttachmentMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
AttachmentSaveMethodInfo ,
#endif
attachmentSave ,
#if defined(ENABLE_OVERLOADING)
AttachmentSaveToCallbackMethodInfo ,
#endif
attachmentSaveToCallback ,
) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
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 GHC.Records as R
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Poppler.Callbacks as Poppler.Callbacks
newtype Attachment = Attachment (SP.ManagedPtr Attachment)
deriving (Attachment -> Attachment -> Bool
(Attachment -> Attachment -> Bool)
-> (Attachment -> Attachment -> Bool) -> Eq Attachment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Attachment -> Attachment -> Bool
$c/= :: Attachment -> Attachment -> Bool
== :: Attachment -> Attachment -> Bool
$c== :: Attachment -> Attachment -> Bool
Eq)
instance SP.ManagedPtrNewtype Attachment where
toManagedPtr :: Attachment -> ManagedPtr Attachment
toManagedPtr (Attachment ManagedPtr Attachment
p) = ManagedPtr Attachment
p
foreign import ccall "poppler_attachment_get_type"
c_poppler_attachment_get_type :: IO B.Types.GType
instance B.Types.TypedObject Attachment where
glibType :: IO GType
glibType = IO GType
c_poppler_attachment_get_type
instance B.Types.GObject Attachment
class (SP.GObject o, O.IsDescendantOf Attachment o) => IsAttachment o
instance (SP.GObject o, O.IsDescendantOf Attachment o) => IsAttachment o
instance O.HasParentTypes Attachment
type instance O.ParentTypes Attachment = '[GObject.Object.Object]
toAttachment :: (MIO.MonadIO m, IsAttachment o) => o -> m Attachment
toAttachment :: forall (m :: * -> *) o.
(MonadIO m, IsAttachment o) =>
o -> m Attachment
toAttachment = IO Attachment -> m Attachment
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Attachment -> m Attachment)
-> (o -> IO Attachment) -> o -> m Attachment
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Attachment -> Attachment) -> o -> IO Attachment
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr Attachment -> Attachment
Attachment
instance B.GValue.IsGValue (Maybe Attachment) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_poppler_attachment_get_type
gvalueSet_ :: Ptr GValue -> Maybe Attachment -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Attachment
P.Nothing = Ptr GValue -> Ptr Attachment -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr Attachment
forall a. Ptr a
FP.nullPtr :: FP.Ptr Attachment)
gvalueSet_ Ptr GValue
gv (P.Just Attachment
obj) = Attachment -> (Ptr Attachment -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Attachment
obj (Ptr GValue -> Ptr Attachment -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe Attachment)
gvalueGet_ Ptr GValue
gv = do
Ptr Attachment
ptr <- Ptr GValue -> IO (Ptr Attachment)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr Attachment)
if Ptr Attachment
ptr Ptr Attachment -> Ptr Attachment -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr Attachment
forall a. Ptr a
FP.nullPtr
then Attachment -> Maybe Attachment
forall a. a -> Maybe a
P.Just (Attachment -> Maybe Attachment)
-> IO Attachment -> IO (Maybe Attachment)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr Attachment -> Attachment)
-> Ptr Attachment -> IO Attachment
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Attachment -> Attachment
Attachment Ptr Attachment
ptr
else Maybe Attachment -> IO (Maybe Attachment)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Attachment
forall a. Maybe a
P.Nothing
#if defined(ENABLE_OVERLOADING)
type family ResolveAttachmentMethod (t :: Symbol) (o :: *) :: * where
ResolveAttachmentMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveAttachmentMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveAttachmentMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveAttachmentMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveAttachmentMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveAttachmentMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveAttachmentMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveAttachmentMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveAttachmentMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveAttachmentMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveAttachmentMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveAttachmentMethod "save" o = AttachmentSaveMethodInfo
ResolveAttachmentMethod "saveToCallback" o = AttachmentSaveToCallbackMethodInfo
ResolveAttachmentMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveAttachmentMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveAttachmentMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveAttachmentMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveAttachmentMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveAttachmentMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveAttachmentMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveAttachmentMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveAttachmentMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveAttachmentMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveAttachmentMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveAttachmentMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveAttachmentMethod t Attachment, O.OverloadedMethod info Attachment p) => OL.IsLabel t (Attachment -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveAttachmentMethod t Attachment, O.OverloadedMethod info Attachment p, R.HasField t Attachment p) => R.HasField t Attachment p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveAttachmentMethod t Attachment, O.OverloadedMethodInfo info Attachment) => OL.IsLabel t (O.MethodProxy info Attachment) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Attachment
type instance O.AttributeList Attachment = AttachmentAttributeList
type AttachmentAttributeList = ('[ ] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Attachment = AttachmentSignalList
type AttachmentSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "poppler_attachment_save" poppler_attachment_save ::
Ptr Attachment ->
CString ->
Ptr (Ptr GError) ->
IO CInt
attachmentSave ::
(B.CallStack.HasCallStack, MonadIO m, IsAttachment a) =>
a
-> T.Text
-> m ()
attachmentSave :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsAttachment a) =>
a -> Text -> m ()
attachmentSave a
attachment 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 Attachment
attachment' <- a -> IO (Ptr Attachment)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
attachment
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 Attachment -> CString -> Ptr (Ptr GError) -> IO CInt
poppler_attachment_save Ptr Attachment
attachment' CString
filename'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
attachment
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 AttachmentSaveMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsAttachment a) => O.OverloadedMethod AttachmentSaveMethodInfo a signature where
overloadedMethod = attachmentSave
instance O.OverloadedMethodInfo AttachmentSaveMethodInfo a where
overloadedMethodInfo = O.MethodInfo {
O.overloadedMethodName = "GI.Poppler.Objects.Attachment.attachmentSave",
O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-poppler-0.18.25/docs/GI-Poppler-Objects-Attachment.html#v:attachmentSave"
}
#endif
foreign import ccall "poppler_attachment_save_to_callback" poppler_attachment_save_to_callback ::
Ptr Attachment ->
FunPtr Poppler.Callbacks.C_AttachmentSaveFunc ->
Ptr () ->
Ptr (Ptr GError) ->
IO CInt
attachmentSaveToCallback ::
(B.CallStack.HasCallStack, MonadIO m, IsAttachment a) =>
a
-> FunPtr Poppler.Callbacks.C_AttachmentSaveFunc
-> m ()
attachmentSaveToCallback :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsAttachment a) =>
a -> FunPtr C_AttachmentSaveFunc -> m ()
attachmentSaveToCallback a
attachment FunPtr C_AttachmentSaveFunc
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 Attachment
attachment' <- a -> IO (Ptr Attachment)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
attachment
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 Attachment
-> FunPtr C_AttachmentSaveFunc
-> Ptr ()
-> Ptr (Ptr GError)
-> IO CInt
poppler_attachment_save_to_callback Ptr Attachment
attachment' FunPtr C_AttachmentSaveFunc
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_AttachmentSaveFunc -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_AttachmentSaveFunc
saveFunc
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
attachment
() -> 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_AttachmentSaveFunc -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_AttachmentSaveFunc
saveFunc
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data AttachmentSaveToCallbackMethodInfo
instance (signature ~ (FunPtr Poppler.Callbacks.C_AttachmentSaveFunc -> m ()), MonadIO m, IsAttachment a) => O.OverloadedMethod AttachmentSaveToCallbackMethodInfo a signature where
overloadedMethod = attachmentSaveToCallback
instance O.OverloadedMethodInfo AttachmentSaveToCallbackMethodInfo a where
overloadedMethodInfo = O.MethodInfo {
O.overloadedMethodName = "GI.Poppler.Objects.Attachment.attachmentSaveToCallback",
O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-poppler-0.18.25/docs/GI-Poppler-Objects-Attachment.html#v:attachmentSaveToCallback"
}
#endif