How to get stuff out of a GValue?

2007-11-19 Thread Dan H
OK, I've got something in the form of a GValue (in this case, integer numeric 
data
obtained with gtk_container_child_get()), and I'd like to get access to the 
actual number inside. How is this done? I've looked into GValue's 
documentation, but all I see is stuff that deals only with GValues and no 
interface to the outside world of regular C types.

Any hints?

--D.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to get stuff out of a GValue?

2007-11-19 Thread Emmanuele Bassi

On Mon, 2007-11-19 at 11:50 +0100, Dan H wrote:
> OK, I've got something in the form of a GValue (in this case, integer numeric 
> data
> obtained with gtk_container_child_get()), and I'd like to get access to the 
> actual number inside. How is this done? I've looked into GValue's 
> documentation, but all I see is stuff that deals only with GValues and no 
> interface to the outside world of regular C types.
> 
> Any hints?

just one page further:

http://library.gnome.org/devel/gobject/stable/gobject-Standard-Parameter-and-Value-Types.html

usually, you get the type held by the GValue with G_VALUE_TYPE() and
then switch; obviously, if you know the type of the property already
then you can just use the right g_value_get_*() accessor.

ciao,
 Emmanuele.

-- 
Emmanuele Bassi,
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to get stuff out of a GValue?

2007-11-19 Thread Tomas Carnecky
Dan H wrote:
> OK, I've got something in the form of a GValue (in this case, integer numeric 
> data
> obtained with gtk_container_child_get()), and I'd like to get access to the 
> actual number inside. How is this done? I've looked into GValue's 
> documentation, but all I see is stuff that deals only with GValues and no 
> interface to the outside world of regular C types.
> 

http://developer.gimp.org/api/2.0/gobject/gobject-Standard-Parameter-and-Value-Types.html

tom
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to get stuff out of a GValue?

2007-11-19 Thread Dan H
On Mon, 19 Nov 2007 10:56:35 +
Emmanuele Bassi <[EMAIL PROTECTED]> wrote:

> > Any hints?
> 
> just one page further:
> 
> http://library.gnome.org/devel/gobject/stable/gobject-Standard-Parameter-and-Value-Types.html

Ah, I'm using the Debian-supplied version 2.12.4, and your page refers to 
2.14.3. Thanks. I guess it's just missing from my docs.

As it is, I'm having much more fundamental problems. I'm trying to do this to a 
GtkWidget *child inside GtkTable *table:
-
GValue left_attach;

gtk_container_child_get(GTK_CONTAINER(table), child,
"left-attach", &left_attach, NULL);
g_printerr("%s\n", g_strdup_value_contents(&left_attach),
-

And I'm getting this error:

GLib-GObject-CRITICAL **: g_strdup_value_contents: assertion
`G_IS_VALUE (value)' failed

Why?

--D.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to get stuff out of a GValue?

2007-11-19 Thread Emmanuele Bassi

On Mon, 2007-11-19 at 12:18 +0100, Dan H wrote:
> On Mon, 19 Nov 2007 10:56:35 +
> Emmanuele Bassi <[EMAIL PROTECTED]> wrote:
> 
> > > Any hints?
> > 
> > just one page further:
> > 
> > http://library.gnome.org/devel/gobject/stable/gobject-Standard-Parameter-and-Value-Types.html
> 
> Ah, I'm using the Debian-supplied version 2.12.4, and your page refers to 
> 2.14.3. Thanks. I guess it's just missing from my docs.

nope: it's been there for ages. :-)

> As it is, I'm having much more fundamental problems. I'm trying to do this to 
> a GtkWidget *child inside GtkTable *table:
> -

- GValue left_attach;
+ GValue left_attach = { 0, };
+
+ g_value_init (&left_attach);
+
  gtk_container_child_get(GTK_CONTAINER(table), child,
  "left-attach", &left_attach, NULL);

  g_printerr("%s\n", g_strdup_value_contents(&left_attach),
+
+ g_value_unset (&left_attach);

> -
> 
> And I'm getting this error:
> 
> GLib-GObject-CRITICAL **: g_strdup_value_contents: assertion
> `G_IS_VALUE (value)' failed
> 
> Why?

because you need to initialise the GValue, if it's on the stack. you
also need to unset it to free its contents.

ciao,
 Emmanuele.

-- 
Emmanuele Bassi,
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to get stuff out of a GValue?

2007-11-19 Thread Dan H
On Mon, 19 Nov 2007 11:33:36 +
Emmanuele Bassi <[EMAIL PROTECTED]> wrote:

Hallo Emmanuele,

it's not getting better. Here's my code. li->data points to a cild of the 
table, and the code compiles without warnings with -W -Wall:

-
g_value_init(&value, G_TYPE_INT);
gtk_container_child_get(GTK_CONTAINER(table), li->data,
"left-attach", &value, NULL); 
g_printerr("%s\n", g_strdup_value_contents(&value));
g_value_unset(&value);
-
and on running it, I still get this error:

 GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE
(value)' failed

Strangely, when I comment-out the call to gtk_container_child_get(), 
g_strdup_value_contents(&value) just returns "0" (as expected). It seems to be 
gtk_container_child_get() that somehow messes up the value.

--D.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GUI problem.

2007-11-19 Thread alberto barbaro
Hi. I'm trying to develop a small application.

Problem:

I have a table with some buttons. I pass the pointer to the table in a
thread, in that thread i would update the table with a some new buttons. The
buttons will appeare but are not 'clickable'! Why? if I try return thay
works but with the mouse no. Someone can help me?

Thanks
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to get stuff out of a GValue?

2007-11-19 Thread Benoît Dejean

Le lundi 19 novembre 2007 à 11:33 +, Emmanuele Bassi a écrit :
> On Mon, 2007-11-19 at 12:18 +0100, Dan H wrote:
> > On Mon, 19 Nov 2007 10:56:35 +
> > Emmanuele Bassi <[EMAIL PROTECTED]> wrote:
> > 
> > > > Any hints?
> > > 
> > > just one page further:
> > > 
> > > http://library.gnome.org/devel/gobject/stable/gobject-Standard-Parameter-and-Value-Types.html
> > 
> > Ah, I'm using the Debian-supplied version 2.12.4, and your page refers to 
> > 2.14.3. Thanks. I guess it's just missing from my docs.
> 
> nope: it's been there for ages. :-)
> 
> > As it is, I'm having much more fundamental problems. I'm trying to do this 
> > to a GtkWidget *child inside GtkTable *table:
> > -
> 
> - GValue left_attach;
> + GValue left_attach = { 0, };
> +
> + g_value_init (&left_attach);
> +

I always though that this requirement was error prone. You just get to 
initialize
your GValue twice to make it OK. A lot of beginners hit this error. The
doc says "A zero-filled (uninitialized) GValue structure." which looks
like an oxymoron :)
-- 
Benoît Dejean
GNOME http://www.gnomefr.org/
LibGTop http://directory.fsf.org/libgtop.html
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list