guess_language


Description:

[ Version ( since = "2.4" ) ]
public unowned SourceLanguage? guess_language (string? filename, string? content_type)

Picks a SourceLanguage for given file name and content type, according to the information in lang files.

Either filename or content_type may be null. This function can be used as follows:

<informalexample><programlisting> GtkSourceLanguage *lang; lang = gtk_source_language_manager_guess_language (filename, NULL); gtk_source_buffer_set_language (buffer, lang); </programlisting></informalexample>

or

<informalexample><programlisting> GtkSourceLanguage *lang = NULL; gboolean result_uncertain; gchar *content_type;

content_type = g_content_type_guess (filename, NULL, 0, &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>

etc. Use get_mime_types and get_globs if you need full control over file -> language mapping.

Parameters:

this

a SourceLanguageManager.

filename

a filename in Glib filename encoding, or null.

content_type

a content type (as in GIO API), or null.

Returns:

a SourceLanguage, or null if there is no suitable language for given filename and/or content_type. Return value is owned by this and should not be freed.