{- | 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. -} module GI.Atk.Interfaces.Selection ( -- * Exported types Selection(..) , noSelection , IsSelection , -- * Methods -- ** addSelection #method:addSelection# SelectionAddSelectionMethodInfo , selectionAddSelection , -- ** clearSelection #method:clearSelection# SelectionClearSelectionMethodInfo , selectionClearSelection , -- ** getSelectionCount #method:getSelectionCount# SelectionGetSelectionCountMethodInfo , selectionGetSelectionCount , -- ** isChildSelected #method:isChildSelected# SelectionIsChildSelectedMethodInfo , selectionIsChildSelected , -- ** refSelection #method:refSelection# SelectionRefSelectionMethodInfo , selectionRefSelection , -- ** removeSelection #method:removeSelection# SelectionRemoveSelectionMethodInfo , selectionRemoveSelection , -- ** selectAllSelection #method:selectAllSelection# SelectionSelectAllSelectionMethodInfo , selectionSelectAllSelection , -- * Signals -- ** selectionChanged #signal:selectionChanged# C_SelectionSelectionChangedCallback , SelectionSelectionChangedCallback , SelectionSelectionChangedSignalInfo , 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.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 -- interface Selection newtype Selection = Selection (ManagedPtr Selection) noSelection :: Maybe Selection noSelection = Nothing type family ResolveSelectionMethod (t :: Symbol) (o :: *) :: * where ResolveSelectionMethod "addSelection" o = SelectionAddSelectionMethodInfo ResolveSelectionMethod "clearSelection" o = SelectionClearSelectionMethodInfo ResolveSelectionMethod "isChildSelected" o = SelectionIsChildSelectedMethodInfo ResolveSelectionMethod "refSelection" o = SelectionRefSelectionMethodInfo ResolveSelectionMethod "removeSelection" o = SelectionRemoveSelectionMethodInfo ResolveSelectionMethod "selectAllSelection" o = SelectionSelectAllSelectionMethodInfo ResolveSelectionMethod "getSelectionCount" o = SelectionGetSelectionCountMethodInfo 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 fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #endif -- signal Selection::selection-changed type SelectionSelectionChangedCallback = IO () noSelectionSelectionChangedCallback :: Maybe SelectionSelectionChangedCallback noSelectionSelectionChangedCallback = Nothing type C_SelectionSelectionChangedCallback = Ptr () -> -- object Ptr () -> -- user_data IO () foreign import ccall "wrapper" mk_SelectionSelectionChangedCallback :: C_SelectionSelectionChangedCallback -> IO (FunPtr C_SelectionSelectionChangedCallback) genClosure_SelectionSelectionChanged :: SelectionSelectionChangedCallback -> IO Closure genClosure_SelectionSelectionChanged cb = do let cb' = wrap_SelectionSelectionChangedCallback cb mk_SelectionSelectionChangedCallback cb' >>= newCClosure wrap_SelectionSelectionChangedCallback :: SelectionSelectionChangedCallback -> Ptr () -> Ptr () -> IO () wrap_SelectionSelectionChangedCallback _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 let cb' = wrap_SelectionSelectionChangedCallback cb cb'' <- mk_SelectionSelectionChangedCallback cb' connectSignalFunPtr obj "selection-changed" cb'' after instance O.HasAttributeList Selection type instance O.AttributeList Selection = SelectionAttributeList type SelectionAttributeList = ('[ ] :: [(Symbol, *)]) data SelectionSelectionChangedSignalInfo instance SignalInfo SelectionSelectionChangedSignalInfo where type HaskellCallbackType SelectionSelectionChangedSignalInfo = SelectionSelectionChangedCallback connectSignal _ = connectSelectionSelectionChanged type instance O.SignalList Selection = SelectionSignalList type SelectionSignalList = ('[ '("selectionChanged", SelectionSelectionChangedSignalInfo)] :: [(Symbol, *)]) class ManagedPtrNewtype a => IsSelection a instance IsSelection Selection -- XXX Wrapping a foreign struct/union with no known destructor or size, leak? instance WrappedPtr Selection where wrappedPtrCalloc = return nullPtr wrappedPtrCopy = return wrappedPtrFree = Nothing -- 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 selection i = liftIO $ do selection' <- unsafeManagedPtrCastPtr selection result <- atk_selection_add_selection selection' i let result' = (/= 0) result touchManagedPtr selection return result' data SelectionAddSelectionMethodInfo instance (signature ~ (Int32 -> m Bool), MonadIO m, IsSelection a) => O.MethodInfo SelectionAddSelectionMethodInfo a signature where overloadedMethod _ = selectionAddSelection -- 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 selection = liftIO $ do selection' <- unsafeManagedPtrCastPtr selection result <- atk_selection_clear_selection selection' let result' = (/= 0) result touchManagedPtr selection return result' data SelectionClearSelectionMethodInfo instance (signature ~ (m Bool), MonadIO m, IsSelection a) => O.MethodInfo SelectionClearSelectionMethodInfo a signature where overloadedMethod _ = selectionClearSelection -- 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 selection = liftIO $ do selection' <- unsafeManagedPtrCastPtr selection result <- atk_selection_get_selection_count selection' touchManagedPtr selection return result data SelectionGetSelectionCountMethodInfo instance (signature ~ (m Int32), MonadIO m, IsSelection a) => O.MethodInfo SelectionGetSelectionCountMethodInfo a signature where overloadedMethod _ = selectionGetSelectionCount -- 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 selection i = liftIO $ do selection' <- unsafeManagedPtrCastPtr selection result <- atk_selection_is_child_selected selection' i let result' = (/= 0) result touchManagedPtr selection return result' data SelectionIsChildSelectedMethodInfo instance (signature ~ (Int32 -> m Bool), MonadIO m, IsSelection a) => O.MethodInfo SelectionIsChildSelectedMethodInfo a signature where overloadedMethod _ = selectionIsChildSelected -- 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 selection i = liftIO $ do selection' <- unsafeManagedPtrCastPtr selection result <- atk_selection_ref_selection selection' i maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapObject Atk.Object.Object) result' return result'' touchManagedPtr selection return maybeResult data SelectionRefSelectionMethodInfo instance (signature ~ (Int32 -> m (Maybe Atk.Object.Object)), MonadIO m, IsSelection a) => O.MethodInfo SelectionRefSelectionMethodInfo a signature where overloadedMethod _ = selectionRefSelection -- 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 selection i = liftIO $ do selection' <- unsafeManagedPtrCastPtr selection result <- atk_selection_remove_selection selection' i let result' = (/= 0) result touchManagedPtr selection return result' data SelectionRemoveSelectionMethodInfo instance (signature ~ (Int32 -> m Bool), MonadIO m, IsSelection a) => O.MethodInfo SelectionRemoveSelectionMethodInfo a signature where overloadedMethod _ = selectionRemoveSelection -- 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 selection = liftIO $ do selection' <- unsafeManagedPtrCastPtr selection result <- atk_selection_select_all_selection selection' let result' = (/= 0) result touchManagedPtr selection return result' data SelectionSelectAllSelectionMethodInfo instance (signature ~ (m Bool), MonadIO m, IsSelection a) => O.MethodInfo SelectionSelectAllSelectionMethodInfo a signature where overloadedMethod _ = selectionSelectAllSelection