Я использую gtk3, и он компилируется и работает для меня.
#include <stdlib.h>
#include <gtk/gtk.h>
void activate(GtkApplication* app, gpointer data)
{
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_application_add_window(app, GTK_WINDOW(window));
GtkWidget *button = gtk_button_new_with_label("Button");
g_signal_connect_swapped(GTK_BUTTON(button), "clicked", G_CALLBACK(gtk_widget_destroy), window);
gtk_container_add(GTK_CONTAINER(window), button);
gtk_widget_show(button);
gtk_window_present(GTK_WINDOW(window));
}
int main (int argc, char *argv[])
{
GApplicationFlags flags = G_APPLICATION_FLAGS_NONE;
GtkApplication *app = gtk_application_new("com.devab.daw", flags);
GApplication *gapp = G_APPLICATION(app);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
g_application_run(gapp, argc, argv);
g_object_unref (app);
//g_application_quit(G_APPLICATION(app));
return 0;
}
Перемещение destroy
снаружи activate
.
#include <stdlib.h>
#include <gtk/gtk.h>
void destroy (GtkWidget* widget, gpointer data)
{
g_application_quit(G_APPLICATION(data));
}
void activate(GtkApplication* app, gpointer data)
{
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_application_add_window(app, GTK_WINDOW(window));
GtkWidget *button = gtk_button_new_with_label("Button");
g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(destroy), app);
gtk_container_add(GTK_CONTAINER(window), button);
gtk_widget_show(button);
gtk_window_present(GTK_WINDOW(window));
}
int main (int argc, char *argv[])
{
GApplicationFlags flags = G_APPLICATION_FLAGS_NONE;
GtkApplication *app = gtk_application_new("com.devab.daw", flags);
GApplication *gapp = G_APPLICATION(app);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
g_application_run(gapp, argc, argv);
g_object_unref (app);
//g_application_quit(G_APPLICATION(app));
return 0;
}