diff --git a/gtk/inspector/clipboard.c b/gtk/inspector/clipboard.c index 4523e9abdd..d0dad0eef0 100644 --- a/gtk/inspector/clipboard.c +++ b/gtk/inspector/clipboard.c @@ -241,19 +241,27 @@ add_content_type_row (GtkInspectorClipboard *self, gtk_list_box_insert (list, row, -1); } +static void +clear_formats (GtkInspectorClipboard *self, + GtkListBox *list) +{ + GtkListBoxRow *row; + + while ((row = gtk_list_box_get_row_at_index (list, 1))) + gtk_list_box_remove (list, GTK_WIDGET (row)); +} + static void init_formats (GtkInspectorClipboard *self, GtkListBox *list, GdkContentFormats *formats, GObject *data_source) { - GtkListBoxRow *row; const char * const *mime_types; const GType *gtypes; gsize i, n; - while ((row = gtk_list_box_get_row_at_index (list, 1))) - gtk_list_box_remove (list, GTK_WIDGET (row)); + clear_formats (self, list); gtypes = gdk_content_formats_get_gtypes (formats, &n); for (i = 0; i < n; i++) @@ -311,6 +319,15 @@ primary_notify (GdkClipboard *clipboard, init_info (self, GTK_LABEL (self->primary_info), clipboard); } +static void +drop_done (gpointer data, + GObject *object) +{ + GtkInspectorClipboard *self = data; + + clear_formats (self, GTK_LIST_BOX (self->dnd_formats)); +} + static void on_drop_enter (GtkDropControllerMotion *motion, double x, @@ -319,6 +336,8 @@ on_drop_enter (GtkDropControllerMotion *motion, { GdkDrop *drop = gtk_drop_controller_motion_get_drop (motion); + g_object_weak_ref (G_OBJECT (drop), drop_done, self); + init_formats (self, GTK_LIST_BOX (self->dnd_formats), gdk_drop_get_formats (drop), G_OBJECT (drop)); if (gdk_drop_get_drag (drop))