-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.GdkPixbuf.Callbacks
    ( 

 -- * Signals
-- ** PixbufDestroyNotify #signal:PixbufDestroyNotify#

    C_PixbufDestroyNotify                   ,
    PixbufDestroyNotify                     ,
    PixbufDestroyNotify_WithClosures        ,
    drop_closures_PixbufDestroyNotify       ,
    dynamic_PixbufDestroyNotify             ,
    genClosure_PixbufDestroyNotify          ,
    mk_PixbufDestroyNotify                  ,
    noPixbufDestroyNotify                   ,
    noPixbufDestroyNotify_WithClosures      ,
    wrap_PixbufDestroyNotify                ,


-- ** PixbufSaveFunc #signal:PixbufSaveFunc#

    C_PixbufSaveFunc                        ,
    PixbufSaveFunc                          ,
    PixbufSaveFunc_WithClosures             ,
    drop_closures_PixbufSaveFunc            ,
    dynamic_PixbufSaveFunc                  ,
    genClosure_PixbufSaveFunc               ,
    mk_PixbufSaveFunc                       ,
    noPixbufSaveFunc                        ,
    noPixbufSaveFunc_WithClosures           ,
    wrap_PixbufSaveFunc                     ,




    ) 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.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


-- callback PixbufSaveFunc
{- Callable
  { returnType = Just (TBasicType TBoolean)
  , returnMayBeNull = False
  , returnTransfer = TransferNothing
  , returnDocumentation =
      Documentation
        { rawDocText =
            Just "%TRUE if successful, %FALSE (with @error set) if failed."
        , sinceVersion = Nothing
        }
  , args =
      [ Arg
          { argCName = "buf"
          , argType = TCArray False (-1) 1 (TBasicType TUInt8)
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "bytes to be written."
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "count"
          , argType = TBasicType TUInt64
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "number of bytes in @buf."
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "error"
          , argType = TError
          , direction = DirectionOut
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "A location to return an error."
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , transfer = TransferEverything
          }
      , Arg
          { argCName = "data"
          , argType = TBasicType TPtr
          , direction = DirectionIn
          , mayBeNull = True
          , argDoc =
              Documentation
                { rawDocText =
                    Just "user data passed to gdk_pixbuf_save_to_callback()."
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = 3
          , argDestroy = -1
          , argCallerAllocates = False
          , transfer = TransferNothing
          }
      ]
  , skipReturn = False
  , callableThrows = False
  , callableDeprecated = Nothing
  , callableDocumentation =
      Documentation
        { rawDocText =
            Just
              "Specifies the type of the function passed to\ngdk_pixbuf_save_to_callback().  It is called once for each block of\nbytes that is \"written\" by gdk_pixbuf_save_to_callback().  If\nsuccessful it should return %TRUE.  If an error occurs it should set\n@error and return %FALSE, in which case gdk_pixbuf_save_to_callback()\nwill fail with the same error."
        , sinceVersion = Just "2.4"
        }
  , callableResolvable = Nothing
  }
-}
-- | Type for the callback on the (unwrapped) C side.
type C_PixbufSaveFunc =
    Ptr Word8 ->
    Word64 ->
    Ptr (Ptr GError) ->
    Ptr () ->
    IO CInt

-- Args: [ Arg
--           { argCName = "buf"
--           , argType = TCArray False (-1) 1 (TBasicType TUInt8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "bytes to be written."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "count"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "number of bytes in @buf."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "error"
--           , argType = TError
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A location to return an error."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "user data passed to gdk_pixbuf_save_to_callback()."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = 3
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "count"
--              , argType = TBasicType TUInt64
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "number of bytes in @buf."
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_PixbufSaveFunc :: FunPtr C_PixbufSaveFunc -> C_PixbufSaveFunc

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_PixbufSaveFunc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_PixbufSaveFunc
    -> ByteString
    -- ^ /@buf@/: bytes to be written.
    -> Ptr ()
    -- ^ /@data@/: user data passed to @/gdk_pixbuf_save_to_callback()/@.
    -> m ((Bool, GError))
    -- ^ __Returns:__ 'P.True' if successful, 'P.False' (with /@error@/ set) if failed.
dynamic_PixbufSaveFunc :: FunPtr C_PixbufSaveFunc -> ByteString -> Ptr () -> m (Bool, GError)
dynamic_PixbufSaveFunc FunPtr C_PixbufSaveFunc
__funPtr ByteString
buf Ptr ()
data_ = IO (Bool, GError) -> m (Bool, GError)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, GError) -> m (Bool, GError))
-> IO (Bool, GError) -> m (Bool, GError)
forall a b. (a -> b) -> a -> b
$ do
    let count :: Word64
count = Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
buf
    Ptr Word8
buf' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
buf
    Ptr (Ptr GError)
error_ <- IO (Ptr (Ptr GError))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (Ptr GError))
    CInt
result <- (FunPtr C_PixbufSaveFunc -> C_PixbufSaveFunc
__dynamic_C_PixbufSaveFunc FunPtr C_PixbufSaveFunc
__funPtr) Ptr Word8
buf' Word64
count Ptr (Ptr GError)
error_ Ptr ()
data_
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Ptr GError
error_' <- Ptr (Ptr GError) -> IO (Ptr GError)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr GError)
error_
    GError
error_'' <- ((ManagedPtr GError -> GError) -> Ptr GError -> IO GError
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr GError -> GError
GError) Ptr GError
error_'
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buf'
    Ptr (Ptr GError) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr GError)
error_
    (Bool, GError) -> IO (Bool, GError)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', GError
error_'')

-- | Generate a function pointer callable from C code, from a `C_PixbufSaveFunc`.
foreign import ccall "wrapper"
    mk_PixbufSaveFunc :: C_PixbufSaveFunc -> IO (FunPtr C_PixbufSaveFunc)

-- | Specifies the type of the function passed to
-- @/gdk_pixbuf_save_to_callback()/@.  It is called once for each block of
-- bytes that is \"written\" by @/gdk_pixbuf_save_to_callback()/@.  If
-- successful it should return 'P.True'.  If an error occurs it should set
-- /@error@/ and return 'P.False', in which case @/gdk_pixbuf_save_to_callback()/@
-- will fail with the same error.
-- 
-- /Since: 2.4/
type PixbufSaveFunc =
    ByteString
    -- ^ /@buf@/: bytes to be written.
    -> IO ((Bool, GError))
    -- ^ __Returns:__ 'P.True' if successful, 'P.False' (with /@error@/ set) if failed.

-- | A convenience synonym for @`Nothing` :: `Maybe` `PixbufSaveFunc`@.
noPixbufSaveFunc :: Maybe PixbufSaveFunc
noPixbufSaveFunc :: Maybe PixbufSaveFunc
noPixbufSaveFunc = Maybe PixbufSaveFunc
forall a. Maybe a
Nothing

-- | Specifies the type of the function passed to
-- @/gdk_pixbuf_save_to_callback()/@.  It is called once for each block of
-- bytes that is \"written\" by @/gdk_pixbuf_save_to_callback()/@.  If
-- successful it should return 'P.True'.  If an error occurs it should set
-- /@error@/ and return 'P.False', in which case @/gdk_pixbuf_save_to_callback()/@
-- will fail with the same error.
-- 
-- /Since: 2.4/
type PixbufSaveFunc_WithClosures =
    ByteString
    -- ^ /@buf@/: bytes to be written.
    -> Ptr ()
    -- ^ /@data@/: user data passed to @/gdk_pixbuf_save_to_callback()/@.
    -> IO ((Bool, GError))
    -- ^ __Returns:__ 'P.True' if successful, 'P.False' (with /@error@/ set) if failed.

-- | A convenience synonym for @`Nothing` :: `Maybe` `PixbufSaveFunc_WithClosures`@.
noPixbufSaveFunc_WithClosures :: Maybe PixbufSaveFunc_WithClosures
noPixbufSaveFunc_WithClosures :: Maybe PixbufSaveFunc_WithClosures
noPixbufSaveFunc_WithClosures = Maybe PixbufSaveFunc_WithClosures
forall a. Maybe a
Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_PixbufSaveFunc :: PixbufSaveFunc -> PixbufSaveFunc_WithClosures
drop_closures_PixbufSaveFunc :: PixbufSaveFunc -> PixbufSaveFunc_WithClosures
drop_closures_PixbufSaveFunc PixbufSaveFunc
_f ByteString
buf Ptr ()
_ = PixbufSaveFunc
_f ByteString
buf

-- | Wrap the callback into a `GClosure`.
genClosure_PixbufSaveFunc :: MonadIO m => PixbufSaveFunc -> m (GClosure C_PixbufSaveFunc)
genClosure_PixbufSaveFunc :: PixbufSaveFunc -> m (GClosure C_PixbufSaveFunc)
genClosure_PixbufSaveFunc PixbufSaveFunc
cb = IO (GClosure C_PixbufSaveFunc) -> m (GClosure C_PixbufSaveFunc)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_PixbufSaveFunc) -> m (GClosure C_PixbufSaveFunc))
-> IO (GClosure C_PixbufSaveFunc) -> m (GClosure C_PixbufSaveFunc)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: PixbufSaveFunc_WithClosures
cb' = PixbufSaveFunc -> PixbufSaveFunc_WithClosures
drop_closures_PixbufSaveFunc PixbufSaveFunc
cb
    let cb'' :: C_PixbufSaveFunc
cb'' = Maybe (Ptr (FunPtr C_PixbufSaveFunc))
-> PixbufSaveFunc_WithClosures -> C_PixbufSaveFunc
wrap_PixbufSaveFunc Maybe (Ptr (FunPtr C_PixbufSaveFunc))
forall a. Maybe a
Nothing PixbufSaveFunc_WithClosures
cb'
    C_PixbufSaveFunc -> IO (FunPtr C_PixbufSaveFunc)
mk_PixbufSaveFunc C_PixbufSaveFunc
cb'' IO (FunPtr C_PixbufSaveFunc)
-> (FunPtr C_PixbufSaveFunc -> IO (GClosure C_PixbufSaveFunc))
-> IO (GClosure C_PixbufSaveFunc)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_PixbufSaveFunc -> IO (GClosure C_PixbufSaveFunc)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `PixbufSaveFunc` into a `C_PixbufSaveFunc`.
wrap_PixbufSaveFunc ::
    Maybe (Ptr (FunPtr C_PixbufSaveFunc)) ->
    PixbufSaveFunc_WithClosures ->
    C_PixbufSaveFunc
wrap_PixbufSaveFunc :: Maybe (Ptr (FunPtr C_PixbufSaveFunc))
-> PixbufSaveFunc_WithClosures -> C_PixbufSaveFunc
wrap_PixbufSaveFunc Maybe (Ptr (FunPtr C_PixbufSaveFunc))
funptrptr PixbufSaveFunc_WithClosures
_cb Ptr Word8
buf Word64
count Ptr (Ptr GError)
error_ Ptr ()
data_ = do
    ByteString
buf' <- (Word64 -> Ptr Word8 -> IO ByteString
forall a. Integral a => a -> Ptr Word8 -> IO ByteString
unpackByteStringWithLength Word64
count) Ptr Word8
buf
    (Bool
result, GError
outerror_) <- PixbufSaveFunc_WithClosures
_cb  ByteString
buf' Ptr ()
data_
    Ptr GError
outerror_' <- GError -> IO (Ptr GError)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed GError
outerror_
    Ptr (Ptr GError) -> Ptr GError -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (Ptr GError)
error_ Ptr GError
outerror_'
    Maybe (Ptr (FunPtr C_PixbufSaveFunc)) -> IO ()
forall a. Maybe (Ptr (FunPtr a)) -> IO ()
maybeReleaseFunPtr Maybe (Ptr (FunPtr C_PixbufSaveFunc))
funptrptr
    let result' :: CInt
result' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
result
    CInt -> IO CInt
forall (m :: * -> *) a. Monad m => a -> m a
return CInt
result'


-- callback PixbufDestroyNotify
{- Callable
  { returnType = Nothing
  , returnMayBeNull = False
  , returnTransfer = TransferNothing
  , returnDocumentation =
      Documentation { rawDocText = Nothing , sinceVersion = Nothing }
  , args =
      [ Arg
          { argCName = "pixels"
          , argType = TCArray False (-1) (-1) (TBasicType TUInt8)
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText =
                    Just "The pixel array of the pixbuf\n  that is being finalized."
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "data"
          , argType = TBasicType TPtr
          , direction = DirectionIn
          , mayBeNull = True
          , argDoc =
              Documentation
                { rawDocText = Just "User closure data." , sinceVersion = Nothing }
          , argScope = ScopeTypeInvalid
          , argClosure = 1
          , argDestroy = -1
          , argCallerAllocates = False
          , transfer = TransferNothing
          }
      ]
  , skipReturn = False
  , callableThrows = False
  , callableDeprecated = Nothing
  , callableDocumentation =
      Documentation
        { rawDocText =
            Just
              "A function of this type is responsible for freeing the pixel array\nof a pixbuf.  The gdk_pixbuf_new_from_data() function lets you\npass in a pre-allocated pixel array so that a pixbuf can be\ncreated from it; in this case you will need to pass in a function\nof #GdkPixbufDestroyNotify so that the pixel data can be freed\nwhen the pixbuf is finalized."
        , sinceVersion = Nothing
        }
  , callableResolvable = Nothing
  }
-}
-- | Type for the callback on the (unwrapped) C side.
type C_PixbufDestroyNotify =
    Ptr Word8 ->
    Ptr () ->
    IO ()

-- Args: [ Arg
--           { argCName = "pixels"
--           , argType = TCArray False (-1) (-1) (TBasicType TUInt8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "The pixel array of the pixbuf\n  that is being finalized."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "User closure data." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = 1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_PixbufDestroyNotify :: FunPtr C_PixbufDestroyNotify -> C_PixbufDestroyNotify

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_PixbufDestroyNotify ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_PixbufDestroyNotify
    -> Ptr Word8
    -- ^ /@pixels@/: The pixel array of the pixbuf
    --   that is being finalized.
    -> Ptr ()
    -- ^ /@data@/: User closure data.
    -> m ()
dynamic_PixbufDestroyNotify :: FunPtr C_PixbufDestroyNotify -> Ptr Word8 -> Ptr () -> m ()
dynamic_PixbufDestroyNotify FunPtr C_PixbufDestroyNotify
__funPtr Ptr Word8
pixels Ptr ()
data_ = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    (FunPtr C_PixbufDestroyNotify -> C_PixbufDestroyNotify
__dynamic_C_PixbufDestroyNotify FunPtr C_PixbufDestroyNotify
__funPtr) Ptr Word8
pixels Ptr ()
data_
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

-- | Generate a function pointer callable from C code, from a `C_PixbufDestroyNotify`.
foreign import ccall "wrapper"
    mk_PixbufDestroyNotify :: C_PixbufDestroyNotify -> IO (FunPtr C_PixbufDestroyNotify)

-- | A function of this type is responsible for freeing the pixel array
-- of a pixbuf.  The 'GI.GdkPixbuf.Objects.Pixbuf.pixbufNewFromData' function lets you
-- pass in a pre-allocated pixel array so that a pixbuf can be
-- created from it; in this case you will need to pass in a function
-- of t'GI.GdkPixbuf.Callbacks.PixbufDestroyNotify' so that the pixel data can be freed
-- when the pixbuf is finalized.
type PixbufDestroyNotify =
    Ptr Word8
    -- ^ /@pixels@/: The pixel array of the pixbuf
    --   that is being finalized.
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `PixbufDestroyNotify`@.
noPixbufDestroyNotify :: Maybe PixbufDestroyNotify
noPixbufDestroyNotify :: Maybe (Ptr Word8 -> IO ())
noPixbufDestroyNotify = Maybe (Ptr Word8 -> IO ())
forall a. Maybe a
Nothing

-- | A function of this type is responsible for freeing the pixel array
-- of a pixbuf.  The 'GI.GdkPixbuf.Objects.Pixbuf.pixbufNewFromData' function lets you
-- pass in a pre-allocated pixel array so that a pixbuf can be
-- created from it; in this case you will need to pass in a function
-- of t'GI.GdkPixbuf.Callbacks.PixbufDestroyNotify' so that the pixel data can be freed
-- when the pixbuf is finalized.
type PixbufDestroyNotify_WithClosures =
    Ptr Word8
    -- ^ /@pixels@/: The pixel array of the pixbuf
    --   that is being finalized.
    -> Ptr ()
    -- ^ /@data@/: User closure data.
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `PixbufDestroyNotify_WithClosures`@.
noPixbufDestroyNotify_WithClosures :: Maybe PixbufDestroyNotify_WithClosures
noPixbufDestroyNotify_WithClosures :: Maybe C_PixbufDestroyNotify
noPixbufDestroyNotify_WithClosures = Maybe C_PixbufDestroyNotify
forall a. Maybe a
Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_PixbufDestroyNotify :: PixbufDestroyNotify -> PixbufDestroyNotify_WithClosures
drop_closures_PixbufDestroyNotify :: (Ptr Word8 -> IO ()) -> C_PixbufDestroyNotify
drop_closures_PixbufDestroyNotify Ptr Word8 -> IO ()
_f Ptr Word8
pixels Ptr ()
_ = Ptr Word8 -> IO ()
_f Ptr Word8
pixels

-- | Wrap the callback into a `GClosure`.
genClosure_PixbufDestroyNotify :: MonadIO m => PixbufDestroyNotify -> m (GClosure C_PixbufDestroyNotify)
genClosure_PixbufDestroyNotify :: (Ptr Word8 -> IO ()) -> m (GClosure C_PixbufDestroyNotify)
genClosure_PixbufDestroyNotify Ptr Word8 -> IO ()
cb = IO (GClosure C_PixbufDestroyNotify)
-> m (GClosure C_PixbufDestroyNotify)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_PixbufDestroyNotify)
 -> m (GClosure C_PixbufDestroyNotify))
-> IO (GClosure C_PixbufDestroyNotify)
-> m (GClosure C_PixbufDestroyNotify)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_PixbufDestroyNotify
cb' = (Ptr Word8 -> IO ()) -> C_PixbufDestroyNotify
drop_closures_PixbufDestroyNotify Ptr Word8 -> IO ()
cb
    let cb'' :: C_PixbufDestroyNotify
cb'' = Maybe (Ptr (FunPtr C_PixbufDestroyNotify))
-> C_PixbufDestroyNotify -> C_PixbufDestroyNotify
wrap_PixbufDestroyNotify Maybe (Ptr (FunPtr C_PixbufDestroyNotify))
forall a. Maybe a
Nothing C_PixbufDestroyNotify
cb'
    C_PixbufDestroyNotify -> IO (FunPtr C_PixbufDestroyNotify)
mk_PixbufDestroyNotify C_PixbufDestroyNotify
cb'' IO (FunPtr C_PixbufDestroyNotify)
-> (FunPtr C_PixbufDestroyNotify
    -> IO (GClosure C_PixbufDestroyNotify))
-> IO (GClosure C_PixbufDestroyNotify)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_PixbufDestroyNotify -> IO (GClosure C_PixbufDestroyNotify)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `PixbufDestroyNotify` into a `C_PixbufDestroyNotify`.
wrap_PixbufDestroyNotify ::
    Maybe (Ptr (FunPtr C_PixbufDestroyNotify)) ->
    PixbufDestroyNotify_WithClosures ->
    C_PixbufDestroyNotify
wrap_PixbufDestroyNotify :: Maybe (Ptr (FunPtr C_PixbufDestroyNotify))
-> C_PixbufDestroyNotify -> C_PixbufDestroyNotify
wrap_PixbufDestroyNotify Maybe (Ptr (FunPtr C_PixbufDestroyNotify))
funptrptr C_PixbufDestroyNotify
_cb Ptr Word8
pixels Ptr ()
data_ = do
    C_PixbufDestroyNotify
_cb  Ptr Word8
pixels Ptr ()
data_
    Maybe (Ptr (FunPtr C_PixbufDestroyNotify)) -> IO ()
forall a. Maybe (Ptr (FunPtr a)) -> IO ()
maybeReleaseFunPtr Maybe (Ptr (FunPtr C_PixbufDestroyNotify))
funptrptr