Class OptionGroup
- All Implemented Interfaces:
Proxy
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 Summary
ConstructorDescriptionOptionGroup
(MemorySegment address) Create a OptionGroup proxy instance for the provided memory address.OptionGroup
(String name, String description, String helpDescription, @Nullable MemorySegment userData) Creates a newGOptionGroup
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEntries
(OptionEntry[] entries) Adds the options specified inentries
to this OptionGroup.void
free()
Deprecated.Use g_option_group_unref() instead.static Type
getType()
Get the GType of the OptionGroup classref()
Increments the reference count of this OptionGroup by one.void
setErrorHook
(OptionErrorFunc errorFunc) Associates a function with this OptionGroup which will be called from g_option_context_parse() when an error occurs.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.void
setTranslateFunc
(@Nullable TranslateFunc func) Sets the function which is used to translate user-visible strings, for--help
output.void
setTranslationDomain
(String domain) A convenience function to use gettext() for translating user-visible strings.void
unref()
Decrements the reference count of this OptionGroup by one.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
OptionGroup
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 @Nullable MemorySegment userData) Creates a newGOptionGroup
.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 grouphelpDescription
- a description for the--help-
name
option. This string is translated using the translation domain or translation function of the groupuserData
- user data that will be passed to the pre- and post-parse hooks, the error hook and to callbacks ofOptionArg.CALLBACK
options, ornull
-
-
Method Details
-
getType
-
addEntries
Adds the options specified inentries
to this OptionGroup.- Parameters:
entries
- anull
-terminated array ofGOptionEntrys
-
free
Deprecated.Use g_option_group_unref() instead.Frees aGOptionGroup
. Note that you must not free groups which have been added to aGOptionContext
. -
ref
Increments the reference count of this OptionGroup by one.- Returns:
- a
GOptionGroup
-
setErrorHook
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
-
setParseHooks
public void setParseHooks(@Nullable @Nullable OptionParseFunc preParseFunc, @Nullable @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
andpostParseFunc
can be specified when constructing the group with g_option_group_new().- Parameters:
preParseFunc
- a function to call before parsing, ornull
postParseFunc
- a function to call after parsing, ornull
-
setTranslateFunc
Sets the function which is used to translate user-visible strings, for--help
output. Different groups can use differentGTranslateFuncs
. Iffunc
isnull
, 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
- theGTranslateFunc
, ornull
-
setTranslationDomain
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 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.
-