]> git.scottworley.com Git - batteryviewer/blame - batteryviewer.c
GTK project's Hello World
[batteryviewer] / batteryviewer.c
CommitLineData
79ac753b
SW
1#include <gtk/gtk.h>
2
3static void print_hello(GtkWidget *widget, gpointer data) {
4 g_print("Hello World\n");
5}
6
7static void activate(GtkApplication *app, gpointer user_data) {
8 GtkWidget *window;
9 GtkWidget *button;
10
11 window = gtk_application_window_new(app);
12 gtk_window_set_title(GTK_WINDOW(window), "Window");
13 gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
14
15 button = gtk_button_new_with_label("Hello World");
16 g_signal_connect(button, "clicked", G_CALLBACK(print_hello), NULL);
17 gtk_window_set_child(GTK_WINDOW(window), button);
18
19 gtk_window_present(GTK_WINDOW(window));
20}
21
22int main(int argc, char **argv) {
23 GtkApplication *app;
24 int status;
25
26 app = gtk_application_new("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
27 g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
28 status = g_application_run(G_APPLICATION(app), argc, argv);
29 g_object_unref(app);
30
31 return status;
32}