pub trait LanguageManagerExt: IsA<LanguageManager> + Sealed + 'static {
    // Provided methods
    fn language(&self, id: &str) -> Option<Language> { ... }
    fn language_ids(&self) -> Vec<GString> { ... }
    fn search_path(&self) -> Vec<GString> { ... }
    fn guess_language(
        &self,
        filename: Option<impl AsRef<Path>>,
        content_type: Option<&str>
    ) -> Option<Language> { ... }
    fn set_search_path(&self, dirs: &[&str]) { ... }
    fn connect_language_ids_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId { ... }
    fn connect_search_path_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all LanguageManager methods.

Implementors

LanguageManager

Provided Methods§

source

fn language(&self, id: &str) -> Option<Language>

Gets the Language identified by the given id in the language manager.

id

a language id.

Returns

a Language, or None if there is no language identified by the given id. Return value is owned by self and should not be freed.

source

fn language_ids(&self) -> Vec<GString>

Returns the ids of the available languages.

Returns

a None-terminated array of strings containing the ids of the available languages or None 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.

source

fn search_path(&self) -> Vec<GString>

Gets the list directories where self looks for language files.

Returns

None-terminated array containg a list of language files directories. The array is owned by self and must not be modified.

source

fn guess_language( &self, filename: Option<impl AsRef<Path>>, content_type: Option<&str> ) -> Option<Language>

Picks a 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:

<informalexample>``<programlisting> GtkSourceLanguage *lang; lang = gtk_source_language_manager_guess_language (filename, NULL); gtk_source_buffer_set_language (buffer, lang); </programlisting>``</informalexample>

or

<informalexample>``<programlisting> 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); </programlisting>``</informalexample>

etc. Use LanguageExt::mime_types() and LanguageExt::globs() if you need full control over file -> language mapping.

filename

a filename in Glib filename encoding, or None.

content_type

a content type (as in GIO API), or None.

Returns

a Language, or None if there is no suitable language for given filename and/or content_type. Return value is owned by self and should not be freed.

source

fn set_search_path(&self, dirs: &[&str])

Sets the list of directories where the self looks for language files. If dirs is None, the search path is reset to default.

<note> <para> 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 LanguageManager, you have to call this function right after creating it. </para> </note>

dirs

a None-terminated array of strings or None.

source

fn connect_language_ids_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_search_path_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

Object Safety§

This trait is not object safe.

Implementors§