Active Topics

 


Reply
Thread Tools
Posts: 6 | Thanked: 0 times | Joined on Sep 2009 @ Finland
#1
Iam using Glade for GUI building and Gtkbuilder for connecting signals.

As a newbie i got confused with the parameter type of 'data' in the code
Code:
	gtk_builder_connect_signals( builder, data);
'data' is a struct where i have my UIdata stored eg data->button1 ,data->label1........data->label4

Code:
/* Main data structure definition */

typedef struct _ChData ChData;
struct _ChData
{
	/* Widgets */

	GtkWidget *window1;  /* Main application window */
	GtkWidget *label1;
	GtkWidget *label2;
	GtkWidget *label3;
	GtkWidget *label4;
};

#endif /* __SUPPORT_H__ */
i have added the Gobject pointers properly with the ChData

Main window has a button and i need to update label4 upon the click of the button . as show below

Code:
G_MODULE_EXPORT gboolean
button1_clicked_cb( GtkWidget   *widget,
				 GdkEventExpose *event,
				 ChData         *data )
{	
	
	g_print ("DAQ started now\n");
	gtk_label_set_text (GTK_LABEL(data->label4), g_strdup_printf ("DAQ started now"));
	
	return( TRUE );
	
}

All the code compiles without error

but when i run it

g_print is working but gtk_label runs into segmentation fault!!


Can some one throw some light on passing UI data to callbacks?

Last edited by rajasekaran; 2009-09-30 at 20:21.
 
Posts: 110 | Thanked: 215 times | Joined on Apr 2008 @ Earth, 38.830000, -77.00000
#2
Originally Posted by rajasekaran View Post
Iam using Glade for GUI building and Gtkbuilder for connecting signals.

As a newbie i got confused with the parameter type of 'data' in the code
Code:
	gtk_builder_connect_signals( builder, data);
this should be:
Code:
gtk_builder_connect_signals( builder, (gpointer*)data);
__________________
-WIlson Tang
http://www.wil.7ang.me
 
Posts: 6 | Thanked: 0 times | Joined on Sep 2009 @ Finland
#3
thanks for the reply...

i solved the bug .. it was a mistake in the button clicked callback function input arguments. there is no eventexpose parameter passed in button click callback. when i deleted the 2nd input argument things worked.
 
Reply


 
Forum Jump


All times are GMT. The time now is 14:37.