[chronojump] combo_select_contacts_top implemented for runEncoder



commit b920a3458c8a997c121aed267a91f423d13e1b80
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jul 30 20:07:22 2021 +0200

    combo_select_contacts_top implemented for runEncoder

 src/gui/app1/chronojump.cs       | 35 +++++++++++++++++++++++++++++++----
 src/gui/app1/contactsExercise.cs | 20 ++++++++++++++++----
 src/gui/app1/runEncoder.cs       | 18 ++++++++++++++++++
 src/util.cs                      | 11 ++++++++++-
 src/utilGtk.cs                   | 15 +++++++++++++++
 5 files changed, 90 insertions(+), 9 deletions(-)
---
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 92db71711..a81f665eb 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -818,7 +818,8 @@ public partial class ChronoJumpWindow
                        //else
 
                        if(current_mode == Constants.Modes.JUMPSSIMPLE || current_mode == 
Constants.Modes.JUMPSREACTIVE ||
-                                       current_mode == Constants.Modes.RUNSSIMPLE || current_mode == 
Constants.Modes.RUNSINTERVALLIC)
+                                       current_mode == Constants.Modes.RUNSSIMPLE || current_mode == 
Constants.Modes.RUNSINTERVALLIC ||
+                                       current_mode == Constants.Modes.RUNSENCODER)
                                createComboSelectContactsTop (true);
                }
 
@@ -2194,6 +2195,10 @@ public partial class ChronoJumpWindow
        {
                if(create)
                {
+                       //deactivate signal
+                       if(combo_select_contacts_top != null)
+                               combo_select_contacts_top.Changed -= new EventHandler 
(on_combo_select_contacts_top_changed);
+
                        //delete children if any
                        if(hbox_combo_select_contacts_top.Children.Length > 0)
                                hbox_combo_select_contacts_top.Remove(combo_select_contacts_top);
@@ -2227,6 +2232,20 @@ public partial class ChronoJumpWindow
                                combo_select_contacts_top.Active = combo_select_runs_interval.Active;
                                combo_select_contacts_top.Sensitive = true;
                        }
+                       else if(current_mode == Constants.Modes.RUNSENCODER)
+                       {
+                               if(combo_select_contacts_top == null)
+                                       combo_select_contacts_top = ComboBox.NewText ();
+
+                               //copy the values form combo_run_encoder_exercise
+                               UtilGtk.ComboUpdate(combo_select_contacts_top,
+                                               UtilGtk.ComboGetValues (combo_run_encoder_exercise), "");
+                               combo_select_contacts_top.Active = combo_run_encoder_exercise.Active;
+                               combo_select_contacts_top.Sensitive = true;
+
+                               hbox_combo_select_contacts_top.PackStart(combo_select_contacts_top, true, 
true, 0);
+                               hbox_combo_select_contacts_top.ShowAll();
+                       }
                        /*
                        TODO:
                        //else if(current_mode == Constants.Modes.FORCESENSOR)
@@ -2235,7 +2254,7 @@ public partial class ChronoJumpWindow
                        ...
                        */
 
-                       combo_select_contacts_top.Changed -= new EventHandler 
(on_combo_select_contacts_top_changed);
+                       //activate signal
                        combo_select_contacts_top.Changed += new EventHandler 
(on_combo_select_contacts_top_changed);
                }
        }
@@ -2300,7 +2319,8 @@ public partial class ChronoJumpWindow
                button_right.Sensitive = true;
 
                if(current_mode == Constants.Modes.JUMPSSIMPLE || current_mode == 
Constants.Modes.JUMPSREACTIVE ||
-                               current_mode == Constants.Modes.RUNSSIMPLE || current_mode == 
Constants.Modes.RUNSINTERVALLIC)
+                               current_mode == Constants.Modes.RUNSSIMPLE || current_mode == 
Constants.Modes.RUNSINTERVALLIC ||
+                               current_mode == Constants.Modes.RUNSENCODER)
                {
                        button_combo_select_contacts_top_left.Sensitive = (combo.Active > 0);
                        button_combo_select_contacts_top_right.Sensitive = true;
@@ -2315,7 +2335,8 @@ public partial class ChronoJumpWindow
                button_right.Sensitive = ! isLast;
 
                if(current_mode == Constants.Modes.JUMPSSIMPLE || current_mode == 
Constants.Modes.JUMPSREACTIVE ||
-                               current_mode == Constants.Modes.RUNSSIMPLE || current_mode == 
Constants.Modes.RUNSINTERVALLIC)
+                               current_mode == Constants.Modes.RUNSSIMPLE || current_mode == 
Constants.Modes.RUNSINTERVALLIC ||
+                               current_mode == Constants.Modes.RUNSENCODER)
                {
                        button_combo_select_contacts_top_left.Sensitive = true;
                        button_combo_select_contacts_top_right.Sensitive = ! isLast;
@@ -2412,6 +2433,8 @@ public partial class ChronoJumpWindow
                        on_combo_select_runs_changed(o, args);
                else if(current_mode == Constants.Modes.RUNSINTERVALLIC)
                        on_combo_select_runs_interval_changed(o, args);
+               else if(current_mode == Constants.Modes.RUNSENCODER)
+                       on_combo_run_encoder_exercise_changed(o, args);
        }
 
        private void on_combo_select_jumps_changed(object o, EventArgs args)
@@ -3772,6 +3795,10 @@ public partial class ChronoJumpWindow
                        label_contacts_exercise_selected_options.Visible = true;
                        image_top_laterality_contacts.Visible = false;
 
+                       createComboSelectContactsTop (true);
+                       label_contacts_exercise_selected_name.Visible = false;
+                       hbox_combo_select_contacts_top_with_arrows.Visible = true; //this will be unneded
+
                        pixbufModeCurrent = new Pixbuf (null, Util.GetImagePath(false) + 
"race_encoder_icon.png");
                        pixbufModeGrid = new Pixbuf (null, Util.GetImagePath(false) + "image_modes_run.png");
                }
diff --git a/src/gui/app1/contactsExercise.cs b/src/gui/app1/contactsExercise.cs
index fd3a05dd9..16e8bed96 100644
--- a/src/gui/app1/contactsExercise.cs
+++ b/src/gui/app1/contactsExercise.cs
@@ -267,10 +267,12 @@ public partial class ChronoJumpWindow
        {
                if(current_mode == Constants.Modes.JUMPSSIMPLE)
                        contacts_exercise_left_button (combo_select_jumps,
-                                       button_combo_jumps_exercise_capture_left, 
button_combo_jumps_exercise_capture_right);
+                                       button_combo_jumps_exercise_capture_left,
+                                       button_combo_jumps_exercise_capture_right);
                else if(current_mode == Constants.Modes.JUMPSREACTIVE)
                        contacts_exercise_left_button (combo_select_jumps_rj,
-                                       button_combo_jumps_rj_exercise_capture_left, 
button_combo_jumps_rj_exercise_capture_right);
+                                       button_combo_jumps_rj_exercise_capture_left,
+                                       button_combo_jumps_rj_exercise_capture_right);
                else if(current_mode == Constants.Modes.RUNSSIMPLE)
                        contacts_exercise_left_button (combo_select_runs,
                                        button_combo_runs_exercise_capture_left,
@@ -279,15 +281,21 @@ public partial class ChronoJumpWindow
                        contacts_exercise_left_button (combo_select_runs_interval,
                                        button_combo_runs_interval_exercise_capture_left,
                                        button_combo_runs_interval_exercise_capture_right);
+               else if(current_mode == Constants.Modes.RUNSENCODER)
+                       contacts_exercise_left_button (combo_run_encoder_exercise,
+                                       button_combo_run_encoder_exercise_capture_left,
+                                       button_combo_run_encoder_exercise_capture_right);
        }
        private void on_button_combo_select_contacts_top_right_clicked (object o, EventArgs args)
        {
                if(current_mode == Constants.Modes.JUMPSSIMPLE)
                        contacts_exercise_right_button (combo_select_jumps,
-                                       button_combo_jumps_exercise_capture_left, 
button_combo_jumps_exercise_capture_right);
+                                       button_combo_jumps_exercise_capture_left,
+                                       button_combo_jumps_exercise_capture_right);
                else if(current_mode == Constants.Modes.JUMPSREACTIVE)
                        contacts_exercise_right_button (combo_select_jumps_rj,
-                                       button_combo_jumps_rj_exercise_capture_left, 
button_combo_jumps_rj_exercise_capture_right);
+                                       button_combo_jumps_rj_exercise_capture_left,
+                                       button_combo_jumps_rj_exercise_capture_right);
                else if(current_mode == Constants.Modes.RUNSSIMPLE)
                        contacts_exercise_right_button (combo_select_runs,
                                        button_combo_runs_exercise_capture_left,
@@ -296,5 +304,9 @@ public partial class ChronoJumpWindow
                        contacts_exercise_right_button (combo_select_runs_interval,
                                        button_combo_runs_interval_exercise_capture_left,
                                        button_combo_runs_interval_exercise_capture_right);
+               else if(current_mode == Constants.Modes.RUNSENCODER)
+                       contacts_exercise_right_button (combo_run_encoder_exercise,
+                                       button_combo_run_encoder_exercise_capture_left,
+                                       button_combo_run_encoder_exercise_capture_right);
        }
 }
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index d03c2e8b6..d244f16de 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -1706,11 +1706,29 @@ public partial class ChronoJumpWindow
 
        private void on_combo_run_encoder_exercise_changed(object o, EventArgs args)
        {
+               ComboBox combo = o as ComboBox;
+               if (o == null)
+                       return;
+
+               //two combobox are linked ---->
+               if(comboSelectContactsTopNoFollow)
+                       return;
+
+               comboSelectContactsTopNoFollow = true;
+               if (o == combo_run_encoder_exercise)
+                       combo_select_contacts_top.Active = combo_run_encoder_exercise.Active;
+               else if (o == combo_select_contacts_top)
+                       combo_run_encoder_exercise.Active = combo_select_contacts_top.Active;
+               comboSelectContactsTopNoFollow = false;
+               //<---- two combobox are linked
+
                setLabelContactsExerciseSelected(Constants.Modes.RUNSENCODER);
 
                //sensitivity of left/right buttons
                button_combo_run_encoder_exercise_capture_left.Sensitive = (combo_run_encoder_exercise.Active 
0);
                button_combo_run_encoder_exercise_capture_right.Sensitive = ! 
UtilGtk.ComboSelectedIsLast(combo_run_encoder_exercise);
+               button_combo_select_contacts_top_left.Sensitive = (combo_run_encoder_exercise.Active > 0);
+               button_combo_select_contacts_top_right.Sensitive = ! 
UtilGtk.ComboSelectedIsLast(combo_run_encoder_exercise);
        }
 
        private void fillRunEncoderExerciseCombo(string name)
diff --git a/src/util.cs b/src/util.cs
index d76955c78..e1cac146c 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -2083,7 +2083,16 @@ public class Util
                ret[0] = str;
                return ret;
        }
-       
+
+       public static string [] ListStringToStringArray (List<string> string_l)
+       {
+               string [] stringArray = new string[string_l.Count];
+               for(int i = 0; i < string_l.Count; i ++)
+                       stringArray[i] = string_l[i];
+
+               return stringArray;
+       }
+
        public static ArrayList StringToArrayList (string str, char sep) {
                ArrayList array = new ArrayList(1);
                string [] strFull = str.Split(new char[] {sep});
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index 0e3d8e0de..58a5cc58e 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -189,6 +189,21 @@ public class UtilGtk
                } while (myCombo.Model.IterNext (ref iter));
        }
 
+       //used on combo_select_contacts_top at least on runEncoder
+       public static string [] ComboGetValues (ComboBox combo)
+       {
+               List<string> values_l = new List<string>();
+
+               TreeIter iter;
+               combo.Model.GetIterFirst(out iter);
+               do {
+                       values_l.Add((string) combo.Model.GetValue (iter, 0));
+               } while (combo.Model.IterNext (ref iter));
+
+               return Util.ListStringToStringArray (values_l);
+       }
+
+
        //for new code, better use the ComboUpdate(ComboBox, ArrayList)
        //if there's no default value, simply pass a "" and there will be returned a 0, that's the first 
value of combo
        public static int ComboUpdate(ComboBox myCombo, string [] myData, string strDefault) {


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