[chronojump] A person can be added from person select window



commit fa336a4aff5ac37ec4a066f993297bde0d312633
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jun 19 09:41:18 2015 +0200

    A person can be added from person select window

 glade/chronojump.glade  |   63 ++++++++++++++++++++++++++++++++++++++++++++---
 src/gui/chronojump.cs   |   23 +++++++++++++++-
 src/gui/personSelect.cs |   30 +++++++++++++++++++++-
 3 files changed, 108 insertions(+), 8 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 6b33283..ae62a7e 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -1058,7 +1058,7 @@
                                                         <property name="receives_default">True</property>
                                                         <property name="has_tooltip">True</property>
                                                         <property name="tooltip" translatable="yes">New 
person</property>
-                                                        <signal name="clicked" 
handler="on_person_add_single_activate" swapped="no"/>
+                                                        <signal name="clicked" 
handler="on_person_add_single_from_main_gui" swapped="no"/>
                                                         <child>
                                                           <widget class="GtkImage" id="image_persons_new_1">
                                                             <property name="visible">True</property>
@@ -36930,7 +36930,6 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
     <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>
@@ -37013,9 +37012,54 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
           </packing>
         </child>
         <child>
-          <widget class="GtkHBox" id="hbox1">
+          <widget class="GtkHButtonBox" id="hbuttonbox1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="layout_style">spread</property>
+            <child>
+              <widget class="GtkButton" id="button_add">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <signal name="clicked" handler="on_button_add_clicked" swapped="no"/>
+                <child>
+                  <widget class="GtkHBox" id="hbox2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="spacing">12</property>
+                    <child>
+                      <widget class="GtkImage" id="image1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="stock">gtk-add</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="label1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Add person</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
             <child>
               <widget class="GtkButton" id="button_close">
                 <property name="label" translatable="yes">Close</property>
@@ -37028,7 +37072,7 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
               <packing>
                 <property name="expand">True</property>
                 <property name="fill">False</property>
-                <property name="position">0</property>
+                <property name="position">1</property>
               </packing>
             </child>
           </widget>
@@ -37038,6 +37082,17 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
             <property name="position">1</property>
           </packing>
         </child>
+        <child>
+          <widget class="GtkHBox" id="hbox1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
       </widget>
     </child>
   </widget>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 8ed04d8..659f5d0 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2624,8 +2624,14 @@ public partial class ChronoJumpWindow
                        sensitiveGuiYesPerson();
                }
        }
-               
-       private void on_person_add_single_activate (object o, EventArgs args) {
+       
+       bool person_add_single_called_from_person_select_window;
+       private void on_person_add_single_from_main_gui (object o, EventArgs args) {
+               person_add_single_called_from_person_select_window = false;
+               person_add_single();
+       }
+
+       private void person_add_single () {
                personAddModifyWin = PersonAddModifyWindow.Show(app1, 
                                currentSession, new Person(-1), 
                                preferences.digitsNumber, checkbutton_video, useVideo
@@ -2671,6 +2677,13 @@ public partial class ChronoJumpWindow
                                sensitiveGuiYesPerson();
                                //appbar2.Push( 1, Catalog.GetString("Successfully added") + " " + 
currentPerson.Name );
                        }
+                       
+                       if(person_add_single_called_from_person_select_window) {
+                               ArrayList myPersons = SqlitePersonSession.SelectCurrentSessionPersons(
+                                               currentSession.UniqueID, 
+                                               false); //means: do not returnPersonAndPSlist
+                               personSelectWin.Update(myPersons);
+                       }
                }
        }
 
@@ -2790,8 +2803,14 @@ public partial class ChronoJumpWindow
                                false); //means: do not returnPersonAndPSlist
 
                personSelectWin = PersonSelectWindow.Show(app1, myPersons);
+               personSelectWin.FakeButtonAddPerson.Clicked += new 
EventHandler(on_button_encoder_person_add_person);
                personSelectWin.FakeButtonDone.Clicked += new 
EventHandler(on_button_encoder_person_change_done);
        }
+       private void on_button_encoder_person_add_person(object o, EventArgs args)
+       {
+               person_add_single_called_from_person_select_window = true;
+               person_add_single();
+       }
        private void on_button_encoder_person_change_done(object o, EventArgs args) 
        {
                currentPerson = personSelectWin.SelectedPerson; 
diff --git a/src/gui/personSelect.cs b/src/gui/personSelect.cs
index 9bfd87f..69cdbfa 100644
--- a/src/gui/personSelect.cs
+++ b/src/gui/personSelect.cs
@@ -35,6 +35,7 @@ public class PersonSelectWindow
        
        private ArrayList persons;
        public Person SelectedPerson;
+       public Gtk.Button FakeButtonAddPerson;
        public Gtk.Button FakeButtonDone;
 
        
@@ -46,6 +47,7 @@ public class PersonSelectWindow
                //put an icon to window
                UtilGtk.IconWindow(person_select_window);
                
+               FakeButtonAddPerson = new Gtk.Button();
                FakeButtonDone = new Gtk.Button();
        }
        
@@ -65,8 +67,28 @@ public class PersonSelectWindow
                return PersonSelectWindowBox;
        }
 
+       public void Update(ArrayList persons) {
+               this.persons = persons;
+               
+               LogB.Debug("Removing table");
+               table1.Visible = false;
+               removeTable();
+
+               LogB.Debug("Recreating table");
+               createTable();
+               table1.Visible = true;
+       }
+       
+       private void removeTable() 
+       {
+               Array buttons = table1.Children;
+               foreach(Gtk.Button b in buttons)
+                       table1.Remove(b);
+       }
+
        private void createTable() 
        {
+               LogB.Debug("Persons count" + persons.Count.ToString());
                uint padding = 8;       
                uint cols = 4; //each row has 4 columns
                uint rows = Convert.ToUInt32(Math.Floor(persons.Count / (1.0 * cols) ) +1);
@@ -83,7 +105,7 @@ public class PersonSelectWindow
                                PersonPhotoButton ppb = new PersonPhotoButton(p);
                                Gtk.Button b = ppb.CreateButton();
                                
-                               b.Clicked += new EventHandler(on_button_clicked);
+                               b.Clicked += new EventHandler(on_button_select_portrait_clicked);
                                b.Show();
                                
                                table1.Attach (b, (uint) col_i, (uint) col_i +1, (uint) row_i, (uint) row_i 
+1, 
@@ -94,7 +116,7 @@ public class PersonSelectWindow
                }
        }
        
-       private void on_button_clicked (object o, EventArgs args)
+       private void on_button_select_portrait_clicked (object o, EventArgs args)
        {
                LogB.Information("Clicked");
 
@@ -113,6 +135,10 @@ public class PersonSelectWindow
                                close_window();
                        }
        }
+       
+       protected virtual void on_button_add_clicked (object o, EventArgs args) {
+               FakeButtonAddPerson.Click();
+       }
 
        private void close_window() {   
                PersonSelectWindowBox.person_select_window.Hide();


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