GtkSource.LanguageManager¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
[ |
r |
List of the ids of the available languages |
|
[ |
r/w |
List of directories where the language specification files (.lang) are located |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class GtkSource.LanguageManager(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
- 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
GtkSource.LanguageManager.get_default
() instead.
- 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
GtkSource.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 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
, 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
GtkSource.Language
for given file name and content type, according to the information in lang files. Either filename or content_type may beNone
. 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
;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
; }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
() andGtkSource.Language.get_globs
() if you need full control over file -> language mapping.New in version 2.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
GtkSource.LanguageManager
, you have to call this function right after creating it.
Property Details¶
- GtkSource.LanguageManager.props.language_ids¶
-
List of the ids of the available languages