[gedit] FileChooser: simplify the custom filter (still equivalent)



commit cdc337b0c6ad29b584d9148261e829a7d9957e2c
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Jun 8 23:06:57 2020 +0200

    FileChooser: simplify the custom filter (still equivalent)
    
    This will permit to rewrite the custom filter as a filter using only
    mimetypes. This will be useful for using the filter with a
    GtkFileChooserNative.
    
    The comment uses the // style, to avoid this compilation warning:
    warning: "/*" within comment [-Wcomment]

 gedit/gedit-file-chooser.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/gedit/gedit-file-chooser.c b/gedit/gedit-file-chooser.c
index dffa1802a..235f70a19 100644
--- a/gedit/gedit-file-chooser.c
+++ b/gedit/gedit-file-chooser.c
@@ -97,22 +97,16 @@ all_text_files_filter (const GtkFileFilterInfo *filter_info,
                return FALSE;
        }
 
-       /* The filter is matching:
-        * - the mime-types beginning with "text/".
-        * - the mime-types inheriting from a supported mime-type (note that
-        *   "text/plain" is the first supported mime-type).
-        */
-
-       if (g_str_has_prefix (filter_info->mime_type, "text/"))
-       {
-               return TRUE;
-       }
-
        supported_mime_types = get_supported_mime_types ();
        for (l = supported_mime_types; l != NULL; l = l->next)
        {
                const gchar *cur_supported_mime_type = l->data;
 
+               // Note that "text/plain" is the first supported mime-type in
+               // the list.
+               //
+               // All "text/*" types are subclasses of "text/plain", see:
+               // 
https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html#subclassing
                if (g_content_type_is_a (filter_info->mime_type, cur_supported_mime_type))
                {
                        return TRUE;


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