Re: newbie question



2009/3/11 frederico schardong <frede sch gmail com>:
void my_callback_function (GtkButton *widget, gpointer user_ptr);

...

g_signal_connect( G_OBJECT( widget), "clicked",
   G_CALLBACK( my_callback_function), user_ptr );


void my_callback_function (GtkButton *widget, gpointer user_ptr) {

   ...
}


http://library.gnome.org/devel/gtk/unstable/GtkButton.html

but how I can pass to my_callback_function the gtk_drawing_area? I
know about the g_signal_connect.. but I not know how pass another
widget, Â Â Â Â without the widget being passed the first parameter of
function..
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Hello.

Just pass your drawing area as a last parameter to g_signal_connect function.

Simple code would look like:

---------- CODE -----------
int
main( int argc, char **argv )
{
    GtkWidget *button = gtk_button_new();
    GtkWidget *draw = gtk_drawing_area_new();

    g_signal_connect( G_OBJECT( button ), "clicked",
                      G_CALLBACK( cb_clicked ), draw );

    /* More code here */
}


/* Callback function */
static void
cb_clicked( GtkButton *button,
            GtkWidget *draw )
{
    /* Code here to save your work */
}

------- /CODE ----------

-- 
Tadej BorovÅak
tadeboro gmail com
tadej borovsak gmail com



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