]> git.scottworley.com Git - batteryviewer/blame - batteryviewer.c
gtk: 4 → 3 :(
[batteryviewer] / batteryviewer.c
CommitLineData
79ac753b
SW
1#include <gtk/gtk.h>
2
d2485ebc
SW
3static void print_hello(GtkWidget *widget __attribute__((unused)),
4 gpointer data __attribute__((unused))) {
79ac753b
SW
5 g_print("Hello World\n");
6}
7
d2485ebc
SW
8static void activate(GtkApplication *app,
9 gpointer user_data __attribute__((unused))) {
79ac753b
SW
10 GtkWidget *window;
11 GtkWidget *button;
a9a80e4e 12 GtkWidget *button_box;
79ac753b
SW
13
14 window = gtk_application_window_new(app);
15 gtk_window_set_title(GTK_WINDOW(window), "Window");
16 gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
17
a9a80e4e
SW
18 button_box = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
19 gtk_container_add(GTK_CONTAINER(window), button_box);
20
79ac753b
SW
21 button = gtk_button_new_with_label("Hello World");
22 g_signal_connect(button, "clicked", G_CALLBACK(print_hello), NULL);
a9a80e4e
SW
23 g_signal_connect_swapped(button, "clicked", G_CALLBACK(gtk_widget_destroy),
24 window);
25 gtk_container_add(GTK_CONTAINER(button_box), button);
79ac753b 26
a9a80e4e 27 gtk_widget_show_all(window);
79ac753b
SW
28}
29
30int main(int argc, char **argv) {
31 GtkApplication *app;
32 int status;
33
34 app = gtk_application_new("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
35 g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
36 status = g_application_run(G_APPLICATION(app), argc, argv);
37 g_object_unref(app);
38
39 return status;
40}