Class LanguageManager
- All Implemented Interfaces:
Proxy
Languages.
GtkSourceLanguageManager is an object which processes language description
files and creates and stores Language objects, and provides API to
access them.
Use getDefault() to retrieve the default
instance of GtkSourceLanguageManager, and
guessLanguage(java.lang.String, java.lang.String) to get a Language for
given file name and content type.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classLanguageManager.Builder<B extends LanguageManager.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new LanguageManager.LanguageManager(MemorySegment address) Create a LanguageManager proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendSearchPath(String path) Appendspathto the list of directories where themanagerlooks for language files.protected LanguageManagerasParent()Returns this instance as if it were its parent type.static LanguageManager.Builder<? extends LanguageManager.Builder> builder()ALanguageManager.Builderobject constructs aLanguageManagerwith the specified properties.static LanguageManagerReturns the defaultGtkSourceLanguageManagerinstance.@Nullable LanguagegetLanguage(String id) Gets theLanguageidentified by the givenidin the language manager.@Nullable String @Nullable []Returns the ids of the available languages.String[]Gets the list directories where this LanguageManager looks for language files.static @Nullable TypegetType()Get the GType of the LanguageManager class@Nullable LanguageguessLanguage(@Nullable String filename, @Nullable String contentType) Picks aLanguagefor given file name and content type, according to the information in lang files.voidprependSearchPath(String path) Prependspathto the list of directories where themanagerlooks for language files.voidsetSearchPath(@Nullable String @Nullable [] dirs) Sets the list of directories where the this LanguageManager looks for language files.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
LanguageManager
Create a LanguageManager proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
LanguageManager
public LanguageManager()Creates a new LanguageManager.
-
-
Method Details
-
getType
Get the GType of the LanguageManager class- Returns:
- the GType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getDefault
Returns the defaultGtkSourceLanguageManagerinstance.- Returns:
- a
GtkSourceLanguageManager. Return value is owned by GtkSourceView library and must not be unref'ed.
-
appendSearchPath
Appendspathto the list of directories where themanagerlooks for language files.See
setSearchPath(java.lang.String[])for details.- Parameters:
path- a directory or a filename.- Since:
- 5.4
-
getLanguage
Gets theLanguageidentified by the givenidin the language manager.- Parameters:
id- a language id.- Returns:
- a
GtkSourceLanguage, ornullif there is no language identified by the givenid.Return value is owned by this LanguageManager and should not be freed.
-
getLanguageIds
Returns the ids of the available languages.- Returns:
- a
null-terminated array of strings containing the ids of the available languages ornullif no language is available. The array is sorted alphabetically according to the language name. The array is owned by this LanguageManager and must not be modified.
-
getSearchPath
Gets the list directories where this LanguageManager looks for language files.- Returns:
null-terminated array containing a list of language files directories. The array is owned by this LanguageManager and must not be modified.
-
guessLanguage
Picks aLanguagefor given file name and content type, according to the information in lang files.Either
filenameorcontentTypemay benull. 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);manager = GtkSource.LanguageManager.get_default() language = manager.guess_language(filename=filename, content_type=None) buffer.set_language(language=language)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_type, uncertain = Gio.content_type_guess(filename=filename, data=None) if uncertain: content_type = None manager = GtkSource.LanguageManager.get_default() language = manager.guess_language(filename=filename, content_type=content_type) buffer.set_language(language=language)etc. Use
Language.getMimeTypes()andLanguage.getGlobs()if you need full control over file -> language mapping.- Parameters:
filename- a filename in Glib filename encoding, ornull.contentType- a content type (as in GIO API), ornull.- Returns:
- a
GtkSourceLanguage, ornullif there is no suitable language for givenfilenameand/orcontentType.Return value is owned by this LanguageManager and should not be freed.
-
prependSearchPath
Prependspathto the list of directories where themanagerlooks for language files.See
setSearchPath(java.lang.String[])for details.- Parameters:
path- a directory or a filename.- Since:
- 5.4
-
setSearchPath
Sets the list of directories where the this LanguageManager looks for language files.If
dirsisnull, 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 GtkSourceView 5.4 this function will allow you to provide paths in the form of "resource:///" URIs to embedded
GResources. They must contain the path of a directory within theGResource.- Parameters:
dirs- anull-terminated array of strings ornull.
-
builder
ALanguageManager.Builderobject constructs aLanguageManagerwith the specified properties. Use the variousset...()methods to set properties, and finish construction withLanguageManager.Builder.build().- Returns:
- the builder object
-