From 3ebf19b783f3b04b5f6b474e13572f8871715045 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 23 Feb 2019 00:46:44 -0500 Subject: [PATCH] text handle: Stop using ::hierarchy-changed Use notify::root instead. --- gtk/gtktexthandle.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gtk/gtktexthandle.c b/gtk/gtktexthandle.c index 84405d297e..eebfcbd129 100644 --- a/gtk/gtktexthandle.c +++ b/gtk/gtktexthandle.c @@ -61,6 +61,7 @@ struct _HandleWindow struct _GtkTextHandlePrivate { HandleWindow windows[2]; + GtkWidget *toplevel; GtkWidget *parent; GtkScrollable *parent_scrollable; GtkAdjustment *vadj; @@ -217,7 +218,7 @@ _gtk_text_handle_ensure_widget (GtkTextHandle *handle, gtk_widget_add_controller (widget, controller); priv->windows[pos].widget = g_object_ref_sink (widget); - window = gtk_widget_get_ancestor (priv->parent, GTK_TYPE_WINDOW); + priv->toplevel = window = gtk_widget_get_ancestor (priv->parent, GTK_TYPE_WINDOW); _gtk_window_add_popover (GTK_WINDOW (window), widget, priv->parent, FALSE); context = gtk_widget_get_style_context (widget); @@ -468,7 +469,7 @@ gtk_text_handle_lookup_scrollable (GtkTextHandle *handle) static void _gtk_text_handle_parent_hierarchy_changed (GtkWidget *widget, - GtkWindow *previous_toplevel, + GParamSpec *pspec, GtkTextHandle *handle) { GtkWidget *toplevel, *scrollable; @@ -477,11 +478,11 @@ _gtk_text_handle_parent_hierarchy_changed (GtkWidget *widget, priv = handle->priv; toplevel = gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW); - if (previous_toplevel && !toplevel) + if (priv->toplevel && !toplevel) { if (priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_START].widget) { - _gtk_window_remove_popover (GTK_WINDOW (previous_toplevel), + _gtk_window_remove_popover (GTK_WINDOW (priv->toplevel), priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_START].widget); g_object_unref (priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_START].widget); priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_START].widget = NULL; @@ -489,11 +490,13 @@ _gtk_text_handle_parent_hierarchy_changed (GtkWidget *widget, if (priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_END].widget) { - _gtk_window_remove_popover (GTK_WINDOW (previous_toplevel), + _gtk_window_remove_popover (GTK_WINDOW (priv->toplevel), priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_END].widget); g_object_unref (priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_END].widget); priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_END].widget = NULL; } + + priv->toplevel = NULL; } scrollable = gtk_text_handle_lookup_scrollable (handle); @@ -521,7 +524,7 @@ _gtk_text_handle_set_parent (GtkTextHandle *handle, if (parent) { priv->hierarchy_changed_id = - g_signal_connect (parent, "hierarchy-changed", + g_signal_connect (parent, "notify::root", G_CALLBACK (_gtk_text_handle_parent_hierarchy_changed), handle);