From: Duncan C. <dun...@us...> - 2004-08-01 16:08:37
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/treeList In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18039/gtk/treeList Modified Files: ListStore.chs api.ignore Log Message: Add missing functions. Update api.ignore files with more deprecated functions. Also fix a couple typo bugs and tidy up some documentation. Index: ListStore.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/treeList/ListStore.chs,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- ListStore.chs 23 May 2004 16:16:43 -0000 1.12 +++ ListStore.chs 1 Aug 2004 16:08:14 -0000 1.13 @@ -24,6 +24,7 @@ -- -- The database for simple (non-hierarchical) tables. -- +#include <gtk/gtkversion.h> module ListStore( ListStore, @@ -38,9 +39,15 @@ listStorePrepend, listStoreAppend, listStoreClear +#if GTK_CHECK_VERSION(2,2,0) + ,listStoreReorder, + listStoreSwap, + listStoreMoveBefore, + listStoreMoveAfter +#endif ) where -import Monad (liftM) +import Monad (liftM, when) import Maybe (fromMaybe) import FFI @@ -55,9 +62,6 @@ {# context lib="gtk" prefix="gtk" #} --- Let's hope this file will always only contain macros. -#include<gtk/gtkversion.h> - -- methods -- | Generate a new entity to store tree information. @@ -165,3 +169,57 @@ -- listStoreClear :: (ListStoreClass ts) => ts -> IO () listStoreClear = {#call list_store_clear#}.toListStore + +#if GTK_CHECK_VERSION(2,2,0) +-- | Reorders store to follow the order indicated by the mapping. The list +-- argument should be a mapping from the /new/ positions to the /old/ +-- positions. That is @newOrder !! newPos = oldPos@ +-- +-- * Note that this function only works with unsorted stores. +-- +-- * You must make sure the mapping is the right size for the store, use +-- @'treeModelIterNChildren' store Nothing@ to check. +-- +listStoreReorder :: (ListStoreClass ts) => ts -> [Int] -> IO () +listStoreReorder ts newOrder = do + --check newOrder is the right length or it'll overrun + storeLength <- treeModelIterNChildren ts Nothing + when (storeLength /= length newOrder) + (fail "ListStore.listStoreReorder: mapping wrong length for store") + withArray (map fromIntegral newOrder) $ \newOrderArrPtr -> + {#call list_store_reorder#} (toListStore ts) newOrderArrPtr + +-- | Swaps the two items in the store. +-- +-- * Note that this function only works with unsorted stores. +-- +listStoreSwap :: (ListStoreClass ts) => ts -> TreeIter -> TreeIter -> IO () +listStoreSwap ts a b = + {#call list_store_swap#} (toListStore ts) a b + +-- | Moves the item in the store to before the given position. If the position +-- is @Nothing@ the item will be moved to then end of the list. +-- +-- * Note that this function only works with unsorted stores. +-- +listStoreMoveBefore :: (ListStoreClass ts) => ts + -> TreeIter -- ^ Iter for the item to be moved + -> Maybe TreeIter -- ^ Iter for the position or @Nothing@. + -> IO () +listStoreMoveBefore ts iter maybePosition = + {#call list_store_move_before#} (toListStore ts) iter + (fromMaybe (TreeIter nullForeignPtr) maybePosition) + +-- | Moves the item in the store to after the given position. If the position +-- is @Nothing@ the item will be moved to then start of the list. +-- +-- * Note that this function only works with unsorted stores. +-- +listStoreMoveAfter :: (ListStoreClass ts) => ts + -> TreeIter -- ^ Iter for the item to be moved + -> Maybe TreeIter -- ^ Iter for the position or @Nothing@. + -> IO () +listStoreMoveAfter ts iter maybePosition = + {#call list_store_move_after#} (toListStore ts) iter + (fromMaybe (TreeIter nullForeignPtr) maybePosition) +#endif Index: api.ignore =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/treeList/api.ignore,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- api.ignore 30 Jul 2004 16:46:54 -0000 1.1 +++ api.ignore 1 Aug 2004 16:08:14 -0000 1.2 @@ -20,3 +20,11 @@ #a bit specialised, we dont need it exclude gtk_cell_renderer_text_set_fixed_height_from_font +#vararg constructor func, we use newv instead +always exclude gtk_list_store_new$ + +#vararg set function +always exclude gtk_list_store_set + +#debugging function +always exclude gtk_list_store_iter_is_valid |