[gtk/kill-popover-relative-to] popover: Drop ::relative-to



commit de16a06b2a19fb33984fad92df1f90f443f16525
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Feb 24 07:21:46 2020 -0500

    popover: Drop ::relative-to
    
    It should enough to just set the parent.
    Also change GtkPopoverMenu api to match.
    
    Update all users.

 demos/gtk-demo/application.c          |   2 +-
 demos/gtk-demo/clipboard.c            |   3 +-
 demos/gtk-demo/dnd.c                  |   3 +-
 demos/gtk-demo/fishbowl.c             |   2 +-
 demos/gtk-demo/popover.c              |   3 +-
 demos/gtk-demo/sliding_puzzle.c       |   2 +-
 demos/widget-factory/widget-factory.c |   3 +-
 docs/tools/widgets.c                  |   4 +-
 gtk/a11y/gtkpopoveraccessible.c       |  65 +--------------
 gtk/gtkcolorswatch.c                  |   3 +-
 gtk/gtkemojichooser.c                 |   3 +-
 gtk/gtkemojicompletion.c              |   5 +-
 gtk/gtkentrycompletion.c              |   8 +-
 gtk/gtkfilechooserwidget.c            |  10 +--
 gtk/gtklabel.c                        |   3 +-
 gtk/gtklinkbutton.c                   |   3 +-
 gtk/gtkmenubutton.c                   |  10 +--
 gtk/gtkmenusectionbox.c               |   2 +-
 gtk/gtkmodelbutton.c                  |   4 +-
 gtk/gtkmountoperation.c               |   3 +-
 gtk/gtknotebook.c                     |   3 +-
 gtk/gtkplacessidebar.c                |  14 ++--
 gtk/gtkplacesview.c                   |   5 +-
 gtk/gtkpopover.c                      | 145 +++++++---------------------------
 gtk/gtkpopover.h                      |   8 +-
 gtk/gtkpopovermenu.c                  |  27 +++----
 gtk/gtkpopovermenu.h                  |   6 +-
 gtk/gtkpopovermenubar.c               |   3 +-
 gtk/gtkpopovermenuprivate.h           |   2 +-
 gtk/gtkscalebutton.c                  |   2 +-
 gtk/gtkshortcutswindow.c              |   1 -
 gtk/gtktext.c                         |  11 ++-
 gtk/gtktextview.c                     |  11 ++-
 gtk/gtktreeview.c                     |   3 +-
 gtk/gtkwindow.c                       |   3 +-
 gtk/inspector/css-node-tree.c         |   3 +-
 gtk/inspector/prop-editor.c           |   4 +-
 gtk/inspector/recorder.c              |   3 +-
 gtk/ui/gtkcombobox.ui                 |   8 +-
 gtk/ui/gtkplacesview.ui               |   1 -
 tests/gdkgears.c                      |   2 +-
 tests/testdnd2.c                      |   7 +-
 tests/testgaction.c                   |   2 +-
 tests/testiconview.c                  |   3 +-
 tests/testpopover.c                   |   2 +-
 tests/testscrolledwindow.c            |   2 +-
 tests/testtooltips.c                  |   2 +-
 testsuite/a11y/misc.c                 |   4 +-
 testsuite/gtk/builder.c               |   2 +-
 testsuite/gtk/popover.c               |   2 +-
 50 files changed, 143 insertions(+), 289 deletions(-)
---
diff --git a/demos/gtk-demo/application.c b/demos/gtk-demo/application.c
index 783966dfd8..d556e6d3ca 100644
--- a/demos/gtk-demo/application.c
+++ b/demos/gtk-demo/application.c
@@ -428,7 +428,7 @@ demo_application_window_init (DemoApplicationWindow *window)
 
   gtk_widget_init_template (GTK_WIDGET (window));
 
-  popover = gtk_popover_menu_new_from_model (window->menubutton, window->toolmenu);
+  popover = gtk_popover_menu_new_from_model (window->toolmenu);
   gtk_menu_button_set_popover (GTK_MENU_BUTTON (window->menubutton), popover);
 
   g_action_map_add_action_entries (G_ACTION_MAP (window),
diff --git a/demos/gtk-demo/clipboard.c b/demos/gtk-demo/clipboard.c
index 68e9695619..525c81e2c2 100644
--- a/demos/gtk-demo/clipboard.c
+++ b/demos/gtk-demo/clipboard.c
@@ -248,7 +248,8 @@ pressed_cb (GtkGesture *gesture,
   item = g_menu_item_new (_("_Paste"), "clipboard.paste");
   g_menu_append_item (menu, item);
 
-  popover = gtk_popover_menu_new_from_model (image, G_MENU_MODEL (menu));
+  popover = gtk_popover_menu_new_from_model (G_MENU_MODEL (menu));
+  gtk_widget_set_parent (popover, image);
 
   gtk_popover_set_pointing_to (GTK_POPOVER (popover), &(GdkRectangle) { x, y, 1, 1});
   gtk_popover_popup (GTK_POPOVER (popover));
diff --git a/demos/gtk-demo/dnd.c b/demos/gtk-demo/dnd.c
index bf82ccf37a..df7c917bc8 100644
--- a/demos/gtk-demo/dnd.c
+++ b/demos/gtk-demo/dnd.c
@@ -271,7 +271,8 @@ pressed_cb (GtkGesture *gesture,
       pos_x = x;
       pos_y = y;
 
-      menu = gtk_popover_new (widget);
+      menu = gtk_popover_new ();
+      gtk_widget_set_parent (menu, widget);
       gtk_popover_set_has_arrow (GTK_POPOVER (menu), FALSE);
       gtk_popover_set_pointing_to (GTK_POPOVER (menu), &(GdkRectangle){ x, y, 1, 1});
       box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
diff --git a/demos/gtk-demo/fishbowl.c b/demos/gtk-demo/fishbowl.c
index 36e45a77bf..81a78b74b4 100644
--- a/demos/gtk-demo/fishbowl.c
+++ b/demos/gtk-demo/fishbowl.c
@@ -158,7 +158,7 @@ static GtkWidget *
 create_menu_button (void)
 {
   GtkWidget *w = gtk_menu_button_new ();
-  GtkWidget *popover = gtk_popover_new (NULL);
+  GtkWidget *popover = gtk_popover_new ();
 
   gtk_container_add (GTK_CONTAINER (popover), gtk_button_new_with_label ("Hey!"));
   gtk_popover_set_autohide (GTK_POPOVER (popover), FALSE);
diff --git a/demos/gtk-demo/popover.c b/demos/gtk-demo/popover.c
index 2d5c44cf59..d8e04596a7 100644
--- a/demos/gtk-demo/popover.c
+++ b/demos/gtk-demo/popover.c
@@ -22,7 +22,8 @@ create_popover (GtkWidget       *parent,
 {
   GtkWidget *popover;
 
-  popover = gtk_popover_new (parent);
+  popover = gtk_popover_new ();
+  gtk_widget_set_parent (popover, parent);
   gtk_popover_set_position (GTK_POPOVER (popover), pos);
   gtk_container_add (GTK_CONTAINER (popover), child);
   g_object_set (child, "margin", 6, NULL);
diff --git a/demos/gtk-demo/sliding_puzzle.c b/demos/gtk-demo/sliding_puzzle.c
index 95cc9dc073..136c65ccfd 100644
--- a/demos/gtk-demo/sliding_puzzle.c
+++ b/demos/gtk-demo/sliding_puzzle.c
@@ -448,7 +448,7 @@ do_sliding_puzzle (GtkWidget *do_widget)
       gtk_grid_attach (GTK_GRID (tweaks), apply, 1, 2, 1, 1);
       g_signal_connect (apply, "clicked", G_CALLBACK (reconfigure), NULL);
 
-      popover = gtk_popover_new (NULL);
+      popover = gtk_popover_new ();
       gtk_container_add (GTK_CONTAINER (popover), tweaks);
 
       tweak = gtk_menu_button_new ();
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index bbf10e8a5d..2d55e91132 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -1630,9 +1630,10 @@ static void
 set_up_context_popover (GtkWidget *widget,
                         GMenuModel *model)
 {
-  GtkWidget *popover = gtk_popover_menu_new_from_model (widget, model);
+  GtkWidget *popover = gtk_popover_menu_new_from_model (model);
   GtkGesture *gesture;
 
+  gtk_widget_set_parent (popover, widget);
   gtk_popover_set_has_arrow (GTK_POPOVER (popover), FALSE);
   gesture = gtk_gesture_click_new ();
   gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c
index d3ec172f79..02cae025cc 100644
--- a/docs/tools/widgets.c
+++ b/docs/tools/widgets.c
@@ -152,7 +152,7 @@ create_menu_button (void)
   image = gtk_image_new ();
   gtk_image_set_from_icon_name (GTK_IMAGE (image), "emblem-system-symbolic");
   gtk_container_add (GTK_CONTAINER (widget), image);
-  menu = gtk_popover_new (NULL);
+  menu = gtk_popover_new ();
   gtk_menu_button_set_popover (GTK_MENU_BUTTON (widget), menu);
 
   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
@@ -615,7 +615,7 @@ create_file_button (void)
                                        GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
   gtk_widget_set_size_request (picker, 150, -1);
   path = g_build_filename (g_get_home_dir (), "Documents", NULL);
-  gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (picker), path);
+  //gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (picker), path);
   g_free (path);
   gtk_widget_set_halign (picker, GTK_ALIGN_CENTER);
   gtk_widget_set_valign (picker, GTK_ALIGN_CENTER);
diff --git a/gtk/a11y/gtkpopoveraccessible.c b/gtk/a11y/gtkpopoveraccessible.c
index 4b51139c05..6e73a34a47 100644
--- a/gtk/a11y/gtkpopoveraccessible.c
+++ b/gtk/a11y/gtkpopoveraccessible.c
@@ -27,56 +27,11 @@ typedef struct _GtkPopoverAccessiblePrivate GtkPopoverAccessiblePrivate;
 
 struct _GtkPopoverAccessiblePrivate
 {
-  GtkWidget *widget;
 };
 
 G_DEFINE_TYPE_WITH_CODE (GtkPopoverAccessible, gtk_popover_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE,
                          G_ADD_PRIVATE (GtkPopoverAccessible))
 
-static void
-popover_update_relative_to (AtkObject  *obj,
-                            GtkPopover *popover)
-{
-  GtkPopoverAccessiblePrivate *priv;
-  AtkObject *widget_accessible;
-  GtkWidget *widget;
-
-  priv = gtk_popover_accessible_get_instance_private (GTK_POPOVER_ACCESSIBLE (obj));
-  widget = gtk_popover_get_relative_to (popover);
-
-  if (priv->widget == widget)
-    return;
-
-  if (priv->widget)
-    {
-      g_object_remove_weak_pointer (G_OBJECT (priv->widget),
-                                    (gpointer*) &priv->widget);
-      widget_accessible = gtk_widget_get_accessible (priv->widget);
-      atk_object_remove_relationship (obj,
-                                      ATK_RELATION_POPUP_FOR,
-                                      widget_accessible);
-    }
-
-  priv->widget = widget;
-
-  if (widget)
-    {
-      AtkObject *parent;
-
-      parent = gtk_widget_get_accessible (widget);
-
-      if (parent)
-        atk_object_set_parent (obj, parent);
-
-      g_object_add_weak_pointer (G_OBJECT (priv->widget),
-                                 (gpointer*) &priv->widget);
-      widget_accessible = gtk_widget_get_accessible (widget);
-      atk_object_add_relationship (obj,
-                                   ATK_RELATION_POPUP_FOR,
-                                   widget_accessible);
-    }
-}
-
 static void
 popover_update_modality (AtkObject  *object,
                          GtkPopover *popover)
@@ -94,9 +49,7 @@ popover_notify_cb (GtkPopover *popover,
 
   popover_accessible = gtk_widget_get_accessible (GTK_WIDGET (popover));
 
-  if (strcmp (g_param_spec_get_name (pspec), "relative-to") == 0)
-    popover_update_relative_to (popover_accessible, popover);
-  else if (strcmp (g_param_spec_get_name (pspec), "modal") == 0)
+  if (strcmp (g_param_spec_get_name (pspec), "modal") == 0)
     popover_update_modality (popover_accessible, popover);
 }
 
@@ -110,7 +63,6 @@ gtk_popover_accessible_initialize (AtkObject *obj,
 
   g_signal_connect (popover, "notify",
                     G_CALLBACK (popover_notify_cb), obj);
-  popover_update_relative_to (obj, popover);
   popover_update_modality (obj, popover);
 
   obj->role = ATK_ROLE_PANEL;
@@ -131,26 +83,11 @@ gtk_popover_accessible_ref_state_set (AtkObject *obj)
   return state_set;
 }
 
-static void
-gtk_popover_accessible_finalize (GObject *object)
-{
-  GtkPopoverAccessiblePrivate *priv;
-
-  priv = gtk_popover_accessible_get_instance_private (GTK_POPOVER_ACCESSIBLE (object));
-
-  if (priv->widget)
-    g_object_remove_weak_pointer (G_OBJECT (priv->widget),
-                                  (gpointer*) &priv->widget);
-  G_OBJECT_CLASS (gtk_popover_accessible_parent_class)->finalize (object);
-}
-
 static void
 gtk_popover_accessible_class_init (GtkPopoverAccessibleClass *klass)
 {
   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-  object_class->finalize = gtk_popover_accessible_finalize;
   class->initialize = gtk_popover_accessible_initialize;
   class->ref_state_set = gtk_popover_accessible_ref_state_set;
 }
diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c
index bc7a4c9fc8..f073a7ff68 100644
--- a/gtk/gtkcolorswatch.c
+++ b/gtk/gtkcolorswatch.c
@@ -259,7 +259,8 @@ do_popup (GtkColorSwatch *swatch)
   g_clear_pointer (&priv->popover, gtk_widget_unparent);
 
   model = gtk_color_swatch_get_menu_model (swatch);
-  priv->popover = gtk_popover_menu_new_from_model (GTK_WIDGET (swatch), model);
+  priv->popover = gtk_popover_menu_new_from_model (model);
+  gtk_widget_set_parent (priv->popover, GTK_WIDGET (swatch));
   g_object_unref (model);
 
   gtk_popover_popup (GTK_POPOVER (priv->popover));
diff --git a/gtk/gtkemojichooser.c b/gtk/gtkemojichooser.c
index 641cd33438..adc415ebc9 100644
--- a/gtk/gtkemojichooser.c
+++ b/gtk/gtkemojichooser.c
@@ -305,7 +305,8 @@ show_variations (GtkEmojiChooser *chooser,
     return;
 
   parent_popover = gtk_widget_get_ancestor (child, GTK_TYPE_POPOVER);
-  popover = gtk_popover_new (child);
+  popover = gtk_popover_new ();
+  gtk_widget_set_parent (popover, child);
   view = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
   gtk_widget_add_css_class (view, "view");
   box = gtk_flow_box_new ();
diff --git a/gtk/gtkemojicompletion.c b/gtk/gtkemojicompletion.c
index 41e37ff221..073961cd99 100644
--- a/gtk/gtkemojicompletion.c
+++ b/gtk/gtkemojicompletion.c
@@ -653,9 +653,8 @@ gtk_emoji_completion_new (GtkText *text)
 {
   GtkEmojiCompletion *completion;
 
-  completion = GTK_EMOJI_COMPLETION (g_object_new (GTK_TYPE_EMOJI_COMPLETION,
-                                                   "relative-to", text,
-                                                   NULL));
+  completion = GTK_EMOJI_COMPLETION (g_object_new (GTK_TYPE_EMOJI_COMPLETION, NULL));
+  gtk_widget_set_parent (GTK_WIDGET (completion), GTK_WIDGET (text));
 
   connect_signals (completion, text);
 
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index a3c642edc8..57b178ee77 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -582,7 +582,7 @@ gtk_entry_completion_constructed (GObject *object)
                                               NULL);
 
   /* pack it all */
-  priv->popup_window = gtk_popover_new (NULL);
+  priv->popup_window = gtk_popover_new ();
   gtk_popover_set_position (GTK_POPOVER (priv->popup_window), GTK_POS_BOTTOM);
   gtk_popover_set_autohide (GTK_POPOVER (priv->popup_window), FALSE);
   gtk_popover_set_has_arrow (GTK_POPOVER (priv->popup_window), FALSE);
@@ -2438,8 +2438,7 @@ _gtk_entry_completion_disconnect (GtkEntryCompletion *completion)
 
   unset_accessible_relation (completion->priv->popup_window,
                              completion->priv->entry);
-  gtk_popover_set_relative_to (GTK_POPOVER (completion->priv->popup_window),
-                               NULL);
+  gtk_widget_unparent (completion->priv->popup_window);
 
   completion->priv->entry = NULL;
 }
@@ -2452,8 +2451,7 @@ _gtk_entry_completion_connect (GtkEntryCompletion *completion,
 
   set_accessible_relation (completion->priv->popup_window,
                            completion->priv->entry);
-  gtk_popover_set_relative_to (GTK_POPOVER (completion->priv->popup_window),
-                              completion->priv->entry);
+  gtk_widget_set_parent (completion->priv->popup_window, GTK_WIDGET (entry));
 
   connect_completion_signals (completion);
 }
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index d8909fb545..dc6d364c09 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -2066,8 +2066,8 @@ file_list_build_popover (GtkFileChooserWidget *impl)
   g_menu_append_section (menu, NULL, G_MENU_MODEL (section));
   g_object_unref (section);
 
-  priv->browse_files_popover = gtk_popover_menu_new_from_model (priv->browse_files_tree_view,
-                                                                G_MENU_MODEL (menu));
+  priv->browse_files_popover = gtk_popover_menu_new_from_model (G_MENU_MODEL (menu));
+  gtk_widget_set_parent (priv->browse_files_popover, priv->browse_files_tree_view);
   g_object_unref (menu);
 }
 
@@ -3264,9 +3264,7 @@ gtk_file_chooser_widget_dispose (GObject *object)
 
   cancel_all_operations (impl);
 
-  if (priv->rename_file_popover)
-    gtk_popover_set_relative_to (GTK_POPOVER (priv->rename_file_popover), NULL);
-
+  g_clear_pointer (&priv->rename_file_popover, gtk_widget_unparent);
   g_clear_pointer (&priv->browse_files_popover, gtk_widget_destroy);
   g_clear_object (&priv->extra_widget);
   g_clear_pointer (&priv->bookmarks_manager, _gtk_bookmarks_manager_free);
@@ -8007,7 +8005,7 @@ post_process_ui (GtkFileChooserWidget *impl)
 
   gtk_popover_set_default_widget (GTK_POPOVER (priv->new_folder_popover), priv->new_folder_create_button);
   gtk_popover_set_default_widget (GTK_POPOVER (priv->rename_file_popover), priv->rename_file_rename_button);
-  gtk_popover_set_relative_to (GTK_POPOVER (priv->rename_file_popover), priv->browse_files_tree_view);
+  gtk_widget_set_parent (priv->rename_file_popover, priv->browse_files_tree_view);
 
   priv->item_actions = G_ACTION_GROUP (g_simple_action_group_new ());
   g_action_map_add_action_entries (G_ACTION_MAP (priv->item_actions),
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 306b01e2c7..7cd4f4856d 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -6045,7 +6045,8 @@ gtk_label_do_popup (GtkLabel *label,
       GMenuModel *model;
 
       model = gtk_label_get_menu_model (label);
-      priv->popup_menu = gtk_popover_menu_new_from_model (GTK_WIDGET (label), model);
+      priv->popup_menu = gtk_popover_menu_new_from_model (model);
+      gtk_widget_set_parent (priv->popup_menu, GTK_WIDGET (label));
       gtk_popover_set_position (GTK_POPOVER (priv->popup_menu), GTK_POS_BOTTOM);
 
       gtk_popover_set_has_arrow (GTK_POPOVER (priv->popup_menu), FALSE);
diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c
index b3dbda9bb1..d64c3f3a83 100644
--- a/gtk/gtklinkbutton.c
+++ b/gtk/gtklinkbutton.c
@@ -421,7 +421,8 @@ gtk_link_button_do_popup (GtkLinkButton *link_button,
       GMenuModel *model;
 
       model = gtk_link_button_get_menu_model ();
-      priv->popup_menu = gtk_popover_menu_new_from_model (GTK_WIDGET (link_button), model);
+      priv->popup_menu = gtk_popover_menu_new_from_model (model);
+      gtk_widget_set_parent (priv->popup_menu, GTK_WIDGET (link_button));
       gtk_popover_set_position (GTK_POPOVER (priv->popup_menu), GTK_POS_BOTTOM);
 
       gtk_popover_set_has_arrow (GTK_POPOVER (priv->popup_menu), FALSE);
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index 3f6a4da5fd..77f0f5198e 100644
--- a/gtk/gtkmenubutton.c
+++ b/gtk/gtkmenubutton.c
@@ -301,6 +301,7 @@ gtk_menu_button_measure (GtkWidget      *widget,
                       for_size,
                       minimum, natural,
                       minimum_baseline, natural_baseline);
+
 }
 
 static void
@@ -315,7 +316,6 @@ gtk_menu_button_size_allocate (GtkWidget *widget,
   gtk_widget_size_allocate (priv->button,
                             &(GtkAllocation) { 0, 0, width, height },
                             baseline);
-
   if (priv->popover)
     gtk_native_check_resize (GTK_NATIVE (priv->popover));
 }
@@ -552,7 +552,7 @@ gtk_menu_button_set_menu_model (GtkMenuButton *menu_button,
     {
       GtkWidget *popover;
 
-      popover = gtk_popover_menu_new_from_model (GTK_WIDGET (menu_button), menu_model);
+      popover = gtk_popover_menu_new_from_model (menu_model);
       gtk_menu_button_set_popover (menu_button, popover);
     }
   else
@@ -752,7 +752,7 @@ gtk_menu_button_dispose (GObject *object)
       g_signal_handlers_disconnect_by_func (priv->popover,
                                             popover_destroy_cb,
                                             object);
-      gtk_popover_set_relative_to (GTK_POPOVER (priv->popover), NULL);
+      gtk_widget_unparent (priv->popover);
       priv->popover = NULL;
     }
 
@@ -803,14 +803,14 @@ gtk_menu_button_set_popover (GtkMenuButton *menu_button,
                                             popover_destroy_cb,
                                             menu_button);
 
-      gtk_popover_set_relative_to (GTK_POPOVER (priv->popover), NULL);
+      gtk_widget_unparent (priv->popover);
     }
 
   priv->popover = popover;
 
   if (popover)
     {
-      gtk_popover_set_relative_to (GTK_POPOVER (priv->popover), GTK_WIDGET (menu_button));
+      gtk_widget_set_parent (priv->popover, GTK_WIDGET (menu_button));
       g_signal_connect_swapped (priv->popover, "closed",
                                 G_CALLBACK (menu_deactivate_cb), menu_button);
       g_signal_connect_swapped (priv->popover, "destroy",
diff --git a/gtk/gtkmenusectionbox.c b/gtk/gtkmenusectionbox.c
index 107355eb24..9aec305ec6 100644
--- a/gtk/gtkmenusectionbox.c
+++ b/gtk/gtkmenusectionbox.c
@@ -303,7 +303,7 @@ gtk_menu_section_box_insert_func (GtkMenuTrackerItem *item,
 
           model = _gtk_menu_tracker_item_get_link (item, G_MENU_LINK_SUBMENU);
 
-          submenu = gtk_popover_menu_new_from_model_full (NULL, model, box->flags);
+          submenu = gtk_popover_menu_new_from_model_full (model, box->flags);
           gtk_popover_set_has_arrow (GTK_POPOVER (submenu), FALSE);
           gtk_widget_set_valign (submenu, GTK_ALIGN_START);
 
diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c
index 2f5d3aba9e..585fa3e46c 100644
--- a/gtk/gtkmodelbutton.c
+++ b/gtk/gtkmodelbutton.c
@@ -699,13 +699,13 @@ gtk_model_button_set_popover (GtkModelButton *button,
                               GtkWidget      *popover)
 {
   if (button->popover)
-    gtk_popover_set_relative_to (GTK_POPOVER (button->popover), NULL);
+    gtk_widget_unparent (button->popover);
 
   button->popover = popover;
 
   if (button->popover)
     {
-      gtk_popover_set_relative_to (GTK_POPOVER (button->popover), GTK_WIDGET (button));
+      gtk_widget_set_parent (button->popover, GTK_WIDGET (button));
       gtk_popover_set_position (GTK_POPOVER (button->popover), GTK_POS_RIGHT);
     }
 
diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c
index a9feb8dde5..51d926c401 100644
--- a/gtk/gtkmountoperation.c
+++ b/gtk/gtkmountoperation.c
@@ -1413,7 +1413,8 @@ do_popup_menu_for_process_tree_view (GtkWidget         *widget,
   GtkWidget *item;
   double x, y;
 
-  menu = gtk_popover_new (widget);
+  menu = gtk_popover_new ();
+  gtk_widget_set_parent (menu, widget);
   gtk_style_context_add_class (gtk_widget_get_style_context (menu),
                                GTK_STYLE_CLASS_CONTEXT_MENU);
 
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 4d89d6766e..a1d28ec698 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -6531,7 +6531,8 @@ gtk_notebook_popup_enable (GtkNotebook *notebook)
   if (priv->menu)
     return;
 
-  priv->menu = gtk_popover_menu_new (priv->tabs_widget);
+  priv->menu = gtk_popover_menu_new ();
+  gtk_widget_set_parent (priv->menu, priv->tabs_widget);
 
   priv->menu_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
   gtk_popover_menu_add_submenu (GTK_POPOVER_MENU (priv->menu), priv->menu_box, "main");
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 86b6e06a50..1e50e8cc02 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -2558,7 +2558,8 @@ create_rename_popover (GtkPlacesSidebar *sidebar)
   if (sidebar->rename_popover)
     return;
 
-  popover = gtk_popover_new (GTK_WIDGET (sidebar));
+  popover = gtk_popover_new ();
+  gtk_widget_set_parent (popover, GTK_WIDGET (sidebar));
   /* Clean sidebar pointer when its destroyed, most of the times due to its
    * relative_to associated row being destroyed */
   g_signal_connect (popover, "destroy", G_CALLBACK (on_rename_popover_destroy), sidebar);
@@ -2625,13 +2626,13 @@ update_popover_shadowing (GtkWidget *row,
 static void
 set_prelight (GtkPopover *popover)
 {
-  update_popover_shadowing (gtk_popover_get_relative_to (popover), TRUE);
+  update_popover_shadowing (gtk_widget_get_parent (GTK_WIDGET (popover)), TRUE);
 }
 
 static void
 unset_prelight (GtkPopover *popover)
 {
-  update_popover_shadowing (gtk_popover_get_relative_to (popover), FALSE);
+  update_popover_shadowing (gtk_widget_get_parent (GTK_WIDGET (popover)), FALSE);
 }
 
 static void
@@ -2661,7 +2662,7 @@ show_rename_popover (GtkSidebarRow *row)
   sidebar->rename_uri = g_strdup (uri);
 
   gtk_editable_set_text (GTK_EDITABLE (sidebar->rename_entry), name);
-  gtk_popover_set_relative_to (GTK_POPOVER (sidebar->rename_popover), GTK_WIDGET (row));
+  gtk_widget_set_parent (sidebar->rename_popover, GTK_WIDGET (row));
   setup_popover_shadowing (sidebar->rename_popover);
 
   gtk_popover_popup (GTK_POPOVER (sidebar->rename_popover));
@@ -3513,7 +3514,8 @@ create_row_popover (GtkPlacesSidebar *sidebar,
     }
 #endif
 
-  sidebar->popover = gtk_popover_new (GTK_WIDGET (sidebar));
+  sidebar->popover = gtk_popover_new ();
+  gtk_widget_set_parent (sidebar->popover, GTK_WIDGET (sidebar));
   /* Clean sidebar pointer when its destroyed, most of the times due to its
    * relative_to associated row being destroyed */
   g_signal_connect (sidebar->popover, "destroy", G_CALLBACK (on_row_popover_destroy), sidebar);
@@ -3561,7 +3563,7 @@ show_row_popover (GtkSidebarRow *row)
 
   create_row_popover (sidebar, row);
 
-  gtk_popover_set_relative_to (GTK_POPOVER (sidebar->popover), GTK_WIDGET (row));
+  gtk_widget_set_parent (sidebar->popover, GTK_WIDGET (row));
 
   sidebar->context_row = row;
   gtk_popover_popup (GTK_POPOVER (sidebar->popover));
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
index 8a54c1b3f3..a20e0642c1 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -1729,7 +1729,8 @@ popup_menu (GtkPlacesViewRow *row,
     {
       GMenuModel *model = get_menu_model ();
 
-      priv->popup_menu = gtk_popover_menu_new_from_model (GTK_WIDGET (view), model);
+      priv->popup_menu = gtk_popover_menu_new_from_model (model);
+      gtk_widget_set_parent (priv->popup_menu, GTK_WIDGET (view));
       gtk_popover_set_position (GTK_POPOVER (priv->popup_menu), GTK_POS_BOTTOM);
 
       gtk_popover_set_has_arrow (GTK_POPOVER (priv->popup_menu), FALSE);
@@ -1739,7 +1740,7 @@ popup_menu (GtkPlacesViewRow *row,
     }
 
   gtk_widget_set_halign (priv->popup_menu, GTK_ALIGN_CENTER);
-  gtk_popover_set_relative_to (GTK_POPOVER (priv->popup_menu), GTK_WIDGET (row));
+  gtk_widget_set_parent (priv->popup_menu, GTK_WIDGET (row));
 
   priv->row_for_action = row;
   gtk_popover_popup (GTK_POPOVER (priv->popup_menu));
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 286388bb2d..3a539757df 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -25,8 +25,7 @@
  *
  * GtkPopover is a bubble-like context window, primarily meant to
  * provide context-dependent information or options. Popovers are
- * attached to a widget, passed at construction time on gtk_popover_new(),
- * or updated afterwards through gtk_popover_set_relative_to(), by
+ * attached to a widget, set with gtk_widget_set_parent(). By
  * default they will point to the whole widget area, although this
  * behavior can be changed through gtk_popover_set_pointing_to().
  *
@@ -143,7 +142,6 @@ typedef struct {
   GtkWidget *default_widget;
 
   GdkSurfaceState state;
-  GtkWidget *relative_to;
   GdkRectangle pointing_to;
   gboolean has_pointing_to;
   guint surface_transform_changed_cb;
@@ -169,8 +167,7 @@ enum {
 static guint signals[LAST_SIGNAL] = { 0 };
 
 enum {
-  PROP_RELATIVE_TO = 1,
-  PROP_POINTING_TO,
+  PROP_POINTING_TO = 1,
   PROP_POSITION,
   PROP_AUTOHIDE,
   PROP_DEFAULT_WIDGET,
@@ -416,8 +413,10 @@ create_popup_layout (GtkPopover *popover)
   GdkGravity surface_anchor;
   GdkAnchorHints anchor_hints;
   GdkPopupLayout *layout;
+  GtkWidget *parent;
 
-  gtk_widget_get_surface_allocation (priv->relative_to, &rect);
+  parent = gtk_widget_get_parent (GTK_WIDGET (popover));
+  gtk_widget_get_surface_allocation (parent, &rect);
   if (priv->has_pointing_to)
     {
       rect.x += priv->pointing_to.x;
@@ -653,7 +652,7 @@ gtk_popover_activate_default (GtkPopover *popover)
   GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
   GtkWidget *focus_widget;
 
-  focus_widget = gtk_window_get_focus (GTK_WINDOW (gtk_widget_get_root (priv->relative_to)));
+  focus_widget = gtk_window_get_focus (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (popover))));
   if (!gtk_widget_is_ancestor (focus_widget, GTK_WIDGET (popover)))
     focus_widget = NULL;
 
@@ -744,10 +743,12 @@ gtk_popover_realize (GtkWidget *widget)
 {
   GtkPopover *popover = GTK_POPOVER (widget);
   GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
-  GdkSurface *parent;
+  GdkSurface *parent_surface;
+  GtkWidget *parent;
 
-  parent = gtk_native_get_surface (gtk_widget_get_native (priv->relative_to));
-  priv->surface = gdk_surface_new_popup (parent, priv->autohide);
+  parent = gtk_widget_get_parent (widget);
+  parent_surface = gtk_native_get_surface (gtk_widget_get_native (parent));
+  priv->surface = gdk_surface_new_popup (parent_surface, priv->autohide);
 
   gdk_surface_set_widget (priv->surface, widget);
 
@@ -838,11 +839,13 @@ gtk_popover_map (GtkWidget *widget)
   GtkPopover *popover = GTK_POPOVER (widget);
   GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
   GtkWidget *child;
+  GtkWidget *parent;
 
   present_popup (popover);
 
+  parent = gtk_widget_get_parent (widget);
   priv->surface_transform_changed_cb =
-    gtk_widget_add_surface_transform_changed_callback (priv->relative_to,
+    gtk_widget_add_surface_transform_changed_callback (parent,
                                                        surface_transform_changed_cb,
                                                        popover,
                                                        unset_surface_transform_changed_cb);
@@ -860,8 +863,10 @@ gtk_popover_unmap (GtkWidget *widget)
   GtkPopover *popover = GTK_POPOVER (widget);
   GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
   GtkWidget *child;
+  GtkWidget *parent;
 
-  gtk_widget_remove_surface_transform_changed_callback (priv->relative_to,
+  parent = gtk_widget_get_parent (widget);
+  gtk_widget_remove_surface_transform_changed_callback (parent,
                                                         priv->surface_transform_changed_cb);
   priv->surface_transform_changed_cb = 0;
 
@@ -926,11 +931,13 @@ gtk_popover_get_gap_coords (GtkPopover *popover,
   int border_radius;
   int popover_width, popover_height;
   GtkCssStyle *style;
+  GtkWidget *parent;
 
   popover_width = gtk_widget_get_allocated_width (widget);
   popover_height = gtk_widget_get_allocated_height (widget);
+  parent = gtk_widget_get_parent (widget);
 
-  gtk_widget_get_surface_allocation (priv->relative_to, &rect);
+  gtk_widget_get_surface_allocation (parent, &rect);
   if (priv->has_pointing_to)
     {
       rect.x += priv->pointing_to.x;
@@ -1097,8 +1104,11 @@ gtk_popover_apply_tail_path (GtkPopover *popover,
   gint tip_x, tip_y;
   gint final_x, final_y;
   GtkBorder border;
+  GtkWidget *parent;
 
-  if (!priv->relative_to)
+  parent = gtk_widget_get_parent (GTK_WIDGET (popover));
+
+  if (!parent)
     return;
 
   get_border (priv->arrow_node, &border);
@@ -1364,10 +1374,6 @@ gtk_popover_set_property (GObject      *object,
 
   switch (prop_id)
     {
-    case PROP_RELATIVE_TO:
-      gtk_popover_set_relative_to (popover, g_value_get_object (value));
-      break;
-
     case PROP_POINTING_TO:
       gtk_popover_set_pointing_to (popover, g_value_get_boxed (value));
       break;
@@ -1405,10 +1411,6 @@ gtk_popover_get_property (GObject      *object,
 
   switch (prop_id)
     {
-    case PROP_RELATIVE_TO:
-      g_value_set_object (value, priv->relative_to);
-      break;
-
     case PROP_POINTING_TO:
       g_value_set_boxed (value, &priv->pointing_to);
       break;
@@ -1483,13 +1485,6 @@ gtk_popover_class_init (GtkPopoverClass *klass)
 
   klass->activate_default = gtk_popover_activate_default;
 
-  properties[PROP_RELATIVE_TO] =
-      g_param_spec_object ("relative-to",
-                           P_("Relative to"),
-                           P_("Widget the bubble window points to"),
-                           GTK_TYPE_WIDGET,
-                           GTK_PARAM_READWRITE);
-
   properties[PROP_POINTING_TO] =
       g_param_spec_boxed ("pointing-to",
                           P_("Pointing to"),
@@ -1551,24 +1546,9 @@ gtk_popover_class_init (GtkPopoverClass *klass)
 }
 
 GtkWidget *
-gtk_popover_new (GtkWidget *relative_to)
+gtk_popover_new (void)
 {
-  return GTK_WIDGET (g_object_new (GTK_TYPE_POPOVER,
-                                   "relative-to", relative_to,
-                                   NULL));
-}
-
-static void
-relative_to_size_changed (GtkWidget  *widget,
-                          int         width,
-                          int         height,
-                          int         baseline,
-                          GtkPopover *popover)
-{
-  GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
-
-  if (priv->surface && gdk_surface_is_visible (priv->surface))
-    present_popup (popover);
+  return g_object_new (GTK_TYPE_POPOVER, NULL);
 }
 
 void
@@ -1610,79 +1590,13 @@ gtk_popover_native_interface_init (GtkNativeInterface *iface)
   iface->check_resize = gtk_popover_native_check_resize;
 }
 
-/**
- * gtk_popover_set_relative_to:
- * @popover: a #GtkPopover
- * @relative_to: (allow-none): a #GtkWidget
- *
- * Sets a new widget to be attached to @popover. If @popover is
- * visible, the position will be updated.
- *
- * Note: the ownership of popovers is always given to their @relative_to
- * widget, so if @relative_to is set to %NULL on an attached @popover, it
- * will be detached from its previous widget, and consequently destroyed
- * unless extra references are kept.
- **/
-void
-gtk_popover_set_relative_to (GtkPopover *popover,
-                             GtkWidget  *relative_to)
-{
-  GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
-  
-  g_return_if_fail (GTK_IS_POPOVER (popover));
-
-  g_object_ref (popover);
-
-  if (priv->relative_to)
-    {
-      g_signal_handlers_disconnect_by_func (priv->relative_to,
-                                            relative_to_size_changed,
-                                            popover);
-      gtk_widget_unparent (GTK_WIDGET (popover));
-    }
-
-  priv->relative_to = relative_to;
-
-  if (priv->relative_to)
-    {
-      g_signal_connect_object (priv->relative_to, "size-allocate",
-                               G_CALLBACK (relative_to_size_changed), popover, 0);
-      gtk_css_node_set_parent (gtk_widget_get_css_node (GTK_WIDGET (popover)),
-                               gtk_widget_get_css_node (relative_to));
-      gtk_widget_set_parent (GTK_WIDGET (popover), relative_to);
-    }
-
-  g_object_notify_by_pspec (G_OBJECT (popover), properties[PROP_RELATIVE_TO]);
-
-  g_object_unref (popover);
-}
-
-/**
- * gtk_popover_get_relative_to:
- * @popover: a #GtkPopover
- *
- * Returns the widget @popover is currently attached to
- *
- * Returns: (transfer none): a #GtkWidget
- **/
-GtkWidget *
-gtk_popover_get_relative_to (GtkPopover *popover)
-{
-  GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
-
-  g_return_val_if_fail (GTK_IS_POPOVER (popover), NULL);
-
-  return priv->relative_to;
-}
-
 /**
  * gtk_popover_set_pointing_to:
  * @popover: a #GtkPopover
  * @rect: rectangle to point to
  *
  * Sets the rectangle that @popover will point to, in the
- * coordinate space of the widget @popover is attached to,
- * see gtk_popover_set_relative_to().
+ * coordinate space of the @popover parent.
  **/
 void
 gtk_popover_set_pointing_to (GtkPopover         *popover,
@@ -1726,11 +1640,12 @@ gtk_popover_get_pointing_to (GtkPopover   *popover,
 
   if (priv->has_pointing_to)
     *rect = priv->pointing_to;
-  else if (priv->relative_to)
+  else
     {
       graphene_rect_t r;
+      GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (popover));
 
-      if (!gtk_widget_compute_bounds (priv->relative_to, priv->relative_to, &r))
+      if (!gtk_widget_compute_bounds (parent, parent, &r))
         return FALSE;
 
       rect->x = floorf (r.origin.x);
diff --git a/gtk/gtkpopover.h b/gtk/gtkpopover.h
index 41b5956c9e..c89d2a1aca 100644
--- a/gtk/gtkpopover.h
+++ b/gtk/gtkpopover.h
@@ -60,13 +60,7 @@ GDK_AVAILABLE_IN_ALL
 GType           gtk_popover_get_type (void) G_GNUC_CONST;
 
 GDK_AVAILABLE_IN_ALL
-GtkWidget *     gtk_popover_new             (GtkWidget    *relative_to);
-
-GDK_AVAILABLE_IN_ALL
-void            gtk_popover_set_relative_to (GtkPopover   *popover,
-                                             GtkWidget    *relative_to);
-GDK_AVAILABLE_IN_ALL
-GtkWidget *     gtk_popover_get_relative_to (GtkPopover   *popover);
+GtkWidget *     gtk_popover_new             (void);
 
 GDK_AVAILABLE_IN_ALL
 void            gtk_popover_set_pointing_to (GtkPopover         *popover,
diff --git a/gtk/gtkpopovermenu.c b/gtk/gtkpopovermenu.c
index 2f73218d88..584a5c5f14 100644
--- a/gtk/gtkpopovermenu.c
+++ b/gtk/gtkpopovermenu.c
@@ -461,21 +461,17 @@ gtk_popover_menu_class_init (GtkPopoverMenuClass *klass)
 
 /**
  * gtk_popover_menu_new:
- * @relative_to: (allow-none): #GtkWidget the popover is related to
  *
  * Creates a new popover menu.
  *
  * Returns: a new #GtkPopoverMenu
  */
 GtkWidget *
-gtk_popover_menu_new (GtkWidget *relative_to)
+gtk_popover_menu_new (void)
 {
   GtkWidget *popover;
 
-  g_return_val_if_fail (relative_to == NULL || GTK_IS_WIDGET (relative_to), NULL);
-
   popover = g_object_new (GTK_TYPE_POPOVER_MENU,
-                          "relative-to", relative_to,
                           "autohide", TRUE,
                           NULL);
 
@@ -522,11 +518,10 @@ gtk_popover_menu_add_submenu (GtkPopoverMenu *popover,
 
 /**
  * gtk_popover_menu_new_from_model:
- * @relative_to: (allow-none): #GtkWidget the popover is related to
  * @model: (allow-none): a #GMenuModel, or %NULL
  *
  * Creates a #GtkPopoverMenu and populates it according to
- * @model. The popover is pointed to the @relative_to widget.
+ * @model.
  *
  * The created buttons are connected to actions found in the
  * #GtkApplicationWindow to which the popover belongs - typically
@@ -543,27 +538,25 @@ gtk_popover_menu_add_submenu (GtkPopoverMenu *popover,
  * Returns: the new #GtkPopoverMenu
  */
 GtkWidget *
-gtk_popover_menu_new_from_model (GtkWidget  *relative_to,
-                                 GMenuModel *model)
+gtk_popover_menu_new_from_model (GMenuModel *model)
 
 {
-  return gtk_popover_menu_new_from_model_full (relative_to, model, 0);
+  return gtk_popover_menu_new_from_model_full (model, 0);
 }
 
 /**
  * gtk_popover_menu_new_from_model_full:
- * @relative_to: (allow-none): #GtkWidget the popover is related to
  * @model: a #GMenuModel
  * @flags: flags that affect how the menu is created
  *
  * Creates a #GtkPopoverMenu and populates it according to
- * @model. The popover is pointed to the @relative_to widget.
+ * @model.
  *
  * The created buttons are connected to actions found in the
- * action groups that are accessible from the @relative-to widget.
+ * action groups that are accessible from the parent widget.
  * This includes the #GtkApplicationWindow to which the popover
  * belongs. Actions can also be added using gtk_widget_insert_action_group()
- * on the @relative-to widget or on any of its parent widgets.
+ * on the parent widget or on any of its parent widgets.
  *
  * The only flag that is supported currently is
  * #GTK_POPOVER_MENU_NESTED, which makes GTK create traditional,
@@ -572,16 +565,14 @@ gtk_popover_menu_new_from_model (GtkWidget  *relative_to,
  * Returns: (transfer full): the new #GtkPopoverMenu
  */
 GtkWidget *
-gtk_popover_menu_new_from_model_full (GtkWidget           *relative_to,
-                                      GMenuModel          *model,
+gtk_popover_menu_new_from_model_full (GMenuModel          *model,
                                       GtkPopoverMenuFlags  flags)
 {
   GtkWidget *popover;
 
-  g_return_val_if_fail (relative_to == NULL || GTK_IS_WIDGET (relative_to), NULL);
   g_return_val_if_fail (model == NULL || G_IS_MENU_MODEL (model), NULL);
 
-  popover = gtk_popover_menu_new (relative_to);
+  popover = gtk_popover_menu_new ();
   GTK_POPOVER_MENU (popover)->flags = flags;
   gtk_popover_menu_set_menu_model (GTK_POPOVER_MENU (popover), model);
 
diff --git a/gtk/gtkpopovermenu.h b/gtk/gtkpopovermenu.h
index af393143a2..f9f8457b27 100644
--- a/gtk/gtkpopovermenu.h
+++ b/gtk/gtkpopovermenu.h
@@ -36,8 +36,7 @@ GDK_AVAILABLE_IN_ALL
 GType       gtk_popover_menu_get_type (void) G_GNUC_CONST;
 
 GDK_AVAILABLE_IN_ALL
-GtkWidget * gtk_popover_menu_new_from_model (GtkWidget  *relative_to,
-                                             GMenuModel *model);
+GtkWidget * gtk_popover_menu_new_from_model (GMenuModel *model);
 
 /**
  * GtkPopoverMenuFlags:
@@ -53,8 +52,7 @@ typedef enum {
 } GtkPopoverMenuFlags;
 
 GDK_AVAILABLE_IN_ALL
-GtkWidget * gtk_popover_menu_new_from_model_full (GtkWidget           *relative_to,
-                                                  GMenuModel          *model,
+GtkWidget * gtk_popover_menu_new_from_model_full (GMenuModel          *model,
                                                   GtkPopoverMenuFlags  flags);
 
 GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtkpopovermenubar.c b/gtk/gtkpopovermenubar.c
index 411d4c0358..98245f6c4c 100644
--- a/gtk/gtkpopovermenubar.c
+++ b/gtk/gtkpopovermenubar.c
@@ -405,7 +405,8 @@ tracker_insert (GtkMenuTrackerItem *item,
                               G_BINDING_SYNC_CREATE);
 
       model = _gtk_menu_tracker_item_get_link (item, G_MENU_LINK_SUBMENU);
-      popover = GTK_POPOVER (gtk_popover_menu_new_from_model_full (GTK_WIDGET (widget), model, 
GTK_POPOVER_MENU_NESTED));
+      popover = GTK_POPOVER (gtk_popover_menu_new_from_model_full (model, GTK_POPOVER_MENU_NESTED));
+      gtk_widget_set_parent (popover, GTK_WIDGET (widget));
       gtk_popover_set_position (popover, GTK_POS_BOTTOM);
       gtk_popover_set_has_arrow (popover, FALSE);
       gtk_widget_set_halign (GTK_WIDGET (popover), GTK_ALIGN_START);
diff --git a/gtk/gtkpopovermenuprivate.h b/gtk/gtkpopovermenuprivate.h
index b0062cf560..215fa1ea99 100644
--- a/gtk/gtkpopovermenuprivate.h
+++ b/gtk/gtkpopovermenuprivate.h
@@ -32,7 +32,7 @@ GtkWidget *gtk_popover_menu_get_parent_menu  (GtkPopoverMenu *menu);
 void       gtk_popover_menu_set_parent_menu  (GtkPopoverMenu *menu,
                                               GtkWidget      *parent);
 
-GtkWidget * gtk_popover_menu_new (GtkWidget  *relative_to);
+GtkWidget * gtk_popover_menu_new (void);
 
 void  gtk_popover_menu_add_submenu (GtkPopoverMenu *popover,
                                     GtkWidget      *submenu,
diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c
index 740ca3efb0..3b41e6a64c 100644
--- a/gtk/gtkscalebutton.c
+++ b/gtk/gtkscalebutton.c
@@ -376,7 +376,7 @@ gtk_scale_button_init (GtkScaleButton *button)
   priv->applied_orientation = GTK_ORIENTATION_VERTICAL;
 
   gtk_widget_init_template (GTK_WIDGET (button));
-  gtk_popover_set_relative_to (GTK_POPOVER (priv->dock), GTK_WIDGET (button));
+  gtk_widget_set_parent (priv->dock, GTK_WIDGET (button));
 
   /* Need a local reference to the adjustment */
   priv->adjustment = gtk_adjustment_new (0, 0, 100, 2, 20, 0);
diff --git a/gtk/gtkshortcutswindow.c b/gtk/gtkshortcutswindow.c
index 14cb212e1c..7f575032e0 100644
--- a/gtk/gtkshortcutswindow.c
+++ b/gtk/gtkshortcutswindow.c
@@ -932,7 +932,6 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self)
   gtk_stack_add_named (priv->title_stack, GTK_WIDGET (priv->menu_button), "sections");
 
   priv->popover = g_object_new (GTK_TYPE_POPOVER,
-                                "relative-to", priv->menu_button,
                                 "position", GTK_POS_BOTTOM,
                                 NULL);
   gtk_menu_button_set_popover (priv->menu_button, GTK_WIDGET (priv->popover));
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 119e2d8386..74d11dae9b 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -1898,7 +1898,8 @@ gtk_text_ensure_magnifier (GtkText *self)
   priv->magnifier = _gtk_magnifier_new (GTK_WIDGET (self));
   gtk_widget_set_size_request (priv->magnifier, 100, 60);
   _gtk_magnifier_set_magnification (GTK_MAGNIFIER (priv->magnifier), 2.0);
-  priv->magnifier_popover = gtk_popover_new (GTK_WIDGET (self));
+  priv->magnifier_popover = gtk_popover_new ();
+  gtk_widget_set_parent (priv->magnifier_popover, GTK_WIDGET (self));
   gtk_widget_add_css_class (priv->magnifier_popover, "magnifier");
   gtk_popover_set_autohide (GTK_POPOVER (priv->magnifier_popover), FALSE);
   gtk_container_add (GTK_CONTAINER (priv->magnifier_popover),
@@ -2527,7 +2528,8 @@ gtk_text_do_popup (GtkText *self,
       GMenuModel *model;
 
       model = gtk_text_get_menu_model (self);
-      priv->popup_menu = gtk_popover_menu_new_from_model (GTK_WIDGET (self), model);
+      priv->popup_menu = gtk_popover_menu_new_from_model (model);
+      gtk_widget_set_parent (priv->popup_menu, GTK_WIDGET (self));
       gtk_popover_set_position (GTK_POPOVER (priv->popup_menu), GTK_POS_BOTTOM);
 
       gtk_popover_set_has_arrow (GTK_POPOVER (priv->popup_menu), FALSE);
@@ -6026,7 +6028,8 @@ gtk_text_selection_bubble_popup_show (gpointer user_data)
 
   g_clear_pointer (&priv->selection_bubble, gtk_widget_unparent);
 
-  priv->selection_bubble = gtk_popover_new (GTK_WIDGET (self));
+  priv->selection_bubble = gtk_popover_new ();
+  gtk_widget_set_parent (priv->selection_bubble, GTK_WIDGET (self));
   gtk_widget_add_css_class (priv->selection_bubble, GTK_STYLE_CLASS_TOUCH_SELECTION);
   gtk_popover_set_position (GTK_POPOVER (priv->selection_bubble), GTK_POS_BOTTOM);
   gtk_popover_set_autohide (GTK_POPOVER (priv->selection_bubble), FALSE);
@@ -6788,7 +6791,7 @@ gtk_text_insert_emoji (GtkText *self)
       chooser = gtk_emoji_chooser_new ();
       g_object_set_data (G_OBJECT (self), "gtk-emoji-chooser", chooser);
 
-      gtk_popover_set_relative_to (GTK_POPOVER (chooser), GTK_WIDGET (self));
+      gtk_widget_set_parent (chooser, GTK_WIDGET (self));
       g_signal_connect (chooser, "emoji-picked", G_CALLBACK (emoji_picked), self);
     }
 
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 8f48e05b64..a2ae4cdd2e 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -1756,7 +1756,8 @@ _gtk_text_view_ensure_magnifier (GtkTextView *text_view)
 
   priv->magnifier = _gtk_magnifier_new (GTK_WIDGET (text_view));
   _gtk_magnifier_set_magnification (GTK_MAGNIFIER (priv->magnifier), 2.0);
-  priv->magnifier_popover = gtk_popover_new (GTK_WIDGET (text_view));
+  priv->magnifier_popover = gtk_popover_new ();
+  gtk_widget_set_parent (priv->magnifier_popover, GTK_WIDGET (text_view));
   gtk_widget_add_css_class (priv->magnifier_popover, "magnifier");
   gtk_popover_set_autohide (GTK_POPOVER (priv->magnifier_popover), FALSE);
   gtk_container_add (GTK_CONTAINER (priv->magnifier_popover),
@@ -8633,7 +8634,8 @@ gtk_text_view_do_popup (GtkTextView    *text_view,
       GMenuModel *model;
 
       model = gtk_text_view_get_menu_model (text_view);
-      priv->popup_menu = gtk_popover_menu_new_from_model (GTK_WIDGET (text_view), model);
+      priv->popup_menu = gtk_popover_menu_new_from_model (model);
+      gtk_widget_set_parent (priv->popup_menu, GTK_WIDGET (text_view));
       gtk_popover_set_position (GTK_POPOVER (priv->popup_menu), GTK_POS_BOTTOM);
 
       gtk_popover_set_has_arrow (GTK_POPOVER (priv->popup_menu), FALSE);
@@ -8847,7 +8849,8 @@ gtk_text_view_selection_bubble_popup_show (gpointer user_data)
 
   g_clear_pointer (&priv->selection_bubble, gtk_widget_unparent);
 
-  priv->selection_bubble = gtk_popover_new (GTK_WIDGET (text_view));
+  priv->selection_bubble = gtk_popover_new ();
+  gtk_widget_set_parent (priv->selection_bubble, GTK_WIDGET (text_view));
   gtk_widget_add_css_class (priv->selection_bubble, GTK_STYLE_CLASS_TOUCH_SELECTION);
   gtk_popover_set_position (GTK_POPOVER (priv->selection_bubble), GTK_POS_BOTTOM);
   gtk_popover_set_autohide (GTK_POPOVER (priv->selection_bubble), FALSE);
@@ -9646,7 +9649,7 @@ gtk_text_view_insert_emoji (GtkTextView *text_view)
       chooser = gtk_emoji_chooser_new ();
       g_object_set_data (G_OBJECT (text_view), "gtk-emoji-chooser", chooser);
 
-      gtk_popover_set_relative_to (GTK_POPOVER (chooser), GTK_WIDGET (text_view));
+      gtk_widget_set_parent (chooser, GTK_WIDGET (text_view));
       g_signal_connect_swapped (chooser, "emoji-picked",
                                 G_CALLBACK (gtk_text_view_insert_at_cursor), text_view);
     }
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 9790d91bcd..8c41725d75 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -10053,7 +10053,8 @@ gtk_tree_view_ensure_interactive_directory (GtkTreeView *tree_view)
   if (tree_view->search_popover)
     return;
 
-  tree_view->search_popover = gtk_popover_new (GTK_WIDGET (tree_view));
+  tree_view->search_popover = gtk_popover_new ();
+  gtk_widget_set_parent (tree_view->search_popover, GTK_WIDGET (tree_view));
   gtk_popover_set_autohide (GTK_POPOVER (tree_view->search_popover), FALSE);
 
   controller = gtk_event_controller_key_new ();
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index c62fa14567..0aa7583ffe 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -6750,7 +6750,8 @@ gtk_window_do_popup_fallback (GtkWindow      *window,
   minimized = (state & GDK_SURFACE_STATE_MINIMIZED) == GDK_SURFACE_STATE_MINIMIZED;
   maximized = priv->maximized && !minimized;
 
-  priv->popup_menu = gtk_popover_menu_new (priv->title_box);
+  priv->popup_menu = gtk_popover_menu_new ();
+  gtk_widget_set_parent (priv->popup_menu, priv->title_box);
 
   box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
   gtk_popover_menu_add_submenu (GTK_POPOVER_MENU (priv->popup_menu), box, "main");
diff --git a/gtk/inspector/css-node-tree.c b/gtk/inspector/css-node-tree.c
index c465f7a5a9..52e94a52c7 100644
--- a/gtk/inspector/css-node-tree.c
+++ b/gtk/inspector/css-node-tree.c
@@ -102,7 +102,8 @@ show_node_prop_editor (NodePropEditor *npe)
   GtkWidget *popover;
   GtkWidget *editor;
 
-  popover = gtk_popover_new (GTK_WIDGET (npe->cnt->priv->node_tree));
+  popover = gtk_popover_new ();
+  gtk_widget_set_parent (popover, GTK_WIDGET (npe->cnt->priv->node_tree));
   gtk_popover_set_pointing_to (GTK_POPOVER (popover), &npe->rect);
 
   editor = gtk_inspector_prop_editor_new (G_OBJECT (npe->node), npe->prop_name, NULL);
diff --git a/gtk/inspector/prop-editor.c b/gtk/inspector/prop-editor.c
index 72dc14c2a8..1a88b38dbe 100644
--- a/gtk/inspector/prop-editor.c
+++ b/gtk/inspector/prop-editor.c
@@ -943,7 +943,7 @@ property_editor (GObject                *object,
         GFlagsClass *fclass;
         gint j;
 
-        popover = gtk_popover_new (NULL);        
+        popover = gtk_popover_new ();        
         prop_edit = gtk_menu_button_new ();
         gtk_menu_button_set_popover (GTK_MENU_BUTTON (prop_edit), popover);
 
@@ -1010,7 +1010,7 @@ property_editor (GObject                *object,
       GtkWidget *sw; 
       GListModel *model;
 
-      popover = gtk_popover_new (NULL);        
+      popover = gtk_popover_new ();        
       prop_edit = gtk_menu_button_new ();
       gtk_menu_button_set_popover (GTK_MENU_BUTTON (prop_edit), popover);
 
diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c
index ac8e8d2380..eade68bcca 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -1163,7 +1163,8 @@ node_property_activated (GtkTreeView *tv,
   if (texture == NULL || visible)
     return;
 
-  popover = gtk_popover_new (GTK_WIDGET (tv));
+  popover = gtk_popover_new ();
+  gtk_widget_set_parent (popover, GTK_WIDGET (tv));
   gtk_popover_set_pointing_to (GTK_POPOVER (popover), &rect);
 
   image = gtk_image_new_from_paintable (GDK_PAINTABLE (texture));
diff --git a/gtk/ui/gtkcombobox.ui b/gtk/ui/gtkcombobox.ui
index 4739b3d35d..87bab550f0 100644
--- a/gtk/ui/gtkcombobox.ui
+++ b/gtk/ui/gtkcombobox.ui
@@ -22,11 +22,9 @@
         </child>
       </object>
     </child>
-  </template>
-  <object class="GtkCellAreaBox" id="area"/>
+    <child>
   <object class="GtkTreePopover" id="popup_widget">
-    <property name="cell-area">area</property>
-    <property name="relative-to">GtkComboBox</property>
+    <property name="cell-area"><object class="GtkCellAreaBox" id="area"/></property>
     <property name="has-arrow">0</property>
     <signal name="menu-activate" handler="gtk_combo_box_menu_activate" swapped="no"/>
     <signal name="show" handler="gtk_combo_box_menu_show" swapped="no"/>
@@ -38,4 +36,6 @@
       </object>
     </child>
   </object>
+  </child>
+  </template>
 </interface>
diff --git a/gtk/ui/gtkplacesview.ui b/gtk/ui/gtkplacesview.ui
index 799b82cabc..bc00c725e1 100644
--- a/gtk/ui/gtkplacesview.ui
+++ b/gtk/ui/gtkplacesview.ui
@@ -14,7 +14,6 @@
     <property name="popup-completion">0</property>
   </object>
   <object class="GtkPopover" id="server_adresses_popover">
-    <property name="relative-to">address_entry</property>
     <property name="position">top</property>
     <child>
       <object class="GtkBox">
diff --git a/tests/gdkgears.c b/tests/gdkgears.c
index a4aa9fadbb..dcb31ee209 100644
--- a/tests/gdkgears.c
+++ b/tests/gdkgears.c
@@ -194,7 +194,7 @@ main (int argc, char *argv[])
 
   button = gtk_menu_button_new ();
   gtk_menu_button_set_direction (GTK_MENU_BUTTON (button), GTK_ARROW_UP);
-  popover = gtk_popover_new (NULL);
+  popover = gtk_popover_new ();
   label = gtk_label_new ("Popovers work too!");
   gtk_container_add (GTK_CONTAINER (popover), label);
 
diff --git a/tests/testdnd2.c b/tests/testdnd2.c
index 7b9db93010..4438e3a1d4 100644
--- a/tests/testdnd2.c
+++ b/tests/testdnd2.c
@@ -141,7 +141,7 @@ static void
 do_copy (GtkWidget *button)
 {
   GtkWidget *popover = gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER);
-  GtkWidget *image = gtk_popover_get_relative_to (GTK_POPOVER (popover));
+  GtkWidget *image = gtk_widget_get_parent (popover);
   GdkDrop *drop = GDK_DROP (g_object_get_data (G_OBJECT (image), "drop"));
 
   gtk_popover_popdown (GTK_POPOVER (popover));
@@ -152,7 +152,7 @@ static void
 do_cancel (GtkWidget *button)
 {
   GtkWidget *popover = gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER);
-  GtkWidget *image = gtk_popover_get_relative_to (GTK_POPOVER (popover));
+  GtkWidget *image = gtk_widget_get_parent (popover);
   GdkDrop *drop = GDK_DROP (g_object_get_data (G_OBJECT (image), "drop"));
 
   gtk_popover_popdown (GTK_POPOVER (popover));
@@ -170,7 +170,8 @@ ask_actions (GdkDrop *drop,
   popover = g_object_get_data (G_OBJECT (image), "popover");
   if (!popover)
     {
-      popover = gtk_popover_new (image);
+      popover = gtk_popover_new ();
+      gtk_widget_set_parent (popover, image);
       g_object_set_data (G_OBJECT (image), "popover", popover);
 
       box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
diff --git a/tests/testgaction.c b/tests/testgaction.c
index 872ac51fd7..ac3cead041 100644
--- a/tests/testgaction.c
+++ b/tests/testgaction.c
@@ -125,7 +125,7 @@ int main (int argc, char **argv)
     GtkBuilder *builder = gtk_builder_new_from_string (menu_data, -1);
     menu_model = G_MENU_MODEL (gtk_builder_get_object (builder, "menu_model"));
 
-    menu = gtk_popover_menu_new_from_model (NULL, menu_model);
+    menu = gtk_popover_menu_new_from_model (menu_model);
 
   }
   gtk_menu_button_set_popover (GTK_MENU_BUTTON (menubutton), menu);
diff --git a/tests/testiconview.c b/tests/testiconview.c
index 9b87c41a38..31394c4ac3 100644
--- a/tests/testiconview.c
+++ b/tests/testiconview.c
@@ -340,7 +340,8 @@ do_popup_menu (GtkWidget   *icon_list,
   if (!path)
     return;
 
-  menu = gtk_popover_new (icon_list);
+  menu = gtk_popover_new ();
+  gtk_widget_set_parent (menu, icon_list);
 
   data = g_new0 (ItemData, 1);
   data->icon_list = icon_view;
diff --git a/tests/testpopover.c b/tests/testpopover.c
index 5eae2c0241..310280fec6 100644
--- a/tests/testpopover.c
+++ b/tests/testpopover.c
@@ -115,7 +115,7 @@ main (int argc, char *argv[])
   gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), model);
   popover = GTK_WIDGET (gtk_menu_button_get_popover (GTK_MENU_BUTTON (button)));
 
-  popover1 = gtk_popover_menu_new_from_model_full (NULL, model, GTK_POPOVER_MENU_NESTED);
+  popover1 = gtk_popover_menu_new_from_model_full (model, GTK_POPOVER_MENU_NESTED);
   gtk_menu_button_set_popover (GTK_MENU_BUTTON (button1), popover1);
 
   g_object_unref (builder);
diff --git a/tests/testscrolledwindow.c b/tests/testscrolledwindow.c
index eb3fe224e0..2e81b31683 100644
--- a/tests/testscrolledwindow.c
+++ b/tests/testscrolledwindow.c
@@ -213,7 +213,7 @@ scrollable_policy (void)
   gtk_widget_show (window);
 
   /* Popover */
-  popover = gtk_popover_new (NULL);
+  popover = gtk_popover_new ();
 
   widget = gtk_menu_button_new ();
   gtk_menu_button_set_popover (GTK_MENU_BUTTON (widget), popover);
diff --git a/tests/testtooltips.c b/tests/testtooltips.c
index 9b48d6e5a2..86ae731f20 100644
--- a/tests/testtooltips.c
+++ b/tests/testtooltips.c
@@ -420,7 +420,7 @@ main (int argc, char *argv[])
   gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
   gtk_menu_button_set_label (GTK_MENU_BUTTON (button), "Custom tooltip I");
   gtk_container_add (GTK_CONTAINER (box), button);
-  popover = gtk_popover_new (NULL);
+  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);
diff --git a/testsuite/a11y/misc.c b/testsuite/a11y/misc.c
index 96c870ba52..b2895fadbe 100644
--- a/testsuite/a11y/misc.c
+++ b/testsuite/a11y/misc.c
@@ -31,13 +31,13 @@ test_popover_parent (void)
 
   w = gtk_entry_new ();
 
-  p = gtk_popover_new (NULL);
+  p = gtk_popover_new ();
   a = gtk_widget_get_accessible (p);
 
   g_assert (a != NULL);
   g_assert (atk_object_get_parent (a) == NULL);
 
-  gtk_popover_set_relative_to (GTK_POPOVER (p), w);
+  gtk_widget_set_parent (p, w);
 
   g_assert (atk_object_get_parent (a) != NULL);
 
diff --git a/testsuite/gtk/builder.c b/testsuite/gtk/builder.c
index 1ddeeea348..4b5dcc268e 100644
--- a/testsuite/gtk/builder.c
+++ b/testsuite/gtk/builder.c
@@ -2181,7 +2181,7 @@ test_expose_object (void)
     "  </object>"
     "</interface>";
 
-  menu = gtk_popover_new (NULL);
+  menu = gtk_popover_new ();
   builder = gtk_builder_new ();
   gtk_builder_expose_object (builder, "builder", G_OBJECT (builder));
   gtk_builder_expose_object (builder, "external_menu", G_OBJECT (menu));
diff --git a/testsuite/gtk/popover.c b/testsuite/gtk/popover.c
index 7c30708198..cb7813f5c3 100644
--- a/testsuite/gtk/popover.c
+++ b/testsuite/gtk/popover.c
@@ -43,7 +43,7 @@ test_show_popover (void)
 
   window = gtk_window_new ();
   button = gtk_menu_button_new ();
-  popover = gtk_popover_new (NULL);
+  popover = gtk_popover_new ();
   gtk_container_add (GTK_CONTAINER (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]