[chronojump] Menuitem Mode from radio to imagemenuitem: other/race encoder. All done!



commit 62e611990c7df9f8be6822b92e3fd24f0c559408
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Aug 9 17:58:41 2019 +0200

    Menuitem Mode from radio to imagemenuitem: other/race encoder. All done!

 glade/app1.glade           | 78 ++++++++++++++++++++++++++--------------------
 src/gui/chronojump.cs      | 47 ++++++++--------------------
 src/gui/chronojumpIcons.cs |  6 ++++
 3 files changed, 64 insertions(+), 67 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 4c54ed3c..1ee69bca 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -291,15 +291,6 @@
                         </child>
                       </widget>
                     </child>
-                    <child>
-                      <widget class="GtkRadioMenuItem" id="radio_menuitem_mode_jumps_simple">
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">Simple</property>
-                        <property name="use_underline">True</property>
-                        <property name="draw_as_radio">True</property>
-                        <signal name="activate" handler="on_radio_menuitem_mode_activate" swapped="no"/>
-                      </widget>
-                    </child>
                     <child>
                       <widget class="GtkSeparatorMenuItem" id="menuitem4">
                         <property name="visible">True</property>
@@ -350,14 +341,20 @@
                       </widget>
                     </child>
                     <child>
-                      <widget class="GtkRadioMenuItem" id="radio_menuitem_mode_runs_encoder">
+                      <widget class="GtkImageMenuItem" id="menuitem_mode_race_encoder">
+                        <property name="label" translatable="yes">Races with encoder</property>
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="label">Races with encoder</property>
-                        <property name="use_underline">True</property>
-                        <property name="draw_as_radio">True</property>
-                        <property name="group">radio_menuitem_mode_jumps_simple</property>
-                        <signal name="activate" handler="on_radio_menuitem_mode_activate" swapped="no"/>
+                        <property name="use_stock">False</property>
+                        <property name="always_show_image">True</property>
+                        <signal name="activate" handler="on_menuitem_mode_activate" swapped="no"/>
+                        <child internal-child="image">
+                          <widget class="GtkImage" id="image_menuitem_mode_race_encoder">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="stock">gtk-missing-image</property>
+                          </widget>
+                        </child>
                       </widget>
                     </child>
                     <child>
@@ -450,14 +447,20 @@
                       </widget>
                     </child>
                     <child>
-                      <widget class="GtkRadioMenuItem" id="radio_menuitem_mode_other">
+                      <widget class="GtkImageMenuItem" id="menuitem_mode_other">
+                        <property name="label" translatable="yes">Other</property>
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">Other</property>
-                        <property name="use_underline">True</property>
-                        <property name="draw_as_radio">True</property>
-                        <property name="group">radio_menuitem_mode_jumps_simple</property>
-                        <signal name="activate" handler="on_radio_menuitem_mode_activate" swapped="no"/>
+                        <property name="use_stock">False</property>
+                        <property name="always_show_image">True</property>
+                        <signal name="activate" handler="on_menuitem_mode_activate" swapped="no"/>
+                        <child internal-child="image">
+                          <widget class="GtkImage" id="image_menuitem_mode_other">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="stock">gtk-missing-image</property>
+                          </widget>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -2197,6 +2200,9 @@
                                                             <placeholder/>
                                                             </child>
                                                             <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkLabel" 
id="label_start_selector_jumps">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -21496,6 +21502,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -23456,6 +23465,18 @@ Concentric</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">6</property>
                                                             <child>
+                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="pack_type">end</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_capturing">
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">4</property>
@@ -23492,18 +23513,6 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="pack_type">end</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_no_capturing">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -30339,6 +30348,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index fb498700..ef2c7d2e 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -57,16 +57,16 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Viewport viewport_chronojump_logo;
        [Widget] Gtk.Image image_chronojump_logo;
 
-       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_runs_encoder;
-       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_other;
        [Widget] Gtk.ImageMenuItem menuitem_mode_jumps_simple;
        [Widget] Gtk.ImageMenuItem menuitem_mode_jumps_reactive;
        [Widget] Gtk.ImageMenuItem menuitem_mode_runs_simple;
        [Widget] Gtk.ImageMenuItem menuitem_mode_runs_intervallic;
+       [Widget] Gtk.ImageMenuItem menuitem_mode_race_encoder;
        [Widget] Gtk.ImageMenuItem menuitem_mode_power_gravitatory;
        [Widget] Gtk.ImageMenuItem menuitem_mode_power_inertial;
        [Widget] Gtk.ImageMenuItem menuitem_mode_force_sensor;
        [Widget] Gtk.ImageMenuItem menuitem_mode_reaction_time;
+       [Widget] Gtk.ImageMenuItem menuitem_mode_other;
 
        [Widget] Gtk.Notebook notebook_start;           //start window or program
        [Widget] Gtk.Notebook notebook_start_selector;  //use to display the start images to select different 
modes
@@ -829,8 +829,8 @@ public partial class ChronoJumpWindow
                        "   " + ((Label) menuitem_mode_runs_simple.Child).Text;
                ((Label) menuitem_mode_runs_intervallic.Child).Text =
                        "   " + ((Label) menuitem_mode_runs_intervallic.Child).Text;
-               ((Label) radio_menuitem_mode_runs_encoder.Child).Text =
-                       "   " + ((Label) radio_menuitem_mode_runs_encoder.Child).Text;
+               ((Label) menuitem_mode_race_encoder.Child).Text =
+                       "   " + ((Label) menuitem_mode_race_encoder.Child).Text;
 
                ((Label) menuitem_mode_power_gravitatory.Child).Text =
                        "   " + ((Label) menuitem_mode_power_gravitatory.Child).Text;
@@ -3422,7 +3422,6 @@ public partial class ChronoJumpWindow
                else if(m == Constants.Menuitem_modes.RUNSENCODER)
                {
                        notebook_sup.CurrentPage = 0;
-                       radio_menuitem_mode_runs_encoder.Active = true;
                        notebooks_change(m);
 //                     on_extra_window_reaction_times_test_changed(new object(), new EventArgs());
 
@@ -3645,26 +3644,6 @@ public partial class ChronoJumpWindow
        */
                
 
-       /*
-        * used after changing radio
-        * for other uses, check:
-        * current_menuitem_mode
-        */
-       private Constants.Menuitem_modes getMenuItemMode() 
-       {
-               return Constants.Menuitem_modes.OTHER;
-       }
-
-       private void on_radio_menuitem_mode_activate(object o, EventArgs args) 
-       {
-               //togglebutton sends signal two times (deactivate/activate), just get the good signal
-               //http://stackoverflow.com/questions/10755541/mono-gtk-radiobutton-clicked-event-firing-twice
-               if( ! (o as Gtk.RadioMenuItem).Active )
-                       return;
-
-               select_menuitem_mode_toggled(getMenuItemMode());
-       }
-
        private void on_menuitem_mode_activate(object o, EventArgs args)
        {
                Gtk.ImageMenuItem imi = o as Gtk.ImageMenuItem;
@@ -3679,6 +3658,8 @@ public partial class ChronoJumpWindow
                        select_menuitem_mode_toggled(Constants.Menuitem_modes.RUNSSIMPLE);
                else if(o == menuitem_mode_runs_intervallic)
                        select_menuitem_mode_toggled(Constants.Menuitem_modes.RUNSINTERVALLIC);
+               else if(o == menuitem_mode_race_encoder)
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.RUNSENCODER);
                else if(o == menuitem_mode_power_gravitatory)
                        select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERGRAVITATORY);
                else if(o == menuitem_mode_power_inertial)
@@ -3687,15 +3668,19 @@ public partial class ChronoJumpWindow
                        select_menuitem_mode_toggled(Constants.Menuitem_modes.FORCESENSOR);
                else if(o == menuitem_mode_reaction_time)
                        select_menuitem_mode_toggled(Constants.Menuitem_modes.RT);
+               else if(o == menuitem_mode_other)
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.OTHER);
 
                changeMenuitemModePixbuf(image_menuitem_mode_jumps_simple, o == menuitem_mode_jumps_simple, 
"image_jump_simple.png", "image_jump_simple_yellow.png");
                changeMenuitemModePixbuf(image_menuitem_mode_jumps_reactive, o == 
menuitem_mode_jumps_reactive, "image_jump_reactive.png", "image_jump_reactive_yellow.png");
                changeMenuitemModePixbuf(image_menuitem_mode_runs_simple, o == menuitem_mode_runs_simple, 
"image_run_simple.png", "image_run_simple_yellow.png");
                changeMenuitemModePixbuf(image_menuitem_mode_runs_intervallic, o == 
menuitem_mode_runs_intervallic, "image_run_multiple.png", "image_run_multiple_yellow.png");
+               changeMenuitemModePixbuf(image_menuitem_mode_race_encoder, o == menuitem_mode_race_encoder, 
"race_encoder_icon.png", "race_encoder_icon_yellow.png");
                changeMenuitemModePixbuf(image_menuitem_mode_power_gravitatory, o == 
menuitem_mode_power_gravitatory, "image_gravity.png", "image_gravity_yellow.png");
                changeMenuitemModePixbuf(image_menuitem_mode_power_inertial, o == 
menuitem_mode_power_inertial, "image_inertia.png", "image_inertia_yellow.png");
                changeMenuitemModePixbuf(image_menuitem_mode_force_sensor, o == menuitem_mode_force_sensor, 
"force_sensor_icon.png", "force_sensor_icon_yellow.png");
                changeMenuitemModePixbuf(image_menuitem_mode_reaction_time, o == menuitem_mode_reaction_time, 
"reaction_time_icon.png", "reaction_time_icon_yellow.png");
+               changeMenuitemModePixbuf(image_menuitem_mode_other, o == menuitem_mode_other, 
"other_icon.png", "other_icon_yellow.png");
        }
 
        private void changeMenuitemModePixbuf(Gtk.Image image, bool active, string pathImageInactive, string 
pathImageActive)
@@ -3736,10 +3721,7 @@ public partial class ChronoJumpWindow
        }
        private void on_button_selector_start_runs_encoder_clicked(object o, EventArgs args)
        {
-               if(radio_menuitem_mode_runs_encoder.Active)
-                       select_menuitem_mode_toggled(Constants.Menuitem_modes.RUNSENCODER);
-               else
-                       radio_menuitem_mode_runs_encoder.Active = true;
+               on_menuitem_mode_activate(menuitem_mode_race_encoder, new EventArgs());
        }
        
        private void on_button_selector_start_encoder_clicked(object o, EventArgs args) 
@@ -3769,10 +3751,7 @@ public partial class ChronoJumpWindow
 
        private void on_button_selector_start_other_clicked(object o, EventArgs args)
        {
-               if(radio_menuitem_mode_other.Active)
-                       select_menuitem_mode_toggled(Constants.Menuitem_modes.OTHER);
-               else
-                       radio_menuitem_mode_other.Active = true;
+               on_menuitem_mode_activate(menuitem_mode_other, new EventArgs());
        }
 
        private void on_button_start_cancel_clicked(object o, EventArgs args)
@@ -3914,7 +3893,7 @@ public partial class ChronoJumpWindow
                }
                if(current_menuitem_mode == Constants.Menuitem_modes.RUNSENCODER)
                {
-                       LogB.Debug("radio_mode_runs_encoder");
+                       LogB.Debug("runs_encoder");
                        /*
                         * runs encoder is not FTDI
                         */
diff --git a/src/gui/chronojumpIcons.cs b/src/gui/chronojumpIcons.cs
index 3a096fa1..759540ff 100644
--- a/src/gui/chronojumpIcons.cs
+++ b/src/gui/chronojumpIcons.cs
@@ -90,10 +90,12 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Image image_menuitem_mode_jumps_reactive;
        [Widget] Gtk.Image image_menuitem_mode_runs_simple;
        [Widget] Gtk.Image image_menuitem_mode_runs_intervallic;
+       [Widget] Gtk.Image image_menuitem_mode_race_encoder;
        [Widget] Gtk.Image image_menuitem_mode_power_gravitatory;
        [Widget] Gtk.Image image_menuitem_mode_power_inertial;
        [Widget] Gtk.Image image_menuitem_mode_force_sensor;
        [Widget] Gtk.Image image_menuitem_mode_reaction_time;
+       [Widget] Gtk.Image image_menuitem_mode_other;
 
        //run
        [Widget] Gtk.Image image_run_execute_running;
@@ -276,6 +278,8 @@ public partial class ChronoJumpWindow
                image_menuitem_mode_force_sensor.Pixbuf = pixbuf;
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "reaction_time_icon.png");
                image_menuitem_mode_reaction_time.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "other_icon.png");
+               image_menuitem_mode_other.Pixbuf = pixbuf;
 
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_capture.png");
                image_tests_capture.Pixbuf = pixbuf;
@@ -458,6 +462,8 @@ public partial class ChronoJumpWindow
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_run_multiple.png");
                image_mode_runs_intervallic_small.Pixbuf = pixbuf;
                image_menuitem_mode_runs_intervallic.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "race_encoder_icon.png");
+               image_menuitem_mode_race_encoder.Pixbuf = pixbuf;
 
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "run.png");
                image_run_execute_running.Pixbuf = pixbuf;


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