Glib / GObject newbie

Hi all,

I'm developping an application in C and I'd like to use the GObjects (and later GTypeModule).
I'm not using GTK, I just want to "program Object Oriented with C".

I've studied Mathieu Lacage's Gobject sample (maman_bar etc.) and I've created some 'simple' classes but I 'd like to implement a Gobject containing other Gobjects. And I don't know how to write the get/set_property for a Gobject.
I'm sorry I'm not very clear.

that's what I want to implement using GObjects :
. a Camera containing a position ( => Vector3 : a GObject containing 3 gfloats) and other members

so I've got :
typedef struct t_Camera Camera;
typedef struct t_CameraPrivate CameraPrivate;

struct t_Camera {
 GObject parent;
 /* instance members */
 CameraPrivate *priv;

struct t_CameraPrivate
 gfloat mFov;
 Vector3 mPosition;
// and other members ...

and I'd like to write
static void
camera_get_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
      Camera *self = (Camera *) object;

       switch (property_id) {
       case CAMERA_FOV: {
               g_value_set_float (value, self->priv->mFov);

       case CAMERA_POSITION :
       // There is my problem
       // I don't know what to do

How can I transform a GValue into a GObject ?
And how do I use it ?

Of course there's the same problem with the camera_set_property function.

I don't really understand what GValue is and how I can use it.

I hope you understand my problem and I thank you in advance.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]