[chronojump] ForceSensorElasticBands better GUI WIP



commit 0e619550fcef1463797b4387157cdc3527480e26
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jun 19 15:04:20 2020 +0200

    ForceSensorElasticBands better GUI WIP

 glade/force_sensor_elastic_bands.glade | 671 +++++++++++++++++++++++----------
 src/forceSensor.cs                     |   1 +
 src/gui/forceSensorElasticBands.cs     | 197 +++++++---
 3 files changed, 627 insertions(+), 242 deletions(-)
---
diff --git a/glade/force_sensor_elastic_bands.glade b/glade/force_sensor_elastic_bands.glade
index 68b10921..8b548f2e 100644
--- a/glade/force_sensor_elastic_bands.glade
+++ b/glade/force_sensor_elastic_bands.glade
@@ -65,15 +65,15 @@
             <property name="show_tabs">False</property>
             <property name="show_border">False</property>
             <child>
-              <widget class="GtkVBox" id="vbox1">
+              <widget class="GtkVBox" id="vbox5">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="spacing">20</property>
+                <property name="spacing">12</property>
                 <child>
                   <widget class="GtkHBox" id="hbox2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="spacing">12</property>
+                    <property name="spacing">20</property>
                     <child>
                       <widget class="GtkHBox" id="hbox3">
                         <property name="visible">True</property>
@@ -172,43 +172,305 @@
                             <property name="position">0</property>
                           </packing>
                         </child>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="pack_type">end</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkFrame" id="frame_in_use">
+                    <property name="visible">True</property>
+                    <property name="sensitive">False</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0.5</property>
+                    <property name="shadow_type">out</property>
+                    <child>
+                      <widget class="GtkVBox" id="vbox6">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="border_width">12</property>
+                        <property name="spacing">20</property>
                         <child>
-                          <widget class="GtkButton" id="button_delete">
+                          <widget class="GtkTable" id="table_add_edit1">
                             <property name="visible">True</property>
-                            <property name="sensitive">False</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <signal name="clicked" handler="on_button_delete_clicked" swapped="no"/>
+                            <property name="can_focus">False</property>
+                            <property name="n_rows">2</property>
+                            <property name="n_columns">2</property>
+                            <property name="column_spacing">20</property>
+                            <property name="row_spacing">8</property>
                             <child>
-                              <widget class="GtkHBox" id="hbox11">
+                              <widget class="GtkLabel" id="label19">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="spacing">6</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">Stiffness</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="hbox14">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">20</property>
                                 <child>
-                                  <widget class="GtkImage" id="image_delete">
+                                  <widget class="GtkHBox" id="hbox17">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
-                                    <property name="stock">gtk-missing-image</property>
+                                    <property name="spacing">6</property>
+                                    <child>
+                                      <widget class="GtkSpinButton" id="spin_stiffness_view">
+                                        <property name="visible">True</property>
+                                        <property name="sensitive">False</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="invisible_char">●</property>
+                                        <property name="activates_default">True</property>
+                                        <property name="primary_icon_activatable">False</property>
+                                        <property name="secondary_icon_activatable">False</property>
+                                        <property name="primary_icon_sensitive">True</property>
+                                        <property name="secondary_icon_sensitive">True</property>
+                                        <property name="adjustment">0 0 9999999 0.10000000000000001 10 
0</property>
+                                        <property name="climb_rate">1</property>
+                                        <property name="digits">3</property>
+                                        <property name="numeric">True</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">True</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <widget class="GtkLabel" id="label20">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="label">N/m</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
                                   </widget>
                                   <packing>
-                                    <property name="expand">True</property>
+                                    <property name="expand">False</property>
                                     <property name="fill">True</property>
                                     <property name="position">0</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkLabel" id="label10">
+                                  <widget class="GtkLabel" id="label_stiffness_of_each_fixture_view">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
-                                    <property name="label" translatable="yes">Delete selected</property>
+                                    <property name="label" translatable="yes">(of each one)</property>
                                   </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">1</property>
                                   </packing>
                                 </child>
                               </widget>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkHBox" id="hbox18">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">30</property>
+                                <child>
+                                  <widget class="GtkHBox" id="hbox19">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="spacing">20</property>
+                                    <child>
+                                      <widget class="GtkHBox" id="hbox_active_view">
+                                        <property name="can_focus">False</property>
+                                        <property name="spacing">6</property>
+                                        <child>
+                                          <widget class="GtkLabel" id="label21">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="label" translatable="yes" comments="Not referred 
as an email attachment,&#10;referred as rubber elastic bands attached together">Attached units</property>
+                                          </widget>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">False</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <widget class="GtkSpinButton" id="spin_active_units_view">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="invisible_char">●</property>
+                                            <property name="primary_icon_activatable">False</property>
+                                            <property name="secondary_icon_activatable">False</property>
+                                            <property name="primary_icon_sensitive">True</property>
+                                            <property name="secondary_icon_sensitive">True</property>
+                                            <property name="adjustment">1 1 99 1 10 0</property>
+                                            <property name="numeric">True</property>
+                                            <signal name="value_changed" 
handler="on_spin_active_units_view_value_changed" swapped="no"/>
+                                          </widget>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">False</property>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                              </widget>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="x_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkCheckButton" id="check_active_view">
+                                <property name="label" translatable="yes">In use</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="toggled" handler="on_check_active_view_toggled" swapped="no"/>
+                              </widget>
+                              <packing>
+                                <property name="x_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkHButtonBox" id="hbuttonbox4">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="spacing">20</property>
+                            <property name="layout_style">end</property>
+                            <child>
+                              <widget class="GtkButton" id="button_edit">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <signal name="clicked" handler="on_button_edit_clicked" swapped="no"/>
+                                <child>
+                                  <widget class="GtkHBox" id="hbox21">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="spacing">6</property>
+                                    <child>
+                                      <widget class="GtkImage" id="image_edit">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="stock">gtk-missing-image</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <widget class="GtkLabel" id="label22">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="label" translatable="yes">Edit</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </widget>
+                                </child>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkButton" id="button_delete">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <signal name="clicked" handler="on_button_delete_clicked" swapped="no"/>
+                                <child>
+                                  <widget class="GtkHBox" id="hbox11">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="spacing">6</property>
+                                    <child>
+                                      <widget class="GtkImage" id="image_delete">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="stock">gtk-missing-image</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">True</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <widget class="GtkLabel" id="label10">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="label" translatable="yes">Delete</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">True</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </widget>
+                                </child>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">1</property>
+                              </packing>
                             </child>
                           </widget>
                           <packing>
@@ -218,24 +480,101 @@
                           </packing>
                         </child>
                       </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkLabel" id="label_edit_or_add1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </widget>
                       <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="pack_type">end</property>
-                        <property name="position">1</property>
+                        <property name="type">label_item</property>
+                      </packing>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkHButtonBox" id="hbuttonbox1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <widget class="GtkButton" id="button_close">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="can_default">True</property>
+                        <property name="receives_default">False</property>
+                        <signal name="clicked" handler="on_button_close_clicked" swapped="no"/>
+                        <accelerator key="Escape" signal="clicked"/>
+                        <child>
+                          <widget class="GtkHBox" id="hbox12">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <widget class="GtkImage" id="image_close">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="stock">gtk-missing-image</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label11">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Close</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </widget>
+                        </child>
+                      </widget>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
                       </packing>
                     </child>
                   </widget>
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
-                    <property name="position">0</property>
+                    <property name="position">2</property>
                   </packing>
                 </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label17">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label">view</property>
+              </widget>
+              <packing>
+                <property name="tab_fill">False</property>
+                <property name="type">tab</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkVBox" id="vbox1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="spacing">12</property>
                 <child>
                   <widget class="GtkFrame" id="frame_add_edit">
                     <property name="visible">True</property>
-                    <property name="sensitive">False</property>
                     <property name="can_focus">False</property>
                     <property name="label_xalign">0.5</property>
                     <property name="shadow_type">out</property>
@@ -322,7 +661,7 @@
                                     <property name="can_focus">False</property>
                                     <property name="spacing">6</property>
                                     <child>
-                                      <widget class="GtkSpinButton" id="spin_stiffness">
+                                      <widget class="GtkSpinButton" id="spin_stiffness_edit">
                                         <property name="visible">True</property>
                                         <property name="can_focus">True</property>
                                         <property name="invisible_char">●</property>
@@ -362,7 +701,7 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkLabel" id="label_stiffness_of_each_fixture">
+                                  <widget class="GtkLabel" id="label_stiffness_of_each_fixture_edit">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
                                     <property name="label" translatable="yes">(of each one)</property>
@@ -381,6 +720,81 @@
                                 <property name="bottom_attach">2</property>
                               </packing>
                             </child>
+                            <child>
+                              <widget class="GtkHBox" id="hbox13">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">20</property>
+                                <child>
+                                  <widget class="GtkEntry" id="entry_brand">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="invisible_char">●</property>
+                                    <property name="invisible_char_set">True</property>
+                                    <property name="primary_icon_activatable">False</property>
+                                    <property name="secondary_icon_activatable">False</property>
+                                    <property name="primary_icon_sensitive">True</property>
+                                    <property name="secondary_icon_sensitive">True</property>
+                                    <signal name="changed" handler="on_entries_changed" swapped="no"/>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkLabel" id="label_entry2">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label">Color</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkEntry" id="entry_color">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="invisible_char">●</property>
+                                    <property name="invisible_char_set">True</property>
+                                    <property name="primary_icon_activatable">False</property>
+                                    <property name="secondary_icon_activatable">False</property>
+                                    <property name="primary_icon_sensitive">True</property>
+                                    <property name="secondary_icon_sensitive">True</property>
+                                    <signal name="changed" handler="on_entries_changed" swapped="no"/>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                              </widget>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">2</property>
+                                <property name="bottom_attach">3</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkCheckButton" id="check_active_edit">
+                                <property name="label" translatable="yes">In use</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="toggled" handler="on_check_active_edit_toggled" swapped="no"/>
+                              </widget>
+                              <packing>
+                                <property name="x_options">GTK_FILL</property>
+                              </packing>
+                            </child>
                             <child>
                               <widget class="GtkHBox" id="hbox4">
                                 <property name="visible">True</property>
@@ -392,7 +806,7 @@
                                     <property name="can_focus">False</property>
                                     <property name="spacing">20</property>
                                     <child>
-                                      <widget class="GtkHBox" id="hbox_active">
+                                      <widget class="GtkHBox" id="hbox_active_edit">
                                         <property name="can_focus">False</property>
                                         <property name="spacing">6</property>
                                         <child>
@@ -408,7 +822,7 @@
                                           </packing>
                                         </child>
                                         <child>
-                                          <widget class="GtkSpinButton" id="spin_active_units">
+                                          <widget class="GtkSpinButton" id="spin_active_units_edit">
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="invisible_char">●</property>
@@ -418,7 +832,6 @@
                                             <property name="secondary_icon_sensitive">True</property>
                                             <property name="adjustment">1 1 99 1 10 0</property>
                                             <property name="numeric">True</property>
-                                            <signal name="value_changed" 
handler="on_spin_active_units_value_changed" swapped="no"/>
                                           </widget>
                                           <packing>
                                             <property name="expand">False</property>
@@ -447,81 +860,6 @@
                                 <property name="x_options">GTK_FILL</property>
                               </packing>
                             </child>
-                            <child>
-                              <widget class="GtkCheckButton" id="check_active">
-                                <property name="label" translatable="yes">In use</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="toggled" handler="on_check_active_toggled" swapped="no"/>
-                              </widget>
-                              <packing>
-                                <property name="x_options">GTK_FILL</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <widget class="GtkHBox" id="hbox13">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="spacing">20</property>
-                                <child>
-                                  <widget class="GtkEntry" id="entry_brand">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="invisible_char">●</property>
-                                    <property name="invisible_char_set">True</property>
-                                    <property name="primary_icon_activatable">False</property>
-                                    <property name="secondary_icon_activatable">False</property>
-                                    <property name="primary_icon_sensitive">True</property>
-                                    <property name="secondary_icon_sensitive">True</property>
-                                    <signal name="changed" handler="on_entries_changed" swapped="no"/>
-                                  </widget>
-                                  <packing>
-                                    <property name="expand">True</property>
-                                    <property name="fill">True</property>
-                                    <property name="position">0</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <widget class="GtkLabel" id="label_entry2">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="xalign">0</property>
-                                    <property name="label">Color</property>
-                                  </widget>
-                                  <packing>
-                                    <property name="expand">True</property>
-                                    <property name="fill">True</property>
-                                    <property name="position">1</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <widget class="GtkEntry" id="entry_color">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="invisible_char">●</property>
-                                    <property name="invisible_char_set">True</property>
-                                    <property name="primary_icon_activatable">False</property>
-                                    <property name="secondary_icon_activatable">False</property>
-                                    <property name="primary_icon_sensitive">True</property>
-                                    <property name="secondary_icon_sensitive">True</property>
-                                    <signal name="changed" handler="on_entries_changed" swapped="no"/>
-                                  </widget>
-                                  <packing>
-                                    <property name="expand">True</property>
-                                    <property name="fill">True</property>
-                                    <property name="position">2</property>
-                                  </packing>
-                                </child>
-                              </widget>
-                              <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                                <property name="top_attach">2</property>
-                                <property name="bottom_attach">3</property>
-                              </packing>
-                            </child>
                           </widget>
                           <packing>
                             <property name="expand">False</property>
@@ -536,19 +874,19 @@
                             <property name="spacing">20</property>
                             <property name="layout_style">end</property>
                             <child>
-                              <widget class="GtkButton" id="button_save">
+                              <widget class="GtkButton" id="button_edit_cancel">
                                 <property name="visible">True</property>
-                                <property name="sensitive">False</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">True</property>
-                                <signal name="clicked" handler="on_button_save_clicked" swapped="no"/>
+                                <signal name="clicked" handler="on_button_edit_cancel_clicked" swapped="no"/>
+                                <accelerator key="Escape" signal="clicked"/>
                                 <child>
-                                  <widget class="GtkHBox" id="hbox9">
+                                  <widget class="GtkHBox" id="hbox10">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
                                     <property name="spacing">6</property>
                                     <child>
-                                      <widget class="GtkImage" id="image_save">
+                                      <widget class="GtkImage" id="image_cancel">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
                                         <property name="stock">gtk-missing-image</property>
@@ -560,10 +898,10 @@
                                       </packing>
                                     </child>
                                     <child>
-                                      <widget class="GtkLabel" id="label7">
+                                      <widget class="GtkLabel" id="label8">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
-                                        <property name="label" translatable="yes">Save</property>
+                                        <property name="label" translatable="yes">Cancel</property>
                                       </widget>
                                       <packing>
                                         <property name="expand">False</property>
@@ -581,18 +919,19 @@
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkButton" id="button_cancel">
+                              <widget class="GtkButton" id="button_edit_save">
                                 <property name="visible">True</property>
+                                <property name="sensitive">False</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">True</property>
-                                <signal name="clicked" handler="on_button_cancel_clicked" swapped="no"/>
+                                <signal name="clicked" handler="on_button_edit_save_clicked" swapped="no"/>
                                 <child>
-                                  <widget class="GtkHBox" id="hbox10">
+                                  <widget class="GtkHBox" id="hbox9">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
                                     <property name="spacing">6</property>
                                     <child>
-                                      <widget class="GtkImage" id="image_cancel">
+                                      <widget class="GtkImage" id="image_save">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
                                         <property name="stock">gtk-missing-image</property>
@@ -604,10 +943,10 @@
                                       </packing>
                                     </child>
                                     <child>
-                                      <widget class="GtkLabel" id="label8">
+                                      <widget class="GtkLabel" id="label7">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
-                                        <property name="label" translatable="yes">Cancel</property>
+                                        <property name="label" translatable="yes">Save</property>
                                       </widget>
                                       <packing>
                                         <property name="expand">False</property>
@@ -646,74 +985,13 @@
                   <packing>
                     <property name="expand">True</property>
                     <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkAlignment" id="alignment2">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="top_padding">12</property>
-                    <child>
-                      <widget class="GtkHButtonBox" id="hbuttonbox1">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <child>
-                          <widget class="GtkButton" id="button_close">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="can_default">True</property>
-                            <property name="receives_default">False</property>
-                            <signal name="clicked" handler="on_button_close_clicked" swapped="no"/>
-                            <accelerator key="Escape" signal="clicked"/>
-                            <child>
-                              <widget class="GtkHBox" id="hbox12">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="spacing">6</property>
-                                <child>
-                                  <widget class="GtkImage" id="image_close">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="stock">gtk-missing-image</property>
-                                  </widget>
-                                  <packing>
-                                    <property name="expand">True</property>
-                                    <property name="fill">True</property>
-                                    <property name="position">0</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <widget class="GtkLabel" id="label11">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="label" translatable="yes">Close</property>
-                                  </widget>
-                                  <packing>
-                                    <property name="expand">True</property>
-                                    <property name="fill">True</property>
-                                    <property name="position">1</property>
-                                  </packing>
-                                </child>
-                              </widget>
-                            </child>
-                          </widget>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                      </widget>
-                    </child>
-                  </widget>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">2</property>
+                    <property name="position">0</property>
                   </packing>
                 </child>
               </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
             </child>
             <child>
               <widget class="GtkLabel" id="label12">
@@ -722,6 +1000,7 @@
                 <property name="label">add/edit</property>
               </widget>
               <packing>
+                <property name="position">1</property>
                 <property name="tab_fill">False</property>
                 <property name="type">tab</property>
               </packing>
@@ -807,18 +1086,19 @@ you will have to create again the elastic band.</property>
                             <property name="spacing">20</property>
                             <property name="layout_style">end</property>
                             <child>
-                              <widget class="GtkButton" id="button_delete_confirm">
+                              <widget class="GtkButton" id="button_cancel_delete">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">True</property>
-                                <signal name="clicked" handler="on_button_delete_confirm_clicked" 
swapped="no"/>
+                                <signal name="clicked" handler="on_button_cancel_delete_clicked" 
swapped="no"/>
+                                <accelerator key="Escape" signal="clicked"/>
                                 <child>
-                                  <widget class="GtkHBox" id="hbox15">
+                                  <widget class="GtkHBox" id="hbox16">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
                                     <property name="spacing">6</property>
                                     <child>
-                                      <widget class="GtkImage" id="image_delete_confirm">
+                                      <widget class="GtkImage" id="image_cancel_delete">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
                                         <property name="stock">gtk-missing-image</property>
@@ -830,10 +1110,10 @@ you will have to create again the elastic band.</property>
                                       </packing>
                                     </child>
                                     <child>
-                                      <widget class="GtkLabel" id="label15">
+                                      <widget class="GtkLabel" id="label16">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
-                                        <property name="label" translatable="yes">Confirm deletion</property>
+                                        <property name="label" translatable="yes">Cancel</property>
                                       </widget>
                                       <packing>
                                         <property name="expand">False</property>
@@ -851,19 +1131,18 @@ you will have to create again the elastic band.</property>
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkButton" id="button_cancel_delete">
+                              <widget class="GtkButton" id="button_delete_confirm">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">True</property>
-                                <signal name="clicked" handler="on_button_cancel_delete_clicked" 
swapped="no"/>
-                                <accelerator key="Escape" signal="clicked"/>
+                                <signal name="clicked" handler="on_button_delete_confirm_clicked" 
swapped="no"/>
                                 <child>
-                                  <widget class="GtkHBox" id="hbox16">
+                                  <widget class="GtkHBox" id="hbox15">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
                                     <property name="spacing">6</property>
                                     <child>
-                                      <widget class="GtkImage" id="image_cancel_delete">
+                                      <widget class="GtkImage" id="image_delete_confirm">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
                                         <property name="stock">gtk-missing-image</property>
@@ -875,10 +1154,10 @@ you will have to create again the elastic band.</property>
                                       </packing>
                                     </child>
                                     <child>
-                                      <widget class="GtkLabel" id="label16">
+                                      <widget class="GtkLabel" id="label15">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
-                                        <property name="label" translatable="yes">Cancel</property>
+                                        <property name="label" translatable="yes">Confirm deletion</property>
                                       </widget>
                                       <packing>
                                         <property name="expand">False</property>
@@ -914,7 +1193,7 @@ you will have to create again the elastic band.</property>
                 </child>
               </widget>
               <packing>
-                <property name="position">1</property>
+                <property name="position">2</property>
               </packing>
             </child>
             <child>
@@ -924,7 +1203,7 @@ you will have to create again the elastic band.</property>
                 <property name="label">delete</property>
               </widget>
               <packing>
-                <property name="position">1</property>
+                <property name="position">2</property>
                 <property name="tab_fill">False</property>
                 <property name="type">tab</property>
               </packing>
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 5df4c1fc..c38c2c1e 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -674,6 +674,7 @@ public class ForceSensorElasticBand
        public int Active
        {
                get { return active; }
+               set { active = value; }
        }
        public string Brand
        {
diff --git a/src/gui/forceSensorElasticBands.cs b/src/gui/forceSensorElasticBands.cs
index ef7c1b7a..6d8b3126 100644
--- a/src/gui/forceSensorElasticBands.cs
+++ b/src/gui/forceSensorElasticBands.cs
@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * Copyright (C) 2004-2019   Xavier de Blas <xaviblas gmail com> 
+ * Copyright (C) 2004-2020   Xavier de Blas <xaviblas gmail com>
  */
 
 using System;
@@ -36,18 +36,24 @@ public class ForceSensorElasticBandsWindow
 
        //fist tab "add/edit"
        [Widget] Gtk.Image image_add;
+       [Widget] Gtk.Image image_edit;
        [Widget] Gtk.Image image_delete;
        [Widget] Gtk.Image image_save;
        [Widget] Gtk.Image image_cancel;
-       [Widget] Gtk.Button button_save;
+       [Widget] Gtk.Button button_edit_save;
        [Widget] Gtk.Button button_delete;
-       [Widget] Gtk.CheckButton check_active;
-       [Widget] Gtk.HBox hbox_active;
-       [Widget] Gtk.SpinButton spin_active_units;
-       [Widget] Gtk.SpinButton spin_stiffness;
-       [Widget] Gtk.Label label_stiffness_of_each_fixture;
+       [Widget] Gtk.CheckButton check_active_view;
+       [Widget] Gtk.CheckButton check_active_edit;
+       [Widget] Gtk.HBox hbox_active_view;
+       [Widget] Gtk.HBox hbox_active_edit;
+       [Widget] Gtk.SpinButton spin_active_units_view;
+       [Widget] Gtk.SpinButton spin_active_units_edit;
+       [Widget] Gtk.SpinButton spin_stiffness_view;
+       [Widget] Gtk.SpinButton spin_stiffness_edit;
+       [Widget] Gtk.Label label_stiffness_of_each_fixture_view;
+       [Widget] Gtk.Label label_stiffness_of_each_fixture_edit;
        [Widget] Gtk.Label label_total_stiffness_value;
-       [Widget] Gtk.Frame frame_add_edit;
+       [Widget] Gtk.Frame frame_in_use;
        [Widget] Gtk.Label label_edit_or_add;
        [Widget] Gtk.Entry entry_brand;
        [Widget] Gtk.Entry entry_color;
@@ -69,6 +75,7 @@ public class ForceSensorElasticBandsWindow
 
        public int uniqueID;                    //used on encoder & forceSensor edit exercise
        private int stiffnessColumn;
+       private bool followSignals;
 
        private enum modes { EDITING, ADDING } 
        private modes currentMode;
@@ -82,6 +89,8 @@ public class ForceSensorElasticBandsWindow
                Pixbuf pixbuf;
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_add.png");
                image_add.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_edit.png");
+               image_edit.Pixbuf = pixbuf;
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "stock_delete.png");
                image_delete.Pixbuf = pixbuf;
                image_delete_confirm.Pixbuf = pixbuf;
@@ -104,7 +113,8 @@ public class ForceSensorElasticBandsWindow
                label_header.Text = textHeader;
 
                initializeGui(title, textHeader);
-               frame_add_edit.Sensitive = false;
+               frame_in_use.Sensitive = false;
+               followSignals = true;
                force_sensor_elastic_bands.Show ();
        }
 
@@ -155,28 +165,36 @@ public class ForceSensorElasticBandsWindow
 
        private void empty_frame()
        {
-               check_active.Active = false;
-               spin_active_units.Value = 1;
+               check_active_view.Active = false;
+               check_active_edit.Active = false;
+               spin_active_units_view.Value = 1;
+               spin_active_units_edit.Value = 1;
                entry_brand.Text = "";
                entry_color.Text = "";
                entry_comments.Text = "";
-               spin_stiffness.Value = 0;
+               spin_stiffness_view.Value = 0;
+               spin_stiffness_edit.Value = 0;
        }
        private void fill_frame(ForceSensorElasticBand fseb)
        {
                if(fseb.Active == 0) {
-                       check_active.Active = false;
-                       spin_active_units.Value = 1;
+                       check_active_view.Active = false;
+                       check_active_edit.Active = false;
+                       spin_active_units_view.Value = 1;
+                       spin_active_units_edit.Value = 1;
                }
                else {
-                       check_active.Active = true;
-                       spin_active_units.Value = fseb.Active;
+                       check_active_view.Active = true;
+                       check_active_edit.Active = true;
+                       spin_active_units_view.Value = fseb.Active;
+                       spin_active_units_edit.Value = fseb.Active;
                }
 
                entry_brand.Text = fseb.Brand;
                entry_color.Text = fseb.Color;
                entry_comments.Text = fseb.Comments;
-               spin_stiffness.Value = fseb.Stiffness;
+               spin_stiffness_view.Value = fseb.Stiffness;
+               spin_stiffness_edit.Value = fseb.Stiffness;
        }
 
        //data is an ArrayList of strings[], each string [] is a row, each of its strings is a column
@@ -253,11 +271,35 @@ public class ForceSensorElasticBandsWindow
                if (treeview.Selection.GetSelected (out myModel, out iter))
                {
                        currentMode = modes.EDITING;
-                       button_delete.Sensitive = true;
+               //      button_delete.Sensitive = true;
                        label_edit_or_add.Text = Catalog.GetString("Edit selected");
                        ForceSensorElasticBand fseb = getSelectedForceSensorElasticBand();
                        fill_frame(fseb);
-                       frame_add_edit.Sensitive = true;
+                       frame_in_use.Sensitive = true;
+               }
+       }
+
+       private int getSelectedID()
+       {
+               TreeIter iter = new TreeIter();
+               TreeModel model = treeview.Model;
+               if (treeview.Selection.GetSelected (out model, out iter))
+                       return Convert.ToInt32(model.GetValue(iter, 0).ToString());
+
+               return -1;
+       }
+       //pass 0 for first row
+       private void selectRow(int rowNumber)
+       {
+               TreeIter iter;
+               bool iterOk = store.GetIterFirst(out iter);
+               if(iterOk) {
+                       int count = 0;
+                       while (count < rowNumber) {
+                               store.IterNext(ref iter);
+                               count ++;
+                       }
+                       treeview.Selection.SelectIter(iter);
                }
        }
 
@@ -266,61 +308,81 @@ public class ForceSensorElasticBandsWindow
                currentMode = modes.ADDING;
                empty_frame(); //empty all
                label_edit_or_add.Text = Catalog.GetString("Add new elastic band/tube");
-               frame_add_edit.Sensitive = true;
+               frame_in_use.Sensitive = true;
                treeview.Selection.UnselectAll();
-               button_delete.Sensitive = false;
+               //button_delete.Sensitive = false;
+
+               notebook.CurrentPage = 1;
        }
-       private void on_button_save_clicked (object o, EventArgs args)
+
+       private void on_button_edit_clicked (object o, EventArgs args)
+       {
+               notebook.CurrentPage = 1;
+       }
+
+       private void on_button_edit_save_clicked (object o, EventArgs args)
        {
                int active = 0;
-               if(check_active.Active)
-                       active = Convert.ToInt32(spin_active_units.Value);
+               if(check_active_edit.Active)
+                       active = Convert.ToInt32(spin_active_units_edit.Value);
 
                //1) insert on SQL
                if(currentMode == modes.ADDING)
                {
-                       //create fseb from frame_add_edit
-                       ForceSensorElasticBand fseb = new ForceSensorElasticBand(-1, active, 
entry_brand.Text, entry_color.Text, spin_stiffness.Value, entry_comments.Text);
+                       //create fseb from frame_in_use
+                       ForceSensorElasticBand fseb = new ForceSensorElasticBand(-1, active, 
entry_brand.Text, entry_color.Text, spin_stiffness_edit.Value, entry_comments.Text);
 
                        //insert on SQL
                        SqliteForceSensorElasticBand.Insert(false, fseb);
 
-                       //unsensitivize frame_add_edit
-                       frame_add_edit.Sensitive = false;
+                       //unsensitivize frame_in_use
+                       frame_in_use.Sensitive = false;
                }
                else //(currentMode == modes.EDITING)
                {
                        //get selected just to know uniqueID and if it is active
                        ForceSensorElasticBand fseb = getSelectedForceSensorElasticBand();
 
-                       //change the params on frame_add_edit
-                       fseb.Update(active, entry_brand.Text, entry_color.Text, spin_stiffness.Value, 
entry_comments.Text);
+                       //change the params on frame_in_use
+                       fseb.Update(active, entry_brand.Text, entry_color.Text, spin_stiffness_edit.Value, 
entry_comments.Text);
 
                        //update SQL
                        SqliteForceSensorElasticBand.Update(false, fseb);
 
-                       //unsensitivize frame_add_edit
-                       frame_add_edit.Sensitive = false;
+                       //unsensitivize frame_in_use
+                       frame_in_use.Sensitive = false;
                }
-               
+
+               //udpate the main (view) tab
+               spin_stiffness_view.Value = spin_stiffness_edit.Value;
+
+               followSignals = false;
+               check_active_view.Active = check_active_edit.Active;
+               spin_active_units_view.Value = spin_active_units_edit.Value;
+               followSignals = true;
+
                //vbox_bands.Sensitive = true;
 
                //2) regenerate treeview
                UtilGtk.RemoveColumns(treeview);
                setTreeview();
+               notebook.CurrentPage = 0;
        }
 
-       private void on_button_cancel_clicked (object o, EventArgs args)
+       private void on_button_edit_cancel_clicked (object o, EventArgs args)
        {
-               //unsensitivize frame_add_edit
-               frame_add_edit.Sensitive = false;
-               button_delete.Sensitive = false;
+               //unsensitivize frame_in_use
+               //frame_in_use.Sensitive = false;
+               //button_delete.Sensitive = false;
+
+               notebook.CurrentPage = 0;
        }
 
+
        private void on_button_delete_clicked (object o, EventArgs args)
        {
                //TODO: only if there are captures done with this
-               notebook.CurrentPage = 1;
+               notebook.CurrentPage = 2;
        }
        private void on_button_cancel_delete_clicked (object o, EventArgs args)
        {
@@ -340,8 +402,10 @@ public class ForceSensorElasticBandsWindow
 
                //4) fix the rest of the gui
                empty_frame(); //empty all
-               frame_add_edit.Sensitive = false;
-               button_delete.Sensitive = false;
+               frame_in_use.Sensitive = false;
+               //button_delete.Sensitive = false;
+
+               notebook.CurrentPage = 0;
        }
 
        private void stiffnessTotalUpdate()
@@ -359,15 +423,56 @@ public class ForceSensorElasticBandsWindow
                fakeButton_stiffness_changed.Click();
        }
 
-       private void on_check_active_toggled (object o, EventArgs args)
+       private void on_check_active_view_toggled (object o, EventArgs args)
+       {
+               hbox_active_view.Visible = check_active_view.Active;
+               on_spin_active_units_view_value_changed (new object (), new EventArgs ());
+
+               check_active_edit.Active = check_active_view.Active;
+       }
+       private void on_check_active_edit_toggled (object o, EventArgs args)
        {
-               hbox_active.Visible = check_active.Active;
-               on_spin_active_units_value_changed (new object (), new EventArgs ());
+               hbox_active_edit.Visible = check_active_edit.Active;
        }
 
-       private void on_spin_active_units_value_changed (object o, EventArgs args)
+
+       private void on_spin_active_units_view_value_changed (object o, EventArgs args)
        {
-               label_stiffness_of_each_fixture.Visible = (Convert.ToInt32(spin_active_units.Value) > 1);
+               label_stiffness_of_each_fixture_view.Visible = (Convert.ToInt32(spin_active_units_view.Value) 
1);
+               label_stiffness_of_each_fixture_edit.Visible = (Convert.ToInt32(spin_active_units_edit.Value) 
1);
+
+               spin_active_units_edit.Value = spin_active_units_view.Value;
+
+               /*
+               //save and update treeview
+               currentMode = modes.EDITING;
+               on_button_edit_save_clicked (new object (), new EventArgs ());
+               */
+
+               if(followSignals)
+                       updateFixtures();
+       }
+
+       private void updateFixtures()
+       {
+               TreeIter iter = new TreeIter();
+               TreeModel model = treeview.Model;
+               int active = 0;
+               if (treeview.Selection.GetSelected (out model, out iter))
+                       if(check_active_view.Active)
+                               active = Convert.ToInt32(spin_active_units_view.Value);
+
+               model.SetValue(iter, 1, active.ToString());
+
+               ForceSensorElasticBand fseb = getSelectedForceSensorElasticBand();
+
+               //change the params on frame_in_use
+               fseb.Active = active;
+
+               //update SQL
+               SqliteForceSensorElasticBand.Update(false, fseb);
+
+               stiffnessTotalUpdate();
        }
 
        private void on_entries_changed (object o, EventArgs args)
@@ -378,7 +483,7 @@ public class ForceSensorElasticBandsWindow
 
                entry.Text = Util.MakeValidSQL(entry.Text);
 
-               button_save.Sensitive = ( entry_brand.Text != "" || entry_color.Text != "" || 
entry_comments.Text != "" );
+               button_edit_save.Sensitive = ( entry_brand.Text != "" || entry_color.Text != "" || 
entry_comments.Text != "" );
        }
 
        private void on_button_close_clicked (object o, EventArgs args)


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