[chronojump] ForceSensor exercise delete on separate button (not on edit)



commit 421a33967ceeed1d92a4f72ad90813098d9529bb
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Oct 4 13:32:32 2019 +0200

    ForceSensor exercise delete on separate button (not on edit)

 glade/app1.glade                  | 25 ++++++++++++++++++++++++-
 glade/force_sensor_exercise.glade |  5 +++--
 src/gui/chronojumpIcons.cs        |  2 ++
 src/gui/encoder.cs                |  4 ++--
 src/gui/forceSensor.cs            | 37 +++++++++++++++++++++++++------------
 src/gui/forceSensorExercise.cs    | 10 +++++-----
 6 files changed, 61 insertions(+), 22 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index b270464a..6f88d1df 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -6666,6 +6666,29 @@ EncoderInertialCapture</property>
                                                             <property name="position">1</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="button_force_sensor_exercise_delete">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <property name="has_tooltip">True</property>
+                                                            <property name="tooltip" 
translatable="yes">Delete exercise type</property>
+                                                            <signal name="clicked" 
handler="on_button_force_sensor_exercise_delete_clicked" swapped="no"/>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_force_sensor_exercise_delete">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-new</property>
+                                                            <property name="icon-size">2</property>
+                                                            </widget>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -24407,7 +24430,7 @@ Concentric</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="receives_default">True</property>
                                                             <property name="has_tooltip">True</property>
-                                                            <property name="tooltip" translatable="yes">Add 
new exercise</property>
+                                                            <property name="tooltip" 
translatable="yes">Delete exercise type</property>
                                                             <property name="relief">half</property>
                                                             <signal name="clicked" 
handler="on_button_encoder_exercise_delete_clicked" swapped="no"/>
                                                             <child>
diff --git a/glade/force_sensor_exercise.glade b/glade/force_sensor_exercise.glade
index 43971091..e07f59a9 100644
--- a/glade/force_sensor_exercise.glade
+++ b/glade/force_sensor_exercise.glade
@@ -699,6 +699,7 @@
                   <widget class="GtkHButtonBox" id="hbuttonbox2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="spacing">20</property>
                     <property name="layout_style">start</property>
                     <child>
                       <widget class="GtkButton" id="button_cancel">
@@ -748,8 +749,8 @@
                     </child>
                   </widget>
                   <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
                     <property name="position">0</property>
                   </packing>
                 </child>
diff --git a/src/gui/chronojumpIcons.cs b/src/gui/chronojumpIcons.cs
index 43608916..3acb482e 100644
--- a/src/gui/chronojumpIcons.cs
+++ b/src/gui/chronojumpIcons.cs
@@ -174,6 +174,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Image image_force_sensor_capture_recalculate;
        [Widget] Gtk.Image image_force_sensor_analyze_analyze;
        [Widget] Gtk.Image image_force_sensor_exercise_edit;
+       [Widget] Gtk.Image image_force_sensor_exercise_delete;
        [Widget] Gtk.Image image_force_sensor_laterality_both;
        [Widget] Gtk.Image image_force_sensor_laterality_r;
        [Widget] Gtk.Image image_force_sensor_laterality_l;
@@ -595,6 +596,7 @@ public partial class ChronoJumpWindow
                image_run_type_delete_intervallic.Pixbuf = pixbuf;
                image_session_delete.Pixbuf = pixbuf;
                image_encoder_exercise_delete.Pixbuf = pixbuf;
+               image_force_sensor_exercise_delete.Pixbuf = pixbuf;
 
                image_button_cancel.Pixbuf = pixbuf;
                image_encoder_capture_cancel.Pixbuf = pixbuf;
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index e15c3d28..5dbbce92 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -4558,7 +4558,7 @@ public partial class ChronoJumpWindow
                bigArray.Add(a5);
                
                
-               genericWin = GenericWindow.Show(Catalog.GetString("Exercise"),
+               genericWin = GenericWindow.Show(Catalog.GetString("Delete exercise"),
                                false, Catalog.GetString("Encoder exercise name:"), bigArray);
                genericWin.LabelSpinInt = Catalog.GetString("Displaced body weight") + " (%)";
                
@@ -4740,7 +4740,7 @@ public partial class ChronoJumpWindow
                        //name cannot be changed because we have to detect if new name already exists, check 
problems with translations,
                        //but most important, if user can change name and then click delete, it will be a 
mess to confirm that the type "newname" or "oldname" will be deleted
                        genericWin = GenericWindow.Show(Catalog.GetString("Exercise"),
-                                       Catalog.GetString("Encoder exercise name:"), 
Constants.GenericWindowShow.ENTRY, false);
+                                       Catalog.GetString("Exercise name:"), 
Constants.GenericWindowShow.ENTRY, false);
 
                        genericWin.EntrySelected = ex.Name;
 
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index 9480e67f..3a05feb9 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -2267,15 +2267,32 @@ LogB.Information(" fs R ");
 
        //based on: on_button_encoder_exercise_delete
        //maybe unify them on the future
-       void on_button_force_sensor_exercise_delete (object o, EventArgs args)
+       void on_button_force_sensor_exercise_delete_clicked (object o, EventArgs args)
        {
-               int exerciseID = genericWin.uniqueID;
+               if(UtilGtk.ComboGetActive(combo_force_sensor_exercise) == "")
+               {
+                       new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Need to 
create/select an exercise."));
+                       return;
+               }
+
+               ForceSensorExercise ex = (ForceSensorExercise) SqliteForceSensorExercise.Select (
+                                false, getExerciseIDFromAnyCombo(combo_force_sensor_exercise, 
forceSensorComboExercisesString, false), false)[0];
 
                //1st find if there are sets with this exercise
-               ArrayList array = SqliteForceSensor.SelectRowsOfAnExercise(false, exerciseID);
+               ArrayList array = SqliteForceSensor.SelectRowsOfAnExercise(false, ex.UniqueID);
+
+               if(array.Count > 0)
+               {
+                       genericWin = GenericWindow.Show(Catalog.GetString("Delete exercise"),
+                                       Catalog.GetString("Exercise name:"), 
Constants.GenericWindowShow.ENTRY, false);
+
+                       genericWin.EntrySelected = ex.Name;
 
-               if(array.Count > 0) {
-                       //there are some records of this exercise on encoder table, do not delete
+                       //just one button to exit and with ESC accelerator
+                       genericWin.ShowButtonAccept(false);
+                       genericWin.SetButtonCancelLabel(Catalog.GetString("Close"));
+
+                       //there are some records of this exercise on forceSensor table, do not delete
                        genericWin.SetTextview(
                                        Catalog.GetString("Sorry, this exercise cannot be deleted until these 
tests are deleted:"));
 
@@ -2292,16 +2309,11 @@ LogB.Information(" fs R ");
 
                        genericWin.ShowTextview();
                        genericWin.ShowTreeview();
-                       genericWin.ShowButtonDelete(false);
-                       genericWin.DeletingExerciseHideSomeWidgets();
 
-                       genericWin.Button_accept.Clicked -= new 
EventHandler(on_button_force_sensor_exercise_edit_oldTODO_accepted);
                        genericWin.Button_accept.Clicked += new 
EventHandler(on_button_force_sensor_exercise_do_not_delete);
                } else {
                        //forceSensor table has not records of this exercise. Delete exercise
-                       SqliteForceSensorExercise.Delete(false, exerciseID);
-
-                       genericWin.HideAndNull();
+                       SqliteForceSensorExercise.Delete(false, ex.UniqueID);
 
                        fillForceSensorExerciseCombo("");
                        combo_force_sensor_exercise.Active = 0;
@@ -2311,7 +2323,8 @@ LogB.Information(" fs R ");
        }
 
        //accept does not save changes, just closes window
-       void on_button_force_sensor_exercise_do_not_delete (object o, EventArgs args) {
+       void on_button_force_sensor_exercise_do_not_delete (object o, EventArgs args)
+       {
                genericWin.Button_accept.Clicked -= new 
EventHandler(on_button_force_sensor_exercise_do_not_delete);
                genericWin.HideAndNull();
        }
diff --git a/src/gui/forceSensorExercise.cs b/src/gui/forceSensorExercise.cs
index 63998d6a..b7b3cb31 100644
--- a/src/gui/forceSensorExercise.cs
+++ b/src/gui/forceSensorExercise.cs
@@ -67,13 +67,13 @@ public class ForceSensorExerciseWindow
        [Widget] Gtk.TextView textview_description;
        [Widget] Gtk.TextView textview_examples;
 
+       [Widget] Gtk.Button button_back;
        [Widget] Gtk.Button button_next;
        [Widget] Gtk.Button button_accept;
-       [Widget] Gtk.Button button_back;
 
-       [Widget] Gtk.Image image_cancel;
-       [Widget] Gtk.Image image_next;
        [Widget] Gtk.Image image_back;
+       [Widget] Gtk.Image image_next;
+       [Widget] Gtk.Image image_cancel;
 
        [Widget] Gtk.Button fakeButtonReadValues;
 
@@ -121,8 +121,8 @@ public class ForceSensorExerciseWindow
                        ForceSensorExerciseWindowBox.label_header.Text = textHeader;
                }
 
-               ForceSensorExerciseWindowBox.modeEnum = modesEnum.EDIT;
                ForceSensorExerciseWindowBox.Success = false;
+               ForceSensorExerciseWindowBox.modeEnum = modesEnum.EDIT;
                ForceSensorExerciseWindowBox.initializeGuiAtShow();
                ForceSensorExerciseWindowBox.exercise = exercise;
                ForceSensorExerciseWindowBox.exerciseToGUI();
@@ -140,8 +140,8 @@ public class ForceSensorExerciseWindow
                        ForceSensorExerciseWindowBox.label_header.Text = textHeader;
                }
 
-               ForceSensorExerciseWindowBox.modeEnum = modesEnum.ADD;
                ForceSensorExerciseWindowBox.Success = false;
+               ForceSensorExerciseWindowBox.modeEnum = modesEnum.ADD;
                ForceSensorExerciseWindowBox.initializeGuiAtShow();
                ForceSensorExerciseWindowBox.exercise = null;
                ForceSensorExerciseWindowBox.force_sensor_exercise.Show ();


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