[chronojump] Better code for last two commits



commit c3188161864f38099416daf71b372c94905de3bb
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sun Apr 4 22:28:44 2021 +0200

    Better code for last two commits

 src/gui/app1/chronojump.cs | 16 ++++++++++++++++
 src/gui/app1/jump.cs       | 26 ++++++++------------------
 2 files changed, 24 insertions(+), 18 deletions(-)
---
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 355ee3c9..9389f6de 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -2122,6 +2122,22 @@ public partial class ChronoJumpWindow
                }
        }
 
+       private void contacts_exercise_left_button (Gtk.ComboBox combo, Gtk.Button button_left, Gtk.Button 
button_right)
+       {
+               combo = UtilGtk.ComboSelectPrevious(combo);
+
+               button_left.Sensitive = (combo.Active > 0);
+               button_right.Sensitive = true;
+       }
+       private void contacts_exercise_right_button (Gtk.ComboBox combo, Gtk.Button button_left, Gtk.Button 
button_right)
+       {
+               bool isLast;
+               combo = UtilGtk.ComboSelectNext(combo, out isLast);
+
+               button_left.Sensitive = true;
+               button_right.Sensitive = ! isLast;
+       }
+
 
        // ---------------- combo_result ----------------------
 
diff --git a/src/gui/app1/jump.cs b/src/gui/app1/jump.cs
index 2de53c7d..619e7b1b 100644
--- a/src/gui/app1/jump.cs
+++ b/src/gui/app1/jump.cs
@@ -125,35 +125,25 @@ public partial class ChronoJumpWindow
        //left-right buttons on jumps combo exercise selection
        private void on_button_combo_jumps_exercise_capture_left_clicked (object o, EventArgs args)
        {
-               combo_select_jumps = UtilGtk.ComboSelectPrevious(combo_select_jumps);
-
-               button_combo_jumps_exercise_capture_left.Sensitive = (combo_select_jumps.Active > 0);
-               button_combo_jumps_exercise_capture_right.Sensitive = true;
+               contacts_exercise_left_button (combo_select_jumps,
+                               button_combo_jumps_exercise_capture_left, 
button_combo_jumps_exercise_capture_right);
        }
        private void on_button_combo_jumps_exercise_capture_right_clicked (object o, EventArgs args)
        {
-               bool isLast;
-               combo_select_jumps = UtilGtk.ComboSelectNext(combo_select_jumps, out isLast);
-
-               button_combo_jumps_exercise_capture_left.Sensitive = true;
-               button_combo_jumps_exercise_capture_right.Sensitive = ! isLast;
+               contacts_exercise_right_button (combo_select_jumps,
+                               button_combo_jumps_exercise_capture_left, 
button_combo_jumps_exercise_capture_right);
        }
 
        //left-right buttons on jumps_rj combo exercise selection
        private void on_button_combo_jumps_rj_exercise_capture_left_clicked (object o, EventArgs args)
        {
-               combo_select_jumps_rj = UtilGtk.ComboSelectPrevious(combo_select_jumps_rj);
-
-               button_combo_jumps_rj_exercise_capture_left.Sensitive = (combo_select_jumps_rj.Active > 0);
-               button_combo_jumps_rj_exercise_capture_right.Sensitive = true;
+               contacts_exercise_left_button (combo_select_jumps_rj,
+                               button_combo_jumps_rj_exercise_capture_left, 
button_combo_jumps_rj_exercise_capture_right);
        }
        private void on_button_combo_jumps_rj_exercise_capture_right_clicked (object o, EventArgs args)
        {
-               bool isLast;
-               combo_select_jumps_rj = UtilGtk.ComboSelectNext(combo_select_jumps_rj, out isLast);
-
-               button_combo_jumps_rj_exercise_capture_left.Sensitive = true;
-               button_combo_jumps_rj_exercise_capture_right.Sensitive = ! isLast;
+               contacts_exercise_right_button (combo_select_jumps_rj,
+                               button_combo_jumps_rj_exercise_capture_left, 
button_combo_jumps_rj_exercise_capture_right);
        }
 
        /*


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