[gedit] gedit-recent: don't require caller to manually lowercase filter string



commit 99a802eb959f70c6c32b4e7cb266a5dccdc14dca
Author: Ray Strode <rstrode redhat com>
Date:   Thu Aug 13 15:52:52 2015 -0400

    gedit-recent: don't require caller to manually lowercase filter string
    
    gedit_recent_get_items filters out items from the recent file list that
    match a set filter string. The filter string must be explicitly
    lowercased by the caller, which is confusing.
    
    This commit changes the code to allow the caller to pass the filter
    string unmodified. gedit_recent_get_items will now implicitly lowercase
    the string on behalf of the caller.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=753481

 gedit/gedit-open-document-selector.c |    2 +-
 gedit/gedit-recent.c                 |   13 +++++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/gedit/gedit-open-document-selector.c b/gedit/gedit-open-document-selector.c
index 2f4f503..08779f2 100644
--- a/gedit/gedit-open-document-selector.c
+++ b/gedit/gedit-open-document-selector.c
@@ -622,7 +622,7 @@ on_entry_changed (GtkEntry                  *entry,
 
        entry_text = gtk_entry_get_text (entry);
        gedit_open_document_selector_store_set_recent_filter (selector->selector_store,
-                                                             g_utf8_strdown (entry_text, -1));
+                                                             g_strdup (entry_text));
 
        if (gtk_widget_get_mapped ( GTK_WIDGET (selector)))
        {
diff --git a/gedit/gedit-recent.c b/gedit/gedit-recent.c
index 0097c96..c872eac 100644
--- a/gedit/gedit-recent.c
+++ b/gedit/gedit-recent.c
@@ -207,7 +207,7 @@ gedit_recent_get_items (GeditRecentConfiguration *config)
        GList *items;
        GList *retitems = NULL;
        gint length;
-       gboolean has_substring_filter;
+       char *substring_filter = NULL;
 
        if (config->limit == 0)
        {
@@ -222,7 +222,10 @@ gedit_recent_get_items (GeditRecentConfiguration *config)
        }
 
        needed = gtk_recent_filter_get_needed (config->filter);
-       has_substring_filter = (config->substring_filter && *config->substring_filter != '\0');
+       if (config->substring_filter && *config->substring_filter != '\0')
+       {
+               substring_filter = g_utf8_strdown (config->substring_filter, -1);
+       }
 
        while (items)
        {
@@ -247,13 +250,13 @@ gedit_recent_get_items (GeditRecentConfiguration *config)
                }
                else
                {
-                       if (has_substring_filter)
+                       if (substring_filter)
                        {
                                gchar *uri_lower;
 
                                uri_lower = g_utf8_strdown (gtk_recent_info_get_uri_display (info), -1);
 
-                               if (strstr (uri_lower, config->substring_filter) == NULL)
+                               if (strstr (uri_lower, substring_filter) == NULL)
                                {
                                        is_filtered = TRUE;
                                }
@@ -291,6 +294,8 @@ gedit_recent_get_items (GeditRecentConfiguration *config)
                items = g_list_delete_link (items, items);
        }
 
+       g_free (substring_filter);
+
        if (!retitems)
        {
                return NULL;


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