glib r6906 - in trunk: docs/reference docs/reference/gio gio



Author: matthiasc
Date: Sun May 18 02:50:48 2008
New Revision: 6906
URL: http://svn.gnome.org/viewvc/glib?rev=6906&view=rev

Log:
2008-05-17  Matthias Clasen  <mclasen redhat com>

        * gcontenttype.h:
        * gcontenttype.c: (g_content_type_from_mime_type):
        New function to create a content type from a mime type. (#527175,
        Milan Crha)



Modified:
   trunk/docs/reference/ChangeLog
   trunk/docs/reference/gio/gio-sections.txt
   trunk/gio/gcontenttype.c
   trunk/gio/gcontenttype.h
   trunk/gio/gio.symbols

Modified: trunk/docs/reference/gio/gio-sections.txt
==============================================================================
--- trunk/docs/reference/gio/gio-sections.txt	(original)
+++ trunk/docs/reference/gio/gio-sections.txt	Sun May 18 02:50:48 2008
@@ -990,6 +990,7 @@
 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
 </SECTION>

Modified: trunk/gio/gcontenttype.c
==============================================================================
--- trunk/gio/gcontenttype.c	(original)
+++ trunk/gio/gcontenttype.c	Sun May 18 02:50:48 2008
@@ -222,6 +222,20 @@
 }
 
 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 @@
 }
 
 /**
+ * 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.

Modified: trunk/gio/gcontenttype.h
==============================================================================
--- trunk/gio/gcontenttype.h	(original)
+++ trunk/gio/gcontenttype.h	Sun May 18 02:50:48 2008
@@ -42,6 +42,8 @@
 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,

Modified: trunk/gio/gio.symbols
==============================================================================
--- trunk/gio/gio.symbols	(original)
+++ trunk/gio/gio.symbols	Sun May 18 02:50:48 2008
@@ -140,6 +140,7 @@
 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



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