[gnome-desktop] Look up mimetypes properly
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop] Look up mimetypes properly
- Date: Wed, 15 Sep 2010 11:43:56 +0000 (UTC)
commit 4e066516b2e8d8c1b074af0aa69fa1733dadca44
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Sep 15 07:41:42 2010 -0400
Look up mimetypes properly
Use GIOs g_content_type apis to unalias mimetypes before looking
them up, to avoid false negatives.
Bug 629231
libgnome-desktop/gnome-desktop-thumbnail.c | 62 +++++++++++++++------------
1 files changed, 34 insertions(+), 28 deletions(-)
---
diff --git a/libgnome-desktop/gnome-desktop-thumbnail.c b/libgnome-desktop/gnome-desktop-thumbnail.c
index e9b122d..9660307 100644
--- a/libgnome-desktop/gnome-desktop-thumbnail.c
+++ b/libgnome-desktop/gnome-desktop-thumbnail.c
@@ -611,38 +611,44 @@ gnome_desktop_thumbnail_factory_has_valid_failed_thumbnail (GnomeDesktopThumbnai
static gboolean
mimetype_supported_by_gdk_pixbuf (const char *mime_type)
{
- guint i;
- static GHashTable *formats_hash = NULL;
+ guint i;
+ static GHashTable *formats_hash = NULL;
+ gchar *key;
+ gboolean result;
- if (!formats_hash) {
- GSList *formats, *list;
-
- formats_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ if (!formats_hash) {
+ GSList *formats, *list;
- formats = gdk_pixbuf_get_formats ();
- list = formats;
-
- while (list) {
- GdkPixbufFormat *format = list->data;
- gchar **mime_types;
-
- 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));
-
- g_strfreev (mime_types);
- list = list->next;
- }
- g_slist_free (formats);
- }
+ formats_hash = g_hash_table_new_full (g_str_hash, g_content_type_equals, g_free, NULL);
+
+ formats = gdk_pixbuf_get_formats ();
+ list = formats;
+
+ while (list) {
+ GdkPixbufFormat *format = list->data;
+ gchar **mime_types;
+
+ 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_content_type_from_mime_type (mime_types[i]),
+ GUINT_TO_POINTER (1));
+
+ g_strfreev (mime_types);
+ list = list->next;
+ }
+ g_slist_free (formats);
+ }
- if (g_hash_table_lookup (formats_hash, mime_type))
- return TRUE;
+ key = g_content_type_from_mime_type (mime_type);
+ if (g_hash_table_lookup (formats_hash, key))
+ result = TRUE;
+ else
+ result = FALSE;
+ g_free (key);
- return FALSE;
+ return result;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]