[gnome-2048] Add --version command-line option.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-2048] Add --version command-line option.
- Date: Tue, 29 Oct 2019 00:26:21 +0000 (UTC)
commit 5e0116fa89e2cd17368ed135492ee7d5571c22f7
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Mon Oct 28 16:25:58 2019 +0100
Add --version command-line option.
Bump GLib required version
to 2.42. And add man page.
data/gnome-2048.6 | 41 +++++++++++++++++++++++++++++++++++++++++
data/meson.build | 11 +++++++++++
meson.build | 4 ++--
src/application.vala | 24 +++++++++++++++++++++++-
4 files changed, 77 insertions(+), 3 deletions(-)
---
diff --git a/data/gnome-2048.6 b/data/gnome-2048.6
new file mode 100644
index 0000000..560ae1a
--- /dev/null
+++ b/data/gnome-2048.6
@@ -0,0 +1,41 @@
+.\"
+.\" Copyright (C) 2019 Arnaud Bonatti <arnaud bonatti gmail com>
+.\"
+.\" This file is part of GNOME 2048.
+.\"
+.\" GNOME 2048 is free software: you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation, either version 3 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" GNOME 2048 is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License
+.\" along with GNOME 2048. If not, see <https://www.gnu.org/licenses/>.
+.\"
+.TH GNOME-2048 6 "2019\-10\-28" "GNOME"
+.SH NAME
+GNOME 2048 \- Obtain the highest possible tile
+.SH SYNOPSIS
+.B gnome-2048
+.RI [ OPTION... ]
+.SH DESCRIPTION
+2048 is a highly addictive single-player game. Gameplay consists of joining numbers in a grid for obtaining
bigger values.
+
+Use your keyboard’s arrow keys or gestures to slide all tiles in the desired direction. Be careful: all
tiles slide to their farthest possible positions, you cannot slide just one tile or one row or column. Tiles
with the same value are joined when slided one over the other. After your turn, one new tile is added to the
game.
+
+Gnome 2048 only adds tiles of value 2, as opposed to the original 2048 game. Also, it allows you to play on
grids of various size.
+.SH OPTIONS
+.TP
+.B \-v, \-\-version
+Prints the program version and exits.
+.P
+This program also accepts the standard GTK+ options.
+.SH AUTHORS
+.B gnome-2048
+was written by Juan R. García Blanco and is maintained by Arnaud Bonatti.
+.P
+This manual page was written by Arnaud Bonatti <arnaud bonatti gmail com>.
diff --git a/data/meson.build b/data/meson.build
index f138f16..33f73ca 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,3 +1,4 @@
+# Install icons
install_data(
join_paths('icons', 'org.gnome.TwentyFortyEight.svg'),
install_dir: join_paths(icondir, 'scalable', 'apps'),
@@ -8,11 +9,13 @@ install_data(
install_dir: join_paths(icondir, 'symbolic', 'apps'),
)
+# Install gschema
install_data(
'org.gnome.TwentyFortyEight.gschema.xml',
install_dir: schemadir,
)
+# Desktop file
desktop_file = i18n.merge_file(
'desktop-file',
input: 'org.gnome.TwentyFortyEight.desktop.in',
@@ -22,6 +25,8 @@ desktop_file = i18n.merge_file(
po_dir: podir,
type: 'desktop',
)
+
+# Validate desktop file
if desktop_file_validate.found()
test(
'Validating @0@'.format(desktop_file),
@@ -30,6 +35,7 @@ if desktop_file_validate.found()
)
endif
+# AppData file
appdata_file = i18n.merge_file(
'appdata-file',
input: 'org.gnome.TwentyFortyEight.appdata.xml.in',
@@ -38,6 +44,8 @@ appdata_file = i18n.merge_file(
install_dir: join_paths(datadir, 'metainfo'),
po_dir: podir,
)
+
+# Validate AppData file
if appstream_util.found()
test(
'Validating @0@'.format(appdata_file),
@@ -45,3 +53,6 @@ if appstream_util.found()
args: ['validate', '--nonet', appdata_file],
)
endif
+
+# Install man page
+install_man('@0@.6'.format(meson.project_name()))
diff --git a/meson.build b/meson.build
index 5bf2758..7ca6fa2 100644
--- a/meson.build
+++ b/meson.build
@@ -26,8 +26,8 @@ podir = join_paths(meson.current_source_dir(), 'po')
# Dependencies
posix_dependency = valac.find_library('posix')
libm_dependency = cc.find_library('m', required: false) # some platforms do not have libm separated from libc
-gio_dependency = dependency('gio-2.0', version: '>= 2.40.0')
-glib_dependency = dependency('glib-2.0', version: '>= 2.40.0')
+gio_dependency = dependency('gio-2.0', version: '>= 2.42.0')
+glib_dependency = dependency('glib-2.0', version: '>= 2.42.0')
gtk_dependency = dependency('gtk+-3.0', version: '>= 3.22.23')
clutter_dependency = dependency('clutter-1.0', version: '>= 1.12.0')
clutter_gtk_dependency = dependency('clutter-gtk-1.0', version: '>= 1.6.0')
diff --git a/src/application.vala b/src/application.vala
index 34ffe5d..d509f54 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -24,7 +24,15 @@ private class TwentyFortyEight : Gtk.Application
{
private GameWindow _window;
- /* actions */
+ private static bool show_version;
+
+ private const OptionEntry [] option_entries =
+ {
+ /* Translators: command-line option description, see 'gnome-2048 --help' */
+ { "version", 'v', OptionFlags.NONE, OptionArg.NONE, ref show_version, N_("Print release version and
exit"), null },
+ {}
+ };
+
private const GLib.ActionEntry [] action_entries =
{
{ "quit", quit_cb }
@@ -38,6 +46,7 @@ private class TwentyFortyEight : Gtk.Application
Intl.textdomain (GETTEXT_PACKAGE);
OptionContext context = new OptionContext ("");
+ context.add_main_entries (option_entries, GETTEXT_PACKAGE);
context.add_group (get_option_group (true));
context.add_group (Clutter.get_option_group_without_init ());
@@ -76,6 +85,19 @@ private class TwentyFortyEight : Gtk.Application
Object (application_id: "org.gnome.TwentyFortyEight", flags: ApplicationFlags.FLAGS_NONE);
}
+ protected override int handle_local_options (GLib.VariantDict options)
+ {
+ if (show_version)
+ {
+ /* NOTE: Is not translated so can be easily parsed */
+ stdout.printf ("%1$s %2$s\n", "gnome-2048", VERSION);
+ return Posix.EXIT_SUCCESS;
+ }
+
+ /* Activate */
+ return -1;
+ }
+
protected override void startup ()
{
base.startup ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]