diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index ebd4a4cfb2..220bb62e45 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -4530,6 +4530,8 @@ gtk_widget_freeze_child_notify gtk_widget_get_child_visible gtk_widget_get_parent gtk_widget_get_settings +gtk_widget_get_clipboard +gtk_widget_get_primary_clipboard gtk_widget_get_old_clipboard gtk_widget_get_display gtk_widget_get_size_request diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 4d250c9bb8..51b0864c39 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -12379,6 +12379,50 @@ gtk_widget_set_margin_bottom (GtkWidget *widget, g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_MARGIN_BOTTOM]); } +/** + * gtk_widget_get_clipboard: + * @widget: a #GtkWidget + * + * This is a utility function to get the clipboard object for the + * #GdkDisplay that @widget is using. + * + * Note that this function always works, even when @widget is not + * realized yet. + * + * Returns: (transfer none): the appropriate clipboard object. + * + * Since: 3.94 + **/ +GdkClipboard * +gtk_widget_get_clipboard (GtkWidget *widget) +{ + g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); + + return gdk_display_get_clipboard (gtk_widget_get_display (widget)); +} + +/** + * gtk_widget_get_primary_clipboard: + * @widget: a #GtkWidget + * + * This is a utility function to get the primary clipboard object + * for the #GdkDisplay that @widget is using. + * + * Note that this function always works, even when @widget is not + * realized yet. + * + * Returns: (transfer none): the appropriate clipboard object. + * + * Since: 3.94 + **/ +GdkClipboard * +gtk_widget_get_primary_clipboard (GtkWidget *widget) +{ + g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); + + return gdk_display_get_primary_clipboard (gtk_widget_get_display (widget)); +} + /** * gtk_widget_get_old_clipboard: * @widget: a #GtkWidget diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 5631299d41..edb7feac58 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -782,6 +782,10 @@ GDK_AVAILABLE_IN_ALL GdkDisplay * gtk_widget_get_display (GtkWidget *widget); GDK_AVAILABLE_IN_ALL GtkSettings* gtk_widget_get_settings (GtkWidget *widget); +GDK_AVAILABLE_IN_3_94 +GdkClipboard *gtk_widget_get_clipboard (GtkWidget *widget); +GDK_AVAILABLE_IN_3_94 +GdkClipboard *gtk_widget_get_primary_clipboard (GtkWidget *widget); GDK_AVAILABLE_IN_ALL GtkClipboard *gtk_widget_get_old_clipboard (GtkWidget *widget, GdkAtom selection);