Passing variables through callback function in GTK C -


i'm trying print value of variable i on console callback functon, instead of printing 23 keeps printing address 11652528 etc...

i've been searching quite lot on net , according old gtk tutorial (where actual g_callback macro gtk_signal_func) should work.

does have idea error is??

#include <stdlib.h> #include <gtk/gtk.h> #include <string.h>  void f_window(gtkwidget* widget, gpointer data) {     g_print("%d\n",gpointer_to_int(data)); } int main(int argc, char **argv) {     gint i=23;      gtkwidget * mainwindow = null;      gtk_init(&argc, &argv);      mainwindow = gtk_window_new(gtk_window_toplevel);      g_signal_connect(g_object(mainwindow),"delete-event",g_callback(f_window),gint_to_pointer(i));      gtk_widget_show_all(mainwindow);     gtk_main();       gtk_exit(exit_success);     return exit_success; } 

thank in advance!!!

the "delete-event" signal callback takes three arguments.

the function signature f_window should gtkwidget* widget, gdkevent *event, gpointer data.

you printing value of event in code.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -