maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   callback parameters when using gtk_builder (https://talk.maemo.org/showthread.php?t=32248)

rajasekaran 2009-09-30 14:28

callback parameters when using gtk_builder
 
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?

Firebird8 2009-10-04 19:04

Re: callback parameters when using gtk_builder
 
Quote:

Originally Posted by rajasekaran (Post 336761)
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);

rajasekaran 2009-10-04 19:44

Re: callback parameters when using gtk_builder
 
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.


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

vBulletin® Version 3.8.8