[moserial] apply the profile (default or not) all at once, not in bits
- From: Michael J. Chudobiak <mjc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [moserial] apply the profile (default or not) all at once, not in bits
- Date: Fri, 22 Jan 2021 17:38:27 +0000 (UTC)
commit f51e0537043397ddc16cc5a6ada5f6f6f7a4c763
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date: Fri Jan 22 12:38:02 2021 -0500
apply the profile (default or not) all at once, not in bits
src/MainWindow.vala | 97 +++++++++++++++++++++++++++--------------------------
1 file changed, 49 insertions(+), 48 deletions(-)
---
diff --git a/src/MainWindow.vala b/src/MainWindow.vala
index af2ac7b..3e04d1f 100644
--- a/src/MainWindow.vala
+++ b/src/MainWindow.vala
@@ -123,25 +123,11 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
gtkWindow.destroy.connect (quitSave);
gtkWindow.delete_event.connect (deleteSaveSize);
gtkWindow.key_press_event.connect (keyPress);
+ paned = (Paned) builder.get_object ("vpaned");
// load defaults
profile = new Profile ();
profile.load (null, gtkWindow);
- currentSettings = Settings.loadFromProfile (profile);
- int width = profile.getInteger("window", "width", -1);
- int height = profile.getInteger("window", "height", -1);
- int panedPosition = profile.getInteger("window", "paned_pos", -1);
- if ((width > 0) && (height > 0))
- {
- gtkWindow.resize (width, height);
- }
-
- // setup paned
- paned = (Paned) builder.get_object ("vpaned");
- if (panedPosition >= -1)
- paned.set_position (panedPosition);
- else
- paned.set_position (-1);
// setup menu items
Gtk.MenuItem quit = (Gtk.MenuItem)builder.get_object ("menubar_quit");
@@ -180,7 +166,6 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
// setup the statusbar
statusbar = (Statusbar) builder.get_object ("statusbar");
statusbarContext = statusbar.get_context_id ("moserial port status");
- statusbar.push (statusbarContext, currentSettings.getStatusbarString (false));
// setup the byte count bar
bytecountbar = (Statusbar) builder.get_object ("bytecountbar");
@@ -210,7 +195,6 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
xmodemFilenameDialog = new XmodemFilenameDialog (this.gtkWindow);
rz = new Rzwrapper (Rzwrapper.Protocol.NULL, null, null, null);
-
// setup recording
recordDialog = new RecordDialog (this.gtkWindow);
recordButton = (ToggleToolButton) builder.get_object ("toolbar_logging");
@@ -241,12 +225,10 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
// setup incoming notebook
incoming_notebook = (Notebook) builder.get_object ("incoming_notebook");
- incoming_notebook.set_current_page (profile.getInteger("main_ui_controls", "incoming_tab", 0));
incoming_notebook.switch_page.connect (onIncomingNotebookSwitchPage);
// setup outgoing notebook
outgoing_notebook = (Notebook) builder.get_object ("outgoing_notebook");
- outgoing_notebook.set_current_page (profile.getInteger("main_ui_controls", "outgoing_tab", 0));
outgoing_notebook.switch_page.connect (onOutgoingNotebookSwitchPage);
// setup textBuffers;
@@ -290,18 +272,10 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
inputModeCombo = (ComboBox) builder.get_object ("input_mode");
MoUtils.populateComboBox (inputModeCombo, inputModeStrings);
- if (profile.getBoolean("main_ui_controls", "input_mode_hex", false))
- {
- inputModeCombo.set_active (inputModeValues.HEX);
- } else
- {
- inputModeCombo.set_active (inputModeValues.ASCII);
- }
inputModeCombo.changed.connect (inputModeChanged);
lineEndModeCombo = (ComboBox) builder.get_object ("termination_mode");
MoUtils.populateComboBox (lineEndModeCombo, SerialConnection.LineEndStrings);
- lineEndModeCombo.set_active (profile.getInteger("main_ui_controls", "input_line_end", 0));
lineEndModeCombo.changed.connect (lineEndChanged);
// setup recent chooser
@@ -356,16 +330,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
outgoingClearButton.clicked.connect (clearOutgoing);
outgoingClearButton.set_tooltip_text (_("Clear outgoing text box"));
- // take currentSettings into account for outgoing input area
- updateOutgoingInputArea ();
-
// load and apply preferences
- currentPreferences = Preferences.loadFromProfile (profile);
- updatePreferences (null, currentPreferences);
- if (!(startupProfileFilename == null))
- applyProfile (startupProfileFilename);
-
- currentPaths = DefaultPaths.loadFromProfile (profile);
+ applyProfile (startupProfileFilename);
}
private void onIncomingNotebookSwitchPage (Widget page, uint page_num)
@@ -418,19 +384,52 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
outgoingAsciiTextBuffer.set_text ("", 0);
}
- private void applyProfile (string filename)
+ private void applyProfile (string ? filename)
{
- if (profile.load (filename, gtkWindow)) {
- profileFilename = filename;
- ensureDisconnected ();
- currentSettings = Settings.loadFromProfile (profile);
- currentPreferences = Preferences.loadFromProfile (profile);
- currentPaths = DefaultPaths.loadFromProfile (profile);
- updateOutgoingInputArea ();
- updatePreferences (null, currentPreferences);
- statusbar.pop (statusbarContext);
- statusbar.push (statusbarContext, currentSettings.getStatusbarString (false));
- setWindowTitle (null);
+ profile.load (filename, gtkWindow);
+ profileFilename = filename;
+ ensureDisconnected ();
+ currentSettings = Settings.loadFromProfile (profile);
+ currentPreferences = Preferences.loadFromProfile (profile);
+ currentPaths = DefaultPaths.loadFromProfile (profile);
+
+ int width = profile.getInteger("window", "width", -1);
+ int height = profile.getInteger("window", "height", -1);
+ int panedPosition = profile.getInteger("window", "paned_pos", -1);
+ if ((width > 0) && (height > 0)) {
+ gtkWindow.resize (width, height);
+ }
+
+ // setup paned
+ if (panedPosition >= -1) {
+ paned.set_position (panedPosition);
+ } else {
+ paned.set_position (-1);
+ }
+
+ // update misc main UI settigns
+ incoming_notebook.set_current_page (profile.getInteger("main_ui_controls", "incoming_tab", 0));
+ outgoing_notebook.set_current_page (profile.getInteger("main_ui_controls", "outgoing_tab", 0));
+ if (profile.getBoolean("main_ui_controls", "input_mode_hex", false)) {
+ inputModeCombo.set_active (inputModeValues.HEX);
+ } else {
+ inputModeCombo.set_active (inputModeValues.ASCII);
+ }
+ lineEndModeCombo.set_active (profile.getInteger("main_ui_controls", "input_line_end", 0));
+ updateOutgoingInputArea ();
+
+ // update preferences dialog
+ updatePreferences (null, currentPreferences);
+
+ // update status bar
+ statusbar.pop (statusbarContext);
+ statusbar.push (statusbarContext, currentSettings.getStatusbarString (false));
+
+ // update window title
+ setWindowTitle (null);
+
+ // update recents
+ if (filename != null) {
RecentManager recentManager = RecentManager.get_default ();
try {
recentManager.add_full (GLib.Filename.to_uri (filename), recentData);
@@ -1100,9 +1099,11 @@ font-weight:
} else {
/* Save the profile even if settings or preferences have not
changed, to save the default file locations */
+ // update the non-default profile, if it has change
saveProfile ();
}
}
+ // update the default profile, always
profile.save (null, gtkWindow);
Gtk.main_quit ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]