[easytag] Use GOptionContext for --help output



commit 4553b5d17edbc33a015a23d6207feea3bf45fc96
Author: David King <amigadave amigadave com>
Date:   Thu Jul 4 20:36:02 2013 +0100

    Use GOptionContext for --help output

 src/application.c |   44 +++++++++++++++-----------------------------
 1 files changed, 15 insertions(+), 29 deletions(-)
---
diff --git a/src/application.c b/src/application.c
index 8586b17..1be15e9 100644
--- a/src/application.c
+++ b/src/application.c
@@ -30,6 +30,13 @@ struct _EtApplicationPrivate
     GtkWindow *main_window;
 };
 
+static const GOptionEntry entries[] =
+{
+    { "version", 'v', 0, G_OPTION_ARG_NONE, NULL,
+      N_("Print the version and exit"), NULL },
+    { NULL }
+};
+
 static void
 init_i18n (void)
 {
@@ -40,34 +47,6 @@ init_i18n (void)
 #endif /* ENABLE_NLS */
 }
 
-static void
-display_usage (void)
-{
-/* Fix from Steve Ralston for gcc-3.2.2 */
-#ifdef G_OS_WIN32
-#define xPREFIX "c:"
-#else /* !G_OS_WIN32 */
-#define xPREFIX ""
-#endif /* !G_OS_WIN32 */
-
-    /* FIXME: Translators should not have to deal with this! */
-    g_print (_("\nUsage: easytag [option] "
-               "\n   or: easytag [directory]\n"
-               "\n"
-               "Option:\n"
-               "-------\n"
-               "-h, --help        Display this text and exit.\n"
-               "-v, --version     Print basic information and exit.\n"
-               "\n"
-               "Directory:\n"
-               "----------\n"
-               "%s/path_to/files  Use an absolute path to load,\n"
-               "path_to/files     Use a relative path.\n"
-               "\n"), xPREFIX);
-
-#undef xPREFIX
-}
-
 /*
  * et_local_command_line:
  * @application: the application
@@ -122,7 +101,14 @@ et_local_command_line (GApplication *application, gchar **arguments[],
         else if ((strcmp (argv[i], "--help") == 0)
                  || (strcmp (argv[i], "-h") == 0))
         {
-            display_usage ();
+            GOptionContext *context;
+            gchar *help;
+
+            context = g_option_context_new (_("- Tag and rename audio files"));
+            g_option_context_add_main_entries (context, entries,
+                                               GETTEXT_PACKAGE);
+            help = g_option_context_get_help (context, TRUE, NULL);
+            g_print ("%s", help);
             exit (0);
         }
         else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]