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





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