[gtk+/places-sidebar] Allow switching to recent:/// even though GIO thinks it is not a native file



commit f623329e95c7d6f43874cf667f5036dc01793331
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Nov 23 12:53:35 2012 -0600

    Allow switching to recent:/// even though GIO thinks it is not a native file
    
    That URI is not a native file, and so it would not show up if local_only=TRUE.
    Add a special case for it so that recent:/// can always be visited.
    
    Signed-off-by: Federico Mena Quintero <federico gnome org>

 gtk/gtkfilechooserdefault.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index be7a958..85111de 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -7545,6 +7545,19 @@ out:
 }
 
 static gboolean
+file_is_recent_uri (GFile *file)
+{
+  GFile *recent;
+  gboolean same;
+
+  recent = g_file_new_for_uri ("recent:///");
+  same = g_file_equal (file, recent);
+  g_object_unref (recent);
+
+  return same;
+}
+
+static gboolean
 gtk_file_chooser_default_update_current_folder (GtkFileChooser    *chooser,
 						GFile             *file,
 						gboolean           keep_trail,
@@ -7560,7 +7573,8 @@ 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 && !g_file_is_native (file)
+      && !file_is_recent_uri (file)) /* GIO considers "recent:///" to be non-native; we special-case it so recent files *will* show up */
     {
       g_set_error_literal (error,
                            GTK_FILE_CHOOSER_ERROR,



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