Hi Maxime, After i check some code, indeed, you're right.
I have apply your patch, thanks! :) -- Andy Maxime Henrion <mhenr...@gmail.com> writes: > Hello all, > > > The attached patch fixes a few minor problems in the gtk package. > > The treeModelFilterSetVisibleFunc function was accepting a "Maybe > (TreeIter -> IO Bool)" type for the visible function, allowing to pass > NULL to the corresponding gtk function when Nothing had been given. > However, this isn't supported by the gtk API and causes an error message > to be printed about it on the console. I just changed the type to a > plain "TreeIter -> IO Bool" and removed the Nothing case. > > In a surprisingly symmetrical way, the treeSortableSetDefaultSortFunc > was only accepting a "TreeIter -> TreeIter -> IO Ordering" type for the > sort function, whereas this time, it is possible to pass NULL to the > underlying gtk function. Doing so is actually quite useful: it allows > to disable the "original" ordering of your rows. If you don't do that, > clicking on a column header cycles through ascending sort, descending > sort, *and* original order. Passing a NULL default sort function allows > to have only the 2 usual sorting states. > > Needless to say, both fixes break the API, and I am not sure how you > guys handle these kind of things. > > Thanks! > Maxime Henrion > > diff -rN -u old-gtk2hs/gtk/Graphics/UI/Gtk/ModelView/TreeModelFilter.chs > new-gtk2hs/gtk/Graphics/UI/Gtk/ModelView/TreeModelFilter.chs > --- old-gtk2hs/gtk/Graphics/UI/Gtk/ModelView/TreeModelFilter.chs 2010-10-17 > 23:40:18.000000000 +0200 > +++ new-gtk2hs/gtk/Graphics/UI/Gtk/ModelView/TreeModelFilter.chs 2010-10-17 > 23:40:19.000000000 +0200 > @@ -148,13 +148,9 @@ > -- up to date. > -- > treeModelFilterSetVisibleFunc :: TreeModelFilterClass self => self > - -> Maybe (TreeIter -> IO Bool) -- ^ @func@ - The visible > function or > - -- @Nothing@ to reset this function. > + -> (TreeIter -> IO Bool) -- ^ @func@ - The visible function. > -> IO () > -treeModelFilterSetVisibleFunc self Nothing = > - {# call gtk_tree_model_filter_set_visible_func #} > - (toTreeModelFilter self) nullFunPtr nullPtr nullFunPtr > -treeModelFilterSetVisibleFunc self (Just func) = do > +treeModelFilterSetVisibleFunc self func = do > funcPtr <- mkTreeModelFilterVisibleFunc $ \_ tiPtr _ -> do > ti <- peekTreeIter tiPtr > liftM fromBool $ func ti > diff -rN -u old-gtk2hs/gtk/Graphics/UI/Gtk/ModelView/TreeSortable.chs > new-gtk2hs/gtk/Graphics/UI/Gtk/ModelView/TreeSortable.chs > --- old-gtk2hs/gtk/Graphics/UI/Gtk/ModelView/TreeSortable.chs 2010-10-17 > 23:40:18.000000000 +0200 > +++ new-gtk2hs/gtk/Graphics/UI/Gtk/ModelView/TreeSortable.chs 2010-10-17 > 23:40:19.000000000 +0200 > @@ -184,10 +184,15 @@ > -- this function. > -- > treeSortableSetDefaultSortFunc :: TreeSortableClass self => self > - -> (TreeIter -> TreeIter -> IO Ordering) > - -- ^ @sortFunc@ - The comparison function > + -> Maybe (TreeIter -> TreeIter -> IO Ordering) > + -- ^ @sortFunc@ - The comparison function, > + -- or Nothing to reset it. > -> IO () > -treeSortableSetDefaultSortFunc self sortFunc = do > +treeSortableSetDefaultSortFunc self Nothing = do > + {# call tree_sortable_set_default_sort_func #} > + (toTreeSortable self) > + nullFunPtr nullPtr nullFunPtr > +treeSortableSetDefaultSortFunc self (Just sortFunc) = do > fPtr <- mkTreeIterCompareFunc (\_ iter1Ptr iter2Ptr _ -> do > iter1 <- peek iter1Ptr > iter2 <- peek iter2Ptr > ------------------------------------------------------------------------------ > Download new Adobe(R) Flash(R) Builder(TM) 4 > The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly > Flex(R) Builder(TM)) enable the development of rich applications that run > across multiple browsers and platforms. Download your free trials today! > http://p.sf.net/sfu/adobe-dev2dev_______________________________________________ > Gtk2hs-devel mailing list > Gtk2hs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ Gtk2hs-devel mailing list Gtk2hs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel