From 4f21fe18cbd1500e626b859861e8f47d98a97a48 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 18 May 2008 02:50:48 +0000 Subject: [PATCH] New function to create a content type from a mime type. (#527175, Milan 2008-05-17 Matthias Clasen * gcontenttype.h: * gcontenttype.c: (g_content_type_from_mime_type): New function to create a content type from a mime type. (#527175, Milan Crha) svn path=/trunk/; revision=6906 --- docs/reference/ChangeLog | 4 ++++ docs/reference/gio/gio-sections.txt | 1 + gio/gcontenttype.c | 33 +++++++++++++++++++++++++++++++++ gio/gcontenttype.h | 2 ++ gio/gio.symbols | 1 + 5 files changed, 41 insertions(+) diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 31f8a02..c14efa7 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,5 +1,9 @@ 2008-05-17 Matthias Clasen + * gio/gio-sections.txt: Add new api + +2008-05-17 Matthias Clasen + Bug 528648 – Extra >s in Object Construction section... * gobject/tut_howto.xml: Fix a formatting glitch diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt index abce363..2bd491b 100644 --- a/docs/reference/gio/gio-sections.txt +++ b/docs/reference/gio/gio-sections.txt @@ -990,6 +990,7 @@ g_content_type_get_description g_content_type_get_mime_type g_content_type_get_icon g_content_type_can_be_executable +g_content_type_from_mime_type g_content_type_guess g_content_types_get_registered diff --git a/gio/gcontenttype.c b/gio/gcontenttype.c index 69949a2..160c63d 100644 --- a/gio/gcontenttype.c +++ b/gio/gcontenttype.c @@ -222,6 +222,20 @@ looks_like_text (const guchar *data, } char * +g_content_type_from_mime_type (const char *mime_type) +{ + char *key, *content_type; + + g_return_val_if_fail (mime_type != NULL, NULL); + + key = g_strconcat ("MIME\\DataBase\\Content Type\\", mime_type, NULL); + content_type = get_registry_classes_key (key, L"Extension"); + g_free (key); + + return content_type; +} + +char * g_content_type_guess (const char *filename, const guchar *data, gsize data_size, @@ -719,6 +733,25 @@ looks_like_text (const guchar *data, gsize data_size) } /** + * g_content_type_from_mime_type: + * @mime_type: a mime type string. + * + * Tries to find a content type based on the mime type name. + * + * Returns: Newly allocated string with content type or NULL when does not know. + * + * Since: 2.18 + **/ +char * +g_content_type_from_mime_type (const char *mime_type) +{ + g_return_val_if_fail (mime_type != NULL, NULL); + + /* mime type and content type are same on unixes */ + return g_strdup (mime_type); +} + +/** * g_content_type_guess: * @filename: a string. * @data: a stream of data. diff --git a/gio/gcontenttype.h b/gio/gcontenttype.h index 9dcbf14..df03fa8 100644 --- a/gio/gcontenttype.h +++ b/gio/gcontenttype.h @@ -42,6 +42,8 @@ char * g_content_type_get_mime_type (const char *type); GIcon * g_content_type_get_icon (const char *type); gboolean g_content_type_can_be_executable (const char *type); +char * g_content_type_from_mime_type (const char *mime_type); + char * g_content_type_guess (const char *filename, const guchar *data, gsize data_size, diff --git a/gio/gio.symbols b/gio/gio.symbols index 7417bf8..5aa1b26 100644 --- a/gio/gio.symbols +++ b/gio/gio.symbols @@ -140,6 +140,7 @@ g_content_type_get_description g_content_type_get_mime_type g_content_type_get_icon g_content_type_can_be_executable +g_content_type_from_mime_type g_content_type_guess g_content_types_get_registered #endif -- 2.7.4