[moserial] make the visibility of the signal indicators optional, for less clutter



commit 74004c593bc6f9b5012bbf55808007e3b5b16b5f
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date:   Fri Jan 22 13:42:31 2021 -0500

    make the visibility of the signal indicators optional, for less clutter

 data/ui/mainwindow.ui | 26 ++++++++++++++++++++++++--
 src/MainWindow.vala   | 29 +++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/mainwindow.ui b/data/ui/mainwindow.ui
index 42cd4c5..9395433 100644
--- a/data/ui/mainwindow.ui
+++ b/data/ui/mainwindow.ui
@@ -134,6 +134,28 @@
                 </child>
               </object>
             </child>
+            <child>
+              <object class="GtkMenuItem" id="menuitemview">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="label" translatable="yes">View</property>
+                <property name="use-underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menuview">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <child>
+                      <object class="GtkCheckMenuItem" id="menubar_extracontrols">
+                        <property name="visible">True</property>
+                        <property name="can-focus">False</property>
+                        <property name="label" translatable="yes">Extra Controls</property>
+                        <property name="use-underline">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
             <child>
               <object class="GtkMenuItem" id="menuitem4">
                 <property name="visible">True</property>
@@ -330,7 +352,7 @@
                 <property name="baseline-position">top</property>
                 <child>
                   <!-- n-columns=6 n-rows=3 -->
-                  <object class="GtkGrid">
+                  <object class="GtkGrid" id="incoming_signals">
                     <property name="visible">True</property>
                     <property name="can-focus">False</property>
                     <property name="valign">start</property>
@@ -553,7 +575,7 @@
                 <property name="baseline-position">top</property>
                 <child>
                   <!-- n-columns=4 n-rows=3 -->
-                  <object class="GtkGrid">
+                  <object class="GtkGrid" id="outgoing_signals">
                     <property name="visible">True</property>
                     <property name="can-focus">False</property>
                     <property name="valign">start</property>
diff --git a/src/MainWindow.vala b/src/MainWindow.vala
index 3e04d1f..4980dda 100644
--- a/src/MainWindow.vala
+++ b/src/MainWindow.vala
@@ -102,6 +102,9 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
     private Button outgoingClearButton;
     private ToggleButton dtrButton;
     private ToggleButton rtsButton;
+    private Grid incoming_signals;
+    private Grid outgoing_signals;
+    private CheckMenuItem extraControlsCheck;
 
     private const string recentGroup = "moserial-configs";
     private Gtk.RecentData recentData;
@@ -123,12 +126,21 @@ 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);
+        gtkWindow.realize.connect (checkExtraVisible);
+
         paned = (Paned) builder.get_object ("vpaned");
 
         // load defaults
         profile = new Profile ();
         profile.load (null, gtkWindow);
 
+        // setup extra controls optional view
+        incoming_signals = (Grid) builder.get_object ("incoming_signals");
+        outgoing_signals = (Grid) builder.get_object ("outgoing_signals");
+
+        extraControlsCheck = (CheckMenuItem) builder.get_object ("menubar_extracontrols");
+        extraControlsCheck.toggled.connect (this.toggleExtraControls);
+
         // setup menu items
         Gtk.MenuItem quit = (Gtk.MenuItem)builder.get_object ("menubar_quit");
         quit.activate.connect (quitSizeSave);
@@ -344,6 +356,19 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
         profile.setInteger ("main_ui_controls", "outgoing_tab", (int) page_num);
     }
 
+    private void checkExtraVisible (Widget widget)
+    {
+        bool new_state = profile.getBoolean ("main_ui_controls", "show_extra_controls", true);
+        incoming_signals.visible = new_state;
+        outgoing_signals.visible = new_state;
+    }
+
+    private void toggleExtraControls (CheckMenuItem check)
+    {
+        profile.setBoolean ("main_ui_controls", "show_extra_controls", check.get_active ());
+        checkExtraVisible (gtkWindow);
+    }
+
     private void toggleRTS (ToggleButton button)
     {
         // Toogle only when connected
@@ -425,6 +450,10 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
         statusbar.pop (statusbarContext);
         statusbar.push (statusbarContext, currentSettings.getStatusbarString (false));
 
+        // update optional views
+        extraControlsCheck.set_active (profile.getBoolean ("main_ui_controls", "show_extra_controls", true));
+        checkExtraVisible (gtkWindow);
+
         // update window title
         setWindowTitle (null);
 


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