GtkSource.LanguageManager¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
[ |
r/en |
List of the ids of the available languages |
|
[ |
r/w/en |
List of directories where the language specification files (.lang) are located |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class GtkSource.LanguageManager(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Provides access to [class`Language`]s.
GtkSourceLanguageManager
is an object which processes language description files and creates and stores [class`Language`] objects, and provides API to access them.Use [func`LanguageManager`.get_default] to retrieve the default instance of
GtkSourceLanguageManager
, and [method`LanguageManager`.guess_language] to get a [class`Language`] for given file name and content type.- classmethod get_default()¶
- Returns:
a
GtkSource.LanguageManager
. Return value is owned byGtkSource.View
library and must not be unref’ed.- Return type:
Returns the default
GtkSource.LanguageManager
instance.
- classmethod new()¶
- Returns:
a new
GtkSource.LanguageManager
.- Return type:
Creates a new language manager.
If you do not need more than one language manager or a private language manager instance then use [func`LanguageManager`.get_default] instead.
- append_search_path(path)¶
- Parameters:
path (
str
) – a directory or a filename.
Appends path to the list of directories where the manager looks for language files.
See [method`LanguageManager`.set_search_path] for details.
New in version 5.4.
- get_language(id)¶
- Parameters:
id (
str
) – a language id.- Returns:
a
GtkSource.Language
, orNone
if there is no language identified by the given id. Return value is owned by self and should not be freed.- Return type:
Gets the [class`Language`] identified 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 orNone
if 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:
Returns the ids of the available languages.
- get_search_path()¶
- Returns:
None
-terminated array containing 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
, orNone
if 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 [class`Language`] for 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:``c 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); ``
or
```c
GtkSource.Language
*lang =None
;GtkSource.LanguageManager
*manager;bool
result_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
; }manager =
GtkSource.LanguageManager.get_default
(); lang =GtkSource.LanguageManager.guess_language
(manager, filename, content_type);GtkSource.Buffer.set_language
(buffer, lang);GLib.free
(content_type); ```etc. Use [method`Language`.get_mime_types] and [method`Language`.get_globs] if you need full control over file -> language mapping.
- prepend_search_path(path)¶
- Parameters:
path (
str
) – a directory or a filename.
Prepends path to the list of directories where the manager looks for language files.
See [method`LanguageManager`.set_search_path] for details.
New in version 5.4.
- set_search_path(dirs)¶
-
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
GtkSourceLanguageManager
, you have to call this function right after creating it.Since
GtkSource.View
5.4 this function will allow you to provide paths in the form of “resource:///” URIs to embeddedGResource``s. They must contain the path of a directory within the ``GResource
.
Property Details¶
- GtkSource.LanguageManager.props.language_ids¶
- Name:
language-ids
- Type:
[
str
]- Default Value:
[]
- Flags:
List of the ids of the available languages