[gedit/wip/gtkapp: 11/17] Handle the help by ourselves in the local command line
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/gtkapp: 11/17] Handle the help by ourselves in the local command line
- Date: Sun, 18 Nov 2012 10:45:33 +0000 (UTC)
commit f0c92519d52071493baacbbb542419199f377f66
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Tue Jul 31 13:11:41 2012 +0200
Handle the help by ourselves in the local command line
gedit/gedit-app.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index 1aa3852..c5ec757 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -94,6 +94,7 @@ struct _GeditAppPrivate
static GeditApp *app_instance = NULL;
+static gboolean help = FALSE;
static gboolean version = FALSE;
static gboolean list_encodings = FALSE;
static gchar *encoding_charset = NULL;
@@ -107,6 +108,12 @@ static gchar **remaining_args = NULL;
static const GOptionEntry options[] =
{
+ /* Help */
+ {
+ "help", '?', 0, G_OPTION_ARG_NONE, &help,
+ N_("Show the application's help"), NULL
+ },
+
/* Version */
{
"version", 'V', 0, G_OPTION_ARG_NONE, &version,
@@ -421,6 +428,7 @@ gedit_app_command_line (GApplication *application,
/* Setup command line options */
context = g_option_context_new (_("- Edit text files"));
+ g_option_context_set_help_enabled (context, FALSE);
g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
g_option_context_add_group (context, gtk_get_option_group (TRUE));
@@ -534,6 +542,7 @@ gedit_app_command_line (GApplication *application,
g_free (geometry);
/* reset values for the next call */
+ help = FALSE;
version = FALSE;
list_encodings = FALSE;
encoding_charset = NULL;
@@ -559,6 +568,7 @@ gedit_app_local_command_line (GApplication *application,
gint argc;
argv = *arguments;
+ argc = g_strv_length (*arguments);
g_message ("local command line");
*exit_status = 0;
@@ -579,6 +589,14 @@ gedit_app_local_command_line (GApplication *application,
g_error_free (error);
*exit_status = 1;
}
+ else if (help)
+ {
+ gchar *text = g_option_context_get_help(context, FALSE, NULL);
+ g_print ("%s\n", text);
+ g_free (text);
+
+ return TRUE;
+ }
else if (version)
{
g_print ("%s - Version %s\n", g_get_application_name (), VERSION);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]