Re: Toolbar/Toolbox or something other...
- From: Andreas Volz <andreas brachttal net>
- To: gtk-app-devel-list gnome org <gtk-app-devel-list gnome org>
- Subject: Re: Toolbar/Toolbox or something other...
- Date: Fri, 22 Nov 2002 11:44:49 +0000
Am Thu, 21 Nov 2002 13:55:16 -0500
Tristan Van Berkom <vantr touchtunes com> schrieb:
void g_object_set_data(GObject *obj, gchar *name, gpointer data);
gpointer g_object_get_data(GObject *obj, gchar *name);
Hi,
I tried all, but it didn't work :-(
Has anyone an example for using this? In the gtk-faq is only this:
| struct my_struct p1,p2,*result;
| GtkWidget *w;
|
| gtk_object_set_data(GTK_OBJECT(w),"p1 data",(gpointer)&p1);
| gtk_object_set_data(GTK_OBJECT(w),"p2 data",(gpointer)&p2);
|
| result = gtk_object_get_data(GTK_OBJECT(w),"p1 data");
I'll show you what I tried:
int main (blabla)
{
/* some lines cut... */
GtkWidget *button;
int test = 99;
/* button - run */
button = gtk_button_new_from_stock (GTK_STOCK_EXECUTE);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (run), (gpointer) entry);
gtk_box_pack_start(GTK_BOX (box2), button, TRUE, TRUE, 5);
g_object_set_data (G_OBJECT (button), "test", (gpointer) &test);
result = (int*) g_object_get_data (G_OBJECT (button), "test");
g_print ("result: %d\n", *result); /* this works
*/
gtk_widget_show (button);
}
void run (GtkWidget *button, gpointer entry)
{
int *result;
result = (int*) g_object_get_data (G_OBJECT (button), "test");
g_print ("result: %d\n", *result); /* here: Segmentation
Fault */
/* some lines cut */
}
I doesn't understand it. Perhaps it's only a silly pointer bug ;-)
Andreas
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]