]> git.scottworley.com Git - batteryviewer/blame - batteryviewer.c
C89 → C99
[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 10
cecfa926 11 GtkWidget *window = gtk_application_window_new(app);
79ac753b
SW
12 gtk_window_set_title(GTK_WINDOW(window), "Window");
13 gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
14
cecfa926 15 GtkWidget *button_box = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
a9a80e4e
SW
16 gtk_container_add(GTK_CONTAINER(window), button_box);
17
cecfa926 18 GtkWidget *button = gtk_button_new_with_label("Hello World");
79ac753b 19 g_signal_connect(button, "clicked", G_CALLBACK(print_hello), NULL);
a9a80e4e
SW
20 g_signal_connect_swapped(button, "clicked", G_CALLBACK(gtk_widget_destroy),
21 window);
22 gtk_container_add(GTK_CONTAINER(button_box), button);
79ac753b 23
a9a80e4e 24 gtk_widget_show_all(window);
79ac753b
SW
25}
26
27int main(int argc, char **argv) {
79ac753b 28
cecfa926
SW
29 GtkApplication *app =
30 gtk_application_new("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
79ac753b 31 g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
cecfa926 32 int status = g_application_run(G_APPLICATION(app), argc, argv);
79ac753b
SW
33 g_object_unref(app);
34
35 return status;
36}