From 77af8e303d375ba148c701a8f513d1eb55347ce4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 3 May 2020 10:32:24 -0400 Subject: [PATCH] Use gtk_overlay_set_child throughout Replace all uses of gtk_container_add on overlays by gtk_overlay_set_child. --- demos/gtk-demo/bluroverlay.c | 2 +- demos/gtk-demo/gears.c | 2 +- demos/gtk-demo/overlay.c | 2 +- demos/gtk-demo/overlay2.c | 2 +- demos/gtk-demo/transparent.c | 2 +- examples/sunny.c | 2 +- gtk/gtkoverlaylayout.c | 4 ++-- tests/gdkgears.c | 2 +- tests/testadjustsize.c | 2 +- tests/testellipsise.c | 2 +- tests/testoverlay.c | 16 ++++++++-------- tests/testoverlaystyleclass.c | 2 +- tests/testpopover.c | 2 +- tests/testscrolledge.c | 2 +- 14 files changed, 22 insertions(+), 22 deletions(-) diff --git a/demos/gtk-demo/bluroverlay.c b/demos/gtk-demo/bluroverlay.c index b2644c0815..b48747f78b 100644 --- a/demos/gtk-demo/bluroverlay.c +++ b/demos/gtk-demo/bluroverlay.c @@ -204,7 +204,7 @@ blur_overlay_size_allocate (GtkWidget *widget, GtkWidget *child; GtkWidget *main_widget; - main_widget = gtk_bin_get_child (GTK_BIN (overlay)); + main_widget = gtk_overlay_get_child (GTK_OVERLAY (overlay)); if (main_widget && gtk_widget_get_visible (main_widget)) gtk_widget_size_allocate (main_widget, &(GtkAllocation) { diff --git a/demos/gtk-demo/gears.c b/demos/gtk-demo/gears.c index f6237da494..bf455b3901 100644 --- a/demos/gtk-demo/gears.c +++ b/demos/gtk-demo/gears.c @@ -107,7 +107,7 @@ do_gears (GtkWidget *do_widget) box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE); gtk_box_set_spacing (GTK_BOX (box), 6); - gtk_container_add (GTK_CONTAINER (overlay), box); + gtk_overlay_set_child (GTK_OVERLAY (overlay), box); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE); gtk_box_set_spacing (GTK_BOX (box), 6); diff --git a/demos/gtk-demo/overlay.c b/demos/gtk-demo/overlay.c index be3c2e1696..ae1391a96d 100644 --- a/demos/gtk-demo/overlay.c +++ b/demos/gtk-demo/overlay.c @@ -37,7 +37,7 @@ do_overlay (GtkWidget *do_widget) overlay = gtk_overlay_new (); grid = gtk_grid_new (); - gtk_container_add (GTK_CONTAINER (overlay), grid); + gtk_overlay_set_child (GTK_OVERLAY (overlay), grid); entry = gtk_entry_new (); diff --git a/demos/gtk-demo/overlay2.c b/demos/gtk-demo/overlay2.c index 8d491faea8..1cfc2d1798 100644 --- a/demos/gtk-demo/overlay2.c +++ b/demos/gtk-demo/overlay2.c @@ -58,7 +58,7 @@ do_overlay2 (GtkWidget *do_widget) gtk_text_buffer_apply_tag (buffer, tag, &start, &end); gtk_window_set_child (GTK_WINDOW (window), overlay); - gtk_container_add (GTK_CONTAINER (overlay), sw); + gtk_overlay_set_child (GTK_OVERLAY (overlay), sw); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), text); g_signal_connect (window, "destroy", diff --git a/demos/gtk-demo/transparent.c b/demos/gtk-demo/transparent.c index 65a7152c11..f53dabed24 100644 --- a/demos/gtk-demo/transparent.c +++ b/demos/gtk-demo/transparent.c @@ -58,7 +58,7 @@ do_transparent (GtkWidget *do_widget) blur_overlay_add_overlay (BLUR_OVERLAY (overlay), button, 5.0); picture = gtk_picture_new_for_resource ("/transparent/portland-rose.jpg"); - gtk_container_add (GTK_CONTAINER (overlay), picture); + gtk_overlay_set_child (GTK_OVERLAY (overlay), picture); } if (!gtk_widget_get_visible (window)) diff --git a/examples/sunny.c b/examples/sunny.c index bd67831451..acb1341e0a 100644 --- a/examples/sunny.c +++ b/examples/sunny.c @@ -27,7 +27,7 @@ new_window (GApplication *app, view = gtk_text_view_new (); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled), view); - gtk_container_add (GTK_CONTAINER (overlay), scrolled); + gtk_overlay_set_child (GTK_OVERLAY (overlay), scrolled); if (file != NULL) { diff --git a/gtk/gtkoverlaylayout.c b/gtk/gtkoverlaylayout.c index a05f58ee23..2e0104f92d 100644 --- a/gtk/gtkoverlaylayout.c +++ b/gtk/gtkoverlaylayout.c @@ -243,7 +243,7 @@ gtk_overlay_layout_measure (GtkLayoutManager *layout_manager, int min, nat; GtkWidget *main_widget; - main_widget = gtk_bin_get_child (GTK_BIN (widget)); + main_widget = gtk_overlay_get_child (GTK_OVERLAY (widget)); min = 0; nat = 0; @@ -397,7 +397,7 @@ gtk_overlay_layout_allocate (GtkLayoutManager *layout_manager, GtkWidget *child; GtkWidget *main_widget; - main_widget = gtk_bin_get_child (GTK_BIN (widget)); + main_widget = gtk_overlay_get_child (GTK_OVERLAY (widget)); if (main_widget && gtk_widget_get_visible (main_widget)) gtk_widget_size_allocate (main_widget, &(GtkAllocation) { 0, 0, width, height }, diff --git a/tests/gdkgears.c b/tests/gdkgears.c index acbb35dc98..5c98eed4db 100644 --- a/tests/gdkgears.c +++ b/tests/gdkgears.c @@ -166,7 +166,7 @@ main (int argc, char *argv[]) box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE); gtk_box_set_spacing (GTK_BOX (box), 6); - gtk_container_add (GTK_CONTAINER (overlay), box); + gtk_overlay_set_child (GTK_OVERLAY (overlay), box); gtk_widget_show (box); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE); diff --git a/tests/testadjustsize.c b/tests/testadjustsize.c index 2f5c227ef0..2e3c251f16 100644 --- a/tests/testadjustsize.c +++ b/tests/testadjustsize.c @@ -166,7 +166,7 @@ open_control_window (void) gtk_widget_show (window); } -#define TEST_WIDGET(outer) (gtk_bin_get_child (GTK_BIN (gtk_bin_get_child (GTK_BIN(outer))))) +#define TEST_WIDGET(outer) (gtk_overlay_get_child (GTK_OVERLAY (gtk_overlay_get_child (GTK_OVERLAY (outer))))) static GtkWidget* create_widget_visible_border (const char *text) diff --git a/tests/testellipsise.c b/tests/testellipsise.c index 0e2301625c..6a8263a9ce 100644 --- a/tests/testellipsise.c +++ b/tests/testellipsise.c @@ -139,7 +139,7 @@ main (int argc, char *argv[]) gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), overlay_draw, label, NULL); overlay = gtk_overlay_new (); - gtk_container_add (GTK_CONTAINER (overlay), da); + gtk_overlay_set_child (GTK_OVERLAY (overlay), da); gtk_widget_set_vexpand (overlay, TRUE); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), label); diff --git a/tests/testoverlay.c b/tests/testoverlay.c index 210fe7594b..565adf549c 100644 --- a/tests/testoverlay.c +++ b/tests/testoverlay.c @@ -63,7 +63,7 @@ test_nonzerox (void) gtk_widget_set_size_request (text, 200, 200); gtk_widget_set_hexpand (text, TRUE); gtk_widget_set_vexpand (text, TRUE); - gtk_container_add (GTK_CONTAINER (overlay), text); + gtk_overlay_set_child (GTK_OVERLAY (overlay), text); child = gtk_label_new ("I'm the overlay"); gtk_widget_set_halign (child, GTK_ALIGN_START); @@ -98,7 +98,7 @@ get_child_position (GtkOverlay *overlay, GtkAllocation main_alloc; gint x, y; - child = gtk_bin_get_child (GTK_BIN (overlay)); + child = gtk_overlay_get_child (GTK_OVERLAY (overlay)); gtk_widget_translate_coordinates (relative, child, 0, 0, &x, &y); main_alloc.x = x; @@ -138,7 +138,7 @@ test_relative (void) gtk_window_set_child (GTK_WINDOW (win), overlay); grid = gtk_grid_new (); - gtk_container_add (GTK_CONTAINER (overlay), grid); + gtk_overlay_set_child (GTK_OVERLAY (overlay), grid); gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Above"), 1, 0, 1, 1); gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Below"), 1, 2, 1, 1); gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Left"), 0, 1, 1, 1); @@ -196,7 +196,7 @@ test_fullwidth (void) gtk_widget_set_size_request (text, 200, 200); gtk_widget_set_hexpand (text, TRUE); gtk_widget_set_vexpand (text, TRUE); - gtk_container_add (GTK_CONTAINER (overlay), text); + gtk_overlay_set_child (GTK_OVERLAY (overlay), text); child = gtk_label_new ("Fullwidth top overlay"); gtk_widget_set_halign (child, GTK_ALIGN_FILL); @@ -232,7 +232,7 @@ test_scrolling (void) sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (sw), 200); gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 200); - gtk_container_add (GTK_CONTAINER (overlay), sw); + gtk_overlay_set_child (GTK_OVERLAY (overlay), sw); text = gtk_text_view_new (); buffer = gtk_text_buffer_new (NULL); @@ -378,7 +378,7 @@ test_chase (void) sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (sw), 200); gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 200); - gtk_container_add (GTK_CONTAINER (overlay), sw); + gtk_overlay_set_child (GTK_OVERLAY (overlay), sw); text = gtk_text_view_new (); text_buffer = gtk_text_buffer_new (NULL); @@ -443,7 +443,7 @@ test_stacking (void) check2 = gtk_check_button_new_with_label ("Show overlay"); g_object_bind_property (child, "visible", check2, "active", G_BINDING_BIDIRECTIONAL); gtk_container_add (GTK_CONTAINER (main_child), label); - gtk_container_add (GTK_CONTAINER (overlay), main_child); + gtk_overlay_set_child (GTK_OVERLAY (overlay), main_child); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child); gtk_grid_attach (GTK_GRID (grid), overlay, 1, 0, 1, 3); gtk_window_set_child (GTK_WINDOW (win), grid); @@ -473,7 +473,7 @@ test_input_stacking (void) overlay = gtk_overlay_new (); grid = gtk_grid_new (); - gtk_container_add (GTK_CONTAINER (overlay), grid); + gtk_overlay_set_child (GTK_OVERLAY (overlay), grid); for (j = 0; j < 5; j++) { diff --git a/tests/testoverlaystyleclass.c b/tests/testoverlaystyleclass.c index 5cff97abb6..8d61b57158 100644 --- a/tests/testoverlaystyleclass.c +++ b/tests/testoverlaystyleclass.c @@ -74,7 +74,7 @@ main (int argc, char *argv[]) gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS); - gtk_container_add (GTK_CONTAINER (overlay), sw); + gtk_overlay_set_child (GTK_OVERLAY (overlay), sw); main_child = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), main_child); diff --git a/tests/testpopover.c b/tests/testpopover.c index 5d3b0fff05..be9a38fe19 100644 --- a/tests/testpopover.c +++ b/tests/testpopover.c @@ -89,7 +89,7 @@ main (int argc, char *argv[]) gtk_widget_set_valign (grid, GTK_ALIGN_FILL); gtk_grid_set_row_spacing (GTK_GRID (grid), 10); gtk_grid_set_column_spacing (GTK_GRID (grid), 10); - gtk_container_add (GTK_CONTAINER (overlay), grid); + gtk_overlay_set_child (GTK_OVERLAY (overlay), grid); label = gtk_label_new (""); gtk_widget_set_hexpand (label, TRUE); diff --git a/tests/testscrolledge.c b/tests/testscrolledge.c index 97d50ded68..16d8ac7664 100644 --- a/tests/testscrolledge.c +++ b/tests/testscrolledge.c @@ -126,7 +126,7 @@ main (int argc, char *argv[]) gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_NONE); gtk_window_set_child (GTK_WINDOW (win), overlay); - gtk_container_add (GTK_CONTAINER (overlay), sw); + gtk_overlay_set_child (GTK_OVERLAY (overlay), sw); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list); populate_list (GTK_LIST_BOX (list));