X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Ftests%2Fgapplication-example-cmdline3.c;h=b95e0cbc8bcb5dcab59dace96fe71036dbec2021;hb=b5ba22f163f884f14724b54d001bd044308f9f63;hp=3d0c8b17ad479cae84a70c1d30a74764f92348ce;hpb=54e474931e4013cf0088df479018d9b7b156e637;p=platform%2Fupstream%2Fglib.git diff --git a/gio/tests/gapplication-example-cmdline3.c b/gio/tests/gapplication-example-cmdline3.c index 3d0c8b1..b95e0cb 100644 --- a/gio/tests/gapplication-example-cmdline3.c +++ b/gio/tests/gapplication-example-cmdline3.c @@ -11,10 +11,12 @@ my_cmdline_handler (gpointer data) gint argc; gint arg1; gboolean arg2; + gboolean help; GOptionContext *context; GOptionEntry entries[] = { { "arg1", 0, 0, G_OPTION_ARG_INT, &arg1, NULL, NULL }, { "arg2", 0, 0, G_OPTION_ARG_NONE, &arg2, NULL, NULL }, + { "help", '?', 0, G_OPTION_ARG_NONE, &help, NULL, NULL }, { NULL } }; GError *error; @@ -30,10 +32,12 @@ my_cmdline_handler (gpointer data) argv[i] = args[i]; context = g_option_context_new (NULL); + g_option_context_set_help_enabled (context, FALSE); g_option_context_add_main_entries (context, entries, NULL); arg1 = 0; arg2 = FALSE; + help = FALSE; error = NULL; if (!g_option_context_parse (context, &argc, &argv, &error)) { @@ -41,6 +45,13 @@ my_cmdline_handler (gpointer data) g_error_free (error); g_application_command_line_set_exit_status (cmdline, 1); } + else if (help) + { + gchar *text; + text = g_option_context_get_help (context, FALSE, NULL); + g_application_command_line_print (cmdline, "%s", text); + g_free (text); + } else { g_application_command_line_print (cmdline, "arg1 is %d and arg2 is %s\n", @@ -56,7 +67,7 @@ my_cmdline_handler (gpointer data) /* we are done handling this commandline */ g_object_unref (cmdline); - return FALSE; + return G_SOURCE_REMOVE; } static int