{- |
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.Gio.Objects.ListStore
    ( 

-- * Exported types
    ListStore(..)                           ,
    ListStoreK                              ,
    toListStore                             ,
    noListStore                             ,


 -- * Methods
-- ** listStoreAppend
    listStoreAppend                         ,


-- ** listStoreInsert
    listStoreInsert                         ,


-- ** listStoreNew
    listStoreNew                            ,


-- ** listStoreRemove
    listStoreRemove                         ,


-- ** listStoreRemoveAll
    listStoreRemoveAll                      ,




 -- * Properties
-- ** ItemType
    ListStoreItemTypePropertyInfo           ,
    constructListStoreItemType              ,
    getListStoreItemType                    ,




    ) 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.Gio.Types
import GI.Gio.Callbacks
import qualified GI.GObject as GObject

newtype ListStore = ListStore (ForeignPtr ListStore)
foreign import ccall "g_list_store_get_type"
    c_g_list_store_get_type :: IO GType

type instance ParentTypes ListStore = ListStoreParentTypes
type ListStoreParentTypes = '[GObject.Object, ListModel]

instance GObject ListStore where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_list_store_get_type
    

class GObject o => ListStoreK o
instance (GObject o, IsDescendantOf ListStore o) => ListStoreK o

toListStore :: ListStoreK o => o -> IO ListStore
toListStore = unsafeCastTo ListStore

noListStore :: Maybe ListStore
noListStore = Nothing

-- VVV Prop "item-type"
   -- Type: TBasicType TGType
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getListStoreItemType :: (MonadIO m, ListStoreK o) => o -> m GType
getListStoreItemType obj = liftIO $ getObjectPropertyGType obj "item-type"

constructListStoreItemType :: GType -> IO ([Char], GValue)
constructListStoreItemType val = constructObjectPropertyGType "item-type" val

data ListStoreItemTypePropertyInfo
instance AttrInfo ListStoreItemTypePropertyInfo where
    type AttrAllowedOps ListStoreItemTypePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint ListStoreItemTypePropertyInfo = (~) GType
    type AttrBaseTypeConstraint ListStoreItemTypePropertyInfo = ListStoreK
    type AttrGetType ListStoreItemTypePropertyInfo = GType
    type AttrLabel ListStoreItemTypePropertyInfo = "ListStore::item-type"
    attrGet _ = getListStoreItemType
    attrSet _ = undefined
    attrConstruct _ = constructListStoreItemType

type instance AttributeList ListStore = ListStoreAttributeList
type ListStoreAttributeList = ('[ '("item-type", ListStoreItemTypePropertyInfo)] :: [(Symbol, *)])

type instance SignalList ListStore = ListStoreSignalList
type ListStoreSignalList = ('[ '("items-changed", ListModelItemsChangedSignalInfo), '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method ListStore::new
-- method type : Constructor
-- Args : [Arg {argName = "item_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "item_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "ListStore"
-- throws : False
-- Skip return : False

foreign import ccall "g_list_store_new" g_list_store_new :: 
    CGType ->                               -- item_type : TBasicType TGType
    IO (Ptr ListStore)


listStoreNew ::
    (MonadIO m) =>
    GType ->                                -- item_type
    m ListStore
listStoreNew item_type = liftIO $ do
    let item_type' = gtypeToCGType item_type
    result <- g_list_store_new item_type'
    checkUnexpectedReturnNULL "g_list_store_new" result
    result' <- (wrapObject ListStore) result
    return result'

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

foreign import ccall "g_list_store_append" g_list_store_append :: 
    Ptr ListStore ->                        -- _obj : TInterface "Gio" "ListStore"
    Ptr () ->                               -- item : TBasicType TVoid
    IO ()


listStoreAppend ::
    (MonadIO m, ListStoreK a) =>
    a ->                                    -- _obj
    Ptr () ->                               -- item
    m ()
listStoreAppend _obj item = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_list_store_append _obj' item
    touchManagedPtr _obj
    return ()

-- method ListStore::insert
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "ListStore", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "position", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "item", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "ListStore", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "position", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "item", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_list_store_insert" g_list_store_insert :: 
    Ptr ListStore ->                        -- _obj : TInterface "Gio" "ListStore"
    Word32 ->                               -- position : TBasicType TUInt32
    Ptr () ->                               -- item : TBasicType TVoid
    IO ()


listStoreInsert ::
    (MonadIO m, ListStoreK a) =>
    a ->                                    -- _obj
    Word32 ->                               -- position
    Ptr () ->                               -- item
    m ()
listStoreInsert _obj position item = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_list_store_insert _obj' position item
    touchManagedPtr _obj
    return ()

-- method ListStore::remove
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "ListStore", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "position", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "ListStore", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "position", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_list_store_remove" g_list_store_remove :: 
    Ptr ListStore ->                        -- _obj : TInterface "Gio" "ListStore"
    Word32 ->                               -- position : TBasicType TUInt32
    IO ()


listStoreRemove ::
    (MonadIO m, ListStoreK a) =>
    a ->                                    -- _obj
    Word32 ->                               -- position
    m ()
listStoreRemove _obj position = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_list_store_remove _obj' position
    touchManagedPtr _obj
    return ()

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

foreign import ccall "g_list_store_remove_all" g_list_store_remove_all :: 
    Ptr ListStore ->                        -- _obj : TInterface "Gio" "ListStore"
    IO ()


listStoreRemoveAll ::
    (MonadIO m, ListStoreK a) =>
    a ->                                    -- _obj
    m ()
listStoreRemoveAll _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_list_store_remove_all _obj'
    touchManagedPtr _obj
    return ()