]> git.scottworley.com Git - batteryviewer/blame - batteryviewer.c
-Wall -Wextra -pedantic -Werror
[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;
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
24int 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}