From: Axel S. <si...@co...> - 2008-08-21 21:25:02
|
Thu Aug 21 17:16:58 EDT 2008 A....@ke... * Add getter and setter for Maybe Objects. hunk ./glib/System/Glib/GValueTypes.chs 63 + valueGetMaybeGObject, hunk ./glib/System/Glib/GValueTypes.chs 226 -valueSetMaybeGObject :: GObjectClass gobj => GValue -> (Maybe gobj) -> IO () -valueSetMaybeGObject gvalue (Just obj) = valueSetGObject gvalue obj -valueSetMaybeGObject gvalue Nothing = - {# call unsafe g_value_set_object #} gvalue nullPtr - hunk ./glib/System/Glib/GValueTypes.chs 235 + +valueSetMaybeGObject :: GObjectClass gobj => GValue -> (Maybe gobj) -> IO () +valueSetMaybeGObject gvalue (Just obj) = valueSetGObject gvalue obj +valueSetMaybeGObject gvalue Nothing = + {# call unsafe g_value_set_object #} gvalue nullPtr + +valueGetMaybeGObject :: GObjectClass gobj => GValue -> IO (Maybe gobj) +valueGetMaybeGObject gvalue = + liftM (liftM unsafeCastGObject) $ + maybeNull (makeNewGObject mkGObject) $ + liftM castPtr $ + {# call unsafe value_get_object #} gvalue hunk ./glib/System/Glib/Properties.chs 84 - + newAttrFromMaybeObjectProperty, + [_$_] hunk ./glib/System/Glib/Properties.chs 217 +objectSetPropertyMaybeGObject :: (GObjectClass gobj, GObjectClass gobj') => GType -> String -> gobj -> (Maybe gobj') -> IO () +objectSetPropertyMaybeGObject gtype = objectSetPropertyInternal gtype valueSetMaybeGObject + +objectGetPropertyMaybeGObject :: (GObjectClass gobj, GObjectClass gobj') => GType -> String -> gobj -> IO (Maybe gobj') +objectGetPropertyMaybeGObject gtype = objectGetPropertyInternal gtype valueGetMaybeGObject + hunk ./glib/System/Glib/Properties.chs 316 +newAttrFromMaybeObjectProperty :: (GObjectClass gobj, GObjectClass gobj', GObjectClass gobj'') => String -> GType -> ReadWriteAttr gobj (Maybe gobj') (Maybe gobj'') +newAttrFromMaybeObjectProperty propName gtype = + newAttr (objectGetPropertyMaybeGObject gtype propName) (objectSetPropertyMaybeGObject gtype propName) + [_$_] |