[glib/osx-appinfo: 2/3] Create g_content_type_is_mime_type()



commit bc90833924cb0711761cbd2cfb1bdd3b1056505b
Author: TingPing <tingping tingping se>
Date:   Thu Aug 21 04:58:37 2014 -0400

    Create g_content_type_is_mime_type()
    
    Convenience wrapper around g_content_type_is_a()

 docs/reference/gio/gio-sections.txt |    1 +
 gio/gcontenttype-win32.c            |   17 +++++++++++++++++
 gio/gcontenttype.c                  |   20 ++++++++++++++++++++
 gio/gcontenttype.h                  |    3 +++
 gio/gnextstepcontenttype.c          |   17 +++++++++++++++++
 5 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index 1257fd2..dddb1d8 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -1376,6 +1376,7 @@ g_io_error_quark
 <TITLE>GContentType</TITLE>
 g_content_type_equals
 g_content_type_is_a
+g_content_type_is_mime_type
 g_content_type_is_unknown
 g_content_type_get_description
 g_content_type_get_mime_type
diff --git a/gio/gcontenttype-win32.c b/gio/gcontenttype-win32.c
index 04d8fd3..e50a25f 100644
--- a/gio/gcontenttype-win32.c
+++ b/gio/gcontenttype-win32.c
@@ -131,6 +131,23 @@ g_content_type_is_a (const gchar *type,
 }
 
 gboolean
+g_content_type_is_mime_type (const gchar *type,
+                             const gchar *mime_type)
+{
+  gchar *content_type;
+  gboolean ret;
+
+  g_return_val_if_fail (type != NULL, FALSE);
+  g_return_val_if_fail (mime_type != NULL, FALSE);
+
+  content_type = g_content_type_from_mime_type (mime_type);
+  ret = g_content_type_is_a (type, content_type);
+  g_free (content_type);
+
+  return ret;
+}
+
+gboolean
 g_content_type_is_unknown (const gchar *type)
 {
   g_return_val_if_fail (type != NULL, FALSE);
diff --git a/gio/gcontenttype.c b/gio/gcontenttype.c
index ccdf57c..0a85597 100644
--- a/gio/gcontenttype.c
+++ b/gio/gcontenttype.c
@@ -164,6 +164,26 @@ g_content_type_is_a (const gchar *type,
 }
 
 /**
+ * g_content_type_is_mime_type:
+ * @type: a content type string
+ * @mime_type: a mime type string
+ *
+ * Determines if @type is a subset of @mime_type.
+ * Convenience wrapper around g_content_type_is_a().
+ *
+ * Returns: %TRUE if @type is a kind of @mime_type,
+ *     %FALSE otherwise.
+ *
+ * Since: 2.50
+ */
+gboolean
+g_content_type_is_mime_type (const gchar *type,
+                             const gchar *mime_type)
+{
+  return g_content_type_is_a (type, mime_type);
+}
+
+/**
  * g_content_type_is_unknown:
  * @type: a content type string
  *
diff --git a/gio/gcontenttype.h b/gio/gcontenttype.h
index 647c7d7..1677d24 100644
--- a/gio/gcontenttype.h
+++ b/gio/gcontenttype.h
@@ -35,6 +35,9 @@ gboolean g_content_type_equals            (const gchar  *type1,
 GLIB_AVAILABLE_IN_ALL
 gboolean g_content_type_is_a              (const gchar  *type,
                                            const gchar  *supertype);
+GLIB_AVAILABLE_IN_2_50
+gboolean g_content_type_is_mime_type      (const gchar *type,
+                                           const gchar *mime_type);
 GLIB_AVAILABLE_IN_ALL
 gboolean g_content_type_is_unknown        (const gchar  *type);
 GLIB_AVAILABLE_IN_ALL
diff --git a/gio/gnextstepcontenttype.c b/gio/gnextstepcontenttype.c
index 04c7439..c451299 100644
--- a/gio/gnextstepcontenttype.c
+++ b/gio/gnextstepcontenttype.c
@@ -133,6 +133,23 @@ g_content_type_is_a (const gchar *ctype,
 }
 
 gboolean
+g_content_type_is_mime_type (const gchar *type,
+                             const gchar *mime_type)
+{
+  gchar *content_type;
+  gboolean ret;
+
+  g_return_val_if_fail (type != NULL, FALSE);
+  g_return_val_if_fail (mime_type != NULL, FALSE);
+
+  content_type = g_content_type_from_mime_type (mime_type);
+  ret = g_content_type_is_a (type, content_type);
+  g_free (content_type);
+
+  return ret;
+}
+
+gboolean
 g_content_type_is_unknown (const gchar *type)
 {
   g_return_val_if_fail (type != NULL, FALSE);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]