After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 629231 - ICO MIME type "regression"
ICO MIME type "regression"
Status: RESOLVED FIXED
Product: gnome-desktop
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Desktop Maintainers
Desktop Maintainers
: 545133 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-09-10 03:49 UTC by Damjan Jovanovic
Modified: 2012-06-22 10:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add the "image/vnd.microsoft.icon" MIME type to the ICO loader (299 bytes, text/plain)
2010-09-10 03:49 UTC, Damjan Jovanovic
  Details
untested patch (1.42 KB, patch)
2010-09-14 23:45 UTC, Matthias Clasen
accepted-commit_after_freeze Details | Review

Description Damjan Jovanovic 2010-09-10 03:49:02 UTC
Created attachment 169921 [details]
Add the "image/vnd.microsoft.icon" MIME type to the ICO loader

The FreeDesktop.org shared MIME database now identifies .ico files as "image/vnd.microsoft.icon", and since gdk-pixbuf doesn't list that as a MIME type, libgnome-desktop no longer wants to thumbnail .ico files, and (at least) Nautilus thus displays no thumbnail for .ico files.

The attached 1 line patch adds "image/vnd.microsoft.icon" to the MIME types listed by the gdk-pixbuf ICO loader and fixes the problem.

On http://mail.gnome.org/archives/gtk-devel-list/2010-September/msg00134.html it was suggested that this fix is wrong or incomplete, because the calling code should be able to handle MIME type aliases if the main MIME type changes.

But:
* Both Nautilus (libnautilus-private/nautilus-thumbnails.c: nautilus_can_thumbnail_internally() -> pixbuf_can_load_type() -> get_types_table()) AND gnome-desktop (libgnome-desktop/gnome-desktop-thumbnail.c: gnome_desktop_thumbnail_factory_can_thumbnail() -> mimetype_supported_by_gdk_pixbuf()) do plain g_hash_table_lookup() calls to find the MIME type using an exact match; there is no g_content_type_equals().
* If the intention in gdk-pixbuf was to have the caller find all MIME aliases on the calling side, why return more than 1 MIME type? It looks to me like the intention was to provide all MIME types, main and aliases, so the caller could do a strcmp().
* Even if gdk-pixbuf isn't supposed to provide aliases, it currently only provides aliases - the new main type "image/vnd.microsoft.icon" is not even listed.
Comment 1 Matthias Clasen 2010-09-10 11:12:44 UTC
it should be enough to replace 

                        if (g_ascii_strcasecmp (type, mime_type) == 0) {

in gdk-pixbuf-io.c:805 with g_content_type_equals

Can you test if that fixes your problem ?
Comment 2 Alexander Larsson 2010-09-10 16:33:30 UTC
Remember that content types are not mimetypes on windows.
Comment 3 Damjan Jovanovic 2010-09-11 11:13:47 UTC
g_content_type_equals() does not fix the problem:

In Nautilus, the MIME type must first pass the nautilus_can_thumbnail() test (libnautilus-private/nautilus-file.c function nautilus_file_get_icon) before an attempt to thumbnail it is even made.

nautilus_can_thumbnail() delegates to gnome_desktop_thumbnail_factory_can_thumbnail(), which fails for reasons explained in the initial bug comment; to recap, it calls mimetype_supported_by_gdk_pixbuf(), which does this:



formats = gdk_pixbuf_get_formats ();
list = formats;
                
while (list) {
    mime_types = gdk_pixbuf_format_get_mime_types (format);
    for (i = 0; mime_types[i] != NULL; i++)
        g_hash_table_insert (formats_hash,
                             (gpointer) g_strdup (mime_types[i]),
                             GUINT_TO_POINTER (1));
    list = list->next;
}

if (g_hash_table_lookup (formats_hash, mime_type))
    return TRUE;

return FALSE;



The exact g_hash_table_lookup() comparison does an exact match, which is what causes the problem.

But again, Nautilus does something similar to libgnome-desktop for internal thumbnailing. It's likely other applications also do exact matches. Should we be fixing all clients of gdk-pixbuf, or just adding a new MIME type to gdk-pixbuf itself?
Comment 4 Matthias Clasen 2010-09-14 13:13:47 UTC
We should be fixing the clients to use the GIO api properly, certainly.
Comment 5 Matthias Clasen 2010-09-14 23:45:13 UTC
I've changed gdk-pixbuf to use g_content_type_equals. Moving this bug to gdk-pixbuf to fix that mime type hash.
Comment 6 Matthias Clasen 2010-09-14 23:45:52 UTC
Created attachment 170305 [details] [review]
untested patch
Comment 7 Matthias Clasen 2010-09-14 23:47:14 UTC
Here is an untested patch to make gnome_desktop_thumbnail use g_content_type_equals when checking if a mimetype is supported.
Comment 8 Vincent Untz 2010-09-15 00:43:57 UTC
Comment on attachment 170305 [details] [review]
untested patch

Can someone test this? If it works fine, please commit to master, and ask the release team for freeze break approval.

(Note: the patch is mixing tabs and spaces)
Comment 9 Damjan Jovanovic 2010-09-15 05:15:29 UTC
The libgnome-desktop patch works, thank you.
Comment 10 Matthias Clasen 2010-09-15 13:02:18 UTC
Committed to master and gnome-2-32
Comment 11 Bastien Nocera 2012-06-22 10:15:47 UTC
*** Bug 545133 has been marked as a duplicate of this bug. ***