{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.Poppler.Objects.FontInfo
    ( 

-- * Exported types
    FontInfo(..)                            ,
    FontInfoK                               ,
    toFontInfo                              ,
    noFontInfo                              ,


 -- * Methods
-- ** fontInfoFree
    fontInfoFree                            ,


-- ** fontInfoNew
    fontInfoNew                             ,


-- ** fontInfoScan
    fontInfoScan                            ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Poppler.Types
import GI.Poppler.Callbacks
import qualified GI.GObject as GObject

newtype FontInfo = FontInfo (ForeignPtr FontInfo)
foreign import ccall "poppler_font_info_get_type"
    c_poppler_font_info_get_type :: IO GType

type instance ParentTypes FontInfo = FontInfoParentTypes
type FontInfoParentTypes = '[GObject.Object]

instance GObject FontInfo where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_poppler_font_info_get_type
    

class GObject o => FontInfoK o
instance (GObject o, IsDescendantOf FontInfo o) => FontInfoK o

toFontInfo :: FontInfoK o => o -> IO FontInfo
toFontInfo = unsafeCastTo FontInfo

noFontInfo :: Maybe FontInfo
noFontInfo = Nothing

type instance AttributeList FontInfo = FontInfoAttributeList
type FontInfoAttributeList = ('[ ] :: [(Symbol, *)])

type instance SignalList FontInfo = FontInfoSignalList
type FontInfoSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method FontInfo::new
-- method type : Constructor
-- Args : [Arg {argName = "document", argType = TInterface "Poppler" "Document", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "document", argType = TInterface "Poppler" "Document", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Poppler" "FontInfo"
-- throws : False
-- Skip return : False

foreign import ccall "poppler_font_info_new" poppler_font_info_new :: 
    Ptr Document ->                         -- document : TInterface "Poppler" "Document"
    IO (Ptr FontInfo)


fontInfoNew ::
    (MonadIO m, DocumentK a) =>
    a ->                                    -- document
    m FontInfo
fontInfoNew document = liftIO $ do
    let document' = unsafeManagedPtrCastPtr document
    result <- poppler_font_info_new document'
    checkUnexpectedReturnNULL "poppler_font_info_new" result
    result' <- (wrapObject FontInfo) result
    touchManagedPtr document
    return result'

-- method FontInfo::free
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "FontInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Poppler" "FontInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "poppler_font_info_free" poppler_font_info_free :: 
    Ptr FontInfo ->                         -- _obj : TInterface "Poppler" "FontInfo"
    IO ()


fontInfoFree ::
    (MonadIO m, FontInfoK a) =>
    a ->                                    -- _obj
    m ()
fontInfoFree _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    poppler_font_info_free _obj'
    touchManagedPtr _obj
    return ()

-- method FontInfo::scan
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "FontInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "n_pages", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "iter", argType = TInterface "Poppler" "FontsIter", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Poppler" "FontInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "n_pages", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "poppler_font_info_scan" poppler_font_info_scan :: 
    Ptr FontInfo ->                         -- _obj : TInterface "Poppler" "FontInfo"
    Int32 ->                                -- n_pages : TBasicType TInt32
    Ptr (Ptr FontsIter) ->                  -- iter : TInterface "Poppler" "FontsIter"
    IO CInt


fontInfoScan ::
    (MonadIO m, FontInfoK a) =>
    a ->                                    -- _obj
    Int32 ->                                -- n_pages
    m (Bool,FontsIter)
fontInfoScan _obj n_pages = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    iter <- allocMem :: IO (Ptr (Ptr FontsIter))
    result <- poppler_font_info_scan _obj' n_pages iter
    let result' = (/= 0) result
    iter' <- peek iter
    iter'' <- (wrapBoxed FontsIter) iter'
    touchManagedPtr _obj
    freeMem iter
    return (result', iter'')