RE: gtk_object_set_data_full
- From: "Thomas Cameron" <tom ceisystems com>
- To: <drl22 cornell edu>, <gtk-app-devel-list gnome org>
- Subject: RE: gtk_object_set_data_full
- Date: Thu, 5 Sep 2002 12:44:15 -0400
Ah yes,
The zen of programming shines through again. :-) I know that I do the
same thing many times, using certain calls because I've seen it done
before. It really depends on which version of GTK+ you're using. In
GTK+-2.0.x, this function has actually been depreciated and replaced by
"g_object_set_data_full(). From what I gather, the only purpose to
using this function is to be notified when the the object or its
associations are destroyed. I would assume that this would be for
cleanup purposes, etc.
Good Luck,
Tom Cameron
-----Original Message-----
From: drl22 cornell edu [mailto:drl22 cornell edu]
Sent: Thursday, September 05, 2002 1:44 AM
To: gtk-app-devel-list gnome org
Subject: Re: gtk_object_set_data_full
Two little changes, you need to cast the 4th argument,
and gtk_object_ref returns void :-P. Try this:
gtk_object_ref(GTK_OBJECT(tree_view));
gtk_object_set_data_full(
GTK_OBJECT(main_window),
"tree_view",
GTK_OBJECT(tree_view),
(GtkDestroyNotify)gtk_object_unref
);
That works nicely!
Anybody know why these ref/unrefs are necessary when
you add a child widget pointer to the parent widget? I
know glade-generated code puts them in, so I do too,
but I don't understand them.
The child widget will be destroyed when the parent
widget is destroyed, so the parent's object data will
be inaccessible, right? Am I missing something?
-Dan
Quoting Collin Starkweather
<collin starkweather collinstarkweather com>:
I'm very new to Gtk and not so hot with C, so please
bear with me.
I'm trying to set data using gtk_object_set_data_full
() to keep track of
some child widgets of my main window. I'm using the
Gnome 1.x
libraries.
To do so, I'm trying something like
gtk_object_set_data_full(
GTK_OBJECT(main_window),
"tree_view",
gtk_object_ref(GTK_OBJECT(tree_view)),
gtk_object_unref
);
where tree_view is a GtkTree widget and which is
consistent with an
example I saw in a mailing list somewhere.
I'm getting an error:
passing arg 4 of `gtk_object_set_data_full' from
incompatible pointer
type
Unfortunately, I can't find any documentation for
gtk_object_set_data_full other than the prototype in
the generic API
documentation such as
http://developer.gnome.org/doc/API/2.0/gtk/gtkobject.htm
l
which seems like it may be helpful if I had alot more
experience in Gtk
and/or C. A bit of a chicken-and-egg problem there.
There's also no mention of it I can find in the book
I'm using, SAMS
"Teach Yourself Gtk+ Programming in 21 Days." (I
know, I know, it's
probably not the most comprehensive manual out there,
but I'm just
learning.)
Any suggestions would be appreciated.
-Collin
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~
Collin Starkweather
http://www.collinstarkweather.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-
list
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]