gi-handy-0.0.1: GI/Handy/Callbacks.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Handy.Callbacks
(
-- * Signals
-- ** ComboRowGetEnumValueNameFunc #signal:ComboRowGetEnumValueNameFunc#
C_ComboRowGetEnumValueNameFunc ,
ComboRowGetEnumValueNameFunc ,
ComboRowGetEnumValueNameFunc_WithClosures,
drop_closures_ComboRowGetEnumValueNameFunc,
dynamic_ComboRowGetEnumValueNameFunc ,
genClosure_ComboRowGetEnumValueNameFunc ,
mk_ComboRowGetEnumValueNameFunc ,
noComboRowGetEnumValueNameFunc ,
noComboRowGetEnumValueNameFunc_WithClosures,
wrap_ComboRowGetEnumValueNameFunc ,
-- ** ComboRowGetNameFunc #signal:ComboRowGetNameFunc#
C_ComboRowGetNameFunc ,
ComboRowGetNameFunc ,
ComboRowGetNameFunc_WithClosures ,
drop_closures_ComboRowGetNameFunc ,
dynamic_ComboRowGetNameFunc ,
genClosure_ComboRowGetNameFunc ,
mk_ComboRowGetNameFunc ,
noComboRowGetNameFunc ,
noComboRowGetNameFunc_WithClosures ,
wrap_ComboRowGetNameFunc ,
) 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.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.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 GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Handy.Objects.EnumValueObject as Handy.EnumValueObject
-- callback ComboRowGetNameFunc
-- -> Callable {returnType = Just (TBasicType TUTF8), returnMayBeNull = False, returnTransfer = TransferEverything, returnDocumentation = Documentation {rawDocText = Just "a newly allocated displayable name that represents @item", sinceVersion = Nothing}, args = [Arg {argCName = "item", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the item from the model from which to get a name", 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", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Called for combo rows that are bound to a #GListModel with\nhdy_combo_row_bind_name_model() for each item that gets added to the model.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_ComboRowGetNameFunc =
Ptr GObject.Object.Object ->
Ptr () ->
IO CString
-- Args : [Arg {argCName = "item", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the item from the model from which to get a name", 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", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False
foreign import ccall "dynamic" __dynamic_C_ComboRowGetNameFunc :: FunPtr C_ComboRowGetNameFunc -> C_ComboRowGetNameFunc
-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_ComboRowGetNameFunc ::
(B.CallStack.HasCallStack, MonadIO m, GObject.Object.IsObject a) =>
FunPtr C_ComboRowGetNameFunc
-> a
{- ^ /@item@/: the item from the model from which to get a name -}
-> Ptr ()
{- ^ /@userData@/: user data -}
-> m T.Text
{- ^ __Returns:__ a newly allocated displayable name that represents /@item@/ -}
dynamic_ComboRowGetNameFunc __funPtr item userData = liftIO $ do
item' <- unsafeManagedPtrCastPtr item
result <- (__dynamic_C_ComboRowGetNameFunc __funPtr) item' userData
checkUnexpectedReturnNULL "comboRowGetNameFunc" result
result' <- cstringToText result
freeMem result
touchManagedPtr item
return result'
-- | Generate a function pointer callable from C code, from a `C_ComboRowGetNameFunc`.
foreign import ccall "wrapper"
mk_ComboRowGetNameFunc :: C_ComboRowGetNameFunc -> IO (FunPtr C_ComboRowGetNameFunc)
{- |
Called for combo rows that are bound to a 'GI.Gio.Interfaces.ListModel.ListModel' with
'GI.Handy.Objects.ComboRow.comboRowBindNameModel' for each item that gets added to the model.
-}
type ComboRowGetNameFunc =
GObject.Object.Object
{- ^ /@item@/: the item from the model from which to get a name -}
-> IO T.Text
{- ^ __Returns:__ a newly allocated displayable name that represents /@item@/ -}
-- | A convenience synonym for @`Nothing` :: `Maybe` `ComboRowGetNameFunc`@.
noComboRowGetNameFunc :: Maybe ComboRowGetNameFunc
noComboRowGetNameFunc = Nothing
{- |
Called for combo rows that are bound to a 'GI.Gio.Interfaces.ListModel.ListModel' with
'GI.Handy.Objects.ComboRow.comboRowBindNameModel' for each item that gets added to the model.
-}
type ComboRowGetNameFunc_WithClosures =
GObject.Object.Object
{- ^ /@item@/: the item from the model from which to get a name -}
-> Ptr ()
{- ^ /@userData@/: user data -}
-> IO T.Text
{- ^ __Returns:__ a newly allocated displayable name that represents /@item@/ -}
-- | A convenience synonym for @`Nothing` :: `Maybe` `ComboRowGetNameFunc_WithClosures`@.
noComboRowGetNameFunc_WithClosures :: Maybe ComboRowGetNameFunc_WithClosures
noComboRowGetNameFunc_WithClosures = Nothing
-- | A simple wrapper that ignores the closure arguments.
drop_closures_ComboRowGetNameFunc :: ComboRowGetNameFunc -> ComboRowGetNameFunc_WithClosures
drop_closures_ComboRowGetNameFunc _f item _ = _f item
-- | Wrap the callback into a `GClosure`.
genClosure_ComboRowGetNameFunc :: MonadIO m => ComboRowGetNameFunc -> m (GClosure C_ComboRowGetNameFunc)
genClosure_ComboRowGetNameFunc cb = liftIO $ do
let cb' = drop_closures_ComboRowGetNameFunc cb
let cb'' = wrap_ComboRowGetNameFunc Nothing cb'
mk_ComboRowGetNameFunc cb'' >>= B.GClosure.newGClosure
-- | Wrap a `ComboRowGetNameFunc` into a `C_ComboRowGetNameFunc`.
wrap_ComboRowGetNameFunc ::
Maybe (Ptr (FunPtr C_ComboRowGetNameFunc)) ->
ComboRowGetNameFunc_WithClosures ->
C_ComboRowGetNameFunc
wrap_ComboRowGetNameFunc funptrptr _cb item userData = do
item' <- (newObject GObject.Object.Object) item
result <- _cb item' userData
maybeReleaseFunPtr funptrptr
result' <- textToCString result
return result'
-- callback ComboRowGetEnumValueNameFunc
-- -> Callable {returnType = Just (TBasicType TUTF8), returnMayBeNull = False, returnTransfer = TransferEverything, returnDocumentation = Documentation {rawDocText = Just "a newly allocated displayable name that represents @value", sinceVersion = Nothing}, args = [Arg {argCName = "value", argType = TInterface (Name {namespace = "Handy", name = "EnumValueObject"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value from the enum from which to get a name", 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", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Called for combo rows that are bound to an enumeration with\nhdy_combo_row_set_for_enum() for each value from that enumeration.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_ComboRowGetEnumValueNameFunc =
Ptr Handy.EnumValueObject.EnumValueObject ->
Ptr () ->
IO CString
-- Args : [Arg {argCName = "value", argType = TInterface (Name {namespace = "Handy", name = "EnumValueObject"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value from the enum from which to get a name", 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", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False
foreign import ccall "dynamic" __dynamic_C_ComboRowGetEnumValueNameFunc :: FunPtr C_ComboRowGetEnumValueNameFunc -> C_ComboRowGetEnumValueNameFunc
-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_ComboRowGetEnumValueNameFunc ::
(B.CallStack.HasCallStack, MonadIO m, Handy.EnumValueObject.IsEnumValueObject a) =>
FunPtr C_ComboRowGetEnumValueNameFunc
-> a
{- ^ /@value@/: the value from the enum from which to get a name -}
-> Ptr ()
{- ^ /@userData@/: user data -}
-> m T.Text
{- ^ __Returns:__ a newly allocated displayable name that represents /@value@/ -}
dynamic_ComboRowGetEnumValueNameFunc __funPtr value userData = liftIO $ do
value' <- unsafeManagedPtrCastPtr value
result <- (__dynamic_C_ComboRowGetEnumValueNameFunc __funPtr) value' userData
checkUnexpectedReturnNULL "comboRowGetEnumValueNameFunc" result
result' <- cstringToText result
freeMem result
touchManagedPtr value
return result'
-- | Generate a function pointer callable from C code, from a `C_ComboRowGetEnumValueNameFunc`.
foreign import ccall "wrapper"
mk_ComboRowGetEnumValueNameFunc :: C_ComboRowGetEnumValueNameFunc -> IO (FunPtr C_ComboRowGetEnumValueNameFunc)
{- |
Called for combo rows that are bound to an enumeration with
'GI.Handy.Objects.ComboRow.comboRowSetForEnum' for each value from that enumeration.
-}
type ComboRowGetEnumValueNameFunc =
Handy.EnumValueObject.EnumValueObject
{- ^ /@value@/: the value from the enum from which to get a name -}
-> IO T.Text
{- ^ __Returns:__ a newly allocated displayable name that represents /@value@/ -}
-- | A convenience synonym for @`Nothing` :: `Maybe` `ComboRowGetEnumValueNameFunc`@.
noComboRowGetEnumValueNameFunc :: Maybe ComboRowGetEnumValueNameFunc
noComboRowGetEnumValueNameFunc = Nothing
{- |
Called for combo rows that are bound to an enumeration with
'GI.Handy.Objects.ComboRow.comboRowSetForEnum' for each value from that enumeration.
-}
type ComboRowGetEnumValueNameFunc_WithClosures =
Handy.EnumValueObject.EnumValueObject
{- ^ /@value@/: the value from the enum from which to get a name -}
-> Ptr ()
{- ^ /@userData@/: user data -}
-> IO T.Text
{- ^ __Returns:__ a newly allocated displayable name that represents /@value@/ -}
-- | A convenience synonym for @`Nothing` :: `Maybe` `ComboRowGetEnumValueNameFunc_WithClosures`@.
noComboRowGetEnumValueNameFunc_WithClosures :: Maybe ComboRowGetEnumValueNameFunc_WithClosures
noComboRowGetEnumValueNameFunc_WithClosures = Nothing
-- | A simple wrapper that ignores the closure arguments.
drop_closures_ComboRowGetEnumValueNameFunc :: ComboRowGetEnumValueNameFunc -> ComboRowGetEnumValueNameFunc_WithClosures
drop_closures_ComboRowGetEnumValueNameFunc _f value _ = _f value
-- | Wrap the callback into a `GClosure`.
genClosure_ComboRowGetEnumValueNameFunc :: MonadIO m => ComboRowGetEnumValueNameFunc -> m (GClosure C_ComboRowGetEnumValueNameFunc)
genClosure_ComboRowGetEnumValueNameFunc cb = liftIO $ do
let cb' = drop_closures_ComboRowGetEnumValueNameFunc cb
let cb'' = wrap_ComboRowGetEnumValueNameFunc Nothing cb'
mk_ComboRowGetEnumValueNameFunc cb'' >>= B.GClosure.newGClosure
-- | Wrap a `ComboRowGetEnumValueNameFunc` into a `C_ComboRowGetEnumValueNameFunc`.
wrap_ComboRowGetEnumValueNameFunc ::
Maybe (Ptr (FunPtr C_ComboRowGetEnumValueNameFunc)) ->
ComboRowGetEnumValueNameFunc_WithClosures ->
C_ComboRowGetEnumValueNameFunc
wrap_ComboRowGetEnumValueNameFunc funptrptr _cb value userData = do
value' <- (newObject Handy.EnumValueObject.EnumValueObject) value
result <- _cb value' userData
maybeReleaseFunPtr funptrptr
result' <- textToCString result
return result'