From: Duncan C. <dun...@us...> - 2005-07-02 19:22:16
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/TreeList In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11333/gtk/Graphics/UI/Gtk/TreeList Modified Files: CellRenderer.hs Log Message: glib/System/Glib/GValueTypes.chs: add value(Set|Get)Enum and value(Set|Get)Flags. Remove use of valueInit since it is done elsewhere. glib/System/Glib/Properties.chs: use valueInit in objectSetPropertyInternal and objectGetPropertyInternal. Modify other object(Set|Get)Property* functions to pass the GType. glib/System/Glib/StoreValue.hsc: use valueInit in valueSetGenericValue and remove object(Set|Get)PropertyGeneric since they are not used much and are hard to implement correctly. gtk/Graphics/UI/Gtk/Abstract/Object.chs.pp: remove objectSetProperty and objectGetProperty which were just wrappers around object(Set|Get)PropertyGeneric. gtk/Graphics/UI/Gtk/TreeList/CellRenderer.hs: change the implementation of cellRendererSet and cellRendererGet because objectSetProperty and objectGetProperty were removed. For object(Set|Get)PropertyInternal we do have the GType available from the Attribute. Even so, it would be preferable if cellRenderer(Set|Get) were replaced with ordinary type safe Attributes. Index: CellRenderer.hs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/TreeList/CellRenderer.hs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- CellRenderer.hs 8 May 2005 12:58:42 -0000 1.4 +++ CellRenderer.hs 2 Jul 2005 19:22:04 -0000 1.5 @@ -79,9 +79,14 @@ cellRendererGet ) where +import Monad (zipWithM, zipWithM_) + import Graphics.UI.Gtk.Types -import System.Glib.StoreValue (GenericValue, TMType) -import Graphics.UI.Gtk.Abstract.Object (objectSetProperty, objectGetProperty) +import System.Glib.StoreValue (GenericValue, TMType, + valueSetGenericValue, valueGetGenericValue) +import qualified System.Glib.GTypeConstants as GType +import System.Glib.Properties (objectSetPropertyInternal, + objectGetPropertyInternal) -- | Definition of the 'Attribute' data type. -- @@ -101,9 +106,13 @@ -- cellRendererSet :: CellRendererClass cr => cr -> Attribute cr val -> val -> IO () -cellRendererSet cr (Attribute names _ write _) val = do +cellRendererSet cr (Attribute names types write _) val = do values <- write val - mapM_ (uncurry $ objectSetProperty cr) (zip names values) + sequence_ $ zipWith3 (\name tmtype value -> + objectSetPropertyInternal + (fromIntegral $ fromEnum tmtype) + valueSetGenericValue name cr value) + names types values -- | Get a static property. -- @@ -114,6 +123,10 @@ -- cellRendererGet :: CellRendererClass cr => cr -> Attribute cr val -> IO val -cellRendererGet cr (Attribute names _ _ read) = do - values <- mapM (objectGetProperty cr) names +cellRendererGet cr (Attribute names types _ read) = do + values <- zipWithM (\name tmtype -> + objectGetPropertyInternal + (fromIntegral $ fromEnum tmtype) + valueGetGenericValue name cr) + names types read values |