[chronojump] Encoder capture end at n inactivity seconds can be false



commit 88e79e7fa232fe98b48601f417256de8767aac72
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Mar 28 12:37:54 2019 +0100

    Encoder capture end at n inactivity seconds can be false

 glade/preferences_win.glade | 30 ++++++++++++++++--------------
 src/encoderCapture.cs       |  4 +++-
 src/gui/preferences.cs      | 35 +++++++++++++++++++++++++++++------
 src/preferences.cs          |  2 +-
 4 files changed, 49 insertions(+), 22 deletions(-)
---
diff --git a/glade/preferences_win.glade b/glade/preferences_win.glade
index 0794dd93..c366d83d 100644
--- a/glade/preferences_win.glade
+++ b/glade/preferences_win.glade
@@ -1627,20 +1627,7 @@ It starts before and arrives there with some speed.</property>
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkLabel" id="label62">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="xalign">0</property>
-                                <property name="label" translatable="yes">End at n inactivity 
seconds</property>
-                              </widget>
-                              <packing>
-                                <property name="top_attach">1</property>
-                                <property name="bottom_attach">2</property>
-                                <property name="x_options">GTK_FILL</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <widget class="GtkHBox" id="hbox21">
+                              <widget class="GtkHBox" id="hbox_encoder_capture_inactivity_time">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="spacing">4</property>
@@ -1713,6 +1700,21 @@ It starts before and arrives there with some speed.</property>
                                 <property name="bottom_attach">2</property>
                               </packing>
                             </child>
+                            <child>
+                              <widget class="GtkCheckButton" id="check_encoder_capture_inactivity_end_time">
+                                <property name="label" translatable="yes">End at n inactivity 
seconds</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="clicked" 
handler="on_check_encoder_capture_inactivity_end_time_clicked" swapped="no"/>
+                              </widget>
+                              <packing>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                                <property name="x_options"/>
+                              </packing>
+                            </child>
                           </widget>
                           <packing>
                             <property name="expand">False</property>
diff --git a/src/encoderCapture.cs b/src/encoderCapture.cs
index 2523008d..703466fb 100644
--- a/src/encoderCapture.cs
+++ b/src/encoderCapture.cs
@@ -85,7 +85,7 @@ public abstract class EncoderCapture
        //this will be used to stop encoder automatically       
        protected int consecutiveZeros;
        protected int consecutiveZerosMax;
-               
+       protected bool automaticallyEndByTime;  
        //specific of some subclasses
        protected bool lastDirectionStoredIsUp;
        protected bool capturingFirstPhase;
@@ -204,6 +204,7 @@ public abstract class EncoderCapture
                //or to save this set and wait for the next on cont mode
                consecutiveZeros = -1;          
                consecutiveZerosMax = timeEnd * 1000;
+               automaticallyEndByTime = (timeEnd >= 0);
 
                initSpecific();
 
@@ -389,6 +390,7 @@ public abstract class EncoderCapture
                                 * 1500 is conversion to milliseconds and * 1.5 to have enough time to move 
after clusters res
                                 */
                                if(
+                                               automaticallyEndByTime &&
                                                (
                                                 (Ecca.curvesAccepted > 0 && consecutiveZeros >= 
consecutiveZerosMax) ||
                                                 (! cont && Ecca.curvesAccepted == 0 && consecutiveZeros >= 
(2* consecutiveZerosMax))
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index 500f6e67..98c64433 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -97,6 +97,8 @@ public class PreferencesWindow
        
        //encoder capture tab
        [Widget] Gtk.SpinButton spin_encoder_capture_time;
+       [Widget] Gtk.CheckButton check_encoder_capture_inactivity_end_time;
+       [Widget] Gtk.HBox hbox_encoder_capture_inactivity_time;
        [Widget] Gtk.SpinButton spin_encoder_capture_inactivity_end_time;
        [Widget] Gtk.Image image_encoder_gravitatory;
        [Widget] Gtk.Image image_encoder_inertial;
@@ -403,8 +405,19 @@ public class PreferencesWindow
 
        
                //encoder capture -->
+
                PreferencesWindowBox.spin_encoder_capture_time.Value = preferences.encoderCaptureTime;
-               PreferencesWindowBox.spin_encoder_capture_inactivity_end_time.Value = 
preferences.encoderCaptureInactivityEndTime;
+
+               if(preferences.encoderCaptureInactivityEndTime < 0) {
+                       PreferencesWindowBox.check_encoder_capture_inactivity_end_time.Active = false;
+                       PreferencesWindowBox.hbox_encoder_capture_inactivity_time.Sensitive = false;
+                       PreferencesWindowBox.spin_encoder_capture_inactivity_end_time.Value = 3;
+               } else {
+                       PreferencesWindowBox.check_encoder_capture_inactivity_end_time.Active = true;
+                       PreferencesWindowBox.hbox_encoder_capture_inactivity_time.Sensitive = true;
+                       PreferencesWindowBox.spin_encoder_capture_inactivity_end_time.Value = 
preferences.encoderCaptureInactivityEndTime;
+               }
+
 
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_gravity.png");
                PreferencesWindowBox.image_encoder_gravitatory.Pixbuf = pixbuf;
@@ -514,6 +527,11 @@ public class PreferencesWindow
                spin_encoder_capture_show_only_some_bars.Sensitive = true;
        }
 
+       private void on_check_encoder_capture_inactivity_end_time_clicked (object o, EventArgs args)
+       {
+               hbox_encoder_capture_inactivity_time.Sensitive = 
check_encoder_capture_inactivity_end_time.Active;
+       }
+
        //private void on_notebook_encoder_capture_gi_change_current_page (object o, 
Gtk.ChangeCurrentPageArgs args)
        private void on_notebook_encoder_capture_gi_switch_page (object o, Gtk.SwitchPageArgs args)
        {
@@ -1300,11 +1318,16 @@ public class PreferencesWindow
                                preferences.encoderCaptureTime,
                                (int) PreferencesWindowBox.spin_encoder_capture_time.Value);
 
-               preferences.encoderCaptureInactivityEndTime = preferencesChange(
-                               "encoderCaptureInactivityEndTime",
-                               preferences.encoderCaptureInactivityEndTime,
-                               (int) PreferencesWindowBox.spin_encoder_capture_inactivity_end_time.Value);
-
+               if(! PreferencesWindowBox.check_encoder_capture_inactivity_end_time.Active)
+               {
+                       SqlitePreferences.Update("encoderCaptureInactivityEndTime", "-1", true);
+                       preferences.encoderCaptureInactivityEndTime = -1;
+               } else {
+                       preferences.encoderCaptureInactivityEndTime = preferencesChange(
+                                       "encoderCaptureInactivityEndTime",
+                                       preferences.encoderCaptureInactivityEndTime,
+                                       (int) 
PreferencesWindowBox.spin_encoder_capture_inactivity_end_time.Value);
+               }
 
                preferences.encoderCaptureMinHeightGravitatory = preferencesChange(
                                "encoderCaptureMinHeightGravitatory",
diff --git a/src/preferences.cs b/src/preferences.cs
index 90a30710..c49a4b9b 100644
--- a/src/preferences.cs
+++ b/src/preferences.cs
@@ -57,7 +57,7 @@ public class Preferences
        
        //encoder capture
        public int encoderCaptureTime;
-       public int encoderCaptureInactivityEndTime;
+       public int encoderCaptureInactivityEndTime; // -1 if not automatically end
        public Constants.EncoderVariablesCapture encoderCaptureMainVariable;
        public int encoderCaptureMinHeightGravitatory;
        public int encoderCaptureMinHeightInertial;


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