mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-07 19:35:50 +01:00
New function to create a content type from a mime type. (#527175, Milan
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) svn path=/trunk/; revision=6906
This commit is contained in:
parent
d238669ef0
commit
4f21fe18cb
@ -1,3 +1,7 @@
|
||||
2008-05-17 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gio/gio-sections.txt: Add new api
|
||||
|
||||
2008-05-17 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Bug 528648 – Extra >s in Object Construction section...
|
||||
|
@ -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
|
||||
</SECTION>
|
||||
|
@ -221,6 +221,20 @@ looks_like_text (const guchar *data,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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,
|
||||
@ -718,6 +732,25 @@ looks_like_text (const guchar *data, gsize data_size)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user