{- |
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.Pango.Objects.FontFace
    ( 

-- * Exported types
    FontFace(..)                            ,
    FontFaceK                               ,
    toFontFace                              ,
    noFontFace                              ,


 -- * Methods
-- ** fontFaceDescribe
    fontFaceDescribe                        ,


-- ** fontFaceGetFaceName
    fontFaceGetFaceName                     ,


-- ** fontFaceIsSynthesized
    fontFaceIsSynthesized                   ,


-- ** fontFaceListSizes
    fontFaceListSizes                       ,




    ) 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.Pango.Types
import GI.Pango.Callbacks
import qualified GI.GObject as GObject

newtype FontFace = FontFace (ForeignPtr FontFace)
foreign import ccall "pango_font_face_get_type"
    c_pango_font_face_get_type :: IO GType

type instance ParentTypes FontFace = FontFaceParentTypes
type FontFaceParentTypes = '[GObject.Object]

instance GObject FontFace where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_pango_font_face_get_type
    

class GObject o => FontFaceK o
instance (GObject o, IsDescendantOf FontFace o) => FontFaceK o

toFontFace :: FontFaceK o => o -> IO FontFace
toFontFace = unsafeCastTo FontFace

noFontFace :: Maybe FontFace
noFontFace = Nothing

type instance AttributeList FontFace = FontFaceAttributeList
type FontFaceAttributeList = ('[ ] :: [(Symbol, *)])

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

-- method FontFace::describe
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "FontFace", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "FontFace", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Pango" "FontDescription"
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_face_describe" pango_font_face_describe :: 
    Ptr FontFace ->                         -- _obj : TInterface "Pango" "FontFace"
    IO (Ptr FontDescription)


fontFaceDescribe ::
    (MonadIO m, FontFaceK a) =>
    a ->                                    -- _obj
    m FontDescription
fontFaceDescribe _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- pango_font_face_describe _obj'
    checkUnexpectedReturnNULL "pango_font_face_describe" result
    result' <- (wrapBoxed FontDescription) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "pango_font_face_get_face_name" pango_font_face_get_face_name :: 
    Ptr FontFace ->                         -- _obj : TInterface "Pango" "FontFace"
    IO CString


fontFaceGetFaceName ::
    (MonadIO m, FontFaceK a) =>
    a ->                                    -- _obj
    m T.Text
fontFaceGetFaceName _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- pango_font_face_get_face_name _obj'
    checkUnexpectedReturnNULL "pango_font_face_get_face_name" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "pango_font_face_is_synthesized" pango_font_face_is_synthesized :: 
    Ptr FontFace ->                         -- _obj : TInterface "Pango" "FontFace"
    IO CInt


fontFaceIsSynthesized ::
    (MonadIO m, FontFaceK a) =>
    a ->                                    -- _obj
    m Bool
fontFaceIsSynthesized _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- pango_font_face_is_synthesized _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method FontFace::list_sizes
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "FontFace", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "sizes", argType = TCArray False (-1) 2 (TBasicType TInt32), direction = DirectionOut, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "n_sizes", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : [Arg {argName = "n_sizes", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "FontFace", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_face_list_sizes" pango_font_face_list_sizes :: 
    Ptr FontFace ->                         -- _obj : TInterface "Pango" "FontFace"
    Ptr (Ptr Int32) ->                      -- sizes : TCArray False (-1) 2 (TBasicType TInt32)
    Ptr Int32 ->                            -- n_sizes : TBasicType TInt32
    IO ()


fontFaceListSizes ::
    (MonadIO m, FontFaceK a) =>
    a ->                                    -- _obj
    m ((Maybe [Int32]))
fontFaceListSizes _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    sizes <- allocMem :: IO (Ptr (Ptr Int32))
    n_sizes <- allocMem :: IO (Ptr Int32)
    pango_font_face_list_sizes _obj' sizes n_sizes
    n_sizes' <- peek n_sizes
    sizes' <- peek sizes
    maybeSizes' <- convertIfNonNull sizes' $ \sizes'' -> do
        sizes''' <- (unpackStorableArrayWithLength n_sizes') sizes''
        freeMem sizes''
        return sizes'''
    touchManagedPtr _obj
    freeMem sizes
    freeMem n_sizes
    return maybeSizes'