guessLanguage
Picks a class@Language 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:
GtkSourceLanguage *lang;
GtkSourceLanguageManager *manager;
lm = gtk_source_language_manager_get_default ();
lang = gtk_source_language_manager_guess_language (manager, filename, NULL);
gtk_source_buffer_set_language (buffer, lang);
Content copied to clipboard
or
GtkSourceLanguage *lang = NULL;
GtkSourceLanguageManager *manager;
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;
}
manager = gtk_source_language_manager_get_default ();
lang = gtk_source_language_manager_guess_language (manager, filename, content_type);
gtk_source_buffer_set_language (buffer, lang);
g_free (content_type);
Content copied to clipboard
etc. Use method@Language.get_mime_types and method@Language.get_globs if you need full control over file -> language mapping.
Return
a #GtkSourceLanguage, or null if there is no suitable language for given @filename and/or @content_type. Return value is owned by @lm and should not be freed.
Parameters
filename
a filename in Glib filename encoding, or null.
contentType
a content type (as in GIO API), or null.