context = g_option_context_new (NULL);
+ /* If the application has not registered local options and it has
+ * G_APPLICATION_HANDLES_COMMAND_LINE then we have to assume that
+ * their primary instance commandline handler may want to deal with
+ * the arguments. We must therefore ignore them.
+ *
+ * We must also ignore --help in this case since some applications
+ * will try to handle this from the remote side. See #737869.
+ */
+ if (application->priv->main_options == NULL && (application->priv->flags & G_APPLICATION_HANDLES_COMMAND_LINE))
+ {
+ g_option_context_set_ignore_unknown_options (context, TRUE);
+ g_option_context_set_help_enabled (context, FALSE);
+ }
+
/* Add the main option group, if it exists */
if (application->priv->main_options)
{
application->priv->option_groups);
}
- /* If the application has not registered local options and it has
- * G_APPLICATION_HANDLES_COMMAND_LINE then we have to assume that
- * their primary instance commandline handler may want to deal with
- * the arguments. We must therefore ignore them.
- */
- if (application->priv->main_options == NULL && (application->priv->flags & G_APPLICATION_HANDLES_COMMAND_LINE))
- g_option_context_set_ignore_unknown_options (context, TRUE);
-
/* In the case that we are not explicitly marked as a service or a
* launcher then we want to add the "--gapplication-service" option to
* allow the process to be made into a service.
g_application_add_main_option (GApplication *application,
const char *long_name,
char short_name,
- gint flags,
+ GOptionFlags flags,
GOptionArg arg,
const char *description,
const char *arg_description)
if (application->priv->notifications)
g_object_unref (application->priv->notifications);
+ g_free (application->priv->resource_path);
+
G_OBJECT_CLASS (g_application_parent_class)
->finalize (object);
}
* decide to perform certain actions, including direct local handling
* (which may be useful for options like --version).
*
- * If the options have been "handled" then a non-negative value should
- * be returned. In this case, the return value is the exit status: 0
- * for success and a positive value for failure. -1 means to continue
- * normal processing.
- *
* In the event that the application is marked
* %G_APPLICATION_HANDLES_COMMAND_LINE the "normal processing" will
* send the @option dictionary to the primary instance where it can be
* capabilities than what is provided here, but this should not
* normally be required.
*
+ * Returns: an exit code. If you have handled your options and want
+ * to exit the process, return a non-negative option, 0 for success,
+ * and a positive value for failure. To continue, return -1 to let
+ * the default option processing continue.
+ *
* Since: 2.40
**/
g_application_signals[SIGNAL_HANDLE_LOCAL_OPTIONS] =
*/
void
g_application_set_resource_base_path (GApplication *application,
- const gchar *resource_path)
+ const gchar *resource_path)
{
g_return_if_fail (G_IS_APPLICATION (application));
g_return_if_fail (resource_path == NULL || g_str_has_prefix (resource_path, "/"));