Sending data in a GTK Callback
Posted
by snostorm
on Stack Overflow
See other posts from Stack Overflow
or by snostorm
Published on 2010-05-25T20:16:05Z
Indexed on
2010/05/25
20:21 UTC
Read the original article
Hit count: 224
How can I send data through a GTK callback? I've Googled, and with the information I found created this:
#include <gtk/gtk.h>
#include <stdio.h>
void button_clicked( GtkWidget *widget, GdkEvent *event, gchar *data);
int main( int argc, char *argv[]){
GtkWidget *window;
GtkWidget *button;
gtk_init (&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
button = gtk_button_new_with_label("Go!");
gtk_container_add(GTK_CONTAINER(window), button);
g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked),"test" );
gtk_widget_show(window);
gtk_widget_show(button);
gtk_main();
return 0;
}
void button_clicked( GtkWidget *widget, GdkEvent *event, gchar *data){
printf("%s \n", (gchar *) data);
return;
}
But it just Segfaults when I press the button. What is the right way to do this?
© Stack Overflow or respective owner