[gthumb] pasting files: better logic to check if the operation is possible
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] pasting files: better logic to check if the operation is possible
- Date: Sun, 24 Nov 2019 12:27:45 +0000 (UTC)
commit 4fae1da60104cba196af7c22fbbfeffd5f25f977
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Nov 4 08:58:24 2019 +0100
pasting files: better logic to check if the operation is possible
Use gth_file_source_get_drop_actions to check if a paste operation is
possible.
extensions/file_manager/actions.c | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/extensions/file_manager/actions.c b/extensions/file_manager/actions.c
index d3a92406..1402d292 100644
--- a/extensions/file_manager/actions.c
+++ b/extensions/file_manager/actions.c
@@ -370,14 +370,15 @@ clipboard_received_cb (GtkClipboard *clipboard,
GtkSelectionData *selection_data,
gpointer user_data)
{
- PasteData *paste_data = user_data;
- GthBrowser *browser = paste_data->browser;
- const char *raw_data;
- char **clipboard_data;
- int i;
- GtkTreePath *path;
- int position;
- GthTask *task;
+ PasteData *paste_data = user_data;
+ GthBrowser *browser = paste_data->browser;
+ const char *raw_data;
+ char **clipboard_data;
+ int i;
+ GdkDragAction actions;
+ GtkTreePath *path;
+ int position;
+ GthTask *task;
raw_data = (const char *) gtk_selection_data_get_data (selection_data);
if (raw_data == NULL) {
@@ -400,7 +401,19 @@ clipboard_received_cb (GtkClipboard *clipboard,
paste_data->files = g_list_reverse (paste_data->files);
paste_data->file_source = gth_main_get_file_source (paste_data->destination->file);
- if (paste_data->cut && ! gth_file_source_can_cut (paste_data->file_source, paste_data->files->data)) {
+ actions = gth_file_source_get_drop_actions (paste_data->file_source,
+ paste_data->destination->file,
+ G_FILE (paste_data->files->data));
+ if (actions == 0) {
+ _gtk_error_dialog_run (GTK_WINDOW (browser),
+ "%s",
+ _("Could not perform the operation"));
+ g_strfreev (clipboard_data);
+ paste_data_free (paste_data);
+ return;
+ }
+
+ if (paste_data->cut && ((actions & GDK_ACTION_MOVE) == 0)) {
GtkWidget *dialog;
int response;
@@ -416,6 +429,7 @@ clipboard_received_cb (GtkClipboard *clipboard,
gtk_widget_destroy (dialog);
if (response == GTK_RESPONSE_CANCEL) {
+ g_strfreev (clipboard_data);
paste_data_free (paste_data);
return;
}
@@ -442,6 +456,7 @@ clipboard_received_cb (GtkClipboard *clipboard,
gth_browser_exec_task (browser, task, GTH_TASK_FLAGS_DEFAULT);
g_object_unref (task);
+ g_strfreev (clipboard_data);
paste_data_free (paste_data);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]