[chronojump] Person select window 80% done



commit 175b0cac8d8209530b1b54afe1bc660dad5c4012
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jun 16 20:55:50 2015 +0200

    Person select window 80% done

 chronojump_config.txt  |    7 ++-
 glade/chronojump.glade |   51 ++++++++++++++++++--
 src/gui/chronojump.cs  |   19 ++++++++
 src/gui/person.cs      |  120 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 190 insertions(+), 7 deletions(-)
---
diff --git a/chronojump_config.txt b/chronojump_config.txt
index 1f9200a..9d64d6c 100644
--- a/chronojump_config.txt
+++ b/chronojump_config.txt
@@ -40,6 +40,11 @@ AutodetectPort=DISCARDFIRST
 #Only Encoder. When connected to a machine and there's always encoder mode
 OnlyEncoder=TRUE
 
+#EncoderNameAndCapture = TRUE means no atletes vbox, and no analysis (capture is the tab selected but is not 
shown).
+#To change person need to select person with a button at left of capture
+#This options is thought for gyms
+EncoderNameAndCapture=TRUE
+
 #EncoderConfiguration if exists, this will be used and cannot be changed
 
#name:d:D:anglePush:angleWeight:inertiaMachine:gearedDown:inertiaTotal:extraWeightN:extraWeightGrams:extraWeightLenght
 EncoderConfiguration=ROTARYAXISINERTIAL:4:-1:-1:-1:42:1:71:2:300:7
@@ -47,7 +52,7 @@ EncoderConfiguration=ROTARYAXISINERTIAL:4:-1:-1:-1:42:1:71:2:300:7
 #Session modes:
 #STANDARD: default mode where sessions are created by user
 #UNIQUE: there's only one session called "session". Menubar is hidden (use it only with OnlyEncoder = TRUE)
-SessionMode=UNIQUE
+SessionMode=STANDARD
 
 #To sync data
 RunScriptOnExit=
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 541a9b8..98992e8 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -15395,6 +15395,7 @@ on current Chronojump version.</property>
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">True</property>
                                                     <property name="receives_default">True</property>
+                                                    <signal name="clicked" 
handler="on_button_encoder_person_change_clicked" swapped="no"/>
                                                   </widget>
                                                   <packing>
                                                     <property name="expand">False</property>
@@ -36717,6 +36718,50 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
       </widget>
     </child>
   </widget>
+  <widget class="GtkWindow" id="person_select_window">
+    <property name="width_request">800</property>
+    <property name="height_request">600</property>
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="border_width">10</property>
+    <property name="resizable">False</property>
+    <property name="modal">True</property>
+    <property name="type_hint">dialog</property>
+    <signal name="delete_event" handler="on_delete_event" swapped="no"/>
+    <child>
+      <widget class="GtkScrolledWindow" id="scrolledwindow1">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="hscrollbar_policy">never</property>
+        <property name="vscrollbar_policy">automatic</property>
+        <child>
+          <widget class="GtkViewport" id="viewport1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <widget class="GtkTable" id="table1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="n_columns">4</property>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+              </widget>
+            </child>
+          </widget>
+        </child>
+      </widget>
+    </child>
+  </widget>
   <widget class="GtkWindow" id="person_show_all_events">
     <property name="width_request">520</property>
     <property name="height_request">350</property>
@@ -49206,10 +49251,4 @@ times</property>
       </widget>
     </child>
   </widget>
-  <widget class="GtkWindow" id="window1">
-    <property name="can_focus">False</property>
-    <child>
-      <placeholder/>
-    </child>
-  </widget>
 </glade-interface>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 919555f..3d78946 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2782,6 +2782,15 @@ public partial class ChronoJumpWindow
                }
        }
 
+       PersonSelectWindow personSelectWin;
+       private void on_button_encoder_person_change_clicked (object o, EventArgs args) {
+               ArrayList myPersons = SqlitePersonSession.SelectCurrentSessionPersons(
+                               currentSession.UniqueID, 
+                               false); //means: do not returnPersonAndPSlist
+
+               personSelectWin = PersonSelectWindow.Show(app1, myPersons);
+       }
+
 
 
        /* ---------------------------------------------------------
@@ -6310,6 +6319,8 @@ LogB.Debug("X");
                button_person_add_multiple.Sensitive = false;
                button_edit_current_person.Sensitive = false;
                button_delete_current_person.Sensitive = false;
+       
+               button_encoder_person_change.Sensitive = false;
                
                //notebooks
                notebook_execute.Sensitive = false;
@@ -6352,6 +6363,8 @@ LogB.Debug("X");
                
                encoderButtonsSensitive(encoderSensEnum.NOPERSON);
                encoderPersonChanged();
+               
+               button_encoder_person_change.Sensitive = false;
 
                notebook_execute.Sensitive = false;
                //hbox_chronopics.Sensitive = false;
@@ -6371,6 +6384,8 @@ LogB.Debug("X");
 
                encoderButtonsSensitive(encoderSensEnum.YESPERSON);
                encoderPersonChanged();
+               
+               button_encoder_person_change.Sensitive = true;
 
                notebook_execute.Sensitive = true;
                //hbox_chronopics.Sensitive = true;
@@ -6408,6 +6423,8 @@ LogB.Debug("X");
                frame_persons.Sensitive = false;
                
                button_execute_test.Sensitive = false;
+               
+               button_encoder_person_change.Sensitive = false;
 
                encoderButtonsSensitive(encoderSensEnum.PROCESSINGR);
                
@@ -6439,6 +6456,8 @@ LogB.Debug("X");
                frame_persons.Sensitive = true;
 
                button_execute_test.Sensitive = true;
+               
+               button_encoder_person_change.Sensitive = true;
        
                if(encoderCaptureCurves != null && encoderCaptureCurves.Count > 0)
                        encoderButtonsSensitive(encoderSensEnum.DONEYESSIGNAL);
diff --git a/src/gui/person.cs b/src/gui/person.cs
index c0469f9..3f36d4a 100644
--- a/src/gui/person.cs
+++ b/src/gui/person.cs
@@ -2429,4 +2429,124 @@ public class PersonShowAllEventsWindow {
        }
 }
 
+public class PersonSelectWindow 
+{
+       [Widget] Gtk.Window person_select_window;
+       [Widget] Gtk.Table table1;
+       
+       static PersonSelectWindow PersonSelectWindowBox;
+       Gtk.Window parent;
+       
+       PersonSelectWindow (Gtk.Window parent) {
+               Glade.XML gladeXML;
+               gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "chronojump.glade", 
"person_select_window", "chronojump");
+               gladeXML.Autoconnect(this);
+               
+               //put an icon to window
+               UtilGtk.IconWindow(person_select_window);
+       }
+       
+       static public PersonSelectWindow Show (Gtk.Window parent, ArrayList persons)
+       {
+               if (PersonSelectWindowBox == null) {
+                       PersonSelectWindowBox = new PersonSelectWindow (parent);
+               }
+               
+               PersonSelectWindowBox.parent = parent;
+               //PersonSelectWindowBox.persons = persons;
+               
+               PersonSelectWindowBox.createTable(persons);
+               
+               PersonSelectWindowBox.person_select_window.Show ();
+               
+               return PersonSelectWindowBox;
+       }
+
+       private void createTable(ArrayList persons) 
+       {
+               uint padding = 8;       
+               uint cols = 4; //each row has 4 columns
+               uint rows = Convert.ToUInt32(Math.Floor(persons.Count / (1.0 * cols) ) +1);
+               int count = 0;
+               
+               for (int row_i = 0; row_i < rows; row_i ++) {
+                       for (int col_i = 0; col_i < cols; col_i ++) {
+                               //Gtk.Label myLabel = new Gtk.Label( row_i.ToString() + "." + 
col_i.ToString() );
+                               if(count >= persons.Count)
+                                       return;
+                               
+                               Person p = (Person) persons[count ++];
+
+                               Gtk.VBox vbox = new Gtk.VBox();
+                       
+                               Gtk.Image image = new Gtk.Image();
+                               string photoFile = Util.GetPhotoFileName(true, p.UniqueID);
+                               if(photoFile != "" && File.Exists(photoFile)) {
+                                       try {
+                                               Pixbuf pixbuf = new Pixbuf (photoFile); //from a file
+                                               image.Pixbuf = pixbuf;
+                                               image.Visible = true;
+                                       }
+                                       catch {
+                                               LogB.Warning("catched while adding photo");
+                                       }
+                               }
+
+                               Gtk.Label label_id = new Gtk.Label(p.UniqueID.ToString());
+                               label_id.Visible = false; //hide this to the user
+
+                               Gtk.Label label_name = new Gtk.Label(p.Name);
+                               label_name.Visible = true;
+
+                               vbox.PackStart(image);
+                               vbox.PackStart(label_id);
+                               vbox.PackStart(label_name);
+
+                               vbox.Show();
+                               
+                               Button b = new Button(vbox);
+                               b.Clicked += new EventHandler(on_button_clicked);
+                               b.Show();
+                               
+                               table1.Attach (b, (uint) col_i, (uint) col_i +1, (uint) row_i, (uint) row_i 
+1, 
+                                               Gtk.AttachOptions.Fill | Gtk.AttachOptions.Expand, 
+                                               Gtk.AttachOptions.Fill | Gtk.AttachOptions.Expand, 
+                                               padding, padding);
+                       }
+               }
+       }
+       
+       private void on_button_clicked (object o, EventArgs args)
+       {
+               LogB.Information("Clicked");
+
+               //access the button
+               Button b = (Button) o;
+               
+               //access the vbox
+               Gtk.VBox box = (Gtk.VBox) b.Child;
+               
+               //access the memebers of vbox
+               Array box_elements = box.Children;
+       
+               //access uniqueID       
+               Gtk.Label l = (Gtk.Label) box_elements.GetValue(1); //the ID
+               LogB.Information("UniqueID: " + l.Text.ToString());
+               
+               //access name
+               l = (Gtk.Label) box_elements.GetValue(2); //the name
+               LogB.Information("Name: " + l.Text.ToString());
+
+               //TODO: now need to process the signal and close
+       }
+
+       //TODO: allow to close with ESC
+       
+       private void on_delete_event (object o, DeleteEventArgs args)
+       {
+               PersonSelectWindowBox.person_select_window.Hide();
+               PersonSelectWindowBox = null;
+       }
+}
+
 


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