<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
<!ENTITY tutorial SYSTEM "lang-tutorial.sgml">
<!ENTITY reference SYSTEM "lang-reference.sgml">
]>
<refentry id="GtkSourceLanguageManager">
<refmeta>
<refentrytitle role="top_of_page" id="GtkSourceLanguageManager.top_of_page">GtkSourceLanguageManager</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GTKSOURCEVIEW-2.0 Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>GtkSourceLanguageManager</refname>
<refpurpose>Object which provides access to <link linkend="GtkSourceLanguage"><type>GtkSourceLanguage</type></link><!-- -->s</refpurpose>
</refnamediv>

<refsynopsisdiv id="GtkSourceLanguageManager.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>

#include &lt;gtksourceview/gtksourcelanguagemanager.h&gt;

                    <link linkend="GtkSourceLanguageManager-struct">GtkSourceLanguageManager</link>;
<link linkend="GtkSourceLanguageManager">GtkSourceLanguageManager</link> * <link linkend="gtk-source-language-manager-new">gtk_source_language_manager_new</link>
                                                        (void);
<link linkend="GtkSourceLanguageManager">GtkSourceLanguageManager</link> * <link linkend="gtk-source-language-manager-get-default">gtk_source_language_manager_get_default</link>
                                                        (void);
<link linkend="void">void</link>                <link linkend="gtk-source-language-manager-set-search-path">gtk_source_language_manager_set_search_path</link>
                                                        (<link linkend="GtkSourceLanguageManager">GtkSourceLanguageManager</link> *lm,
                                                         <link linkend="gchar">gchar</link> **dirs);
const <link linkend="gchar">gchar</link> * const * <link linkend="gtk-source-language-manager-get-search-path">gtk_source_language_manager_get_search_path</link>
                                                        (<link linkend="GtkSourceLanguageManager">GtkSourceLanguageManager</link> *lm);
const <link linkend="gchar">gchar</link> * const * <link linkend="gtk-source-language-manager-get-language-ids">gtk_source_language_manager_get_language_ids</link>
                                                        (<link linkend="GtkSourceLanguageManager">GtkSourceLanguageManager</link> *lm);
<link linkend="GtkSourceLanguage">GtkSourceLanguage</link> * <link linkend="gtk-source-language-manager-get-language">gtk_source_language_manager_get_language</link>
                                                        (<link linkend="GtkSourceLanguageManager">GtkSourceLanguageManager</link> *lm,
                                                         const <link linkend="gchar">gchar</link> *id);
<link linkend="GtkSourceLanguage">GtkSourceLanguage</link> * <link linkend="gtk-source-language-manager-guess-language">gtk_source_language_manager_guess_language</link>
                                                        (<link linkend="GtkSourceLanguageManager">GtkSourceLanguageManager</link> *lm,
                                                         const <link linkend="gchar">gchar</link> *filename,
                                                         const <link linkend="gchar">gchar</link> *content_type);
</synopsis>
</refsynopsisdiv>

<refsect1 id="GtkSourceLanguageManager.object-hierarchy" role="object_hierarchy">
<title role="object_hierarchy.title">Object Hierarchy</title>
<synopsis>
  <link linkend="GObject">GObject</link>
   +----GtkSourceLanguageManager
</synopsis>
</refsect1>





<refsect1 id="GtkSourceLanguageManager.properties" role="properties">
<title role="properties.title">Properties</title>
<synopsis>
  &quot;<link linkend="GtkSourceLanguageManager--language-ids">language-ids</link>&quot;             <link linkend="GStrv">GStrv</link>*                : Read
  &quot;<link linkend="GtkSourceLanguageManager--search-path">search-path</link>&quot;              <link linkend="GStrv">GStrv</link>*                : Read / Write
</synopsis>
</refsect1>



<refsect1 id="GtkSourceLanguageManager.description" role="desc">
<title role="desc.title">Description</title>
<para>
<link linkend="GtkSourceLanguageManager"><type>GtkSourceLanguageManager</type></link> is an object which processes language description
files and creates and stores <link linkend="GtkSourceLanguage"><type>GtkSourceLanguage</type></link> objects, and provides API to
access them.
</para><para>Use <link linkend="gtk-source-language-manager-get-default"><function>gtk_source_language_manager_get_default()</function></link> to retrieve the default
instance of <link linkend="GtkSourceLanguageManager"><type>GtkSourceLanguageManager</type></link>, and <link linkend="gtk-source-language-manager-guess-language"><function>gtk_source_language_manager_guess_language()</function></link>
to get a <link linkend="GtkSourceLanguage"><type>GtkSourceLanguage</type></link> for given file name and content type.
</para>
</refsect1>

<refsect1 id="GtkSourceLanguageManager.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="GtkSourceLanguageManager-struct" role="struct">
<title>GtkSourceLanguageManager</title>
<indexterm zone="GtkSourceLanguageManager-struct"><primary sortas="GtkSourceLanguageManager">GtkSourceLanguageManager</primary></indexterm><programlisting>typedef struct _GtkSourceLanguageManager GtkSourceLanguageManager;</programlisting>
<para>
<structname>GtkSourceLanguageManager</structname> structure contains only
private members and should not be accessed directly.
</para></refsect2>
<refsect2 id="gtk-source-language-manager-new" role="function">
<title>gtk_source_language_manager_new ()</title>
<indexterm zone="gtk-source-language-manager-new"><primary sortas="gtk_source_language_manager_new">gtk_source_language_manager_new</primary></indexterm><programlisting><link linkend="GtkSourceLanguageManager">GtkSourceLanguageManager</link> * gtk_source_language_manager_new
                                                        (void);</programlisting>
<para>
Creates a new language manager. If you do not need more than one language
manager or a private language manager instance then use
<link linkend="gtk-source-language-manager-get-default"><function>gtk_source_language_manager_get_default()</function></link> instead.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a <link linkend="GtkSourceLanguageManager"><type>GtkSourceLanguageManager</type></link>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-source-language-manager-get-default" role="function">
<title>gtk_source_language_manager_get_default ()</title>
<indexterm zone="gtk-source-language-manager-get-default"><primary sortas="gtk_source_language_manager_get_default">gtk_source_language_manager_get_default</primary></indexterm><programlisting><link linkend="GtkSourceLanguageManager">GtkSourceLanguageManager</link> * gtk_source_language_manager_get_default
                                                        (void);</programlisting>
<para>
Returns the default <link linkend="GtkSourceLanguageManager"><type>GtkSourceLanguageManager</type></link> instance.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a <link linkend="GtkSourceLanguageManager"><type>GtkSourceLanguageManager</type></link>. Return value is owned
by GtkSourceView library and must not be unref'ed.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-source-language-manager-set-search-path" role="function">
<title>gtk_source_language_manager_set_search_path ()</title>
<indexterm zone="gtk-source-language-manager-set-search-path"><primary sortas="gtk_source_language_manager_set_search_path">gtk_source_language_manager_set_search_path</primary></indexterm><programlisting><link linkend="void">void</link>                gtk_source_language_manager_set_search_path
                                                        (<link linkend="GtkSourceLanguageManager">GtkSourceLanguageManager</link> *lm,
                                                         <link linkend="gchar">gchar</link> **dirs);</programlisting>
<para>
Sets the list of directories where the <parameter>lm</parameter> looks for
language files.
If <parameter>dirs</parameter> is <link linkend="NULL--CAPS"><literal>NULL</literal></link>, the search path is reset to default.
</para>
<para>
<note>
  <para>
    At the moment this function can be called only before the
    language files are loaded for the first time. In practice
    to set a custom search path for a <link linkend="GtkSourceLanguageManager"><type>GtkSourceLanguageManager</type></link>,
    you have to call this function right after creating it.
  </para>
</note></para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>lm</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkSourceLanguageManager"><type>GtkSourceLanguageManager</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dirs</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="NULL--CAPS"><literal>NULL</literal></link>-terminated array of strings or <link linkend="NULL--CAPS"><literal>NULL</literal></link>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-source-language-manager-get-search-path" role="function">
<title>gtk_source_language_manager_get_search_path ()</title>
<indexterm zone="gtk-source-language-manager-get-search-path"><primary sortas="gtk_source_language_manager_get_search_path">gtk_source_language_manager_get_search_path</primary></indexterm><programlisting>const <link linkend="gchar">gchar</link> * const * gtk_source_language_manager_get_search_path
                                                        (<link linkend="GtkSourceLanguageManager">GtkSourceLanguageManager</link> *lm);</programlisting>
<para>
Gets the list directories where <parameter>lm</parameter> looks for language files.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>lm</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkSourceLanguageManager"><type>GtkSourceLanguageManager</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="NULL--CAPS"><literal>NULL</literal></link>-terminated array containg a list of language files directories.
The array is owned by <parameter>lm</parameter> and must not be modified.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-source-language-manager-get-language-ids" role="function">
<title>gtk_source_language_manager_get_language_ids ()</title>
<indexterm zone="gtk-source-language-manager-get-language-ids"><primary sortas="gtk_source_language_manager_get_language_ids">gtk_source_language_manager_get_language_ids</primary></indexterm><programlisting>const <link linkend="gchar">gchar</link> * const * gtk_source_language_manager_get_language_ids
                                                        (<link linkend="GtkSourceLanguageManager">GtkSourceLanguageManager</link> *lm);</programlisting>
<para>
Returns the ids of the available languages.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>lm</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkSourceLanguageManager"><type>GtkSourceLanguageManager</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a <link linkend="NULL--CAPS"><literal>NULL</literal></link>-terminated array of string containing the ids of the
available languages or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if no language is available. The array
is owned by <parameter>lm</parameter> and must not be modified.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-source-language-manager-get-language" role="function">
<title>gtk_source_language_manager_get_language ()</title>
<indexterm zone="gtk-source-language-manager-get-language"><primary sortas="gtk_source_language_manager_get_language">gtk_source_language_manager_get_language</primary></indexterm><programlisting><link linkend="GtkSourceLanguage">GtkSourceLanguage</link> * gtk_source_language_manager_get_language
                                                        (<link linkend="GtkSourceLanguageManager">GtkSourceLanguageManager</link> *lm,
                                                         const <link linkend="gchar">gchar</link> *id);</programlisting>
<para>
Gets the <link linkend="GtkSourceLanguage"><type>GtkSourceLanguage</type></link> identified by the given <parameter>id</parameter> in the language
manager.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>lm</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkSourceLanguageManager"><type>GtkSourceLanguageManager</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>id</parameter>&#160;:</term>
<listitem><simpara> a language id.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a <link linkend="GtkSourceLanguage"><type>GtkSourceLanguage</type></link>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if there is no language
identified by the given <parameter>id</parameter>. Return value is owned by <parameter>lm</parameter> and should not
be freed.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-source-language-manager-guess-language" role="function" condition="since:2.4">
<title>gtk_source_language_manager_guess_language ()</title>
<indexterm zone="gtk-source-language-manager-guess-language" role="2.4"><primary sortas="gtk_source_language_manager_guess_language">gtk_source_language_manager_guess_language</primary></indexterm><programlisting><link linkend="GtkSourceLanguage">GtkSourceLanguage</link> * gtk_source_language_manager_guess_language
                                                        (<link linkend="GtkSourceLanguageManager">GtkSourceLanguageManager</link> *lm,
                                                         const <link linkend="gchar">gchar</link> *filename,
                                                         const <link linkend="gchar">gchar</link> *content_type);</programlisting>
<para>
Picks a <link linkend="GtkSourceLanguage"><type>GtkSourceLanguage</type></link> for given file name and content type,
according to the information in lang files. Either <parameter>filename</parameter> or
<parameter>content_type</parameter> may be <link linkend="NULL--CAPS"><literal>NULL</literal></link>. This function can be used as follows:
</para>
<para>
<informalexample><programlisting>
  GtkSourceLanguage *lang;
  lang = gtk_source_language_manager_guess_language (filename, NULL);
  gtk_source_buffer_set_language (buffer, lang);
</programlisting></informalexample>
</para>
<para>
or
</para>
<para>
<informalexample><programlisting>
  GtkSourceLanguage *lang = NULL;
  gboolean result_uncertain;
  gchar *content_type;

  content_type = g_content_type_guess (filename, NULL, 0, &amp;result_uncertain);
  if (result_uncertain)
    {
      g_free (content_type);
      content_type = NULL;
    }

  lang = gtk_source_language_manager_guess_language (manager, filename, content_type);
  gtk_source_buffer_set_language (buffer, lang);

  g_free (content_type);
</programlisting></informalexample>
</para>
<para>
etc. Use <link linkend="gtk-source-language-get-mime-types"><function>gtk_source_language_get_mime_types()</function></link> and <link linkend="gtk-source-language-get-globs"><function>gtk_source_language_get_globs()</function></link>
if you need full control over file -> language mapping.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>lm</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkSourceLanguageManager"><type>GtkSourceLanguageManager</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>filename</parameter>&#160;:</term>
<listitem><simpara> a filename in Glib filename encoding, or <link linkend="NULL--CAPS"><literal>NULL</literal></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>content_type</parameter>&#160;:</term>
<listitem><simpara> a content type (as in GIO API), or <link linkend="NULL--CAPS"><literal>NULL</literal></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a <link linkend="GtkSourceLanguage"><type>GtkSourceLanguage</type></link>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if there is no suitable language
for given <parameter>filename</parameter> and/or <parameter>content_type</parameter>. Return value is owned by <parameter>lm</parameter>
and should not be freed.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.4</para></refsect2>

</refsect1>
<refsect1 id="GtkSourceLanguageManager.property-details" role="property_details">
<title role="property_details.title">Property Details</title>
<refsect2 id="GtkSourceLanguageManager--language-ids" role="property"><title>The <literal>&quot;language-ids&quot;</literal> property</title>
<indexterm zone="GtkSourceLanguageManager--language-ids"><primary sortas="GtkSourceLanguageManager:language-ids">GtkSourceLanguageManager:language-ids</primary></indexterm><programlisting>  &quot;language-ids&quot;             <link linkend="GStrv">GStrv</link>*                : Read</programlisting>
<para>List of the ids of the available languages.</para></refsect2>
<refsect2 id="GtkSourceLanguageManager--search-path" role="property"><title>The <literal>&quot;search-path&quot;</literal> property</title>
<indexterm zone="GtkSourceLanguageManager--search-path"><primary sortas="GtkSourceLanguageManager:search-path">GtkSourceLanguageManager:search-path</primary></indexterm><programlisting>  &quot;search-path&quot;              <link linkend="GStrv">GStrv</link>*                : Read / Write</programlisting>
<para>List of directories where the language specification files (.lang) are located.</para></refsect2>
</refsect1>



<refsect1 id="GtkSourceLanguageManager.see-also">
<title>See Also</title>
<para>
<link linkend="GtkSourceLanguage"><type>GtkSourceLanguage</type></link>
</para>
</refsect1>

</refentry>
