[chronojump] ConfigurationFile imported and automatically applied from preferences win



commit cca3d0cb51bb3b39ff1d55605f61b193c04cc148
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Jul 13 10:40:07 2015 +0200

    ConfigurationFile imported and automatically applied from preferences win

 glade/chronojump.glade |  449 ++++++++++++++++++++++++++----------------------
 src/gui/chronojump.cs  |    8 +
 src/gui/preferences.cs |   65 ++++++--
 3 files changed, 299 insertions(+), 223 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index fa32c4f..7602ad8 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -7568,6 +7568,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             <child>
@@ -8931,6 +8934,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">2</property>
@@ -9935,6 +9941,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">4</property>
@@ -21392,6 +21401,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -22295,6 +22307,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -23690,6 +23705,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>
@@ -24142,6 +24160,9 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -35426,6 +35447,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>
@@ -37001,6 +37040,18 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -38398,9 +38449,6 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                       <placeholder/>
                                     </child>
                                     <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
                                       <widget class="GtkLabel" id="label218">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
@@ -39303,6 +39351,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>
@@ -39428,257 +39479,228 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
               <widget class="GtkVBox" id="vbox142">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="border_width">8</property>
+                <property name="border_width">16</property>
+                <property name="spacing">16</property>
                 <child>
-                  <widget class="GtkVBox" id="vbox143">
+                  <widget class="GtkFrame" id="frame3">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="border_width">8</property>
-                    <property name="spacing">10</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">in</property>
                     <child>
-                      <widget class="GtkVBox" id="vbox144">
+                      <widget class="GtkVBox" id="vbox9">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
+                        <property name="border_width">8</property>
                         <property name="spacing">8</property>
                         <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <widget class="GtkLabel" id="label_database">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="selectable">True</property>
-                          </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <widget class="GtkLabel" id="label_database_temp">
+                          <widget class="GtkTable" id="table2">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="selectable">True</property>
-                          </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">3</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <widget class="GtkButton" id="button_db_folder_open">
-                            <property name="label" translatable="yes">Open database folder</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="use_underline">True</property>
-                            <signal name="clicked" handler="on_button_db_folder_open_clicked" swapped="no"/>
+                            <property name="can_focus">False</property>
+                            <property name="n_rows">3</property>
+                            <property name="n_columns">2</property>
+                            <property name="column_spacing">6</property>
+                            <property name="row_spacing">6</property>
+                            <child>
+                              <widget class="GtkCheckButton" id="check_backup_sessions">
+                                <property name="label" translatable="yes">Sessions</property>
+                                <property name="visible">True</property>
+                                <property name="sensitive">False</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                              </widget>
+                            </child>
+                            <child>
+                              <widget class="GtkCheckButton" id="check_backup_encoder_tests">
+                                <property name="label" translatable="yes">Encoder tests</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="clicked" handler="on_check_backup_encoder_tests_clicked" 
swapped="no"/>
+                              </widget>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkCheckButton" id="check_backup_multimedia">
+                                <property name="label" translatable="yes">Images and Videos</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="clicked" handler="on_check_backup_multimedia_clicked" 
swapped="no"/>
+                              </widget>
+                              <packing>
+                                <property name="top_attach">2</property>
+                                <property name="bottom_attach">3</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkCheckButton" id="check_backup_persons">
+                                <property name="label" translatable="yes">Persons</property>
+                                <property name="visible">True</property>
+                                <property name="sensitive">False</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                              </widget>
+                              <packing>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkCheckButton" id="check_backup_contact_tests">
+                                <property name="label" translatable="yes">Contact tests</property>
+                                <property name="visible">True</property>
+                                <property name="sensitive">False</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                              </widget>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkButton" id="button_db_backup">
+                                <property name="label" translatable="yes">Backup database</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="tooltip" translatable="yes">Make a copy of the 
database</property>
+                                <property name="use_underline">True</property>
+                                <signal name="clicked" handler="on_button_db_backup_clicked" swapped="no"/>
+                              </widget>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">2</property>
+                                <property name="bottom_attach">3</property>
+                              </packing>
+                            </child>
                           </widget>
                           <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="padding">10</property>
-                            <property name="position">4</property>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
                           </packing>
                         </child>
                         <child>
-                          <widget class="GtkFrame" id="frame3">
-                            <property name="visible">True</property>
+                          <widget class="GtkHBox" id="hbox_backup_doing">
                             <property name="can_focus">False</property>
-                            <property name="label_xalign">0</property>
-                            <property name="shadow_type">in</property>
+                            <property name="spacing">8</property>
                             <child>
-                              <widget class="GtkVBox" id="vbox9">
+                              <widget class="GtkLabel" id="label19">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="border_width">8</property>
-                                <property name="spacing">8</property>
-                                <child>
-                                  <widget class="GtkTable" id="table2">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="n_rows">3</property>
-                                    <property name="n_columns">2</property>
-                                    <property name="column_spacing">6</property>
-                                    <property name="row_spacing">6</property>
-                                    <child>
-                                      <widget class="GtkCheckButton" id="check_backup_sessions">
-                                        <property name="label" translatable="yes">Sessions</property>
-                                        <property name="visible">True</property>
-                                        <property name="sensitive">False</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="receives_default">False</property>
-                                        <property name="active">True</property>
-                                        <property name="draw_indicator">True</property>
-                                      </widget>
-                                    </child>
-                                    <child>
-                                      <widget class="GtkCheckButton" id="check_backup_encoder_tests">
-                                        <property name="label" translatable="yes">Encoder tests</property>
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="receives_default">False</property>
-                                        <property name="draw_indicator">True</property>
-                                        <signal name="clicked" 
handler="on_check_backup_encoder_tests_clicked" swapped="no"/>
-                                      </widget>
-                                      <packing>
-                                        <property name="left_attach">1</property>
-                                        <property name="right_attach">2</property>
-                                        <property name="top_attach">1</property>
-                                        <property name="bottom_attach">2</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <widget class="GtkCheckButton" id="check_backup_multimedia">
-                                        <property name="label" translatable="yes">Images and 
Videos</property>
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="receives_default">False</property>
-                                        <property name="draw_indicator">True</property>
-                                        <signal name="clicked" handler="on_check_backup_multimedia_clicked" 
swapped="no"/>
-                                      </widget>
-                                      <packing>
-                                        <property name="top_attach">2</property>
-                                        <property name="bottom_attach">3</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <widget class="GtkCheckButton" id="check_backup_persons">
-                                        <property name="label" translatable="yes">Persons</property>
-                                        <property name="visible">True</property>
-                                        <property name="sensitive">False</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="receives_default">False</property>
-                                        <property name="active">True</property>
-                                        <property name="draw_indicator">True</property>
-                                      </widget>
-                                      <packing>
-                                        <property name="top_attach">1</property>
-                                        <property name="bottom_attach">2</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <widget class="GtkCheckButton" id="check_backup_contact_tests">
-                                        <property name="label" translatable="yes">Contact tests</property>
-                                        <property name="visible">True</property>
-                                        <property name="sensitive">False</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="receives_default">False</property>
-                                        <property name="active">True</property>
-                                        <property name="draw_indicator">True</property>
-                                      </widget>
-                                      <packing>
-                                        <property name="left_attach">1</property>
-                                        <property name="right_attach">2</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <widget class="GtkButton" id="button_db_backup">
-                                        <property name="label" translatable="yes">Backup database</property>
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="receives_default">False</property>
-                                        <property name="tooltip" translatable="yes">Make a copy of the 
database</property>
-                                        <property name="use_underline">True</property>
-                                        <signal name="clicked" handler="on_button_db_backup_clicked" 
swapped="no"/>
-                                      </widget>
-                                      <packing>
-                                        <property name="left_attach">1</property>
-                                        <property name="right_attach">2</property>
-                                        <property name="top_attach">2</property>
-                                        <property name="bottom_attach">3</property>
-                                      </packing>
-                                    </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="hbox_backup_doing">
-                                    <property name="can_focus">False</property>
-                                    <property name="spacing">8</property>
-                                    <child>
-                                      <widget class="GtkLabel" id="label19">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="label" translatable="yes">Please, wait.</property>
-                                      </widget>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">True</property>
-                                        <property name="position">0</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <widget class="GtkProgressBar" id="pulsebar">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                      </widget>
-                                      <packing>
-                                        <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>
-                                  </packing>
-                                </child>
+                                <property name="label" translatable="yes">Please, wait.</property>
                               </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
                             </child>
                             <child>
-                              <widget class="GtkLabel" id="label18">
+                              <widget class="GtkProgressBar" id="pulsebar">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="label" translatable="yes">Backup database</property>
-                                <property name="use_markup">True</property>
                               </widget>
                               <packing>
-                                <property name="type">label_item</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="padding">10</property>
-                            <property name="position">5</property>
+                            <property name="position">1</property>
                           </packing>
                         </child>
                       </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkLabel" id="label18">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Backup database</property>
+                        <property name="use_markup">True</property>
+                      </widget>
                       <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="padding">4</property>
-                        <property name="position">0</property>
+                        <property name="type">label_item</property>
                       </packing>
                     </child>
                   </widget>
                   <packing>
                     <property name="expand">False</property>
-                    <property name="fill">True</property>
+                    <property name="fill">False</property>
                     <property name="position">0</property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkButton" id="button_logs_folder_open">
-                    <property name="label" translatable="yes">Open logs folder</property>
+                  <widget class="GtkVButtonBox" id="vbuttonbox1">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_underline">True</property>
-                    <signal name="clicked" handler="on_button_logs_folder_open_clicked" swapped="no"/>
+                    <property name="can_focus">False</property>
+                    <property name="spacing">20</property>
+                    <child>
+                      <widget class="GtkButton" id="button_db_folder_open">
+                        <property name="label" translatable="yes">Open database folder</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <signal name="clicked" handler="on_button_db_folder_open_clicked" swapped="no"/>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="padding">10</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkButton" id="button_logs_folder_open">
+                        <property name="label" translatable="yes">Open logs folder</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <signal name="clicked" handler="on_button_logs_folder_open_clicked" swapped="no"/>
+                      </widget>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkButton" id="button_import_configuration">
+                        <property name="label" translatable="yes">Import configuration</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <signal name="clicked" handler="on_button_import_configuration_clicked" 
swapped="no"/>
+                      </widget>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
                   </widget>
                   <packing>
                     <property name="expand">True</property>
@@ -42769,6 +42791,9 @@ It starts before and arrives there with some speed.</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                       <packing>
                         <property name="left_attach">2</property>
@@ -43336,6 +43361,9 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -43918,6 +43946,9 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index a909b5b..baa79ec 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2856,8 +2856,16 @@ public partial class ChronoJumpWindow
        {
                preferencesWin = PreferencesWindow.Show(preferences);
                
+               preferencesWin.FakeButtonImported.Clicked += new 
EventHandler(on_preferences_import_configuration);
                preferencesWin.Button_accept.Clicked += new EventHandler(on_preferences_accepted);
        }
+               
+       private void on_preferences_import_configuration (object o, EventArgs args) {
+               preferencesWin.FakeButtonImported.Clicked -= new 
EventHandler(on_preferences_import_configuration);
+               
+               configInit();
+               LogB.Information("Initialized configuration");
+       }
 
        private void on_preferences_accepted (object o, EventArgs args) 
        {
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index cf36d9b..c5f0091 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -36,9 +36,6 @@ public class PreferencesWindow {
 
 
        //database tab
-       [Widget] Gtk.Label label_database;
-       [Widget] Gtk.Label label_database_temp;
-       
        [Widget] Gtk.Button button_db_folder_open;
 
        //this three are unneded because cannot be unchecked
@@ -121,6 +118,7 @@ public class PreferencesWindow {
 
        [Widget] Gtk.Button button_accept;
        [Widget] Gtk.Button button_cancel;
+       public Gtk.Button FakeButtonImported;
        
        static PreferencesWindow PreferencesWindowBox;
        
@@ -130,6 +128,9 @@ public class PreferencesWindow {
        //language when window is called. If changes, then change data in sql and show 
        //dialogMessage
        //private string languageIni;
+       
+       string databaseURL;
+       string databaseTempURL;
 
 
        PreferencesWindow () {
@@ -140,12 +141,11 @@ public class PreferencesWindow {
                //put an icon to window
                UtilGtk.IconWindow(preferences_win);
 
-               label_database.Visible = false;
-               label_database_temp.Visible = false;
-
                //database and log files stuff
-               label_database.Text = Util.GetDatabaseDir() + System.IO.Path.DirectorySeparatorChar  + 
"chronojump.db";
-               label_database_temp.Text = Util.GetDatabaseTempDir() + System.IO.Path.DirectorySeparatorChar  
+ "chronojump.db";
+               databaseURL = Util.GetDatabaseDir() + System.IO.Path.DirectorySeparatorChar  + 
"chronojump.db";
+               databaseTempURL = Util.GetDatabaseTempDir() + System.IO.Path.DirectorySeparatorChar  + 
"chronojump.db";
+               
+               FakeButtonImported = new Gtk.Button();
        }
        
        static public PreferencesWindow Show (Preferences preferences)
@@ -389,8 +389,8 @@ public class PreferencesWindow {
        
        void on_button_db_folder_open_clicked (object o, EventArgs args)
        {
-               System.IO.FileInfo file1 = new System.IO.FileInfo(label_database.Text); //potser cal una 
arrobar abans (a windows)
-               System.IO.FileInfo file2 = new System.IO.FileInfo(label_database_temp.Text); //potser cal una 
arrobar abans (a windows)
+               System.IO.FileInfo file1 = new System.IO.FileInfo(databaseURL); //potser cal una arrobar 
abans (a windows)
+               System.IO.FileInfo file2 = new System.IO.FileInfo(databaseTempURL); //potser cal una arrobar 
abans (a windows)
 
                if(file1.Exists)
                        System.Diagnostics.Process.Start(Util.GetDatabaseDir()); 
@@ -439,8 +439,8 @@ public class PreferencesWindow {
        Gtk.FileChooserDialog fc;
        void on_button_db_backup_clicked (object o, EventArgs args)
        {
-               System.IO.FileInfo file1 = new System.IO.FileInfo(label_database.Text); //potser cal una 
arrobar abans (a windows)
-               System.IO.FileInfo file2 = new System.IO.FileInfo(label_database_temp.Text); //potser cal una 
arrobar abans (a windows)
+               System.IO.FileInfo file1 = new System.IO.FileInfo(databaseURL); //potser cal una arrobar 
abans (a windows)
+               System.IO.FileInfo file2 = new System.IO.FileInfo(databaseTempURL); //potser cal una arrobar 
abans (a windows)
                fileDB = "";
 
                long length1 = 0;
@@ -453,9 +453,9 @@ public class PreferencesWindow {
                if(length1 == 0 && length2 == 0) 
                        new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error. Cannot 
find database."));
                else if(length1 > length2)
-                       fileDB = label_database.Text;
+                       fileDB = databaseURL;
                else
-                       fileDB = label_database_temp.Text;
+                       fileDB = databaseTempURL;
 
                fc = new Gtk.FileChooserDialog(Catalog.GetString("Copy database to:"),
                                preferences_win,
@@ -528,6 +528,43 @@ public class PreferencesWindow {
                
        }
        
+       void on_button_import_configuration_clicked (object o, EventArgs args)
+       {
+               fc = new Gtk.FileChooserDialog(Catalog.GetString("Import configuration file"),
+                               preferences_win,
+                               FileChooserAction.Open,
+                               Catalog.GetString("Cancel"),ResponseType.Cancel,
+                               Catalog.GetString("Import"),ResponseType.Accept
+                               );
+               
+               fc.Filter = new FileFilter();
+               //it can handle future archives like: chronojump_config_SOME_VENDOR.txt
+               //and it will be copied to chronojump_config.txt
+               fc.Filter.AddPattern("chronojump_config*.txt");
+       
+               bool success = false;   
+               if (fc.Run() == (int)ResponseType.Accept) 
+               {
+                       try {
+                               File.Copy(fc.Filename, UtilAll.GetConfigFileName(), true);
+                               LogB.Information("Imported configuration");
+
+                               //will launch configInit() from gui/chronojump.cs
+                               FakeButtonImported.Click();
+
+                               success = true;
+                       } catch {
+                               LogB.Warning("Catched! Configuration cannot be imported");
+                               new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error 
importing data."));
+                       }
+               }
+               //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
+               fc.Destroy();
+
+               if(success)
+                       new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Successfulluy 
imported."));
+       }
+       
        private void on_overwrite_file_accepted(object o, EventArgs args)
        {
                try {



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