-- | 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.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.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
import qualified GHC.Records as R

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

-- 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
          , 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
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "error"
          , argType = TError
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "a #GError, or %NULL"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = 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 = 3
          , argDestroy = -1
          , argCallerAllocates = False
          , 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
--           , 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
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "error"
--           , argType = TError
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GError, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = 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 = 3
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , 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/@
    -> 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 -> GError -> Ptr () -> m ()
dynamic_TerminalSpawnAsyncCallback FunPtr C_TerminalSpawnAsyncCallback
__funPtr a
terminal Int32
pid GError
error_ Ptr ()
userData = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Terminal
terminal' <- a -> IO (Ptr Terminal)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
terminal
    Ptr GError
error_' <- GError -> IO (Ptr GError)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GError
error_
    (FunPtr C_TerminalSpawnAsyncCallback -> C_TerminalSpawnAsyncCallback
__dynamic_C_TerminalSpawnAsyncCallback FunPtr C_TerminalSpawnAsyncCallback
__funPtr) Ptr Terminal
terminal' Int32
pid Ptr GError
error_' Ptr ()
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
terminal
    GError -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GError
error_
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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/@
    -> 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/@
    -> 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 GError
error_ Ptr ()
_ = TerminalSpawnAsyncCallback
_f Terminal
terminal Int32
pid 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 (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 (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))
funptrptr TerminalSpawnAsyncCallback_WithClosures
_cb Ptr Terminal
terminal Int32
pid Ptr GError
error_ Ptr ()
userData = do
    Terminal
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
    GError
error_' <- ((ManagedPtr GError -> GError) -> Ptr GError -> IO GError
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr GError -> GError
GError) Ptr GError
error_
    TerminalSpawnAsyncCallback_WithClosures
_cb  Terminal
terminal' Int32
pid GError
error_' Ptr ()
userData
    Maybe (Ptr (FunPtr C_TerminalSpawnAsyncCallback)) -> IO ()
forall a. Maybe (Ptr (FunPtr a)) -> IO ()
maybeReleaseFunPtr Maybe (Ptr (FunPtr C_TerminalSpawnAsyncCallback))
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
          , 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
          , 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
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "data"
          , argType = TBasicType TPtr
          , direction = DirectionIn
          , mayBeNull = True
          , argDoc =
              Documentation
                { rawDocText = Just "user data." , 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 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 ->
    CLong ->
    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
--           , 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
--           , 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
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = 3
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , 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.
    -> CLong
    -- ^ /@column@/: column in which the cell is.
    -> 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 (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
    Ptr Terminal
terminal' <- a -> IO (Ptr Terminal)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
terminal
    CInt
result <- (FunPtr C_SelectionFunc -> C_SelectionFunc
__dynamic_C_SelectionFunc FunPtr C_SelectionFunc
__funPtr) Ptr Terminal
terminal' CLong
column CLong
row Ptr ()
data_
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
terminal
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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)

-- | 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.
    -> CLong
    -- ^ /@column@/: column in which the cell is.
    -> 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.
    -> CLong
    -- ^ /@column@/: column in which the cell is.
    -> 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 (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 (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))
funptrptr SelectionFunc_WithClosures
_cb Ptr Terminal
terminal CLong
column CLong
row Ptr ()
data_ = do
    Terminal
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
    Bool
result <- SelectionFunc_WithClosures
_cb  Terminal
terminal' CLong
column CLong
row Ptr ()
data_
    Maybe (Ptr (FunPtr C_SelectionFunc)) -> IO ()
forall a. Maybe (Ptr (FunPtr a)) -> IO ()
maybeReleaseFunPtr Maybe (Ptr (FunPtr C_SelectionFunc))
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'