Re: Urgent help on GValue



Matteo Frigerio wrote:

Hello, probally for many people this is a stupid
question but i can't understand the way to get the
cursor position in a selectable label (under gtk-2.0).
I use the g_object_get_property(G_OBJECT(mylabel),
"cursor_pos", &mygvalue);
in the focus-in event but don't work. I think that don't work because i have bad init the GValue.
Really i don't understand how to init a new GValue.
The code that i use is this:

GValue mygvalue;
GType  mytype;

memset(&mygvalue,0,sizeof(GValue));
G_TYPE_MAKE_FUNDAMENTAL(mytype);
g_value_init(&mygvalue,&mytype);

but i think this is not good.
Some one can help me ? How code i have to use ?

GValue initalization:
{
GValue value={0};

g_value_init(&value, G_TYPE_INT); /* cursor_position is of gint type */
}

You can use g_object_get() function to avoid value handling:
{
gint pos;
   g_object_get(G_OBJECT(label), "cursor_position",&pos, NULL);
}

Olexiy





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