GLib.OptionGroup - Structures - GLib 2.0 (original) (raw)

Fields

None

Methods

class new (name, description, help_description, user_data, destroy)
add_entries (entries)
free ()
ref ()
set_translate_func (func, *data)
set_translation_domain (domain)
unref ()

Details

class GLib.OptionGroup

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 GLib.OptionContext.

classmethod new(name, description, help_description, user_data, destroy)[source]

Parameters:

Returns:

a newly created option group. It should be added to a GLib.OptionContext or freed with GLib.OptionGroup.unref().

Return type:

GLib.OptionGroup

Creates a new GLib.OptionGroup.

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

New in version 2.6.

add_entries(entries)[source]

Parameters:

entries ([GLib.OptionEntry]) – a None-terminated array of GLib.OptionEntrys

Adds the options specified in entries to self.

New in version 2.6.

free()[source]

Frees a GLib.OptionGroup. Note that you must not free groups which have been added to a GLib.OptionContext.

New in version 2.6.

Deprecated since version 2.44: Use GLib.OptionGroup.unref() instead.

ref()[source]

Returns:

a GLib.OptionGroup

Return type:

GLib.OptionGroup

Increments the reference count of self by one.

New in version 2.44.

set_translate_func(func, *data)[source]

Parameters:

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

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

New in version 2.6.

set_translation_domain(domain)[source]

Parameters:

domain (str) – the domain to use

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

New in version 2.6.

unref()[source]

Decrements the reference count of self by one. If the reference count drops to 0, the self will be freed. and all memory allocated by the self is released.

New in version 2.44.