[swell-foop] Fixed swell foop not starting from launcher (fixes #22)



commit 614239dbe0f82e8de836cc5780e971366e09f035
Author: Robert Roth <robert roth bee-tf ro>
Date:   Thu Apr 8 09:39:01 2021 +0300

    Fixed swell foop not starting from launcher (fixes #22)

 src/swell-foop.vala | 41 +++++++++++++----------------------------
 1 file changed, 13 insertions(+), 28 deletions(-)
---
diff --git a/src/swell-foop.vala b/src/swell-foop.vala
index 1b330a8..13db7bf 100644
--- a/src/swell-foop.vala
+++ b/src/swell-foop.vala
@@ -19,11 +19,10 @@ public class SwellFoop : Gtk.Application
     private SwellFoopWindow window;
 
     /* Command-line options */
-    private static bool version = false;
     private const OptionEntry [] option_entries =
     {
         /* Translators: command-line option description, see 'swell-foop --help' */
-        { "version", 'v', OptionFlags.NONE, OptionArg.NONE, ref version, N_("Print release version and 
exit"), null },
+        { "version", 'v', OptionFlags.NONE, OptionArg.NONE, null, N_("Print release version and exit"), null 
},
 
         {}
     };
@@ -40,6 +39,8 @@ public class SwellFoop : Gtk.Application
     public SwellFoop ()
     {
         Object (application_id: "org.gnome.SwellFoop", flags: ApplicationFlags.FLAGS_NONE);
+        add_option_group (Clutter.get_option_group_without_init ());
+        add_main_option_entries (option_entries);
     }
 
     protected override void startup ()
@@ -58,7 +59,16 @@ public class SwellFoop : Gtk.Application
 
         /* Create the main window */
         window = new SwellFoopWindow (this);
-        add_window (window);
+    }
+
+    protected override int handle_local_options (GLib.VariantDict options)
+    {
+        if (options.contains ("version"))
+        {
+            stderr.printf ("%1$s %2$s\n", PROGRAM_NAME, Config.VERSION);
+            return Posix.EXIT_SUCCESS;
+        }
+        return -1;
     }
 
     protected override void shutdown ()
@@ -136,31 +146,6 @@ public class SwellFoop : Gtk.Application
             return Posix.EXIT_FAILURE;
         }
 
-        var context = new OptionContext (null);
-        context.set_translation_domain (Config.GETTEXT_PACKAGE);
-
-        context.add_group (Gtk.get_option_group (true));
-        context.add_group (Clutter.get_option_group_without_init ());
-
-        context.add_main_entries (option_entries, Config.GETTEXT_PACKAGE);
-
-        try
-        {
-            context.parse (ref args);
-        }
-        catch (Error e)
-        {
-            stderr.printf ("%s\n", e.message);
-            return Posix.EXIT_FAILURE;
-        }
-
-        if (version)
-        {
-            /* NOTE: Is not translated so can be easily parsed */
-            stderr.printf ("%1$s %2$s\n", "swell-foop", Config.VERSION);
-            return Posix.EXIT_SUCCESS;
-        }
-
         Environment.set_application_name (PROGRAM_NAME);
         Gtk.Window.set_default_icon_name ("org.gnome.SwellFoop");
 


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