]> Pileus Git - ~andy/gtk/commitdiff
filechooser: Show FUSE mounted locations in shortcuts
authorTimothy Arceri <t_arceri@yahoo.com.au>
Sun, 18 Nov 2012 08:39:11 +0000 (19:39 +1100)
committerFederico Mena Quintero <federico@gnome.org>
Tue, 5 Mar 2013 23:17:42 +0000 (17:17 -0600)
Since FUSE locations can be handled safely by applications show these mounted locations regardless of whether gtk_file_chooser_set_local_only()
is set to TRUE

https://bugzilla.gnome.org/show_bug.cgi?id=586367

gtk/gtkfilechooser.c
gtk/gtkfilechooserdefault.c
gtk/gtkfilechooserentry.c
gtk/gtkfilesystem.c
gtk/gtkfilesystem.h

index 8e2d64da4c87e8e2d37b5a97f921d028a3c0cf1d..820db562bf86a64d85069897f76f439a43d78853 100644 (file)
@@ -907,6 +907,10 @@ gtk_file_chooser_get_action (GtkFileChooser *chooser)
  * rather than the URI functions like
  * gtk_file_chooser_get_uri(),
  *
+ * On some systems non-native files may still be
+ * available using the native filesystem via a userspace
+ * filesystem (FUSE).
+ *
  * Since: 2.4
  **/
 void
@@ -1345,7 +1349,9 @@ gtk_file_chooser_set_current_name  (GtkFileChooser *chooser,
  * folder.
  * 
  * Return value: The currently selected URI, or %NULL
- *  if no file is selected. Free with g_free()
+ *  if no file is selected. If gtk_file_chooser_set_local_only() is set to %TRUE
+ * (the default) a local URI will be returned for any FUSE locations.
+ * Free with g_free()
  *
  * Since: 2.4
  **/
@@ -1360,7 +1366,19 @@ gtk_file_chooser_get_uri (GtkFileChooser *chooser)
   file = gtk_file_chooser_get_file (chooser);
   if (file)
     {
-      result = g_file_get_uri (file);
+      if (gtk_file_chooser_get_local_only (chooser))
+        {
+           gchar *local = g_file_get_path (file);
+           if (local)
+             {
+               result = g_filename_to_uri (local, NULL, NULL);
+               g_free (local);
+             }
+        }
+      else 
+        {
+          result = g_file_get_uri (file);
+        }
       g_object_unref (file);
     }
 
index 498efd135d717907af781658c4c8758a055ab3ba..8f0b278903b88ff60a69c97974e2a763eb3ddda1 100644 (file)
@@ -1854,7 +1854,7 @@ shortcuts_append_bookmarks (GtkFileChooserDefault *impl,
 
       file = bookmarks->data;
 
-      if (impl->local_only && !g_file_is_native (file))
+      if (impl->local_only && _gtk_file_is_path_not_local (file))
        continue;
 
       if (shortcut_find_position (impl, file) != -1)
@@ -1976,16 +1976,16 @@ shortcuts_add_volumes (GtkFileChooserDefault *impl)
          if (_gtk_file_system_volume_is_mounted (volume))
            {
              GFile *base_file;
-              gboolean base_is_native = TRUE;
+              gboolean base_is_not_local = FALSE;
 
              base_file = _gtk_file_system_volume_get_root (volume);
               if (base_file != NULL)
                 {
-                  base_is_native = g_file_is_native (base_file);
+                  base_is_not_local = _gtk_file_is_path_not_local (base_file);
                   g_object_unref (base_file);
                 }
 
-              if (!base_is_native)
+              if (base_is_not_local)
                 continue;
            }
        }
@@ -7338,7 +7338,7 @@ gtk_file_chooser_default_update_current_folder (GtkFileChooser    *chooser,
 
   operation_mode_set (impl, OPERATION_MODE_BROWSE);
 
-  if (impl->local_only && !g_file_is_native (file))
+  if (impl->local_only && _gtk_file_is_path_not_local (file))
     {
       g_set_error_literal (error,
                            GTK_FILE_CHOOSER_ERROR,
index 98ecd24c71d88301a7ae92e3d0f9d9a0b20b7698..603516a2cfb8c8dac3be7ff55d3d7d0232f419ea 100644 (file)
@@ -558,7 +558,7 @@ set_completion_folder (GtkFileChooserEntry *chooser_entry,
 {
   if (folder_file &&
       chooser_entry->local_only
-      && !g_file_is_native (folder_file))
+      && _gtk_file_is_path_not_local (folder_file))
     folder_file = NULL;
 
   if ((chooser_entry->current_folder_file
index 553e007e08bc58e717309e922ea90e4513c6cd69..db09c9a654a87427832bb094cfe3e1ae9caf07df 100644 (file)
@@ -1273,3 +1273,17 @@ _gtk_file_info_consider_as_directory (GFileInfo *info)
           type == G_FILE_TYPE_SHORTCUT);
 }
 
+gboolean
+_gtk_file_is_path_not_local (GFile *file)
+{
+  char *local_file_path;
+  gboolean is_not_local;
+
+  /* Don't use is_native(), as we want to support fuse paths if available */
+  local_file_path = g_file_get_path (file);
+  is_not_local = (local_file_path == NULL);
+  g_free (local_file_path);
+
+  return is_not_local;
+}
+
index 83e1f34d5627c468d41161361181aad7f1f9d2ce..57b687615b0fdbae787f670bd9f838a5feb28137 100644 (file)
@@ -128,6 +128,9 @@ GdkPixbuf *     _gtk_file_info_render_icon (GFileInfo *info,
 
 gboolean       _gtk_file_info_consider_as_directory (GFileInfo *info);
 
+/* GFile helper functions */
+gboolean       _gtk_file_is_path_not_local (GFile *file);
+
 G_END_DECLS
 
 #endif /* __GTK_FILE_SYSTEM_H__ */