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

'GI.Atk.Interfaces.Selection.Selection' should be implemented by UI components with children
which are exposed by @/atk_object_ref_child/@ and
@/atk_object_get_n_children/@, if the use of the parent UI component
ordinarily involves selection of one or more of the objects
corresponding to those 'GI.Atk.Objects.Object.Object' children - for example,
selectable lists.

Note that other types of \"selection\" (for instance text selection)
are accomplished a other ATK interfaces - 'GI.Atk.Interfaces.Selection.Selection' is limited
to the selection\/deselection of children.
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.Atk.Interfaces.Selection
    ( 

-- * Exported types
    Selection(..)                           ,
    noSelection                             ,
    IsSelection                             ,
    toSelection                             ,


 -- * Methods
-- ** addSelection #method:addSelection#

#if ENABLE_OVERLOADING
    SelectionAddSelectionMethodInfo         ,
#endif
    selectionAddSelection                   ,


-- ** clearSelection #method:clearSelection#

#if ENABLE_OVERLOADING
    SelectionClearSelectionMethodInfo       ,
#endif
    selectionClearSelection                 ,


-- ** getSelectionCount #method:getSelectionCount#

#if ENABLE_OVERLOADING
    SelectionGetSelectionCountMethodInfo    ,
#endif
    selectionGetSelectionCount              ,


-- ** isChildSelected #method:isChildSelected#

#if ENABLE_OVERLOADING
    SelectionIsChildSelectedMethodInfo      ,
#endif
    selectionIsChildSelected                ,


-- ** refSelection #method:refSelection#

#if ENABLE_OVERLOADING
    SelectionRefSelectionMethodInfo         ,
#endif
    selectionRefSelection                   ,


-- ** removeSelection #method:removeSelection#

#if ENABLE_OVERLOADING
    SelectionRemoveSelectionMethodInfo      ,
#endif
    selectionRemoveSelection                ,


-- ** selectAllSelection #method:selectAllSelection#

#if ENABLE_OVERLOADING
    SelectionSelectAllSelectionMethodInfo   ,
#endif
    selectionSelectAllSelection             ,




 -- * Signals
-- ** selectionChanged #signal:selectionChanged#

    C_SelectionSelectionChangedCallback     ,
    SelectionSelectionChangedCallback       ,
#if ENABLE_OVERLOADING
    SelectionSelectionChangedSignalInfo     ,
#endif
    afterSelectionSelectionChanged          ,
    genClosure_SelectionSelectionChanged    ,
    mk_SelectionSelectionChangedCallback    ,
    noSelectionSelectionChangedCallback     ,
    onSelectionSelectionChanged             ,
    wrap_SelectionSelectionChangedCallback  ,




    ) 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

-- interface Selection 
-- | Memory-managed wrapper type.
newtype Selection = Selection (ManagedPtr Selection)
-- | A convenience alias for `Nothing` :: `Maybe` `Selection`.
noSelection :: Maybe Selection
noSelection :: Maybe Selection
noSelection = Maybe Selection
forall a. Maybe a
Nothing

-- signal Selection::selection-changed
{- |
The \"selection-changed\" signal is emitted by an object which
implements AtkSelection interface when the selection changes.
-}
type SelectionSelectionChangedCallback =
    IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `SelectionSelectionChangedCallback`@.
noSelectionSelectionChangedCallback :: Maybe SelectionSelectionChangedCallback
noSelectionSelectionChangedCallback :: Maybe SelectionSelectionChangedCallback
noSelectionSelectionChangedCallback = Maybe SelectionSelectionChangedCallback
forall a. Maybe a
Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_SelectionSelectionChangedCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_SelectionSelectionChangedCallback`.
foreign import ccall "wrapper"
    mk_SelectionSelectionChangedCallback :: C_SelectionSelectionChangedCallback -> IO (FunPtr C_SelectionSelectionChangedCallback)

-- | Wrap the callback into a `Closure`.
genClosure_SelectionSelectionChanged :: SelectionSelectionChangedCallback -> IO Closure
genClosure_SelectionSelectionChanged :: SelectionSelectionChangedCallback -> IO Closure
genClosure_SelectionSelectionChanged cb :: SelectionSelectionChangedCallback
cb = do
    let cb' :: C_SelectionSelectionChangedCallback
cb' = SelectionSelectionChangedCallback
-> C_SelectionSelectionChangedCallback
wrap_SelectionSelectionChangedCallback SelectionSelectionChangedCallback
cb
    C_SelectionSelectionChangedCallback
-> IO (FunPtr C_SelectionSelectionChangedCallback)
mk_SelectionSelectionChangedCallback C_SelectionSelectionChangedCallback
cb' IO (FunPtr C_SelectionSelectionChangedCallback)
-> (FunPtr C_SelectionSelectionChangedCallback -> IO Closure)
-> IO Closure
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_SelectionSelectionChangedCallback -> IO Closure
forall a. FunPtr a -> IO Closure
newCClosure


-- | Wrap a `SelectionSelectionChangedCallback` into a `C_SelectionSelectionChangedCallback`.
wrap_SelectionSelectionChangedCallback ::
    SelectionSelectionChangedCallback ->
    C_SelectionSelectionChangedCallback
wrap_SelectionSelectionChangedCallback :: SelectionSelectionChangedCallback
-> C_SelectionSelectionChangedCallback
wrap_SelectionSelectionChangedCallback _cb :: SelectionSelectionChangedCallback
_cb _ _ = do
    SelectionSelectionChangedCallback
_cb 


{- |
Connect a signal handler for the “@selection-changed@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' selection #selectionChanged callback
@
-}
onSelectionSelectionChanged :: (IsSelection a, MonadIO m) => a -> SelectionSelectionChangedCallback -> m SignalHandlerId
onSelectionSelectionChanged :: a -> SelectionSelectionChangedCallback -> m SignalHandlerId
onSelectionSelectionChanged obj :: a
obj cb :: SelectionSelectionChangedCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SelectionSelectionChangedCallback
cb' = SelectionSelectionChangedCallback
-> C_SelectionSelectionChangedCallback
wrap_SelectionSelectionChangedCallback SelectionSelectionChangedCallback
cb
    FunPtr C_SelectionSelectionChangedCallback
cb'' <- C_SelectionSelectionChangedCallback
-> IO (FunPtr C_SelectionSelectionChangedCallback)
mk_SelectionSelectionChangedCallback C_SelectionSelectionChangedCallback
cb'
    a
-> String
-> FunPtr C_SelectionSelectionChangedCallback
-> SignalConnectMode
-> IO SignalHandlerId
forall o a.
GObject o =>
o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
connectSignalFunPtr a
obj "selection-changed" FunPtr C_SelectionSelectionChangedCallback
cb'' SignalConnectMode
SignalConnectBefore

{- |
Connect a signal handler for the “@selection-changed@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' selection #selectionChanged callback
@
-}
afterSelectionSelectionChanged :: (IsSelection a, MonadIO m) => a -> SelectionSelectionChangedCallback -> m SignalHandlerId
afterSelectionSelectionChanged :: a -> SelectionSelectionChangedCallback -> m SignalHandlerId
afterSelectionSelectionChanged obj :: a
obj cb :: SelectionSelectionChangedCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SelectionSelectionChangedCallback
cb' = SelectionSelectionChangedCallback
-> C_SelectionSelectionChangedCallback
wrap_SelectionSelectionChangedCallback SelectionSelectionChangedCallback
cb
    FunPtr C_SelectionSelectionChangedCallback
cb'' <- C_SelectionSelectionChangedCallback
-> IO (FunPtr C_SelectionSelectionChangedCallback)
mk_SelectionSelectionChangedCallback C_SelectionSelectionChangedCallback
cb'
    a
-> String
-> FunPtr C_SelectionSelectionChangedCallback
-> SignalConnectMode
-> IO SignalHandlerId
forall o a.
GObject o =>
o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
connectSignalFunPtr a
obj "selection-changed" FunPtr C_SelectionSelectionChangedCallback
cb'' SignalConnectMode
SignalConnectAfter


#if ENABLE_OVERLOADING
data SelectionSelectionChangedSignalInfo
instance SignalInfo SelectionSelectionChangedSignalInfo where
    type HaskellCallbackType SelectionSelectionChangedSignalInfo = SelectionSelectionChangedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_SelectionSelectionChangedCallback cb
        cb'' <- mk_SelectionSelectionChangedCallback cb'
        connectSignalFunPtr obj "selection-changed" cb'' connectMode

type instance O.SignalList Selection = SelectionSignalList
type SelectionSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo), '("selectionChanged", SelectionSelectionChangedSignalInfo)] :: [(Symbol, *)])

#endif

foreign import ccall "atk_selection_get_type"
    c_atk_selection_get_type :: IO GType

instance GObject Selection where
    gobjectType :: Selection -> IO GType
gobjectType _ = IO GType
c_atk_selection_get_type
    

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

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

#if ENABLE_OVERLOADING
instance O.HasAttributeList Selection
type instance O.AttributeList Selection = SelectionAttributeList
type SelectionAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
type family ResolveSelectionMethod (t :: Symbol) (o :: *) :: * where
    ResolveSelectionMethod "addSelection" o = SelectionAddSelectionMethodInfo
    ResolveSelectionMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveSelectionMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveSelectionMethod "clearSelection" o = SelectionClearSelectionMethodInfo
    ResolveSelectionMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveSelectionMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveSelectionMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveSelectionMethod "isChildSelected" o = SelectionIsChildSelectedMethodInfo
    ResolveSelectionMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveSelectionMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveSelectionMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveSelectionMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveSelectionMethod "refSelection" o = SelectionRefSelectionMethodInfo
    ResolveSelectionMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveSelectionMethod "removeSelection" o = SelectionRemoveSelectionMethodInfo
    ResolveSelectionMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveSelectionMethod "selectAllSelection" o = SelectionSelectAllSelectionMethodInfo
    ResolveSelectionMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveSelectionMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveSelectionMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveSelectionMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveSelectionMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveSelectionMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveSelectionMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveSelectionMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveSelectionMethod "getSelectionCount" o = SelectionGetSelectionCountMethodInfo
    ResolveSelectionMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveSelectionMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveSelectionMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveSelectionMethod t Selection, O.MethodInfo info Selection p) => O.IsLabelProxy t (Selection -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveSelectionMethod t Selection, O.MethodInfo info Selection p) => O.IsLabel t (Selection -> 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

-- method Selection::add_selection
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "selection", argType = TInterface (Name {namespace = "Atk", name = "Selection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject instance that implements AtkSelectionIface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "i", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gint specifying the child index.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_selection_add_selection" atk_selection_add_selection :: 
    Ptr Selection ->                        -- selection : TInterface (Name {namespace = "Atk", name = "Selection"})
    Int32 ->                                -- i : TBasicType TInt
    IO CInt

{- |
Adds the specified accessible child of the object to the
object\'s selection.
-}
selectionAddSelection ::
    (B.CallStack.HasCallStack, MonadIO m, IsSelection a) =>
    a
    {- ^ /@selection@/: a 'GI.GObject.Objects.Object.Object' instance that implements AtkSelectionIface -}
    -> Int32
    {- ^ /@i@/: a @/gint/@ specifying the child index. -}
    -> m Bool
    {- ^ __Returns:__ TRUE if success, FALSE otherwise. -}
selectionAddSelection :: a -> Int32 -> m Bool
selectionAddSelection selection :: a
selection i :: Int32
i = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Selection
selection' <- a -> IO (Ptr Selection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
selection
    CInt
result <- Ptr Selection -> Int32 -> IO CInt
atk_selection_add_selection Ptr Selection
selection' Int32
i
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> SelectionSelectionChangedCallback
forall a.
ManagedPtrNewtype a =>
a -> SelectionSelectionChangedCallback
touchManagedPtr a
selection
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data SelectionAddSelectionMethodInfo
instance (signature ~ (Int32 -> m Bool), MonadIO m, IsSelection a) => O.MethodInfo SelectionAddSelectionMethodInfo a signature where
    overloadedMethod _ = selectionAddSelection

#endif

-- method Selection::clear_selection
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "selection", argType = TInterface (Name {namespace = "Atk", name = "Selection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject instance that implements AtkSelectionIface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_selection_clear_selection" atk_selection_clear_selection :: 
    Ptr Selection ->                        -- selection : TInterface (Name {namespace = "Atk", name = "Selection"})
    IO CInt

{- |
Clears the selection in the object so that no children in the object
are selected.
-}
selectionClearSelection ::
    (B.CallStack.HasCallStack, MonadIO m, IsSelection a) =>
    a
    {- ^ /@selection@/: a 'GI.GObject.Objects.Object.Object' instance that implements AtkSelectionIface -}
    -> m Bool
    {- ^ __Returns:__ TRUE if success, FALSE otherwise. -}
selectionClearSelection :: a -> m Bool
selectionClearSelection selection :: a
selection = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Selection
selection' <- a -> IO (Ptr Selection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
selection
    CInt
result <- Ptr Selection -> IO CInt
atk_selection_clear_selection Ptr Selection
selection'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> SelectionSelectionChangedCallback
forall a.
ManagedPtrNewtype a =>
a -> SelectionSelectionChangedCallback
touchManagedPtr a
selection
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data SelectionClearSelectionMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSelection a) => O.MethodInfo SelectionClearSelectionMethodInfo a signature where
    overloadedMethod _ = selectionClearSelection

#endif

-- method Selection::get_selection_count
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "selection", argType = TInterface (Name {namespace = "Atk", name = "Selection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject instance that implements AtkSelectionIface", 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 "atk_selection_get_selection_count" atk_selection_get_selection_count :: 
    Ptr Selection ->                        -- selection : TInterface (Name {namespace = "Atk", name = "Selection"})
    IO Int32

{- |
Gets the number of accessible children currently selected.
Note: callers should not rely on 'Nothing' or on a zero value for
indication of whether AtkSelectionIface is implemented, they should
use type checking\/interface checking macros or the
@/atk_get_accessible_value()/@ convenience method.
-}
selectionGetSelectionCount ::
    (B.CallStack.HasCallStack, MonadIO m, IsSelection a) =>
    a
    {- ^ /@selection@/: a 'GI.GObject.Objects.Object.Object' instance that implements AtkSelectionIface -}
    -> m Int32
    {- ^ __Returns:__ a gint representing the number of items selected, or 0
if /@selection@/ does not implement this interface. -}
selectionGetSelectionCount :: a -> m Int32
selectionGetSelectionCount selection :: a
selection = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Selection
selection' <- a -> IO (Ptr Selection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
selection
    Int32
result <- Ptr Selection -> IO Int32
atk_selection_get_selection_count Ptr Selection
selection'
    a -> SelectionSelectionChangedCallback
forall a.
ManagedPtrNewtype a =>
a -> SelectionSelectionChangedCallback
touchManagedPtr a
selection
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if ENABLE_OVERLOADING
data SelectionGetSelectionCountMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsSelection a) => O.MethodInfo SelectionGetSelectionCountMethodInfo a signature where
    overloadedMethod _ = selectionGetSelectionCount

#endif

-- method Selection::is_child_selected
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "selection", argType = TInterface (Name {namespace = "Atk", name = "Selection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject instance that implements AtkSelectionIface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "i", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gint specifying the child index.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_selection_is_child_selected" atk_selection_is_child_selected :: 
    Ptr Selection ->                        -- selection : TInterface (Name {namespace = "Atk", name = "Selection"})
    Int32 ->                                -- i : TBasicType TInt
    IO CInt

{- |
Determines if the current child of this object is selected
Note: callers should not rely on 'Nothing' or on a zero value for
indication of whether AtkSelectionIface is implemented, they should
use type checking\/interface checking macros or the
@/atk_get_accessible_value()/@ convenience method.
-}
selectionIsChildSelected ::
    (B.CallStack.HasCallStack, MonadIO m, IsSelection a) =>
    a
    {- ^ /@selection@/: a 'GI.GObject.Objects.Object.Object' instance that implements AtkSelectionIface -}
    -> Int32
    {- ^ /@i@/: a @/gint/@ specifying the child index. -}
    -> m Bool
    {- ^ __Returns:__ a gboolean representing the specified child is selected, or 0
if /@selection@/ does not implement this interface. -}
selectionIsChildSelected :: a -> Int32 -> m Bool
selectionIsChildSelected selection :: a
selection i :: Int32
i = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Selection
selection' <- a -> IO (Ptr Selection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
selection
    CInt
result <- Ptr Selection -> Int32 -> IO CInt
atk_selection_is_child_selected Ptr Selection
selection' Int32
i
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> SelectionSelectionChangedCallback
forall a.
ManagedPtrNewtype a =>
a -> SelectionSelectionChangedCallback
touchManagedPtr a
selection
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data SelectionIsChildSelectedMethodInfo
instance (signature ~ (Int32 -> m Bool), MonadIO m, IsSelection a) => O.MethodInfo SelectionIsChildSelectedMethodInfo a signature where
    overloadedMethod _ = selectionIsChildSelected

#endif

-- method Selection::ref_selection
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "selection", argType = TInterface (Name {namespace = "Atk", name = "Selection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject instance that implements AtkSelectionIface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "i", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gint specifying the index in the selection set.  (e.g. the\nith selection as opposed to the ith child).", 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_selection_ref_selection" atk_selection_ref_selection :: 
    Ptr Selection ->                        -- selection : TInterface (Name {namespace = "Atk", name = "Selection"})
    Int32 ->                                -- i : TBasicType TInt
    IO (Ptr Atk.Object.Object)

{- |
Gets a reference to the accessible object representing the specified
selected child of the object.
Note: callers should not rely on 'Nothing' or on a zero value for
indication of whether AtkSelectionIface is implemented, they should
use type checking\/interface checking macros or the
@/atk_get_accessible_value()/@ convenience method.
-}
selectionRefSelection ::
    (B.CallStack.HasCallStack, MonadIO m, IsSelection a) =>
    a
    {- ^ /@selection@/: a 'GI.GObject.Objects.Object.Object' instance that implements AtkSelectionIface -}
    -> Int32
    {- ^ /@i@/: a @/gint/@ specifying the index in the selection set.  (e.g. the
ith selection as opposed to the ith child). -}
    -> m (Maybe Atk.Object.Object)
    {- ^ __Returns:__ an 'GI.Atk.Objects.Object.Object' representing the
selected accessible, or 'Nothing' if /@selection@/ does not implement this
interface. -}
selectionRefSelection :: a -> Int32 -> m (Maybe Object)
selectionRefSelection selection :: a
selection i :: Int32
i = IO (Maybe Object) -> m (Maybe Object)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Object) -> m (Maybe Object))
-> IO (Maybe Object) -> m (Maybe Object)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Selection
selection' <- a -> IO (Ptr Selection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
selection
    Ptr Object
result <- Ptr Selection -> Int32 -> IO (Ptr Object)
atk_selection_ref_selection Ptr Selection
selection' Int32
i
    Maybe Object
maybeResult <- Ptr Object -> (Ptr Object -> IO Object) -> IO (Maybe Object)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Object
result ((Ptr Object -> IO Object) -> IO (Maybe Object))
-> (Ptr Object -> IO Object) -> IO (Maybe Object)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr Object
result' -> do
        Object
result'' <- ((ManagedPtr Object -> Object) -> Ptr Object -> IO Object
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Object -> Object
Atk.Object.Object) Ptr Object
result'
        Object -> IO Object
forall (m :: * -> *) a. Monad m => a -> m a
return Object
result''
    a -> SelectionSelectionChangedCallback
forall a.
ManagedPtrNewtype a =>
a -> SelectionSelectionChangedCallback
touchManagedPtr a
selection
    Maybe Object -> IO (Maybe Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Object
maybeResult

#if ENABLE_OVERLOADING
data SelectionRefSelectionMethodInfo
instance (signature ~ (Int32 -> m (Maybe Atk.Object.Object)), MonadIO m, IsSelection a) => O.MethodInfo SelectionRefSelectionMethodInfo a signature where
    overloadedMethod _ = selectionRefSelection

#endif

-- method Selection::remove_selection
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "selection", argType = TInterface (Name {namespace = "Atk", name = "Selection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject instance that implements AtkSelectionIface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "i", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gint specifying the index in the selection set.  (e.g. the\nith selection as opposed to the ith child).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_selection_remove_selection" atk_selection_remove_selection :: 
    Ptr Selection ->                        -- selection : TInterface (Name {namespace = "Atk", name = "Selection"})
    Int32 ->                                -- i : TBasicType TInt
    IO CInt

{- |
Removes the specified child of the object from the object\'s selection.
-}
selectionRemoveSelection ::
    (B.CallStack.HasCallStack, MonadIO m, IsSelection a) =>
    a
    {- ^ /@selection@/: a 'GI.GObject.Objects.Object.Object' instance that implements AtkSelectionIface -}
    -> Int32
    {- ^ /@i@/: a @/gint/@ specifying the index in the selection set.  (e.g. the
ith selection as opposed to the ith child). -}
    -> m Bool
    {- ^ __Returns:__ TRUE if success, FALSE otherwise. -}
selectionRemoveSelection :: a -> Int32 -> m Bool
selectionRemoveSelection selection :: a
selection i :: Int32
i = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Selection
selection' <- a -> IO (Ptr Selection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
selection
    CInt
result <- Ptr Selection -> Int32 -> IO CInt
atk_selection_remove_selection Ptr Selection
selection' Int32
i
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> SelectionSelectionChangedCallback
forall a.
ManagedPtrNewtype a =>
a -> SelectionSelectionChangedCallback
touchManagedPtr a
selection
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data SelectionRemoveSelectionMethodInfo
instance (signature ~ (Int32 -> m Bool), MonadIO m, IsSelection a) => O.MethodInfo SelectionRemoveSelectionMethodInfo a signature where
    overloadedMethod _ = selectionRemoveSelection

#endif

-- method Selection::select_all_selection
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "selection", argType = TInterface (Name {namespace = "Atk", name = "Selection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GObject instance that implements AtkSelectionIface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_selection_select_all_selection" atk_selection_select_all_selection :: 
    Ptr Selection ->                        -- selection : TInterface (Name {namespace = "Atk", name = "Selection"})
    IO CInt

{- |
Causes every child of the object to be selected if the object
supports multiple selections.
-}
selectionSelectAllSelection ::
    (B.CallStack.HasCallStack, MonadIO m, IsSelection a) =>
    a
    {- ^ /@selection@/: a 'GI.GObject.Objects.Object.Object' instance that implements AtkSelectionIface -}
    -> m Bool
    {- ^ __Returns:__ TRUE if success, FALSE otherwise. -}
selectionSelectAllSelection :: a -> m Bool
selectionSelectAllSelection selection :: a
selection = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Selection
selection' <- a -> IO (Ptr Selection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
selection
    CInt
result <- Ptr Selection -> IO CInt
atk_selection_select_all_selection Ptr Selection
selection'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> SelectionSelectionChangedCallback
forall a.
ManagedPtrNewtype a =>
a -> SelectionSelectionChangedCallback
touchManagedPtr a
selection
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data SelectionSelectAllSelectionMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSelection a) => O.MethodInfo SelectionSelectAllSelectionMethodInfo a signature where
    overloadedMethod _ = selectionSelectAllSelection

#endif