[gtk+/wip/matthiasc/filechooser: 11/13] file chooser: Make location column work better



commit 2295fe13c6696abc19cd838c14db3e6a6fbaec7f
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 27 01:07:32 2015 -0400

    file chooser: Make location column work better
    
    The location column did not work for search results in recent://.
    Fix that by looking at the target uri in this case. Show the location
    column in recent mode. And make it more similar to nautilus by
    showing the full path if it is not below $HOME.

 gtk/gtkfilechooserwidget.c  |   24 +++++++++++++++++++-----
 gtk/gtksearchenginesimple.c |    1 +
 2 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 9edee93..2c87035 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -361,7 +361,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
 
 #define MODEL_ATTRIBUTES "standard::name,standard::type,standard::display-name," \
                          "standard::is-hidden,standard::is-backup,standard::size," \
-                         "standard::content-type,time::modified"
+                         "standard::content-type,time::modified,standard::target-uri"
 enum {
   /* the first 3 must be these due to settings caching sort column */
   MODEL_COL_NAME,
@@ -2618,7 +2618,7 @@ operation_mode_set_recent (GtkFileChooserWidget *impl)
   gtk_places_sidebar_set_location (GTK_PLACES_SIDEBAR (priv->places_sidebar), file);
   g_object_unref (file);
   gtk_widget_set_sensitive (priv->filter_combo, TRUE);
-  gtk_tree_view_column_set_visible (priv->list_location_column, FALSE);
+  gtk_tree_view_column_set_visible (priv->list_location_column, TRUE);
 }
 
 static void
@@ -4198,9 +4198,23 @@ file_system_model_set (GtkFileSystemModel *model,
         else
           dir_location = NULL;
 
-        if (dir_location && g_file_equal (home_location, dir_location))
+        if (dir_location && file_is_recent_uri (dir_location))
+          {
+            const char *target_uri;
+            GFile *target;
+
+            target_uri = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI);
+            target = g_file_new_for_uri (target_uri);
+            g_object_unref (dir_location);
+            dir_location = g_file_get_parent (target);
+            g_object_unref (target);
+          }
+
+        if (!dir_location)
+          location = g_strdup ("");
+        else if (g_file_equal (home_location, dir_location))
           location = g_strdup (_("Home"));
-        else if (dir_location && g_file_has_prefix (dir_location, home_location))
+        else if (g_file_has_prefix (dir_location, home_location))
           {
             gchar *relative_path;
 
@@ -4210,7 +4224,7 @@ file_system_model_set (GtkFileSystemModel *model,
             g_free (relative_path);
           }
         else
-          location = g_strdup ("");
+          location = g_file_get_path (dir_location);
 
         g_value_take_string (value, location);
 
diff --git a/gtk/gtksearchenginesimple.c b/gtk/gtksearchenginesimple.c
index bb064b9..ee12ae3 100644
--- a/gtk/gtksearchenginesimple.c
+++ b/gtk/gtksearchenginesimple.c
@@ -218,6 +218,7 @@ visit_directory (GFile *dir, SearchThreadData *data)
                                           G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP ","
                                           G_FILE_ATTRIBUTE_STANDARD_SIZE ","
                                           G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
+                                          G_FILE_ATTRIBUTE_STANDARD_TARGET_URI ","
                                           G_FILE_ATTRIBUTE_TIME_MODIFIED,
                                           G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
                                           data->cancellable, NULL);


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