[chronojump] Compujump tasks can be marked as done. Other dialog improvements.



commit 488d90c5f1627a4be92039cdc7432aaaf7459086
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Jun 29 06:01:37 2017 +0200

    Compujump tasks can be marked as done. Other dialog improvements.

 glade/dialog_person_popup.glade |  112 +++++++++++++++++++++++---------------
 src/gui/dialogPersonPopup.cs    |  103 +++++++++++++++++++++++++-----------
 src/gui/networks.cs             |    4 +-
 3 files changed, 143 insertions(+), 76 deletions(-)
---
diff --git a/glade/dialog_person_popup.glade b/glade/dialog_person_popup.glade
index f78a7e5..e6f1132 100644
--- a/glade/dialog_person_popup.glade
+++ b/glade/dialog_person_popup.glade
@@ -7,7 +7,7 @@
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
-    <property name="title" translatable="yes">Chronojump</property>
+    <property name="title" translatable="yes">Player</property>
     <property name="modal">True</property>
     <property name="type_hint">dialog</property>
     <signal name="delete_event" handler="on_delete_event" swapped="no"/>
@@ -25,70 +25,97 @@
               <widget class="GtkHBox" id="hbox1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="spacing">20</property>
                 <child>
-                  <widget class="GtkImage" id="image">
+                  <widget class="GtkHBox" id="hbox2">
                     <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="GtkVBox" id="vbox3">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="spacing">20</property>
+                    <property name="spacing">30</property>
                     <child>
-                      <widget class="GtkLabel" id="label_name">
+                      <widget class="GtkImage" id="image_person">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">label</property>
+                        <property name="stock">gtk-missing-image</property>
                       </widget>
                       <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
                         <property name="position">0</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkLabel" id="label_rfid">
+                      <widget class="GtkVBox" id="vbox4">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">label</property>
+                        <property name="spacing">20</property>
+                        <child>
+                          <widget class="GtkLabel" id="label_name">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">label</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="label_rfid">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">label</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">False</property>
-                        <property name="fill">False</property>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
                         <property name="position">1</property>
                       </packing>
                     </child>
                   </widget>
                   <packing>
                     <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkVButtonBox" id="vbuttonbox1">
+                  <widget class="GtkVBox" id="vbox5">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="layout_style">start</property>
                     <child>
-                      <widget class="GtkButton" id="button24">
-                        <property name="label">gtk-close</property>
+                      <widget class="GtkHButtonBox" id="hbuttonbox1">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="can_default">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="use_stock">True</property>
-                        <signal name="clicked" handler="on_button_close_clicked" swapped="no"/>
-                        <accelerator key="Escape" signal="clicked"/>
+                        <property name="can_focus">False</property>
+                        <property name="layout_style">end</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="GtkImage" id="image_close">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="stock">gtk-missing-image</property>
+                              </widget>
+                            </child>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
                       </widget>
                       <packing>
                         <property name="expand">False</property>
@@ -96,20 +123,17 @@
                         <property name="position">0</property>
                       </packing>
                     </child>
-                    <child>
-                      <placeholder/>
-                    </child>
                   </widget>
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
-                    <property name="position">2</property>
+                    <property name="position">1</property>
                   </packing>
                 </child>
               </widget>
               <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">0</property>
               </packing>
             </child>
@@ -136,7 +160,7 @@
                           <widget class="GtkVBox" id="vbox_tasks_parametrized">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="spacing">10</property>
+                            <property name="spacing">12</property>
                             <child>
                               <placeholder/>
                             </child>
@@ -192,7 +216,7 @@
                           <widget class="GtkVBox" id="vbox_tasks_free">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="spacing">10</property>
+                            <property name="spacing">12</property>
                             <child>
                               <placeholder/>
                             </child>
diff --git a/src/gui/dialogPersonPopup.cs b/src/gui/dialogPersonPopup.cs
index 9ae1ea4..c3155f2 100644
--- a/src/gui/dialogPersonPopup.cs
+++ b/src/gui/dialogPersonPopup.cs
@@ -29,7 +29,8 @@ public class DialogPersonPopup
 {
        [Widget] Gtk.Dialog dialog_person_popup;
        [Widget] Gtk.Label label_name;
-       [Widget] Gtk.Image image;
+       [Widget] Gtk.Image image_person;
+       [Widget] Gtk.Image image_close;
        [Widget] Gtk.Label label_rfid;
        [Widget] Gtk.Frame frame_tasks_parametrized;
        [Widget] Gtk.Frame frame_tasks_free;
@@ -37,7 +38,9 @@ public class DialogPersonPopup
        [Widget] Gtk.VBox vbox_tasks_free;
 
        private List<Gtk.CheckButton> list_checks;
-       private List<Gtk.Button> list_buttons;
+       private List<Gtk.Button> list_buttons_start;
+       private List<Gtk.Label> list_labels;
+       private List<Gtk.Button> list_buttons_done;
        private List<int> list_tasks_id;
        private List<int> list_buttons_id;
 
@@ -59,23 +62,28 @@ public class DialogPersonPopup
                label_rfid.Text = rfid;
                list_tasks = tasks;
 
+               Pixbuf pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_close.png");
+               image_close.Pixbuf = pixbuf;
+
                string photoFile = Util.GetPhotoFileName(false, personID);
                if(File.Exists(photoFile)) {
                        try {
-                               Pixbuf pixbuf = new Pixbuf (photoFile); //from a file
-                               image.Pixbuf = pixbuf;
+                               pixbuf = new Pixbuf (photoFile); //from a file
+                               image_person.Pixbuf = pixbuf;
                        } catch {
                                //on windows there are problem using the fileNames that are not on temp
                                string tempFileName = Path.Combine(Path.GetTempPath(), 
Constants.PhotoSmallTemp +
                                                Util.GetMultimediaExtension(Constants.MultimediaItems.PHOTO));
                                File.Copy(photoFile, tempFileName, true);
-                               Pixbuf pixbuf = new Pixbuf (tempFileName);
-                               image.Pixbuf = pixbuf;
+                               pixbuf = new Pixbuf (tempFileName);
+                               image_person.Pixbuf = pixbuf;
                        }
                }
 
                list_checks = new List<Gtk.CheckButton>();
-               list_buttons = new List<Gtk.Button>();
+               list_buttons_start = new List<Gtk.Button>();
+               list_labels = new List<Gtk.Label>();
+               list_buttons_done = new List<Gtk.Button>();
                list_tasks_id = new List<int>();
                list_buttons_id = new List<int>();
                taskActive = new Task();
@@ -83,34 +91,46 @@ public class DialogPersonPopup
 
                bool task_parametrized_exist = false;
                bool task_free_exist = false;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_capture.png");
                foreach(Task t in tasks)
                {
                        Gtk.Label l = new Gtk.Label(t.ToString());
                        HBox hbox = new Gtk.HBox(false, 12);
-                       Button button_do;
+                       Button button_start;
 
                        if(t.Type == 'P')
                        {
-                               button_do = new Gtk.Button("Inicia");
-                               button_do.Clicked += new EventHandler(button_clicked);
-                               hbox.PackStart(button_do, false, false, 0);
-                               hbox.PackStart(l, false, false, 0);
-                               vbox_tasks_parametrized.PackStart(hbox, false, false, 0);
+                               Gtk.Image image = new Gtk.Image();
+                               image.Pixbuf = pixbuf;
+
+                               button_start = new Gtk.Button(image);
                                task_parametrized_exist = true;
                        } else // 'F'
                        {
-                               button_do = new Gtk.Button("Fet!");
-                               button_do.Clicked += new EventHandler(button_clicked);
-                               hbox.PackStart(l, false, false, 0);
-                               hbox.PackStart(button_do, false, false, 0);
-                               vbox_tasks_free.PackStart(hbox, false, false, 0);
+                               button_start = new Gtk.Button("Prepara");
                                task_free_exist = true;
                        }
+                       button_start.Clicked += new EventHandler(button_start_clicked);
+
+                       Gtk.Button button_done = new Gtk.Button("Fet!");
+                       button_done.Clicked += new EventHandler(button_done_clicked);
+
+                       hbox.PackStart(button_start, false, false, 0);
+                       hbox.PackStart(l, false, false, 0);
+                       hbox.PackEnd(button_done, false, false, 0);
 
-                       list_buttons.Add(button_do);
+                       if(t.Type == 'P')
+                               vbox_tasks_parametrized.PackStart(hbox, false, false, 0);
+                       else // 'F'
+                               vbox_tasks_free.PackStart(hbox, false, false, 0);
+
+                       list_buttons_start.Add(button_start);
+                       list_labels.Add(l);
+                       list_buttons_done.Add(button_done);
                        list_tasks_id.Add(t.Id);
                        list_buttons_id.Add(t.Id);
                }
+
                if(task_parametrized_exist)
                        vbox_tasks_parametrized.ShowAll();
                else
@@ -122,27 +142,48 @@ public class DialogPersonPopup
                        frame_tasks_free.Visible = false;
        }
 
-       private void button_clicked(object o, EventArgs args)
+       private void button_start_clicked(object o, EventArgs args)
+       {
+               Button buttonClicked = o as Button;
+               if (o == null)
+                       return;
+
+               int count = 0;
+               foreach(Gtk.Button button in list_buttons_start)
+               {
+                       if(button == buttonClicked)
+                       {
+                               LogB.Information("Clicked button start: " + count.ToString());
+
+                               taskActive = list_tasks[count];
+                               Fake_button_start_task.Click();
+
+                               return;
+                       }
+                       count ++;
+               }
+       }
+
+       private void button_done_clicked(object o, EventArgs args)
        {
                Button buttonClicked = o as Button;
                if (o == null)
                        return;
 
                int count = 0;
-               foreach(Gtk.Button button in list_buttons)
+               foreach(Gtk.Button button in list_buttons_done)
                {
                        if(button == buttonClicked)
                        {
-                               LogB.Information("Clicked button" + count.ToString());
-                               if(list_tasks[count].Type == 'P')
-                               {
-                                       taskActive = list_tasks[count];
-                                       Fake_button_start_task.Click();
-                               } else { // 'F'
-                                       Json json = new Json();
-                                       json.UpdateTask(list_tasks_id[count], 1);
-                                       button.Sensitive = false;
-                               }
+                               LogB.Information("Clicked button done: " + count.ToString());
+
+                               Json json = new Json();
+                               json.UpdateTask(list_tasks_id[count], 1);
+
+                               button.Sensitive = false;
+                               list_buttons_start[count].Sensitive = false;
+                               list_labels[count].Sensitive = false;
+
                                return;
                        }
                        count ++;
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index b78ccc3..067acf0 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -573,7 +573,9 @@ public partial class ChronoJumpWindow
                        entry_raspberry_extra_weight.Text = Convert.ToInt32(task.Load).ToString();
                }
 
-               on_button_encoder_capture_clicked (new object(), new EventArgs ());
+               //start test if task is parametrized
+               if(task.Type == 'P')
+                       on_button_encoder_capture_clicked (new object(), new EventArgs ());
        }
 
 


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