[dconf-editor] Add --version command-line option.



commit 314dc51ef7487f7c5053c22b7564eff88684474d
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Mon Feb 23 13:18:38 2015 +0100

    Add --version command-line option.

 editor/Makefile.am       |   73 ++++++++++++++++++++++++---------------------
 editor/dconf-editor.vala |   21 +++++++++++++
 2 files changed, 60 insertions(+), 34 deletions(-)
---
diff --git a/editor/Makefile.am b/editor/Makefile.am
index da74778..bdb0142 100644
--- a/editor/Makefile.am
+++ b/editor/Makefile.am
@@ -1,28 +1,33 @@
 bin_PROGRAMS = dconf-editor
 
-dconf_editor_VALAFLAGS = --pkg gtk+-3.0 --pkg gmodule-2.0 --pkg libxml-2.0 --pkg dconf
+dconf_editor_VALAFLAGS = \
+       --pkg posix \
+       --pkg gtk+-3.0 \
+       --pkg gmodule-2.0 \
+       --pkg libxml-2.0 \
+       --pkg dconf
 
 dconf_editor_LDADD = \
-       $(dconf_LIBS)                   \
-       $(gtk_LIBS)                     \
-       $(gee_LIBS)                     \
-       $(gmodule_LIBS)                 \
+       $(dconf_LIBS) \
+       $(gtk_LIBS) \
+       $(gee_LIBS) \
+       $(gmodule_LIBS) \
        $(libxml_LIBS)
 
 dconf_editor_CFLAGS = \
-       $(dconf_CFLAGS)                         \
-       $(gtk_CFLAGS)                           \
-       $(gee_CFLAGS)                           \
-       $(libxml_CFLAGS)                        \
-       -DPKGDATADIR=\"$(pkgdatadir)\"          \
-       -DVERSION=\"$(VERSION)\"                \
-       -DLOCALEDIR=\"$(localedir)\"            \
-       -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\"\
+       $(dconf_CFLAGS) \
+       $(gtk_CFLAGS) \
+       $(gee_CFLAGS) \
+       $(libxml_CFLAGS) \
+       -DPKGDATADIR=\"$(pkgdatadir)\" \
+       -DVERSION=\"$(VERSION)\" \
+       -DLOCALEDIR=\"$(localedir)\" \
+       -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
        -w
 
 resource_data = \
-       dconf-editor.gresource.xml      \
-       dconf-editor-menu.ui            \
+       dconf-editor.gresource.xml \
+       dconf-editor-menu.ui \
        dconf-editor.ui
 
 resources.c: $(resource_data)
@@ -31,10 +36,10 @@ resources.c: $(resource_data)
 nodist_dconf_editor_SOURCES = resources.c
 
 dconf_editor_SOURCES = \
-       config.vapi             \
-       dconf-editor.vala       \
-       dconf-model.vala        \
-       dconf-schema.vala       \
+       config.vapi \
+       dconf-editor.vala \
+       dconf-model.vala \
+       dconf-schema.vala \
        dconf-view.vala
 
 desktopdir = $(datadir)/applications
@@ -47,9 +52,9 @@ dbusservice_DATA = ca.desrt.dconf-editor.service
 
 ca.desrt.dconf-editor.service: Makefile
        $(AM_V_GEN) (echo '[D-BUS Service]'; \
-                    echo 'Name=ca.desrt.dconf-editor'; \
-                    echo 'Exec=${bindir}/dconf-editor --gapplication-service') > $  tmp && \
-                    mv $  tmp $@
+                    echo 'Name=ca.desrt.dconf-editor'; \
+                    echo 'Exec=${bindir}/dconf-editor --gapplication-service') > $  tmp && \
+                    mv $  tmp $@
 
 CLEANFILES = $(desktop_DATA) $(dbusservice_DATA) resources.c
 
@@ -62,18 +67,18 @@ gsettings_SCHEMAS = ca.desrt.dconf-editor.gschema.xml
 nobase_data_DATA = $(icons)
 
 icons = \
-       icons/HighContrast/16x16/apps/dconf-editor.png          \
-       icons/HighContrast/22x22/apps/dconf-editor.png          \
-       icons/HighContrast/24x24/apps/dconf-editor.png          \
-       icons/HighContrast/32x32/apps/dconf-editor.png          \
-       icons/HighContrast/48x48/apps/dconf-editor.png          \
-       icons/HighContrast/256x256/apps/dconf-editor.png        \
-       icons/hicolor/16x16/apps/dconf-editor.png               \
-       icons/hicolor/22x22/apps/dconf-editor.png               \
-       icons/hicolor/24x24/apps/dconf-editor.png               \
-       icons/hicolor/32x32/apps/dconf-editor.png               \
-       icons/hicolor/48x48/apps/dconf-editor.png               \
-       icons/hicolor/64x64/apps/dconf-editor.png               \
+       icons/HighContrast/16x16/apps/dconf-editor.png \
+       icons/HighContrast/22x22/apps/dconf-editor.png \
+       icons/HighContrast/24x24/apps/dconf-editor.png \
+       icons/HighContrast/32x32/apps/dconf-editor.png \
+       icons/HighContrast/48x48/apps/dconf-editor.png \
+       icons/HighContrast/256x256/apps/dconf-editor.png \
+       icons/hicolor/16x16/apps/dconf-editor.png \
+       icons/hicolor/22x22/apps/dconf-editor.png \
+       icons/hicolor/24x24/apps/dconf-editor.png \
+       icons/hicolor/32x32/apps/dconf-editor.png \
+       icons/hicolor/48x48/apps/dconf-editor.png \
+       icons/hicolor/64x64/apps/dconf-editor.png \
        icons/hicolor/256x256/apps/dconf-editor.png
 
 install-data-hook: update-icon-cache
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index 854c923..f0a969f 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -24,6 +24,12 @@ class ConfigurationEditor : Gtk.Application
 
     private Key? selected_key;
 
+    private const OptionEntry[] option_entries =
+    {
+        { "version", 'v', 0, OptionArg.NONE, null, N_("Print release version and exit"), null },
+        { null }
+    };
+
     private const GLib.ActionEntry[] action_entries =
     {
         { "find",  find_cb  },
@@ -34,6 +40,21 @@ class ConfigurationEditor : Gtk.Application
     public ConfigurationEditor()
     {
         Object(application_id: "ca.desrt.dconf-editor", flags: ApplicationFlags.FLAGS_NONE);
+
+        add_main_option_entries (option_entries);
+    }
+
+    protected override int handle_local_options (GLib.VariantDict options)
+    {
+        if (options.contains ("version"))
+        {
+            /* NOTE: Is not translated so can be easily parsed */
+            stderr.printf ("%1$s %2$s\n", "dconf-editor", Config.VERSION);
+            return Posix.EXIT_SUCCESS;
+        }
+
+        /* Activate */
+        return -1;
     }
 
     protected override void startup()


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