[gedit/zbrown/deteplification-src: 170/633] file-chooser: Use text files filter by default




commit faa4c2aa70ebb8fbd971a0beea3920330e890f6d
Author: p3732 <p3732 users noreply github com>
Date:   Wed Mar 11 11:01:37 2020 +0100

    file-chooser: Use text files filter by default
    
    Swap the order by which the filters are added, so that the "All Text Files" filter is the default one.
    
    Fixes #282

 gedit/gedit-file-chooser-dialog-gtk.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/gedit/gedit-file-chooser-dialog-gtk.c b/gedit/gedit-file-chooser-dialog-gtk.c
index a8439a306..909c4c89d 100644
--- a/gedit/gedit-file-chooser-dialog-gtk.c
+++ b/gedit/gedit-file-chooser-dialog-gtk.c
@@ -488,13 +488,14 @@ filter_changed (GeditFileChooserDialogGtk *dialog,
        filter = gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog));
        if (filter != NULL)
        {
+               /* Store ID of selected filter */
                const gchar *name;
                gint id = 0;
 
                name = gtk_file_filter_get_name (filter);
                g_return_if_fail (name != NULL);
 
-               if (strcmp (name, ALL_TEXT_FILES) == 0)
+               if (strcmp (name, ALL_FILES) == 0)
                        id = 1;
 
                gedit_debug_message (DEBUG_COMMANDS, "Active filter: %s (%d)", name, id);
@@ -640,31 +641,31 @@ gedit_file_chooser_dialog_gtk_create (const gchar             *title,
 
        if ((flags & GEDIT_FILE_CHOOSER_ENABLE_DEFAULT_FILTERS) != 0)
        {
-               /* Filters */
+               /* "All Text Files" filter */
                filter = gtk_file_filter_new ();
-
-               gtk_file_filter_set_name (filter, ALL_FILES);
-               gtk_file_filter_add_pattern (filter, "*");
+               gtk_file_filter_set_name (filter, ALL_TEXT_FILES);
+               gtk_file_filter_add_custom (filter,
+                                           GTK_FILE_FILTER_MIME_TYPE,
+                                           all_text_files_filter,
+                                           NULL,
+                                           NULL);
                gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (result), filter);
 
                if (active_filter != 1)
                {
-                       /* Make this filter the default */
+                       /* Use this filter if set by user and as default */
                        gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (result), filter);
                }
 
+               /* "All Files" filter */
                filter = gtk_file_filter_new ();
-               gtk_file_filter_set_name (filter, ALL_TEXT_FILES);
-               gtk_file_filter_add_custom (filter,
-                                           GTK_FILE_FILTER_MIME_TYPE,
-                                           all_text_files_filter,
-                                           NULL,
-                                           NULL);
+               gtk_file_filter_set_name (filter, ALL_FILES);
+               gtk_file_filter_add_pattern (filter, "*");
                gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (result), filter);
 
                if (active_filter == 1)
                {
-                       /* Make this filter the default */
+                       /* Use this filter if set by user */
                        gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (result), filter);
                }
 


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