]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfilechooser.c
GtkTextView: don't popdown a bubble if we don't have one
[~andy/gtk] / gtk / gtkfilechooser.c
index b5f992c0698da5d1f19dd27f3c5171888b96c994..141e8bf76e817d686dfce382828262921ceb1f06 100644 (file)
@@ -554,7 +554,7 @@ gtk_file_chooser_default_init (GtkFileChooserInterface *iface)
   GType iface_type = G_TYPE_FROM_INTERFACE (iface);
 
   /**
-   * GtkFileChooser::current-folder-changed
+   * GtkFileChooser::current-folder-changed:
    * @chooser: the object which received the signal.
    *
    * This signal is emitted when the current folder in a #GtkFileChooser
@@ -580,7 +580,7 @@ gtk_file_chooser_default_init (GtkFileChooserInterface *iface)
                G_TYPE_NONE, 0);
 
   /**
-   * GtkFileChooser::selection-changed
+   * GtkFileChooser::selection-changed:
    * @chooser: the object which received the signal.
    *
    * This signal is emitted when there is a change in the set of selected files
@@ -607,7 +607,7 @@ gtk_file_chooser_default_init (GtkFileChooserInterface *iface)
                G_TYPE_NONE, 0);
 
   /**
-   * GtkFileChooser::update-preview
+   * GtkFileChooser::update-preview:
    * @chooser: the object which received the signal.
    *
    * This signal is emitted when the preview in a file chooser should be
@@ -641,7 +641,7 @@ gtk_file_chooser_default_init (GtkFileChooserInterface *iface)
                G_TYPE_NONE, 0);
 
   /**
-   * GtkFileChooser::file-activated
+   * GtkFileChooser::file-activated:
    * @chooser: the object which received the signal.
    *
    * This signal is emitted when the user "activates" a file in the 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
@@ -1032,8 +1036,9 @@ gtk_file_chooser_get_create_folders (GtkFileChooser *chooser)
  * @chooser: a #GtkFileChooser
  * 
  * Gets the filename for the currently selected file in
- * the file selector. If multiple files are selected,
- * one of the filenames will be returned at random.
+ * the file selector. The filename is returned as an absolute path. If
+ * multiple files are selected, one of the filenames will be returned at
+ * random.
  *
  * If the file chooser is in folder mode, this function returns the selected
  * folder.
@@ -1196,6 +1201,22 @@ files_to_strings (GSList  *files,
   return g_slist_reverse (strings);
 }
 
+static gchar *
+file_to_uri_with_native_path (GFile *file)
+{
+  gchar *result = NULL;
+  gchar *native;
+
+  native = g_file_get_path (file);
+  if (native)
+    {
+      result = g_filename_to_uri (native, NULL, NULL); /* NULL-GError */
+      g_free (native);
+    }
+
+  return result;
+}
+
 /**
  * gtk_file_chooser_get_filenames:
  * @chooser: a #GtkFileChooser
@@ -1344,7 +1365,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
  **/
@@ -1359,7 +1382,11 @@ 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))
+         result = file_to_uri_with_native_path (file);
+      else 
+          result = g_file_get_uri (file);
+
       g_object_unref (file);
     }
 
@@ -1528,7 +1555,11 @@ gtk_file_chooser_get_uris (GtkFileChooser *chooser)
 
   files = gtk_file_chooser_get_files (chooser);
 
-  result = files_to_strings (files, g_file_get_uri);
+  if (gtk_file_chooser_get_local_only (chooser))
+    result = files_to_strings (files, file_to_uri_with_native_path);
+  else
+    result = files_to_strings (files, g_file_get_uri);
+
   g_slist_foreach (files, (GFunc) g_object_unref, NULL);
   g_slist_free (files);