GTK C - Passing multiple variables using g_signal_connect -
GTK C - Passing multiple variables using g_signal_connect -
so, i'm trying accomplish following:
the user choosing file, , path file saved in variable filename. after choosing file user selecting checkbox chmod want set.
i have this:
g_signal_connect (ux, "toggled",g_callback(user_read_only), (gpointer *)ux);
and function user_read_only:
void user_read_only(gtkwidget *widget, gpointer *data) { if (gtk_toggle_button_get_active(gtk_toggle_button(data))){ int stat; stat = chmod(filename, s_irusr); printf("added read attribute user in file: %s\n", filename); } else { printf("no read attribute user in file: %s\n", filename); } }
my question is: how can pass filename callback function? when try:
g_signal_connect (ux, "toggled",g_callback(user_read_only), (gpointer *)ux,filename);
i got error can pass 1 variable.
that info parameter of gpointer type pass whatever type of info want pass onto callback.
g_signal_connect (ux, "toggled",g_callback(user_read_only), (gpointer *)filename);
should trick. not need pass gtk instance (ux) data. need alter function as:
void user_read_only(gtkwidget *widget, gpointer *data) { if (gtk_toggle_button_get_active(gtk_toggle_button(widget))){ int stat; stat = chmod(data, s_irusr); printf("added read attribute user in file: %s\n", (char *)data); } else { printf("no read attribute user in file: %s\n", (char *)data); } }
c gtk
Comments
Post a Comment