[gthumb] Fixed pasting files into remote folders



commit 01bb838036f7e697c0e15f1d6d36e5707d3d2843
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Mar 1 20:56:33 2020 +0100

    Fixed pasting files into remote folders

 extensions/catalogs/gth-file-source-catalogs.c     |  4 ++--
 extensions/selections/gth-file-source-selections.c | 12 +++++++++--
 gthumb/gth-file-source-vfs.c                       | 24 +++++++++++++++++-----
 gthumb/gth-main.c                                  | 17 +++++++++++++++
 gthumb/gth-main.h                                  |  1 +
 5 files changed, 49 insertions(+), 9 deletions(-)
---
diff --git a/extensions/catalogs/gth-file-source-catalogs.c b/extensions/catalogs/gth-file-source-catalogs.c
index eb9162e8..517f0bcc 100644
--- a/extensions/catalogs/gth-file-source-catalogs.c
+++ b/extensions/catalogs/gth-file-source-catalogs.c
@@ -1459,12 +1459,12 @@ gth_file_source_catalogs_get_drop_actions (GthFileSource *file_source,
        gboolean       file_is_catalog;
 
        dest_uri = g_file_get_uri (destination);
-       dest_scheme = _g_uri_get_scheme (dest_uri);
+       dest_scheme = gth_main_get_source_scheme (dest_uri);
        dest_ext = _g_uri_get_extension (dest_uri);
        dest_is_catalog = _g_str_equal (dest_ext, ".catalog") || _g_str_equal (dest_ext, ".search");
 
        file_uri = g_file_get_uri (file);
-       file_scheme = _g_uri_get_scheme (file_uri);
+       file_scheme = gth_main_get_source_scheme (file_uri);
        file_ext = _g_uri_get_extension (file_uri);
        file_is_catalog = _g_str_equal (file_ext, ".catalog") || _g_str_equal (file_ext, ".search");
 
diff --git a/extensions/selections/gth-file-source-selections.c 
b/extensions/selections/gth-file-source-selections.c
index 42a42275..f3ce08a9 100644
--- a/extensions/selections/gth-file-source-selections.c
+++ b/extensions/selections/gth-file-source-selections.c
@@ -289,15 +289,23 @@ gth_file_source_selections_get_drop_actions (GthFileSource *file_source,
                                             GFile         *destination,
                                             GFile         *file)
 {
-       GdkDragAction actions = 0;
+       GdkDragAction  actions = 0;
+       char          *file_uri;
+       char          *file_scheme;
+
+       file_uri = g_file_get_uri (file);
+       file_scheme = gth_main_get_source_scheme (file_uri);
 
        if (_g_file_has_scheme (destination, "selection")
-               && _g_file_has_scheme (file, "file"))
+               && _g_str_equal (file_scheme, "file"))
        {
                /* Copy files into a selection. */
                actions = GDK_ACTION_COPY;
        }
 
+       g_free (file_scheme);
+       g_free (file_uri);
+
        return actions;
 }
 
diff --git a/gthumb/gth-file-source-vfs.c b/gthumb/gth-file-source-vfs.c
index 9ad3255a..df318346 100644
--- a/gthumb/gth-file-source-vfs.c
+++ b/gthumb/gth-file-source-vfs.c
@@ -875,14 +875,28 @@ gth_file_source_vfs_get_drop_actions (GthFileSource *file_source,
                                      GFile         *destination,
                                      GFile         *file)
 {
-       GdkDragAction actions = 0;
-
-       if (_g_file_has_scheme (destination, "file")
-               && _g_file_has_scheme (file, "file"))
+       GdkDragAction  actions = 0;
+       char          *dest_uri;
+       char          *file_uri;
+       char          *dest_scheme;
+       char          *file_scheme;
+
+       dest_uri = g_file_get_uri (destination);
+       dest_scheme = gth_main_get_source_scheme (dest_uri);
+       file_uri = g_file_get_uri (file);
+       file_scheme = gth_main_get_source_scheme (file_uri);
+
+       if (_g_str_equal (dest_scheme, "file")
+               && _g_str_equal (file_scheme, "file"))
        {
                actions = GDK_ACTION_COPY | GDK_ACTION_MOVE;
        }
 
+       g_free (file_scheme);
+       g_free (file_uri);
+       g_free (dest_scheme);
+       g_free (dest_uri);
+
        return actions;
 }
 
@@ -954,5 +968,5 @@ gth_file_source_vfs_init (GthFileSourceVfs *file_source)
        file_source->priv->mount_monitor = NULL;
        file_source->priv->check_hidden_files = FALSE;
 
-       gth_file_source_add_scheme (GTH_FILE_SOURCE (file_source), "vfs+");
+       gth_file_source_add_scheme (GTH_FILE_SOURCE (file_source), "file");
 }
diff --git a/gthumb/gth-main.c b/gthumb/gth-main.c
index a4f81781..3aa0b14f 100644
--- a/gthumb/gth-main.c
+++ b/gthumb/gth-main.c
@@ -278,6 +278,23 @@ gth_main_get_file_source (GFile *file)
        return file_source;
 }
 
+
+char *
+gth_main_get_source_scheme (const char *uri)
+{
+       GList *scan;
+
+       for (scan = Main->priv->file_sources; scan; scan = scan->next) {
+               GthFileSource *registered_file_source = scan->data;
+
+               if (gth_file_source_supports_scheme (registered_file_source, uri))
+                       return _g_uri_get_scheme (uri);
+       }
+
+       return g_strdup ("file");
+}
+
+
 GList *
 gth_main_get_all_file_sources (void)
 {
diff --git a/gthumb/gth-main.h b/gthumb/gth-main.h
index dacdb49a..f329ea36 100644
--- a/gthumb/gth-main.h
+++ b/gthumb/gth-main.h
@@ -68,6 +68,7 @@ void                   gth_main_release                       (void);
 void                   gth_main_register_file_source          (GType                 file_source_type);
 GthFileSource *        gth_main_get_file_source_for_uri       (const char           *uri);
 GthFileSource *        gth_main_get_file_source               (GFile                *file);
+char *                 gth_main_get_source_scheme             (const char           *uri);
 GList *                gth_main_get_all_file_sources          (void);
 GList *                gth_main_get_all_entry_points          (void);
 GFile *                gth_main_get_nearest_entry_point       (GFile                *file);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]