]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfilechooser.c
separator: Don't use padding and borders wrongly
[~andy/gtk] / gtk / gtkfilechooser.c
index edad5368775358830cf7455aaf74894c0793973e..141e8bf76e817d686dfce382828262921ceb1f06 100644 (file)
@@ -13,9 +13,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "config.h"
@@ -81,7 +79,7 @@
  * However, filenames are <emphasis>always</emphasis> returned in
  * the character set specified by the
  * <envar>G_FILENAME_ENCODING</envar> environment variable.
- * Please see the Glib documentation for more details about this
+ * Please see the GLib documentation for more details about this
  * variable.
  * <note>
  *    This means that while you can pass the result of
  * </example>
  * <note>
  *    If you want to set more than one extra widget in the file
- *    chooser, you can a container such as a #GtkVBox or a #GtkTable
+ *    chooser, you can a container such as a #GtkBox or a #GtkGrid
  *    and include your widgets in it.  Then, set the container as
  *    the whole extra widget.
  * </note>
@@ -556,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
@@ -582,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
@@ -609,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
@@ -643,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
@@ -909,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
@@ -1034,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.
@@ -1198,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
@@ -1346,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
  **/
@@ -1361,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);
     }
 
@@ -1530,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);