diff options
author | TingPing <tingping@tingping.se> | 2017-03-08 23:02:10 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-03-08 23:02:10 -0500 |
commit | fe1a749ca6803057dd876f374b5296c3c800fde1 (patch) | |
tree | 44fc23bfe9a844fc06dd07c33b9512c4a1dfdabd | |
parent | 525b33c05f37625864b41c03cb95ea6b822c1ede (diff) | |
download | glib-fe1a749ca6803057dd876f374b5296c3c800fde1.tar.gz |
Create g_content_type_is_mime_type()
Convenience wrapper around g_content_type_is_a().
https://bugzilla.gnome.org/show_bug.cgi?id=734946
-rw-r--r-- | gio/gcontenttype-win32.c | 17 | ||||
-rw-r--r-- | gio/gcontenttype.c | 20 | ||||
-rw-r--r-- | gio/gcontenttype.h | 3 |
3 files changed, 40 insertions, 0 deletions
diff --git a/gio/gcontenttype-win32.c b/gio/gcontenttype-win32.c index 04d8fd38a..e50a25fc4 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 76a5b137b..d5c2b5a00 100644 --- a/gio/gcontenttype.c +++ b/gio/gcontenttype.c @@ -162,6 +162,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.52 + */ +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 647c7d730..1e5bd4729 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_52 +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 |