gtkfilechooser: clear cut feedback when clipboard changes

This commit is contained in:
Daemonratte 2026-05-22 09:55:28 +02:00
commit 073b38a0f5

View file

@ -5035,6 +5035,7 @@ struct file_clipboard_data
gchar *uri_list;
gchar *plain_text;
gchar *cut_selection;
GtkFileChooserDefault *impl;
};
struct file_clipboard_closure
@ -5086,6 +5087,10 @@ file_clipboard_data_free (struct file_clipboard_data *data)
if (!data)
return;
if (data->impl)
g_object_remove_weak_pointer (G_OBJECT (data->impl),
(gpointer *) &data->impl);
g_free (data->gnome_copied_files);
g_free (data->uri_list);
g_free (data->plain_text);
@ -5138,7 +5143,12 @@ static void
file_clipboard_clear_cb (GtkClipboard *clipboard,
gpointer user_data)
{
file_clipboard_data_free (user_data);
struct file_clipboard_data *data = user_data;
if (data->impl)
file_clipboard_cut_files_clear (data->impl);
file_clipboard_data_free (data);
}
static void
@ -5225,6 +5235,9 @@ copy_or_cut_files_to_clipboard (GtkFileChooserDefault *impl,
data->uri_list = g_string_free (closure.uri_list, FALSE);
data->plain_text = g_string_free (closure.plain_text, FALSE);
data->cut_selection = g_strdup (cut ? "1" : "0");
data->impl = impl;
g_object_add_weak_pointer (G_OBJECT (impl),
(gpointer *) &data->impl);
clipboard = gtk_clipboard_get_for_display (gtk_widget_get_display (impl->browse_files_current_view),
GDK_SELECTION_CLIPBOARD);