[gnome-calculator] command-line: added option to select mode from CLI



commit f9d760e85936d62671ded5d36a174dd5bfe86a56
Author: Moo <eldmannen+gnome gmail com>
Date:   Sat Sep 17 06:45:20 2016 +0300

    command-line: added option to select mode from CLI
    
    https://bugzilla.gnome.org/show_bug.cgi?id=748135

 src/gnome-calculator.vala |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/src/gnome-calculator.vala b/src/gnome-calculator.vala
index 27182b3..782499e 100644
--- a/src/gnome-calculator.vala
+++ b/src/gnome-calculator.vala
@@ -16,9 +16,10 @@ public class Calculator : Gtk.Application
     private MathPreferencesDialog preferences_dialog;
     private static string program_name = null;
     private static string equation_string = null;
+    private static string mode_string = null;
 
     private const OptionEntry[] option_entries = {
-        { "mode", 'm', 0, OptionArg.STRING, null, N_("Start in given mode"), "mode" },
+        { "mode", 'm', 0, OptionArg.STRING, ref mode_string, N_("Start in given mode"), "mode" },
         { "solve", 's', 0, OptionArg.STRING, null, N_("Solve given equation"), "equation" },
         { "equation", 'e', 0, OptionArg.STRING, ref equation_string, N_("Start with given equation"), 
"equation"},
         { "version", 'v', 0, OptionArg.NONE, null, N_("Show release version"), null },
@@ -115,10 +116,29 @@ public class Calculator : Gtk.Application
                     window.equation.solve ();
             }
         }
-        if (options.contains ("mode"))
+        if (mode_string != "" && mode_string != null)
         {
-            var button_mode = (string) options.lookup_value ("mode", VariantType.STRING);
-            window.buttons.mode = button_mode;
+            var mode = ButtonMode.BASIC;
+
+            switch (mode_string)
+            {
+            case "basic":
+                mode = ButtonMode.BASIC;
+                break;
+            case "advanced":
+                mode = ButtonMode.ADVANCED;
+                break;
+            case "financial":
+                mode = ButtonMode.FINANCIAL;
+                break;
+            case "programming":
+                mode = ButtonMode.PROGRAMMING;
+                break;
+            case "keyboard":
+                mode = ButtonMode.KEYBOARD;
+                break;
+            }
+            window.buttons.mode = mode;
         }
     }
 


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