[gnome-logs] Handle --version command line option
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-logs] Handle --version command line option
- Date: Fri, 21 Feb 2014 23:09:17 +0000 (UTC)
commit 7035a18a10f8895dcdbd942125d89339dc126489
Author: Paolo Borelli <pborelli gnome org>
Date: Thu Feb 20 22:54:13 2014 +0100
Handle --version command line option
configure.ac | 2 +-
src/gl-application.c | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 019bf4e..a6f2268 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,7 +84,7 @@ AS_IF([test "x$have_desktop_file_validate" = "xyes"],
AM_CONDITIONAL([LOGS_ENABLE_TESTS], [test "x$testing_utilities" = "xyes"])
dnl Libraries
-GIO_REQUIRED="gio-unix-2.0"
+GIO_REQUIRED="gio-unix-2.0 >= 2.39.90"
GTK_REQUIRED="gtk+-3.0 >= 3.9.6"
SYSTEMD_JOURNAL_REQUIRED="libsystemd-journal"
PKG_CHECK_MODULES([LOGS], [$GIO_REQUIRED $GTK_REQUIRED $SYSTEMD_JOURNAL_REQUIRED])
diff --git a/src/gl-application.c b/src/gl-application.c
index 3d08e14..404fcb3 100644
--- a/src/gl-application.c
+++ b/src/gl-application.c
@@ -217,6 +217,26 @@ gl_application_activate (GApplication *application)
priv);
}
+static const GOptionEntry options[] =
+{
+ { "version", 'v', 0, G_OPTION_ARG_NONE, NULL,
+ N_("Print version information and exit"), NULL },
+ { NULL }
+};
+
+static gint
+gl_application_handle_local_options (GApplication *application,
+ GVariantDict *options)
+{
+ if (g_variant_dict_contains (options, "version"))
+ {
+ g_print ("%s - Version %s\n", g_get_application_name (), PACKAGE_VERSION);
+ return 0;
+ }
+
+ return -1;
+}
+
static void
gl_application_finalize (GObject *object)
{
@@ -241,6 +261,8 @@ gl_application_init (GlApplication *application)
priv->monospace_font = NULL;
priv->desktop = g_settings_new (DESKTOP_SCHEMA);
+ g_application_add_main_option_entries (G_APPLICATION (application), options);
+
changed_font = g_strconcat ("changed::", DESKTOP_MONOSPACE_FONT_NAME, NULL);
g_signal_connect (priv->desktop, changed_font,
G_CALLBACK (on_monospace_font_name_changed),
@@ -261,6 +283,7 @@ gl_application_class_init (GlApplicationClass *klass)
app_class = G_APPLICATION_CLASS (klass);
app_class->activate = gl_application_activate;
app_class->startup = gl_application_startup;
+ app_class->handle_local_options = gl_application_handle_local_options;
}
GtkApplication *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]