1 | /* simple.c |
2 | * Copyright (C) 2017 Red Hat, Inc |
3 | * Author: Benjamin Otte |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Library General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Library General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Library General Public |
16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
17 | */ |
18 | #include "config.h" |
19 | #include <gtk/gtk.h> |
20 | |
21 | |
22 | static void |
23 | hello (void) |
24 | { |
25 | g_print (format: "hello world\n" ); |
26 | } |
27 | |
28 | static void |
29 | quit_cb (GtkWidget *widget, |
30 | gpointer data) |
31 | { |
32 | gboolean *done = data; |
33 | |
34 | *done = TRUE; |
35 | |
36 | g_main_context_wakeup (NULL); |
37 | } |
38 | |
39 | int |
40 | main (int argc, char *argv[]) |
41 | { |
42 | GtkWidget *window, *button; |
43 | gboolean done = FALSE; |
44 | |
45 | gtk_init (); |
46 | |
47 | window = gtk_window_new (); |
48 | gtk_window_set_title (GTK_WINDOW (window), title: "hello world" ); |
49 | gtk_window_set_resizable (GTK_WINDOW (window), FALSE); |
50 | g_signal_connect (window, "destroy" , G_CALLBACK (quit_cb), &done); |
51 | |
52 | button = gtk_button_new (); |
53 | gtk_button_set_label (GTK_BUTTON (button), label: "hello world" ); |
54 | gtk_widget_set_margin_top (widget: button, margin: 10); |
55 | gtk_widget_set_margin_bottom (widget: button, margin: 10); |
56 | gtk_widget_set_margin_start (widget: button, margin: 10); |
57 | gtk_widget_set_margin_end (widget: button, margin: 10); |
58 | g_signal_connect (button, "clicked" , G_CALLBACK (hello), NULL); |
59 | |
60 | gtk_window_set_child (GTK_WINDOW (window), child: button); |
61 | |
62 | gtk_widget_show (widget: window); |
63 | |
64 | while (!done) |
65 | g_main_context_iteration (NULL, TRUE); |
66 | |
67 | return 0; |
68 | } |
69 | |