[chronojump] Menuitem Mode from radio to imagemenuitem. jumps/runs done!



commit cd556991cc2a06ebda558073ccc491f21d195258
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Aug 8 17:31:02 2019 +0200

    Menuitem Mode from radio to imagemenuitem. jumps/runs done!

 glade/app1.glade           | 126 +++++++++++++++++++++++++++++++++++++++------
 src/gui/chronojump.cs      |  57 +++++++++++++++++++-
 src/gui/chronojumpIcons.cs |   9 ++++
 3 files changed, 175 insertions(+), 17 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 00cc2739..5276031b 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -256,8 +256,43 @@
                       </widget>
                     </child>
                     <child>
-                      <widget class="GtkRadioMenuItem" id="radio_menuitem_mode_jumps_simple">
+                      <widget class="GtkImageMenuItem" id="menuitem_mode_jumps_simple">
+                        <property name="label" translatable="yes">Simple</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <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_jumps_simple">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">1</property>
+                            <property name="xpad">1</property>
+                            <property name="stock">gtk-missing-image</property>
+                          </widget>
+                        </child>
+                      </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkImageMenuItem" id="menuitem_mode_jumps_reactive">
+                        <property name="label" translatable="yes">Multiple</property>
                         <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <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_jumps_reactive">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="stock">gtk-missing-image</property>
+                          </widget>
+                        </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>
@@ -267,7 +302,6 @@
                     </child>
                     <child>
                       <widget class="GtkRadioMenuItem" id="radio_menuitem_mode_jumps_reactive">
-                        <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="label" translatable="yes">Multiple</property>
                         <property name="use_underline">True</property>
@@ -292,8 +326,41 @@
                       </widget>
                     </child>
                     <child>
-                      <widget class="GtkRadioMenuItem" id="radio_menuitem_mode_runs_simple">
+                      <widget class="GtkImageMenuItem" id="menuitem_mode_runs_simple">
+                        <property name="label" translatable="yes">Simple</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <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_runs_simple">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="stock">gtk-missing-image</property>
+                          </widget>
+                        </child>
+                      </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkImageMenuItem" id="menuitem_mode_runs_intervallic">
+                        <property name="label" translatable="yes">Intervallic</property>
                         <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <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_runs_intervallic">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="stock">gtk-missing-image</property>
+                          </widget>
+                        </child>
+                      </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkRadioMenuItem" id="radio_menuitem_mode_runs_simple">
                         <property name="can_focus">False</property>
                         <property name="label" translatable="yes">Simple</property>
                         <property name="use_underline">True</property>
@@ -304,7 +371,6 @@
                     </child>
                     <child>
                       <widget class="GtkRadioMenuItem" id="radio_menuitem_mode_runs_intervallic">
-                        <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="label" translatable="yes">Intervallic</property>
                         <property name="use_underline">True</property>
@@ -315,6 +381,7 @@
                     </child>
                     <child>
                       <widget class="GtkRadioMenuItem" id="radio_menuitem_mode_runs_encoder">
+                        <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="label">Races with encoder</property>
                         <property name="use_underline">True</property>
@@ -2114,6 +2181,15 @@
                                                             <placeholder/>
                                                             </child>
                                                             <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <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>
@@ -21392,6 +21468,15 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -23352,18 +23437,6 @@ 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>
@@ -23400,6 +23473,18 @@ 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>
@@ -30214,6 +30299,15 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <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 bafed3b5..3d7af84b 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -67,6 +67,10 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.RadioMenuItem radio_menuitem_mode_force_sensor;
        [Widget] Gtk.RadioMenuItem radio_menuitem_mode_rt;
        [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.Notebook notebook_start;           //start window or program
        [Widget] Gtk.Notebook notebook_start_selector;  //use to display the start images to select different 
modes
@@ -820,15 +824,27 @@ public partial class ChronoJumpWindow
 
        private void formatModeMenu()
        {
+               /*
                ((Label) radio_menuitem_mode_jumps_simple.Child).Text =
                        "   " + ((Label) radio_menuitem_mode_jumps_simple.Child).Text;
                ((Label) radio_menuitem_mode_jumps_reactive.Child).Text =
                        "   " + ((Label) radio_menuitem_mode_jumps_reactive.Child).Text;
+               */
+               ((Label) menuitem_mode_jumps_simple.Child).Text =
+                       "   " + ((Label) menuitem_mode_jumps_simple.Child).Text;
+               ((Label) menuitem_mode_jumps_reactive.Child).Text =
+                       "   " + ((Label) menuitem_mode_jumps_reactive.Child).Text;
 
+               /*
                ((Label) radio_menuitem_mode_runs_simple.Child).Text =
                        "   " + ((Label) radio_menuitem_mode_runs_simple.Child).Text;
                ((Label) radio_menuitem_mode_runs_intervallic.Child).Text =
                        "   " + ((Label) radio_menuitem_mode_runs_intervallic.Child).Text;
+                       */
+               ((Label) menuitem_mode_runs_simple.Child).Text =
+                       "   " + ((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;
 
@@ -836,6 +852,7 @@ public partial class ChronoJumpWindow
                        "   " + ((Label) radio_menuitem_mode_power_gravitatory.Child).Text;
                ((Label) radio_menuitem_mode_power_inertial.Child).Text =
                        "   " + ((Label) radio_menuitem_mode_power_inertial.Child).Text;
+
        }
 
        //different than on_preferences_activate (opening preferences window)
@@ -3682,10 +3699,40 @@ public partial class ChronoJumpWindow
                //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;
+               if (o == null)
+                       return;
+
+               if(o == menuitem_mode_jumps_simple)
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.JUMPSSIMPLE);
+               else if(o == menuitem_mode_jumps_reactive)
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.JUMPSREACTIVE);
+               else if(o == menuitem_mode_runs_simple)
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.RUNSSIMPLE);
+               else if(o == menuitem_mode_runs_intervallic)
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.RUNSINTERVALLIC);
+
+               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");
+       }
+
+       private void changeMenuitemModePixbuf(Gtk.Image image, bool active, string pathImageInactive, string 
pathImageActive)
+       {
+               Pixbuf pixbuf = new Pixbuf (null, Util.GetImagePath(false) + pathImageInactive);
+               if(active)
+                       pixbuf = new Pixbuf (null, Util.GetImagePath(false) + pathImageActive);
+
+               image.Pixbuf = pixbuf;
+       }
+
        private void on_button_selector_start_jumps_clicked(object o, EventArgs args) 
        {
                notebook_start_selector2.CurrentPage = 0; //jumps
@@ -3699,6 +3746,8 @@ public partial class ChronoJumpWindow
                }
                else
                        radio_menuitem_mode_jumps_simple.Active = true;
+
+               changeMenuitemModePixbuf(image_menuitem_mode_jumps_simple, true, "image_jump_simple.png", 
"image_jump_simple_yellow.png");
        }
        private void on_button_selector_start_jumps_reactive_clicked(object o, EventArgs args) 
        {
@@ -3706,6 +3755,8 @@ public partial class ChronoJumpWindow
                        select_menuitem_mode_toggled(Constants.Menuitem_modes.JUMPSREACTIVE);
                else
                        radio_menuitem_mode_jumps_reactive.Active = true;
+
+               changeMenuitemModePixbuf(image_menuitem_mode_jumps_reactive, true, "image_jump_reactive.png", 
"image_jump_reactive_yellow.png");
        }
        
        private void on_button_selector_start_runs_clicked(object o, EventArgs args) 
@@ -3719,6 +3770,8 @@ public partial class ChronoJumpWindow
                        select_menuitem_mode_toggled(Constants.Menuitem_modes.RUNSSIMPLE);
                else
                        radio_menuitem_mode_runs_simple.Active = true;
+
+               changeMenuitemModePixbuf(image_menuitem_mode_runs_simple, true, "image_run_simple.png", 
"image_run_simple_yellow.png");
        }
        private void on_button_selector_start_runs_intervallic_clicked(object o, EventArgs args) 
        {
@@ -3726,6 +3779,8 @@ public partial class ChronoJumpWindow
                        select_menuitem_mode_toggled(Constants.Menuitem_modes.RUNSINTERVALLIC);
                else
                        radio_menuitem_mode_runs_intervallic.Active = true;
+
+               changeMenuitemModePixbuf(image_menuitem_mode_runs_intervallic, true, 
"image_run_multiple.png", "image_run_multiple_yellow.png");
        }
        private void on_button_selector_start_runs_encoder_clicked(object o, EventArgs args)
        {
diff --git a/src/gui/chronojumpIcons.cs b/src/gui/chronojumpIcons.cs
index d2f718d6..9fbacd00 100644
--- a/src/gui/chronojumpIcons.cs
+++ b/src/gui/chronojumpIcons.cs
@@ -86,6 +86,11 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Image image_selector_start_other;
        [Widget] Gtk.Image image_selector_start_cancel;
 
+       [Widget] Gtk.Image image_menuitem_mode_jumps_simple;
+       [Widget] Gtk.Image image_menuitem_mode_jumps_reactive;
+       [Widget] Gtk.Image image_menuitem_mode_runs_simple;
+       [Widget] Gtk.Image image_menuitem_mode_runs_intervallic;
+
        //run
        [Widget] Gtk.Image image_run_execute_running;
        [Widget] Gtk.Image image_run_execute_photocell;
@@ -432,12 +437,16 @@ public partial class ChronoJumpWindow
 
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_jump_simple.png");
                image_mode_jumps_small.Pixbuf = pixbuf;
+               image_menuitem_mode_jumps_simple.Pixbuf = pixbuf;
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_jump_reactive.png");
                image_mode_jumps_reactive_small.Pixbuf = pixbuf;
+               image_menuitem_mode_jumps_reactive.Pixbuf = pixbuf;
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_run_simple.png");
                image_mode_runs_small.Pixbuf = pixbuf;
+               image_menuitem_mode_runs_simple.Pixbuf = pixbuf;
                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) + "run.png");
                image_run_execute_running.Pixbuf = pixbuf;


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