diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index ec9d6f52a1..c9cdf2f159 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -4443,7 +4443,6 @@ gtk_widget_set_name gtk_widget_get_name gtk_widget_set_sensitive gtk_widget_set_parent -gtk_widget_get_toplevel gtk_widget_get_root gtk_widget_get_native gtk_widget_get_ancestor diff --git a/gtk/gtkimcontextxim.c b/gtk/gtkimcontextxim.c index 6cfec9f271..e4b747af58 100644 --- a/gtk/gtkimcontextxim.c +++ b/gtk/gtkimcontextxim.c @@ -1419,7 +1419,7 @@ gtk_im_context_xim_get_ic (GtkIMContextXIM *context_xim) * The toplevel is computed by walking up the GdkSurface * hierarchy from context->client_surface until we find a * window that is owned by some widget, and then calling - * gtk_widget_get_toplevel() on that widget. This should + * gtk_widget_get_root() on that widget. This should * handle both cases where we might have GdkSurfaces without widgets, * and cases where GtkWidgets have strange window hierarchies * (like a torn off GtkHandleBox.) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index ce6bee16f4..9a393a5bb9 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -7498,59 +7498,6 @@ gtk_widget_has_size_request (GtkWidget *widget) return !(priv->width_request == -1 && priv->height_request == -1); } -/** - * gtk_widget_get_toplevel: - * @widget: a #GtkWidget - * - * This function returns the topmost widget in the container hierarchy - * @widget is a part of. If @widget has no parent widgets, it will be - * returned as the topmost widget. No reference will be added to the - * returned widget; it should not be unreferenced. - * - * Note the difference in behavior vs. gtk_widget_get_ancestor(); - * `gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW)` - * would return - * %NULL if @widget wasn’t inside a toplevel window, and if the - * window was inside a #GtkWindow-derived widget which was in turn - * inside the toplevel #GtkWindow. - * - * To reliably find the toplevel #GtkWindow, use - * gtk_widget_get_toplevel() and call GTK_IS_WINDOW() - * on the result. For instance, to get the title of a widget's toplevel - * window, one might use: - * |[ - * static const char * - * get_widget_toplevel_title (GtkWidget *widget) - * { - * GtkWidget *toplevel = gtk_widget_get_toplevel (widget); - * if (GTK_IS_WINDOW (toplevel)) - * { - * return gtk_window_get_title (GTK_WINDOW (toplevel)); - * } - * - * return NULL; - * } - * ]| - * - * Returns: (transfer none): the topmost ancestor of @widget, or @widget itself - * if there’s no ancestor. - **/ -GtkWidget * -gtk_widget_get_toplevel (GtkWidget *widget) -{ - GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); - - g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - - while (priv->parent) - { - widget = priv->parent; - priv = gtk_widget_get_instance_private (widget); - } - - return widget; -} - /** * gtk_widget_get_ancestor: * @widget: a #GtkWidget @@ -7559,9 +7506,7 @@ gtk_widget_get_toplevel (GtkWidget *widget) * Gets the first ancestor of @widget with type @widget_type. For example, * `gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)` gets * the first #GtkBox that’s an ancestor of @widget. No reference will be - * added to the returned widget; it should not be unreferenced. See note - * about checking for a toplevel #GtkWindow in the docs for - * gtk_widget_get_toplevel(). + * added to the returned widget; it should not be unreferenced. * * Note that unlike gtk_widget_is_ancestor(), gtk_widget_get_ancestor() * considers @widget to be an ancestor of itself. diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index f456393e85..94586e2253 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -607,9 +607,6 @@ void gtk_widget_set_overflow (GtkWidget *widget, GDK_AVAILABLE_IN_ALL GtkOverflow gtk_widget_get_overflow (GtkWidget *widget); - -GDK_AVAILABLE_IN_ALL -GtkWidget* gtk_widget_get_toplevel (GtkWidget *widget); GDK_AVAILABLE_IN_ALL GtkWidget* gtk_widget_get_ancestor (GtkWidget *widget, GType widget_type); diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index f67b24ab85..26df307cc2 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -423,15 +423,6 @@ _gtk_widget_get_direction (GtkWidget *widget) return widget->priv->direction; } -static inline GtkWidget * -_gtk_widget_get_toplevel (GtkWidget *widget) -{ - while (widget->priv->parent) - widget = widget->priv->parent; - - return widget; -} - static inline GtkRoot * _gtk_widget_get_root (GtkWidget *widget) {