{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A boxed type which wraps a list of references to GtkAccessible objects.
-- 
-- /Since: 4.14/

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

module GI.Gtk.Structs.AccessibleList
    ( 

-- * Exported types
    AccessibleList(..)                      ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- /None/.
-- 
-- ==== Getters
-- [getObjects]("GI.Gtk.Structs.AccessibleList#g:method:getObjects").
-- 
-- ==== Setters
-- /None/.

#if defined(ENABLE_OVERLOADING)
    ResolveAccessibleListMethod             ,
#endif

-- ** getObjects #method:getObjects#

#if defined(ENABLE_OVERLOADING)
    AccessibleListGetObjectsMethodInfo      ,
#endif
    accessibleListGetObjects                ,


-- ** newFromArray #method:newFromArray#

    accessibleListNewFromArray              ,


-- ** newFromList #method:newFromList#

    accessibleListNewFromList               ,




    ) 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.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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 GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gdk.Objects.Display as Gdk.Display
import {-# SOURCE #-} qualified GI.Gtk.Enums as Gtk.Enums
import {-# SOURCE #-} qualified GI.Gtk.Interfaces.Accessible as Gtk.Accessible
import {-# SOURCE #-} qualified GI.Gtk.Objects.ATContext as Gtk.ATContext

#else
import {-# SOURCE #-} qualified GI.Gtk.Interfaces.Accessible as Gtk.Accessible

#endif

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

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

foreign import ccall "gtk_accessible_list_get_type" c_gtk_accessible_list_get_type :: 
    IO GType

type instance O.ParentTypes AccessibleList = '[]
instance O.HasParentTypes AccessibleList

instance B.Types.TypedObject AccessibleList where
    glibType :: IO GType
glibType = IO GType
c_gtk_accessible_list_get_type

instance B.Types.GBoxed AccessibleList

-- | Convert 'AccessibleList' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe AccessibleList) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_gtk_accessible_list_get_type
    gvalueSet_ :: Ptr GValue -> Maybe AccessibleList -> IO ()
gvalueSet_ Ptr GValue
gv Maybe AccessibleList
P.Nothing = Ptr GValue -> Ptr AccessibleList -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr AccessibleList
forall a. Ptr a
FP.nullPtr :: FP.Ptr AccessibleList)
    gvalueSet_ Ptr GValue
gv (P.Just AccessibleList
obj) = AccessibleList -> (Ptr AccessibleList -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr AccessibleList
obj (Ptr GValue -> Ptr AccessibleList -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe AccessibleList)
gvalueGet_ Ptr GValue
gv = do
        Ptr AccessibleList
ptr <- Ptr GValue -> IO (Ptr AccessibleList)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr AccessibleList)
        if Ptr AccessibleList
ptr Ptr AccessibleList -> Ptr AccessibleList -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr AccessibleList
forall a. Ptr a
FP.nullPtr
        then AccessibleList -> Maybe AccessibleList
forall a. a -> Maybe a
P.Just (AccessibleList -> Maybe AccessibleList)
-> IO AccessibleList -> IO (Maybe AccessibleList)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr AccessibleList -> AccessibleList)
-> Ptr AccessibleList -> IO AccessibleList
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr AccessibleList -> AccessibleList
AccessibleList Ptr AccessibleList
ptr
        else Maybe AccessibleList -> IO (Maybe AccessibleList)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe AccessibleList
forall a. Maybe a
P.Nothing
        
    


#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList AccessibleList
type instance O.AttributeList AccessibleList = AccessibleListAttributeList
type AccessibleListAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif

-- method AccessibleList::new_from_array
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "accessibles"
--           , argType =
--               TCArray
--                 False
--                 (-1)
--                 1
--                 (TInterface Name { namespace = "Gtk" , name = "Accessible" })
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "array of GtkAccessible"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "n_accessibles"
--           , argType = TBasicType TSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "length of @accessibles array"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "n_accessibles"
--              , argType = TBasicType TSize
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "length of @accessibles array"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , argCallbackUserData = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just
--               (TInterface Name { namespace = "Gtk" , name = "AccessibleList" })
-- throws : False
-- Skip return : False

foreign import ccall "gtk_accessible_list_new_from_array" gtk_accessible_list_new_from_array :: 
    Ptr (Ptr Gtk.Accessible.Accessible) ->  -- accessibles : TCArray False (-1) 1 (TInterface (Name {namespace = "Gtk", name = "Accessible"}))
    FCT.CSize ->                            -- n_accessibles : TBasicType TSize
    IO (Ptr AccessibleList)

-- | Allocates a new list of accessible instances.
-- 
-- /Since: 4.14/
accessibleListNewFromArray ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Gtk.Accessible.Accessible]
    -- ^ /@accessibles@/: array of GtkAccessible
    -> m AccessibleList
    -- ^ __Returns:__ the newly created list of accessible instances
accessibleListNewFromArray :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
[Accessible] -> m AccessibleList
accessibleListNewFromArray [Accessible]
accessibles = IO AccessibleList -> m AccessibleList
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO AccessibleList -> m AccessibleList)
-> IO AccessibleList -> m AccessibleList
forall a b. (a -> b) -> a -> b
$ do
    let nAccessibles :: CSize
nAccessibles = Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CSize) -> Int -> CSize
forall a b. (a -> b) -> a -> b
$ [Accessible] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Accessible]
accessibles
    [Ptr Accessible]
accessibles' <- (Accessible -> IO (Ptr Accessible))
-> [Accessible] -> IO [Ptr Accessible]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Accessible -> IO (Ptr Accessible)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr [Accessible]
accessibles
    Ptr (Ptr Accessible)
accessibles'' <- [Ptr Accessible] -> IO (Ptr (Ptr Accessible))
forall a. [Ptr a] -> IO (Ptr (Ptr a))
packPtrArray [Ptr Accessible]
accessibles'
    Ptr AccessibleList
result <- Ptr (Ptr Accessible) -> CSize -> IO (Ptr AccessibleList)
gtk_accessible_list_new_from_array Ptr (Ptr Accessible)
accessibles'' CSize
nAccessibles
    Text -> Ptr AccessibleList -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"accessibleListNewFromArray" Ptr AccessibleList
result
    AccessibleList
result' <- ((ManagedPtr AccessibleList -> AccessibleList)
-> Ptr AccessibleList -> IO AccessibleList
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr AccessibleList -> AccessibleList
AccessibleList) Ptr AccessibleList
result
    (Accessible -> IO ()) -> [Accessible] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Accessible -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [Accessible]
accessibles
    Ptr (Ptr Accessible) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Accessible)
accessibles''
    AccessibleList -> IO AccessibleList
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return AccessibleList
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method AccessibleList::new_from_list
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "list"
--           , argType =
--               TGList
--                 (TInterface Name { namespace = "Gtk" , name = "Accessible" })
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a reference to a `GList` containing a list of accessible values"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "Gtk" , name = "AccessibleList" })
-- throws : False
-- Skip return : False

foreign import ccall "gtk_accessible_list_new_from_list" gtk_accessible_list_new_from_list :: 
    Ptr (GList (Ptr Gtk.Accessible.Accessible)) -> -- list : TGList (TInterface (Name {namespace = "Gtk", name = "Accessible"}))
    IO (Ptr AccessibleList)

-- | Allocates a new @GtkAccessibleList@, doing a shallow copy of the
-- passed list of @GtkAccessible@ instances.
-- 
-- /Since: 4.14/
accessibleListNewFromList ::
    (B.CallStack.HasCallStack, MonadIO m, Gtk.Accessible.IsAccessible a) =>
    [a]
    -- ^ /@list@/: a reference to a @GList@ containing a list of accessible values
    -> m AccessibleList
    -- ^ __Returns:__ the list of accessible instances
accessibleListNewFromList :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsAccessible a) =>
[a] -> m AccessibleList
accessibleListNewFromList [a]
list = IO AccessibleList -> m AccessibleList
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO AccessibleList -> m AccessibleList)
-> IO AccessibleList -> m AccessibleList
forall a b. (a -> b) -> a -> b
$ do
    [Ptr Accessible]
list' <- (a -> IO (Ptr Accessible)) -> [a] -> IO [Ptr Accessible]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM a -> IO (Ptr Accessible)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr [a]
list
    Ptr (GList (Ptr Accessible))
list'' <- [Ptr Accessible] -> IO (Ptr (GList (Ptr Accessible)))
forall a. [Ptr a] -> IO (Ptr (GList (Ptr a)))
packGList [Ptr Accessible]
list'
    Ptr AccessibleList
result <- Ptr (GList (Ptr Accessible)) -> IO (Ptr AccessibleList)
gtk_accessible_list_new_from_list Ptr (GList (Ptr Accessible))
list''
    Text -> Ptr AccessibleList -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"accessibleListNewFromList" Ptr AccessibleList
result
    AccessibleList
result' <- ((ManagedPtr AccessibleList -> AccessibleList)
-> Ptr AccessibleList -> IO AccessibleList
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr AccessibleList -> AccessibleList
AccessibleList) Ptr AccessibleList
result
    (a -> IO ()) -> [a] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [a]
list
    Ptr (GList (Ptr Accessible)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr Accessible))
list''
    AccessibleList -> IO AccessibleList
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return AccessibleList
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method AccessibleList::get_objects
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "accessible_list"
--           , argType =
--               TInterface Name { namespace = "Gtk" , name = "AccessibleList" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TGList
--                  (TInterface Name { namespace = "Gtk" , name = "Accessible" }))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_accessible_list_get_objects" gtk_accessible_list_get_objects :: 
    Ptr AccessibleList ->                   -- accessible_list : TInterface (Name {namespace = "Gtk", name = "AccessibleList"})
    IO (Ptr (GList (Ptr Gtk.Accessible.Accessible)))

-- | Gets the list of objects this boxed type holds
-- 
-- /Since: 4.14/
accessibleListGetObjects ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    AccessibleList
    -> m [Gtk.Accessible.Accessible]
    -- ^ __Returns:__ a shallow copy of the objects
accessibleListGetObjects :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
AccessibleList -> m [Accessible]
accessibleListGetObjects AccessibleList
accessibleList = IO [Accessible] -> m [Accessible]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Accessible] -> m [Accessible])
-> IO [Accessible] -> m [Accessible]
forall a b. (a -> b) -> a -> b
$ do
    Ptr AccessibleList
accessibleList' <- AccessibleList -> IO (Ptr AccessibleList)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr AccessibleList
accessibleList
    Ptr (GList (Ptr Accessible))
result <- Ptr AccessibleList -> IO (Ptr (GList (Ptr Accessible)))
gtk_accessible_list_get_objects Ptr AccessibleList
accessibleList'
    [Ptr Accessible]
result' <- Ptr (GList (Ptr Accessible)) -> IO [Ptr Accessible]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr Accessible))
result
    [Accessible]
result'' <- (Ptr Accessible -> IO Accessible)
-> [Ptr Accessible] -> IO [Accessible]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((ManagedPtr Accessible -> Accessible)
-> Ptr Accessible -> IO Accessible
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Accessible -> Accessible
Gtk.Accessible.Accessible) [Ptr Accessible]
result'
    Ptr (GList (Ptr Accessible)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr Accessible))
result
    AccessibleList -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr AccessibleList
accessibleList
    [Accessible] -> IO [Accessible]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [Accessible]
result''

#if defined(ENABLE_OVERLOADING)
data AccessibleListGetObjectsMethodInfo
instance (signature ~ (m [Gtk.Accessible.Accessible]), MonadIO m) => O.OverloadedMethod AccessibleListGetObjectsMethodInfo AccessibleList signature where
    overloadedMethod = accessibleListGetObjects

instance O.OverloadedMethodInfo AccessibleListGetObjectsMethodInfo AccessibleList where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gtk.Structs.AccessibleList.accessibleListGetObjects",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gtk-4.0.9/docs/GI-Gtk-Structs-AccessibleList.html#v:accessibleListGetObjects"
        })


#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveAccessibleListMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveAccessibleListMethod "getObjects" o = AccessibleListGetObjectsMethodInfo
    ResolveAccessibleListMethod l o = O.MethodResolutionFailed l o

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

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveAccessibleListMethod t AccessibleList, O.OverloadedMethod info AccessibleList p, R.HasField t AccessibleList p) => R.HasField t AccessibleList p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveAccessibleListMethod t AccessibleList, O.OverloadedMethodInfo info AccessibleList) => OL.IsLabel t (O.MethodProxy info AccessibleList) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif