#include <gtk/gtk.h>static void on_activate(GtkApplication* app, gpointer user_data) { GtkWidget *window; GtkWidget *button;// 创建一个新窗口 window = gtk_application_window_new(app); gtk_window_set_title(GTK_WINDOW(window), "Hello GTK"); gtk_window_set_default_size(GTK_WINDOW(window), 400, 400);// 创建一个按钮并添加到窗口 button = gtk_button_new_with_label("我是一个按钮!"); gtk_container_add(GTK_CONTAINER(window), button);// 显示窗口和按钮 gtk_widget_show_all(window); }int main(int argc, char **argv) { GtkApplication *app; int status;// 创建一个新的GTK应用程序 app = gtk_application_new("com.test.GtkApplication", G_APPLICATION_FLAGS_NONE); g_signal_connect(app, "activate", G_CALLBACK(on_activate), NULL);// 运行应用程序 status = g_application_run(G_APPLICATION(app), argc, argv);// 释放应用程序对象 g_object_unref(app);return status; }