]> git.scottworley.com Git - batteryviewer/blob - batteryviewer.c
7be007c3ff54aad376199c1e38bd32fbb0dd04d8
[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
13 window = gtk_application_window_new(app);
14 gtk_window_set_title(GTK_WINDOW(window), "Window");
15 gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
16
17 button = gtk_button_new_with_label("Hello World");
18 g_signal_connect(button, "clicked", G_CALLBACK(print_hello), NULL);
19 gtk_window_set_child(GTK_WINDOW(window), button);
20
21 gtk_window_present(GTK_WINDOW(window));
22 }
23
24 int main(int argc, char **argv) {
25 GtkApplication *app;
26 int status;
27
28 app = gtk_application_new("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
29 g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
30 status = g_application_run(G_APPLICATION(app), argc, argv);
31 g_object_unref(app);
32
33 return status;
34 }