[chronojump] Person select window done!



commit 562a82fe51d2b01f2e5fbb7e6e66c0a94f85a5b7
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Jun 17 11:30:14 2015 +0200

    Person select window done!

 chronojump_config.txt   |   18 +++-
 glade/chronojump.glade  |  143 +++++++++++++++++++++++++++++----
 src/Makefile.am         |    1 +
 src/config.cs           |   15 +++-
 src/gui/chronojump.cs   |   14 +++-
 src/gui/networks.cs     |    7 +-
 src/gui/person.cs       |  122 ----------------------------
 src/gui/personSelect.cs |  200 +++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 366 insertions(+), 154 deletions(-)
---
diff --git a/chronojump_config.txt b/chronojump_config.txt
index 9d64d6c..91a7c32 100644
--- a/chronojump_config.txt
+++ b/chronojump_config.txt
@@ -28,31 +28,39 @@
 Maximized=TRUE
 
 #Bigger / different buttons at some parts
+#default: CustomButtons=FALSE
 CustomButtons=TRUE
 
 #To disable video on Raspberry change to FALSE
+#default: UseVideo=TRUE
 UseVideo=TRUE
 
 #options are ACTIVE, DISCARDFIRST and INACTIVE
 #PIPO windows tablet has COM1 and usually COM5. At COM1 it doesn't work, use DISCARDFIRST to use the other
+#default: AutodetectPort=ACTIVE
 AutodetectPort=DISCARDFIRST
 
 #Only Encoder. When connected to a machine and there's always encoder mode
+#default: OnlyEncoder=FALSE
 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
+#Hide left person box. Select person by a label and button on the top
+#default: PersonWinHide=FALSE
+PersonWinHide=TRUE
+
+#default: EncoderAnalyzeHide=FALSE
+EncoderAnalyzeHide=FALSE
 
 #EncoderConfiguration if exists, this will be used and cannot be changed
 
#name:d:D:anglePush:angleWeight:inertiaMachine:gearedDown:inertiaTotal:extraWeightN:extraWeightGrams:extraWeightLenght
+#default: EncoderConfiguration=
 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=STANDARD
+#default: SessionMode=STANDARD
+SessionMode=UNIQUE
 
 #To sync data
 RunScriptOnExit=
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 98992e8..109e396 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -7991,6 +7991,9 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                           </widget>
                                                           <packing>
                                                             <property name="expand">True</property>
@@ -9003,6 +9006,9 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             <child>
@@ -10267,6 +10273,9 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">2</property>
@@ -11172,6 +11181,9 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">4</property>
@@ -22459,6 +22471,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -23269,6 +23284,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -24571,6 +24589,9 @@ by you</property>
               <placeholder/>
             </child>
             <child>
+              <placeholder/>
+            </child>
+            <child>
               <widget class="GtkButton" id="button_video_url">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -24930,6 +24951,9 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -35557,6 +35581,24 @@ options</property>
                             <child>
                               <placeholder/>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
                           </widget>
                         </child>
                       </widget>
@@ -36729,35 +36771,85 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
     <property name="type_hint">dialog</property>
     <signal name="delete_event" handler="on_delete_event" swapped="no"/>
     <child>
-      <widget class="GtkScrolledWindow" id="scrolledwindow1">
+      <widget class="GtkVBox" id="vbox1">
         <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="hscrollbar_policy">never</property>
-        <property name="vscrollbar_policy">automatic</property>
+        <property name="can_focus">False</property>
+        <property name="spacing">12</property>
         <child>
-          <widget class="GtkViewport" id="viewport1">
+          <widget class="GtkScrolledWindow" id="scrolledwindow1">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="can_focus">True</property>
+            <property name="hscrollbar_policy">never</property>
+            <property name="vscrollbar_policy">automatic</property>
             <child>
-              <widget class="GtkTable" id="table1">
+              <widget class="GtkViewport" id="viewport1">
                 <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/>
+                  <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>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </widget>
                 </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="GtkHBox" id="hbox1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <widget class="GtkButton" id="button_close">
+                <property name="label" translatable="yes">Close</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+               <signal name="clicked" handler="on_button_close_clicked" swapped="no"/>
+               <accelerator key="Escape" signal="clicked"/>
+              </widget>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
         </child>
       </widget>
     </child>
@@ -37791,6 +37883,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                 <child>
                                   <placeholder/>
                                 </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
                               </widget>
                             </child>
                           </widget>
@@ -38639,6 +38734,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -41477,6 +41575,9 @@ show elevation as:</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                       <packing>
                         <property name="left_attach">2</property>
@@ -41951,6 +42052,9 @@ show elevation as:</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -42440,6 +42544,9 @@ show elevation as:</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/src/Makefile.am b/src/Makefile.am
index c7456b2..bc64d48 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,6 +24,7 @@ SOURCES = \
        gui/pulse.cs\
        gui/multiChronopic.cs\
        gui/person.cs\
+       gui/personSelect.cs\
        gui/preferences.cs\
        gui/session.cs\
        gui/stats.cs\
diff --git a/src/config.cs b/src/config.cs
index e5003e8..f0872da 100644
--- a/src/config.cs
+++ b/src/config.cs
@@ -32,7 +32,8 @@ public class Config
        public bool UseVideo;
        public AutodetectPortEnum AutodetectPort;
        public bool OnlyEncoder;
-       public bool EncoderNameAndCapture;
+       public bool PersonWinHide;
+       public bool EncoderAnalyzeHide;
        public EncoderConfiguration Econf;
        public SessionModeEnum SessionMode;
        public string RunScriptOnExit;
@@ -44,7 +45,8 @@ public class Config
                UseVideo = true;
                AutodetectPort = AutodetectPortEnum.ACTIVE;
                OnlyEncoder = false;
-               EncoderNameAndCapture = false;
+               PersonWinHide = false;
+               EncoderAnalyzeHide = false;
                Econf = null; 
                SessionMode = SessionModeEnum.STANDARD;
                RunScriptOnExit = "";
@@ -80,8 +82,10 @@ public class Config
                                                        Enum.Parse(typeof(AutodetectPortEnum), parts[1]);
                                        else if(parts[0] == "OnlyEncoder" && Util.StringToBool(parts[1]))
                                                OnlyEncoder = true;
-                                       else if(parts[0] == "EncoderNameAndCapture" && 
Util.StringToBool(parts[1]))
-                                               EncoderNameAndCapture = true;
+                                       else if(parts[0] == "PersonWinHide" && Util.StringToBool(parts[1]))
+                                               PersonWinHide = true;
+                                       else if(parts[0] == "EncoderAnalyzeHide" && 
Util.StringToBool(parts[1]))
+                                               EncoderAnalyzeHide = true;
                                        else if(parts[0] == "EncoderConfiguration")
                                        {
                                                string [] ecFull = parts[1].Split(new char[] {':'});
@@ -117,7 +121,8 @@ public class Config
                                "UseVideo = " + UseVideo.ToString() + "\n" +
                                "AutodetectPort = " + AutodetectPort.ToString() + "\n" +
                                "OnlyEncoder = " + OnlyEncoder.ToString() + "\n" +
-                               "EncoderNameAndCapture = " + EncoderNameAndCapture.ToString() + "\n" +
+                               "PersonWinHide = " + PersonWinHide.ToString() + "\n" +
+                               "EncoderAnalyzeHide = " + EncoderAnalyzeHide.ToString() + "\n" +
                                "Econf = " + econfStr + "\n" +
                                "SessionMode = " + SessionMode.ToString() + "\n" +
                                "RunScriptOnExit = " + RunScriptOnExit.ToString() + "\n"
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 3d78946..8ed04d8 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -407,6 +407,7 @@ public partial class ChronoJumpWindow
        PersonsRecuperateFromOtherSessionWindow personsRecuperateFromOtherSessionWin; 
        PersonAddModifyWindow personAddModifyWin; 
        PersonAddMultipleWindow personAddMultipleWin; 
+       PersonSelectWindow personSelectWin;
        JumpsMoreWindow jumpsMoreWin;
        JumpsRjMoreWindow jumpsRjMoreWin;
        EditJumpWindow editJumpWin;
@@ -2782,13 +2783,22 @@ public partial class ChronoJumpWindow
                }
        }
 
-       PersonSelectWindow personSelectWin;
-       private void on_button_encoder_person_change_clicked (object o, EventArgs args) {
+       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);
+               personSelectWin.FakeButtonDone.Clicked += new 
EventHandler(on_button_encoder_person_change_done);
+       }
+       private void on_button_encoder_person_change_done(object o, EventArgs args) 
+       {
+               currentPerson = personSelectWin.SelectedPerson; 
+               currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, 
currentSession.UniqueID);
+               label_person_change();
+
+               encoderPersonChanged();
        }
 
 
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 33fa7d9..3baca63 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -76,12 +76,15 @@ public partial class ChronoJumpWindow
                if(config.OnlyEncoder)
                        select_menuitem_mode_toggled(menuitem_modes.POWER);
                
-               if(config.EncoderNameAndCapture) {
+               if(config.PersonWinHide) {
                        vbox_persons.Visible = false;
-                       hbox_encoder_sup_capture_analyze_two_buttons.Visible = false;
                        hbox_encoder_person.Visible = true;
                }
                
+               if(config.EncoderAnalyzeHide) {
+                       hbox_encoder_sup_capture_analyze_two_buttons.Visible = false;
+               }
+               
                if(config.Econf != null) {
                        encoderConfigurationCurrent = config.Econf;
                        encoderConfigurationGUIUpdate();
diff --git a/src/gui/person.cs b/src/gui/person.cs
index 3f36d4a..5b44c7f 100644
--- a/src/gui/person.cs
+++ b/src/gui/person.cs
@@ -2428,125 +2428,3 @@ public class PersonShowAllEventsWindow {
                PersonShowAllEventsWindowBox = null;
        }
 }
-
-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;
-       }
-}
-
-
diff --git a/src/gui/personSelect.cs b/src/gui/personSelect.cs
new file mode 100644
index 0000000..9bfd87f
--- /dev/null
+++ b/src/gui/personSelect.cs
@@ -0,0 +1,200 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2004-2015   Xavier de Blas <xaviblas gmail com> 
+ */
+
+using System;
+using Gtk;
+using Gdk;
+using Glade;
+using System.Collections; //ArrayList
+using System.IO; 
+
+public class PersonSelectWindow 
+{
+       [Widget] Gtk.Window person_select_window;
+       [Widget] Gtk.Table table1;
+       
+       static PersonSelectWindow PersonSelectWindowBox;
+       Gtk.Window parent;
+       
+       private ArrayList persons;
+       public Person SelectedPerson;
+       public Gtk.Button FakeButtonDone;
+
+       
+       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);
+               
+               FakeButtonDone = new Gtk.Button();
+       }
+       
+       static public PersonSelectWindow Show (Gtk.Window parent, ArrayList persons)
+       {
+               if (PersonSelectWindowBox == null) {
+                       PersonSelectWindowBox = new PersonSelectWindow (parent);
+               }
+               
+               PersonSelectWindowBox.parent = parent;
+               PersonSelectWindowBox.persons = persons;
+               
+               PersonSelectWindowBox.createTable();
+               
+               PersonSelectWindowBox.person_select_window.Show ();
+               
+               return PersonSelectWindowBox;
+       }
+
+       private void createTable() 
+       {
+               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 ++) 
+                       {
+                               if(count >= persons.Count)
+                                       return;
+                               
+                               Person p = (Person) persons[count ++];
+
+                               PersonPhotoButton ppb = new PersonPhotoButton(p);
+                               Gtk.Button b = ppb.CreateButton();
+                               
+                               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;
+       
+               int personID = PersonPhotoButton.GetPersonID(b);
+
+               LogB.Information("UniqueID: " + personID.ToString());
+
+               //TODO: now need to process the signal and close
+               foreach(Person p in persons)
+                       if(p.UniqueID == personID) {
+                               SelectedPerson = p;
+                               FakeButtonDone.Click();
+                               close_window();
+                       }
+       }
+
+       private void close_window() {   
+               PersonSelectWindowBox.person_select_window.Hide();
+               PersonSelectWindowBox = null;
+       }
+       
+       //ESC is enabled
+       protected virtual void on_button_close_clicked (object o, EventArgs args) {
+               close_window();
+       }
+       
+       //TODO: allow to close with ESC
+       private void on_delete_event (object o, DeleteEventArgs args)
+       {
+               PersonSelectWindowBox.person_select_window.Hide();
+               PersonSelectWindowBox = null;
+       }
+}
+
+//used by PersonSelectWindow
+public class PersonPhotoButton
+{
+       private Person p;
+
+       public PersonPhotoButton (Person p) {
+               this.p = p;
+       }
+
+       public Gtk.Button CreateButton () {
+               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);
+
+               return b;
+       }
+
+       public static int GetPersonID (Gtk.Button b) 
+       {
+               //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
+               int personID = Convert.ToInt32(l.Text);
+
+               //LogB.Information("UniqueID: " + l.Text.ToString());
+               
+               //access name
+               /*
+               l = (Gtk.Label) box_elements.GetValue(2); //the name
+               LogB.Information("Name: " + l.Text.ToString());
+               */
+
+               return personID;
+       }
+}
+


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