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

module GI.Atk.Interfaces.Selection
    ( 

-- * Exported types
    Selection(..)                           ,
    noSelection                             ,
    SelectionK                              ,


 -- * Methods
-- ** selectionAddSelection
    selectionAddSelection                   ,


-- ** selectionClearSelection
    selectionClearSelection                 ,


-- ** selectionGetSelectionCount
    selectionGetSelectionCount              ,


-- ** selectionIsChildSelected
    selectionIsChildSelected                ,


-- ** selectionRefSelection
    selectionRefSelection                   ,


-- ** selectionRemoveSelection
    selectionRemoveSelection                ,


-- ** selectionSelectAllSelection
    selectionSelectAllSelection             ,




 -- * Signals
-- ** SelectionChanged
    SelectionSelectionChangedCallback       ,
    SelectionSelectionChangedCallbackC      ,
    SelectionSelectionChangedSignalInfo     ,
    afterSelectionSelectionChanged          ,
    mkSelectionSelectionChangedCallback     ,
    noSelectionSelectionChangedCallback     ,
    onSelectionSelectionChanged             ,
    selectionSelectionChangedCallbackWrapper,
    selectionSelectionChangedClosure        ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Atk.Types
import GI.Atk.Callbacks

-- interface Selection 

newtype Selection = Selection (ForeignPtr Selection)
noSelection :: Maybe Selection
noSelection = Nothing

-- signal Selection::selection-changed
type SelectionSelectionChangedCallback =
    IO ()

noSelectionSelectionChangedCallback :: Maybe SelectionSelectionChangedCallback
noSelectionSelectionChangedCallback = Nothing

type SelectionSelectionChangedCallbackC =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mkSelectionSelectionChangedCallback :: SelectionSelectionChangedCallbackC -> IO (FunPtr SelectionSelectionChangedCallbackC)

selectionSelectionChangedClosure :: SelectionSelectionChangedCallback -> IO Closure
selectionSelectionChangedClosure cb = newCClosure =<< mkSelectionSelectionChangedCallback wrapped
    where wrapped = selectionSelectionChangedCallbackWrapper cb

selectionSelectionChangedCallbackWrapper ::
    SelectionSelectionChangedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
selectionSelectionChangedCallbackWrapper _cb _ _ = do
    _cb 

onSelectionSelectionChanged :: (GObject a, MonadIO m) => a -> SelectionSelectionChangedCallback -> m SignalHandlerId
onSelectionSelectionChanged obj cb = liftIO $ connectSelectionSelectionChanged obj cb SignalConnectBefore
afterSelectionSelectionChanged :: (GObject a, MonadIO m) => a -> SelectionSelectionChangedCallback -> m SignalHandlerId
afterSelectionSelectionChanged obj cb = connectSelectionSelectionChanged obj cb SignalConnectAfter

connectSelectionSelectionChanged :: (GObject a, MonadIO m) =>
                                    a -> SelectionSelectionChangedCallback -> SignalConnectMode -> m SignalHandlerId
connectSelectionSelectionChanged obj cb after = liftIO $ do
    cb' <- mkSelectionSelectionChangedCallback (selectionSelectionChangedCallbackWrapper cb)
    connectSignalFunPtr obj "selection-changed" cb' after

type instance AttributeList Selection = SelectionAttributeList
type SelectionAttributeList = ('[ ] :: [(Symbol, *)])

data SelectionSelectionChangedSignalInfo
instance SignalInfo SelectionSelectionChangedSignalInfo where
    type HaskellCallbackType SelectionSelectionChangedSignalInfo = SelectionSelectionChangedCallback
    connectSignal _ = connectSelectionSelectionChanged

type instance SignalList Selection = SelectionSignalList
type SelectionSignalList = ('[ '("selection-changed", SelectionSelectionChangedSignalInfo)] :: [(Symbol, *)])

class ForeignPtrNewtype a => SelectionK a
instance (ForeignPtrNewtype o, IsDescendantOf Selection o) => SelectionK o
type instance ParentTypes Selection = SelectionParentTypes
type SelectionParentTypes = '[]

-- method Selection::add_selection
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Atk" "Selection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "i", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Atk" "Selection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "i", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "atk_selection_add_selection" atk_selection_add_selection :: 
    Ptr Selection ->                        -- _obj : TInterface "Atk" "Selection"
    Int32 ->                                -- i : TBasicType TInt32
    IO CInt


selectionAddSelection ::
    (MonadIO m, SelectionK a) =>
    a ->                                    -- _obj
    Int32 ->                                -- i
    m Bool
selectionAddSelection _obj i = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- atk_selection_add_selection _obj' i
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Selection::clear_selection
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Atk" "Selection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Atk" "Selection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "atk_selection_clear_selection" atk_selection_clear_selection :: 
    Ptr Selection ->                        -- _obj : TInterface "Atk" "Selection"
    IO CInt


selectionClearSelection ::
    (MonadIO m, SelectionK a) =>
    a ->                                    -- _obj
    m Bool
selectionClearSelection _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- atk_selection_clear_selection _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Selection::get_selection_count
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Atk" "Selection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Atk" "Selection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "atk_selection_get_selection_count" atk_selection_get_selection_count :: 
    Ptr Selection ->                        -- _obj : TInterface "Atk" "Selection"
    IO Int32


selectionGetSelectionCount ::
    (MonadIO m, SelectionK a) =>
    a ->                                    -- _obj
    m Int32
selectionGetSelectionCount _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- atk_selection_get_selection_count _obj'
    touchManagedPtr _obj
    return result

-- method Selection::is_child_selected
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Atk" "Selection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "i", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Atk" "Selection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "i", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "atk_selection_is_child_selected" atk_selection_is_child_selected :: 
    Ptr Selection ->                        -- _obj : TInterface "Atk" "Selection"
    Int32 ->                                -- i : TBasicType TInt32
    IO CInt


selectionIsChildSelected ::
    (MonadIO m, SelectionK a) =>
    a ->                                    -- _obj
    Int32 ->                                -- i
    m Bool
selectionIsChildSelected _obj i = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- atk_selection_is_child_selected _obj' i
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Selection::ref_selection
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Atk" "Selection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "i", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Atk" "Selection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "i", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Atk" "Object"
-- throws : False
-- Skip return : False

foreign import ccall "atk_selection_ref_selection" atk_selection_ref_selection :: 
    Ptr Selection ->                        -- _obj : TInterface "Atk" "Selection"
    Int32 ->                                -- i : TBasicType TInt32
    IO (Ptr Object)


selectionRefSelection ::
    (MonadIO m, SelectionK a) =>
    a ->                                    -- _obj
    Int32 ->                                -- i
    m Object
selectionRefSelection _obj i = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- atk_selection_ref_selection _obj' i
    checkUnexpectedReturnNULL "atk_selection_ref_selection" result
    result' <- (wrapObject Object) result
    touchManagedPtr _obj
    return result'

-- method Selection::remove_selection
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Atk" "Selection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "i", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Atk" "Selection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "i", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "atk_selection_remove_selection" atk_selection_remove_selection :: 
    Ptr Selection ->                        -- _obj : TInterface "Atk" "Selection"
    Int32 ->                                -- i : TBasicType TInt32
    IO CInt


selectionRemoveSelection ::
    (MonadIO m, SelectionK a) =>
    a ->                                    -- _obj
    Int32 ->                                -- i
    m Bool
selectionRemoveSelection _obj i = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- atk_selection_remove_selection _obj' i
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Selection::select_all_selection
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Atk" "Selection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Atk" "Selection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "atk_selection_select_all_selection" atk_selection_select_all_selection :: 
    Ptr Selection ->                        -- _obj : TInterface "Atk" "Selection"
    IO CInt


selectionSelectAllSelection ::
    (MonadIO m, SelectionK a) =>
    a ->                                    -- _obj
    m Bool
selectionSelectAllSelection _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- atk_selection_select_all_selection _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'