{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- This object class is derived from AtkObject. It can be used as a
-- basis for implementing accessible objects for GObjects which are
-- not derived from GtkWidget. One example of its use is in providing
-- an accessible object for GnomeCanvasItem in the GAIL library.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Atk.Objects.GObjectAccessible
    ( 

-- * Exported types
    GObjectAccessible(..)                   ,
    IsGObjectAccessible                     ,
    toGObjectAccessible                     ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveGObjectAccessibleMethod          ,
#endif


-- ** forObject #method:forObject#

    gObjectAccessibleForObject              ,


-- ** getObject #method:getObject#

#if defined(ENABLE_OVERLOADING)
    GObjectAccessibleGetObjectMethodInfo    ,
#endif
    gObjectAccessibleGetObject              ,




    ) 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.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 {-# SOURCE #-} qualified GI.Atk.Objects.Object as Atk.Object
import qualified GI.GObject.Objects.Object as GObject.Object

-- | Memory-managed wrapper type.
newtype GObjectAccessible = GObjectAccessible (SP.ManagedPtr GObjectAccessible)
    deriving (GObjectAccessible -> GObjectAccessible -> Bool
(GObjectAccessible -> GObjectAccessible -> Bool)
-> (GObjectAccessible -> GObjectAccessible -> Bool)
-> Eq GObjectAccessible
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GObjectAccessible -> GObjectAccessible -> Bool
$c/= :: GObjectAccessible -> GObjectAccessible -> Bool
== :: GObjectAccessible -> GObjectAccessible -> Bool
$c== :: GObjectAccessible -> GObjectAccessible -> Bool
Eq)

instance SP.ManagedPtrNewtype GObjectAccessible where
    toManagedPtr :: GObjectAccessible -> ManagedPtr GObjectAccessible
toManagedPtr (GObjectAccessible ManagedPtr GObjectAccessible
p) = ManagedPtr GObjectAccessible
p

foreign import ccall "atk_gobject_accessible_get_type"
    c_atk_gobject_accessible_get_type :: IO B.Types.GType

instance B.Types.TypedObject GObjectAccessible where
    glibType :: IO GType
glibType = IO GType
c_atk_gobject_accessible_get_type

instance B.Types.GObject GObjectAccessible

-- | Convert 'GObjectAccessible' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue GObjectAccessible where
    toGValue :: GObjectAccessible -> IO GValue
toGValue GObjectAccessible
o = do
        GType
gtype <- IO GType
c_atk_gobject_accessible_get_type
        GObjectAccessible
-> (Ptr GObjectAccessible -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr GObjectAccessible
o (GType
-> (GValue -> Ptr GObjectAccessible -> IO ())
-> Ptr GObjectAccessible
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr GObjectAccessible -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO GObjectAccessible
fromGValue GValue
gv = do
        Ptr GObjectAccessible
ptr <- GValue -> IO (Ptr GObjectAccessible)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr GObjectAccessible)
        (ManagedPtr GObjectAccessible -> GObjectAccessible)
-> Ptr GObjectAccessible -> IO GObjectAccessible
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr GObjectAccessible -> GObjectAccessible
GObjectAccessible Ptr GObjectAccessible
ptr
        
    

-- | Type class for types which can be safely cast to `GObjectAccessible`, for instance with `toGObjectAccessible`.
class (SP.GObject o, O.IsDescendantOf GObjectAccessible o) => IsGObjectAccessible o
instance (SP.GObject o, O.IsDescendantOf GObjectAccessible o) => IsGObjectAccessible o

instance O.HasParentTypes GObjectAccessible
type instance O.ParentTypes GObjectAccessible = '[Atk.Object.Object, GObject.Object.Object]

-- | Cast to `GObjectAccessible`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toGObjectAccessible :: (MonadIO m, IsGObjectAccessible o) => o -> m GObjectAccessible
toGObjectAccessible :: o -> m GObjectAccessible
toGObjectAccessible = IO GObjectAccessible -> m GObjectAccessible
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GObjectAccessible -> m GObjectAccessible)
-> (o -> IO GObjectAccessible) -> o -> m GObjectAccessible
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr GObjectAccessible -> GObjectAccessible)
-> o -> IO GObjectAccessible
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr GObjectAccessible -> GObjectAccessible
GObjectAccessible

#if defined(ENABLE_OVERLOADING)
type family ResolveGObjectAccessibleMethod (t :: Symbol) (o :: *) :: * where
    ResolveGObjectAccessibleMethod "addRelationship" o = Atk.Object.ObjectAddRelationshipMethodInfo
    ResolveGObjectAccessibleMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveGObjectAccessibleMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveGObjectAccessibleMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveGObjectAccessibleMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveGObjectAccessibleMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveGObjectAccessibleMethod "initialize" o = Atk.Object.ObjectInitializeMethodInfo
    ResolveGObjectAccessibleMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveGObjectAccessibleMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveGObjectAccessibleMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveGObjectAccessibleMethod "notifyStateChange" o = Atk.Object.ObjectNotifyStateChangeMethodInfo
    ResolveGObjectAccessibleMethod "peekParent" o = Atk.Object.ObjectPeekParentMethodInfo
    ResolveGObjectAccessibleMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveGObjectAccessibleMethod "refAccessibleChild" o = Atk.Object.ObjectRefAccessibleChildMethodInfo
    ResolveGObjectAccessibleMethod "refRelationSet" o = Atk.Object.ObjectRefRelationSetMethodInfo
    ResolveGObjectAccessibleMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveGObjectAccessibleMethod "refStateSet" o = Atk.Object.ObjectRefStateSetMethodInfo
    ResolveGObjectAccessibleMethod "removePropertyChangeHandler" o = Atk.Object.ObjectRemovePropertyChangeHandlerMethodInfo
    ResolveGObjectAccessibleMethod "removeRelationship" o = Atk.Object.ObjectRemoveRelationshipMethodInfo
    ResolveGObjectAccessibleMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveGObjectAccessibleMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveGObjectAccessibleMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveGObjectAccessibleMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveGObjectAccessibleMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveGObjectAccessibleMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveGObjectAccessibleMethod "getAccessibleId" o = Atk.Object.ObjectGetAccessibleIdMethodInfo
    ResolveGObjectAccessibleMethod "getAttributes" o = Atk.Object.ObjectGetAttributesMethodInfo
    ResolveGObjectAccessibleMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveGObjectAccessibleMethod "getDescription" o = Atk.Object.ObjectGetDescriptionMethodInfo
    ResolveGObjectAccessibleMethod "getIndexInParent" o = Atk.Object.ObjectGetIndexInParentMethodInfo
    ResolveGObjectAccessibleMethod "getLayer" o = Atk.Object.ObjectGetLayerMethodInfo
    ResolveGObjectAccessibleMethod "getMdiZorder" o = Atk.Object.ObjectGetMdiZorderMethodInfo
    ResolveGObjectAccessibleMethod "getNAccessibleChildren" o = Atk.Object.ObjectGetNAccessibleChildrenMethodInfo
    ResolveGObjectAccessibleMethod "getName" o = Atk.Object.ObjectGetNameMethodInfo
    ResolveGObjectAccessibleMethod "getObject" o = GObjectAccessibleGetObjectMethodInfo
    ResolveGObjectAccessibleMethod "getObjectLocale" o = Atk.Object.ObjectGetObjectLocaleMethodInfo
    ResolveGObjectAccessibleMethod "getParent" o = Atk.Object.ObjectGetParentMethodInfo
    ResolveGObjectAccessibleMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveGObjectAccessibleMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveGObjectAccessibleMethod "getRole" o = Atk.Object.ObjectGetRoleMethodInfo
    ResolveGObjectAccessibleMethod "setAccessibleId" o = Atk.Object.ObjectSetAccessibleIdMethodInfo
    ResolveGObjectAccessibleMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveGObjectAccessibleMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveGObjectAccessibleMethod "setDescription" o = Atk.Object.ObjectSetDescriptionMethodInfo
    ResolveGObjectAccessibleMethod "setName" o = Atk.Object.ObjectSetNameMethodInfo
    ResolveGObjectAccessibleMethod "setParent" o = Atk.Object.ObjectSetParentMethodInfo
    ResolveGObjectAccessibleMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveGObjectAccessibleMethod "setRole" o = Atk.Object.ObjectSetRoleMethodInfo
    ResolveGObjectAccessibleMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveGObjectAccessibleMethod t GObjectAccessible, O.MethodInfo info GObjectAccessible p) => OL.IsLabel t (GObjectAccessible -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList GObjectAccessible
type instance O.AttributeList GObjectAccessible = GObjectAccessibleAttributeList
type GObjectAccessibleAttributeList = ('[ '("accessibleComponentLayer", Atk.Object.ObjectAccessibleComponentLayerPropertyInfo), '("accessibleComponentMdiZorder", Atk.Object.ObjectAccessibleComponentMdiZorderPropertyInfo), '("accessibleDescription", Atk.Object.ObjectAccessibleDescriptionPropertyInfo), '("accessibleHypertextNlinks", Atk.Object.ObjectAccessibleHypertextNlinksPropertyInfo), '("accessibleName", Atk.Object.ObjectAccessibleNamePropertyInfo), '("accessibleParent", Atk.Object.ObjectAccessibleParentPropertyInfo), '("accessibleRole", Atk.Object.ObjectAccessibleRolePropertyInfo), '("accessibleTableCaption", Atk.Object.ObjectAccessibleTableCaptionPropertyInfo), '("accessibleTableCaptionObject", Atk.Object.ObjectAccessibleTableCaptionObjectPropertyInfo), '("accessibleTableColumnDescription", Atk.Object.ObjectAccessibleTableColumnDescriptionPropertyInfo), '("accessibleTableColumnHeader", Atk.Object.ObjectAccessibleTableColumnHeaderPropertyInfo), '("accessibleTableRowDescription", Atk.Object.ObjectAccessibleTableRowDescriptionPropertyInfo), '("accessibleTableRowHeader", Atk.Object.ObjectAccessibleTableRowHeaderPropertyInfo), '("accessibleTableSummary", Atk.Object.ObjectAccessibleTableSummaryPropertyInfo), '("accessibleValue", Atk.Object.ObjectAccessibleValuePropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList GObjectAccessible = GObjectAccessibleSignalList
type GObjectAccessibleSignalList = ('[ '("activeDescendantChanged", Atk.Object.ObjectActiveDescendantChangedSignalInfo), '("childrenChanged", Atk.Object.ObjectChildrenChangedSignalInfo), '("focusEvent", Atk.Object.ObjectFocusEventSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("propertyChange", Atk.Object.ObjectPropertyChangeSignalInfo), '("stateChange", Atk.Object.ObjectStateChangeSignalInfo), '("visibleDataChanged", Atk.Object.ObjectVisibleDataChangedSignalInfo)] :: [(Symbol, *)])

#endif

-- method GObjectAccessible::get_object
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "obj"
--           , argType =
--               TInterface Name { namespace = "Atk" , name = "GObjectAccessible" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #AtkGObjectAccessible"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "GObject" , name = "Object" })
-- throws : False
-- Skip return : False

foreign import ccall "atk_gobject_accessible_get_object" atk_gobject_accessible_get_object :: 
    Ptr GObjectAccessible ->                -- obj : TInterface (Name {namespace = "Atk", name = "GObjectAccessible"})
    IO (Ptr GObject.Object.Object)

-- | Gets the GObject for which /@obj@/ is the accessible object.
gObjectAccessibleGetObject ::
    (B.CallStack.HasCallStack, MonadIO m, IsGObjectAccessible a) =>
    a
    -- ^ /@obj@/: a t'GI.Atk.Objects.GObjectAccessible.GObjectAccessible'
    -> m GObject.Object.Object
    -- ^ __Returns:__ a t'GI.GObject.Objects.Object.Object' which is the object for which /@obj@/ is
    -- the accessible object
gObjectAccessibleGetObject :: a -> m Object
gObjectAccessibleGetObject a
obj = 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 GObjectAccessible
obj' <- a -> IO (Ptr GObjectAccessible)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
obj
    Ptr Object
result <- Ptr GObjectAccessible -> IO (Ptr Object)
atk_gobject_accessible_get_object Ptr GObjectAccessible
obj'
    Text -> Ptr Object -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"gObjectAccessibleGetObject" 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
GObject.Object.Object) Ptr Object
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
obj
    Object -> IO Object
forall (m :: * -> *) a. Monad m => a -> m a
return Object
result'

#if defined(ENABLE_OVERLOADING)
data GObjectAccessibleGetObjectMethodInfo
instance (signature ~ (m GObject.Object.Object), MonadIO m, IsGObjectAccessible a) => O.MethodInfo GObjectAccessibleGetObjectMethodInfo a signature where
    overloadedMethod = gObjectAccessibleGetObject

#endif

-- method GObjectAccessible::for_object
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "obj"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "Object" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GObject" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Atk" , name = "Object" })
-- throws : False
-- Skip return : False

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

-- | Gets the accessible object for the specified /@obj@/.
gObjectAccessibleForObject ::
    (B.CallStack.HasCallStack, MonadIO m, GObject.Object.IsObject a) =>
    a
    -- ^ /@obj@/: a t'GI.GObject.Objects.Object.Object'
    -> m Atk.Object.Object
    -- ^ __Returns:__ a t'GI.Atk.Objects.Object.Object' which is the accessible object for
    -- the /@obj@/
gObjectAccessibleForObject :: a -> m Object
gObjectAccessibleForObject a
obj = 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
obj' <- a -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
obj
    Ptr Object
result <- Ptr Object -> IO (Ptr Object)
atk_gobject_accessible_for_object Ptr Object
obj'
    Text -> Ptr Object -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"gObjectAccessibleForObject" 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
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
obj
    Object -> IO Object
forall (m :: * -> *) a. Monad m => a -> m a
return Object
result'

#if defined(ENABLE_OVERLOADING)
#endif