-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- 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.Gdk.Callbacks
    ( 

 -- * Signals


-- ** ContentDeserializeFunc #signal:ContentDeserializeFunc#

    C_ContentDeserializeFunc                ,
    ContentDeserializeFunc                  ,
    dynamic_ContentDeserializeFunc          ,
    genClosure_ContentDeserializeFunc       ,
    mk_ContentDeserializeFunc               ,
    noContentDeserializeFunc                ,
    wrap_ContentDeserializeFunc             ,


-- ** ContentSerializeFunc #signal:ContentSerializeFunc#

    C_ContentSerializeFunc                  ,
    ContentSerializeFunc                    ,
    dynamic_ContentSerializeFunc            ,
    genClosure_ContentSerializeFunc         ,
    mk_ContentSerializeFunc                 ,
    noContentSerializeFunc                  ,
    wrap_ContentSerializeFunc               ,


-- ** CursorGetTextureCallback #signal:CursorGetTextureCallback#

    C_CursorGetTextureCallback              ,
    CursorGetTextureCallback                ,
    dynamic_CursorGetTextureCallback        ,
    genClosure_CursorGetTextureCallback     ,
    mk_CursorGetTextureCallback             ,
    noCursorGetTextureCallback              ,
    wrap_CursorGetTextureCallback           ,




    ) 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.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gdk.Enums as Gdk.Enums
import {-# SOURCE #-} qualified GI.Gdk.Flags as Gdk.Flags
import {-# SOURCE #-} qualified GI.Gdk.Interfaces.Paintable as Gdk.Paintable
import {-# SOURCE #-} qualified GI.Gdk.Objects.CicpParams as Gdk.CicpParams
import {-# SOURCE #-} qualified GI.Gdk.Objects.ContentDeserializer as Gdk.ContentDeserializer
import {-# SOURCE #-} qualified GI.Gdk.Objects.ContentSerializer as Gdk.ContentSerializer
import {-# SOURCE #-} qualified GI.Gdk.Objects.Cursor as Gdk.Cursor
import {-# SOURCE #-} qualified GI.Gdk.Objects.Snapshot as Gdk.Snapshot
import {-# SOURCE #-} qualified GI.Gdk.Objects.Texture as Gdk.Texture
import {-# SOURCE #-} qualified GI.Gdk.Structs.ColorState as Gdk.ColorState
import qualified GI.GdkPixbuf.Objects.Pixbuf as GdkPixbuf.Pixbuf
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Interfaces.File as Gio.File
import qualified GI.Gio.Interfaces.Icon as Gio.Icon
import qualified GI.Gio.Interfaces.LoadableIcon as Gio.LoadableIcon
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Gio.Objects.InputStream as Gio.InputStream
import qualified GI.Gio.Objects.OutputStream as Gio.OutputStream

#else
import {-# SOURCE #-} qualified GI.Gdk.Objects.ContentDeserializer as Gdk.ContentDeserializer
import {-# SOURCE #-} qualified GI.Gdk.Objects.ContentSerializer as Gdk.ContentSerializer
import {-# SOURCE #-} qualified GI.Gdk.Objects.Cursor as Gdk.Cursor
import {-# SOURCE #-} qualified GI.Gdk.Objects.Texture as Gdk.Texture

#endif

-- callback CursorGetTextureCallback
{- Callable
  { returnType =
      Just (TInterface Name { namespace = "Gdk" , name = "Texture" })
  , returnMayBeNull = True
  , returnTransfer = TransferEverything
  , returnDocumentation =
      Documentation
        { rawDocText =
            Just "the cursor image, or\n  `NULL` if none could be produced."
        , sinceVersion = Nothing
        }
  , args =
      [ Arg
          { argCName = "cursor"
          , argType = TInterface Name { namespace = "Gdk" , name = "Cursor" }
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "the `GdkCursor`" , sinceVersion = Nothing }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "cursor_size"
          , argType = TBasicType TInt
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText =
                    Just "the nominal cursor size, in application pixels"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "scale"
          , argType = TBasicType TDouble
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "the device scale" , sinceVersion = Nothing }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "width"
          , argType = TBasicType TInt
          , direction = DirectionOut
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText =
                    Just
                      "return location for the actual cursor width,\n  in application pixels"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferEverything
          }
      , Arg
          { argCName = "height"
          , argType = TBasicType TInt
          , direction = DirectionOut
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText =
                    Just
                      "return location for the actual cursor height,\n  in application pixels"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferEverything
          }
      , Arg
          { argCName = "hotspot_x"
          , argType = TBasicType TInt
          , direction = DirectionOut
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText =
                    Just
                      "return location for the hotspot X position,\n  in application pixels"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferEverything
          }
      , Arg
          { argCName = "hotspot_y"
          , argType = TBasicType TInt
          , direction = DirectionOut
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText =
                    Just
                      "return location for the hotspot Y position,\n  in application pixels"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferEverything
          }
      , Arg
          { argCName = "data"
          , argType = TBasicType TPtr
          , direction = DirectionIn
          , mayBeNull = True
          , argDoc =
              Documentation
                { rawDocText = Just "User data for the callback"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      ]
  , skipReturn = False
  , callableThrows = False
  , callableDeprecated = Nothing
  , callableDocumentation =
      Documentation
        { rawDocText =
            Just
              "The type of callback used by a dynamic `GdkCursor` to generate\na texture for the cursor image at the given @cursor_size\nand @scale.\n\nThe actual cursor size in application pixels may be different\nfrom @cursor_size x @cursor_size, and will be returned in\n@width, @height. The returned texture should have a size that\ncorresponds to the actual cursor size, in device pixels (i.e.\napplication pixels, multiplied by @scale).\n\nThis function may fail and return `NULL`, in which case\nthe fallback cursor will be used."
        , sinceVersion = Nothing
        }
  , callableResolvable = Nothing
  }
-}
-- | Type for the callback on the (unwrapped) C side.
type C_CursorGetTextureCallback =
    Ptr Gdk.Cursor.Cursor ->
    Int32 ->
    CDouble ->
    Ptr Int32 ->
    Ptr Int32 ->
    Ptr Int32 ->
    Ptr Int32 ->
    Ptr () ->
    IO (Ptr Gdk.Texture.Texture)

-- Args: [ Arg
--           { argCName = "cursor"
--           , argType = TInterface Name { namespace = "Gdk" , name = "Cursor" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the `GdkCursor`" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "cursor_size"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the nominal cursor size, in application pixels"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "scale"
--           , argType = TBasicType TDouble
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the device scale" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "width"
--           , argType = TBasicType TInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "return location for the actual cursor width,\n  in application pixels"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "height"
--           , argType = TBasicType TInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "return location for the actual cursor height,\n  in application pixels"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "hotspot_x"
--           , argType = TBasicType TInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "return location for the hotspot X position,\n  in application pixels"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "hotspot_y"
--           , argType = TBasicType TInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "return location for the hotspot Y position,\n  in application pixels"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "User data for the callback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gdk" , name = "Texture" })
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_CursorGetTextureCallback :: FunPtr C_CursorGetTextureCallback -> C_CursorGetTextureCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_CursorGetTextureCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Gdk.Cursor.IsCursor a) =>
    FunPtr C_CursorGetTextureCallback
    -> a
    -- ^ /@cursor@/: the @GdkCursor@
    -> Int32
    -- ^ /@cursorSize@/: the nominal cursor size, in application pixels
    -> Double
    -- ^ /@scale@/: the device scale
    -> Ptr ()
    -- ^ /@data@/: User data for the callback
    -> m ((Maybe Gdk.Texture.Texture, Int32, Int32, Int32, Int32))
    -- ^ __Returns:__ the cursor image, or
    --   @NULL@ if none could be produced.
dynamic_CursorGetTextureCallback :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCursor a) =>
FunPtr C_CursorGetTextureCallback
-> a
-> Int32
-> Double
-> Ptr ()
-> m (Maybe Texture, Int32, Int32, Int32, Int32)
dynamic_CursorGetTextureCallback FunPtr C_CursorGetTextureCallback
__funPtr a
cursor Int32
cursorSize Double
scale Ptr ()
data_ = IO (Maybe Texture, Int32, Int32, Int32, Int32)
-> m (Maybe Texture, Int32, Int32, Int32, Int32)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Texture, Int32, Int32, Int32, Int32)
 -> m (Maybe Texture, Int32, Int32, Int32, Int32))
-> IO (Maybe Texture, Int32, Int32, Int32, Int32)
-> m (Maybe Texture, Int32, Int32, Int32, Int32)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Cursor
cursor' <- a -> IO (Ptr Cursor)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cursor
    let scale' :: CDouble
scale' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
scale
    Ptr Int32
width <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr Int32
height <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr Int32
hotspotX <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr Int32
hotspotY <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr Texture
result <- (FunPtr C_CursorGetTextureCallback -> C_CursorGetTextureCallback
__dynamic_C_CursorGetTextureCallback FunPtr C_CursorGetTextureCallback
__funPtr) Ptr Cursor
cursor' Int32
cursorSize CDouble
scale' Ptr Int32
width Ptr Int32
height Ptr Int32
hotspotX Ptr Int32
hotspotY Ptr ()
data_
    Maybe Texture
maybeResult <- Ptr Texture -> (Ptr Texture -> IO Texture) -> IO (Maybe Texture)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Texture
result ((Ptr Texture -> IO Texture) -> IO (Maybe Texture))
-> (Ptr Texture -> IO Texture) -> IO (Maybe Texture)
forall a b. (a -> b) -> a -> b
$ \Ptr Texture
result' -> do
        Texture
result'' <- ((ManagedPtr Texture -> Texture) -> Ptr Texture -> IO Texture
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Texture -> Texture
Gdk.Texture.Texture) Ptr Texture
result'
        Texture -> IO Texture
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Texture
result''
    Int32
width' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
width
    Int32
height' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
height
    Int32
hotspotX' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
hotspotX
    Int32
hotspotY' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
hotspotY
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cursor
    Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
width
    Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
height
    Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
hotspotX
    Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
hotspotY
    (Maybe Texture, Int32, Int32, Int32, Int32)
-> IO (Maybe Texture, Int32, Int32, Int32, Int32)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Texture
maybeResult, Int32
width', Int32
height', Int32
hotspotX', Int32
hotspotY')

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

-- | The type of callback used by a dynamic @GdkCursor@ to generate
-- a texture for the cursor image at the given /@cursorSize@/
-- and /@scale@/.
-- 
-- The actual cursor size in application pixels may be different
-- from /@cursorSize@/ x /@cursorSize@/, and will be returned in
-- /@width@/, /@height@/. The returned texture should have a size that
-- corresponds to the actual cursor size, in device pixels (i.e.
-- application pixels, multiplied by /@scale@/).
-- 
-- This function may fail and return @NULL@, in which case
-- the fallback cursor will be used.
type CursorGetTextureCallback =
    Gdk.Cursor.Cursor
    -- ^ /@cursor@/: the @GdkCursor@
    -> Int32
    -- ^ /@cursorSize@/: the nominal cursor size, in application pixels
    -> Double
    -- ^ /@scale@/: the device scale
    -> Ptr ()
    -- ^ /@data@/: User data for the callback
    -> IO ((Maybe Gdk.Texture.Texture, Int32, Int32, Int32, Int32))
    -- ^ __Returns:__ the cursor image, or
    --   @NULL@ if none could be produced.

-- | A convenience synonym for @`Nothing` :: `Maybe` `CursorGetTextureCallback`@.
noCursorGetTextureCallback :: Maybe CursorGetTextureCallback
noCursorGetTextureCallback :: Maybe CursorGetTextureCallback
noCursorGetTextureCallback = Maybe CursorGetTextureCallback
forall a. Maybe a
Nothing

-- | Wrap the callback into a `GClosure`.
genClosure_CursorGetTextureCallback :: MonadIO m => CursorGetTextureCallback -> m (GClosure C_CursorGetTextureCallback)
genClosure_CursorGetTextureCallback :: forall (m :: * -> *).
MonadIO m =>
CursorGetTextureCallback -> m (GClosure C_CursorGetTextureCallback)
genClosure_CursorGetTextureCallback CursorGetTextureCallback
cb = IO (GClosure C_CursorGetTextureCallback)
-> m (GClosure C_CursorGetTextureCallback)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_CursorGetTextureCallback)
 -> m (GClosure C_CursorGetTextureCallback))
-> IO (GClosure C_CursorGetTextureCallback)
-> m (GClosure C_CursorGetTextureCallback)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_CursorGetTextureCallback
cb' = Maybe (Ptr (FunPtr C_CursorGetTextureCallback))
-> CursorGetTextureCallback -> C_CursorGetTextureCallback
wrap_CursorGetTextureCallback Maybe (Ptr (FunPtr C_CursorGetTextureCallback))
forall a. Maybe a
Nothing CursorGetTextureCallback
cb
    C_CursorGetTextureCallback
-> IO (FunPtr C_CursorGetTextureCallback)
mk_CursorGetTextureCallback C_CursorGetTextureCallback
cb' IO (FunPtr C_CursorGetTextureCallback)
-> (FunPtr C_CursorGetTextureCallback
    -> IO (GClosure C_CursorGetTextureCallback))
-> IO (GClosure C_CursorGetTextureCallback)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_CursorGetTextureCallback
-> IO (GClosure C_CursorGetTextureCallback)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `CursorGetTextureCallback` into a `C_CursorGetTextureCallback`.
wrap_CursorGetTextureCallback :: 
    Maybe (Ptr (FunPtr C_CursorGetTextureCallback)) ->
    CursorGetTextureCallback ->
    C_CursorGetTextureCallback
wrap_CursorGetTextureCallback :: Maybe (Ptr (FunPtr C_CursorGetTextureCallback))
-> CursorGetTextureCallback -> C_CursorGetTextureCallback
wrap_CursorGetTextureCallback Maybe (Ptr (FunPtr C_CursorGetTextureCallback))
gi'funptrptr CursorGetTextureCallback
gi'cb Ptr Cursor
cursor Int32
cursorSize CDouble
scale Ptr Int32
width Ptr Int32
height Ptr Int32
hotspotX Ptr Int32
hotspotY Ptr ()
data_ = do
    Cursor
cursor' <- ((ManagedPtr Cursor -> Cursor) -> Ptr Cursor -> IO Cursor
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Cursor -> Cursor
Gdk.Cursor.Cursor) Ptr Cursor
cursor
    let scale' :: Double
scale' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
scale
    (Maybe Texture
result, Int32
outwidth, Int32
outheight, Int32
outhotspotX, Int32
outhotspotY) <- CursorGetTextureCallback
gi'cb  Cursor
cursor' Int32
cursorSize Double
scale' Ptr ()
data_
    Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr Int32
width Int32
outwidth
    Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr Int32
height Int32
outheight
    Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr Int32
hotspotX Int32
outhotspotX
    Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr Int32
hotspotY Int32
outhotspotY
    Maybe (Ptr (FunPtr C_CursorGetTextureCallback)) -> IO ()
forall a. Maybe (Ptr (FunPtr a)) -> IO ()
maybeReleaseFunPtr Maybe (Ptr (FunPtr C_CursorGetTextureCallback))
gi'funptrptr
    Ptr Texture
-> Maybe Texture
-> (Texture -> IO (Ptr Texture))
-> IO (Ptr Texture)
forall (m :: * -> *) b a.
Monad m =>
b -> Maybe a -> (a -> m b) -> m b
maybeM Ptr Texture
forall a. Ptr a
FP.nullPtr Maybe Texture
result ((Texture -> IO (Ptr Texture)) -> IO (Ptr Texture))
-> (Texture -> IO (Ptr Texture)) -> IO (Ptr Texture)
forall a b. (a -> b) -> a -> b
$ \Texture
result' -> do
        Ptr Texture
result'' <- Texture -> IO (Ptr Texture)
forall a b. (HasCallStack, GObject a) => a -> IO (Ptr b)
B.ManagedPtr.disownObject Texture
result'
        Ptr Texture -> IO (Ptr Texture)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Texture
result''


-- callback ContentSerializeFunc
{- Callable
  { returnType = Nothing
  , returnMayBeNull = False
  , returnTransfer = TransferNothing
  , returnDocumentation =
      Documentation { rawDocText = Nothing , sinceVersion = Nothing }
  , args =
      [ Arg
          { argCName = "serializer"
          , argType =
              TInterface Name { namespace = "Gdk" , name = "ContentSerializer" }
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "a `GdkContentSerializer`"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      ]
  , skipReturn = False
  , callableThrows = False
  , callableDeprecated = Nothing
  , callableDocumentation =
      Documentation
        { rawDocText =
            Just
              "The type of a function that can be registered with gdk_content_register_serializer().\n\nWhen the function gets called to operate on content, it can call functions on the\n@serializer object to obtain the mime type, output stream, user data, etc. for its\noperation."
        , sinceVersion = Nothing
        }
  , callableResolvable = Nothing
  }
-}
-- | Type for the callback on the (unwrapped) C side.
type C_ContentSerializeFunc =
    Ptr Gdk.ContentSerializer.ContentSerializer ->
    IO ()

-- Args: [ Arg
--           { argCName = "serializer"
--           , argType =
--               TInterface Name { namespace = "Gdk" , name = "ContentSerializer" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a `GdkContentSerializer`"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_ContentSerializeFunc :: FunPtr C_ContentSerializeFunc -> C_ContentSerializeFunc

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_ContentSerializeFunc ::
    (B.CallStack.HasCallStack, MonadIO m, Gdk.ContentSerializer.IsContentSerializer a) =>
    FunPtr C_ContentSerializeFunc
    -> a
    -- ^ /@serializer@/: a @GdkContentSerializer@
    -> m ()
dynamic_ContentSerializeFunc :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsContentSerializer a) =>
FunPtr C_ContentSerializeFunc -> a -> m ()
dynamic_ContentSerializeFunc FunPtr C_ContentSerializeFunc
__funPtr a
serializer = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr ContentSerializer
serializer' <- a -> IO (Ptr ContentSerializer)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
serializer
    (FunPtr C_ContentSerializeFunc -> C_ContentSerializeFunc
__dynamic_C_ContentSerializeFunc FunPtr C_ContentSerializeFunc
__funPtr) Ptr ContentSerializer
serializer'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
serializer
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

-- | The type of a function that can be registered with 'GI.Gdk.Functions.contentRegisterSerializer'.
-- 
-- When the function gets called to operate on content, it can call functions on the
-- /@serializer@/ object to obtain the mime type, output stream, user data, etc. for its
-- operation.
type ContentSerializeFunc =
    Gdk.ContentSerializer.ContentSerializer
    -- ^ /@serializer@/: a @GdkContentSerializer@
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ContentSerializeFunc`@.
noContentSerializeFunc :: Maybe ContentSerializeFunc
noContentSerializeFunc :: Maybe ContentSerializeFunc
noContentSerializeFunc = Maybe ContentSerializeFunc
forall a. Maybe a
Nothing

-- | Wrap the callback into a `GClosure`.
genClosure_ContentSerializeFunc :: MonadIO m => ContentSerializeFunc -> m (GClosure C_ContentSerializeFunc)
genClosure_ContentSerializeFunc :: forall (m :: * -> *).
MonadIO m =>
ContentSerializeFunc -> m (GClosure C_ContentSerializeFunc)
genClosure_ContentSerializeFunc ContentSerializeFunc
cb = IO (GClosure C_ContentSerializeFunc)
-> m (GClosure C_ContentSerializeFunc)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_ContentSerializeFunc)
 -> m (GClosure C_ContentSerializeFunc))
-> IO (GClosure C_ContentSerializeFunc)
-> m (GClosure C_ContentSerializeFunc)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_ContentSerializeFunc
cb' = Maybe (Ptr (FunPtr C_ContentSerializeFunc))
-> ContentSerializeFunc -> C_ContentSerializeFunc
wrap_ContentSerializeFunc Maybe (Ptr (FunPtr C_ContentSerializeFunc))
forall a. Maybe a
Nothing ContentSerializeFunc
cb
    C_ContentSerializeFunc -> IO (FunPtr C_ContentSerializeFunc)
mk_ContentSerializeFunc C_ContentSerializeFunc
cb' IO (FunPtr C_ContentSerializeFunc)
-> (FunPtr C_ContentSerializeFunc
    -> IO (GClosure C_ContentSerializeFunc))
-> IO (GClosure C_ContentSerializeFunc)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_ContentSerializeFunc
-> IO (GClosure C_ContentSerializeFunc)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `ContentSerializeFunc` into a `C_ContentSerializeFunc`.
wrap_ContentSerializeFunc :: 
    Maybe (Ptr (FunPtr C_ContentSerializeFunc)) ->
    ContentSerializeFunc ->
    C_ContentSerializeFunc
wrap_ContentSerializeFunc :: Maybe (Ptr (FunPtr C_ContentSerializeFunc))
-> ContentSerializeFunc -> C_ContentSerializeFunc
wrap_ContentSerializeFunc Maybe (Ptr (FunPtr C_ContentSerializeFunc))
gi'funptrptr ContentSerializeFunc
gi'cb Ptr ContentSerializer
serializer = do
    ContentSerializer
serializer' <- ((ManagedPtr ContentSerializer -> ContentSerializer)
-> Ptr ContentSerializer -> IO ContentSerializer
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr ContentSerializer -> ContentSerializer
Gdk.ContentSerializer.ContentSerializer) Ptr ContentSerializer
serializer
    ContentSerializeFunc
gi'cb  ContentSerializer
serializer'
    Maybe (Ptr (FunPtr C_ContentSerializeFunc)) -> IO ()
forall a. Maybe (Ptr (FunPtr a)) -> IO ()
maybeReleaseFunPtr Maybe (Ptr (FunPtr C_ContentSerializeFunc))
gi'funptrptr


-- callback ContentDeserializeFunc
{- Callable
  { returnType = Nothing
  , returnMayBeNull = False
  , returnTransfer = TransferNothing
  , returnDocumentation =
      Documentation { rawDocText = Nothing , sinceVersion = Nothing }
  , args =
      [ Arg
          { argCName = "deserializer"
          , argType =
              TInterface
                Name { namespace = "Gdk" , name = "ContentDeserializer" }
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "a `GdkContentDeserializer`"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      ]
  , skipReturn = False
  , callableThrows = False
  , callableDeprecated = Nothing
  , callableDocumentation =
      Documentation
        { rawDocText =
            Just
              "The type of a function that can be registered with gdk_content_register_deserializer().\n\nWhen the function gets called to operate on content, it can call functions on the\n@deserializer object to obtain the mime type, input stream, user data, etc. for its\noperation."
        , sinceVersion = Nothing
        }
  , callableResolvable = Nothing
  }
-}
-- | Type for the callback on the (unwrapped) C side.
type C_ContentDeserializeFunc =
    Ptr Gdk.ContentDeserializer.ContentDeserializer ->
    IO ()

-- Args: [ Arg
--           { argCName = "deserializer"
--           , argType =
--               TInterface
--                 Name { namespace = "Gdk" , name = "ContentDeserializer" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a `GdkContentDeserializer`"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_ContentDeserializeFunc :: FunPtr C_ContentDeserializeFunc -> C_ContentDeserializeFunc

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_ContentDeserializeFunc ::
    (B.CallStack.HasCallStack, MonadIO m, Gdk.ContentDeserializer.IsContentDeserializer a) =>
    FunPtr C_ContentDeserializeFunc
    -> a
    -- ^ /@deserializer@/: a @GdkContentDeserializer@
    -> m ()
dynamic_ContentDeserializeFunc :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsContentDeserializer a) =>
FunPtr C_ContentDeserializeFunc -> a -> m ()
dynamic_ContentDeserializeFunc FunPtr C_ContentDeserializeFunc
__funPtr a
deserializer = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr ContentDeserializer
deserializer' <- a -> IO (Ptr ContentDeserializer)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
deserializer
    (FunPtr C_ContentDeserializeFunc -> C_ContentDeserializeFunc
__dynamic_C_ContentDeserializeFunc FunPtr C_ContentDeserializeFunc
__funPtr) Ptr ContentDeserializer
deserializer'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
deserializer
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

-- | The type of a function that can be registered with 'GI.Gdk.Functions.contentRegisterDeserializer'.
-- 
-- When the function gets called to operate on content, it can call functions on the
-- /@deserializer@/ object to obtain the mime type, input stream, user data, etc. for its
-- operation.
type ContentDeserializeFunc =
    Gdk.ContentDeserializer.ContentDeserializer
    -- ^ /@deserializer@/: a @GdkContentDeserializer@
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ContentDeserializeFunc`@.
noContentDeserializeFunc :: Maybe ContentDeserializeFunc
noContentDeserializeFunc :: Maybe ContentDeserializeFunc
noContentDeserializeFunc = Maybe ContentDeserializeFunc
forall a. Maybe a
Nothing

-- | Wrap the callback into a `GClosure`.
genClosure_ContentDeserializeFunc :: MonadIO m => ContentDeserializeFunc -> m (GClosure C_ContentDeserializeFunc)
genClosure_ContentDeserializeFunc :: forall (m :: * -> *).
MonadIO m =>
ContentDeserializeFunc -> m (GClosure C_ContentDeserializeFunc)
genClosure_ContentDeserializeFunc ContentDeserializeFunc
cb = IO (GClosure C_ContentDeserializeFunc)
-> m (GClosure C_ContentDeserializeFunc)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_ContentDeserializeFunc)
 -> m (GClosure C_ContentDeserializeFunc))
-> IO (GClosure C_ContentDeserializeFunc)
-> m (GClosure C_ContentDeserializeFunc)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_ContentDeserializeFunc
cb' = Maybe (Ptr (FunPtr C_ContentDeserializeFunc))
-> ContentDeserializeFunc -> C_ContentDeserializeFunc
wrap_ContentDeserializeFunc Maybe (Ptr (FunPtr C_ContentDeserializeFunc))
forall a. Maybe a
Nothing ContentDeserializeFunc
cb
    C_ContentDeserializeFunc -> IO (FunPtr C_ContentDeserializeFunc)
mk_ContentDeserializeFunc C_ContentDeserializeFunc
cb' IO (FunPtr C_ContentDeserializeFunc)
-> (FunPtr C_ContentDeserializeFunc
    -> IO (GClosure C_ContentDeserializeFunc))
-> IO (GClosure C_ContentDeserializeFunc)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_ContentDeserializeFunc
-> IO (GClosure C_ContentDeserializeFunc)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `ContentDeserializeFunc` into a `C_ContentDeserializeFunc`.
wrap_ContentDeserializeFunc :: 
    Maybe (Ptr (FunPtr C_ContentDeserializeFunc)) ->
    ContentDeserializeFunc ->
    C_ContentDeserializeFunc
wrap_ContentDeserializeFunc :: Maybe (Ptr (FunPtr C_ContentDeserializeFunc))
-> ContentDeserializeFunc -> C_ContentDeserializeFunc
wrap_ContentDeserializeFunc Maybe (Ptr (FunPtr C_ContentDeserializeFunc))
gi'funptrptr ContentDeserializeFunc
gi'cb Ptr ContentDeserializer
deserializer = do
    ContentDeserializer
deserializer' <- ((ManagedPtr ContentDeserializer -> ContentDeserializer)
-> Ptr ContentDeserializer -> IO ContentDeserializer
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr ContentDeserializer -> ContentDeserializer
Gdk.ContentDeserializer.ContentDeserializer) Ptr ContentDeserializer
deserializer
    ContentDeserializeFunc
gi'cb  ContentDeserializer
deserializer'
    Maybe (Ptr (FunPtr C_ContentDeserializeFunc)) -> IO ()
forall a. Maybe (Ptr (FunPtr a)) -> IO ()
maybeReleaseFunPtr Maybe (Ptr (FunPtr C_ContentDeserializeFunc))
gi'funptrptr