{-# LANGUAGE ImplicitParams, RankNTypes, TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- t'GI.Gio.Interfaces.ListModel.ListModel' is an interface that represents a mutable list of
-- @/GObjects/@. Its main intention is as a model for various widgets in
-- user interfaces, such as list views, but it can also be used as a
-- convenient method of returning lists of data, with support for
-- updates.
-- 
-- Each object in the list may also report changes in itself via some
-- mechanism (normally the [Object::notify]("GI.GObject.Objects.Object#g:signal:notify") signal).  Taken together
-- with the [ListModel::itemsChanged]("GI.Gio.Interfaces.ListModel#g:signal:itemsChanged") signal, this provides for a list
-- that can change its membership, and in which the members can change
-- their individual properties.
-- 
-- A good example would be the list of visible wireless network access
-- points, where each access point can report dynamic properties such as
-- signal strength.
-- 
-- It is important to note that the t'GI.Gio.Interfaces.ListModel.ListModel' itself does not report
-- changes to the individual items.  It only reports changes to the list
-- membership.  If you want to observe changes to the objects themselves
-- then you need to connect signals to the objects that you are
-- interested in.
-- 
-- All items in a t'GI.Gio.Interfaces.ListModel.ListModel' are of (or derived from) the same type.
-- 'GI.Gio.Interfaces.ListModel.listModelGetItemType' returns that type.  The type may be an
-- interface, in which case all objects in the list must implement it.
-- 
-- The semantics are close to that of an array:
-- 'GI.Gio.Interfaces.ListModel.listModelGetNItems' returns the number of items in the list and
-- @/g_list_model_get_item()/@ returns an item at a (0-based) position. In
-- order to allow implementations to calculate the list length lazily,
-- you can also iterate over items: starting from 0, repeatedly call
-- @/g_list_model_get_item()/@ until it returns 'P.Nothing'.
-- 
-- An implementation may create objects lazily, but must take care to
-- return the same object for a given position until all references to
-- it are gone.
-- 
-- On the other side, a consumer is expected only to hold references on
-- objects that are currently \"user visible\", in order to facilitate the
-- maximum level of laziness in the implementation of the list and to
-- reduce the required number of signal connections at a given time.
-- 
-- This interface is intended only to be used from a single thread.  The
-- thread in which it is appropriate to use it depends on the particular
-- implementation, but typically it will be from the thread that owns
-- the [thread-default main context][g-main-context-push-thread-default]
-- in effect at the time that the model was created.
-- 
-- Over time, it has established itself as good practice for listmodel
-- implementations to provide properties @item-type@ and @n-items@ to
-- ease working with them. While it is not required, it is recommended
-- that implementations provide these two properties. They should return
-- the values of 'GI.Gio.Interfaces.ListModel.listModelGetItemType' and 'GI.Gio.Interfaces.ListModel.listModelGetNItems'
-- respectively and be defined as such:
-- 
-- === /C code/
-- >
-- >properties[PROP_ITEM_TYPE] =
-- >  g_param_spec_gtype ("item-type", "", "", G_TYPE_OBJECT,
-- >                      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-- >properties[PROP_N_ITEMS] =
-- >  g_param_spec_uint ("n-items", "", "", 0, G_MAXUINT, 0,
-- >                     G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
-- 

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

module GI.Gio.Interfaces.ListModel
    ( 

-- * Exported types
    ListModel(..)                           ,
    IsListModel                             ,
    toListModel                             ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [itemsChanged]("GI.Gio.Interfaces.ListModel#g:method:itemsChanged"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [stealData]("GI.GObject.Objects.Object#g:method:stealData"), [stealQdata]("GI.GObject.Objects.Object#g:method:stealQdata"), [thawNotify]("GI.GObject.Objects.Object#g:method:thawNotify"), [unref]("GI.GObject.Objects.Object#g:method:unref"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure").
-- 
-- ==== Getters
-- [getData]("GI.GObject.Objects.Object#g:method:getData"), [getItem]("GI.Gio.Interfaces.ListModel#g:method:getItem"), [getItemType]("GI.Gio.Interfaces.ListModel#g:method:getItemType"), [getNItems]("GI.Gio.Interfaces.ListModel#g:method:getNItems"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata").
-- 
-- ==== Setters
-- [setData]("GI.GObject.Objects.Object#g:method:setData"), [setDataFull]("GI.GObject.Objects.Object#g:method:setDataFull"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty").

#if defined(ENABLE_OVERLOADING)
    ResolveListModelMethod                  ,
#endif

-- ** getItem #method:getItem#

#if defined(ENABLE_OVERLOADING)
    ListModelGetItemMethodInfo              ,
#endif
    listModelGetItem                        ,


-- ** getItemType #method:getItemType#

#if defined(ENABLE_OVERLOADING)
    ListModelGetItemTypeMethodInfo          ,
#endif
    listModelGetItemType                    ,


-- ** getNItems #method:getNItems#

#if defined(ENABLE_OVERLOADING)
    ListModelGetNItemsMethodInfo            ,
#endif
    listModelGetNItems                      ,


-- ** itemsChanged #method:itemsChanged#

#if defined(ENABLE_OVERLOADING)
    ListModelItemsChangedMethodInfo         ,
#endif
    listModelItemsChanged                   ,




 -- * Signals


-- ** itemsChanged #signal:itemsChanged#

    ListModelItemsChangedCallback           ,
#if defined(ENABLE_OVERLOADING)
    ListModelItemsChangedSignalInfo         ,
#endif
    afterListModelItemsChanged              ,
    onListModelItemsChanged                 ,




    ) 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 GI.GObject.Objects.Object as GObject.Object

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

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

foreign import ccall "g_list_model_get_type"
    c_g_list_model_get_type :: IO B.Types.GType

instance B.Types.TypedObject ListModel where
    glibType :: IO GType
glibType = IO GType
c_g_list_model_get_type

instance B.Types.GObject ListModel

-- | Type class for types which can be safely cast to `ListModel`, for instance with `toListModel`.
class (SP.GObject o, O.IsDescendantOf ListModel o) => IsListModel o
instance (SP.GObject o, O.IsDescendantOf ListModel o) => IsListModel o

instance O.HasParentTypes ListModel
type instance O.ParentTypes ListModel = '[GObject.Object.Object]

-- | Cast to `ListModel`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toListModel :: (MIO.MonadIO m, IsListModel o) => o -> m ListModel
toListModel :: forall (m :: * -> *) o.
(MonadIO m, IsListModel o) =>
o -> m ListModel
toListModel = IO ListModel -> m ListModel
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO ListModel -> m ListModel)
-> (o -> IO ListModel) -> o -> m ListModel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr ListModel -> ListModel) -> o -> IO ListModel
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr ListModel -> ListModel
ListModel

-- | Convert 'ListModel' 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 ListModel) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_list_model_get_type
    gvalueSet_ :: Ptr GValue -> Maybe ListModel -> IO ()
gvalueSet_ Ptr GValue
gv Maybe ListModel
P.Nothing = Ptr GValue -> Ptr ListModel -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr ListModel
forall a. Ptr a
FP.nullPtr :: FP.Ptr ListModel)
    gvalueSet_ Ptr GValue
gv (P.Just ListModel
obj) = ListModel -> (Ptr ListModel -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr ListModel
obj (Ptr GValue -> Ptr ListModel -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe ListModel)
gvalueGet_ Ptr GValue
gv = do
        Ptr ListModel
ptr <- Ptr GValue -> IO (Ptr ListModel)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr ListModel)
        if Ptr ListModel
ptr Ptr ListModel -> Ptr ListModel -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr ListModel
forall a. Ptr a
FP.nullPtr
        then ListModel -> Maybe ListModel
forall a. a -> Maybe a
P.Just (ListModel -> Maybe ListModel)
-> IO ListModel -> IO (Maybe ListModel)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr ListModel -> ListModel)
-> Ptr ListModel -> IO ListModel
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr ListModel -> ListModel
ListModel Ptr ListModel
ptr
        else Maybe ListModel -> IO (Maybe ListModel)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe ListModel
forall a. Maybe a
P.Nothing
        
    

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

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveListModelMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveListModelMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveListModelMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveListModelMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveListModelMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveListModelMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveListModelMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveListModelMethod "itemsChanged" o = ListModelItemsChangedMethodInfo
    ResolveListModelMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveListModelMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveListModelMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveListModelMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveListModelMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveListModelMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveListModelMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveListModelMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveListModelMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveListModelMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveListModelMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveListModelMethod "getItem" o = ListModelGetItemMethodInfo
    ResolveListModelMethod "getItemType" o = ListModelGetItemTypeMethodInfo
    ResolveListModelMethod "getNItems" o = ListModelGetNItemsMethodInfo
    ResolveListModelMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveListModelMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveListModelMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveListModelMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveListModelMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveListModelMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveListModelMethod t ListModel, O.OverloadedMethod info ListModel p) => OL.IsLabel t (ListModel -> 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 ~ ResolveListModelMethod t ListModel, O.OverloadedMethod info ListModel p, R.HasField t ListModel p) => R.HasField t ListModel p where
    getField = O.overloadedMethod @info

#endif

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

#endif

-- method ListModel::get_item_type
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "list"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "ListModel" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GListModel" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TGType)
-- throws : False
-- Skip return : False

foreign import ccall "g_list_model_get_item_type" g_list_model_get_item_type :: 
    Ptr ListModel ->                        -- list : TInterface (Name {namespace = "Gio", name = "ListModel"})
    IO CGType

-- | Gets the type of the items in /@list@/.
-- 
-- All items returned from @/g_list_model_get_item()/@ are of the type
-- returned by this function, or a subtype, or if the type is an
-- interface, they are an implementation of that interface.
-- 
-- The item type of a t'GI.Gio.Interfaces.ListModel.ListModel' can not change during the life of the
-- model.
-- 
-- /Since: 2.44/
listModelGetItemType ::
    (B.CallStack.HasCallStack, MonadIO m, IsListModel a) =>
    a
    -- ^ /@list@/: a t'GI.Gio.Interfaces.ListModel.ListModel'
    -> m GType
    -- ^ __Returns:__ the t'GType' of the items contained in /@list@/.
listModelGetItemType :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsListModel a) =>
a -> m GType
listModelGetItemType a
list = IO GType -> m GType
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GType -> m GType) -> IO GType -> m GType
forall a b. (a -> b) -> a -> b
$ do
    Ptr ListModel
list' <- a -> IO (Ptr ListModel)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
list
    CGType
result <- Ptr ListModel -> IO CGType
g_list_model_get_item_type Ptr ListModel
list'
    let result' :: GType
result' = CGType -> GType
GType CGType
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
list
    GType -> IO GType
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return GType
result'

#if defined(ENABLE_OVERLOADING)
data ListModelGetItemTypeMethodInfo
instance (signature ~ (m GType), MonadIO m, IsListModel a) => O.OverloadedMethod ListModelGetItemTypeMethodInfo a signature where
    overloadedMethod = listModelGetItemType

instance O.OverloadedMethodInfo ListModelGetItemTypeMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gio.Interfaces.ListModel.listModelGetItemType",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.32/docs/GI-Gio-Interfaces-ListModel.html#v:listModelGetItemType"
        })


#endif

-- method ListModel::get_n_items
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "list"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "ListModel" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GListModel" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_list_model_get_n_items" g_list_model_get_n_items :: 
    Ptr ListModel ->                        -- list : TInterface (Name {namespace = "Gio", name = "ListModel"})
    IO Word32

-- | Gets the number of items in /@list@/.
-- 
-- Depending on the model implementation, calling this function may be
-- less efficient than iterating the list with increasing values for
-- /@position@/ until @/g_list_model_get_item()/@ returns 'P.Nothing'.
-- 
-- /Since: 2.44/
listModelGetNItems ::
    (B.CallStack.HasCallStack, MonadIO m, IsListModel a) =>
    a
    -- ^ /@list@/: a t'GI.Gio.Interfaces.ListModel.ListModel'
    -> m Word32
    -- ^ __Returns:__ the number of items in /@list@/.
listModelGetNItems :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsListModel a) =>
a -> m Word32
listModelGetNItems a
list = IO Word32 -> m Word32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Ptr ListModel
list' <- a -> IO (Ptr ListModel)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
list
    Word32
result <- Ptr ListModel -> IO Word32
g_list_model_get_n_items Ptr ListModel
list'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
list
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result

#if defined(ENABLE_OVERLOADING)
data ListModelGetNItemsMethodInfo
instance (signature ~ (m Word32), MonadIO m, IsListModel a) => O.OverloadedMethod ListModelGetNItemsMethodInfo a signature where
    overloadedMethod = listModelGetNItems

instance O.OverloadedMethodInfo ListModelGetNItemsMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gio.Interfaces.ListModel.listModelGetNItems",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.32/docs/GI-Gio-Interfaces-ListModel.html#v:listModelGetNItems"
        })


#endif

-- method ListModel::get_item
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "list"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "ListModel" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GListModel" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "position"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the position of the item to fetch"
--                 , 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 "g_list_model_get_object" g_list_model_get_object :: 
    Ptr ListModel ->                        -- list : TInterface (Name {namespace = "Gio", name = "ListModel"})
    Word32 ->                               -- position : TBasicType TUInt
    IO (Ptr GObject.Object.Object)

-- | Get the item at /@position@/.
-- 
-- If /@position@/ is greater than the number of items in /@list@/, 'P.Nothing' is
-- returned.
-- 
-- 'P.Nothing' is never returned for an index that is smaller than the length
-- of the list.
-- 
-- This function is meant to be used by language bindings in place
-- of @/g_list_model_get_item()/@.
-- 
-- See also: 'GI.Gio.Interfaces.ListModel.listModelGetNItems'
-- 
-- /Since: 2.44/
listModelGetItem ::
    (B.CallStack.HasCallStack, MonadIO m, IsListModel a) =>
    a
    -- ^ /@list@/: a t'GI.Gio.Interfaces.ListModel.ListModel'
    -> Word32
    -- ^ /@position@/: the position of the item to fetch
    -> m (Maybe GObject.Object.Object)
    -- ^ __Returns:__ the object at /@position@/.
listModelGetItem :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsListModel a) =>
a -> Word32 -> m (Maybe Object)
listModelGetItem a
list Word32
position = IO (Maybe Object) -> m (Maybe Object)
forall a. IO a -> m a
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 ListModel
list' <- a -> IO (Ptr ListModel)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
list
    Ptr Object
result <- Ptr ListModel -> Word32 -> IO (Ptr Object)
g_list_model_get_object Ptr ListModel
list' Word32
position
    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
$ \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
GObject.Object.Object) Ptr Object
result'
        Object -> IO Object
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Object
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
list
    Maybe Object -> IO (Maybe Object)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Object
maybeResult

#if defined(ENABLE_OVERLOADING)
data ListModelGetItemMethodInfo
instance (signature ~ (Word32 -> m (Maybe GObject.Object.Object)), MonadIO m, IsListModel a) => O.OverloadedMethod ListModelGetItemMethodInfo a signature where
    overloadedMethod = listModelGetItem

instance O.OverloadedMethodInfo ListModelGetItemMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gio.Interfaces.ListModel.listModelGetItem",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.32/docs/GI-Gio-Interfaces-ListModel.html#v:listModelGetItem"
        })


#endif

-- method ListModel::items_changed
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "list"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "ListModel" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GListModel" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "position"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the position at which @list changed"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "removed"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the number of items removed"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "added"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the number of items added"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_list_model_items_changed" g_list_model_items_changed :: 
    Ptr ListModel ->                        -- list : TInterface (Name {namespace = "Gio", name = "ListModel"})
    Word32 ->                               -- position : TBasicType TUInt
    Word32 ->                               -- removed : TBasicType TUInt
    Word32 ->                               -- added : TBasicType TUInt
    IO ()

-- | Emits the [ListModel::itemsChanged]("GI.Gio.Interfaces.ListModel#g:signal:itemsChanged") signal on /@list@/.
-- 
-- This function should only be called by classes implementing
-- t'GI.Gio.Interfaces.ListModel.ListModel'. It has to be called after the internal representation
-- of /@list@/ has been updated, because handlers connected to this signal
-- might query the new state of the list.
-- 
-- Implementations must only make changes to the model (as visible to
-- its consumer) in places that will not cause problems for that
-- consumer.  For models that are driven directly by a write API (such
-- as t'GI.Gio.Objects.ListStore.ListStore'), changes can be reported in response to uses of that
-- API.  For models that represent remote data, changes should only be
-- made from a fresh mainloop dispatch.  It is particularly not
-- permitted to make changes in response to a call to the t'GI.Gio.Interfaces.ListModel.ListModel'
-- consumer API.
-- 
-- Stated another way: in general, it is assumed that code making a
-- series of accesses to the model via the API, without returning to the
-- mainloop, and without calling other code, will continue to view the
-- same contents of the model.
-- 
-- /Since: 2.44/
listModelItemsChanged ::
    (B.CallStack.HasCallStack, MonadIO m, IsListModel a) =>
    a
    -- ^ /@list@/: a t'GI.Gio.Interfaces.ListModel.ListModel'
    -> Word32
    -- ^ /@position@/: the position at which /@list@/ changed
    -> Word32
    -- ^ /@removed@/: the number of items removed
    -> Word32
    -- ^ /@added@/: the number of items added
    -> m ()
listModelItemsChanged :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsListModel a) =>
a -> Word32 -> Word32 -> Word32 -> m ()
listModelItemsChanged a
list Word32
position Word32
removed Word32
added = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr ListModel
list' <- a -> IO (Ptr ListModel)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
list
    Ptr ListModel -> Word32 -> Word32 -> Word32 -> IO ()
g_list_model_items_changed Ptr ListModel
list' Word32
position Word32
removed Word32
added
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
list
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data ListModelItemsChangedMethodInfo
instance (signature ~ (Word32 -> Word32 -> Word32 -> m ()), MonadIO m, IsListModel a) => O.OverloadedMethod ListModelItemsChangedMethodInfo a signature where
    overloadedMethod = listModelItemsChanged

instance O.OverloadedMethodInfo ListModelItemsChangedMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gio.Interfaces.ListModel.listModelItemsChanged",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.32/docs/GI-Gio-Interfaces-ListModel.html#v:listModelItemsChanged"
        })


#endif

-- signal ListModel::items-changed
-- | This signal is emitted whenever items were added to or removed
-- from /@list@/. At /@position@/, /@removed@/ items were removed and /@added@/
-- items were added in their place.
-- 
-- Note: If @removed != added@, the positions of all later items
-- in the model change.
-- 
-- /Since: 2.44/
type ListModelItemsChangedCallback =
    Word32
    -- ^ /@position@/: the position at which /@list@/ changed
    -> Word32
    -- ^ /@removed@/: the number of items removed
    -> Word32
    -- ^ /@added@/: the number of items added
    -> IO ()

type C_ListModelItemsChangedCallback =
    Ptr ListModel ->                        -- object
    Word32 ->
    Word32 ->
    Word32 ->
    Ptr () ->                               -- user_data
    IO ()

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

wrap_ListModelItemsChangedCallback :: 
    GObject a => (a -> ListModelItemsChangedCallback) ->
    C_ListModelItemsChangedCallback
wrap_ListModelItemsChangedCallback :: forall a.
GObject a =>
(a -> Word32 -> Word32 -> Word32 -> IO ())
-> C_ListModelItemsChangedCallback
wrap_ListModelItemsChangedCallback a -> Word32 -> Word32 -> Word32 -> IO ()
gi'cb Ptr ListModel
gi'selfPtr Word32
position Word32
removed Word32
added Ptr ()
_ = do
    Ptr ListModel -> (ListModel -> IO ()) -> IO ()
forall a b.
(HasCallStack, ManagedPtrNewtype a) =>
Ptr a -> (a -> IO b) -> IO b
B.ManagedPtr.withTransient Ptr ListModel
gi'selfPtr ((ListModel -> IO ()) -> IO ()) -> (ListModel -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ListModel
gi'self -> a -> Word32 -> Word32 -> Word32 -> IO ()
gi'cb (ListModel -> a
forall a b. Coercible a b => a -> b
Coerce.coerce ListModel
gi'self)  Word32
position Word32
removed Word32
added


-- | Connect a signal handler for the [itemsChanged](#signal:itemsChanged) 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' listModel #itemsChanged callback
-- @
-- 
-- 
onListModelItemsChanged :: (IsListModel a, MonadIO m) => a -> ((?self :: a) => ListModelItemsChangedCallback) -> m SignalHandlerId
onListModelItemsChanged :: forall a (m :: * -> *).
(IsListModel a, MonadIO m) =>
a
-> ((?self::a) => Word32 -> Word32 -> Word32 -> IO ())
-> m SignalHandlerId
onListModelItemsChanged a
obj (?self::a) => Word32 -> Word32 -> Word32 -> IO ()
cb = IO SignalHandlerId -> m SignalHandlerId
forall a. IO a -> m a
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 wrapped :: a -> Word32 -> Word32 -> Word32 -> IO ()
wrapped a
self = let ?self = a
?self::a
self in (?self::a) => Word32 -> Word32 -> Word32 -> IO ()
Word32 -> Word32 -> Word32 -> IO ()
cb
    let wrapped' :: C_ListModelItemsChangedCallback
wrapped' = (a -> Word32 -> Word32 -> Word32 -> IO ())
-> C_ListModelItemsChangedCallback
forall a.
GObject a =>
(a -> Word32 -> Word32 -> Word32 -> IO ())
-> C_ListModelItemsChangedCallback
wrap_ListModelItemsChangedCallback a -> Word32 -> Word32 -> Word32 -> IO ()
wrapped
    FunPtr C_ListModelItemsChangedCallback
wrapped'' <- C_ListModelItemsChangedCallback
-> IO (FunPtr C_ListModelItemsChangedCallback)
mk_ListModelItemsChangedCallback C_ListModelItemsChangedCallback
wrapped'
    a
-> Text
-> FunPtr C_ListModelItemsChangedCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"items-changed" FunPtr C_ListModelItemsChangedCallback
wrapped'' SignalConnectMode
SignalConnectBefore Maybe Text
forall a. Maybe a
Nothing

-- | Connect a signal handler for the [itemsChanged](#signal:itemsChanged) 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' listModel #itemsChanged callback
-- @
-- 
-- 
-- 
-- By default the object invoking the signal is not passed to the callback.
-- If you need to access it, you can use the implit @?self@ parameter.
-- Note that this requires activating the @ImplicitParams@ GHC extension.
-- 
afterListModelItemsChanged :: (IsListModel a, MonadIO m) => a -> ((?self :: a) => ListModelItemsChangedCallback) -> m SignalHandlerId
afterListModelItemsChanged :: forall a (m :: * -> *).
(IsListModel a, MonadIO m) =>
a
-> ((?self::a) => Word32 -> Word32 -> Word32 -> IO ())
-> m SignalHandlerId
afterListModelItemsChanged a
obj (?self::a) => Word32 -> Word32 -> Word32 -> IO ()
cb = IO SignalHandlerId -> m SignalHandlerId
forall a. IO a -> m a
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 wrapped :: a -> Word32 -> Word32 -> Word32 -> IO ()
wrapped a
self = let ?self = a
?self::a
self in (?self::a) => Word32 -> Word32 -> Word32 -> IO ()
Word32 -> Word32 -> Word32 -> IO ()
cb
    let wrapped' :: C_ListModelItemsChangedCallback
wrapped' = (a -> Word32 -> Word32 -> Word32 -> IO ())
-> C_ListModelItemsChangedCallback
forall a.
GObject a =>
(a -> Word32 -> Word32 -> Word32 -> IO ())
-> C_ListModelItemsChangedCallback
wrap_ListModelItemsChangedCallback a -> Word32 -> Word32 -> Word32 -> IO ()
wrapped
    FunPtr C_ListModelItemsChangedCallback
wrapped'' <- C_ListModelItemsChangedCallback
-> IO (FunPtr C_ListModelItemsChangedCallback)
mk_ListModelItemsChangedCallback C_ListModelItemsChangedCallback
wrapped'
    a
-> Text
-> FunPtr C_ListModelItemsChangedCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"items-changed" FunPtr C_ListModelItemsChangedCallback
wrapped'' SignalConnectMode
SignalConnectAfter Maybe Text
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
data ListModelItemsChangedSignalInfo
instance SignalInfo ListModelItemsChangedSignalInfo where
    type HaskellCallbackType ListModelItemsChangedSignalInfo = ListModelItemsChangedCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_ListModelItemsChangedCallback cb
        cb'' <- mk_ListModelItemsChangedCallback cb'
        connectSignalFunPtr obj "items-changed" cb'' connectMode detail
    dbgSignalInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gio.Interfaces.ListModel::items-changed"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.32/docs/GI-Gio-Interfaces-ListModel.html#g:signal:itemsChanged"})

#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList ListModel = ListModelSignalList
type ListModelSignalList = ('[ '("itemsChanged", ListModelItemsChangedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])

#endif