{- |
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.GdkPixbuf.Objects.PixbufLoader
    ( 

-- * Exported types
    PixbufLoader(..)                        ,
    PixbufLoaderK                           ,
    toPixbufLoader                          ,
    noPixbufLoader                          ,


 -- * Methods
-- ** pixbufLoaderClose
    pixbufLoaderClose                       ,


-- ** pixbufLoaderGetAnimation
    pixbufLoaderGetAnimation                ,


-- ** pixbufLoaderGetFormat
    pixbufLoaderGetFormat                   ,


-- ** pixbufLoaderGetPixbuf
    pixbufLoaderGetPixbuf                   ,


-- ** pixbufLoaderNew
    pixbufLoaderNew                         ,


-- ** pixbufLoaderNewWithMimeType
    pixbufLoaderNewWithMimeType             ,


-- ** pixbufLoaderNewWithType
    pixbufLoaderNewWithType                 ,


-- ** pixbufLoaderSetSize
    pixbufLoaderSetSize                     ,


-- ** pixbufLoaderWrite
    pixbufLoaderWrite                       ,


-- ** pixbufLoaderWriteBytes
    pixbufLoaderWriteBytes                  ,




 -- * Signals
-- ** AreaPrepared
    PixbufLoaderAreaPreparedCallback        ,
    PixbufLoaderAreaPreparedCallbackC       ,
    PixbufLoaderAreaPreparedSignalInfo      ,
    afterPixbufLoaderAreaPrepared           ,
    mkPixbufLoaderAreaPreparedCallback      ,
    noPixbufLoaderAreaPreparedCallback      ,
    onPixbufLoaderAreaPrepared              ,
    pixbufLoaderAreaPreparedCallbackWrapper ,
    pixbufLoaderAreaPreparedClosure         ,


-- ** AreaUpdated
    PixbufLoaderAreaUpdatedCallback         ,
    PixbufLoaderAreaUpdatedCallbackC        ,
    PixbufLoaderAreaUpdatedSignalInfo       ,
    afterPixbufLoaderAreaUpdated            ,
    mkPixbufLoaderAreaUpdatedCallback       ,
    noPixbufLoaderAreaUpdatedCallback       ,
    onPixbufLoaderAreaUpdated               ,
    pixbufLoaderAreaUpdatedCallbackWrapper  ,
    pixbufLoaderAreaUpdatedClosure          ,


-- ** Closed
    PixbufLoaderClosedCallback              ,
    PixbufLoaderClosedCallbackC             ,
    PixbufLoaderClosedSignalInfo            ,
    afterPixbufLoaderClosed                 ,
    mkPixbufLoaderClosedCallback            ,
    noPixbufLoaderClosedCallback            ,
    onPixbufLoaderClosed                    ,
    pixbufLoaderClosedCallbackWrapper       ,
    pixbufLoaderClosedClosure               ,


-- ** SizePrepared
    PixbufLoaderSizePreparedCallback        ,
    PixbufLoaderSizePreparedCallbackC       ,
    PixbufLoaderSizePreparedSignalInfo      ,
    afterPixbufLoaderSizePrepared           ,
    mkPixbufLoaderSizePreparedCallback      ,
    noPixbufLoaderSizePreparedCallback      ,
    onPixbufLoaderSizePrepared              ,
    pixbufLoaderSizePreparedCallbackWrapper ,
    pixbufLoaderSizePreparedClosure         ,




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

newtype PixbufLoader = PixbufLoader (ForeignPtr PixbufLoader)
foreign import ccall "gdk_pixbuf_loader_get_type"
    c_gdk_pixbuf_loader_get_type :: IO GType

type instance ParentTypes PixbufLoader = PixbufLoaderParentTypes
type PixbufLoaderParentTypes = '[GObject.Object]

instance GObject PixbufLoader where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_gdk_pixbuf_loader_get_type
    

class GObject o => PixbufLoaderK o
instance (GObject o, IsDescendantOf PixbufLoader o) => PixbufLoaderK o

toPixbufLoader :: PixbufLoaderK o => o -> IO PixbufLoader
toPixbufLoader = unsafeCastTo PixbufLoader

noPixbufLoader :: Maybe PixbufLoader
noPixbufLoader = Nothing

-- signal PixbufLoader::area-prepared
type PixbufLoaderAreaPreparedCallback =
    IO ()

noPixbufLoaderAreaPreparedCallback :: Maybe PixbufLoaderAreaPreparedCallback
noPixbufLoaderAreaPreparedCallback = Nothing

type PixbufLoaderAreaPreparedCallbackC =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mkPixbufLoaderAreaPreparedCallback :: PixbufLoaderAreaPreparedCallbackC -> IO (FunPtr PixbufLoaderAreaPreparedCallbackC)

pixbufLoaderAreaPreparedClosure :: PixbufLoaderAreaPreparedCallback -> IO Closure
pixbufLoaderAreaPreparedClosure cb = newCClosure =<< mkPixbufLoaderAreaPreparedCallback wrapped
    where wrapped = pixbufLoaderAreaPreparedCallbackWrapper cb

pixbufLoaderAreaPreparedCallbackWrapper ::
    PixbufLoaderAreaPreparedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
pixbufLoaderAreaPreparedCallbackWrapper _cb _ _ = do
    _cb 

onPixbufLoaderAreaPrepared :: (GObject a, MonadIO m) => a -> PixbufLoaderAreaPreparedCallback -> m SignalHandlerId
onPixbufLoaderAreaPrepared obj cb = liftIO $ connectPixbufLoaderAreaPrepared obj cb SignalConnectBefore
afterPixbufLoaderAreaPrepared :: (GObject a, MonadIO m) => a -> PixbufLoaderAreaPreparedCallback -> m SignalHandlerId
afterPixbufLoaderAreaPrepared obj cb = connectPixbufLoaderAreaPrepared obj cb SignalConnectAfter

connectPixbufLoaderAreaPrepared :: (GObject a, MonadIO m) =>
                                   a -> PixbufLoaderAreaPreparedCallback -> SignalConnectMode -> m SignalHandlerId
connectPixbufLoaderAreaPrepared obj cb after = liftIO $ do
    cb' <- mkPixbufLoaderAreaPreparedCallback (pixbufLoaderAreaPreparedCallbackWrapper cb)
    connectSignalFunPtr obj "area-prepared" cb' after

-- signal PixbufLoader::area-updated
type PixbufLoaderAreaUpdatedCallback =
    Int32 ->
    Int32 ->
    Int32 ->
    Int32 ->
    IO ()

noPixbufLoaderAreaUpdatedCallback :: Maybe PixbufLoaderAreaUpdatedCallback
noPixbufLoaderAreaUpdatedCallback = Nothing

type PixbufLoaderAreaUpdatedCallbackC =
    Ptr () ->                               -- object
    Int32 ->
    Int32 ->
    Int32 ->
    Int32 ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mkPixbufLoaderAreaUpdatedCallback :: PixbufLoaderAreaUpdatedCallbackC -> IO (FunPtr PixbufLoaderAreaUpdatedCallbackC)

pixbufLoaderAreaUpdatedClosure :: PixbufLoaderAreaUpdatedCallback -> IO Closure
pixbufLoaderAreaUpdatedClosure cb = newCClosure =<< mkPixbufLoaderAreaUpdatedCallback wrapped
    where wrapped = pixbufLoaderAreaUpdatedCallbackWrapper cb

pixbufLoaderAreaUpdatedCallbackWrapper ::
    PixbufLoaderAreaUpdatedCallback ->
    Ptr () ->
    Int32 ->
    Int32 ->
    Int32 ->
    Int32 ->
    Ptr () ->
    IO ()
pixbufLoaderAreaUpdatedCallbackWrapper _cb _ x y width height _ = do
    _cb  x y width height

onPixbufLoaderAreaUpdated :: (GObject a, MonadIO m) => a -> PixbufLoaderAreaUpdatedCallback -> m SignalHandlerId
onPixbufLoaderAreaUpdated obj cb = liftIO $ connectPixbufLoaderAreaUpdated obj cb SignalConnectBefore
afterPixbufLoaderAreaUpdated :: (GObject a, MonadIO m) => a -> PixbufLoaderAreaUpdatedCallback -> m SignalHandlerId
afterPixbufLoaderAreaUpdated obj cb = connectPixbufLoaderAreaUpdated obj cb SignalConnectAfter

connectPixbufLoaderAreaUpdated :: (GObject a, MonadIO m) =>
                                  a -> PixbufLoaderAreaUpdatedCallback -> SignalConnectMode -> m SignalHandlerId
connectPixbufLoaderAreaUpdated obj cb after = liftIO $ do
    cb' <- mkPixbufLoaderAreaUpdatedCallback (pixbufLoaderAreaUpdatedCallbackWrapper cb)
    connectSignalFunPtr obj "area-updated" cb' after

-- signal PixbufLoader::closed
type PixbufLoaderClosedCallback =
    IO ()

noPixbufLoaderClosedCallback :: Maybe PixbufLoaderClosedCallback
noPixbufLoaderClosedCallback = Nothing

type PixbufLoaderClosedCallbackC =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mkPixbufLoaderClosedCallback :: PixbufLoaderClosedCallbackC -> IO (FunPtr PixbufLoaderClosedCallbackC)

pixbufLoaderClosedClosure :: PixbufLoaderClosedCallback -> IO Closure
pixbufLoaderClosedClosure cb = newCClosure =<< mkPixbufLoaderClosedCallback wrapped
    where wrapped = pixbufLoaderClosedCallbackWrapper cb

pixbufLoaderClosedCallbackWrapper ::
    PixbufLoaderClosedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
pixbufLoaderClosedCallbackWrapper _cb _ _ = do
    _cb 

onPixbufLoaderClosed :: (GObject a, MonadIO m) => a -> PixbufLoaderClosedCallback -> m SignalHandlerId
onPixbufLoaderClosed obj cb = liftIO $ connectPixbufLoaderClosed obj cb SignalConnectBefore
afterPixbufLoaderClosed :: (GObject a, MonadIO m) => a -> PixbufLoaderClosedCallback -> m SignalHandlerId
afterPixbufLoaderClosed obj cb = connectPixbufLoaderClosed obj cb SignalConnectAfter

connectPixbufLoaderClosed :: (GObject a, MonadIO m) =>
                             a -> PixbufLoaderClosedCallback -> SignalConnectMode -> m SignalHandlerId
connectPixbufLoaderClosed obj cb after = liftIO $ do
    cb' <- mkPixbufLoaderClosedCallback (pixbufLoaderClosedCallbackWrapper cb)
    connectSignalFunPtr obj "closed" cb' after

-- signal PixbufLoader::size-prepared
type PixbufLoaderSizePreparedCallback =
    Int32 ->
    Int32 ->
    IO ()

noPixbufLoaderSizePreparedCallback :: Maybe PixbufLoaderSizePreparedCallback
noPixbufLoaderSizePreparedCallback = Nothing

type PixbufLoaderSizePreparedCallbackC =
    Ptr () ->                               -- object
    Int32 ->
    Int32 ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mkPixbufLoaderSizePreparedCallback :: PixbufLoaderSizePreparedCallbackC -> IO (FunPtr PixbufLoaderSizePreparedCallbackC)

pixbufLoaderSizePreparedClosure :: PixbufLoaderSizePreparedCallback -> IO Closure
pixbufLoaderSizePreparedClosure cb = newCClosure =<< mkPixbufLoaderSizePreparedCallback wrapped
    where wrapped = pixbufLoaderSizePreparedCallbackWrapper cb

pixbufLoaderSizePreparedCallbackWrapper ::
    PixbufLoaderSizePreparedCallback ->
    Ptr () ->
    Int32 ->
    Int32 ->
    Ptr () ->
    IO ()
pixbufLoaderSizePreparedCallbackWrapper _cb _ width height _ = do
    _cb  width height

onPixbufLoaderSizePrepared :: (GObject a, MonadIO m) => a -> PixbufLoaderSizePreparedCallback -> m SignalHandlerId
onPixbufLoaderSizePrepared obj cb = liftIO $ connectPixbufLoaderSizePrepared obj cb SignalConnectBefore
afterPixbufLoaderSizePrepared :: (GObject a, MonadIO m) => a -> PixbufLoaderSizePreparedCallback -> m SignalHandlerId
afterPixbufLoaderSizePrepared obj cb = connectPixbufLoaderSizePrepared obj cb SignalConnectAfter

connectPixbufLoaderSizePrepared :: (GObject a, MonadIO m) =>
                                   a -> PixbufLoaderSizePreparedCallback -> SignalConnectMode -> m SignalHandlerId
connectPixbufLoaderSizePrepared obj cb after = liftIO $ do
    cb' <- mkPixbufLoaderSizePreparedCallback (pixbufLoaderSizePreparedCallbackWrapper cb)
    connectSignalFunPtr obj "size-prepared" cb' after

type instance AttributeList PixbufLoader = PixbufLoaderAttributeList
type PixbufLoaderAttributeList = ('[ ] :: [(Symbol, *)])

data PixbufLoaderAreaPreparedSignalInfo
instance SignalInfo PixbufLoaderAreaPreparedSignalInfo where
    type HaskellCallbackType PixbufLoaderAreaPreparedSignalInfo = PixbufLoaderAreaPreparedCallback
    connectSignal _ = connectPixbufLoaderAreaPrepared

data PixbufLoaderAreaUpdatedSignalInfo
instance SignalInfo PixbufLoaderAreaUpdatedSignalInfo where
    type HaskellCallbackType PixbufLoaderAreaUpdatedSignalInfo = PixbufLoaderAreaUpdatedCallback
    connectSignal _ = connectPixbufLoaderAreaUpdated

data PixbufLoaderClosedSignalInfo
instance SignalInfo PixbufLoaderClosedSignalInfo where
    type HaskellCallbackType PixbufLoaderClosedSignalInfo = PixbufLoaderClosedCallback
    connectSignal _ = connectPixbufLoaderClosed

data PixbufLoaderSizePreparedSignalInfo
instance SignalInfo PixbufLoaderSizePreparedSignalInfo where
    type HaskellCallbackType PixbufLoaderSizePreparedSignalInfo = PixbufLoaderSizePreparedCallback
    connectSignal _ = connectPixbufLoaderSizePrepared

type instance SignalList PixbufLoader = PixbufLoaderSignalList
type PixbufLoaderSignalList = ('[ '("area-prepared", PixbufLoaderAreaPreparedSignalInfo), '("area-updated", PixbufLoaderAreaUpdatedSignalInfo), '("closed", PixbufLoaderClosedSignalInfo), '("notify", GObject.ObjectNotifySignalInfo), '("size-prepared", PixbufLoaderSizePreparedSignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method PixbufLoader::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "GdkPixbuf" "PixbufLoader"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_pixbuf_loader_new" gdk_pixbuf_loader_new :: 
    IO (Ptr PixbufLoader)


pixbufLoaderNew ::
    (MonadIO m) =>
    m PixbufLoader
pixbufLoaderNew  = liftIO $ do
    result <- gdk_pixbuf_loader_new
    checkUnexpectedReturnNULL "gdk_pixbuf_loader_new" result
    result' <- (wrapObject PixbufLoader) result
    return result'

-- method PixbufLoader::new_with_mime_type
-- method type : Constructor
-- Args : [Arg {argName = "mime_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "mime_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "GdkPixbuf" "PixbufLoader"
-- throws : True
-- Skip return : False

foreign import ccall "gdk_pixbuf_loader_new_with_mime_type" gdk_pixbuf_loader_new_with_mime_type :: 
    CString ->                              -- mime_type : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr PixbufLoader)


pixbufLoaderNewWithMimeType ::
    (MonadIO m) =>
    T.Text ->                               -- mime_type
    m PixbufLoader
pixbufLoaderNewWithMimeType mime_type = liftIO $ do
    mime_type' <- textToCString mime_type
    onException (do
        result <- propagateGError $ gdk_pixbuf_loader_new_with_mime_type mime_type'
        checkUnexpectedReturnNULL "gdk_pixbuf_loader_new_with_mime_type" result
        result' <- (wrapObject PixbufLoader) result
        freeMem mime_type'
        return result'
     ) (do
        freeMem mime_type'
     )

-- method PixbufLoader::new_with_type
-- method type : Constructor
-- Args : [Arg {argName = "image_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "image_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "GdkPixbuf" "PixbufLoader"
-- throws : True
-- Skip return : False

foreign import ccall "gdk_pixbuf_loader_new_with_type" gdk_pixbuf_loader_new_with_type :: 
    CString ->                              -- image_type : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr PixbufLoader)


pixbufLoaderNewWithType ::
    (MonadIO m) =>
    T.Text ->                               -- image_type
    m PixbufLoader
pixbufLoaderNewWithType image_type = liftIO $ do
    image_type' <- textToCString image_type
    onException (do
        result <- propagateGError $ gdk_pixbuf_loader_new_with_type image_type'
        checkUnexpectedReturnNULL "gdk_pixbuf_loader_new_with_type" result
        result' <- (wrapObject PixbufLoader) result
        freeMem image_type'
        return result'
     ) (do
        freeMem image_type'
     )

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

foreign import ccall "gdk_pixbuf_loader_close" gdk_pixbuf_loader_close :: 
    Ptr PixbufLoader ->                     -- _obj : TInterface "GdkPixbuf" "PixbufLoader"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


pixbufLoaderClose ::
    (MonadIO m, PixbufLoaderK a) =>
    a ->                                    -- _obj
    m ()
pixbufLoaderClose _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    onException (do
        _ <- propagateGError $ gdk_pixbuf_loader_close _obj'
        touchManagedPtr _obj
        return ()
     ) (do
        return ()
     )

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

foreign import ccall "gdk_pixbuf_loader_get_animation" gdk_pixbuf_loader_get_animation :: 
    Ptr PixbufLoader ->                     -- _obj : TInterface "GdkPixbuf" "PixbufLoader"
    IO (Ptr PixbufAnimation)


pixbufLoaderGetAnimation ::
    (MonadIO m, PixbufLoaderK a) =>
    a ->                                    -- _obj
    m PixbufAnimation
pixbufLoaderGetAnimation _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_pixbuf_loader_get_animation _obj'
    checkUnexpectedReturnNULL "gdk_pixbuf_loader_get_animation" result
    result' <- (newObject PixbufAnimation) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "gdk_pixbuf_loader_get_format" gdk_pixbuf_loader_get_format :: 
    Ptr PixbufLoader ->                     -- _obj : TInterface "GdkPixbuf" "PixbufLoader"
    IO (Ptr PixbufFormat)


pixbufLoaderGetFormat ::
    (MonadIO m, PixbufLoaderK a) =>
    a ->                                    -- _obj
    m PixbufFormat
pixbufLoaderGetFormat _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_pixbuf_loader_get_format _obj'
    checkUnexpectedReturnNULL "gdk_pixbuf_loader_get_format" result
    result' <- (newBoxed PixbufFormat) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "gdk_pixbuf_loader_get_pixbuf" gdk_pixbuf_loader_get_pixbuf :: 
    Ptr PixbufLoader ->                     -- _obj : TInterface "GdkPixbuf" "PixbufLoader"
    IO (Ptr Pixbuf)


pixbufLoaderGetPixbuf ::
    (MonadIO m, PixbufLoaderK a) =>
    a ->                                    -- _obj
    m Pixbuf
pixbufLoaderGetPixbuf _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_pixbuf_loader_get_pixbuf _obj'
    checkUnexpectedReturnNULL "gdk_pixbuf_loader_get_pixbuf" result
    result' <- (newObject Pixbuf) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "gdk_pixbuf_loader_set_size" gdk_pixbuf_loader_set_size :: 
    Ptr PixbufLoader ->                     -- _obj : TInterface "GdkPixbuf" "PixbufLoader"
    Int32 ->                                -- width : TBasicType TInt32
    Int32 ->                                -- height : TBasicType TInt32
    IO ()


pixbufLoaderSetSize ::
    (MonadIO m, PixbufLoaderK a) =>
    a ->                                    -- _obj
    Int32 ->                                -- width
    Int32 ->                                -- height
    m ()
pixbufLoaderSetSize _obj width height = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    gdk_pixbuf_loader_set_size _obj' width height
    touchManagedPtr _obj
    return ()

-- method PixbufLoader::write
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GdkPixbuf" "PixbufLoader", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buf", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "count", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "count", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GdkPixbuf" "PixbufLoader", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buf", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "gdk_pixbuf_loader_write" gdk_pixbuf_loader_write :: 
    Ptr PixbufLoader ->                     -- _obj : TInterface "GdkPixbuf" "PixbufLoader"
    Ptr Word8 ->                            -- buf : TCArray False (-1) 2 (TBasicType TUInt8)
    Word64 ->                               -- count : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO CInt


pixbufLoaderWrite ::
    (MonadIO m, PixbufLoaderK a) =>
    a ->                                    -- _obj
    ByteString ->                           -- buf
    m ()
pixbufLoaderWrite _obj buf = liftIO $ do
    let count = fromIntegral $ B.length buf
    let _obj' = unsafeManagedPtrCastPtr _obj
    buf' <- packByteString buf
    onException (do
        _ <- propagateGError $ gdk_pixbuf_loader_write _obj' buf' count
        touchManagedPtr _obj
        freeMem buf'
        return ()
     ) (do
        freeMem buf'
     )

-- method PixbufLoader::write_bytes
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GdkPixbuf" "PixbufLoader", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TInterface "GLib" "Bytes", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GdkPixbuf" "PixbufLoader", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TInterface "GLib" "Bytes", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "gdk_pixbuf_loader_write_bytes" gdk_pixbuf_loader_write_bytes :: 
    Ptr PixbufLoader ->                     -- _obj : TInterface "GdkPixbuf" "PixbufLoader"
    Ptr GLib.Bytes ->                       -- buffer : TInterface "GLib" "Bytes"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


pixbufLoaderWriteBytes ::
    (MonadIO m, PixbufLoaderK a) =>
    a ->                                    -- _obj
    GLib.Bytes ->                           -- buffer
    m ()
pixbufLoaderWriteBytes _obj buffer = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let buffer' = unsafeManagedPtrGetPtr buffer
    onException (do
        _ <- propagateGError $ gdk_pixbuf_loader_write_bytes _obj' buffer'
        touchManagedPtr _obj
        touchManagedPtr buffer
        return ()
     ) (do
        return ()
     )