]> git.scottworley.com Git - batteryviewer/blob - batteryviewer.c
6c4304cd643bde66f9dee732497724adc25c5308
[batteryviewer] / batteryviewer.c
1 #include <gtk/gtk.h>
2
3 static void print_hello(GtkWidget *widget __attribute__((unused)),
4 gpointer data __attribute__((unused))) {
5 g_print("Hello World\n");
6 }
7
8 static void activate(GtkApplication *app,
9 gpointer user_data __attribute__((unused))) {
10 GtkWidget *window;
11 GtkWidget *button;
12 GtkWidget *button_box;
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
18 button_box = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
19 gtk_container_add(GTK_CONTAINER(window), button_box);
20
21 button = gtk_button_new_with_label("Hello World");
22 g_signal_connect(button, "clicked", G_CALLBACK(print_hello), NULL);
23 g_signal_connect_swapped(button, "clicked", G_CALLBACK(gtk_widget_destroy),
24 window);
25 gtk_container_add(GTK_CONTAINER(button_box), button);
26
27 gtk_widget_show_all(window);
28 }
29
30 int 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 }