-- | 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.Vte.Callbacks
    ( 

 -- * Signals


-- ** SelectionFunc #signal:SelectionFunc#

    C_SelectionFunc                         ,
    SelectionFunc                           ,
    SelectionFunc_WithClosures              ,
    drop_closures_SelectionFunc             ,
    dynamic_SelectionFunc                   ,
    genClosure_SelectionFunc                ,
    mk_SelectionFunc                        ,
    noSelectionFunc                         ,
    noSelectionFunc_WithClosures            ,
    wrap_SelectionFunc                      ,


-- ** TerminalSpawnAsyncCallback #signal:TerminalSpawnAsyncCallback#

    C_TerminalSpawnAsyncCallback            ,
    TerminalSpawnAsyncCallback              ,
    TerminalSpawnAsyncCallback_WithClosures ,
    drop_closures_TerminalSpawnAsyncCallback,
    dynamic_TerminalSpawnAsyncCallback      ,
    genClosure_TerminalSpawnAsyncCallback   ,
    mk_TerminalSpawnAsyncCallback           ,
    noTerminalSpawnAsyncCallback            ,
    noTerminalSpawnAsyncCallback_WithClosures,
    wrap_TerminalSpawnAsyncCallback         ,




    ) 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.Atk.Interfaces.ImplementorIface as Atk.ImplementorIface
import qualified GI.Cairo.Structs.FontOptions as Cairo.FontOptions
import qualified GI.Cairo.Structs.Surface as Cairo.Surface
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Flags as GLib.Flags
import qualified GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.GLib.Structs.Regex as GLib.Regex
import qualified GI.GLib.Structs.Uri as GLib.Uri
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gdk.Enums as Gdk.Enums
import qualified GI.Gdk.Objects.Cursor as Gdk.Cursor
import qualified GI.Gdk.Structs.Geometry as Gdk.Geometry
import qualified GI.Gdk.Structs.RGBA as Gdk.RGBA
import qualified GI.Gdk.Structs.Rectangle as Gdk.Rectangle
import qualified GI.Gdk.Unions.Event as Gdk.Event
import qualified GI.GdkPixbuf.Objects.Pixbuf as GdkPixbuf.Pixbuf
import qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Interfaces.Initable as Gio.Initable
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Gio.Objects.MenuModel as Gio.MenuModel
import qualified GI.Gio.Objects.OutputStream as Gio.OutputStream
import qualified GI.Gtk.Interfaces.Buildable as Gtk.Buildable
import qualified GI.Gtk.Interfaces.Scrollable as Gtk.Scrollable
import qualified GI.Gtk.Objects.Menu as Gtk.Menu
import qualified GI.Gtk.Objects.Widget as Gtk.Widget
import qualified GI.Gtk.Objects.Window as Gtk.Window
import qualified GI.Pango.Structs.FontDescription as Pango.FontDescription
import {-# SOURCE #-} qualified GI.Vte.Enums as Vte.Enums
import {-# SOURCE #-} qualified GI.Vte.Flags as Vte.Flags
import {-# SOURCE #-} qualified GI.Vte.Objects.Pty as Vte.Pty
import {-# SOURCE #-} qualified GI.Vte.Objects.Terminal as Vte.Terminal
import {-# SOURCE #-} qualified GI.Vte.Structs.CharAttributes as Vte.CharAttributes
import {-# SOURCE #-} qualified GI.Vte.Structs.EventContext as Vte.EventContext
import {-# SOURCE #-} qualified GI.Vte.Structs.Regex as Vte.Regex
import {-# SOURCE #-} qualified GI.Vte.Structs.Uuid as Vte.Uuid

#else
import {-# SOURCE #-} qualified GI.Vte.Objects.Terminal as Vte.Terminal

#endif

-- callback TerminalSpawnAsyncCallback
{- Callable
  { returnType = Nothing
  , returnMayBeNull = False
  , returnTransfer = TransferNothing
  , returnDocumentation =
      Documentation { rawDocText = Nothing , sinceVersion = Nothing }
  , args =
      [ Arg
          { argCName = "terminal"
          , argType =
              TInterface Name { namespace = "Vte" , name = "Terminal" }
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "the #VteTerminal" , sinceVersion = Nothing }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "pid"
          , argType = TBasicType TInt
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "a #GPid" , sinceVersion = Nothing }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "error"
          , argType = TError
          , direction = DirectionIn
          , mayBeNull = True
          , argDoc =
              Documentation
                { rawDocText = Just "a #GError, or %NULL"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "user_data"
          , argType = TBasicType TPtr
          , direction = DirectionIn
          , mayBeNull = True
          , argDoc =
              Documentation
                { rawDocText =
                    Just "user data that was passed to vte_terminal_spawn_async"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = True
          , transfer = TransferNothing
          }
      ]
  , skipReturn = False
  , callableThrows = False
  , callableDeprecated = Nothing
  , callableDocumentation =
      Documentation
        { rawDocText =
            Just
              "Callback for vte_terminal_spawn_async().\n\nOn success, @pid contains the PID of the spawned process, and @error\nis %NULL.\nOn failure, @pid is -1 and @error contains the error information."
        , sinceVersion = Just "0.48"
        }
  , callableResolvable = Nothing
  }
-}
-- | Type for the callback on the (unwrapped) C side.
type C_TerminalSpawnAsyncCallback =
    Ptr Vte.Terminal.Terminal ->
    Int32 ->
    Ptr GError ->
    Ptr () ->
    IO ()

-- Args: [ Arg
--           { argCName = "terminal"
--           , argType =
--               TInterface Name { namespace = "Vte" , name = "Terminal" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the #VteTerminal" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "pid"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GPid" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "error"
--           , argType = TError
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GError, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "user data that was passed to vte_terminal_spawn_async"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = True
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_TerminalSpawnAsyncCallback :: FunPtr C_TerminalSpawnAsyncCallback -> C_TerminalSpawnAsyncCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_TerminalSpawnAsyncCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Vte.Terminal.IsTerminal a) =>
    FunPtr C_TerminalSpawnAsyncCallback
    -> a
    -- ^ /@terminal@/: the t'GI.Vte.Objects.Terminal.Terminal'
    -> Int32
    -- ^ /@pid@/: a @/GPid/@
    -> Maybe (GError)
    -- ^ /@error@/: a t'GError', or 'P.Nothing'
    -> Ptr ()
    -- ^ /@userData@/: user data that was passed to vte_terminal_spawn_async
    -> m ()
dynamic_TerminalSpawnAsyncCallback :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsTerminal a) =>
FunPtr C_TerminalSpawnAsyncCallback
-> a -> Int32 -> Maybe GError -> Ptr () -> m ()
dynamic_TerminalSpawnAsyncCallback FunPtr C_TerminalSpawnAsyncCallback
__funPtr a
terminal Int32
pid Maybe GError
error_ Ptr ()
userData = 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
    terminal' <- a -> IO (Ptr Terminal)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
terminal
    maybeError_ <- case error_ of
        Maybe GError
Nothing -> Ptr GError -> IO (Ptr GError)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr GError
forall a. Ptr a
FP.nullPtr
        Just GError
jError_ -> do
            jError_' <- GError -> IO (Ptr GError)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GError
jError_
            return jError_'
    (__dynamic_C_TerminalSpawnAsyncCallback __funPtr) terminal' pid maybeError_ userData
    touchManagedPtr terminal
    whenJust error_ touchManagedPtr
    return ()

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

-- | Callback for 'GI.Vte.Objects.Terminal.terminalSpawnAsync'.
-- 
-- On success, /@pid@/ contains the PID of the spawned process, and /@error@/
-- is 'P.Nothing'.
-- On failure, /@pid@/ is -1 and /@error@/ contains the error information.
-- 
-- /Since: 0.48/
type TerminalSpawnAsyncCallback =
    Vte.Terminal.Terminal
    -- ^ /@terminal@/: the t'GI.Vte.Objects.Terminal.Terminal'
    -> Int32
    -- ^ /@pid@/: a @/GPid/@
    -> Maybe GError
    -- ^ /@error@/: a t'GError', or 'P.Nothing'
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `TerminalSpawnAsyncCallback`@.
noTerminalSpawnAsyncCallback :: Maybe TerminalSpawnAsyncCallback
noTerminalSpawnAsyncCallback :: Maybe TerminalSpawnAsyncCallback
noTerminalSpawnAsyncCallback = Maybe TerminalSpawnAsyncCallback
forall a. Maybe a
Nothing

-- | Callback for 'GI.Vte.Objects.Terminal.terminalSpawnAsync'.
-- 
-- On success, /@pid@/ contains the PID of the spawned process, and /@error@/
-- is 'P.Nothing'.
-- On failure, /@pid@/ is -1 and /@error@/ contains the error information.
-- 
-- /Since: 0.48/
type TerminalSpawnAsyncCallback_WithClosures =
    Vte.Terminal.Terminal
    -- ^ /@terminal@/: the t'GI.Vte.Objects.Terminal.Terminal'
    -> Int32
    -- ^ /@pid@/: a @/GPid/@
    -> Maybe GError
    -- ^ /@error@/: a t'GError', or 'P.Nothing'
    -> Ptr ()
    -- ^ /@userData@/: user data that was passed to vte_terminal_spawn_async
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `TerminalSpawnAsyncCallback_WithClosures`@.
noTerminalSpawnAsyncCallback_WithClosures :: Maybe TerminalSpawnAsyncCallback_WithClosures
noTerminalSpawnAsyncCallback_WithClosures :: Maybe TerminalSpawnAsyncCallback_WithClosures
noTerminalSpawnAsyncCallback_WithClosures = Maybe TerminalSpawnAsyncCallback_WithClosures
forall a. Maybe a
Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_TerminalSpawnAsyncCallback :: TerminalSpawnAsyncCallback -> TerminalSpawnAsyncCallback_WithClosures
drop_closures_TerminalSpawnAsyncCallback :: TerminalSpawnAsyncCallback
-> TerminalSpawnAsyncCallback_WithClosures
drop_closures_TerminalSpawnAsyncCallback TerminalSpawnAsyncCallback
_f Terminal
terminal Int32
pid Maybe GError
error_ Ptr ()
_ = TerminalSpawnAsyncCallback
_f Terminal
terminal Int32
pid Maybe GError
error_

-- | Wrap the callback into a `GClosure`.
genClosure_TerminalSpawnAsyncCallback :: MonadIO m => TerminalSpawnAsyncCallback -> m (GClosure C_TerminalSpawnAsyncCallback)
genClosure_TerminalSpawnAsyncCallback :: forall (m :: * -> *).
MonadIO m =>
TerminalSpawnAsyncCallback
-> m (GClosure C_TerminalSpawnAsyncCallback)
genClosure_TerminalSpawnAsyncCallback TerminalSpawnAsyncCallback
cb = IO (GClosure C_TerminalSpawnAsyncCallback)
-> m (GClosure C_TerminalSpawnAsyncCallback)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_TerminalSpawnAsyncCallback)
 -> m (GClosure C_TerminalSpawnAsyncCallback))
-> IO (GClosure C_TerminalSpawnAsyncCallback)
-> m (GClosure C_TerminalSpawnAsyncCallback)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: TerminalSpawnAsyncCallback_WithClosures
cb' = TerminalSpawnAsyncCallback
-> TerminalSpawnAsyncCallback_WithClosures
drop_closures_TerminalSpawnAsyncCallback TerminalSpawnAsyncCallback
cb
    let cb'' :: C_TerminalSpawnAsyncCallback
cb'' = Maybe (Ptr (FunPtr C_TerminalSpawnAsyncCallback))
-> TerminalSpawnAsyncCallback_WithClosures
-> C_TerminalSpawnAsyncCallback
wrap_TerminalSpawnAsyncCallback Maybe (Ptr (FunPtr C_TerminalSpawnAsyncCallback))
forall a. Maybe a
Nothing TerminalSpawnAsyncCallback_WithClosures
cb'
    C_TerminalSpawnAsyncCallback
-> IO (FunPtr C_TerminalSpawnAsyncCallback)
mk_TerminalSpawnAsyncCallback C_TerminalSpawnAsyncCallback
cb'' IO (FunPtr C_TerminalSpawnAsyncCallback)
-> (FunPtr C_TerminalSpawnAsyncCallback
    -> IO (GClosure C_TerminalSpawnAsyncCallback))
-> IO (GClosure C_TerminalSpawnAsyncCallback)
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_TerminalSpawnAsyncCallback
-> IO (GClosure C_TerminalSpawnAsyncCallback)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `TerminalSpawnAsyncCallback` into a `C_TerminalSpawnAsyncCallback`.
wrap_TerminalSpawnAsyncCallback :: 
    Maybe (Ptr (FunPtr C_TerminalSpawnAsyncCallback)) ->
    TerminalSpawnAsyncCallback_WithClosures ->
    C_TerminalSpawnAsyncCallback
wrap_TerminalSpawnAsyncCallback :: Maybe (Ptr (FunPtr C_TerminalSpawnAsyncCallback))
-> TerminalSpawnAsyncCallback_WithClosures
-> C_TerminalSpawnAsyncCallback
wrap_TerminalSpawnAsyncCallback Maybe (Ptr (FunPtr C_TerminalSpawnAsyncCallback))
gi'funptrptr TerminalSpawnAsyncCallback_WithClosures
gi'cb Ptr Terminal
terminal Int32
pid Ptr GError
error_ Ptr ()
userData = do
    terminal' <- ((ManagedPtr Terminal -> Terminal) -> Ptr Terminal -> IO Terminal
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Terminal -> Terminal
Vte.Terminal.Terminal) Ptr Terminal
terminal
    maybeError_ <-
        if error_ == FP.nullPtr
        then return Nothing
        else do
            error_' <- (newBoxed GError) error_
            return $ Just error_'
    gi'cb  terminal' pid maybeError_ userData
    maybeReleaseFunPtr gi'funptrptr


-- callback SelectionFunc
{- Callable
  { returnType = Just (TBasicType TBoolean)
  , returnMayBeNull = False
  , returnTransfer = TransferNothing
  , returnDocumentation =
      Documentation
        { rawDocText =
            Just "%TRUE if cell has to be selected; %FALSE if otherwise."
        , sinceVersion = Nothing
        }
  , args =
      [ Arg
          { argCName = "terminal"
          , argType =
              TInterface Name { namespace = "Vte" , name = "Terminal" }
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "terminal in which the cell is."
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "column"
          , argType = TBasicType TLong
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "column in which the cell is."
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "row"
          , argType = TBasicType TLong
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "row in which the cell is."
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "data"
          , argType = TBasicType TPtr
          , direction = DirectionIn
          , mayBeNull = True
          , argDoc =
              Documentation
                { rawDocText = Just "user data." , sinceVersion = Nothing }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = True
          , transfer = TransferNothing
          }
      ]
  , skipReturn = False
  , callableThrows = False
  , callableDeprecated =
      Just
        DeprecationInfo
          { deprecatedSinceVersion = Just "0.76"
          , deprecationMessage = Nothing
          }
  , callableDocumentation =
      Documentation
        { rawDocText =
            Just
              "Specifies the type of a selection function used to check whether\na cell has to be selected or not."
        , sinceVersion = Nothing
        }
  , callableResolvable = Nothing
  }
-}
-- | Type for the callback on the (unwrapped) C side.
type C_SelectionFunc =
    Ptr Vte.Terminal.Terminal ->
    FCT.CLong ->
    FCT.CLong ->
    Ptr () ->
    IO CInt

-- Args: [ Arg
--           { argCName = "terminal"
--           , argType =
--               TInterface Name { namespace = "Vte" , name = "Terminal" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "terminal in which the cell is."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "column"
--           , argType = TBasicType TLong
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "column in which the cell is."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "row"
--           , argType = TBasicType TLong
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "row in which the cell is."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = True
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_SelectionFunc :: FunPtr C_SelectionFunc -> C_SelectionFunc

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_SelectionFunc ::
    (B.CallStack.HasCallStack, MonadIO m, Vte.Terminal.IsTerminal a) =>
    FunPtr C_SelectionFunc
    -> a
    -- ^ /@terminal@/: terminal in which the cell is.
    -> FCT.CLong
    -- ^ /@column@/: column in which the cell is.
    -> FCT.CLong
    -- ^ /@row@/: row in which the cell is.
    -> Ptr ()
    -- ^ /@data@/: user data.
    -> m Bool
    -- ^ __Returns:__ 'P.True' if cell has to be selected; 'P.False' if otherwise.
dynamic_SelectionFunc :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsTerminal a) =>
FunPtr C_SelectionFunc -> a -> CLong -> CLong -> Ptr () -> m Bool
dynamic_SelectionFunc FunPtr C_SelectionFunc
__funPtr a
terminal CLong
column CLong
row Ptr ()
data_ = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    terminal' <- a -> IO (Ptr Terminal)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
terminal
    result <- (__dynamic_C_SelectionFunc __funPtr) terminal' column row data_
    let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    touchManagedPtr terminal
    return result'

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

{-# DEPRECATED SelectionFunc ["(Since version 0.76)"] #-}
-- | Specifies the type of a selection function used to check whether
-- a cell has to be selected or not.
type SelectionFunc =
    Vte.Terminal.Terminal
    -- ^ /@terminal@/: terminal in which the cell is.
    -> FCT.CLong
    -- ^ /@column@/: column in which the cell is.
    -> FCT.CLong
    -- ^ /@row@/: row in which the cell is.
    -> IO Bool
    -- ^ __Returns:__ 'P.True' if cell has to be selected; 'P.False' if otherwise.

-- | A convenience synonym for @`Nothing` :: `Maybe` `SelectionFunc`@.
noSelectionFunc :: Maybe SelectionFunc
noSelectionFunc :: Maybe SelectionFunc
noSelectionFunc = Maybe SelectionFunc
forall a. Maybe a
Nothing

-- | Specifies the type of a selection function used to check whether
-- a cell has to be selected or not.
type SelectionFunc_WithClosures =
    Vte.Terminal.Terminal
    -- ^ /@terminal@/: terminal in which the cell is.
    -> FCT.CLong
    -- ^ /@column@/: column in which the cell is.
    -> FCT.CLong
    -- ^ /@row@/: row in which the cell is.
    -> Ptr ()
    -- ^ /@data@/: user data.
    -> IO Bool
    -- ^ __Returns:__ 'P.True' if cell has to be selected; 'P.False' if otherwise.

-- | A convenience synonym for @`Nothing` :: `Maybe` `SelectionFunc_WithClosures`@.
noSelectionFunc_WithClosures :: Maybe SelectionFunc_WithClosures
noSelectionFunc_WithClosures :: Maybe SelectionFunc_WithClosures
noSelectionFunc_WithClosures = Maybe SelectionFunc_WithClosures
forall a. Maybe a
Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_SelectionFunc :: SelectionFunc -> SelectionFunc_WithClosures
drop_closures_SelectionFunc :: SelectionFunc -> SelectionFunc_WithClosures
drop_closures_SelectionFunc SelectionFunc
_f Terminal
terminal CLong
column CLong
row Ptr ()
_ = SelectionFunc
_f Terminal
terminal CLong
column CLong
row

-- | Wrap the callback into a `GClosure`.
genClosure_SelectionFunc :: MonadIO m => SelectionFunc -> m (GClosure C_SelectionFunc)
genClosure_SelectionFunc :: forall (m :: * -> *).
MonadIO m =>
SelectionFunc -> m (GClosure C_SelectionFunc)
genClosure_SelectionFunc SelectionFunc
cb = IO (GClosure C_SelectionFunc) -> m (GClosure C_SelectionFunc)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_SelectionFunc) -> m (GClosure C_SelectionFunc))
-> IO (GClosure C_SelectionFunc) -> m (GClosure C_SelectionFunc)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: SelectionFunc_WithClosures
cb' = SelectionFunc -> SelectionFunc_WithClosures
drop_closures_SelectionFunc SelectionFunc
cb
    let cb'' :: C_SelectionFunc
cb'' = Maybe (Ptr (FunPtr C_SelectionFunc))
-> SelectionFunc_WithClosures -> C_SelectionFunc
wrap_SelectionFunc Maybe (Ptr (FunPtr C_SelectionFunc))
forall a. Maybe a
Nothing SelectionFunc_WithClosures
cb'
    C_SelectionFunc -> IO (FunPtr C_SelectionFunc)
mk_SelectionFunc C_SelectionFunc
cb'' IO (FunPtr C_SelectionFunc)
-> (FunPtr C_SelectionFunc -> IO (GClosure C_SelectionFunc))
-> IO (GClosure C_SelectionFunc)
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_SelectionFunc -> IO (GClosure C_SelectionFunc)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `SelectionFunc` into a `C_SelectionFunc`.
wrap_SelectionFunc :: 
    Maybe (Ptr (FunPtr C_SelectionFunc)) ->
    SelectionFunc_WithClosures ->
    C_SelectionFunc
wrap_SelectionFunc :: Maybe (Ptr (FunPtr C_SelectionFunc))
-> SelectionFunc_WithClosures -> C_SelectionFunc
wrap_SelectionFunc Maybe (Ptr (FunPtr C_SelectionFunc))
gi'funptrptr SelectionFunc_WithClosures
gi'cb Ptr Terminal
terminal CLong
column CLong
row Ptr ()
data_ = do
    terminal' <- ((ManagedPtr Terminal -> Terminal) -> Ptr Terminal -> IO Terminal
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Terminal -> Terminal
Vte.Terminal.Terminal) Ptr Terminal
terminal
    result <- gi'cb  terminal' column row data_
    maybeReleaseFunPtr gi'funptrptr
    let result' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
P.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
P.fromEnum) Bool
result
    return result'