[gedit/gnome-3-16] OpenDocumentSelector: filter fix



commit 0a5188cffa7e3e48f34b760060ebbd874910525f
Author: Sebastien Lafargue <slafargue gnome org>
Date:   Sun Aug 30 19:30:55 2015 +0200

    OpenDocumentSelector: filter fix
    
    When loading a file from the selector with
    a filter, next recent files list in selector keeps
    this filter, even if you reset it.

 gedit/gedit-open-document-selector-store.c |   23 +++++++++++------------
 gedit/gedit-open-document-selector-store.h |    4 ++--
 gedit/gedit-open-document-selector.c       |    6 +++---
 3 files changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/gedit/gedit-open-document-selector-store.c b/gedit/gedit-open-document-selector-store.c
index 337ef51..7065bc1 100644
--- a/gedit/gedit-open-document-selector-store.c
+++ b/gedit/gedit-open-document-selector-store.c
@@ -34,9 +34,9 @@
  * in return the list of FileItem structs.
  *
  * The recent files list can be filtered by calling
- * gedit_open_document_selector_store_set_recent_filter()
+ * gedit_open_document_selector_store_set_filter()
  * and you can get the actual filter by calling
- * gedit_open_document_selector_store_get_recent_filter()
+ * gedit_open_document_selector_store_get_filter()
  * ( this is in addition to the text mime type filter)
  *
  * The recent files list is not capped by Gedit settings like
@@ -68,6 +68,7 @@ struct _GeditOpenDocumentSelectorStorePrivate
        GSource                  *recent_source;
 
        GeditRecentConfiguration  recent_config;
+       gchar                    *filter;
        GList                    *recent_items;
        gint                      recent_config_limit;
        gboolean                  recent_items_need_update;
@@ -557,10 +558,8 @@ gedit_open_document_selector_store_dispose (GObject *object)
 
        gedit_recent_configuration_destroy (&priv->recent_config);
 
-       if (priv->recent_source != NULL)
-       {
-               g_clear_pointer (&priv->recent_source, g_source_destroy);
-       }
+       g_clear_pointer (&priv->recent_source, g_source_destroy);
+       g_clear_pointer (&priv->filter, g_free);
 
        if (priv->recent_items)
        {
@@ -774,8 +773,8 @@ gedit_open_document_selector_store_get_recent_limit (GeditOpenDocumentSelectorSt
 }
 
 void
-gedit_open_document_selector_store_set_recent_filter (GeditOpenDocumentSelectorStore *store,
-                                                      gchar                          *filter)
+gedit_open_document_selector_store_set_filter (GeditOpenDocumentSelectorStore *store,
+                                               gchar                          *filter)
 {
        gchar *old_filter;
 
@@ -784,22 +783,22 @@ gedit_open_document_selector_store_set_recent_filter (GeditOpenDocumentSelectorS
 
        G_LOCK (recent_files_filter_lock);
 
-       old_filter = store->priv->recent_config.substring_filter;
-       store->priv->recent_config.substring_filter = filter;
+       old_filter = store->priv->filter;
+       store->priv->filter = g_strdup (filter);
 
        G_UNLOCK (recent_files_filter_lock);
        g_free (old_filter);
 }
 
 gchar *
-gedit_open_document_selector_store_get_recent_filter (GeditOpenDocumentSelectorStore *store)
+gedit_open_document_selector_store_get_filter (GeditOpenDocumentSelectorStore *store)
 {
        gchar *recent_filter;
 
        g_return_val_if_fail (GEDIT_IS_OPEN_DOCUMENT_SELECTOR_STORE (store), NULL);
 
        G_LOCK (recent_files_filter_lock);
-       recent_filter = g_strdup (store->priv->recent_config.substring_filter);
+       recent_filter = g_strdup (store->priv->filter);
        G_UNLOCK (recent_files_filter_lock);
 
        return recent_filter;
diff --git a/gedit/gedit-open-document-selector-store.h b/gedit/gedit-open-document-selector-store.h
index 809309c..dab67f6 100644
--- a/gedit/gedit-open-document-selector-store.h
+++ b/gedit/gedit-open-document-selector-store.h
@@ -66,10 +66,10 @@ GType                                gedit_open_document_selector_store_get_type          
                  (void) G_GNUC_CONST;
 
 gint                            gedit_open_document_selector_store_get_recent_limit                    
(GeditOpenDocumentSelectorStore *store);
 
-void                            gedit_open_document_selector_store_set_recent_filter                   
(GeditOpenDocumentSelectorStore *store,
+void                            gedit_open_document_selector_store_set_filter                          
(GeditOpenDocumentSelectorStore *store,
                                                                                                          
gchar                          *filter);
 
-gchar                          *gedit_open_document_selector_store_get_recent_filter                   
(GeditOpenDocumentSelectorStore *store);
+gchar                          *gedit_open_document_selector_store_get_filter                          
(GeditOpenDocumentSelectorStore *store);
 
 GList                          *gedit_open_document_selector_store_update_list_finish                  
(GeditOpenDocumentSelectorStore  *open_document_selector_store,
                                                                                                          
GAsyncResult                    *res,
diff --git a/gedit/gedit-open-document-selector.c b/gedit/gedit-open-document-selector.c
index 2951f52..8b237c1 100644
--- a/gedit/gedit-open-document-selector.c
+++ b/gedit/gedit-open-document-selector.c
@@ -487,7 +487,7 @@ real_populate_liststore (gpointer data)
 
        gtk_list_store_clear (priv->liststore);
 
-       filter = gedit_open_document_selector_store_get_recent_filter (selector_store);
+       filter = gedit_open_document_selector_store_get_filter (selector_store);
        if (filter && *filter != '\0')
        {
                DEBUG_SELECTOR (g_print ("Selector(%p): populate liststore: all lists\n", selector););
@@ -621,8 +621,8 @@ on_entry_changed (GtkEntry                  *entry,
        const gchar *entry_text;
 
        entry_text = gtk_entry_get_text (entry);
-       gedit_open_document_selector_store_set_recent_filter (priv->selector_store,
-                                                             g_utf8_strdown (entry_text, -1));
+       gedit_open_document_selector_store_set_filter (priv->selector_store,
+                                                      g_utf8_strdown (entry_text, -1));
 
        if (gtk_widget_get_mapped ( GTK_WIDGET (selector)))
        {


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