blob: 5f84a14bff88a87d24cbeeed5a1602eabb98d919 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GContentType</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="GIO Reference Manual">
<link rel="up" href="types.html" title="File types and applications">
<link rel="prev" href="types.html" title="File types and applications">
<link rel="next" href="GAppInfo.html" title="GAppInfo">
<meta name="generator" content="GTK-Doc V1.14 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="types.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="types.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GIO Reference Manual</th>
<td><a accesskey="n" href="GAppInfo.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#gio-GContentType.synopsis" class="shortcut">Top</a>
 | 
<a href="#gio-GContentType.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry" title="GContentType">
<a name="gio-GContentType"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="gio-GContentType.top_of_page"></a>GContentType</span></h2>
<p>GContentType — Platform-specific content typing</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv" title="Synopsis">
<a name="gio-GContentType.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;gio/gio.h&gt;
<a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="gio-GContentType.html#g-content-type-equals" title="g_content_type_equals ()">g_content_type_equals</a> (<em class="parameter"><code>const <span class="type">char</span> *type1</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *type2</code></em>);
<a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="gio-GContentType.html#g-content-type-is-a" title="g_content_type_is_a ()">g_content_type_is_a</a> (<em class="parameter"><code>const <span class="type">char</span> *type</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *supertype</code></em>);
<a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="gio-GContentType.html#g-content-type-is-unknown" title="g_content_type_is_unknown ()">g_content_type_is_unknown</a> (<em class="parameter"><code>const <span class="type">char</span> *type</code></em>);
<span class="returnvalue">char</span> * <a class="link" href="gio-GContentType.html#g-content-type-get-description" title="g_content_type_get_description ()">g_content_type_get_description</a> (<em class="parameter"><code>const <span class="type">char</span> *type</code></em>);
<span class="returnvalue">char</span> * <a class="link" href="gio-GContentType.html#g-content-type-get-mime-type" title="g_content_type_get_mime_type ()">g_content_type_get_mime_type</a> (<em class="parameter"><code>const <span class="type">char</span> *type</code></em>);
<a class="link" href="GIcon.html" title="GIcon"><span class="returnvalue">GIcon</span></a> * <a class="link" href="gio-GContentType.html#g-content-type-get-icon" title="g_content_type_get_icon ()">g_content_type_get_icon</a> (<em class="parameter"><code>const <span class="type">char</span> *type</code></em>);
<a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="gio-GContentType.html#g-content-type-can-be-executable" title="g_content_type_can_be_executable ()">g_content_type_can_be_executable</a> (<em class="parameter"><code>const <span class="type">char</span> *type</code></em>);
<span class="returnvalue">char</span> * <a class="link" href="gio-GContentType.html#g-content-type-from-mime-type" title="g_content_type_from_mime_type ()">g_content_type_from_mime_type</a> (<em class="parameter"><code>const <span class="type">char</span> *mime_type</code></em>);
<span class="returnvalue">char</span> * <a class="link" href="gio-GContentType.html#g-content-type-guess" title="g_content_type_guess ()">g_content_type_guess</a> (<em class="parameter"><code>const <span class="type">char</span> *filename</code></em>,
<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *data</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> data_size</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> *result_uncertain</code></em>);
<span class="returnvalue">char</span> ** <a class="link" href="gio-GContentType.html#g-content-type-guess-for-tree" title="g_content_type_guess_for_tree ()">g_content_type_guess_for_tree</a> (<em class="parameter"><code><a class="link" href="GFile.html" title="GFile"><span class="type">GFile</span></a> *root</code></em>);
<a href="/usr/share/gtk-doc/html/glib/glib-Doubly-Linked-Lists.html#GList"><span class="returnvalue">GList</span></a> * <a class="link" href="gio-GContentType.html#g-content-types-get-registered" title="g_content_types_get_registered ()">g_content_types_get_registered</a> (<em class="parameter"><code><span class="type">void</span></code></em>);
</pre>
</div>
<div class="refsect1" title="Description">
<a name="gio-GContentType.description"></a><h2>Description</h2>
<p>
A content type is a platform specific string that defines the type
of a file. On unix it is a mime type, on win32 it is an extension string
like ".doc", ".txt" or a percieved string like "audio". Such strings
can be looked up in the registry at HKEY_CLASSES_ROOT.
</p>
</div>
<div class="refsect1" title="Details">
<a name="gio-GContentType.details"></a><h2>Details</h2>
<div class="refsect2" title="g_content_type_equals ()">
<a name="g-content-type-equals"></a><h3>g_content_type_equals ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_content_type_equals (<em class="parameter"><code>const <span class="type">char</span> *type1</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *type2</code></em>);</pre>
<p>
Compares two content types for equality.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>type1</code></em> :</span></p></td>
<td>a content type string.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type2</code></em> :</span></p></td>
<td>a content type string.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the two strings are identical or equivalent,
<a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_content_type_is_a ()">
<a name="g-content-type-is-a"></a><h3>g_content_type_is_a ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_content_type_is_a (<em class="parameter"><code>const <span class="type">char</span> *type</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *supertype</code></em>);</pre>
<p>
Determines if <em class="parameter"><code>type</code></em> is a subset of <em class="parameter"><code>supertype</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>a content type string.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>supertype</code></em> :</span></p></td>
<td>a string.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if <em class="parameter"><code>type</code></em> is a kind of <em class="parameter"><code>supertype</code></em>,
<a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_content_type_is_unknown ()">
<a name="g-content-type-is-unknown"></a><h3>g_content_type_is_unknown ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_content_type_is_unknown (<em class="parameter"><code>const <span class="type">char</span> *type</code></em>);</pre>
<p>
Checks if the content type is the generic "unknown" type.
On unix this is the "application/octet-stream" mimetype,
while on win32 it is "*".
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>a content type string.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the type is the unknown type.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_content_type_get_description ()">
<a name="g-content-type-get-description"></a><h3>g_content_type_get_description ()</h3>
<pre class="programlisting"><span class="returnvalue">char</span> * g_content_type_get_description (<em class="parameter"><code>const <span class="type">char</span> *type</code></em>);</pre>
<p>
Gets the human readable description of the content type.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>a content type string.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> a short description of the content type <em class="parameter"><code>type</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_content_type_get_mime_type ()">
<a name="g-content-type-get-mime-type"></a><h3>g_content_type_get_mime_type ()</h3>
<pre class="programlisting"><span class="returnvalue">char</span> * g_content_type_get_mime_type (<em class="parameter"><code>const <span class="type">char</span> *type</code></em>);</pre>
<p>
Gets the mime-type for the content type. If one is registered
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>a content type string.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> the registered mime-type for the given <em class="parameter"><code>type</code></em>, or NULL if unknown.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_content_type_get_icon ()">
<a name="g-content-type-get-icon"></a><h3>g_content_type_get_icon ()</h3>
<pre class="programlisting"><a class="link" href="GIcon.html" title="GIcon"><span class="returnvalue">GIcon</span></a> * g_content_type_get_icon (<em class="parameter"><code>const <span class="type">char</span> *type</code></em>);</pre>
<p>
Gets the icon for a content type.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>a content type string.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> <a class="link" href="GIcon.html" title="GIcon"><span class="type">GIcon</span></a> corresponding to the content type.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_content_type_can_be_executable ()">
<a name="g-content-type-can-be-executable"></a><h3>g_content_type_can_be_executable ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_content_type_can_be_executable (<em class="parameter"><code>const <span class="type">char</span> *type</code></em>);</pre>
<p>
Checks if a content type can be executable. Note that for instance
things like text files can be executables (i.e. scripts and batch files).
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>a content type string.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the file type corresponds to a type that
can be executable, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_content_type_from_mime_type ()">
<a name="g-content-type-from-mime-type"></a><h3>g_content_type_from_mime_type ()</h3>
<pre class="programlisting"><span class="returnvalue">char</span> * g_content_type_from_mime_type (<em class="parameter"><code>const <span class="type">char</span> *mime_type</code></em>);</pre>
<p>
Tries to find a content type based on the mime type name.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>mime_type</code></em> :</span></p></td>
<td>a mime type string.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> Newly allocated string with content type or NULL when does not know.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.18</p>
</div>
<hr>
<div class="refsect2" title="g_content_type_guess ()">
<a name="g-content-type-guess"></a><h3>g_content_type_guess ()</h3>
<pre class="programlisting"><span class="returnvalue">char</span> * g_content_type_guess (<em class="parameter"><code>const <span class="type">char</span> *filename</code></em>,
<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar"><span class="type">guchar</span></a> *data</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> data_size</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> *result_uncertain</code></em>);</pre>
<p>
Guesses the content type based on example data. If the function is
uncertain, <em class="parameter"><code>result_uncertain</code></em> will be set to <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>. Either <em class="parameter"><code>filename</code></em>
or <em class="parameter"><code>data</code></em> may be <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, in which case the guess will be based solely
on the other argument.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
<td>a string, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>a stream of data, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data_size</code></em> :</span></p></td>
<td>the size of <em class="parameter"><code>data</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>result_uncertain</code></em> :</span></p></td>
<td>a flag indicating the certainty of the result
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> a string indicating a guessed content type for the
given data.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_content_type_guess_for_tree ()">
<a name="g-content-type-guess-for-tree"></a><h3>g_content_type_guess_for_tree ()</h3>
<pre class="programlisting"><span class="returnvalue">char</span> ** g_content_type_guess_for_tree (<em class="parameter"><code><a class="link" href="GFile.html" title="GFile"><span class="type">GFile</span></a> *root</code></em>);</pre>
<p>
Tries to guess the type of the tree with root <em class="parameter"><code>root</code></em>, by
looking at the files it contains. The result is an array
of content types, with the best guess coming first.
</p>
<p>
The types returned all have the form x-content/foo, e.g.
x-content/audio-cdda (for audio CDs) or x-content/image-dcf
(for a camera memory card). See the <a class="ulink" href="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec" target="_top">shared-mime-info</a>
specification for more on x-content types.
</p>
<p>
This function is useful in the implementation of <a class="link" href="GMount.html#g-mount-guess-content-type" title="g_mount_guess_content_type ()"><code class="function">g_mount_guess_content_type()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>root</code></em> :</span></p></td>
<td>the root of the tree to guess a type for
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> an <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>-terminated array of zero or more content types, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
Free with <a href="/usr/share/gtk-doc/html/glib/glib-String-Utility-Functions.html#g-strfreev"><code class="function">g_strfreev()</code></a>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.18</p>
</div>
<hr>
<div class="refsect2" title="g_content_types_get_registered ()">
<a name="g-content-types-get-registered"></a><h3>g_content_types_get_registered ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Doubly-Linked-Lists.html#GList"><span class="returnvalue">GList</span></a> * g_content_types_get_registered (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Gets a list of strings containing all the registered content types
known to the system. The list and its data should be freed using
<em class="parameter"><code>g_list_foreach</code></em>(list, g_free, NULL) and <em class="parameter"><code>g_list_free</code></em>(list)
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> <a href="/usr/share/gtk-doc/html/glib/glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> of the registered content types.
</td>
</tr></tbody>
</table></div>
</div>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.14</div>
</body>
</html>