[moserial] store "other" settings in a separate section of the profile files



commit 0866e181e93175a5792174a9c79cbd94535a3a28
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date:   Thu Jan 21 15:51:42 2021 -0500

    store "other" settings in a separate section of the profile files

 src/MainWindow.vala | 11 ++---------
 src/Profile.vala    | 32 +++++++++++---------------------
 2 files changed, 13 insertions(+), 30 deletions(-)
---
diff --git a/src/MainWindow.vala b/src/MainWindow.vala
index 5d9ea79..7a223f5 100644
--- a/src/MainWindow.vala
+++ b/src/MainWindow.vala
@@ -285,7 +285,6 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
         sendButton.clicked.connect (sendString);
         sendButton.set_tooltip_text (_("Send the outgoing data now."));
         entry = (Gtk.Entry)builder.get_object ("entry");
-//      entry.set_text (profile.getInputString ());
         entry.activate.connect (sendString);
         entry.set_tooltip_text (_("Type outgoing data here. Press Enter or Send to send it."));
 
@@ -364,7 +363,7 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
         currentPreferences = Preferences.loadFromProfile (profile);
         updatePreferences (null, currentPreferences);
         if (!(startupProfileFilename == null))
-            loadProfileOnStartup (startupProfileFilename);
+            applyProfile (startupProfileFilename);
 
         currentPaths = DefaultPaths.loadFromProfile (profile);
     }
@@ -490,7 +489,6 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
     {
         string s;
         s = entry.get_text ();
-//      profile.setInputString (s);
         if (!ensureConnected ()) {
             return;
         }
@@ -1096,7 +1094,7 @@ font-weight:
         currentPaths.saveToProfile (profile);
         if (profileFilename != null) {
             if (profile.profileChanged) {
-                var dialog = new MessageDialog (gtkWindow, DialogFlags.DESTROY_WITH_PARENT, 
MessageType.QUESTION, ButtonsType.YES_NO, "%s", _("You have changed your setting or preferences. Do you want 
to save these changes to the loaded profile?"));
+                var dialog = new MessageDialog (gtkWindow, DialogFlags.DESTROY_WITH_PARENT, 
MessageType.QUESTION, ButtonsType.YES_NO, "%s", _("Save modified settings to the loaded profile?"));
                 int response = dialog.run ();
                 if (response == Gtk.ResponseType.YES)
                     saveProfile ();
@@ -1145,11 +1143,6 @@ font-weight:
             saveProfile ();
     }
 
-    private void loadProfileOnStartup (string profileFilename)
-    {
-        applyProfile (profileFilename);
-    }
-
     private void loadProfile ()
     {
         var dialog = new FileChooserDialog (null, gtkWindow, Gtk.FileChooserAction.OPEN);
diff --git a/src/Profile.vala b/src/Profile.vala
index bff87a0..d2b7f1a 100644
--- a/src/Profile.vala
+++ b/src/Profile.vala
@@ -75,10 +75,12 @@ public class Profile : GLib.Object
         }
 
         if (tab != 0) {
-            keyFile.set_integer ("window", n, 1);
+            keyFile.set_integer ("main_ui_controls", n, 1);
         } else {
-            keyFile.set_integer ("window", n, 0);
+            keyFile.set_integer ("main_ui_controls", n, 0);
         }
+
+        profileChanged = true;
     }
 
     public int getNotebookTab (bool outgoing)
@@ -89,7 +91,7 @@ public class Profile : GLib.Object
         }
 
         try {
-            if (keyFile.get_integer ("window", n) != 0) {
+            if (keyFile.get_integer ("main_ui_controls", n) != 0) {
                 return 1;
             }
             return 0;
@@ -100,13 +102,14 @@ public class Profile : GLib.Object
 
     public void setInputModeHex (bool hex)
     {
-        keyFile.set_boolean ("window", "input_mode_hex", hex);
+        keyFile.set_boolean ("main_ui_controls", "input_mode_hex", hex);
+        profileChanged = true;
     }
 
     public bool getInputModeHex ()
     {
         try {
-            return keyFile.get_boolean ("window", "input_mode_hex");
+            return keyFile.get_boolean ("main_ui_controls", "input_mode_hex");
         } catch (GLib.KeyFileError e) {
             return false;
         }
@@ -114,32 +117,19 @@ public class Profile : GLib.Object
 
     public void setInputLineEnd (int end)
     {
-        keyFile.set_integer ("window", "input_line_end", end);
+        keyFile.set_integer ("main_ui_controls", "input_line_end", end);
+        profileChanged = true;
     }
 
     public int getInputLineEnd ()
     {
         try {
-            return keyFile.get_integer ("window", "input_line_end");
+            return keyFile.get_integer ("main_ui_controls", "input_line_end");
         } catch (GLib.KeyFileError e) {
             return 0;
         }
     }
 
-    public void setInputString (string s)
-    {
-        keyFile.set_string ("window", "input_string", s);
-    }
-
-    public string getInputString ()
-    {
-        try {
-            return keyFile.get_string ("window", "input_string");
-        } catch (GLib.KeyFileError e) {
-            return "";
-        }
-    }
-
     public bool load (string ? filename, Gtk.Window window)
     {
         string f;


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