[gnome-autoar] mime-types: Use g_content_type_equals to check for alias
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-autoar] mime-types: Use g_content_type_equals to check for alias
- Date: Fri, 12 Feb 2021 07:02:09 +0000 (UTC)
commit 7fe4af4037e11fa447e8447431aaa716e49c88c8
Author: Hernawan Fa'iz Abdillah <hernawan faiz abdillah gmail com>
Date: Fri Feb 12 06:06:46 2021 +0700
mime-types: Use g_content_type_equals to check for alias
Autoar can't detect archive with non-standard unsupported content type
that actually an alias of existing type supported.
To avoid listing all those alias, instead, we check
for similar type through g_content_type_equals.
Fixes #8
gnome-autoar/autoar-mime-types.c | 24 +++++-------------------
1 file changed, 5 insertions(+), 19 deletions(-)
---
diff --git a/gnome-autoar/autoar-mime-types.c b/gnome-autoar/autoar-mime-types.c
index d288c71..e1013cb 100644
--- a/gnome-autoar/autoar-mime-types.c
+++ b/gnome-autoar/autoar-mime-types.c
@@ -48,22 +48,6 @@ static gchar *supported_mime_types[] = {
NULL
};
-static GHashTable *supported_mime_types_table = NULL;
-
-static void
-initialize_supported_mime_types_table (void)
-{
- int i;
-
- supported_mime_types_table = g_hash_table_new (g_str_hash,
- g_str_equal);
-
- for (i = 0; supported_mime_types[i] != NULL; ++i) {
- g_hash_table_add (supported_mime_types_table,
- supported_mime_types[i]);
- }
-}
-
/**
* autoar_check_mime_type_supported:
* @mime_type: a string representing the mime type
@@ -76,11 +60,13 @@ initialize_supported_mime_types_table (void)
gboolean
autoar_check_mime_type_supported (const gchar *mime_type)
{
- if (supported_mime_types_table == NULL) {
- initialize_supported_mime_types_table ();
+ gint i;
+ for (i = 0; supported_mime_types[i] != NULL; ++i) {
+ if (g_content_type_equals (supported_mime_types[i], mime_type))
+ return TRUE;
}
- return g_hash_table_contains (supported_mime_types_table, mime_type);
+ return FALSE;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]