Hi Andy,

I think your peekGdkPoint function and the mkIconInfo functions are  
fine. Could you search for 'array' in the docs and replace it with  
'list'? Also all file paths should be of type FilePath, not String.

On May 6, 2010, at 17:15, Andy Stewart wrote:

> +iconInfoGetAttachPoints :: IconInfo -> IO (Maybe ([Point], Int))
> +iconInfoGetAttachPoints self =
> +  allocaArray 0 $ \pointPtr ->

This is not right. You're passing an array of size 0. What you want to  
pass in is a pointer into which the function can write a pointer to a  
heap-allocated array. I.e.

     alloca $ \arrPtrPtr -> do
> +  alloca $ \nPointsPtr -> do
> +  success <- liftM toBool $
> +            {# call gtk_icon_info_get_attach_points #}
> +              self
                 arrPtrPtr
> +              (castPtr pointPtr)
> +              nPointsPtr
> +  if success
> +     then do
           arrPtr <- peek arrPtrPtr
           nPoints <- peek nPointsPtr
          pointList <- peekArray nPoints arrPtr
           return (Just pointList)

> +       pointListPtrs <- peekArray 0 pointPtr
> +       pointList <- mapM peekPoint pointListPtrs
> +       {#call unsafe g_free#} (castPtr pointPtr)
> +       nPoints <- peek nPointsPtr
> +       return (Just (pointList, (fromIntegral nPoints)))
> +     else return Nothing

You would need to create an instance of Storable for Point for this  
code to work.

Cheers,
Axel


------------------------------------------------------------------------------

_______________________________________________
Gtk2hs-devel mailing list
Gtk2hs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel

Reply via email to