since: 2.40


g_application_add_option_group (
  GApplication* application,
  GOptionGroup* group


Adds a GOptionGroup to the commandline handling of application.

This function is comparable to g_option_context_add_group().

Unlike g_application_add_main_option_entries(), this function does not deal with NULL arg_data and never transmits options to the primary instance.

The reason for that is because, by the time the options arrive at the primary instance, it is typically too late to do anything with them. Taking the GTK option group as an example: GTK will already have been initialised by the time the GApplication::command-line handler runs. In the case that this is not the first-running instance of the application, the existing instance may already have been running for a very long time.

This means that the options from GOptionGroup are only really usable in the case that the instance of the application being run is the first instance. Passing options like --display= or --gdk-debug= on future runs will have no effect on the existing primary instance.

Calling this function will cause the options in the supplied option group to be parsed, but it does not cause you to be “opted in” to the new functionality whereby unrecognized options are rejected even if G_APPLICATION_HANDLES_COMMAND_LINE was given.

Available since: 2.40



Type: GOptionGroup

A GOptionGroup.

The instance takes ownership of the data, and is responsible for freeing it.