From bda75577831a61523b072a33dda72a4fd4a1cb8a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 29 Jun 2021 08:01:37 -0400 Subject: [PATCH] Update hello-world.c Simplify the code a bit and make the window match the existing screenshot. --- docs/reference/gtk/getting_started.md | 10 +++++----- examples/hello/hello-world.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/reference/gtk/getting_started.md b/docs/reference/gtk/getting_started.md index df0c968f75..0b1dcee503 100644 --- a/docs/reference/gtk/getting_started.md +++ b/docs/reference/gtk/getting_started.md @@ -161,19 +161,19 @@ activate (GtkApplication *app, { GtkWidget *window; GtkWidget *button; - GtkWidget *box; window = gtk_application_window_new (app); gtk_window_set_title (GTK_WINDOW (window), "Window"); gtk_window_set_default_size (GTK_WINDOW (window), 200, 200); - box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_window_set_child (GTK_WINDOW (window), box); - button = gtk_button_new_with_label ("Hello World"); + gtk_widget_set_halign (button, GTK_ALIGN_CENTER); + gtk_widget_set_valign (button, GTK_ALIGN_CENTER); + g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL); g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window); - gtk_box_append (GTK_BOX (box), button); + + gtk_window_set_child (GTK_WINDOW (window), button); gtk_widget_show (window); } diff --git a/examples/hello/hello-world.c b/examples/hello/hello-world.c index f4c058e978..a597a97573 100644 --- a/examples/hello/hello-world.c +++ b/examples/hello/hello-world.c @@ -13,19 +13,19 @@ activate (GtkApplication *app, { GtkWidget *window; GtkWidget *button; - GtkWidget *box; window = gtk_application_window_new (app); gtk_window_set_title (GTK_WINDOW (window), "Window"); gtk_window_set_default_size (GTK_WINDOW (window), 200, 200); - box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_window_set_child (GTK_WINDOW (window), box); - button = gtk_button_new_with_label ("Hello World"); + gtk_widget_set_halign (button, GTK_ALIGN_CENTER); + gtk_widget_set_valign (button, GTK_ALIGN_CENTER); + g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL); g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window); - gtk_box_append (GTK_BOX (box), button); + + gtk_window_set_child (GTK_WINDOW (window), button); gtk_widget_show (window); }