Class OptionGroup

All Implemented Interfaces:
PointerInterface

public class OptionGroup extends Record
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.

https://docs.gtk.org/glib/struct.OptionGroup.html

  • Constructor Details

    • OptionGroup

      public OptionGroup(PointerContainer pointer)
    • OptionGroup

      public OptionGroup(@Nonnull Str name, @Nonnull Str description, @Nonnull Str help_description, @Nullable Pointer user_data, OptionGroup.OnDestroyNotify destroy)
      Creates a new #GOptionGroup.
      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
      help_description - a description for the `--help-`@name option. This string is translated using the translation domain or translation function of the group
      user_data - user data that will be passed to the pre- and post-parse hooks, the error hook and to callbacks of %G_OPTION_ARG_CALLBACK options, or %NULL
      destroy - a function that will be called to free @user_data, or %NULL
    • OptionGroup

      public OptionGroup(String name, String description, String help_description, @Nullable Pointer user_data, OptionGroup.OnDestroyNotify destroy)
      Creates a new #GOptionGroup.
      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
      help_description - a description for the `--help-`@name option. This string is translated using the translation domain or translation function of the group
      user_data - user data that will be passed to the pre- and post-parse hooks, the error hook and to callbacks of %G_OPTION_ARG_CALLBACK options, or %NULL
      destroy - a function that will be called to free @user_data, or %NULL
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • ref

      public OptionGroup ref()
      Increments the reference count of @group by one.
      Returns:
      a #GOptionGroup
    • setErrorHook

      public void setErrorHook(OptionGroup.OnOptionErrorFunc error_func)
      Associates a function with @group which will be called
      from g_option_context_parse() when an error occurs.

      Note that the user data to be passed to @error_func can be
      specified when constructing the group with g_option_group_new().
      Parameters:
      error_func - a function to call when an error occurs
    • setParseHooks

      public void setParseHooks(OptionGroup.OnOptionParseFunc pre_parse_func, OptionGroup.OnOptionParseFunc post_parse_func)
      Associates two functions with @group 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 @pre_parse_func and
      @post_parse_func can be specified when constructing the group
      with g_option_group_new().
      Parameters:
      pre_parse_func - a function to call before parsing, or %NULL
      post_parse_func - a function to call after parsing, or %NULL
    • setTranslateFunc

      public void setTranslateFunc(OptionGroup.OnTranslateFunc func, @Nullable Pointer data, OptionGroup.OnDestroyNotify destroy_notify)
      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
      data - user data to pass to @func, or %NULL
      destroy_notify - a function which gets called to free @data, or %NULL
    • setTranslationDomain

      public void setTranslationDomain(@Nonnull Str domain)
      A convenience function to use gettext() for translating
      user-visible strings.
      Parameters:
      domain - the domain to use
    • setTranslationDomain

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

      public void unref()
      Decrements the reference count of @group by one.
      If the reference count drops to 0, the @group will be freed.
      and all memory allocated by the @group is released.
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()