[baobab] Use new method to deal with command line options



commit d8174c9a52ecd32454ff55d4b9e02f3f55ea76b9
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Feb 16 23:08:35 2014 +0100

    Use new method to deal with command line options

 src/baobab-application.vala |   28 ++++++----------------------
 1 files changed, 6 insertions(+), 22 deletions(-)
---
diff --git a/src/baobab-application.vala b/src/baobab-application.vala
index a51d83d..2751d52 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -25,9 +25,8 @@ namespace Baobab {
     public class Application : Gtk.Application {
         static Application baobab;
 
-        static bool print_version;
         const OptionEntry[] option_entries = {
-            { "version", 'v', 0, OptionArg.NONE, ref print_version, N_("Print version information and 
exit"), null },
+            { "version", 'v', 0, OptionArg.NONE, null, N_("Print version information and exit"), null },
             { null }
         };
 
@@ -95,29 +94,13 @@ namespace Baobab {
             add_accelerator ("<Primary>r", "win.reload", null);
         }
 
-        protected override bool local_command_line ([CCode (array_length = false, array_null_terminated = 
true)] ref unowned string[] arguments, out int exit_status) {
-            var ctx = new OptionContext (_("- Disk Usage Analyzer"));
-
-            ctx.add_main_entries (option_entries, Config.GETTEXT_PACKAGE);
-            ctx.add_group (Gtk.get_option_group (true));
-
-            // Workaround for bug #642885
-            unowned string[] argv = arguments;
-
-            try {
-                ctx.parse (ref argv);
-            } catch (Error e) {
-                exit_status = 1;
-                return true;
-            }
-
-            if (print_version) {
+        protected override int handle_local_options (GLib.VariantDict options) {
+            if (options.contains("version")) {
                 print ("%s %s\n", Environment.get_application_name (), Config.VERSION);
-                exit_status = 0;
-                return true;
+                return 0;
             }
 
-            return base.local_command_line (ref arguments, out exit_status);
+            return -1; 
         }
 
         protected override void shutdown () {
@@ -128,6 +111,7 @@ namespace Baobab {
         public Application () {
             Object (application_id: "org.gnome.baobab", flags: ApplicationFlags.HANDLES_OPEN);
 
+            add_main_option_entries (option_entries);
             add_action_entries (action_entries, this);
         }
 


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