From 85310bff461d260fe89586f001d01d3eabb720e2 Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Tue, 21 May 2024 23:15:01 -0400 Subject: [PATCH] xapp-icon-chooser-dialog.c: Fix mimetype test for browsed images. When browsing for an image file, png files weren't being added to the icon view because of uncertainty from g_content_type_guess(). This function's mimetype lookup was returning both image/png and image/apng (animated png). Since g_content_type_guess only tests the file's path and not its contents, having two possible values resulted in the uncertainty. Lookup the content type in the file's GFileInfo instead. Fixes: #182 --- libxapp/xapp-icon-chooser-dialog.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libxapp/xapp-icon-chooser-dialog.c b/libxapp/xapp-icon-chooser-dialog.c index 69c8360..13257e0 100644 --- a/libxapp/xapp-icon-chooser-dialog.c +++ b/libxapp/xapp-icon-chooser-dialog.c @@ -1645,12 +1645,15 @@ search_path (XAppIconChooserDialog *dialog, { priv->current_category = NULL; - gchar *content_type; - gboolean uncertain; + const gchar *content_type; - content_type = g_content_type_guess (child_name, NULL, 0, &uncertain); + content_type = g_file_info_get_attribute_string (child_info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE); + if (content_type == NULL) + { + content_type = g_file_info_get_attribute_string (child_info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE); + } - if (content_type && g_str_has_prefix (content_type, "image") && !uncertain) + if (content_type && g_content_type_is_a (content_type, "image/*")) { GFileInputStream *stream; @@ -1692,8 +1695,6 @@ search_path (XAppIconChooserDialog *dialog, } } } - - g_free (content_type); } g_free (child_path);