Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: GOptionGroup

[17:7] extends: object

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.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • GOptionGroup (name = null, description = null, help_description = null, user_data = null, destroy = null)

    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:’.

    • @p name is the name for the option group, this is used to provide help for the options in this group with --help-@name.
    • @p description is a description for this group to be shown in --help. This string is translated using the translation domain or translation function of the group.
    • @p help_description is a description for the --help-@name option. This string is translated using the translation domain or translation function of the group.
    • @p user_data is 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.
    • @p destroy is a function that will be called to free @user_data, or %NULL.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • add_entries (list entries)

    Adds the options specified in @entries to @group.

    • @p entries is a %NULL-terminated array of #GOptionEntrys.
    • @r None.
  • free ()

    Frees a #GOptionGroup. Note that you must not free groups which have been added to a #GOptionContext.

    • @r None.
  • ref ()

    Increments the reference count of @group by one.

    • @r a #GOptionGroup.
  • set_error_hook (object 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().

    • @p error_func is a function to call when an error occurs.
    • @r None.
  • set_parse_hooks (object pre_parse_func, object 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().

    • @p pre_parse_func is a function to call before parsing, or %NULL.
    • @p post_parse_func is a function to call after parsing, or %NULL.
    • @r None.
  • set_translate_func (object 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().
    • @p func is the #GTranslateFunc, or %NULL.
    • @p data is user data to pass to @func, or %NULL.
    • @p destroy_notify is a function which gets called to free @data, or %NULL.
    • @r None.
  • set_translation_domain (string domain)

    A convenience function to use gettext() for translating user-visible strings.

    • @p domain is the domain to use.
    • @r None.
  • 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.
    • @r None.