[gtk/bin-removal: 46/83] Use gtk_popover_set_child throughout
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/bin-removal: 46/83] Use gtk_popover_set_child throughout
- Date: Mon, 4 May 2020 16:48:59 +0000 (UTC)
commit 169900617eb77c5575c820d4b1493cbe82cefc7e
Author: Matthias Clasen <mclasen redhat com>
Date: Fri May 1 22:22:20 2020 -0400
Use gtk_popover_set_child throughout
Replace all uses of gtk_container_add on popovers
by gtk_popover_set_child.
demos/gtk-demo/fishbowl.c | 2 +-
demos/gtk-demo/sliding_puzzle.c | 2 +-
gtk/gtkemojichooser.c | 2 +-
gtk/gtkentrycompletion.c | 2 +-
gtk/gtknotebook.c | 6 ++++--
gtk/gtkplacessidebar.c | 2 +-
gtk/gtkpopovermenu.c | 18 ++++++------------
gtk/gtkshortcutswindow.c | 2 +-
gtk/gtktreepopover.c | 16 ++++++++--------
gtk/inspector/css-node-tree.c | 2 +-
gtk/inspector/prop-editor.c | 16 ++++++++--------
gtk/inspector/recorder.c | 2 +-
tests/gdkgears.c | 2 +-
tests/testdnd2.c | 2 +-
tests/testscrolledwindow.c | 2 +-
tests/testtooltips.c | 2 +-
testsuite/gtk/popover.c | 2 +-
17 files changed, 39 insertions(+), 43 deletions(-)
---
diff --git a/demos/gtk-demo/fishbowl.c b/demos/gtk-demo/fishbowl.c
index 3f49ad2f20..60ec2b5c28 100644
--- a/demos/gtk-demo/fishbowl.c
+++ b/demos/gtk-demo/fishbowl.c
@@ -161,7 +161,7 @@ create_menu_button (void)
GtkWidget *w = gtk_menu_button_new ();
GtkWidget *popover = gtk_popover_new ();
- gtk_container_add (GTK_CONTAINER (popover), gtk_button_new_with_label ("Hey!"));
+ gtk_popover_set_child (GTK_POPOVER (popover), gtk_button_new_with_label ("Hey!"));
gtk_popover_set_autohide (GTK_POPOVER (popover), FALSE);
gtk_menu_button_set_popover (GTK_MENU_BUTTON (w), popover);
g_signal_connect (w, "map", G_CALLBACK (mapped), NULL);
diff --git a/demos/gtk-demo/sliding_puzzle.c b/demos/gtk-demo/sliding_puzzle.c
index 9ea5c1ca3d..b4d0e991e0 100644
--- a/demos/gtk-demo/sliding_puzzle.c
+++ b/demos/gtk-demo/sliding_puzzle.c
@@ -440,7 +440,7 @@ do_sliding_puzzle (GtkWidget *do_widget)
g_signal_connect (apply, "clicked", G_CALLBACK (reconfigure), NULL);
popover = gtk_popover_new ();
- gtk_container_add (GTK_CONTAINER (popover), tweaks);
+ gtk_popover_set_child (GTK_POPOVER (popover), tweaks);
tweak = gtk_menu_button_new ();
gtk_menu_button_set_popover (GTK_MENU_BUTTON (tweak), popover);
diff --git a/gtk/gtkemojichooser.c b/gtk/gtkemojichooser.c
index e8a0d70353..eee1ac7934 100644
--- a/gtk/gtkemojichooser.c
+++ b/gtk/gtkemojichooser.c
@@ -442,7 +442,7 @@ show_variations (GtkEmojiChooser *chooser,
gtk_flow_box_set_activate_on_single_click (GTK_FLOW_BOX (box), TRUE);
gtk_flow_box_set_selection_mode (GTK_FLOW_BOX (box), GTK_SELECTION_NONE);
g_object_set (box, "accept-unpaired-release", TRUE, NULL);
- gtk_container_add (GTK_CONTAINER (popover), view);
+ gtk_popover_set_child (GTK_POPOVER (popover), view);
gtk_container_add (GTK_CONTAINER (view), box);
g_signal_connect (box, "child-activated", G_CALLBACK (emoji_activated), parent_popover);
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index 6191717f16..5ab7fb828a 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -600,7 +600,7 @@ gtk_entry_completion_constructed (GObject *object)
gtk_widget_add_controller (priv->popup_window, controller);
popup_frame = gtk_frame_new (NULL);
- gtk_container_add (GTK_CONTAINER (priv->popup_window), popup_frame);
+ gtk_popover_set_child (GTK_POPOVER (priv->popup_window), popup_frame);
priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_frame_set_child (GTK_FRAME (popup_frame), priv->vbox);
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index a594e7974d..c7b5597865 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -4245,8 +4245,9 @@ gtk_notebook_real_remove (GtkNotebook *notebook,
{
GtkWidget *parent = gtk_widget_get_parent (page->menu_label);
- gtk_notebook_menu_label_unparent (parent, NULL);
- gtk_container_remove (GTK_CONTAINER (notebook->menu), parent);
+ if (parent)
+ gtk_notebook_menu_label_unparent (parent, NULL);
+ gtk_popover_set_child (GTK_POPOVER (notebook->menu), NULL);
gtk_widget_queue_resize (notebook->menu);
}
@@ -6370,6 +6371,7 @@ gtk_notebook_popup_enable (GtkNotebook *notebook)
gtk_widget_set_parent (notebook->menu, notebook->tabs_widget);
notebook->menu_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ g_object_ref_sink (notebook->menu_box);
gtk_popover_menu_add_submenu (GTK_POPOVER_MENU (notebook->menu), notebook->menu_box, "main");
for (list = gtk_notebook_search_page (notebook, NULL, STEP_NEXT, FALSE);
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index dabe9470ef..6ba5cd3a5c 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -2296,7 +2296,7 @@ create_rename_popover (GtkPlacesSidebar *sidebar)
g_signal_connect (popover, "destroy", G_CALLBACK (on_rename_popover_destroy), sidebar);
gtk_popover_set_position (GTK_POPOVER (popover), GTK_POS_RIGHT);
grid = gtk_grid_new ();
- gtk_container_add (GTK_CONTAINER (popover), grid);
+ gtk_popover_set_child (GTK_POPOVER (popover), grid);
g_object_set (grid,
"margin-start", 10,
"margin-end", 10,
diff --git a/gtk/gtkpopovermenu.c b/gtk/gtkpopovermenu.c
index d9faf80f7b..eacd370f6b 100644
--- a/gtk/gtkpopovermenu.c
+++ b/gtk/gtkpopovermenu.c
@@ -265,7 +265,7 @@ gtk_popover_menu_init (GtkPopoverMenu *popover)
gtk_stack_set_vhomogeneous (GTK_STACK (stack), FALSE);
gtk_stack_set_transition_type (GTK_STACK (stack), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
gtk_stack_set_interpolate_size (GTK_STACK (stack), TRUE);
- gtk_container_add (GTK_CONTAINER (popover), stack);
+ gtk_popover_set_child (GTK_POPOVER (popover), stack);
g_signal_connect (stack, "notify::visible-child-name",
G_CALLBACK (visible_submenu_changed), popover);
@@ -328,9 +328,7 @@ gtk_popover_menu_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GtkWidget *stack;
-
- stack = gtk_bin_get_child (GTK_BIN (object));
+ GtkWidget *stack = gtk_popover_get_child (GTK_POPOVER (object));
switch (property_id)
{
@@ -354,9 +352,7 @@ gtk_popover_menu_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GtkWidget *stack;
-
- stack = gtk_bin_get_child (GTK_BIN (object));
+ GtkWidget *stack = gtk_popover_get_child (GTK_POPOVER (object));
switch (property_id)
{
@@ -588,7 +584,7 @@ gtk_popover_menu_open_submenu (GtkPopoverMenu *popover,
g_return_if_fail (GTK_IS_POPOVER_MENU (popover));
- stack = gtk_bin_get_child (GTK_BIN (popover));
+ stack = gtk_popover_get_child (GTK_POPOVER (popover));
gtk_stack_set_visible_child_name (GTK_STACK (stack), name);
}
@@ -597,9 +593,7 @@ gtk_popover_menu_add_submenu (GtkPopoverMenu *popover,
GtkWidget *submenu,
const char *name)
{
- GtkWidget *stack;
-
- stack = gtk_bin_get_child (GTK_BIN (popover));
+ GtkWidget *stack = gtk_popover_get_child (GTK_POPOVER (popover));
gtk_stack_add_named (GTK_STACK (stack), submenu, name);
}
@@ -689,7 +683,7 @@ gtk_popover_menu_set_menu_model (GtkPopoverMenu *popover,
GtkWidget *stack;
GtkWidget *child;
- stack = gtk_bin_get_child (GTK_BIN (popover));
+ stack = gtk_popover_get_child (GTK_POPOVER (popover));
while ((child = gtk_widget_get_first_child (stack)))
gtk_container_remove (GTK_CONTAINER (stack), child);
diff --git a/gtk/gtkshortcutswindow.c b/gtk/gtkshortcutswindow.c
index f51f77dc31..168dce4dc1 100644
--- a/gtk/gtkshortcutswindow.c
+++ b/gtk/gtkshortcutswindow.c
@@ -952,7 +952,7 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self)
G_CALLBACK (gtk_shortcuts_window__list_box__row_activated),
self,
G_CONNECT_SWAPPED);
- gtk_container_add (GTK_CONTAINER (priv->popover), GTK_WIDGET (priv->list_box));
+ gtk_popover_set_child (GTK_POPOVER (priv->popover), GTK_WIDGET (priv->list_box));
priv->search_entry = GTK_SEARCH_ENTRY (gtk_search_entry_new ());
gtk_container_add (GTK_CONTAINER (priv->search_bar), GTK_WIDGET (priv->search_entry));
diff --git a/gtk/gtktreepopover.c b/gtk/gtktreepopover.c
index b638ec2f17..c60ec32aa0 100644
--- a/gtk/gtktreepopover.c
+++ b/gtk/gtktreepopover.c
@@ -25,7 +25,6 @@
#include "gtkcellarea.h"
#include "gtkcelllayout.h"
#include "gtkcellview.h"
-#include "gtkbin.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkgizmoprivate.h"
@@ -231,7 +230,7 @@ gtk_tree_popover_add_submenu (GtkTreePopover *popover,
GtkWidget *submenu,
const char *name)
{
- GtkWidget *stack = gtk_bin_get_child (GTK_BIN (popover));
+ GtkWidget *stack = gtk_popover_get_child (GTK_POPOVER (popover));
gtk_stack_add_named (GTK_STACK (stack), submenu, name);
}
@@ -239,8 +238,7 @@ static GtkWidget *
gtk_tree_popover_get_submenu (GtkTreePopover *popover,
const char *name)
{
- GtkWidget *stack = gtk_bin_get_child (GTK_BIN (popover));
-
+ GtkWidget *stack = gtk_popover_get_child (GTK_POPOVER (popover));
return gtk_stack_get_child_by_name (GTK_STACK (stack), name);
}
@@ -248,7 +246,7 @@ void
gtk_tree_popover_open_submenu (GtkTreePopover *popover,
const char *name)
{
- GtkWidget *stack = gtk_bin_get_child (GTK_BIN (popover));
+ GtkWidget *stack = gtk_popover_get_child (GTK_POPOVER (popover));
gtk_stack_set_visible_child_name (GTK_STACK (stack), name);
}
@@ -261,7 +259,7 @@ gtk_tree_popover_init (GtkTreePopover *popover)
gtk_stack_set_vhomogeneous (GTK_STACK (stack), FALSE);
gtk_stack_set_transition_type (GTK_STACK (stack), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
gtk_stack_set_interpolate_size (GTK_STACK (stack), TRUE);
- gtk_container_add (GTK_CONTAINER (popover), stack);
+ gtk_popover_set_child (GTK_POPOVER (popover), stack);
gtk_widget_add_css_class (GTK_WIDGET (popover), GTK_STYLE_CLASS_MENU);
}
@@ -466,7 +464,7 @@ static GtkWidget *
gtk_tree_popover_get_path_item (GtkTreePopover *popover,
GtkTreePath *search)
{
- GtkWidget *stack = gtk_bin_get_child (GTK_BIN (popover));
+ GtkWidget *stack = gtk_popover_get_child (GTK_POPOVER (popover));
GtkWidget *item = NULL;
GList *children, *l;
@@ -733,7 +731,9 @@ gtk_tree_popover_populate (GtkTreePopover *popover)
static void
rebuild_menu (GtkTreePopover *popover)
{
- GtkWidget *stack = gtk_bin_get_child (GTK_BIN (popover));
+ GtkWidget *stack;
+
+ stack = gtk_popover_get_child (GTK_POPOVER (popover));
gtk_container_foreach (GTK_CONTAINER (stack), (GtkCallback) gtk_widget_destroy, NULL);
if (popover->model)
diff --git a/gtk/inspector/css-node-tree.c b/gtk/inspector/css-node-tree.c
index 52e94a52c7..a5a2017c0f 100644
--- a/gtk/inspector/css-node-tree.c
+++ b/gtk/inspector/css-node-tree.c
@@ -108,7 +108,7 @@ show_node_prop_editor (NodePropEditor *npe)
editor = gtk_inspector_prop_editor_new (G_OBJECT (npe->node), npe->prop_name, NULL);
- gtk_container_add (GTK_CONTAINER (popover), editor);
+ gtk_popover_set_child (GTK_POPOVER (popover), editor);
gtk_popover_popup (GTK_POPOVER (popover));
diff --git a/gtk/inspector/prop-editor.c b/gtk/inspector/prop-editor.c
index a5630d4488..04c8d20dee 100644
--- a/gtk/inspector/prop-editor.c
+++ b/gtk/inspector/prop-editor.c
@@ -573,7 +573,7 @@ flags_changed (GObject *object, GParamSpec *pspec, gpointer data)
g_free (str);
popover = gtk_menu_button_get_popover (GTK_MENU_BUTTON (data));
- sw = gtk_bin_get_child (GTK_BIN (popover));
+ sw = gtk_popover_get_child (GTK_POPOVER (popover));
viewport = gtk_bin_get_child (GTK_BIN (sw));
box = gtk_viewport_get_child (GTK_VIEWPORT (viewport));
children = gtk_container_get_children (GTK_CONTAINER (box));
@@ -943,12 +943,12 @@ property_editor (GObject *object,
GFlagsClass *fclass;
gint j;
- popover = gtk_popover_new ();
+ popover = gtk_popover_new ();
prop_edit = gtk_menu_button_new ();
gtk_menu_button_set_popover (GTK_MENU_BUTTON (prop_edit), popover);
sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (popover), sw);
+ gtk_popover_set_child (GTK_POPOVER (popover), sw);
g_object_set (sw,
"hexpand", TRUE,
"vexpand", TRUE,
@@ -1006,17 +1006,17 @@ property_editor (GObject *object,
else if (type == G_TYPE_PARAM_OBJECT &&
g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (spec), G_TYPE_LIST_MODEL))
{
- GtkWidget *popover;
- GtkWidget *box;
- GtkWidget *sw;
+ GtkWidget *popover;
+ GtkWidget *box;
+ GtkWidget *sw;
GListModel *model;
- popover = gtk_popover_new ();
+ popover = gtk_popover_new ();
prop_edit = gtk_menu_button_new ();
gtk_menu_button_set_popover (GTK_MENU_BUTTON (prop_edit), popover);
sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (popover), sw);
+ gtk_popover_set_child (GTK_POPOVER (popover), sw);
g_object_set (sw,
"hexpand", TRUE,
"vexpand", TRUE,
diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c
index ac7f728f7f..d59d7ca8a6 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -1175,7 +1175,7 @@ node_property_activated (GtkTreeView *tv,
gtk_widget_set_margin_end (image, 20);
gtk_widget_set_margin_top (image, 20);
gtk_widget_set_margin_bottom (image, 20);
- gtk_container_add (GTK_CONTAINER (popover), image);
+ gtk_popover_set_child (GTK_POPOVER (popover), image);
gtk_popover_popup (GTK_POPOVER (popover));
g_signal_connect (popover, "unmap", G_CALLBACK (gtk_widget_destroy), NULL);
diff --git a/tests/gdkgears.c b/tests/gdkgears.c
index a2eae19fd5..bc7a9c869f 100644
--- a/tests/gdkgears.c
+++ b/tests/gdkgears.c
@@ -199,7 +199,7 @@ main (int argc, char *argv[])
gtk_menu_button_set_direction (GTK_MENU_BUTTON (button), GTK_ARROW_UP);
popover = gtk_popover_new ();
label = gtk_label_new ("Popovers work too!");
- gtk_container_add (GTK_CONTAINER (popover), label);
+ gtk_popover_set_child (GTK_POPOVER (popover), label);
gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), popover);
gtk_container_add (GTK_CONTAINER (hbox), button);
diff --git a/tests/testdnd2.c b/tests/testdnd2.c
index cf64e69035..e2b3bb6d30 100644
--- a/tests/testdnd2.c
+++ b/tests/testdnd2.c
@@ -177,7 +177,7 @@ ask_actions (GdkDrop *drop,
g_object_set_data (G_OBJECT (image), "popover", popover);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_add (GTK_CONTAINER (popover), box);
+ gtk_popover_set_child (GTK_POPOVER (popover), box);
button = gtk_button_new_with_label ("Copy");
g_signal_connect (button, "clicked", G_CALLBACK (do_copy), NULL);
gtk_container_add (GTK_CONTAINER (box), button);
diff --git a/tests/testscrolledwindow.c b/tests/testscrolledwindow.c
index a8926410d3..c00508288c 100644
--- a/tests/testscrolledwindow.c
+++ b/tests/testscrolledwindow.c
@@ -221,7 +221,7 @@ scrollable_policy (void)
gtk_container_add (GTK_CONTAINER (cntl), widget);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_container_add (GTK_CONTAINER (popover), vbox);
+ gtk_popover_set_child (GTK_POPOVER (popover), vbox);
/* Popover's scrolled window */
swindow = gtk_scrolled_window_new (NULL, NULL);
diff --git a/tests/testtooltips.c b/tests/testtooltips.c
index 84c40e445f..8696427e2f 100644
--- a/tests/testtooltips.c
+++ b/tests/testtooltips.c
@@ -424,7 +424,7 @@ main (int argc, char *argv[])
popover = gtk_popover_new ();
gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), popover);
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_add (GTK_CONTAINER (popover), box2);
+ gtk_popover_set_child (GTK_POPOVER (popover), box2);
button = gtk_label_new ("Hidden here");
custom = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
diff --git a/testsuite/gtk/popover.c b/testsuite/gtk/popover.c
index cb7813f5c3..2a982e2417 100644
--- a/testsuite/gtk/popover.c
+++ b/testsuite/gtk/popover.c
@@ -44,7 +44,7 @@ test_show_popover (void)
window = gtk_window_new ();
button = gtk_menu_button_new ();
popover = gtk_popover_new ();
- gtk_container_add (GTK_CONTAINER (popover), gtk_label_new ("Nu?"));
+ gtk_popover_set_child (GTK_POPOVER (popover), gtk_label_new ("Nu?"));
gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), popover);
gtk_container_add (GTK_CONTAINER (window), button);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]