guess_language
Description:
[ Version ( since = "2.4" ) ]
public unowned SourceLanguage? guess_language (string? filename, string? content_type)
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:
GtkSourceLanguage *lang;
lang = gtk_source_language_manager_guess_language (filename, NULL);
gtk_source_buffer_set_language (buffer, lang);
or
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);
etc. Use get_mime_types and get_globs if you need full control over file -> language mapping.
Parameters:
this | |
filename |
a filename in Glib filename encoding, or |
content_type |
a content type (as in GIO API), or |
Returns:
a SourceLanguage, or |