{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) -} module GI.Atk.Callbacks ( -- * Signals -- ** EventListener #signal:EventListener# C_EventListener , EventListener , dynamic_EventListener , genClosure_EventListener , mk_EventListener , noEventListener , wrap_EventListener , -- ** EventListenerInit #signal:EventListenerInit# C_EventListenerInit , EventListenerInit , dynamic_EventListenerInit , genClosure_EventListenerInit , mk_EventListenerInit , noEventListenerInit , wrap_EventListenerInit , -- ** FocusHandler #signal:FocusHandler# C_FocusHandler , FocusHandler , dynamic_FocusHandler , genClosure_FocusHandler , mk_FocusHandler , noFocusHandler , wrap_FocusHandler , -- ** Function #signal:Function# C_Function , Function , Function_WithClosures , drop_closures_Function , dynamic_Function , genClosure_Function , mk_Function , noFunction , noFunction_WithClosures , wrap_Function , -- ** KeySnoopFunc #signal:KeySnoopFunc# C_KeySnoopFunc , KeySnoopFunc , KeySnoopFunc_WithClosures , drop_closures_KeySnoopFunc , dynamic_KeySnoopFunc , genClosure_KeySnoopFunc , mk_KeySnoopFunc , noKeySnoopFunc , noKeySnoopFunc_WithClosures , wrap_KeySnoopFunc , -- ** PropertyChangeHandler #signal:PropertyChangeHandler# C_PropertyChangeHandler , PropertyChangeHandler , dynamic_PropertyChangeHandler , genClosure_PropertyChangeHandler , mk_PropertyChangeHandler , noPropertyChangeHandler , wrap_PropertyChangeHandler , ) 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.GError as B.GError import qualified Data.GI.Base.GVariant as B.GVariant import qualified Data.GI.Base.GParamSpec as B.GParamSpec import qualified Data.GI.Base.CallStack as B.CallStack 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 {-# SOURCE #-} qualified GI.Atk.Objects.Object as Atk.Object import {-# SOURCE #-} qualified GI.Atk.Structs.KeyEventStruct as Atk.KeyEventStruct import {-# SOURCE #-} qualified GI.Atk.Structs.PropertyValues as Atk.PropertyValues -- callback PropertyChangeHandler -- -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "obj", argType = TInterface (Name {namespace = "Atk", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "atkobject which property changes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "vals", argType = TInterface (Name {namespace = "Atk", name = "PropertyValues"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "values changed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Just (DeprecationInfo {deprecatedSinceVersion = Nothing, deprecationMessage = Just "Since 2.12."}), callableDocumentation = Documentation {rawDocText = Just "An AtkPropertyChangeHandler is a function which is executed when an\nAtkObject's property changes value. It is specified in a call to\natk_object_connect_property_change_handler().", sinceVersion = Nothing}} type C_PropertyChangeHandler = Ptr Atk.Object.Object -> Ptr Atk.PropertyValues.PropertyValues -> IO () -- Args : [Arg {argCName = "obj", argType = TInterface (Name {namespace = "Atk", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "atkobject which property changes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "vals", argType = TInterface (Name {namespace = "Atk", name = "PropertyValues"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "values changed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "dynamic" __dynamic_C_PropertyChangeHandler :: FunPtr C_PropertyChangeHandler -> C_PropertyChangeHandler dynamic_PropertyChangeHandler :: (B.CallStack.HasCallStack, MonadIO m, Atk.Object.IsObject a) => FunPtr C_PropertyChangeHandler -> a {- ^ /@obj@/: atkobject which property changes -} -> Atk.PropertyValues.PropertyValues {- ^ /@vals@/: values changed -} -> m () dynamic_PropertyChangeHandler __funPtr obj vals = liftIO $ do obj' <- unsafeManagedPtrCastPtr obj vals' <- unsafeManagedPtrGetPtr vals (__dynamic_C_PropertyChangeHandler __funPtr) obj' vals' touchManagedPtr obj touchManagedPtr vals return () foreign import ccall "wrapper" mk_PropertyChangeHandler :: C_PropertyChangeHandler -> IO (FunPtr C_PropertyChangeHandler) {-# DEPRECATED PropertyChangeHandler ["Since 2.12."] #-} type PropertyChangeHandler = Atk.Object.Object -> Atk.PropertyValues.PropertyValues -> IO () noPropertyChangeHandler :: Maybe PropertyChangeHandler noPropertyChangeHandler = Nothing genClosure_PropertyChangeHandler :: PropertyChangeHandler -> IO Closure genClosure_PropertyChangeHandler cb = do let cb' = wrap_PropertyChangeHandler Nothing cb mk_PropertyChangeHandler cb' >>= newCClosure wrap_PropertyChangeHandler :: Maybe (Ptr (FunPtr C_PropertyChangeHandler)) -> PropertyChangeHandler -> Ptr Atk.Object.Object -> Ptr Atk.PropertyValues.PropertyValues -> IO () wrap_PropertyChangeHandler funptrptr _cb obj vals = do obj' <- (newObject Atk.Object.Object) obj vals' <- (newPtr Atk.PropertyValues.PropertyValues) vals _cb obj' vals' maybeReleaseFunPtr funptrptr -- callback KeySnoopFunc -- -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "TRUE (nonzero) if the event emission should be stopped and the event\ndiscarded without being passed to the normal GUI recipient; FALSE (zero) if the\nevent dispatch to the client application should proceed as normal.\n\nsee atk_add_key_event_listener.", sinceVersion = Nothing}, args = [Arg {argCName = "event", argType = TInterface (Name {namespace = "Atk", name = "KeyEventStruct"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an AtkKeyEventStruct containing information about the key event for which\nnotification is being given.", 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 "a block of data which will be passed to the event listener, on notification.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "An #AtkKeySnoopFunc is a type of callback which is called whenever a key event occurs,\nif registered via atk_add_key_event_listener. It allows for pre-emptive\ninterception of key events via the return code as described below.", sinceVersion = Nothing}} type C_KeySnoopFunc = Ptr Atk.KeyEventStruct.KeyEventStruct -> Ptr () -> IO Int32 -- Args : [Arg {argCName = "event", argType = TInterface (Name {namespace = "Atk", name = "KeyEventStruct"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an AtkKeyEventStruct containing information about the key event for which\nnotification is being given.", 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 "a block of data which will be passed to the event listener, on notification.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "dynamic" __dynamic_C_KeySnoopFunc :: FunPtr C_KeySnoopFunc -> C_KeySnoopFunc dynamic_KeySnoopFunc :: (B.CallStack.HasCallStack, MonadIO m) => FunPtr C_KeySnoopFunc -> Atk.KeyEventStruct.KeyEventStruct {- ^ /@event@/: an AtkKeyEventStruct containing information about the key event for which notification is being given. -} -> Ptr () {- ^ /@userData@/: a block of data which will be passed to the event listener, on notification. -} -> m Int32 {- ^ __Returns:__ TRUE (nonzero) if the event emission should be stopped and the event discarded without being passed to the normal GUI recipient; FALSE (zero) if the event dispatch to the client application should proceed as normal. see atk_add_key_event_listener. -} dynamic_KeySnoopFunc __funPtr event userData = liftIO $ do event' <- unsafeManagedPtrGetPtr event result <- (__dynamic_C_KeySnoopFunc __funPtr) event' userData touchManagedPtr event return result foreign import ccall "wrapper" mk_KeySnoopFunc :: C_KeySnoopFunc -> IO (FunPtr C_KeySnoopFunc) type KeySnoopFunc = Atk.KeyEventStruct.KeyEventStruct -> IO Int32 noKeySnoopFunc :: Maybe KeySnoopFunc noKeySnoopFunc = Nothing type KeySnoopFunc_WithClosures = Atk.KeyEventStruct.KeyEventStruct -> Ptr () -> IO Int32 noKeySnoopFunc_WithClosures :: Maybe KeySnoopFunc_WithClosures noKeySnoopFunc_WithClosures = Nothing drop_closures_KeySnoopFunc :: KeySnoopFunc -> KeySnoopFunc_WithClosures drop_closures_KeySnoopFunc _f event _ = _f event genClosure_KeySnoopFunc :: KeySnoopFunc -> IO Closure genClosure_KeySnoopFunc cb = do let cb' = drop_closures_KeySnoopFunc cb let cb'' = wrap_KeySnoopFunc Nothing cb' mk_KeySnoopFunc cb'' >>= newCClosure wrap_KeySnoopFunc :: Maybe (Ptr (FunPtr C_KeySnoopFunc)) -> KeySnoopFunc_WithClosures -> Ptr Atk.KeyEventStruct.KeyEventStruct -> Ptr () -> IO Int32 wrap_KeySnoopFunc funptrptr _cb event userData = do event' <- (newPtr Atk.KeyEventStruct.KeyEventStruct) event result <- _cb event' userData maybeReleaseFunPtr funptrptr return result -- callback Function -- -> Callable {returnType = Just (TBasicType TBoolean), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "not used", sinceVersion = Nothing}, args = [Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "custom data defined by the user", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 0, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "An AtkFunction is a function definition used for padding which has\nbeen added to class and interface structures to allow for expansion\nin the future.", sinceVersion = Nothing}} type C_Function = Ptr () -> IO CInt -- Args : [Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "custom data defined by the user", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 0, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "dynamic" __dynamic_C_Function :: FunPtr C_Function -> C_Function dynamic_Function :: (B.CallStack.HasCallStack, MonadIO m) => FunPtr C_Function -> Ptr () {- ^ /@userData@/: custom data defined by the user -} -> m Bool {- ^ __Returns:__ not used -} dynamic_Function __funPtr userData = liftIO $ do result <- (__dynamic_C_Function __funPtr) userData let result' = (/= 0) result return result' foreign import ccall "wrapper" mk_Function :: C_Function -> IO (FunPtr C_Function) type Function = IO Bool noFunction :: Maybe Function noFunction = Nothing type Function_WithClosures = Ptr () -> IO Bool noFunction_WithClosures :: Maybe Function_WithClosures noFunction_WithClosures = Nothing drop_closures_Function :: Function -> Function_WithClosures drop_closures_Function _f _ = _f genClosure_Function :: Function -> IO Closure genClosure_Function cb = do let cb' = drop_closures_Function cb let cb'' = wrap_Function Nothing cb' mk_Function cb'' >>= newCClosure wrap_Function :: Maybe (Ptr (FunPtr C_Function)) -> Function_WithClosures -> Ptr () -> IO CInt wrap_Function funptrptr _cb userData = do result <- _cb userData maybeReleaseFunPtr funptrptr let result' = (fromIntegral . fromEnum) result return result' -- callback FocusHandler -- -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "object", argType = TInterface (Name {namespace = "Atk", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #AtkObject that receives/lose the focus", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "focus_in", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "TRUE if the object receives the focus", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Just (DeprecationInfo {deprecatedSinceVersion = Just "2.9.4", deprecationMessage = Just "Deprecated with atk_component_add_focus_handler()\nand atk_component_remove_focus_handler(). See those\nmethods for more information."}), callableDocumentation = Documentation {rawDocText = Just "The type of callback function used for\natk_component_add_focus_handler() and\natk_component_remove_focus_handler()", sinceVersion = Nothing}} type C_FocusHandler = Ptr Atk.Object.Object -> CInt -> IO () -- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "Atk", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #AtkObject that receives/lose the focus", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "focus_in", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "TRUE if the object receives the focus", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "dynamic" __dynamic_C_FocusHandler :: FunPtr C_FocusHandler -> C_FocusHandler dynamic_FocusHandler :: (B.CallStack.HasCallStack, MonadIO m, Atk.Object.IsObject a) => FunPtr C_FocusHandler -> a {- ^ /@object@/: the 'GI.Atk.Objects.Object.Object' that receives\/lose the focus -} -> Bool {- ^ /@focusIn@/: TRUE if the object receives the focus -} -> m () dynamic_FocusHandler __funPtr object focusIn = liftIO $ do object' <- unsafeManagedPtrCastPtr object let focusIn' = (fromIntegral . fromEnum) focusIn (__dynamic_C_FocusHandler __funPtr) object' focusIn' touchManagedPtr object return () foreign import ccall "wrapper" mk_FocusHandler :: C_FocusHandler -> IO (FunPtr C_FocusHandler) {-# DEPRECATED FocusHandler ["(Since version 2.9.4)","Deprecated with @/atk_component_add_focus_handler()/@","and 'GI.Atk.Interfaces.Component.componentRemoveFocusHandler'. See those","methods for more information."] #-} type FocusHandler = Atk.Object.Object -> Bool -> IO () noFocusHandler :: Maybe FocusHandler noFocusHandler = Nothing genClosure_FocusHandler :: FocusHandler -> IO Closure genClosure_FocusHandler cb = do let cb' = wrap_FocusHandler Nothing cb mk_FocusHandler cb' >>= newCClosure wrap_FocusHandler :: Maybe (Ptr (FunPtr C_FocusHandler)) -> FocusHandler -> Ptr Atk.Object.Object -> CInt -> IO () wrap_FocusHandler funptrptr _cb object focusIn = do object' <- (newObject Atk.Object.Object) object let focusIn' = (/= 0) focusIn _cb object' focusIn' maybeReleaseFunPtr funptrptr -- callback EventListenerInit -- -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "An #AtkEventListenerInit function is a special function that is\ncalled in order to initialize the per-object event registration system\nused by #AtkEventListener, if any preparation is required.\n\nsee atk_focus_tracker_init.", sinceVersion = Nothing}} type C_EventListenerInit = IO () -- Args : [] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "dynamic" __dynamic_C_EventListenerInit :: FunPtr C_EventListenerInit -> C_EventListenerInit dynamic_EventListenerInit :: (B.CallStack.HasCallStack, MonadIO m) => FunPtr C_EventListenerInit -> m () dynamic_EventListenerInit __funPtr = liftIO $ do (__dynamic_C_EventListenerInit __funPtr) return () foreign import ccall "wrapper" mk_EventListenerInit :: C_EventListenerInit -> IO (FunPtr C_EventListenerInit) type EventListenerInit = IO () noEventListenerInit :: Maybe EventListenerInit noEventListenerInit = Nothing genClosure_EventListenerInit :: EventListenerInit -> IO Closure genClosure_EventListenerInit cb = do let cb' = wrap_EventListenerInit Nothing cb mk_EventListenerInit cb' >>= newCClosure wrap_EventListenerInit :: Maybe (Ptr (FunPtr C_EventListenerInit)) -> EventListenerInit -> IO () wrap_EventListenerInit funptrptr _cb = do _cb maybeReleaseFunPtr funptrptr -- callback EventListener -- -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "obj", argType = TInterface (Name {namespace = "Atk", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An #AtkObject instance for whom the callback will be called when\nthe specified event (e.g. 'focus:') takes place.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "A function which is called when an object emits a matching event,\nas used in #atk_add_focus_tracker.\nCurrently the only events for which object-specific handlers are\nsupported are events of type \"focus:\". Most clients of ATK will prefer to\nattach signal handlers for the various ATK signals instead.\n\nsee atk_add_focus_tracker.", sinceVersion = Nothing}} type C_EventListener = Ptr Atk.Object.Object -> IO () -- Args : [Arg {argCName = "obj", argType = TInterface (Name {namespace = "Atk", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An #AtkObject instance for whom the callback will be called when\nthe specified event (e.g. 'focus:') takes place.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "dynamic" __dynamic_C_EventListener :: FunPtr C_EventListener -> C_EventListener dynamic_EventListener :: (B.CallStack.HasCallStack, MonadIO m, Atk.Object.IsObject a) => FunPtr C_EventListener -> a {- ^ /@obj@/: An 'GI.Atk.Objects.Object.Object' instance for whom the callback will be called when the specified event (e.g. \'focus:\') takes place. -} -> m () dynamic_EventListener __funPtr obj = liftIO $ do obj' <- unsafeManagedPtrCastPtr obj (__dynamic_C_EventListener __funPtr) obj' touchManagedPtr obj return () foreign import ccall "wrapper" mk_EventListener :: C_EventListener -> IO (FunPtr C_EventListener) type EventListener = Atk.Object.Object -> IO () noEventListener :: Maybe EventListener noEventListener = Nothing genClosure_EventListener :: EventListener -> IO Closure genClosure_EventListener cb = do let cb' = wrap_EventListener Nothing cb mk_EventListener cb' >>= newCClosure wrap_EventListener :: Maybe (Ptr (FunPtr C_EventListener)) -> EventListener -> Ptr Atk.Object.Object -> IO () wrap_EventListener funptrptr _cb obj = do obj' <- (newObject Atk.Object.Object) obj _cb obj' maybeReleaseFunPtr funptrptr