{- |
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.Gtk.Objects.TreeModelSort
    ( 

-- * Exported types
    TreeModelSort(..)                       ,
    TreeModelSortK                          ,
    toTreeModelSort                         ,
    noTreeModelSort                         ,


 -- * Methods
-- ** treeModelSortClearCache
    treeModelSortClearCache                 ,


-- ** treeModelSortConvertChildIterToIter
    treeModelSortConvertChildIterToIter     ,


-- ** treeModelSortConvertChildPathToPath
    treeModelSortConvertChildPathToPath     ,


-- ** treeModelSortConvertIterToChildIter
    treeModelSortConvertIterToChildIter     ,


-- ** treeModelSortConvertPathToChildPath
    treeModelSortConvertPathToChildPath     ,


-- ** treeModelSortGetModel
    treeModelSortGetModel                   ,


-- ** treeModelSortIterIsValid
    treeModelSortIterIsValid                ,


-- ** treeModelSortResetDefaultSortFunc
    treeModelSortResetDefaultSortFunc       ,




 -- * Properties
-- ** Model
    TreeModelSortModelPropertyInfo          ,
    constructTreeModelSortModel             ,
    getTreeModelSortModel                   ,




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

newtype TreeModelSort = TreeModelSort (ForeignPtr TreeModelSort)
foreign import ccall "gtk_tree_model_sort_get_type"
    c_gtk_tree_model_sort_get_type :: IO GType

type instance ParentTypes TreeModelSort = TreeModelSortParentTypes
type TreeModelSortParentTypes = '[GObject.Object, TreeDragSource, TreeModel, TreeSortable]

instance GObject TreeModelSort where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_gtk_tree_model_sort_get_type
    

class GObject o => TreeModelSortK o
instance (GObject o, IsDescendantOf TreeModelSort o) => TreeModelSortK o

toTreeModelSort :: TreeModelSortK o => o -> IO TreeModelSort
toTreeModelSort = unsafeCastTo TreeModelSort

noTreeModelSort :: Maybe TreeModelSort
noTreeModelSort = Nothing

-- VVV Prop "model"
   -- Type: TInterface "Gtk" "TreeModel"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getTreeModelSortModel :: (MonadIO m, TreeModelSortK o) => o -> m TreeModel
getTreeModelSortModel obj = liftIO $ getObjectPropertyObject obj "model" TreeModel

constructTreeModelSortModel :: (TreeModelK a) => a -> IO ([Char], GValue)
constructTreeModelSortModel val = constructObjectPropertyObject "model" val

data TreeModelSortModelPropertyInfo
instance AttrInfo TreeModelSortModelPropertyInfo where
    type AttrAllowedOps TreeModelSortModelPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint TreeModelSortModelPropertyInfo = TreeModelK
    type AttrBaseTypeConstraint TreeModelSortModelPropertyInfo = TreeModelSortK
    type AttrGetType TreeModelSortModelPropertyInfo = TreeModel
    type AttrLabel TreeModelSortModelPropertyInfo = "TreeModelSort::model"
    attrGet _ = getTreeModelSortModel
    attrSet _ = undefined
    attrConstruct _ = constructTreeModelSortModel

type instance AttributeList TreeModelSort = TreeModelSortAttributeList
type TreeModelSortAttributeList = ('[ '("model", TreeModelSortModelPropertyInfo)] :: [(Symbol, *)])

type instance SignalList TreeModelSort = TreeModelSortSignalList
type TreeModelSortSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("row-changed", TreeModelRowChangedSignalInfo), '("row-deleted", TreeModelRowDeletedSignalInfo), '("row-has-child-toggled", TreeModelRowHasChildToggledSignalInfo), '("row-inserted", TreeModelRowInsertedSignalInfo), '("sort-column-changed", TreeSortableSortColumnChangedSignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

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

foreign import ccall "gtk_tree_model_sort_clear_cache" gtk_tree_model_sort_clear_cache :: 
    Ptr TreeModelSort ->                    -- _obj : TInterface "Gtk" "TreeModelSort"
    IO ()


treeModelSortClearCache ::
    (MonadIO m, TreeModelSortK a) =>
    a ->                                    -- _obj
    m ()
treeModelSortClearCache _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    gtk_tree_model_sort_clear_cache _obj'
    touchManagedPtr _obj
    return ()

-- method TreeModelSort::convert_child_iter_to_iter
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "TreeModelSort", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "sort_iter", argType = TInterface "Gtk" "TreeIter", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "child_iter", argType = TInterface "Gtk" "TreeIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "TreeModelSort", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "child_iter", argType = TInterface "Gtk" "TreeIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "gtk_tree_model_sort_convert_child_iter_to_iter" gtk_tree_model_sort_convert_child_iter_to_iter :: 
    Ptr TreeModelSort ->                    -- _obj : TInterface "Gtk" "TreeModelSort"
    Ptr TreeIter ->                         -- sort_iter : TInterface "Gtk" "TreeIter"
    Ptr TreeIter ->                         -- child_iter : TInterface "Gtk" "TreeIter"
    IO CInt


treeModelSortConvertChildIterToIter ::
    (MonadIO m, TreeModelSortK a) =>
    a ->                                    -- _obj
    TreeIter ->                             -- child_iter
    m (Bool,TreeIter)
treeModelSortConvertChildIterToIter _obj child_iter = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    sort_iter <- callocBoxedBytes 32 :: IO (Ptr TreeIter)
    let child_iter' = unsafeManagedPtrGetPtr child_iter
    result <- gtk_tree_model_sort_convert_child_iter_to_iter _obj' sort_iter child_iter'
    let result' = (/= 0) result
    sort_iter' <- (wrapBoxed TreeIter) sort_iter
    touchManagedPtr _obj
    touchManagedPtr child_iter
    return (result', sort_iter')

-- method TreeModelSort::convert_child_path_to_path
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "TreeModelSort", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "child_path", argType = TInterface "Gtk" "TreePath", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "TreeModelSort", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "child_path", argType = TInterface "Gtk" "TreePath", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gtk" "TreePath"
-- throws : False
-- Skip return : False

foreign import ccall "gtk_tree_model_sort_convert_child_path_to_path" gtk_tree_model_sort_convert_child_path_to_path :: 
    Ptr TreeModelSort ->                    -- _obj : TInterface "Gtk" "TreeModelSort"
    Ptr TreePath ->                         -- child_path : TInterface "Gtk" "TreePath"
    IO (Ptr TreePath)


treeModelSortConvertChildPathToPath ::
    (MonadIO m, TreeModelSortK a) =>
    a ->                                    -- _obj
    TreePath ->                             -- child_path
    m TreePath
treeModelSortConvertChildPathToPath _obj child_path = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let child_path' = unsafeManagedPtrGetPtr child_path
    result <- gtk_tree_model_sort_convert_child_path_to_path _obj' child_path'
    checkUnexpectedReturnNULL "gtk_tree_model_sort_convert_child_path_to_path" result
    result' <- (wrapBoxed TreePath) result
    touchManagedPtr _obj
    touchManagedPtr child_path
    return result'

-- method TreeModelSort::convert_iter_to_child_iter
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "TreeModelSort", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "child_iter", argType = TInterface "Gtk" "TreeIter", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "sorted_iter", argType = TInterface "Gtk" "TreeIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "TreeModelSort", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "sorted_iter", argType = TInterface "Gtk" "TreeIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gtk_tree_model_sort_convert_iter_to_child_iter" gtk_tree_model_sort_convert_iter_to_child_iter :: 
    Ptr TreeModelSort ->                    -- _obj : TInterface "Gtk" "TreeModelSort"
    Ptr TreeIter ->                         -- child_iter : TInterface "Gtk" "TreeIter"
    Ptr TreeIter ->                         -- sorted_iter : TInterface "Gtk" "TreeIter"
    IO ()


treeModelSortConvertIterToChildIter ::
    (MonadIO m, TreeModelSortK a) =>
    a ->                                    -- _obj
    TreeIter ->                             -- sorted_iter
    m (TreeIter)
treeModelSortConvertIterToChildIter _obj sorted_iter = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    child_iter <- callocBoxedBytes 32 :: IO (Ptr TreeIter)
    let sorted_iter' = unsafeManagedPtrGetPtr sorted_iter
    gtk_tree_model_sort_convert_iter_to_child_iter _obj' child_iter sorted_iter'
    child_iter' <- (wrapBoxed TreeIter) child_iter
    touchManagedPtr _obj
    touchManagedPtr sorted_iter
    return child_iter'

-- method TreeModelSort::convert_path_to_child_path
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "TreeModelSort", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "sorted_path", argType = TInterface "Gtk" "TreePath", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "TreeModelSort", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "sorted_path", argType = TInterface "Gtk" "TreePath", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gtk" "TreePath"
-- throws : False
-- Skip return : False

foreign import ccall "gtk_tree_model_sort_convert_path_to_child_path" gtk_tree_model_sort_convert_path_to_child_path :: 
    Ptr TreeModelSort ->                    -- _obj : TInterface "Gtk" "TreeModelSort"
    Ptr TreePath ->                         -- sorted_path : TInterface "Gtk" "TreePath"
    IO (Ptr TreePath)


treeModelSortConvertPathToChildPath ::
    (MonadIO m, TreeModelSortK a) =>
    a ->                                    -- _obj
    TreePath ->                             -- sorted_path
    m TreePath
treeModelSortConvertPathToChildPath _obj sorted_path = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let sorted_path' = unsafeManagedPtrGetPtr sorted_path
    result <- gtk_tree_model_sort_convert_path_to_child_path _obj' sorted_path'
    checkUnexpectedReturnNULL "gtk_tree_model_sort_convert_path_to_child_path" result
    result' <- (wrapBoxed TreePath) result
    touchManagedPtr _obj
    touchManagedPtr sorted_path
    return result'

-- method TreeModelSort::get_model
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "TreeModelSort", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "TreeModelSort", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gtk" "TreeModel"
-- throws : False
-- Skip return : False

foreign import ccall "gtk_tree_model_sort_get_model" gtk_tree_model_sort_get_model :: 
    Ptr TreeModelSort ->                    -- _obj : TInterface "Gtk" "TreeModelSort"
    IO (Ptr TreeModel)


treeModelSortGetModel ::
    (MonadIO m, TreeModelSortK a) =>
    a ->                                    -- _obj
    m TreeModel
treeModelSortGetModel _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gtk_tree_model_sort_get_model _obj'
    checkUnexpectedReturnNULL "gtk_tree_model_sort_get_model" result
    result' <- (newObject TreeModel) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "gtk_tree_model_sort_iter_is_valid" gtk_tree_model_sort_iter_is_valid :: 
    Ptr TreeModelSort ->                    -- _obj : TInterface "Gtk" "TreeModelSort"
    Ptr TreeIter ->                         -- iter : TInterface "Gtk" "TreeIter"
    IO CInt


treeModelSortIterIsValid ::
    (MonadIO m, TreeModelSortK a) =>
    a ->                                    -- _obj
    TreeIter ->                             -- iter
    m Bool
treeModelSortIterIsValid _obj iter = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let iter' = unsafeManagedPtrGetPtr iter
    result <- gtk_tree_model_sort_iter_is_valid _obj' iter'
    let result' = (/= 0) result
    touchManagedPtr _obj
    touchManagedPtr iter
    return result'

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

foreign import ccall "gtk_tree_model_sort_reset_default_sort_func" gtk_tree_model_sort_reset_default_sort_func :: 
    Ptr TreeModelSort ->                    -- _obj : TInterface "Gtk" "TreeModelSort"
    IO ()


treeModelSortResetDefaultSortFunc ::
    (MonadIO m, TreeModelSortK a) =>
    a ->                                    -- _obj
    m ()
treeModelSortResetDefaultSortFunc _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    gtk_tree_model_sort_reset_default_sort_func _obj'
    touchManagedPtr _obj
    return ()