[gtranslator: 1/2] Add version option to application
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator: 1/2] Add version option to application
- Date: Tue, 15 Mar 2022 07:11:26 +0000 (UTC)
commit ae0535f3eca2d89f4661f4bfc048f08dfb88b0f3
Author: redoC-A2k <afshanahmeda2k gmail com>
Date: Tue Mar 15 07:11:19 2022 +0000
Add version option to application
Fixes https://gitlab.gnome.org/GNOME/gtranslator/-/issues/150
src/gtr-application.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
---
diff --git a/src/gtr-application.c b/src/gtr-application.c
index db58041b..25f24ba1 100644
--- a/src/gtr-application.c
+++ b/src/gtr-application.c
@@ -162,6 +162,15 @@ on_window_destroy_cb (GtrWindow *window, GtrApplication *app)
set_active_window (app, windows != NULL ? windows->data : NULL);
}
+static int
+handle_local_options_cb (GApplication *application, GVariantDict *options, gpointer user_data) {
+ if (g_variant_dict_contains (options, "version")) {
+ g_print ("%s - %s\n", PACKAGE, PACKAGE_VERSION);
+ return 0;
+ }
+ return -1;
+}
+
static void
gtr_application_init (GtrApplication *application)
{
@@ -173,6 +182,15 @@ gtr_application_init (GtrApplication *application)
priv->last_dir = NULL;
priv->first_run = FALSE;
+ GOptionEntry options[] = {
+ {"version", 'v', 0, G_OPTION_ARG_NONE, NULL, "Print version information and exit", NULL},
+ {NULL}
+ };
+
+ g_application_add_main_option_entries (application, options);
+
+ g_signal_connect (application, "handle-local-options", handle_local_options_cb, NULL);
+
/* Creating config folder */
ensure_user_config_dir (); /* FIXME: is this really needed ? */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]