#include <gtk/gtk.h>
void my_haha(GtkButton* button,gpointer user_data)
{
//打印按钮内容
const char * haha = gtk_button_get_label(button);
printf("%s\n", haha);
//打印传递参数
printf("%s\n",(char *)user_data );
}
int main(int argc, char *argv[])
{
gtk_init(&argc,&argv);
GtkWidget window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request(window,400,300);
gtk_window_set_title(GTK_WINDOW(window),“小可爱”);
GtkWidget button1=gtk_button_new_with_label(“戳我啊”);
gtk_container_add(GTK_CONTAINER(window),button1);
g_signal_connect(button1,“pressed”,G_CALLBACK(my_haha),“哎呀疼”);
gtk_widget_show_all(window);
g_signal_connect(window,“destroy”,G_CALLBACK(gtk_main_quit),NULL);
gtk_main();
return 0;
}