[gtk+/gtk-2-24] filechooser: Show FUSE mounted locations in shortcuts
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] filechooser: Show FUSE mounted locations in shortcuts
- Date: Wed, 6 Mar 2013 18:49:42 +0000 (UTC)
commit 5d32c05578869c4c5eff9b9c3ee058fd9afc5dc5
Author: Timothy Arceri <t_arceri yahoo com au>
Date: Sun Nov 18 19:39:11 2012 +1100
filechooser: Show FUSE mounted locations in shortcuts
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 | 22 ++++++++++++++++++++--
gtk/gtkfilechooserdefault.c | 10 +++++-----
gtk/gtkfilechooserentry.c | 2 +-
gtk/gtkfilesystem.c | 14 ++++++++++++++
gtk/gtkfilesystem.h | 3 +++
5 files changed, 43 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkfilechooser.c b/gtk/gtkfilechooser.c
index a50cbe5..b274637 100644
--- a/gtk/gtkfilechooser.c
+++ b/gtk/gtkfilechooser.c
@@ -934,6 +934,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
@@ -1368,7 +1372,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
**/
@@ -1383,7 +1389,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);
}
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 57dfa27..39d87e5 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -1873,7 +1873,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)
@@ -2000,16 +2000,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;
}
}
@@ -7240,7 +7240,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,
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 238d1fb..1bf3fba 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -1467,7 +1467,7 @@ start_loading_current_folder (GtkFileChooserEntry *chooser_entry)
g_assert (chooser_entry->load_folder_cancellable == NULL);
if (chooser_entry->local_only
- && !g_file_is_native (chooser_entry->current_folder_file))
+ && !_gtk_file_is_path_not_local (chooser_entry->current_folder_file))
{
g_object_unref (chooser_entry->current_folder_file);
chooser_entry->current_folder_file = NULL;
diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c
index 4871904..1197255 100644
--- a/gtk/gtkfilesystem.c
+++ b/gtk/gtkfilesystem.c
@@ -1927,3 +1927,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;
+}
+
diff --git a/gtk/gtkfilesystem.h b/gtk/gtkfilesystem.h
index a92c8f8..410795d 100644
--- a/gtk/gtkfilesystem.h
+++ b/gtk/gtkfilesystem.h
@@ -175,6 +175,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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]