[gedit/gnome-3-18] OpenDocumentSelector: fix fetching of recents



commit 5fcff27ad0f0b5f0f26a13805c22005374261621
Author: Sebastien Lafargue <slafargue gnome org>
Date:   Mon Oct 26 21:27:06 2015 +0100

    OpenDocumentSelector: fix fetching of recents
    
    Previously we were querying each files for a precise access time
    but this is slow with remote ones. Let just gets the time
    from the recent manager ( sec precision vs msec )
    
    We also now show remote files in the selector.

 gedit/gedit-open-document-selector-store.c |   22 ++--------------------
 gedit/gedit-open-document-selector.c       |   25 +++++++++++++++++++++----
 2 files changed, 23 insertions(+), 24 deletions(-)
---
diff --git a/gedit/gedit-open-document-selector-store.c b/gedit/gedit-open-document-selector-store.c
index b9b6e4d..dccc566 100644
--- a/gedit/gedit-open-document-selector-store.c
+++ b/gedit/gedit-open-document-selector-store.c
@@ -473,35 +473,17 @@ convert_recent_item_list_to_fileitem_list (GList *uri_list)
        for (l = uri_list; l != NULL; l = l->next)
        {
                gchar *uri;
-               GFile *file;
-               GFileInfo *info;
                FileItem *item;
 
                uri = g_strdup (gtk_recent_info_get_uri (l->data));
-               file = g_file_new_for_uri (uri);
-               info = g_file_query_info (file,
-                                         "time::access,time::access-usec",
-                                         G_FILE_QUERY_INFO_NONE,
-                                         NULL,
-                                         NULL);
-
-               g_object_unref (file);
-
-               if (info == NULL)
-               {
-                       g_free (uri);
-                       continue;
-               }
 
                item = gedit_open_document_selector_create_fileitem_item ();
                item->uri = uri;
 
-               /* We query access time because gtk_recent_info_get_modified() doesn't give us the usec part 
*/
-               item->access_time.tv_sec = g_file_info_get_attribute_uint64 (info, "time::access");
-               item->access_time.tv_usec = g_file_info_get_attribute_uint32 (info, "time::access-usec");
+               item->access_time.tv_sec = gtk_recent_info_get_visited (l->data);
+               item->access_time.tv_usec = 0;
 
                fileitem_list = g_list_prepend (fileitem_list, item);
-               g_object_unref (info);
        }
 
        fileitem_list = g_list_reverse (fileitem_list);
diff --git a/gedit/gedit-open-document-selector.c b/gedit/gedit-open-document-selector.c
index e61b01a..969dffa 100644
--- a/gedit/gedit-open-document-selector.c
+++ b/gedit/gedit-open-document-selector.c
@@ -387,7 +387,7 @@ fileitem_setup (FileItem *item)
 {
        gchar *scheme;
        gchar *filename;
-       gchar *normalized_filename;
+       gchar *normalized_filename = NULL;
        gchar *candidate = NULL;
        gchar *path;
        gchar *name;
@@ -408,11 +408,28 @@ fileitem_setup (FileItem *item)
 
                        normalized_filename = g_utf8_normalize (filename, -1, G_NORMALIZE_ALL);
                        g_free (filename);
-
-                       candidate = g_utf8_casefold (normalized_filename, -1);
-                       g_free (normalized_filename);
                }
        }
+       else
+       {
+               GFile *file;
+               gchar *parse_name;
+
+               file = g_file_new_for_uri (item->uri);
+               item->path = gedit_utils_location_get_dirname_for_display (file);
+               item->name  = gedit_utils_basename_for_display (file);
+               parse_name = g_file_get_parse_name (file);
+               g_object_unref (file);
+
+               normalized_filename = g_utf8_normalize (parse_name, -1, G_NORMALIZE_ALL);
+               g_free (parse_name);
+       }
+
+        if (normalized_filename)
+       {
+               candidate = g_utf8_casefold (normalized_filename, -1);
+               g_free (normalized_filename);
+       }
 
        g_free (scheme);
 


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