module Graphics.UI.Gtk.Poppler.Types (
module System.Glib.GObject,
Document(Document), DocumentClass,
toDocument,
mkDocument, unDocument,
castToDocument, gTypeDocument,
FontsIter(FontsIter), FontsIterClass,
toFontsIter,
mkFontsIter, unFontsIter,
castToFontsIter, gTypeFontsIter,
Page(Page), PageClass,
toPage,
mkPage, unPage,
castToPage, gTypePage,
FormField(FormField), FormFieldClass,
toFormField,
mkFormField, unFormField,
castToFormField, gTypeFormField,
PSFile(PSFile), PSFileClass,
toPSFile,
mkPSFile, unPSFile,
castToPSFile, gTypePSFile,
FontInfo(FontInfo), FontInfoClass,
toFontInfo,
mkFontInfo, unFontInfo,
castToFontInfo, gTypeFontInfo,
Attachment(Attachment), AttachmentClass,
toAttachment,
mkAttachment, unAttachment,
castToAttachment, gTypeAttachment,
Layer(Layer), LayerClass,
toLayer,
mkLayer, unLayer,
castToLayer, gTypeLayer
) where
import Foreign.ForeignPtr (ForeignPtr, castForeignPtr)
import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
import Foreign.C.Types (CULong(..), CUInt(..), CULLong(..))
import System.Glib.GType (GType, typeInstanceIsA)
import System.Glib.GObject
castTo :: (GObjectClass obj, GObjectClass obj') => GType -> String
-> (obj -> obj')
castTo gtype objTypeName obj =
case toGObject obj of
gobj@(GObject objFPtr)
| typeInstanceIsA ((unsafeForeignPtrToPtr.castForeignPtr) objFPtr) gtype
-> unsafeCastGObject gobj
| otherwise -> error $ "Cannot cast object to " ++ objTypeName
newtype Document = Document (ForeignPtr (Document)) deriving (Eq,Ord)
mkDocument = (Document, objectUnref)
unDocument (Document o) = o
class GObjectClass o => DocumentClass o
toDocument :: DocumentClass o => o -> Document
toDocument = unsafeCastGObject . toGObject
instance DocumentClass Document
instance GObjectClass Document where
toGObject = GObject . castForeignPtr . unDocument
unsafeCastGObject = Document . castForeignPtr . unGObject
castToDocument :: GObjectClass obj => obj -> Document
castToDocument = castTo gTypeDocument "Document"
gTypeDocument :: GType
gTypeDocument =
poppler_document_get_type
newtype FontsIter = FontsIter (ForeignPtr (FontsIter)) deriving (Eq,Ord)
mkFontsIter = (FontsIter, objectUnref)
unFontsIter (FontsIter o) = o
class GObjectClass o => FontsIterClass o
toFontsIter :: FontsIterClass o => o -> FontsIter
toFontsIter = unsafeCastGObject . toGObject
instance FontsIterClass FontsIter
instance GObjectClass FontsIter where
toGObject = GObject . castForeignPtr . unFontsIter
unsafeCastGObject = FontsIter . castForeignPtr . unGObject
castToFontsIter :: GObjectClass obj => obj -> FontsIter
castToFontsIter = castTo gTypeFontsIter "FontsIter"
gTypeFontsIter :: GType
gTypeFontsIter =
poppler_fonts_iter_get_type
newtype Page = Page (ForeignPtr (Page)) deriving (Eq,Ord)
mkPage = (Page, objectUnref)
unPage (Page o) = o
class GObjectClass o => PageClass o
toPage :: PageClass o => o -> Page
toPage = unsafeCastGObject . toGObject
instance PageClass Page
instance GObjectClass Page where
toGObject = GObject . castForeignPtr . unPage
unsafeCastGObject = Page . castForeignPtr . unGObject
castToPage :: GObjectClass obj => obj -> Page
castToPage = castTo gTypePage "Page"
gTypePage :: GType
gTypePage =
poppler_page_get_type
newtype FormField = FormField (ForeignPtr (FormField)) deriving (Eq,Ord)
mkFormField = (FormField, objectUnref)
unFormField (FormField o) = o
class GObjectClass o => FormFieldClass o
toFormField :: FormFieldClass o => o -> FormField
toFormField = unsafeCastGObject . toGObject
instance FormFieldClass FormField
instance GObjectClass FormField where
toGObject = GObject . castForeignPtr . unFormField
unsafeCastGObject = FormField . castForeignPtr . unGObject
castToFormField :: GObjectClass obj => obj -> FormField
castToFormField = castTo gTypeFormField "FormField"
gTypeFormField :: GType
gTypeFormField =
poppler_form_field_get_type
newtype PSFile = PSFile (ForeignPtr (PSFile)) deriving (Eq,Ord)
mkPSFile = (PSFile, objectUnref)
unPSFile (PSFile o) = o
class GObjectClass o => PSFileClass o
toPSFile :: PSFileClass o => o -> PSFile
toPSFile = unsafeCastGObject . toGObject
instance PSFileClass PSFile
instance GObjectClass PSFile where
toGObject = GObject . castForeignPtr . unPSFile
unsafeCastGObject = PSFile . castForeignPtr . unGObject
castToPSFile :: GObjectClass obj => obj -> PSFile
castToPSFile = castTo gTypePSFile "PSFile"
gTypePSFile :: GType
gTypePSFile =
poppler_ps_file_get_type
newtype FontInfo = FontInfo (ForeignPtr (FontInfo)) deriving (Eq,Ord)
mkFontInfo = (FontInfo, objectUnref)
unFontInfo (FontInfo o) = o
class GObjectClass o => FontInfoClass o
toFontInfo :: FontInfoClass o => o -> FontInfo
toFontInfo = unsafeCastGObject . toGObject
instance FontInfoClass FontInfo
instance GObjectClass FontInfo where
toGObject = GObject . castForeignPtr . unFontInfo
unsafeCastGObject = FontInfo . castForeignPtr . unGObject
castToFontInfo :: GObjectClass obj => obj -> FontInfo
castToFontInfo = castTo gTypeFontInfo "FontInfo"
gTypeFontInfo :: GType
gTypeFontInfo =
poppler_font_info_get_type
newtype Attachment = Attachment (ForeignPtr (Attachment)) deriving (Eq,Ord)
mkAttachment = (Attachment, objectUnref)
unAttachment (Attachment o) = o
class GObjectClass o => AttachmentClass o
toAttachment :: AttachmentClass o => o -> Attachment
toAttachment = unsafeCastGObject . toGObject
instance AttachmentClass Attachment
instance GObjectClass Attachment where
toGObject = GObject . castForeignPtr . unAttachment
unsafeCastGObject = Attachment . castForeignPtr . unGObject
castToAttachment :: GObjectClass obj => obj -> Attachment
castToAttachment = castTo gTypeAttachment "Attachment"
gTypeAttachment :: GType
gTypeAttachment =
poppler_attachment_get_type
newtype Layer = Layer (ForeignPtr (Layer)) deriving (Eq,Ord)
mkLayer = (Layer, objectUnref)
unLayer (Layer o) = o
class GObjectClass o => LayerClass o
toLayer :: LayerClass o => o -> Layer
toLayer = unsafeCastGObject . toGObject
instance LayerClass Layer
instance GObjectClass Layer where
toGObject = GObject . castForeignPtr . unLayer
unsafeCastGObject = Layer . castForeignPtr . unGObject
castToLayer :: GObjectClass obj => obj -> Layer
castToLayer = castTo gTypeLayer "Layer"
gTypeLayer :: GType
gTypeLayer =
poppler_layer_get_type
foreign import ccall unsafe "poppler_document_get_type"
poppler_document_get_type :: CULong
foreign import ccall unsafe "poppler_fonts_iter_get_type"
poppler_fonts_iter_get_type :: CULong
foreign import ccall unsafe "poppler_page_get_type"
poppler_page_get_type :: CULong
foreign import ccall unsafe "poppler_form_field_get_type"
poppler_form_field_get_type :: CULong
foreign import ccall unsafe "poppler_ps_file_get_type"
poppler_ps_file_get_type :: CULong
foreign import ccall unsafe "poppler_font_info_get_type"
poppler_font_info_get_type :: CULong
foreign import ccall unsafe "poppler_attachment_get_type"
poppler_attachment_get_type :: CULong
foreign import ccall unsafe "poppler_layer_get_type"
poppler_layer_get_type :: CULong