GtkSource.LanguageManager¶
| Subclasses: | None | 
|---|
Methods¶
| Inherited: | GObject.Object (37) | 
|---|---|
| Structs: | GObject.ObjectClass (5) | 
| class | get_default() | 
| class | new() | 
| get_language(id) | |
| get_language_ids() | |
| get_search_path() | |
| guess_language(filename, content_type) | |
| set_search_path(dirs) | 
Virtual Methods¶
| Inherited: | GObject.Object (7) | 
|---|
Properties¶
| Name | Type | Flags | Short Description | 
|---|---|---|---|
| language-ids | [ str] | r | List of the ids of the available languages | 
| search-path | [ str] | r/w | List of directories where the language specification files (.lang) are located | 
Signals¶
| Inherited: | GObject.Object (1) | 
|---|
Class Details¶
- 
class GtkSource.LanguageManager(**kwargs)¶
- Bases: - GObject.Object- Abstract: - No - Structure: - GtkSource.LanguageManagerClass- 
classmethod get_default()¶
- Returns: - a - GtkSource.LanguageManager. Return value is owned by- GtkSource.Viewlibrary and must not be unref’ed.- Return type: - GtkSource.LanguageManager- Returns the default - GtkSource.LanguageManagerinstance.
 - 
classmethod new()¶
- Returns: - a new - GtkSource.LanguageManager.- Return type: - GtkSource.LanguageManager- Creates a new language manager. If you do not need more than one language manager or a private language manager instance then use - GtkSource.LanguageManager.get_default() instead.
 - 
get_language(id)¶
- Parameters: - id ( - str) – a language id.- Returns: - a - GtkSource.Language, or- Noneif there is no language identified by the given id. Return value is owned by self and should not be freed.- Return type: - GtkSource.Languageor- None- Gets the - GtkSource.Languageidentified by the given id in the language manager.
 - 
get_language_ids()¶
- Returns: - a - None-terminated array of strings containing the ids of the available languages or- Noneif no language is available. The array is sorted alphabetically according to the language name. The array is owned by self and must not be modified.- Return type: - [ - str] or- None- Returns the ids of the available languages. 
 - 
get_search_path()¶
- Returns: - None-terminated array containg a list of language files directories. The array is owned by self and must not be modified.- Return type: - [ - str]- Gets the list directories where self looks for language files. 
 - 
guess_language(filename, content_type)¶
- Parameters: - Returns: - a - GtkSource.Language, or- Noneif there is no suitable language for given filename and/or content_type. Return value is owned by self and should not be freed.- Return type: - Picks a - GtkSource.Languagefor given file name and content type, according to the information in lang files. Either filename or content_type may be- None. This function can be used as follows:- <informalexample><programlisting> - GtkSource.Language*lang; lang =- GtkSource.LanguageManager.guess_language(filename,- None);- GtkSource.Buffer.set_language(buffer, lang); </programlisting></informalexample>- or - <informalexample><programlisting> - GtkSource.Language*lang =- None;- boolresult_uncertain;- str*content_type;- content_type = - Gio.content_type_guess(filename,- None, 0, &result_uncertain); if (result_uncertain) {- GLib.free(content_type); content_type =- None; }- lang = - GtkSource.LanguageManager.guess_language(manager, filename, content_type);- GtkSource.Buffer.set_language(buffer, lang);- GLib.free(content_type); </programlisting></informalexample>- etc. Use - GtkSource.Language.get_mime_types() and- GtkSource.Language.get_globs() if you need full control over file -> language mapping.- New in version 2.4. 
 - 
set_search_path(dirs)¶
- Parameters: - dirs ([ - str] or- None) – a- None-terminated array of strings or- None.- Sets the list of directories where the self looks for language files. If dirs is - None, the search path is reset to default.- 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 - GtkSource.LanguageManager, you have to call this function right after creating it.
 
- 
classmethod