{- | 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 , -- ** listStoreInsertSorted listStoreInsertSorted , -- ** listStoreNew listStoreNew , -- ** listStoreRemove listStoreRemove , -- ** listStoreRemoveAll listStoreRemoveAll , -- ** listStoreSort listStoreSort , -- ** listStoreSplice listStoreSplice , -- * 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.GLib as GLib 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 = TInterface "GObject" "Object", 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 = TInterface "GObject" "Object", 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 GObject.Object -> -- item : TInterface "GObject" "Object" IO () listStoreAppend :: (MonadIO m, ListStoreK a, GObject.ObjectK b) => a -> -- _obj b -> -- item m () listStoreAppend _obj item = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let item' = unsafeManagedPtrCastPtr item g_list_store_append _obj' item' touchManagedPtr _obj touchManagedPtr item 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 = TInterface "GObject" "Object", 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 = TInterface "GObject" "Object", 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 GObject.Object -> -- item : TInterface "GObject" "Object" IO () listStoreInsert :: (MonadIO m, ListStoreK a, GObject.ObjectK b) => a -> -- _obj Word32 -> -- position b -> -- item m () listStoreInsert _obj position item = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let item' = unsafeManagedPtrCastPtr item g_list_store_insert _obj' position item' touchManagedPtr _obj touchManagedPtr item return () -- method ListStore::insert_sorted -- 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 = TInterface "GObject" "Object", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "compare_func", argType = TInterface "GLib" "CompareDataFunc", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeCall, argClosure = 3, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", 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 = TInterface "GObject" "Object", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "compare_func", argType = TInterface "GLib" "CompareDataFunc", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeCall, argClosure = 3, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TUInt32 -- throws : False -- Skip return : False foreign import ccall "g_list_store_insert_sorted" g_list_store_insert_sorted :: Ptr ListStore -> -- _obj : TInterface "Gio" "ListStore" Ptr GObject.Object -> -- item : TInterface "GObject" "Object" FunPtr GLib.CompareDataFuncC -> -- compare_func : TInterface "GLib" "CompareDataFunc" Ptr () -> -- user_data : TBasicType TVoid IO Word32 listStoreInsertSorted :: (MonadIO m, ListStoreK a, GObject.ObjectK b) => a -> -- _obj b -> -- item GLib.CompareDataFunc -> -- compare_func m Word32 listStoreInsertSorted _obj item compare_func = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let item' = unsafeManagedPtrCastPtr item compare_func' <- GLib.mkCompareDataFunc (GLib.compareDataFuncWrapper Nothing compare_func) let user_data = nullPtr result <- g_list_store_insert_sorted _obj' item' compare_func' user_data safeFreeFunPtr $ castFunPtrToPtr compare_func' touchManagedPtr _obj touchManagedPtr item return result -- 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 () -- method ListStore::sort -- 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 = "compare_func", argType = TInterface "GLib" "CompareDataFunc", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeCall, argClosure = 2, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", 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 = "compare_func", argType = TInterface "GLib" "CompareDataFunc", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeCall, argClosure = 2, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "g_list_store_sort" g_list_store_sort :: Ptr ListStore -> -- _obj : TInterface "Gio" "ListStore" FunPtr GLib.CompareDataFuncC -> -- compare_func : TInterface "GLib" "CompareDataFunc" Ptr () -> -- user_data : TBasicType TVoid IO () listStoreSort :: (MonadIO m, ListStoreK a) => a -> -- _obj GLib.CompareDataFunc -> -- compare_func m () listStoreSort _obj compare_func = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj compare_func' <- GLib.mkCompareDataFunc (GLib.compareDataFuncWrapper Nothing compare_func) let user_data = nullPtr g_list_store_sort _obj' compare_func' user_data safeFreeFunPtr $ castFunPtrToPtr compare_func' touchManagedPtr _obj return () -- method ListStore::splice -- 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 = "n_removals", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "additions", argType = TCArray False (-1) 4 (TInterface "GObject" "Object"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "n_additions", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [Arg {argName = "n_additions", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- 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 = "n_removals", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "additions", argType = TCArray False (-1) 4 (TInterface "GObject" "Object"), 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_splice" g_list_store_splice :: Ptr ListStore -> -- _obj : TInterface "Gio" "ListStore" Word32 -> -- position : TBasicType TUInt32 Word32 -> -- n_removals : TBasicType TUInt32 Ptr (Ptr GObject.Object) -> -- additions : TCArray False (-1) 4 (TInterface "GObject" "Object") Word32 -> -- n_additions : TBasicType TUInt32 IO () listStoreSplice :: (MonadIO m, ListStoreK a) => a -> -- _obj Word32 -> -- position Word32 -> -- n_removals [GObject.Object] -> -- additions m () listStoreSplice _obj position n_removals additions = liftIO $ do let n_additions = fromIntegral $ length additions let _obj' = unsafeManagedPtrCastPtr _obj let additions' = map unsafeManagedPtrCastPtr additions additions'' <- packPtrArray additions' g_list_store_splice _obj' position n_removals additions'' n_additions touchManagedPtr _obj mapM_ touchManagedPtr additions freeMem additions'' return ()