[moserial] Save and restore input mode from profile.



commit 54f373403e4b25a302ee96e970557c2c2a289887
Author: Mictronics <github mictronics de>
Date:   Mon Apr 27 20:52:48 2020 +0200

    Save and restore input mode from profile.

 src/MainWindow.vala |  8 +++++++-
 src/Profile.vala    | 12 ++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/src/MainWindow.vala b/src/MainWindow.vala
index aea0975..5c9c1db 100644
--- a/src/MainWindow.vala
+++ b/src/MainWindow.vala
@@ -289,7 +289,11 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
 
         inputModeCombo = (ComboBox) builder.get_object ("input_mode");
         MoUtils.populateComboBox (inputModeCombo, inputModeStrings);
-        inputModeCombo.set_active (inputModeValues.ASCII);
+        if (profile.getInputModeHex ()) {
+            inputModeCombo.set_active (inputModeValues.HEX);
+        } else {
+            inputModeCombo.set_active (inputModeValues.ASCII);
+        }
         inputModeCombo.changed.connect (inputModeChanged);
 
         lineEndModeCombo = (ComboBox) builder.get_object ("termination_mode");
@@ -890,9 +894,11 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
         if (inputModeCombo.get_active () == inputModeValues.HEX) {
             outgoing_notebook.set_current_page (1);
             profile.setNotebookTab (true, 1);
+            profile.setInputModeHex (true);
         } else {
             outgoing_notebook.set_current_page (0);
             profile.setNotebookTab (true, 0);
+            profile.setInputModeHex (false);
         }
     }
 
diff --git a/src/Profile.vala b/src/Profile.vala
index 5f845aa..430564b 100644
--- a/src/Profile.vala
+++ b/src/Profile.vala
@@ -88,6 +88,18 @@ public class Profile : GLib.Object {
         }
     }
 
+    public void setInputModeHex (bool hex) {
+        keyFile.set_boolean ("window", "input_mode_hex", hex);
+    }
+
+    public bool getInputModeHex () {
+        try {
+            return keyFile.get_boolean ("window", "input_mode_hex");
+        } catch (GLib.KeyFileError e) {
+            return false;
+        }
+    }
+
     public bool load (string ? filename, Gtk.Window window) {
         string f;
         bool default_profile = false;


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