[nautilus] directory, file: add function to query FUSE handling



commit 2f1765d80392c06166d077c27a9a6661edd7c128
Author: Carlos Soriano <csoriano gnome org>
Date:   Tue Apr 26 11:29:04 2016 +0200

    directory, file: add function to query FUSE handling
    
    We use checks to know whether a file is local, using g_file_is_native.
    However, we also need to know for some cases when a file, even if no
    native, can be handled like native, using FUSE.
    
    This will be needed for the selection of default applications on remote
    locations, and will be used in a upcoming patch.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764506

 src/nautilus-directory.c |   29 ++++++++++++++++++++++++++++-
 src/nautilus-directory.h |    1 +
 src/nautilus-file.c      |    8 ++++++++
 src/nautilus-file.h      |    1 +
 4 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/src/nautilus-directory.c b/src/nautilus-directory.c
index 8cee225..3595406 100644
--- a/src/nautilus-directory.c
+++ b/src/nautilus-directory.c
@@ -642,15 +642,42 @@ nautilus_directory_new (GFile *location)
 gboolean
 nautilus_directory_is_local (NautilusDirectory *directory)
 {
+  g_autofree char* path = NULL;
+
+       g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
+
+       if (directory->details->location == NULL) {
+               return TRUE;
+       }
+
+  path = g_file_get_path (directory->details->location);
+
+       return nautilus_directory_is_in_trash (directory) ||
+               nautilus_directory_is_in_recent (directory) ||
+              g_file_is_native (directory->details->location) ||
+         path != NULL;
+}
+
+gboolean
+nautilus_directory_is_local_or_fuse (NautilusDirectory *directory)
+{
+        g_autofree char* path = NULL;
+
        g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
        
        if (directory->details->location == NULL) {
                return TRUE;
        }
 
+        /* If the glib reports a path, then it can use FUSE to convert the uri
+         * to a local path
+         */
+        path = g_file_get_path (directory->details->location);
+
        return nautilus_directory_is_in_trash (directory) ||
                nautilus_directory_is_in_recent (directory) ||
-              g_file_is_native (directory->details->location);
+              g_file_is_native (directory->details->location) ||
+               path != NULL;
 }
 
 gboolean
diff --git a/src/nautilus-directory.h b/src/nautilus-directory.h
index 25e3aa2..dc8c732 100644
--- a/src/nautilus-directory.h
+++ b/src/nautilus-directory.h
@@ -221,6 +221,7 @@ gboolean           nautilus_directory_are_all_files_seen       (NautilusDirector
 
 /* Return true if the directory is local. */
 gboolean           nautilus_directory_is_local                 (NautilusDirectory         *directory);
+gboolean           nautilus_directory_is_local_or_fuse         (NautilusDirectory         *directory);
 
 gboolean           nautilus_directory_is_in_trash              (NautilusDirectory         *directory);
 gboolean           nautilus_directory_is_in_recent             (NautilusDirectory         *directory);
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index 49f23c9..e3cbdfe 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -2048,6 +2048,14 @@ nautilus_file_is_local (NautilusFile *file)
        return nautilus_directory_is_local (file->details->directory);
 }
 
+gboolean
+nautilus_file_is_local_or_fuse (NautilusFile *file)
+{
+       g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
+
+       return nautilus_directory_is_local_or_fuse (file->details->directory);
+}
+
 static void
 update_link (NautilusFile *link_file, NautilusFile *target_file)
 {
diff --git a/src/nautilus-file.h b/src/nautilus-file.h
index 46085b2..1050575 100644
--- a/src/nautilus-file.h
+++ b/src/nautilus-file.h
@@ -402,6 +402,7 @@ gboolean                nautilus_file_matches_uri                       (Nautilu
 
 /* Is the file local? */
 gboolean                nautilus_file_is_local                          (NautilusFile                   
*file);
+gboolean                nautilus_file_is_local_or_fuse                  (NautilusFile                   
*file);
 
 /* Comparing two file objects for sorting */
 NautilusFileSortType    nautilus_file_get_default_sort_type             (NautilusFile                   
*file,


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