[gtk+] gtk-launch: Add --version
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gtk-launch: Add --version
- Date: Sun, 31 Jan 2016 18:09:58 +0000 (UTC)
commit bc882a679d7e51baf1e61d31cfa75202e5a70e9b
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jan 31 12:05:35 2016 -0500
gtk-launch: Add --version
Support --version. Also improve the --help output cosmetically.
docs/reference/gtk/gtk-launch.xml | 9 ++++++++-
gtk/gtk-launch.c | 29 +++++++++++++++++++----------
2 files changed, 27 insertions(+), 11 deletions(-)
---
diff --git a/docs/reference/gtk/gtk-launch.xml b/docs/reference/gtk/gtk-launch.xml
index 1b2ba7b..86ffe6d 100644
--- a/docs/reference/gtk/gtk-launch.xml
+++ b/docs/reference/gtk/gtk-launch.xml
@@ -31,7 +31,8 @@
<refsynopsisdiv>
<cmdsynopsis>
<command>gtk-launch</command>
-<arg>APPLICATION</arg>
+<arg choice="opt" rep="repeat">OPTION</arg>
+<arg choice="plain">APPLICATION</arg>
<arg choice="opt" rep="repeat">URI</arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -62,6 +63,12 @@ application.
<listitem><para>Prints a short help text and exits.</para></listitem>
</varlistentry>
</variablelist>
+ <variablelist>
+ <varlistentry>
+ <term><option>--version</option></term>
+ <listitem><para>Prints the program version and exits.</para></listitem>
+ </varlistentry>
+ </variablelist>
</refsect1>
</refentry>
diff --git a/gtk/gtk-launch.c b/gtk/gtk-launch.c
index 15d183b..576a449 100644
--- a/gtk/gtk-launch.c
+++ b/gtk/gtk-launch.c
@@ -33,9 +33,11 @@
#endif
#include <gtk.h>
+static gboolean show_version;
static gchar **args = NULL;
static GOptionEntry entries[] = {
+ { "version", 0, 0, G_OPTION_ARG_NONE, &show_version, NULL, NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &args, NULL, NULL },
{ NULL}
};
@@ -66,14 +68,14 @@ main (int argc, char *argv[])
#endif
/* Translators: this message will appear immediately after the */
- /* usage string - Usage: COMMAND [OPTION]… <THIS_MESSAGE> */
+ /* usage string - Usage: COMMAND [OPTION...] <THIS_MESSAGE> */
context =
- g_option_context_new (_("APPLICATION [URI…] — launch an APPLICATION with URI."));
+ g_option_context_new (_("APPLICATION [URI...] — launch an APPLICATION"));
/* Translators: this message will appear after the usage string */
/* and before the list of options. */
- summary = _("Launch specified application by its desktop file info\n"
- "optionally passing list of URIs as arguments.");
+ summary = _("Launch an application (specified by its desktop file name),\n"
+ "optionally passing one or more URIs as arguments.");
g_option_context_set_summary (context, summary);
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_add_group (context, gtk_get_option_group (FALSE));
@@ -86,21 +88,28 @@ main (int argc, char *argv[])
{
g_printerr (_("Error parsing commandline options: %s\n"), error->message);
g_printerr ("\n");
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
- g_error_free(error);
+ g_error_free (error);
return 1;
}
+ if (show_version)
+ {
+ g_print ("%d.%d.%d\n",
+ gtk_get_major_version (),
+ gtk_get_minor_version (),
+ gtk_get_micro_version ());
+ return 0;
+ }
+
if (!args)
{
/* Translators: the %s is the program name. This error message */
/* means the user is calling gtk-launch without any argument. */
g_printerr (_("%s: missing application name"), g_get_prgname ());
g_printerr ("\n");
- g_printerr (_("Try \"%s --help\" for more information."),
- g_get_prgname ());
+ g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
g_printerr ("\n");
return 1;
}
@@ -112,7 +121,7 @@ main (int argc, char *argv[])
#ifdef G_OS_UNIX
if (g_str_has_suffix (app_name, ".desktop"))
desktop_file_name = g_strdup (app_name);
- else
+ else
desktop_file_name = g_strconcat (app_name, ".desktop", NULL);
info = G_APP_INFO (g_desktop_app_info_new (desktop_file_name));
g_free (desktop_file_name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]