Class SnippetManager

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class SnippetManager extends GObject

Provides access to Snippet.

GtkSourceSnippetManager is an object which processes snippet description files and creates Snippet objects.

Use getDefault() to retrieve the default instance of GtkSourceSnippetManager.

Use getSnippet(String, String, String) to retrieve snippets for a given snippets.

  • Constructor Details

    • SnippetManager

      public SnippetManager(MemorySegment address)
      Create a SnippetManager instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • SnippetManager

      public SnippetManager()
      Create a new SnippetManager.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the SnippetManager class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected SnippetManager asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • getDefault

      public static SnippetManager getDefault()
      Returns the default GtkSourceSnippetManager instance.
      Returns:
      a GtkSourceSnippetManager which is owned by GtkSourceView library and must not be unref'd.
    • getSearchPath

      public String[] getSearchPath()
      Gets the list directories where this SnippetManager looks for snippet files.
      Returns:
      null-terminated array containing a list of snippet files directories. The array is owned by lm and must not be modified.
    • getSnippet

      public @Nullable Snippet getSnippet(@Nullable String group, @Nullable String languageId, String trigger)

      Queries the known snippets for the first matching group, languageId, and/or trigger.

      If group or languageId are null, they will be ignored.

      Parameters:
      group - a group name or null
      languageId - a GtkSourceLanguage:id or null
      trigger - the trigger for the snippet
      Returns:
      a GtkSourceSnippet or null if no matching snippet was found.
    • listAll

      public ListModel listAll()

      Gets a ListModel of all snippets.

      This can be used to get an unfiltered list of all of the snippets known to the snippet manager.

      Returns:
      a ListModel of Snippet
      Since:
      5.6
    • listGroups

      public String[] listGroups()

      List all the known groups within the snippet manager.

      The result should be freed with g_free(), and the individual strings are owned by this SnippetManager and should never be freed by the caller.

      Returns:
      An array of strings which should be freed with g_free().
    • listMatching

      public ListModel listMatching(@Nullable String group, @Nullable String languageId, @Nullable String triggerPrefix)

      Queries the known snippets for those matching group, languageId, and/or triggerPrefix.

      If any of these are null, they will be ignored when filtering the available snippets.

      The ListModel only contains information about the available snippets until ListModel#getItem is called for a specific snippet. This helps reduce the number of GObject's that are created at runtime to those needed by the calling application.

      Parameters:
      group - a group name or null
      languageId - a GtkSourceLanguage:id or null
      triggerPrefix - a prefix for a trigger to activate
      Returns:
      a GListModel of GtkSourceSnippet.
    • setSearchPath

      public void setSearchPath(@Nullable String @Nullable [] dirs)

      Sets the list of directories in which the GtkSourceSnippetManager looks for snippet files.

      If dirs is null, the search path is reset to default.

      At the moment this function can be called only before the snippet files are loaded for the first time. In practice to set a custom search path for a GtkSourceSnippetManager, you have to call this function right after creating it.

      Parameters:
      dirs - a null-terminated array of strings or null.
    • builder

      public static SnippetManager.Builder<? extends SnippetManager.Builder> builder()
      A SnippetManager.Builder object constructs a SnippetManager with the specified properties. Use the various set...() methods to set properties, and finish construction with SnippetManager.Builder.build().
      Returns:
      the builder object