{-# LINE 2 "./Graphics/UI/Gtk/ModelView/TreeSortable.chs" #-}-- -*-haskell-*--- GIMP Toolkit (GTK) Interface TreeSortable---- Author : Axel Simon---- Created: 8 Mar 2007---- Copyright (C) 1999-2007 Duncan Coutts, Axel Simon---- This library is free software; you can redistribute it and/or-- modify it under the terms of the GNU Lesser General Public-- License as published by the Free Software Foundation; either-- version 2.1 of the License, or (at your option) any later version.---- This library is distributed in the hope that it will be useful,-- but WITHOUT ANY WARRANTY; without even the implied warranty of-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU-- Lesser General Public License for more details.---- Note: there is a constant called GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID-- which is only used in the C implementation of list store and tree store.-- The TreeModelSort proxy only uses the default column constant. Hence, we do-- not expose or tell the user about the UNSORTED constant since it can only-- be confusing.---- |-- Maintainer : gtk2hs-users@lists.sourceforge.net-- Stability : provisional-- Portability : portable (depends on GHC)---- The interface for sortable models used by 'TreeView'--moduleGraphics.UI.Gtk.ModelView.TreeSortable(-- * Detail---- | 'TreeSortable' is an interface to be implemented by tree models which-- support sorting. The 'TreeView' uses the methods provided by this interface-- to sort the model. As of now, only the-- 'Graphics.UI.Gtk.ModelView.TreeModelSort.TreeModelSort' proxy supports the-- sortable interface. Thus, in order to enable sortable columns in a-- 'TreeView', it is necessary to wrap a-- 'Graphics.UI.Gtk.ModelView.ListStore.ListStore' or-- 'Graphics.UI.Gtk.ModelView.TreeStore.TreeStore' model in a-- 'Graphics.UI.Gtk.ModelView.TreeModelSort.TreeModelSort'.---- A 'Graphics.UI.Gtk.ModelView.TreeViewColumn' can be sorted by the user-- though clicking into the column's header. The rows in the view will then be-- sorted by the sorting function set for that column. Specifically, a set of-- sorting functions must be set using the interface provided in this module.-- Each sorting function is associated with a 'SortColumnId', which is some-- positive number. A tree view column is then associated with the sorting-- function by passing the 'SortColumnId' to-- 'Graphics.UI.Gtk.ModelView.TreeViewColumn.treeViewColumnSetSortColumnId'.-- There exists one special 'SortColumnId', namely-- 'treeSortableDefaultSortColumnId' for which a default sorting function can-- be set. If no such function is set, the order of the rows is the order in-- which they are stored in the model.-- * Class Hierarchy---- |-- @-- | 'GInterface'-- | +----TreeSortable-- @-- * TypesTreeSortable,TreeSortableClass,castToTreeSortable,gTypeTreeSortable,toTreeSortable,SortColumnId,-- * ConstantstreeSortableDefaultSortColumnId,-- * MethodstreeSortableGetSortColumnId,treeSortableSetSortColumnId,treeSortableSetSortFunc,treeSortableSetDefaultSortFunc,treeSortableHasDefaultSortFunc,treeSortableSortColumnChanged,-- * SignalssortColumnChanged)whereimportControl.Monad(liftM,when)importSystem.Glib.FFIimportSystem.Glib.Flags(Flags,toFlags)importSystem.Glib.UTFStringimportSystem.Glib.GObject(destroyFunPtr)importGraphics.UI.Gtk.Types{-# LINE 98 "./Graphics/UI/Gtk/ModelView/TreeSortable.chs" #-}importGraphics.UI.Gtk.General.Enums(SortType(..))importGraphics.UI.Gtk.Signals{-# LINE 100 "./Graphics/UI/Gtk/ModelView/TreeSortable.chs" #-}importGraphics.UI.Gtk.ModelView.Types{-# LINE 101 "./Graphics/UI/Gtk/ModelView/TreeSortable.chs" #-}importGraphics.UI.Gtk.General.Structs(SortColumnId,treeSortableDefaultSortColumnId){-# LINE 105 "./Graphics/UI/Gtk/ModelView/TreeSortable.chs" #-}---------------------- Methods-- %hash c:a53 d:e0d2-- | Query the sort column id that is currently in use. The return value may-- be the special constant 'treeSortableDefaultSortColumnId' in which case-- the returned Boolean flag is @False@.--treeSortableGetSortColumnId::TreeSortableClassself=>self->IO(SortType,Bool,SortColumnId)-- ^ @(type, columnSet, sortColumnId)@-- returns @True@ in @columnSet@ if @sortColumnId@ is not-- 'treeSortableDefaultSortColumnId'. The @type@ value indicates increasing-- or decreasing ordering.treeSortableGetSortColumnIdself=alloca$\orderPtr->alloca$\sortColumnIdPtr->docolumnSet<-liftMtoBool$(\(TreeSortablearg1)arg2arg3->withForeignPtrarg1$\argPtr1->gtk_tree_sortable_get_sort_column_idargPtr1arg2arg3){-# LINE 122 "./Graphics/UI/Gtk/ModelView/TreeSortable.chs" #-}(toTreeSortableself)sortColumnIdPtrorderPtrorder<-peekorderPtrsortColumnId<-peeksortColumnIdPtrreturn(toEnum(fromIntegralorder),columnSet,fromIntegralsortColumnId)-- %hash c:8951 d:33ab-- | Sets the current sort column to be @sortColumnId@. The @sortable@ will-- resort itself to reflect this change, after emitting a 'sortColumnChanged'-- signal. If @sortColumnId@ is 'treeSortableDefaultSortColumnId', then the-- default sort function will be used, if it is set. Note that this function-- is mainly used by the view and that the user program should simply set the-- 'SortColumnId' of the 'TreeViewColumn's.--treeSortableSetSortColumnId::TreeSortableClassself=>self->SortColumnId-- ^ @sortColumnId@ - the sort column id to set->SortType-- ^ @order@ - The sort order of the column->IO()treeSortableSetSortColumnIdselfsortColumnIdorder=(\(TreeSortablearg1)arg2arg3->withForeignPtrarg1$\argPtr1->gtk_tree_sortable_set_sort_column_idargPtr1arg2arg3){-# LINE 143 "./Graphics/UI/Gtk/ModelView/TreeSortable.chs" #-}(toTreeSortableself)(fromIntegralsortColumnId)((fromIntegral.fromEnum)order)-- %hash c:9048 d:c49d-- | Sets the comparison function used when sorting to be @sortFunc@. If the-- current sort column id of @self@ is the same as @sortColumnId@, then the-- model will sort using this function.--treeSortableSetSortFunc::TreeSortableClassself=>self->SortColumnId-- ^ @sortColumnId@ - the sort column id to set-- the function for->(TreeIter->TreeIter->IOOrdering)-- ^ @sortFunc@ - The comparison function->IO()treeSortableSetSortFuncselfsortColumnIdsortFunc=dofPtr<-mkTreeIterCompareFunc(\_iter1Ptriter2Ptr_->doiter1<-peekiter1Ptriter2<-peekiter2PtrliftMorderToGInt$sortFunciter1iter2)(\(TreeSortablearg1)arg2arg3arg4arg5->withForeignPtrarg1$\argPtr1->gtk_tree_sortable_set_sort_funcargPtr1arg2arg3arg4arg5){-# LINE 165 "./Graphics/UI/Gtk/ModelView/TreeSortable.chs" #-}(toTreeSortableself)(fromIntegralsortColumnId)fPtr(castFunPtrToPtrfPtr)destroyFunPtrorderToGInt::Ordering->(CInt){-# LINE 170 "./Graphics/UI/Gtk/ModelView/TreeSortable.chs" #-}orderToGIntLT=-1orderToGIntEQ=0orderToGIntGT=1typeTreeIterCompareFunc=FunPtr(((PtrTreeModel)->((PtrTreeIter)->((PtrTreeIter)->((Ptr())->(IOCInt)))))){-# LINE 175 "./Graphics/UI/Gtk/ModelView/TreeSortable.chs" #-}foreignimportccall"wrapper"mkTreeIterCompareFunc::(PtrTreeModel->PtrTreeIter->PtrTreeIter->Ptr()->IO(CInt))->IOTreeIterCompareFunc-- %hash c:221e d:7c9-- | Sets the default comparison function used when sorting to be @sortFunc@.-- If the current sort column id of @self@ is-- 'treeSortableDefaultSortColumnId' then the model will sort using-- this function.--treeSortableSetDefaultSortFunc::TreeSortableClassself=>self->(TreeIter->TreeIter->IOOrdering)-- ^ @sortFunc@ - The comparison function->IO()treeSortableSetDefaultSortFuncselfsortFunc=dofPtr<-mkTreeIterCompareFunc(\_iter1Ptriter2Ptr_->doiter1<-peekiter1Ptriter2<-peekiter2PtrliftMorderToGInt$sortFunciter1iter2)(\(TreeSortablearg1)arg2arg3arg4->withForeignPtrarg1$\argPtr1->gtk_tree_sortable_set_default_sort_funcargPtr1arg2arg3arg4){-# LINE 196 "./Graphics/UI/Gtk/ModelView/TreeSortable.chs" #-}(toTreeSortableself)fPtr(castFunPtrToPtrfPtr)destroyFunPtr-- %hash c:78ec d:d949-- | Emits a 'sortColumnChanged' signal on the model.--treeSortableSortColumnChanged::TreeSortableClassself=>self->IO()treeSortableSortColumnChangedself=(\(TreeSortablearg1)->withForeignPtrarg1$\argPtr1->gtk_tree_sortable_sort_column_changedargPtr1){-# LINE 205 "./Graphics/UI/Gtk/ModelView/TreeSortable.chs" #-}(toTreeSortableself)-- %hash c:4a10 d:f107-- | Returns @True@ if the model has a default sort function. This is used-- primarily by 'Graphics.UI.Gtk.ModelView.TreeViewColumn's in order to-- determine if a model has a default ordering or if the entries are-- retrieved in the sequence in which they are stored in the model.--treeSortableHasDefaultSortFunc::TreeSortableClassself=>self->IOBool-- ^ returns @True@, if the model has a default sort functiontreeSortableHasDefaultSortFuncself=liftMtoBool$(\(TreeSortablearg1)->withForeignPtrarg1$\argPtr1->gtk_tree_sortable_has_default_sort_funcargPtr1){-# LINE 218 "./Graphics/UI/Gtk/ModelView/TreeSortable.chs" #-}(toTreeSortableself)---------------------- Signals-- %hash c:c461 d:af3f-- |--sortColumnChanged::TreeSortableClassself=>Signalself(IO())sortColumnChanged=Signal(connect_NONE__NONE"sort_column_changed")foreignimportccallunsafe"gtk_tree_sortable_get_sort_column_id"gtk_tree_sortable_get_sort_column_id::((PtrTreeSortable)->((PtrCInt)->((PtrCInt)->(IOCInt))))foreignimportccallsafe"gtk_tree_sortable_set_sort_column_id"gtk_tree_sortable_set_sort_column_id::((PtrTreeSortable)->(CInt->(CInt->(IO()))))foreignimportccallsafe"gtk_tree_sortable_set_sort_func"gtk_tree_sortable_set_sort_func::((PtrTreeSortable)->(CInt->((FunPtr((PtrTreeModel)->((PtrTreeIter)->((PtrTreeIter)->((Ptr())->(IOCInt))))))->((Ptr())->((FunPtr((Ptr())->(IO())))->(IO()))))))foreignimportccallsafe"gtk_tree_sortable_set_default_sort_func"gtk_tree_sortable_set_default_sort_func::((PtrTreeSortable)->((FunPtr((PtrTreeModel)->((PtrTreeIter)->((PtrTreeIter)->((Ptr())->(IOCInt))))))->((Ptr())->((FunPtr((Ptr())->(IO())))->(IO())))))foreignimportccallsafe"gtk_tree_sortable_sort_column_changed"gtk_tree_sortable_sort_column_changed::((PtrTreeSortable)->(IO()))foreignimportccallsafe"gtk_tree_sortable_has_default_sort_func"gtk_tree_sortable_has_default_sort_func::((PtrTreeSortable)->(IOCInt))