<refentry id="glib-Commandline-option-parser">
<refmeta>
<refentrytitle role="top_of_page" id="glib-Commandline-option-parser.top_of_page">Commandline option parser</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GLIB Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Commandline option parser</refname>
<refpurpose>parses commandline options</refpurpose>
</refnamediv>

<refsynopsisdiv id="glib-Commandline-option-parser.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>

#include &lt;glib.h&gt;

enum                <link linkend="GOptionError">GOptionError</link>;
#define             <link linkend="G-OPTION-ERROR--CAPS">G_OPTION_ERROR</link>
<link linkend="gboolean">gboolean</link>            (<link linkend="GOptionArgFunc">*GOptionArgFunc</link>)                   (const <link linkend="gchar">gchar</link> *option_name,
                                                         const <link linkend="gchar">gchar</link> *value,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GError">GError</link> **error);
                    <link linkend="GOptionContext">GOptionContext</link>;
<link linkend="GOptionContext">GOptionContext</link> *    <link linkend="g-option-context-new">g_option_context_new</link>                (const <link linkend="gchar">gchar</link> *parameter_string);
<link linkend="void">void</link>                <link linkend="g-option-context-set-summary">g_option_context_set_summary</link>        (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         const <link linkend="gchar">gchar</link> *summary);
const <link linkend="gchar">gchar</link> *       <link linkend="g-option-context-get-summary">g_option_context_get_summary</link>        (<link linkend="GOptionContext">GOptionContext</link> *context);
<link linkend="void">void</link>                <link linkend="g-option-context-set-description">g_option_context_set_description</link>    (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         const <link linkend="gchar">gchar</link> *description);
const <link linkend="gchar">gchar</link> *       <link linkend="g-option-context-get-description">g_option_context_get_description</link>    (<link linkend="GOptionContext">GOptionContext</link> *context);
const <link linkend="gchar">gchar</link> *       (<link linkend="GTranslateFunc">*GTranslateFunc</link>)                   (const <link linkend="gchar">gchar</link> *str,
                                                         <link linkend="gpointer">gpointer</link> data);
<link linkend="void">void</link>                <link linkend="g-option-context-set-translate-func">g_option_context_set_translate_func</link> (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="GTranslateFunc">GTranslateFunc</link> func,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GDestroyNotify">GDestroyNotify</link> destroy_notify);
<link linkend="void">void</link>                <link linkend="g-option-context-set-translation-domain">g_option_context_set_translation_domain</link>
                                                        (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         const <link linkend="gchar">gchar</link> *domain);
<link linkend="void">void</link>                <link linkend="g-option-context-free">g_option_context_free</link>               (<link linkend="GOptionContext">GOptionContext</link> *context);
<link linkend="gboolean">gboolean</link>            <link linkend="g-option-context-parse">g_option_context_parse</link>              (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="gint">gint</link> *argc,
                                                         <link linkend="gchar">gchar</link> ***argv,
                                                         <link linkend="GError">GError</link> **error);
<link linkend="void">void</link>                <link linkend="g-option-context-set-help-enabled">g_option_context_set_help_enabled</link>   (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="gboolean">gboolean</link> help_enabled);
<link linkend="gboolean">gboolean</link>            <link linkend="g-option-context-get-help-enabled">g_option_context_get_help_enabled</link>   (<link linkend="GOptionContext">GOptionContext</link> *context);
<link linkend="void">void</link>                <link linkend="g-option-context-set-ignore-unknown-options">g_option_context_set_ignore_unknown_options</link>
                                                        (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="gboolean">gboolean</link> ignore_unknown);
<link linkend="gboolean">gboolean</link>            <link linkend="g-option-context-get-ignore-unknown-options">g_option_context_get_ignore_unknown_options</link>
                                                        (<link linkend="GOptionContext">GOptionContext</link> *context);
<link linkend="gchar">gchar</link> *             <link linkend="g-option-context-get-help">g_option_context_get_help</link>           (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="gboolean">gboolean</link> main_help,
                                                         <link linkend="GOptionGroup">GOptionGroup</link> *group);
enum                <link linkend="GOptionArg">GOptionArg</link>;
enum                <link linkend="GOptionFlags">GOptionFlags</link>;
#define             <link linkend="G-OPTION-REMAINING--CAPS">G_OPTION_REMAINING</link>
                    <link linkend="GOptionEntry">GOptionEntry</link>;
<link linkend="void">void</link>                <link linkend="g-option-context-add-main-entries">g_option_context_add_main_entries</link>   (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         const <link linkend="GOptionEntry">GOptionEntry</link> *entries,
                                                         const <link linkend="gchar">gchar</link> *translation_domain);
                    <link linkend="GOptionGroup">GOptionGroup</link>;
<link linkend="void">void</link>                <link linkend="g-option-context-add-group">g_option_context_add_group</link>          (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="GOptionGroup">GOptionGroup</link> *group);
<link linkend="void">void</link>                <link linkend="g-option-context-set-main-group">g_option_context_set_main_group</link>     (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="GOptionGroup">GOptionGroup</link> *group);
<link linkend="GOptionGroup">GOptionGroup</link> *      <link linkend="g-option-context-get-main-group">g_option_context_get_main_group</link>     (<link linkend="GOptionContext">GOptionContext</link> *context);
<link linkend="GOptionGroup">GOptionGroup</link> *      <link linkend="g-option-group-new">g_option_group_new</link>                  (const <link linkend="gchar">gchar</link> *name,
                                                         const <link linkend="gchar">gchar</link> *description,
                                                         const <link linkend="gchar">gchar</link> *help_description,
                                                         <link linkend="gpointer">gpointer</link> user_data,
                                                         <link linkend="GDestroyNotify">GDestroyNotify</link> destroy);
<link linkend="void">void</link>                <link linkend="g-option-group-free">g_option_group_free</link>                 (<link linkend="GOptionGroup">GOptionGroup</link> *group);
<link linkend="void">void</link>                <link linkend="g-option-group-add-entries">g_option_group_add_entries</link>          (<link linkend="GOptionGroup">GOptionGroup</link> *group,
                                                         const <link linkend="GOptionEntry">GOptionEntry</link> *entries);
<link linkend="gboolean">gboolean</link>            (<link linkend="GOptionParseFunc">*GOptionParseFunc</link>)                 (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="GOptionGroup">GOptionGroup</link> *group,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GError">GError</link> **error);
<link linkend="void">void</link>                <link linkend="g-option-group-set-parse-hooks">g_option_group_set_parse_hooks</link>      (<link linkend="GOptionGroup">GOptionGroup</link> *group,
                                                         <link linkend="GOptionParseFunc">GOptionParseFunc</link> pre_parse_func,
                                                         <link linkend="GOptionParseFunc">GOptionParseFunc</link> post_parse_func);
<link linkend="void">void</link>                (<link linkend="GOptionErrorFunc">*GOptionErrorFunc</link>)                 (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="GOptionGroup">GOptionGroup</link> *group,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GError">GError</link> **error);
<link linkend="void">void</link>                <link linkend="g-option-group-set-error-hook">g_option_group_set_error_hook</link>       (<link linkend="GOptionGroup">GOptionGroup</link> *group,
                                                         <link linkend="GOptionErrorFunc">GOptionErrorFunc</link> error_func);
<link linkend="void">void</link>                <link linkend="g-option-group-set-translate-func">g_option_group_set_translate_func</link>   (<link linkend="GOptionGroup">GOptionGroup</link> *group,
                                                         <link linkend="GTranslateFunc">GTranslateFunc</link> func,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GDestroyNotify">GDestroyNotify</link> destroy_notify);
<link linkend="void">void</link>                <link linkend="g-option-group-set-translation-domain">g_option_group_set_translation_domain</link>
                                                        (<link linkend="GOptionGroup">GOptionGroup</link> *group,
                                                         const <link linkend="gchar">gchar</link> *domain);
</synopsis>
</refsynopsisdiv>









<refsect1 id="glib-Commandline-option-parser.description" role="desc">
<title role="desc.title">Description</title>
<para>
The GOption commandline parser is intended to be a simpler replacement for the
popt library. It supports short and long commandline options, as shown in the 
following example:
</para>
<para>
<literal>testtreemodel -r 1 --max-size 20 --rand --display=:1.0 -vb -- file1 file2</literal>
</para>
<para>
The example demonstrates a number of features of the GOption commandline parser
<itemizedlist><listitem><para>
  Options can be single letters, prefixed by a single dash. Multiple
  short options can be grouped behind a single dash.
</para></listitem><listitem><para>
  Long options are prefixed by two consecutive dashes.
</para></listitem><listitem><para>
  Options can have an extra argument, which can be a number, a string or a 
  filename. For long options, the extra argument can be appended with an 
  equals sign after the option name.
</para></listitem><listitem><para>
  Non-option arguments are returned to the application as rest arguments.
</para></listitem><listitem><para>
  An argument consisting solely of two dashes turns off further parsing, 
  any remaining arguments (even those starting with a dash) are returned 
  to the application as rest arguments.
</para></listitem></itemizedlist>
</para>
<para>
Another important feature of GOption is that it can automatically generate 
nicely formatted help output. Unless it is explicitly turned off with 
<link linkend="g-option-context-set-help-enabled"><function>g_option_context_set_help_enabled()</function></link>, GOption will recognize the 
<option>--help</option>, <option>-?</option>, <option>--help-all</option>
and <option>--help-</option><replaceable>groupname</replaceable> options 
(where <replaceable>groupname</replaceable> is the name of a <link linkend="GOptionGroup"><type>GOptionGroup</type></link>) 
and write a text similar to the one shown in the following example to stdout.
</para>
<para>
<informalexample><screen>
Usage:
  testtreemodel [OPTION...] - test tree model performance
 
Help Options:
  -h, --help               Show help options
  --help-all               Show all help options
  --help-gtk               Show GTK+ Options
 
Application Options:
  -r, --repeats=N          Average over N repetitions
  -m, --max-size=M         Test up to 2^M items
  --display=DISPLAY        X display to use
  -v, --verbose            Be verbose
  -b, --beep               Beep when done   
  --rand                   Randomize the data
</screen></informalexample>
</para>
<para>
GOption groups options in <link linkend="GOptionGroup"><type>GOptionGroup</type></link><!-- -->s, which makes it easy to
incorporate options from multiple sources. The intended use for this is
to let applications collect option groups from the libraries it uses,
add them to their <link linkend="GOptionContext"><type>GOptionContext</type></link>, and parse all options by a single call
to <link linkend="g-option-context-parse"><function>g_option_context_parse()</function></link>. See <link linkend="gtk-get-option-group"><function>gtk_get_option_group()</function></link> for an example.
</para>
<para>
If an option is declared to be of type string or filename, GOption takes
care of converting it to the right encoding; strings are returned in UTF-8,
filenames are returned in the GLib filename encoding. Note that this only
works if <link linkend="setlocale"><function>setlocale()</function></link> has been called before <link linkend="g-option-context-parse"><function>g_option_context_parse()</function></link>.
</para>
<para>
Here is a complete example of setting up GOption to parse the example
commandline above and produce the example help output.
</para>
<para>
<informalexample><programlisting>
static gint repeats = 2;
static gint max_size = 8;
static gboolean verbose = FALSE;
static gboolean beep = FALSE;
static gboolean rand = FALSE;

static GOptionEntry entries[] = 
{
  { "repeats", 'r', 0, G_OPTION_ARG_INT, &amp;repeats, "Average over N repetitions", "N" },
  { "max-size", 'm', 0, G_OPTION_ARG_INT, &amp;max_size, "Test up to 2^M items", "M" },
  { "verbose", 'v', 0, G_OPTION_ARG_NONE, &amp;verbose, "Be verbose", NULL },
  { "beep", 'b', 0, G_OPTION_ARG_NONE, &amp;beep, "Beep when done", NULL },
  { "rand", 0, 0, G_OPTION_ARG_NONE, &amp;rand, "Randomize the data", NULL },
  { NULL }
};

int 
main (int argc, char *argv[])
{
  GError *error = NULL;
  GOptionContext *context;

  context = g_option_context_new ("- test tree model performance");
  g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
  g_option_context_add_group (context, gtk_get_option_group (TRUE));
  if (!g_option_context_parse (context, &amp;argc, &amp;argv, &amp;error))
    {
      g_print ("option parsing failed: %s\n", error->message);
      exit (1);
    }

  // ...

}
</programlisting></informalexample></para>
<para>
</para>
</refsect1>

<refsect1 id="glib-Commandline-option-parser.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="GOptionError" role="enum">
<title>enum GOptionError</title>
<indexterm zone="GOptionError"><primary sortas="OptionError">GOptionError</primary></indexterm><programlisting>typedef enum
{
  G_OPTION_ERROR_UNKNOWN_OPTION,
  G_OPTION_ERROR_BAD_VALUE,
  G_OPTION_ERROR_FAILED
} GOptionError;
</programlisting>
<para>
Error codes returned by option parsing.</para>
<para>
</para><variablelist role="enum">
<varlistentry id="G-OPTION-ERROR-UNKNOWN-OPTION--CAPS" role="constant">
<term><literal>G_OPTION_ERROR_UNKNOWN_OPTION</literal></term>
<listitem><simpara> An option was not known to the parser.
 This error will only be reported, if the parser hasn't been instructed
 to ignore unknown options, see <link linkend="g-option-context-set-ignore-unknown-options"><function>g_option_context_set_ignore_unknown_options()</function></link>.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-ERROR-BAD-VALUE--CAPS" role="constant">
<term><literal>G_OPTION_ERROR_BAD_VALUE</literal></term>
<listitem><simpara> A value couldn't be parsed.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-ERROR-FAILED--CAPS" role="constant">
<term><literal>G_OPTION_ERROR_FAILED</literal></term>
<listitem><simpara> A <link linkend="GOptionArgFunc"><type>GOptionArgFunc</type></link> callback failed.
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="G-OPTION-ERROR--CAPS" role="macro">
<title>G_OPTION_ERROR</title>
<indexterm zone="G-OPTION-ERROR--CAPS"><primary sortas="OPTION_ERROR">G_OPTION_ERROR</primary></indexterm><programlisting>#define G_OPTION_ERROR (g_option_error_quark ())
</programlisting>
<para>
Error domain for option parsing. Errors in this domain will
be from the <link linkend="GOptionError"><type>GOptionError</type></link> enumeration. See <link linkend="GError"><type>GError</type></link> for information on 
error domains.</para>
<para>
</para></refsect2>
<refsect2 id="GOptionArgFunc" role="function">
<title>GOptionArgFunc ()</title>
<indexterm zone="GOptionArgFunc"><primary sortas="OptionArgFunc">GOptionArgFunc</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            (*GOptionArgFunc)                   (const <link linkend="gchar">gchar</link> *option_name,
                                                         const <link linkend="gchar">gchar</link> *value,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GError">GError</link> **error);</programlisting>
<para>
The type of function to be passed as callback for <link linkend="G-OPTION-ARG-CALLBACK--CAPS"><literal>G_OPTION_ARG_CALLBACK</literal></link>
options.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>option_name</parameter>&#160;:</term>
<listitem><simpara> The name of the option being parsed. This will be either a 
 single dash followed by a single letter (for a short name) or two dashes
 followed by a long option name.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>value</parameter>&#160;:</term>
<listitem><simpara> The value to be parsed.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> User data added to the <link linkend="GOptionGroup"><type>GOptionGroup</type></link> containing the option when it
 was created with <link linkend="g-option-group-new"><function>g_option_group_new()</function></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>error</parameter>&#160;:</term>
<listitem><simpara> A return location for errors. The error code <link linkend="G-OPTION-ERROR-FAILED--CAPS"><literal>G_OPTION_ERROR_FAILED</literal></link>
 is intended to be used for errors in <link linkend="GOptionArgFunc"><type>GOptionArgFunc</type></link> callbacks.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the option was successfully parsed, <link linkend="FALSE--CAPS"><literal>FALSE</literal></link> if an error 
 occurred, in which case <parameter>error</parameter> should be set with <link linkend="g-set-error"><function>g_set_error()</function></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="GOptionContext" role="struct">
<title>GOptionContext</title>
<indexterm zone="GOptionContext"><primary sortas="OptionContext">GOptionContext</primary></indexterm><programlisting>typedef struct _GOptionContext GOptionContext;</programlisting>
<para>
A <structname>GOptionContext</structname> struct defines which options
are accepted by the commandline option parser. The struct has only private 
fields and should not be directly accessed.</para>
<para>
</para></refsect2>
<refsect2 id="g-option-context-new" role="function" condition="since:2.6">
<title>g_option_context_new ()</title>
<indexterm zone="g-option-context-new" role="2.6"><primary sortas="option_context_new">g_option_context_new</primary></indexterm><programlisting><link linkend="GOptionContext">GOptionContext</link> *    g_option_context_new                (const <link linkend="gchar">gchar</link> *parameter_string);</programlisting>
<para>
Creates a new option context. 
</para>
<para>
The <parameter>parameter_string</parameter> can serve multiple purposes. It can be used
to add descriptions for "rest" arguments, which are not parsed by
the <link linkend="GOptionContext"><type>GOptionContext</type></link>, typically something like "FILES" or
"FILE1 FILE2...". If you are using <link linkend="G-OPTION-REMAINING--CAPS"><type>G_OPTION_REMAINING</type></link> for
collecting "rest" arguments, GLib handles this automatically by
using the <parameter>arg_description</parameter> of the corresponding <link linkend="GOptionEntry"><type>GOptionEntry</type></link> in
the usage summary.
</para>
<para>
Another usage is to give a short summary of the program
functionality, like " - frob the strings", which will be displayed
in the same line as the usage. For a longer description of the
program functionality that should be displayed as a paragraph
below the usage line, use <link linkend="g-option-context-set-summary"><function>g_option_context_set_summary()</function></link>.
</para>
<para>
Note that the <parameter>parameter_string</parameter> is translated using the
function set with <link linkend="g-option-context-set-translate-func"><function>g_option_context_set_translate_func()</function></link>, so
it should normally be passed untranslated.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>parameter_string</parameter>&#160;:</term>
<listitem><simpara> a string which is displayed in
   the first line of <option>--help</option> output, after the
   usage summary 
   <literal><replaceable>programname</replaceable> [OPTION...]</literal>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a newly created <link linkend="GOptionContext"><type>GOptionContext</type></link>, which must be
   freed with <link linkend="g-option-context-free"><function>g_option_context_free()</function></link> after use.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-option-context-set-summary" role="function" condition="since:2.12">
<title>g_option_context_set_summary ()</title>
<indexterm zone="g-option-context-set-summary" role="2.12"><primary sortas="option_context_set_summary">g_option_context_set_summary</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_context_set_summary        (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         const <link linkend="gchar">gchar</link> *summary);</programlisting>
<para>
Adds a string to be displayed in <option>--help</option> output
before the list of options. This is typically a summary of the
program functionality. 
</para>
<para>
Note that the summary is translated (see 
<link linkend="g-option-context-set-translate-func"><function>g_option_context_set_translate_func()</function></link> and
<link linkend="g-option-context-set-translation-domain"><function>g_option_context_set_translation_domain()</function></link>).</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>summary</parameter>&#160;:</term>
<listitem><simpara> a string to be shown in <option>--help</option> output 
 before the list of options, or <link linkend="NULL--CAPS"><literal>NULL</literal></link>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.12</para></refsect2>
<refsect2 id="g-option-context-get-summary" role="function" condition="since:2.12">
<title>g_option_context_get_summary ()</title>
<indexterm zone="g-option-context-get-summary" role="2.12"><primary sortas="option_context_get_summary">g_option_context_get_summary</primary></indexterm><programlisting>const <link linkend="gchar">gchar</link> *       g_option_context_get_summary        (<link linkend="GOptionContext">GOptionContext</link> *context);</programlisting>
<para>
Returns the summary. See <link linkend="g-option-context-set-summary"><function>g_option_context_set_summary()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the summary

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.12</para></refsect2>
<refsect2 id="g-option-context-set-description" role="function" condition="since:2.12">
<title>g_option_context_set_description ()</title>
<indexterm zone="g-option-context-set-description" role="2.12"><primary sortas="option_context_set_description">g_option_context_set_description</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_context_set_description    (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         const <link linkend="gchar">gchar</link> *description);</programlisting>
<para>
Adds a string to be displayed in <option>--help</option> output
after the list of options. This text often includes a bug reporting
address.
</para>
<para>
Note that the summary is translated (see 
<link linkend="g-option-context-set-translate-func"><function>g_option_context_set_translate_func()</function></link>).</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>description</parameter>&#160;:</term>
<listitem><simpara> a string to be shown in <option>--help</option> output 
  after the list of options, or <link linkend="NULL--CAPS"><literal>NULL</literal></link>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.12</para></refsect2>
<refsect2 id="g-option-context-get-description" role="function" condition="since:2.12">
<title>g_option_context_get_description ()</title>
<indexterm zone="g-option-context-get-description" role="2.12"><primary sortas="option_context_get_description">g_option_context_get_description</primary></indexterm><programlisting>const <link linkend="gchar">gchar</link> *       g_option_context_get_description    (<link linkend="GOptionContext">GOptionContext</link> *context);</programlisting>
<para>
Returns the description. See <link linkend="g-option-context-set-description"><function>g_option_context_set_description()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the description

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.12</para></refsect2>
<refsect2 id="GTranslateFunc" role="function">
<title>GTranslateFunc ()</title>
<indexterm zone="GTranslateFunc"><primary sortas="TranslateFunc">GTranslateFunc</primary></indexterm><programlisting>const <link linkend="gchar">gchar</link> *       (*GTranslateFunc)                   (const <link linkend="gchar">gchar</link> *str,
                                                         <link linkend="gpointer">gpointer</link> data);</programlisting>
<para>
The type of functions which are used to translate user-visible
strings, for <option>--help</option> output.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>str</parameter>&#160;:</term>
<listitem><simpara> the untranslated string
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> user data specified when installing the function, e.g.
 in <link linkend="g-option-group-set-translate-func"><function>g_option_group_set_translate_func()</function></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a translation of the string for the current locale.
 The returned string is owned by GLib and must not be freed.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-option-context-set-translate-func" role="function" condition="since:2.12">
<title>g_option_context_set_translate_func ()</title>
<indexterm zone="g-option-context-set-translate-func" role="2.12"><primary sortas="option_context_set_translate_func">g_option_context_set_translate_func</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_context_set_translate_func (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="GTranslateFunc">GTranslateFunc</link> func,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GDestroyNotify">GDestroyNotify</link> destroy_notify);</programlisting>
<para>
Sets the function which is used to translate the contexts 
user-visible strings, for <option>--help</option> output. 
If <parameter>func</parameter> is <link linkend="NULL--CAPS"><literal>NULL</literal></link>, strings are not translated.
</para>
<para>
Note that option groups have their own translation functions, 
this function only affects the <parameter>parameter_string</parameter> (see <link linkend="g-option-context-new"><function>g_option_context_new()</function></link>), 
the summary (see <link linkend="g-option-context-set-summary"><function>g_option_context_set_summary()</function></link>) and the description 
(see <link linkend="g-option-context-set-description"><function>g_option_context_set_description()</function></link>).
</para>
<para>
If you are using <link linkend="gettext"><function>gettext()</function></link>, you only need to set the translation
domain, see <link linkend="g-option-context-set-translation-domain"><function>g_option_context_set_translation_domain()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>func</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GTranslateFunc"><type>GTranslateFunc</type></link>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> user data to pass to <parameter>func</parameter>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>destroy_notify</parameter>&#160;:</term>
<listitem><simpara> a function which gets called to free <parameter>data</parameter>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.12</para></refsect2>
<refsect2 id="g-option-context-set-translation-domain" role="function" condition="since:2.12">
<title>g_option_context_set_translation_domain ()</title>
<indexterm zone="g-option-context-set-translation-domain" role="2.12"><primary sortas="option_context_set_translation_domain">g_option_context_set_translation_domain</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_context_set_translation_domain
                                                        (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         const <link linkend="gchar">gchar</link> *domain);</programlisting>
<para>
A convenience function to use <link linkend="gettext"><function>gettext()</function></link> for translating
user-visible strings.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>domain</parameter>&#160;:</term>
<listitem><simpara> the domain to use
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.12</para></refsect2>
<refsect2 id="g-option-context-free" role="function" condition="since:2.6">
<title>g_option_context_free ()</title>
<indexterm zone="g-option-context-free" role="2.6"><primary sortas="option_context_free">g_option_context_free</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_context_free               (<link linkend="GOptionContext">GOptionContext</link> *context);</programlisting>
<para>
Frees context and all the groups which have been 
added to it.
</para>
<para>
Please note that parsed arguments need to be freed separately (see
<link linkend="GOptionEntry"><type>GOptionEntry</type></link>).</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link> 
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-option-context-parse" role="function" condition="since:2.6">
<title>g_option_context_parse ()</title>
<indexterm zone="g-option-context-parse" role="2.6"><primary sortas="option_context_parse">g_option_context_parse</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_option_context_parse              (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="gint">gint</link> *argc,
                                                         <link linkend="gchar">gchar</link> ***argv,
                                                         <link linkend="GError">GError</link> **error);</programlisting>
<para>
Parses the command line arguments, recognizing options
which have been added to <parameter>context</parameter>. A side-effect of 
calling this function is that <link linkend="g-set-prgname"><function>g_set_prgname()</function></link> will be
called.
</para>
<para>
If the parsing is successful, any parsed arguments are
removed from the array and <parameter>argc</parameter> and <parameter>argv</parameter> are updated 
accordingly. A '--' option is stripped from <parameter>argv</parameter>
unless there are unparsed options before and after it, 
or some of the options after it start with '-'. In case 
of an error, <parameter>argc</parameter> and <parameter>argv</parameter> are left unmodified. 
</para>
<para>
If automatic <option>--help</option> support is enabled
(see <link linkend="g-option-context-set-help-enabled"><function>g_option_context_set_help_enabled()</function></link>), and the 
<parameter>argv</parameter> array contains one of the recognized help options,
this function will produce help output to stdout and
call <literal>exit (0)</literal>.
</para>
<para>
Note that function depends on the 
<link linkend="setlocale">current locale</link> for 
automatic character set conversion of string and filename
arguments.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>argc</parameter>&#160;:</term>
<listitem><simpara> a pointer to the number of command line arguments
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>argv</parameter>&#160;:</term>
<listitem><simpara> a pointer to the array of command line arguments
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>error</parameter>&#160;:</term>
<listitem><simpara> a return location for errors 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the parsing was successful, 
              <link linkend="FALSE--CAPS"><literal>FALSE</literal></link> if an error occurred

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-option-context-set-help-enabled" role="function" condition="since:2.6">
<title>g_option_context_set_help_enabled ()</title>
<indexterm zone="g-option-context-set-help-enabled" role="2.6"><primary sortas="option_context_set_help_enabled">g_option_context_set_help_enabled</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_context_set_help_enabled   (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="gboolean">gboolean</link> help_enabled);</programlisting>
<para>
Enables or disables automatic generation of <option>--help</option> 
output. By default, <link linkend="g-option-context-parse"><function>g_option_context_parse()</function></link> recognizes
<option>--help</option>, <option>-h</option>,
<option>-?</option>, <option>--help-all</option>
and <option>--help-</option><replaceable>groupname</replaceable> and creates
suitable output to stdout.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>help_enabled</parameter>&#160;:</term>
<listitem><simpara> <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> to enable <option>--help</option>, <link linkend="FALSE--CAPS"><literal>FALSE</literal></link> to disable it
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-option-context-get-help-enabled" role="function" condition="since:2.6">
<title>g_option_context_get_help_enabled ()</title>
<indexterm zone="g-option-context-get-help-enabled" role="2.6"><primary sortas="option_context_get_help_enabled">g_option_context_get_help_enabled</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_option_context_get_help_enabled   (<link linkend="GOptionContext">GOptionContext</link> *context);</programlisting>
<para>
Returns whether automatic <option>--help</option> generation
is turned on for <parameter>context</parameter>. See <link linkend="g-option-context-set-help-enabled"><function>g_option_context_set_help_enabled()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if automatic help generation is turned on.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-option-context-set-ignore-unknown-options" role="function" condition="since:2.6">
<title>g_option_context_set_ignore_unknown_options ()</title>
<indexterm zone="g-option-context-set-ignore-unknown-options" role="2.6"><primary sortas="option_context_set_ignore_unknown_options">g_option_context_set_ignore_unknown_options</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_context_set_ignore_unknown_options
                                                        (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="gboolean">gboolean</link> ignore_unknown);</programlisting>
<para>
Sets whether to ignore unknown options or not. If an argument is 
ignored, it is left in the <parameter>argv</parameter> array after parsing. By default, 
<link linkend="g-option-context-parse"><function>g_option_context_parse()</function></link> treats unknown options as error.
</para>
<para>
This setting does not affect non-option arguments (i.e. arguments 
which don't start with a dash). But note that GOption cannot reliably
determine whether a non-option belongs to a preceding unknown option.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ignore_unknown</parameter>&#160;:</term>
<listitem><simpara> <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> to ignore unknown options, <link linkend="FALSE--CAPS"><literal>FALSE</literal></link> to produce
   an error when unknown options are met
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-option-context-get-ignore-unknown-options" role="function" condition="since:2.6">
<title>g_option_context_get_ignore_unknown_options ()</title>
<indexterm zone="g-option-context-get-ignore-unknown-options" role="2.6"><primary sortas="option_context_get_ignore_unknown_options">g_option_context_get_ignore_unknown_options</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_option_context_get_ignore_unknown_options
                                                        (<link linkend="GOptionContext">GOptionContext</link> *context);</programlisting>
<para>
Returns whether unknown options are ignored or not. See
<link linkend="g-option-context-set-ignore-unknown-options"><function>g_option_context_set_ignore_unknown_options()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if unknown options are ignored.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-option-context-get-help" role="function" condition="since:2.14">
<title>g_option_context_get_help ()</title>
<indexterm zone="g-option-context-get-help" role="2.14"><primary sortas="option_context_get_help">g_option_context_get_help</primary></indexterm><programlisting><link linkend="gchar">gchar</link> *             g_option_context_get_help           (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="gboolean">gboolean</link> main_help,
                                                         <link linkend="GOptionGroup">GOptionGroup</link> *group);</programlisting>
<para>
Returns a formatted, translated help text for the given context.
To obtain the text produced by <option>--help</option>, call
<literal>g_option_context_get_help (context, TRUE, NULL)</literal>.
To obtain the text produced by <option>--help-all</option>, call
<literal>g_option_context_get_help (context, FALSE, NULL)</literal>.
To obtain the help text for an option group, call
<literal>g_option_context_get_help (context, FALSE, group)</literal>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>main_help</parameter>&#160;:</term>
<listitem><simpara> if <link linkend="TRUE--CAPS"><literal>TRUE</literal></link>, only include the main group 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GOptionGroup"><type>GOptionGroup</type></link> to create help for, or <link linkend="NULL--CAPS"><literal>NULL</literal></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> A newly allocated string containing the help text

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="GOptionArg" role="enum">
<title>enum GOptionArg</title>
<indexterm zone="GOptionArg"><primary sortas="OptionArg">GOptionArg</primary></indexterm><programlisting>typedef enum
{
  G_OPTION_ARG_NONE,
  G_OPTION_ARG_STRING,
  G_OPTION_ARG_INT,
  G_OPTION_ARG_CALLBACK,
  G_OPTION_ARG_FILENAME,
  G_OPTION_ARG_STRING_ARRAY,
  G_OPTION_ARG_FILENAME_ARRAY,
  G_OPTION_ARG_DOUBLE,
  G_OPTION_ARG_INT64
} GOptionArg;
</programlisting>
<para>
The <link linkend="GOptionArg"><type>GOptionArg</type></link> enum values determine which type of extra argument the
options expect to find. If an option expects an extra argument, it
can be specified in several ways; with a short option:
<option>-x arg</option>, with a long option: <option>--name arg</option>
or combined in a single argument: <option>--name=arg</option>.</para>
<para>
</para><variablelist role="enum">
<varlistentry id="G-OPTION-ARG-NONE--CAPS" role="constant">
<term><literal>G_OPTION_ARG_NONE</literal></term>
<listitem><simpara> No extra argument. This is useful for simple flags.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-ARG-STRING--CAPS" role="constant">
<term><literal>G_OPTION_ARG_STRING</literal></term>
<listitem><simpara> The option takes a string argument.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-ARG-INT--CAPS" role="constant">
<term><literal>G_OPTION_ARG_INT</literal></term>
<listitem><simpara> The option takes an integer argument.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-ARG-CALLBACK--CAPS" role="constant">
<term><literal>G_OPTION_ARG_CALLBACK</literal></term>
<listitem><simpara> The option provides a callback to parse the
 extra argument.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-ARG-FILENAME--CAPS" role="constant">
<term><literal>G_OPTION_ARG_FILENAME</literal></term>
<listitem><simpara> The option takes a filename as argument.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-ARG-STRING-ARRAY--CAPS" role="constant">
<term><literal>G_OPTION_ARG_STRING_ARRAY</literal></term>
<listitem><simpara> The option takes a string argument, multiple
 uses of the option are collected into an array of strings.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-ARG-FILENAME-ARRAY--CAPS" role="constant">
<term><literal>G_OPTION_ARG_FILENAME_ARRAY</literal></term>
<listitem><simpara> The option takes a filename as argument, 
 multiple uses of the option are collected into an array of strings.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-ARG-DOUBLE--CAPS" role="constant">
<term><literal>G_OPTION_ARG_DOUBLE</literal></term>
<listitem><simpara> The option takes a double argument. The argument
 can be formatted either for the user's locale or for the "C" locale. Since 2.12
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-ARG-INT64--CAPS" role="constant">
<term><literal>G_OPTION_ARG_INT64</literal></term>
<listitem><simpara> The option takes a 64-bit integer. Like <link linkend="G-OPTION-ARG-INT--CAPS"><literal>G_OPTION_ARG_INT</literal></link>
 but for larger numbers. The number can be in decimal base, or in hexadecimal
 (when prefixed with <literal>0x</literal>, for example, <literal>0xffffffff</literal>).
 Since 2.12
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="GOptionFlags" role="enum">
<title>enum GOptionFlags</title>
<indexterm zone="GOptionFlags"><primary sortas="OptionFlags">GOptionFlags</primary></indexterm><programlisting>typedef enum
{
  G_OPTION_FLAG_HIDDEN		= 1 &lt;&lt; 0,
  G_OPTION_FLAG_IN_MAIN		= 1 &lt;&lt; 1,
  G_OPTION_FLAG_REVERSE		= 1 &lt;&lt; 2,
  G_OPTION_FLAG_NO_ARG		= 1 &lt;&lt; 3,
  G_OPTION_FLAG_FILENAME	= 1 &lt;&lt; 4,
  G_OPTION_FLAG_OPTIONAL_ARG    = 1 &lt;&lt; 5,
  G_OPTION_FLAG_NOALIAS	        = 1 &lt;&lt; 6
} GOptionFlags;
</programlisting>
<para>
Flags which modify individual options.</para>
<para>
</para><variablelist role="enum">
<varlistentry id="G-OPTION-FLAG-HIDDEN--CAPS" role="constant">
<term><literal>G_OPTION_FLAG_HIDDEN</literal></term>
<listitem><simpara> The option doesn't appear in <option>--help</option>
 output.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-FLAG-IN-MAIN--CAPS" role="constant">
<term><literal>G_OPTION_FLAG_IN_MAIN</literal></term>
<listitem><simpara> The option appears in the main section of the
 <option>--help</option> output, even if it is defined in a group.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-FLAG-REVERSE--CAPS" role="constant">
<term><literal>G_OPTION_FLAG_REVERSE</literal></term>
<listitem><simpara> For options of the <link linkend="G-OPTION-ARG-NONE--CAPS"><literal>G_OPTION_ARG_NONE</literal></link> kind, this flag
 indicates that the sense of the option is reversed.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-FLAG-NO-ARG--CAPS" role="constant">
<term><literal>G_OPTION_FLAG_NO_ARG</literal></term>
<listitem><simpara> For options of the <link linkend="G-OPTION-ARG-CALLBACK--CAPS"><literal>G_OPTION_ARG_CALLBACK</literal></link> kind,
 this flag indicates that the callback does not take any argument
 (like a <link linkend="G-OPTION-ARG-NONE--CAPS"><literal>G_OPTION_ARG_NONE</literal></link> option). Since 2.8
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-FLAG-FILENAME--CAPS" role="constant">
<term><literal>G_OPTION_FLAG_FILENAME</literal></term>
<listitem><simpara> For options of the <link linkend="G-OPTION-ARG-CALLBACK--CAPS"><literal>G_OPTION_ARG_CALLBACK</literal></link>
 kind, this flag indicates that the argument should be passed to the
 callback in the GLib filename encoding rather than UTF-8. Since 2.8
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-FLAG-OPTIONAL-ARG--CAPS" role="constant">
<term><literal>G_OPTION_FLAG_OPTIONAL_ARG</literal></term>
<listitem><simpara> For options of the <link linkend="G-OPTION-ARG-CALLBACK--CAPS"><literal>G_OPTION_ARG_CALLBACK</literal></link> 
 kind, this flag indicates that the argument supply is optional. If no argument
 is given then data of <link linkend="GOptionParseFunc"><literal>GOptionParseFunc</literal></link> will be set to NULL. Since 2.8
</simpara></listitem>
</varlistentry>
<varlistentry id="G-OPTION-FLAG-NOALIAS--CAPS" role="constant">
<term><literal>G_OPTION_FLAG_NOALIAS</literal></term>
<listitem><simpara> This flag turns off the automatic conflict resolution
 which prefixes long option names with <literal>groupname-</literal> if 
 there is a conflict. This option should only be used in situations where
 aliasing is necessary to model some legacy commandline interface. It is
 not safe to use this option, unless all option groups are under your 
 direct control. Since 2.8.
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="G-OPTION-REMAINING--CAPS" role="macro" condition="since:2.6">
<title>G_OPTION_REMAINING</title>
<indexterm zone="G-OPTION-REMAINING--CAPS" role="2.6"><primary sortas="OPTION_REMAINING">G_OPTION_REMAINING</primary></indexterm><programlisting>#define G_OPTION_REMAINING ""
</programlisting>
<para>
If a long option in the main group has this name, it is not treated as a 
regular option. Instead it collects all non-option arguments which would
otherwise be left in <literal>argv</literal>. The option must be of type
<link linkend="G-OPTION-ARG-CALLBACK--CAPS"><literal>G_OPTION_ARG_CALLBACK</literal></link>, <link linkend="G-OPTION-ARG-STRING-ARRAY--CAPS"><literal>G_OPTION_ARG_STRING_ARRAY</literal></link>
or <link linkend="G-OPTION-ARG-FILENAME-ARRAY--CAPS"><literal>G_OPTION_ARG_FILENAME_ARRAY</literal></link>.
</para>
<para>
Using <link linkend="G-OPTION-REMAINING--CAPS"><type>G_OPTION_REMAINING</type></link> instead of simply scanning <literal>argv</literal>
for leftover arguments has the advantage that GOption takes care of 
necessary encoding conversions for strings or filenames.</para>
<para>
</para><para role="since">Since 2.6</para></refsect2>
<refsect2 id="GOptionEntry" role="struct">
<title>GOptionEntry</title>
<indexterm zone="GOptionEntry"><primary sortas="OptionEntry">GOptionEntry</primary></indexterm><programlisting>typedef struct {
  const gchar *long_name;
  gchar        short_name;
  gint         flags;

  GOptionArg   arg;
  gpointer     arg_data;
  
  const gchar *description;
  const gchar *arg_description;
} GOptionEntry;
</programlisting>
<para>
A <structname>GOptionEntry</structname> defines a single option.
To have an effect, they must be added to a <link linkend="GOptionGroup"><type>GOptionGroup</type></link> with
<link linkend="g-option-context-add-main-entries"><function>g_option_context_add_main_entries()</function></link> or <link linkend="g-option-group-add-entries"><function>g_option_group_add_entries()</function></link>.</para>
<para>
</para><variablelist role="struct">
<varlistentry>
<term>const&#160;<link linkend="gchar">gchar</link>&#160;*<structfield>long_name</structfield>;</term>
<listitem><simpara> The long name of an option can be used to specify it
 in a commandline as --<replaceable>long_name</replaceable>. Every
 option must have a long name. To resolve conflicts if multiple
 option groups contain the same long name, it is also possible to
 specify the option as 
 --<replaceable>groupname</replaceable>-<replaceable>long_name</replaceable>.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="gchar">gchar</link>&#160;<structfield>short_name</structfield>;</term>
<listitem><simpara> If an option has a short name, it can be specified
 -<replaceable>short_name</replaceable> in a commandline. <parameter>short_name</parameter> must be 
 a printable ASCII character different from '-', or zero if the option has no
 short name.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="gint">gint</link>&#160;<structfield>flags</structfield>;</term>
<listitem><simpara> Flags from <link linkend="GOptionFlags"><type>GOptionFlags</type></link>.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="GOptionArg">GOptionArg</link>&#160;<structfield>arg</structfield>;</term>
<listitem><simpara> The type of the option, as a <link linkend="GOptionArg"><type>GOptionArg</type></link>.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="gpointer">gpointer</link>&#160;<structfield>arg_data</structfield>;</term>
<listitem><simpara> If the <parameter>arg</parameter> type is <link linkend="G-OPTION-ARG-CALLBACK--CAPS"><literal>G_OPTION_ARG_CALLBACK</literal></link>, then <parameter>arg_data</parameter> must 
 point to a <link linkend="GOptionArgFunc"><type>GOptionArgFunc</type></link> callback function, which will be called to handle 
 the extra argument. Otherwise, <parameter>arg_data</parameter> is a pointer to a location to store 
 the value, the required type of the location depends on the <parameter>arg</parameter> type:
 <variablelist>
 <varlistentry>
 <term><link linkend="G-OPTION-ARG-NONE--CAPS"><literal>G_OPTION_ARG_NONE</literal></link></term>
 <listitem><para><link linkend="gboolean"><literal>gboolean</literal></link></para></listitem>
 </varlistentry>
 <varlistentry>
 <term><link linkend="G-OPTION-ARG-STRING--CAPS"><literal>G_OPTION_ARG_STRING</literal></link></term>
 <listitem><para><link linkend="gchar"><literal>gchar</literal></link>*</para></listitem>
 </varlistentry>
 <varlistentry>
 <term><link linkend="G-OPTION-ARG-INT--CAPS"><literal>G_OPTION_ARG_INT</literal></link></term>
 <listitem><para><link linkend="gint"><literal>gint</literal></link></para></listitem>
 </varlistentry>
 <varlistentry>
 <term><link linkend="G-OPTION-ARG-FILENAME--CAPS"><literal>G_OPTION_ARG_FILENAME</literal></link></term>
 <listitem><para><link linkend="gchar"><literal>gchar</literal></link>*</para></listitem>
 </varlistentry>
 <varlistentry>
 <term><link linkend="G-OPTION-ARG-STRING-ARRAY--CAPS"><literal>G_OPTION_ARG_STRING_ARRAY</literal></link></term>
 <listitem><para><link linkend="gchar"><literal>gchar</literal></link>**</para></listitem>
 </varlistentry>
 <varlistentry>
 <term><link linkend="G-OPTION-ARG-FILENAME-ARRAY--CAPS"><literal>G_OPTION_ARG_FILENAME_ARRAY</literal></link></term>
 <listitem><para><link linkend="gchar"><literal>gchar</literal></link>**</para></listitem>
 </varlistentry>
 <varlistentry>
 <term><link linkend="G-OPTION-ARG-DOUBLE--CAPS"><literal>G_OPTION_ARG_DOUBLE</literal></link></term>
 <listitem><para><link linkend="gdouble"><literal>gdouble</literal></link></para></listitem>
 </varlistentry>
 </variablelist>
 If <parameter>arg</parameter> type is <link linkend="G-OPTION-ARG-STRING--CAPS"><literal>G_OPTION_ARG_STRING</literal></link> or <link linkend="G-OPTION-ARG-FILENAME--CAPS"><literal>G_OPTION_ARG_FILENAME</literal></link> the location
 will contain a newly allocated string if the option was given. That string
 needs to be freed by the callee using <link linkend="g-free"><function>g_free()</function></link>. Likewise if <parameter>arg</parameter> type is
 <link linkend="G-OPTION-ARG-STRING-ARRAY--CAPS"><literal>G_OPTION_ARG_STRING_ARRAY</literal></link> or <link linkend="G-OPTION-ARG-FILENAME-ARRAY--CAPS"><literal>G_OPTION_ARG_FILENAME_ARRAY</literal></link>, the data should
 be freed using <link linkend="g-strfreev"><function>g_strfreev()</function></link>.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term>const&#160;<link linkend="gchar">gchar</link>&#160;*<structfield>description</structfield>;</term>
<listitem><simpara> the description for the option in <option>--help</option>
 output. The <parameter>description</parameter> is translated using the <parameter>translate_func</parameter> of the
 group, see <link linkend="g-option-group-set-translation-domain"><function>g_option_group_set_translation_domain()</function></link>.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term>const&#160;<link linkend="gchar">gchar</link>&#160;*<structfield>arg_description</structfield>;</term>
<listitem><simpara> The placeholder to use for the extra argument parsed
 by the option in <option>--help</option>
 output. The <parameter>arg_description</parameter> is translated using the <parameter>translate_func</parameter> of the
 group, see <link linkend="g-option-group-set-translation-domain"><function>g_option_group_set_translation_domain()</function></link>.
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="g-option-context-add-main-entries" role="function" condition="since:2.6">
<title>g_option_context_add_main_entries ()</title>
<indexterm zone="g-option-context-add-main-entries" role="2.6"><primary sortas="option_context_add_main_entries">g_option_context_add_main_entries</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_context_add_main_entries   (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         const <link linkend="GOptionEntry">GOptionEntry</link> *entries,
                                                         const <link linkend="gchar">gchar</link> *translation_domain);</programlisting>
<para>
A convenience function which creates a main group if it doesn't 
exist, adds the <parameter>entries</parameter> to it and sets the translation domain.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>entries</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="NULL--CAPS"><literal>NULL</literal></link>-terminated array of <link linkend="GOptionEntry"><type>GOptionEntry</type></link><!-- -->s
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>translation_domain</parameter>&#160;:</term>
<listitem><simpara> a translation domain to use for translating
   the <option>--help</option> output for the options in <parameter>entries</parameter>
   with <link linkend="gettext"><function>gettext()</function></link>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="GOptionGroup" role="struct">
<title>GOptionGroup</title>
<indexterm zone="GOptionGroup"><primary sortas="OptionGroup">GOptionGroup</primary></indexterm><programlisting>typedef struct _GOptionGroup GOptionGroup;</programlisting>
<para>
A <structname>GOptionGroup</structname> struct defines the options in a single
group. The struct has only private fields and should not be directly accessed. 
</para>
<para>
All options in a group share the same translation function. Libaries which
need to parse commandline options are expected to provide a function for
getting a <structname>GOptionGroup</structname> holding their options, which 
the application can then add to its <link linkend="GOptionContext"><type>GOptionContext</type></link>.</para>
<para>
</para></refsect2>
<refsect2 id="g-option-context-add-group" role="function" condition="since:2.6">
<title>g_option_context_add_group ()</title>
<indexterm zone="g-option-context-add-group" role="2.6"><primary sortas="option_context_add_group">g_option_context_add_group</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_context_add_group          (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="GOptionGroup">GOptionGroup</link> *group);</programlisting>
<para>
Adds a <link linkend="GOptionGroup"><type>GOptionGroup</type></link> to the <parameter>context</parameter>, so that parsing with <parameter>context</parameter>
will recognize the options in the group. Note that the group will
be freed together with the context when <link linkend="g-option-context-free"><function>g_option_context_free()</function></link> is
called, so you must not free the group yourself after adding it
to a context.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara> the group to add
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-option-context-set-main-group" role="function" condition="since:2.6">
<title>g_option_context_set_main_group ()</title>
<indexterm zone="g-option-context-set-main-group" role="2.6"><primary sortas="option_context_set_main_group">g_option_context_set_main_group</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_context_set_main_group     (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="GOptionGroup">GOptionGroup</link> *group);</programlisting>
<para>
Sets a <link linkend="GOptionGroup"><type>GOptionGroup</type></link> as main group of the <parameter>context</parameter>. 
This has the same effect as calling <link linkend="g-option-context-add-group"><function>g_option_context_add_group()</function></link>, 
the only difference is that the options in the main group are 
treated differently when generating <option>--help</option> output.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara> the group to set as main group
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-option-context-get-main-group" role="function" condition="since:2.6">
<title>g_option_context_get_main_group ()</title>
<indexterm zone="g-option-context-get-main-group" role="2.6"><primary sortas="option_context_get_main_group">g_option_context_get_main_group</primary></indexterm><programlisting><link linkend="GOptionGroup">GOptionGroup</link> *      g_option_context_get_main_group     (<link linkend="GOptionContext">GOptionContext</link> *context);</programlisting>
<para>
Returns a pointer to the main group of <parameter>context</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the main group of <parameter>context</parameter>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if <parameter>context</parameter> doesn't
 have a main group. Note that group belongs to <parameter>context</parameter> and should
 not be modified or freed.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-option-group-new" role="function" condition="since:2.6">
<title>g_option_group_new ()</title>
<indexterm zone="g-option-group-new" role="2.6"><primary sortas="option_group_new">g_option_group_new</primary></indexterm><programlisting><link linkend="GOptionGroup">GOptionGroup</link> *      g_option_group_new                  (const <link linkend="gchar">gchar</link> *name,
                                                         const <link linkend="gchar">gchar</link> *description,
                                                         const <link linkend="gchar">gchar</link> *help_description,
                                                         <link linkend="gpointer">gpointer</link> user_data,
                                                         <link linkend="GDestroyNotify">GDestroyNotify</link> destroy);</programlisting>
<para>
Creates a new <link linkend="GOptionGroup"><type>GOptionGroup</type></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>name</parameter>&#160;:</term>
<listitem><simpara> the name for the option group, this is used to provide
  help for the options in this group with <option>--help-</option><parameter>name</parameter>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>description</parameter>&#160;:</term>
<listitem><simpara> a description for this group to be shown in 
  <option>--help</option>. This string is translated using the translation
  domain or translation function of the group
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>help_description</parameter>&#160;:</term>
<listitem><simpara> a description for the <option>--help-</option><parameter>name</parameter> option.
  This string is translated using the translation domain or translation function
  of the group
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>user_data</parameter>&#160;:</term>
<listitem><simpara> user data that will be passed to the pre- and post-parse hooks,
  the error hook and to callbacks of <link linkend="G-OPTION-ARG-CALLBACK--CAPS"><literal>G_OPTION_ARG_CALLBACK</literal></link> options, or <link linkend="NULL--CAPS"><literal>NULL</literal></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>destroy</parameter>&#160;:</term>
<listitem><simpara> a function that will be called to free <parameter>user_data</parameter>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a newly created option group. It should be added 
  to a <link linkend="GOptionContext"><type>GOptionContext</type></link> or freed with <link linkend="g-option-group-free"><function>g_option_group_free()</function></link>.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-option-group-free" role="function" condition="since:2.6">
<title>g_option_group_free ()</title>
<indexterm zone="g-option-group-free" role="2.6"><primary sortas="option_group_free">g_option_group_free</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_group_free                 (<link linkend="GOptionGroup">GOptionGroup</link> *group);</programlisting>
<para>
Frees a <link linkend="GOptionGroup"><type>GOptionGroup</type></link>. Note that you must <emphasis>not</emphasis>
free groups which have been added to a <link linkend="GOptionContext"><type>GOptionContext</type></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionGroup"><type>GOptionGroup</type></link>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-option-group-add-entries" role="function" condition="since:2.6">
<title>g_option_group_add_entries ()</title>
<indexterm zone="g-option-group-add-entries" role="2.6"><primary sortas="option_group_add_entries">g_option_group_add_entries</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_group_add_entries          (<link linkend="GOptionGroup">GOptionGroup</link> *group,
                                                         const <link linkend="GOptionEntry">GOptionEntry</link> *entries);</programlisting>
<para>
Adds the options specified in <parameter>entries</parameter> to <parameter>group</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionGroup"><type>GOptionGroup</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>entries</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="NULL--CAPS"><literal>NULL</literal></link>-terminated array of <link linkend="GOptionEntry"><type>GOptionEntry</type></link><!-- -->s
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="GOptionParseFunc" role="function">
<title>GOptionParseFunc ()</title>
<indexterm zone="GOptionParseFunc"><primary sortas="OptionParseFunc">GOptionParseFunc</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            (*GOptionParseFunc)                 (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="GOptionGroup">GOptionGroup</link> *group,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GError">GError</link> **error);</programlisting>
<para>
The type of function that can be called before and after parsing.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> The active <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara> The group to which the function belongs
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> User data added to the <link linkend="GOptionGroup"><type>GOptionGroup</type></link> containing the option when it
 was created with <link linkend="g-option-group-new"><function>g_option_group_new()</function></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>error</parameter>&#160;:</term>
<listitem><simpara> A return location for error details
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the function completed successfully, <link linkend="FALSE--CAPS"><literal>FALSE</literal></link> if an error 
 occurred, in which case <parameter>error</parameter> should be set with <link linkend="g-set-error"><function>g_set_error()</function></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-option-group-set-parse-hooks" role="function" condition="since:2.6">
<title>g_option_group_set_parse_hooks ()</title>
<indexterm zone="g-option-group-set-parse-hooks" role="2.6"><primary sortas="option_group_set_parse_hooks">g_option_group_set_parse_hooks</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_group_set_parse_hooks      (<link linkend="GOptionGroup">GOptionGroup</link> *group,
                                                         <link linkend="GOptionParseFunc">GOptionParseFunc</link> pre_parse_func,
                                                         <link linkend="GOptionParseFunc">GOptionParseFunc</link> post_parse_func);</programlisting>
<para>
Associates two functions with <parameter>group</parameter> which will be called 
from <link linkend="g-option-context-parse"><function>g_option_context_parse()</function></link> before the first option is parsed
and after the last option has been parsed, respectively.
</para>
<para>
Note that the user data to be passed to <parameter>pre_parse_func</parameter> and
<parameter>post_parse_func</parameter> can be specified when constructing the group
with <link linkend="g-option-group-new"><function>g_option_group_new()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionGroup"><type>GOptionGroup</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>pre_parse_func</parameter>&#160;:</term>
<listitem><simpara> a function to call before parsing, or <link linkend="NULL--CAPS"><literal>NULL</literal></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>post_parse_func</parameter>&#160;:</term>
<listitem><simpara> a function to call after parsing, or <link linkend="NULL--CAPS"><literal>NULL</literal></link>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="GOptionErrorFunc" role="function">
<title>GOptionErrorFunc ()</title>
<indexterm zone="GOptionErrorFunc"><primary sortas="OptionErrorFunc">GOptionErrorFunc</primary></indexterm><programlisting><link linkend="void">void</link>                (*GOptionErrorFunc)                 (<link linkend="GOptionContext">GOptionContext</link> *context,
                                                         <link linkend="GOptionGroup">GOptionGroup</link> *group,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GError">GError</link> **error);</programlisting>
<para>
The type of function to be used as callback when a parse error occurs.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> The active <link linkend="GOptionContext"><type>GOptionContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara> The group to which the function belongs
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> User data added to the <link linkend="GOptionGroup"><type>GOptionGroup</type></link> containing the option when it
 was created with <link linkend="g-option-group-new"><function>g_option_group_new()</function></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>error</parameter>&#160;:</term>
<listitem><simpara> The <link linkend="GError"><type>GError</type></link> containing details about the parse error
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-option-group-set-error-hook" role="function" condition="since:2.6">
<title>g_option_group_set_error_hook ()</title>
<indexterm zone="g-option-group-set-error-hook" role="2.6"><primary sortas="option_group_set_error_hook">g_option_group_set_error_hook</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_group_set_error_hook       (<link linkend="GOptionGroup">GOptionGroup</link> *group,
                                                         <link linkend="GOptionErrorFunc">GOptionErrorFunc</link> error_func);</programlisting>
<para>
Associates a function with <parameter>group</parameter> which will be called 
from <link linkend="g-option-context-parse"><function>g_option_context_parse()</function></link> when an error occurs.
</para>
<para>
Note that the user data to be passed to <parameter>error_func</parameter> can be
specified when constructing the group with <link linkend="g-option-group-new"><function>g_option_group_new()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionGroup"><type>GOptionGroup</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>error_func</parameter>&#160;:</term>
<listitem><simpara> a function to call when an error occurs
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-option-group-set-translate-func" role="function" condition="since:2.6">
<title>g_option_group_set_translate_func ()</title>
<indexterm zone="g-option-group-set-translate-func" role="2.6"><primary sortas="option_group_set_translate_func">g_option_group_set_translate_func</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_group_set_translate_func   (<link linkend="GOptionGroup">GOptionGroup</link> *group,
                                                         <link linkend="GTranslateFunc">GTranslateFunc</link> func,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GDestroyNotify">GDestroyNotify</link> destroy_notify);</programlisting>
<para>
Sets the function which is used to translate user-visible
strings, for <option>--help</option> output. Different
groups can use different <link linkend="GTranslateFunc"><type>GTranslateFunc</type></link><!-- -->s. If <parameter>func</parameter>
is <link linkend="NULL--CAPS"><literal>NULL</literal></link>, strings are not translated.
</para>
<para>
If you are using <link linkend="gettext"><function>gettext()</function></link>, you only need to set the translation
domain, see <link linkend="g-option-group-set-translation-domain"><function>g_option_group_set_translation_domain()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionGroup"><type>GOptionGroup</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>func</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GTranslateFunc"><type>GTranslateFunc</type></link>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> user data to pass to <parameter>func</parameter>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>destroy_notify</parameter>&#160;:</term>
<listitem><simpara> a function which gets called to free <parameter>data</parameter>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-option-group-set-translation-domain" role="function" condition="since:2.6">
<title>g_option_group_set_translation_domain ()</title>
<indexterm zone="g-option-group-set-translation-domain" role="2.6"><primary sortas="option_group_set_translation_domain">g_option_group_set_translation_domain</primary></indexterm><programlisting><link linkend="void">void</link>                g_option_group_set_translation_domain
                                                        (<link linkend="GOptionGroup">GOptionGroup</link> *group,
                                                         const <link linkend="gchar">gchar</link> *domain);</programlisting>
<para>
A convenience function to use <link linkend="gettext"><function>gettext()</function></link> for translating
user-visible strings.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GOptionGroup"><type>GOptionGroup</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>domain</parameter>&#160;:</term>
<listitem><simpara> the domain to use
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>

</refsect1>




</refentry>
