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

    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.
    -}

    #define ENABLE_OVERLOADING \
           (!defined(__HADDOCK_VERSION__))

    module GI.Atk.Objects.GObjectAccessible
        (

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

     -- * Methods
    -- ** forObject #method:forObject#

        gObjectAccessibleForObject              ,

    -- ** getObject #method:getObject#

    #if 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.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 qualified GI.GObject.Objects.Object as GObject.Object

    -- | Memory-managed wrapper type.
    newtype GObjectAccessible = GObjectAccessible (ManagedPtr GObjectAccessible)
    foreign import ccall "atk_gobject_accessible_get_type"
        c_atk_gobject_accessible_get_type :: IO GType

    instance GObject GObjectAccessible where
        gobjectType _ = c_atk_gobject_accessible_get_type

    -- | Type class for types which can be safely cast to `GObjectAccessible`, for instance with `toGObjectAccessible`.
    class GObject o => IsGObjectAccessible o
    #if MIN_VERSION_base(4,9,0)
    instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError GObjectAccessible a) =>
        IsGObjectAccessible a
    #endif
    instance IsGObjectAccessible GObjectAccessible
    instance Atk.Object.IsObject GObjectAccessible
    instance GObject.Object.IsObject GObjectAccessible

    -- | 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 = liftIO . unsafeCastTo GObjectAccessible

    -- | A convenience alias for `Nothing` :: `Maybe` `GObjectAccessible`.
    noGObjectAccessible :: Maybe GObjectAccessible
    noGObjectAccessible = Nothing

    #if 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 "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) => O.IsLabelProxy t (GObjectAccessible -> p) where
        fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

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

    #endif

    #if 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 ENABLE_OVERLOADING
    #endif

    #if 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 'GI.Atk.Objects.GObjectAccessible.GObjectAccessible' -}
        -> m GObject.Object.Object
        {- ^ __Returns:__ a 'GI.GObject.Objects.Object.Object' which is the object for which /@obj@/ is
    the accessible object -}
    gObjectAccessibleGetObject obj = liftIO $ do
        obj' <- unsafeManagedPtrCastPtr obj
        result <- atk_gobject_accessible_get_object obj'
        checkUnexpectedReturnNULL "gObjectAccessibleGetObject" result
        result' <- (newObject GObject.Object.Object) result
        touchManagedPtr obj
        return result'

    #if 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 'GI.GObject.Objects.Object.Object' -}
        -> m Atk.Object.Object
        {- ^ __Returns:__ a 'GI.Atk.Objects.Object.Object' which is the accessible object for
    the /@obj@/ -}
    gObjectAccessibleForObject obj = liftIO $ do
        obj' <- unsafeManagedPtrCastPtr obj
        result <- atk_gobject_accessible_for_object obj'
        checkUnexpectedReturnNULL "gObjectAccessibleForObject" result
        result' <- (newObject Atk.Object.Object) result
        touchManagedPtr obj
        return result'

    #if ENABLE_OVERLOADING
    #endif