Class OptionGroup

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class OptionGroup extends ProxyInstance

A GOptionGroup struct defines the options in a single group. The struct has only private fields and should not be directly accessed.

All options in a group share the same translation function. Libraries which need to parse commandline options are expected to provide a function for getting a GOptionGroup holding their options, which the application can then add to its GOptionContext.

  • Constructor Details

    • OptionGroup

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

      public OptionGroup(String name, String description, String helpDescription, @Nullable MemorySegment userData)

      Creates a new GOptionGroup.

      description is typically used to provide a title for the group. If so, it is recommended that it’s written in title case, and has a trailing colon so that it matches the style of built-in GLib group titles such as ‘Application Options:’.

      Parameters:
      name - the name for the option group, this is used to provide help for the options in this group with --help-``name
      description - a description for this group to be shown in --help. This string is translated using the translation domain or translation function of the group
      helpDescription - a description for the --help-``name option. This string is translated using the translation domain or translation function of the group
      userData - user data that will be passed to the pre- and post-parse hooks, the error hook and to callbacks of OptionArg.CALLBACK options, or null
      Since:
      2.6
  • Method Details

    • getType

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

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

      public void addEntries(@Nullable OptionEntry @Nullable [] entries)
      Adds the options specified in entries to group.
      Parameters:
      entries - a null-terminated array of GOptionEntrys
      Since:
      2.6
    • free

      @Deprecated public void free()
      Deprecated.
      Use g_option_group_unref() instead.
      Frees a GOptionGroup. Note that you must not free groups which have been added to a GOptionContext.
      Since:
      2.6
    • ref

      public OptionGroup ref()
      Increments the reference count of this OptionGroup by one.
      Returns:
      a GOptionGroup
      Since:
      2.44
    • setErrorHook

      public void setErrorHook(@Nullable OptionErrorFunc errorFunc)

      Associates a function with this OptionGroup which will be called from g_option_context_parse() when an error occurs.

      Note that the user data to be passed to errorFunc can be specified when constructing the group with g_option_group_new().

      Parameters:
      errorFunc - a function to call when an error occurs
      Since:
      2.6
    • setParseHooks

      public void setParseHooks(@Nullable OptionParseFunc preParseFunc, @Nullable OptionParseFunc postParseFunc)

      Associates two functions with this OptionGroup which will be called from g_option_context_parse() before the first option is parsed and after the last option has been parsed, respectively.

      Note that the user data to be passed to preParseFunc and postParseFunc can be specified when constructing the group with g_option_group_new().

      Parameters:
      preParseFunc - a function to call before parsing, or null
      postParseFunc - a function to call after parsing, or null
      Since:
      2.6
    • setTranslateFunc

      public void setTranslateFunc(@Nullable TranslateFunc func)

      Sets the function which is used to translate user-visible strings, for --help output. Different groups can use different GTranslateFuncs. If func is null, strings are not translated.

      If you are using gettext(), you only need to set the translation domain, see g_option_group_set_translation_domain().

      Parameters:
      func - the GTranslateFunc, or null
      Since:
      2.6
    • setTranslationDomain

      public void setTranslationDomain(String domain)
      A convenience function to use gettext() for translating user-visible strings.
      Parameters:
      domain - the domain to use
      Since:
      2.6
    • unref

      public void unref()
      Decrements the reference count of this OptionGroup by one. If the reference count drops to 0, the this OptionGroup will be freed. and all memory allocated by the this OptionGroup is released.
      Since:
      2.44