From 7840bad5d78664f47c19d019d5d4614aec19e7ea Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 13 May 2014 07:28:20 -0400 Subject: [PATCH] Drop most uses of GtkMisc in tests Replace them by GtkWidget h/valign. The only remaining uses are those where a size group is involved; they can't be replaced until GtkLabel stops looking at GtkMisc alignment for size allocation. --- tests/motion-compression.c | 2 +- tests/testcombochange.c | 35 ++++++++--------------------------- tests/testentryicons.c | 15 ++++++++++----- tests/testgmenu.c | 5 ----- 4 files changed, 19 insertions(+), 38 deletions(-) diff --git a/tests/motion-compression.c b/tests/motion-compression.c index c7effad9a4..de6d9d6b60 100644 --- a/tests/motion-compression.c +++ b/tests/motion-compression.c @@ -55,7 +55,7 @@ main (int argc, char **argv) gtk_box_pack_end (GTK_BOX (vbox), scale, FALSE, FALSE, 0); label = gtk_label_new ("Event processing time (ms):"); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_CENTER); gtk_box_pack_end (GTK_BOX (vbox), label, FALSE, FALSE, 0); g_signal_connect (window, "motion-notify-event", diff --git a/tests/testcombochange.c b/tests/testcombochange.c index 7cd4e0cc69..fdd477246e 100644 --- a/tests/testcombochange.c +++ b/tests/testcombochange.c @@ -70,18 +70,6 @@ combochange_log (const char *fmt, g_free (msg); } -static GtkWidget * -align_button_new (const char *text) -{ - GtkWidget *button = gtk_button_new (); - GtkWidget *label = gtk_label_new (text); - - gtk_container_add (GTK_CONTAINER (button), label); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - - return button; -} - static GtkWidget * create_combo (const char *name, gboolean is_list) @@ -241,7 +229,6 @@ main (int argc, char **argv) GtkWidget *combo_vbox; GtkWidget *button; GtkWidget *menu_combo; - GtkWidget *alignment; GtkWidget *label; GtkWidget *list_combo; @@ -268,25 +255,19 @@ main (int argc, char **argv) label = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (label), "Menu mode"); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (combo_vbox), label, FALSE, FALSE, 0); - alignment = g_object_new (GTK_TYPE_ALIGNMENT, "left-padding", 12, NULL); - gtk_box_pack_start (GTK_BOX (combo_vbox), alignment, FALSE, FALSE, 0); - menu_combo = create_combo ("menu-combo", FALSE); - gtk_container_add (GTK_CONTAINER (alignment), menu_combo); + gtk_widget_set_margin_start (menu_combo, 12); + gtk_box_pack_start (GTK_BOX (combo_vbox), menu_combo, FALSE, FALSE, 0); label = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (label), "List mode"); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (combo_vbox), label, FALSE, FALSE, 0); - alignment = g_object_new (GTK_TYPE_ALIGNMENT, "left-padding", 12, NULL); - gtk_box_pack_start (GTK_BOX (combo_vbox), alignment, FALSE, FALSE, 0); - list_combo = create_combo ("list-combo", TRUE); - gtk_container_add (GTK_CONTAINER (alignment), list_combo); + gtk_widget_set_margin_start (list_combo, 12); + gtk_box_pack_start (GTK_BOX (combo_vbox), list_combo, FALSE, FALSE, 0); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_box_pack_start (GTK_BOX (hbox), scrolled_window, TRUE, TRUE, 0); @@ -304,19 +285,19 @@ main (int argc, char **argv) gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 300); - button = align_button_new ("Insert"); + button = gtk_button_new_with_label ("Insert"); gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0); g_signal_connect (button, "clicked", G_CALLBACK (on_insert), NULL); - button = align_button_new ("Delete"); + button = gtk_button_new_with_label ("Delete"); gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0); g_signal_connect (button, "clicked", G_CALLBACK (on_delete), NULL); - button = align_button_new ("Reorder"); + button = gtk_button_new_with_label ("Reorder"); gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0); g_signal_connect (button, "clicked", G_CALLBACK (on_reorder), NULL); - button = align_button_new ("Animate"); + button = gtk_button_new_with_label ("Animate"); gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0); g_signal_connect (button, "clicked", G_CALLBACK (on_animate), NULL); diff --git a/tests/testentryicons.c b/tests/testentryicons.c index 1c03cade80..8e6122c34c 100644 --- a/tests/testentryicons.c +++ b/tests/testentryicons.c @@ -115,7 +115,8 @@ main (int argc, char **argv) */ label = gtk_label_new ("Open File:"); gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); entry = gtk_entry_new (); gtk_widget_set_hexpand (entry, TRUE); @@ -146,7 +147,8 @@ main (int argc, char **argv) */ label = gtk_label_new ("Save File:"); gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1); - gtk_misc_set_alignment (GTK_MISC(label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); entry = gtk_entry_new (); gtk_widget_set_hexpand (entry, TRUE); @@ -181,7 +183,8 @@ main (int argc, char **argv) */ label = gtk_label_new ("Search:"); gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); entry = gtk_entry_new (); gtk_widget_set_hexpand (entry, TRUE); @@ -207,7 +210,8 @@ main (int argc, char **argv) */ label = gtk_label_new ("Password:"); gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); entry = gtk_entry_new (); gtk_widget_set_hexpand (entry, TRUE); @@ -230,7 +234,8 @@ main (int argc, char **argv) /* Name - Does not set any icons. */ label = gtk_label_new ("Name:"); gtk_grid_attach (GTK_GRID (grid), label, 0, 4, 1, 1); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); entry = gtk_entry_new (); gtk_widget_set_hexpand (entry, TRUE); diff --git a/tests/testgmenu.c b/tests/testgmenu.c index 94a21fe8a1..01ab461f05 100644 --- a/tests/testgmenu.c +++ b/tests/testgmenu.c @@ -294,11 +294,6 @@ append_items_from_model (GtkWidget *menu, gtk_widget_show (w); gtk_widget_set_sensitive (w, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), w); -#if 0 - /* FIXME: this interferes with toggle spacing */ - w = gtk_bin_get_child (GTK_BIN (w)); - gtk_misc_set_alignment (GTK_MISC (w), 0.5, 0.5); -#endif } for (i = 0; i < n; i++)