{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.Atk.Functions
    ( 

 -- * Methods
-- ** focusTrackerNotify #method:focusTrackerNotify#

    focusTrackerNotify                      ,


-- ** getBinaryAge #method:getBinaryAge#

    getBinaryAge                            ,


-- ** getDefaultRegistry #method:getDefaultRegistry#

    getDefaultRegistry                      ,


-- ** getFocusObject #method:getFocusObject#

    getFocusObject                          ,


-- ** getInterfaceAge #method:getInterfaceAge#

    getInterfaceAge                         ,


-- ** getMajorVersion #method:getMajorVersion#

    getMajorVersion                         ,


-- ** getMicroVersion #method:getMicroVersion#

    getMicroVersion                         ,


-- ** getMinorVersion #method:getMinorVersion#

    getMinorVersion                         ,


-- ** getRoot #method:getRoot#

    getRoot                                 ,


-- ** getToolkitName #method:getToolkitName#

    getToolkitName                          ,


-- ** getToolkitVersion #method:getToolkitVersion#

    getToolkitVersion                       ,


-- ** getVersion #method:getVersion#

    getVersion                              ,


-- ** removeFocusTracker #method:removeFocusTracker#

    removeFocusTracker                      ,


-- ** removeGlobalEventListener #method:removeGlobalEventListener#

    removeGlobalEventListener               ,


-- ** removeKeyEventListener #method:removeKeyEventListener#

    removeKeyEventListener                  ,




    ) 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.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.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.Objects.Registry as Atk.Registry

-- function atk_remove_key_event_listener
-- Args : [Arg {argCName = "listener_id", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the id of the event listener to remove", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "atk_remove_key_event_listener" atk_remove_key_event_listener :: 
    Word32 ->                               -- listener_id : TBasicType TUInt
    IO ()

{- |
/@listenerId@/ is the value returned by @/atk_add_key_event_listener/@
when you registered that event listener.

Removes the specified event listener.
-}
removeKeyEventListener ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    {- ^ /@listenerId@/: the id of the event listener to remove -}
    -> m ()
removeKeyEventListener :: Word32 -> m ()
removeKeyEventListener listenerId :: Word32
listenerId = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Word32 -> IO ()
atk_remove_key_event_listener Word32
listenerId
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function atk_remove_global_event_listener
-- Args : [Arg {argCName = "listener_id", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the id of the event listener to remove", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "atk_remove_global_event_listener" atk_remove_global_event_listener :: 
    Word32 ->                               -- listener_id : TBasicType TUInt
    IO ()

{- |
/@listenerId@/ is the value returned by @/atk_add_global_event_listener/@
when you registered that event listener.

Toolkit implementor note: ATK provides a default implementation for
this virtual method. ATK implementors are discouraged from
reimplementing this method.

Toolkit implementor note: this method is not intended to be used by
ATK implementors but by ATK consumers.

Removes the specified event listener
-}
removeGlobalEventListener ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    {- ^ /@listenerId@/: the id of the event listener to remove -}
    -> m ()
removeGlobalEventListener :: Word32 -> m ()
removeGlobalEventListener listenerId :: Word32
listenerId = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Word32 -> IO ()
atk_remove_global_event_listener Word32
listenerId
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function atk_remove_focus_tracker
-- Args : [Arg {argCName = "tracker_id", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the id of the focus tracker to remove", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "atk_remove_focus_tracker" atk_remove_focus_tracker :: 
    Word32 ->                               -- tracker_id : TBasicType TUInt
    IO ()

{-# DEPRECATED removeFocusTracker ["(Since version 2.9.4)","Focus tracking has been dropped as a feature","  to be implemented by ATK itself. If you need focus tracking on your","  implementation, subscribe to the 'GI.Atk.Objects.Object.Object'::@/state-change/@ \\\"focused\\\"","  signal."] #-}
{- |
Removes the specified focus tracker from the list of functions
to be called when any object receives focus.
-}
removeFocusTracker ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    {- ^ /@trackerId@/: the id of the focus tracker to remove -}
    -> m ()
removeFocusTracker :: Word32 -> m ()
removeFocusTracker trackerId :: Word32
trackerId = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Word32 -> IO ()
atk_remove_focus_tracker Word32
trackerId
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function atk_get_version
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "atk_get_version" atk_get_version :: 
    IO CString

{- |
Gets the current version for ATK.

/Since: 1.20/
-}
getVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m T.Text
    {- ^ __Returns:__ version string for ATK -}
getVersion :: m Text
getVersion  = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
atk_get_version
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getVersion" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function atk_get_toolkit_version
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "atk_get_toolkit_version" atk_get_toolkit_version :: 
    IO CString

{- |
Gets version string for the GUI toolkit implementing ATK for this application.
-}
getToolkitVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m T.Text
    {- ^ __Returns:__ version string for the GUI toolkit implementing ATK for this application -}
getToolkitVersion :: m Text
getToolkitVersion  = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
atk_get_toolkit_version
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getToolkitVersion" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function atk_get_toolkit_name
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "atk_get_toolkit_name" atk_get_toolkit_name :: 
    IO CString

{- |
Gets name string for the GUI toolkit implementing ATK for this application.
-}
getToolkitName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m T.Text
    {- ^ __Returns:__ name string for the GUI toolkit implementing ATK for this application -}
getToolkitName :: m Text
getToolkitName  = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
atk_get_toolkit_name
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getToolkitName" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function atk_get_root
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Atk", name = "Object"}))
-- throws : False
-- Skip return : False

foreign import ccall "atk_get_root" atk_get_root :: 
    IO (Ptr Atk.Object.Object)

{- |
Gets the root accessible container for the current application.
-}
getRoot ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Atk.Object.Object
    {- ^ __Returns:__ the root accessible container for the current
application -}
getRoot :: m Object
getRoot  = IO Object -> m Object
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Object -> m Object) -> IO Object -> m Object
forall a b. (a -> b) -> a -> b
$ do
    Ptr Object
result <- IO (Ptr Object)
atk_get_root
    Text -> Ptr Object -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getRoot" Ptr Object
result
    Object
result' <- ((ManagedPtr Object -> Object) -> Ptr Object -> IO Object
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Object -> Object
Atk.Object.Object) Ptr Object
result
    Object -> IO Object
forall (m :: * -> *) a. Monad m => a -> m a
return Object
result'


-- function atk_get_minor_version
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "atk_get_minor_version" atk_get_minor_version :: 
    IO Word32

{- |
Returns the minor version number of the ATK library.  (e.g. in ATK
version 2.7.4 this is 7.)

This function is in the library, so it represents the ATK library
your code is are running against. In contrast, the
'GI.Atk.Constants.MINOR_VERSION' macro represents the minor version of the ATK
headers you have included when compiling your code.

/Since: 2.8/
-}
getMinorVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    {- ^ __Returns:__ the minor version number of the ATK library -}
getMinorVersion :: m Word32
getMinorVersion  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
atk_get_minor_version
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function atk_get_micro_version
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "atk_get_micro_version" atk_get_micro_version :: 
    IO Word32

{- |
Returns the micro version number of the ATK library.  (e.g. in ATK
version 2.7.4 this is 4.)

This function is in the library, so it represents the ATK library
your code is are running against. In contrast, the
'GI.Atk.Constants.MICRO_VERSION' macro represents the micro version of the ATK
headers you have included when compiling your code.

/Since: 2.8/
-}
getMicroVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    {- ^ __Returns:__ the micro version number of the ATK library -}
getMicroVersion :: m Word32
getMicroVersion  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
atk_get_micro_version
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function atk_get_major_version
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "atk_get_major_version" atk_get_major_version :: 
    IO Word32

{- |
Returns the major version number of the ATK library.  (e.g. in ATK
version 2.7.4 this is 2.)

This function is in the library, so it represents the ATK library
your code is running against. In contrast, the 'GI.Atk.Constants.MAJOR_VERSION'
macro represents the major version of the ATK headers you have
included when compiling your code.

/Since: 2.8/
-}
getMajorVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    {- ^ __Returns:__ the major version number of the ATK library -}
getMajorVersion :: m Word32
getMajorVersion  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
atk_get_major_version
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function atk_get_interface_age
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "atk_get_interface_age" atk_get_interface_age :: 
    IO Word32

{- |
Returns the interface age as passed to libtool when building the
ATK library the process is running against.

/Since: 2.8/
-}
getInterfaceAge ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    {- ^ __Returns:__ the interface age of the ATK library -}
getInterfaceAge :: m Word32
getInterfaceAge  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
atk_get_interface_age
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function atk_get_focus_object
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Atk", name = "Object"}))
-- throws : False
-- Skip return : False

foreign import ccall "atk_get_focus_object" atk_get_focus_object :: 
    IO (Ptr Atk.Object.Object)

{- |
Gets the currently focused object.

/Since: 1.6/
-}
getFocusObject ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Atk.Object.Object
    {- ^ __Returns:__ the currently focused object for the current
application -}
getFocusObject :: m Object
getFocusObject  = IO Object -> m Object
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Object -> m Object) -> IO Object -> m Object
forall a b. (a -> b) -> a -> b
$ do
    Ptr Object
result <- IO (Ptr Object)
atk_get_focus_object
    Text -> Ptr Object -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getFocusObject" Ptr Object
result
    Object
result' <- ((ManagedPtr Object -> Object) -> Ptr Object -> IO Object
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Object -> Object
Atk.Object.Object) Ptr Object
result
    Object -> IO Object
forall (m :: * -> *) a. Monad m => a -> m a
return Object
result'


-- function atk_get_default_registry
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Atk", name = "Registry"}))
-- throws : False
-- Skip return : False

foreign import ccall "atk_get_default_registry" atk_get_default_registry :: 
    IO (Ptr Atk.Registry.Registry)

{- |
Gets a default implementation of the 'GI.Atk.Objects.ObjectFactory.ObjectFactory'\/type
registry.
Note: For most toolkit maintainers, this will be the correct
registry for registering new 'GI.Atk.Objects.Object.Object' factories. Following
a call to this function, maintainers may call 'GI.Atk.Objects.Registry.registrySetFactoryType'
to associate an 'GI.Atk.Objects.ObjectFactory.ObjectFactory' subclass with the GType of objects
for whom accessibility information will be provided.
-}
getDefaultRegistry ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Atk.Registry.Registry
    {- ^ __Returns:__ a default implementation of the
'GI.Atk.Objects.ObjectFactory.ObjectFactory'\/type registry -}
getDefaultRegistry :: m Registry
getDefaultRegistry  = IO Registry -> m Registry
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Registry -> m Registry) -> IO Registry -> m Registry
forall a b. (a -> b) -> a -> b
$ do
    Ptr Registry
result <- IO (Ptr Registry)
atk_get_default_registry
    Text -> Ptr Registry -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getDefaultRegistry" Ptr Registry
result
    Registry
result' <- ((ManagedPtr Registry -> Registry) -> Ptr Registry -> IO Registry
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Registry -> Registry
Atk.Registry.Registry) Ptr Registry
result
    Registry -> IO Registry
forall (m :: * -> *) a. Monad m => a -> m a
return Registry
result'


-- function atk_get_binary_age
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "atk_get_binary_age" atk_get_binary_age :: 
    IO Word32

{- |
Returns the binary age as passed to libtool when building the ATK
library the process is running against.

/Since: 2.8/
-}
getBinaryAge ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    {- ^ __Returns:__ the binary age of the ATK library -}
getBinaryAge :: m Word32
getBinaryAge  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
atk_get_binary_age
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function atk_focus_tracker_notify
-- Args : [Arg {argCName = "object", argType = TInterface (Name {namespace = "Atk", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkObject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "atk_focus_tracker_notify" atk_focus_tracker_notify :: 
    Ptr Atk.Object.Object ->                -- object : TInterface (Name {namespace = "Atk", name = "Object"})
    IO ()

{-# DEPRECATED focusTrackerNotify ["(Since version 2.9.4)","Focus tracking has been dropped as a feature","to be implemented by ATK itself. As 'GI.Atk.Objects.Object.Object'::@/focus-event/@ was","deprecated in favor of a 'GI.Atk.Objects.Object.Object'::@/state-change/@ signal, in order","to notify a focus change on your implementation, you can use","'GI.Atk.Objects.Object.objectNotifyStateChange' instead."] #-}
{- |
Cause the focus tracker functions which have been specified to be
executed for the object.
-}
focusTrackerNotify ::
    (B.CallStack.HasCallStack, MonadIO m, Atk.Object.IsObject a) =>
    a
    {- ^ /@object@/: an 'GI.Atk.Objects.Object.Object' -}
    -> m ()
focusTrackerNotify :: a -> m ()
focusTrackerNotify object :: a
object = 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 Object
object' <- a -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
object
    Ptr Object -> IO ()
atk_focus_tracker_notify Ptr Object
object'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
object
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()