[chronojump] Threshold hscale moved to dialogThreshold



commit f232455ea7a63d1b2e211051521c9d0983b368d5
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Mar 29 14:01:31 2017 +0200

    Threshold hscale moved to dialogThreshold

 glade/app1.glade             |  146 ++++--------------------------------------
 glade/dialog_threshold.glade |   69 ++++++++++++++++++--
 src/gui/chronojump.cs        |   30 +++++----
 src/gui/chronojumpIcons.cs   |    2 -
 src/gui/dialogThreshold.cs   |   55 +++++++++++++++-
 5 files changed, 145 insertions(+), 157 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index ada448b..b9345a6 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -4146,72 +4146,21 @@ Carles</property>
                                                       </packing>
                                                     </child>
                                                     <child>
-                                                      <widget class="GtkHBox" id="hbox75">
+                                                      <widget class="GtkAlignment" id="alignment19">
                                                         <property name="visible">True</property>
                                                         <property name="can_focus">False</property>
+                                                        <property name="top_padding">8</property>
                                                         <child>
-                                                          <widget class="GtkHBox" 
id="hbox_chronopic_detecting">
-                                                            <property name="can_focus">False</property>
-                                                            <property name="spacing">4</property>
-                                                            <child>
-                                                            <widget class="GtkProgressBar" 
id="progressbar_chronopic_detecting">
+                                                          <widget class="GtkHBox" id="hbox75">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="show_text">True</property>
-                                                            </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_chronopic_detecting_cancel">
-                                                            <property name="label">gtk-cancel</property>
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">True</property>
-                                                            <property name="receives_default">True</property>
-                                                            <property name="use_stock">True</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
+                                                            <property name="spacing">8</property>
                                                             <child>
-                                                            <widget class="GtkButton" 
id="button_chronopic_detecting_info">
-                                                            <property name="label">gtk-info</property>
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">True</property>
-                                                            <property name="receives_default">True</property>
-                                                            <property name="use_stock">True</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">2</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="GtkViewport" 
id="viewport_chronopics">
+                                                            <widget class="GtkViewport" 
id="viewport_chronopics">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="shadow_type">none</property>
                                                             <child>
-                                                            <widget class="GtkHBox" id="hbox_chronopics">
-                                                            <property name="visible">True</property>
-                                                            <property name="app_paintable">True</property>
-                                                            <property name="can_focus">True</property>
-                                                            <property name="spacing">8</property>
-                                                            <child>
                                                             <widget class="GtkButton" 
id="button_activate_chronopics">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
@@ -4246,14 +4195,16 @@ Carles</property>
                                                             <property name="icon-size">2</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>
                                                             </child>
                                                             </widget>
+                                                            </child>
+                                                            </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
@@ -4261,81 +4212,16 @@ Carles</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkHBox" id="hbox36">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="spacing">4</property>
-                                                            <child>
-                                                            <widget class="GtkTable" 
id="table_chronopic_threshold">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="n_rows">2</property>
-                                                            <property name="n_columns">2</property>
-                                                            <property name="column_spacing">4</property>
-                                                            <property name="row_spacing">2</property>
-                                                            <child>
-                                                            <widget class="GtkLabel" id="label254">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label" 
translatable="yes">Threshold</property>
-                                                            </widget>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkButton" 
id="chronopic_threshold_help">
+                                                            <widget class="GtkButton" id="button_threshold">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="receives_default">True</property>
-                                                            <signal name="clicked" 
handler="on_chronopic_threshold_help_clicked" swapped="no"/>
-                                                            <child>
-                                                            <widget class="GtkImage" 
id="image_info_threshold">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="stock">gtk-info</property>
-                                                            <property name="icon-size">1</property>
-                                                            </widget>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="left_attach">1</property>
-                                                            <property name="right_attach">2</property>
-                                                            <property name="y_options"/>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkHScale" id="hscale_threshold">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">True</property>
-                                                            <property name="adjustment">5 1 10 1 1 
0</property>
-                                                            <property 
name="restrict_to_fill_level">False</property>
-                                                            <property name="fill_level">0</property>
-                                                            <property name="digits">0</property>
-                                                            <property name="draw_value">False</property>
-                                                            <signal name="value_changed" 
handler="on_hscale_threshold_value_changed" swapped="no"/>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="top_attach">1</property>
-                                                            <property name="bottom_attach">2</property>
-                                                            </packing>
-                                                            </child>
+                                                            <signal name="clicked" 
handler="on_threshold_clicked" swapped="no"/>
                                                             <child>
                                                             <widget class="GtkLabel" id="label_threshold">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="label">50</property>
-                                                            </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>
                                                             </widget>
-                                                            <packing>
-                                                            <property name="expand">True</property>
-                                                            <property name="fill">True</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
                                                             </child>
                                                             </widget>
                                                             <packing>
@@ -4344,14 +4230,7 @@ Carles</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>
@@ -19653,6 +19532,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/glade/dialog_threshold.glade b/glade/dialog_threshold.glade
index e5585c3..d651a97 100644
--- a/glade/dialog_threshold.glade
+++ b/glade/dialog_threshold.glade
@@ -15,7 +15,7 @@
       <widget class="GtkVBox" id="vbox151">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="spacing">20</property>
+        <property name="spacing">16</property>
         <child internal-child="action_area">
           <widget class="GtkHButtonBox" id="hbuttonbox44">
             <property name="visible">True</property>
@@ -51,7 +51,66 @@
           <widget class="GtkVBox" id="vbox152">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="spacing">20</property>
+            <property name="spacing">16</property>
+            <child>
+              <widget class="GtkAlignment" id="alignment1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="top_padding">10</property>
+                <child>
+                  <widget class="GtkHBox" id="hbox1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="spacing">12</property>
+                    <child>
+                      <widget class="GtkLabel" id="label_threshold_name">
+                        <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="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkHScale" id="hscale_threshold">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="adjustment">5 1 10 1 1 0</property>
+                        <property name="restrict_to_fill_level">False</property>
+                        <property name="fill_level">0</property>
+                        <property name="digits">0</property>
+                        <property name="draw_value">False</property>
+                        <signal name="value_changed" handler="on_hscale_threshold_value_changed" 
swapped="no"/>
+                      </widget>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkLabel" id="label_threshold_value">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label">50</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
             <child>
               <widget class="GtkFrame" id="frame2">
                 <property name="visible">True</property>
@@ -90,7 +149,7 @@
                   <widget class="GtkLabel" id="label23">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">&lt;b&gt;About threshold&lt;/b&gt;</property>
+                    <property name="label" translatable="yes">About threshold</property>
                     <property name="use_markup">True</property>
                   </widget>
                   <packing>
@@ -101,7 +160,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">0</property>
+                <property name="position">1</property>
               </packing>
             </child>
             <child>
@@ -204,7 +263,7 @@
               <packing>
                 <property name="expand">True</property>
                 <property name="fill">True</property>
-                <property name="position">1</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </widget>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 2aef21e..8958561 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -271,12 +271,12 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Box vbox_execute_test;
        [Widget] Gtk.Button button_execute_test;
        [Widget] Gtk.Viewport viewport_chronopics;
-       [Widget] Gtk.Label label_threshold;
-       [Widget] Gtk.HScale hscale_threshold;
        //[Widget] Gtk.Label label_chronopic_encoder;
        //[Widget] Gtk.Image image_chronopic_encoder_no;
        //[Widget] Gtk.Image image_chronopic_encoder_yes;
-       
+
+       [Widget] Gtk.Label label_threshold;
+
        [Widget] Gtk.HBox hbox_video_capture;
        [Widget] Gtk.Label label_video_feedback;
        [Widget] Gtk.CheckButton checkbutton_video;
@@ -2985,7 +2985,8 @@ public partial class ChronoJumpWindow
                        {
                                if(threshold.SelectTresholdForThisMode(m))
                                {
-                                       hscale_threshold.Value = threshold.SetHScaleValue();
+                                       label_threshold.Text = Catalog.GetString("Threshold") + " " + 
threshold.GetLabel() + " ms";
+
                                        last_menuitem_mode = m;
                                }
                        }
@@ -3448,17 +3449,21 @@ public partial class ChronoJumpWindow
                LogB.Debug("Called finish on multi");
        }
 
-       private void on_chronopic_threshold_help_clicked (object o, EventArgs args)
+       DialogThreshold dialogThreshold;
+       private void on_threshold_clicked (object o, EventArgs args)
        {
-               new DialogThreshold(getMenuItemMode());
+               dialogThreshold = new DialogThreshold(getMenuItemMode(), threshold.GetT);
+               dialogThreshold.FakeButtonClose.Clicked += new EventHandler(on_threshold_close);
        }
 
-       //hscale does not manage correctly the +10 increments.
-       //we solve it with a label
-       private void on_hscale_threshold_value_changed(object o, EventArgs arg)
+       private void on_threshold_close (object o, EventArgs args)
        {
-               threshold.UpdateFromGUI(10 * Convert.ToInt32(hscale_threshold.Value));
-               label_threshold.Text = threshold.GetLabel();
+               dialogThreshold.FakeButtonClose.Clicked -= new EventHandler(on_threshold_close);
+
+               threshold.UpdateFromGUI(dialogThreshold.ThresholdCurrent);
+               label_threshold.Text = Catalog.GetString("Threshold") + " " + threshold.GetLabel() + " ms";
+
+               dialogThreshold.DestroyDialog();
        }
 
        void on_button_execute_test_clicked (object o, EventArgs args) 
@@ -6371,7 +6376,6 @@ LogB.Debug("X");
                
                //notebooks
                notebook_execute.Sensitive = false;
-               //hbox_chronopics.Sensitive = false;
                notebook_results.Sensitive = false;
                notebook_options_top.Sensitive = false;
                notebook_encoder_sup.Sensitive = false;
@@ -6417,7 +6421,6 @@ LogB.Debug("X");
                personChanged();
                
                notebook_execute.Sensitive = false;
-               //hbox_chronopics.Sensitive = false;
                notebook_results.Sensitive = false;
                notebook_options_top.Sensitive = false;
                notebook_encoder_sup.Sensitive = false;
@@ -6438,7 +6441,6 @@ LogB.Debug("X");
                personChanged();
                
                notebook_execute.Sensitive = true;
-               //hbox_chronopics.Sensitive = true;
                notebook_results.Sensitive = true;
                notebook_options_top.Sensitive = true;
                notebook_encoder_sup.Sensitive = true;
diff --git a/src/gui/chronojumpIcons.cs b/src/gui/chronojumpIcons.cs
index db9e4c0..c138a1c 100644
--- a/src/gui/chronojumpIcons.cs
+++ b/src/gui/chronojumpIcons.cs
@@ -49,7 +49,6 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Image image_info2;
        [Widget] Gtk.Image image_info3;
        [Widget] Gtk.Image image_info4;
-       [Widget] Gtk.Image image_info_threshold;
        [Widget] Gtk.Image image_info_sessions_info;
        [Widget] Gtk.Image image_add_test1;
        [Widget] Gtk.Image image_add_test2;
@@ -125,7 +124,6 @@ public partial class ChronoJumpWindow
                image_info2.Pixbuf = pixbuf;
                image_info3.Pixbuf = pixbuf;
                image_info4.Pixbuf = pixbuf;
-               image_info_threshold.Pixbuf = pixbuf;
                image_info_sessions_info.Pixbuf = pixbuf;
                image_encoder_1RM_info.Pixbuf = pixbuf;
 
diff --git a/src/gui/dialogThreshold.cs b/src/gui/dialogThreshold.cs
index dc77116..de86d13 100644
--- a/src/gui/dialogThreshold.cs
+++ b/src/gui/dialogThreshold.cs
@@ -27,13 +27,21 @@ using Mono.Unix;
 public class DialogThreshold
 {
        [Widget] Gtk.Dialog dialog_threshold;
+
        [Widget] Gtk.Notebook notebook;
        [Widget] Gtk.TextView textview_about;
        [Widget] Gtk.TextView textview_jumps;
        [Widget] Gtk.TextView textview_races;
        [Widget] Gtk.TextView textview_other;
 
-       public DialogThreshold (Constants.Menuitem_modes m)
+       [Widget] Gtk.Label label_threshold_name;
+       [Widget] Gtk.Label label_threshold_value;
+       [Widget] Gtk.HScale hscale_threshold;
+
+       private int thresholdCurrent;
+       public Button FakeButtonClose;
+
+       public DialogThreshold (Constants.Menuitem_modes m, int thresholdCurrent)
        {
                Glade.XML gladeXML;
                gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "dialog_threshold.glade", 
"dialog_threshold", null);
@@ -42,14 +50,39 @@ public class DialogThreshold
                //put an icon to window
                UtilGtk.IconWindow(dialog_threshold);
 
+               FakeButtonClose = new Gtk.Button();
+
+               this.thresholdCurrent = thresholdCurrent;
+               hscale_threshold.Value = Convert.ToInt32(thresholdCurrent / 10);
+               label_threshold_value.Text = thresholdCurrent.ToString() + " ms";
+
                writeTexts();
 
                if(m == Constants.Menuitem_modes.JUMPSSIMPLE || m == Constants.Menuitem_modes.JUMPSREACTIVE)
+               {
+                       label_threshold_name.Text = "<b>" + Catalog.GetString("Threshold for jumps") + "</b>";
                        notebook.CurrentPage = 0;
+               }
                 else if(m == Constants.Menuitem_modes.RUNSSIMPLE || m == 
Constants.Menuitem_modes.RUNSINTERVALLIC)
+               {
+                       label_threshold_name.Text = "<b>" + Catalog.GetString("Threshold for runs") + "</b>";
                        notebook.CurrentPage = 1;
+               }
                else    //other
+               {
+                       label_threshold_name.Text = "<b>" + Catalog.GetString("Threshold for other tests") + 
"</b>";
                        notebook.CurrentPage = 2;
+               }
+
+               label_threshold_name.UseMarkup = true;
+       }
+
+       //hscale does not manage correctly the +10 increments.
+       //we solve it with a label
+       private void on_hscale_threshold_value_changed(object o, EventArgs arg)
+       {
+               thresholdCurrent = 10 * Convert.ToInt32(hscale_threshold.Value);
+               label_threshold_value.Text = thresholdCurrent.ToString() + " ms";
        }
 
        private void writeTexts()
@@ -84,11 +117,25 @@ public class DialogThreshold
                textview_other.Buffer = tb_other;
        }
 
-       public void on_button_close_clicked (object obj, EventArgs args) {
-               dialog_threshold.Destroy ();
+       public void on_button_close_clicked (object obj, EventArgs args)
+       {
+               FakeButtonClose.Click(); //this will call DestroyDialog() later
+       }
+
+       private void on_delete_event (object o, DeleteEventArgs args)
+       {
+               FakeButtonClose.Click(); //this will call DestroyDialog() later
+
+               args.RetVal = true;
        }
 
-       private void on_delete_event (object o, DeleteEventArgs args) {
+       public void DestroyDialog ()
+       {
                dialog_threshold.Destroy ();
        }
+
+       public int ThresholdCurrent
+       {
+               get { return thresholdCurrent;  }
+       }
 }


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