3 static void print_hello(GtkWidget
*widget
__attribute__((unused
)),
4 gpointer data
__attribute__((unused
))) {
5 g_print("Hello World\n");
8 static void activate(GtkApplication
*app
,
9 gpointer user_data
__attribute__((unused
))) {
11 GtkWidget
*window
= gtk_application_window_new(app
);
12 gtk_window_set_title(GTK_WINDOW(window
), "Window");
13 gtk_window_set_default_size(GTK_WINDOW(window
), 200, 200);
15 GtkWidget
*button_box
= gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL
);
16 gtk_container_add(GTK_CONTAINER(window
), button_box
);
18 GtkWidget
*button
= gtk_button_new_with_label("Hello World");
19 g_signal_connect(button
, "clicked", G_CALLBACK(print_hello
), NULL
);
20 g_signal_connect_swapped(button
, "clicked", G_CALLBACK(gtk_widget_destroy
),
22 gtk_container_add(GTK_CONTAINER(button_box
), button
);
24 gtk_widget_show_all(window
);
27 int main(int argc
, char **argv
) {
30 gtk_application_new("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS
);
31 g_signal_connect(app
, "activate", G_CALLBACK(activate
), NULL
);
32 int status
= g_application_run(G_APPLICATION(app
), argc
, argv
);