[anjuta] file-loader: bgo #699329 - Convert mime types to content types before comparing
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] file-loader: bgo #699329 - Convert mime types to content types before comparing
- Date: Mon, 6 May 2013 20:11:53 +0000 (UTC)
commit 83344504aa7e2f9482d60710f9f5ceb0c512f4e7
Author: Arnel A. Borja <kyoushuu yahoo com>
Date: Sun Apr 28 15:13:24 2013 +0800
file-loader: bgo #699329 - Convert mime types to content types before comparing
Since the functions for converting mime types to content types are now old
enough, convert the mime types to content types before checking if the mime
type is a subtype of supported mime types of each plugins.
plugins/file-loader/plugin.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/plugins/file-loader/plugin.c b/plugins/file-loader/plugin.c
index 61f57d2..d822500 100644
--- a/plugins/file-loader/plugin.c
+++ b/plugins/file-loader/plugin.c
@@ -130,6 +130,7 @@ get_available_plugins_for_mime (AnjutaPlugin* plugin,
{
AnjutaPluginManager *plugin_manager;
GList *plugin_descs = NULL;
+ gchar *content_type;
g_return_val_if_fail (mime_type != NULL, NULL);
@@ -146,6 +147,7 @@ get_available_plugins_for_mime (AnjutaPlugin* plugin,
NULL);
/* Check for plugins supporting one supertype */
+ content_type = g_content_type_from_mime_type (mime_type);
if (plugin_descs == NULL)
{
GList *node;
@@ -172,20 +174,22 @@ get_available_plugins_for_mime (AnjutaPlugin* plugin,
for (mime = split_value; *mime != NULL; mime++)
{
- /* The following line is working on unix only where
- * content and mime type are the same. Normally the
- * mime type has to be converted to a content type.
- * But it is a recent (glib 2.18) function, I think we can
- * wait a bit to fix this */
- if (g_content_type_is_a (mime_type, *mime))
+ gchar *supertype = g_content_type_from_mime_type (*mime);
+
+ if (g_content_type_is_a (content_type, supertype))
{
gchar *loc;
anjuta_plugin_description_get_string
((AnjutaPluginDescription *)node->data,
"Anjuta Plugin", "Location", &loc);
plugin_descs = g_list_prepend (plugin_descs,
node->data);
+
+ g_free (supertype);
+
break;
}
+
+ g_free (supertype);
}
}
g_strfreev (split_value);
@@ -194,6 +198,7 @@ get_available_plugins_for_mime (AnjutaPlugin* plugin,
g_list_free (loader_descs);
plugin_descs = g_list_reverse (plugin_descs);
}
+ g_free (content_type);
return plugin_descs;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]