Skip to content

Commit

Permalink
xapp-icon-chooser-dialog.c: Fix mimetype test for browsed images.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mtwebster committed May 22, 2024
1 parent 6b6e78d commit 85310bf
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions libxapp/xapp-icon-chooser-dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1692,8 +1695,6 @@ search_path (XAppIconChooserDialog *dialog,
}
}
}

g_free (content_type);
}

g_free (child_path);
Expand Down

0 comments on commit 85310bf

Please sign in to comment.