[chronojump] Scheduled backup now working and updating sqlite vars



commit 6790f185b139374737314a49864df9c202effde4
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Aug 19 12:08:55 2021 +0200

    Scheduled backup now working and updating sqlite vars

 glade/app1.glade               | 96 ++++++++++++++++++++++++++++++++++++++++--
 src/gui/app1/session/backup.cs | 37 ++++++++++++++--
 src/gui/app1/session/main.cs   |  1 +
 3 files changed, 127 insertions(+), 7 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 4f2f92953..be2720828 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -46515,11 +46515,12 @@ then click this button.</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">16</property>
                                                             <child>
-                                                            <widget class="GtkButton" id="button3">
+                                                            <widget class="GtkButton" 
id="app1s_button_backup_scheduled_now">
                                                             <property name="label" translatable="yes">Make 
the backup now!</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="receives_default">True</property>
+                                                            <signal name="clicked" 
handler="on_app1s_button_backup_scheduled_now_clicked" swapped="no"/>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -46615,8 +46616,69 @@ then click this button.</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkButton" id="button14">
-                                                            <property name="label" translatable="yes">Don't 
ask me again</property>
+                                                            <widget class="GtkVBox" id="vbox127">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">2</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label656">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="xalign">0</property>
+                                                            <property name="label">Remind me …</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox7">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">4</property>
+                                                            <child>
+                                                            <widget class="GtkButton" id="button24">
+                                                            <property name="label">tomorrow</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkButton" id="button13">
+                                                            <property name="label">in 30 days</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkButton" id="button21">
+                                                            <property name="label">in 60 days</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkButton" id="button22">
+                                                            <property name="label">in 90 days</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="receives_default">True</property>
@@ -46629,6 +46691,34 @@ then click this button.</property>
                                                             </child>
                                                             </widget>
                                                             <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">3</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="app1s_button_backup_scheduled_never">
+                                                            <property name="label" translatable="yes">Don't 
ask me again</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <signal name="clicked" 
handler="on_app1s_button_backup_scheduled_never_clicked" swapped="no"/>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">4</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
                                                             <property name="position">1</property>
diff --git a/src/gui/app1/session/backup.cs b/src/gui/app1/session/backup.cs
index 6c64d6d36..522879d7e 100644
--- a/src/gui/app1/session/backup.cs
+++ b/src/gui/app1/session/backup.cs
@@ -35,6 +35,12 @@ public partial class ChronoJumpWindow
 
        //user clicks on backup
        private void on_button_db_backup_pre_clicked (object o, EventArgs args)
+       {
+               label_backup_why.Visible = true; //user clicked on backup from more window. Show this label
+               db_backup_pre_2 ();
+       }
+
+       private void db_backup_pre_2 ()
        {
                if(! app1s_getDatabaseFile())
                {
@@ -60,9 +66,6 @@ public partial class ChronoJumpWindow
 
        private bool shouldAskBackupScheduled ()
        {
-               /*
-                       TODO: disabled until 4 buttons do something
-
                // 1) if never scheduled, need to show widget
                if(preferences.backupScheduledCreatedDate == DateTime.MinValue)
                        return true;
@@ -75,7 +78,6 @@ public partial class ChronoJumpWindow
                // <0 means "This instance is earlier than value.". So if created date + nextDays is < than 
current date, need to do backup
                
if(preferences.backupScheduledCreatedDate.AddDays(preferences.backupScheduledNextDays).CompareTo(DateTime.Now)
 <= 0)
                        return true;
-                       */
 
                return false;
        }
@@ -95,6 +97,23 @@ public partial class ChronoJumpWindow
                //TODO: remember to show again after pressing any of the buttons
        }
 
+       private void on_app1s_button_backup_scheduled_now_clicked (object o, EventArgs args)
+       {
+               app1s_button_backup_cancel_close.Visible = true;
+               label_backup_why.Visible = false; //do not show again label_backup_why
+
+               db_backup_pre_2 ();
+       }
+
+       private void on_app1s_button_backup_scheduled_remind_clicked (object o, EventArgs args)
+       {
+               //if (o == (object) button_) ..
+       }
+
+       private void on_app1s_button_backup_scheduled_never_clicked (object o, EventArgs args)
+       {
+       }
+
        private bool app1s_getDatabaseFile ()
        {
                string databaseURL = Util.GetDatabaseDir() +
@@ -207,6 +226,16 @@ public partial class ChronoJumpWindow
                        app1s_BackupPulseEnd();
 
                        LogB.ThreadEnded();
+
+                       //update Sqlite backup vars (preferences not neede because will not be used until 
next boot)
+                       Sqlite.Open(); // ---->
+
+                       DateTime nowDT = DateTime.Now;
+                       SqlitePreferences.Update(SqlitePreferences.LastBackupDatetimeStr, 
UtilDate.ToSql(nowDT), true);
+                       SqlitePreferences.Update(SqlitePreferences.BackupScheduledCreatedDateStr, 
UtilDate.ToSql(nowDT), true);
+
+                       Sqlite.Close(); // <----
+
                        return false;
                }
 
diff --git a/src/gui/app1/session/main.cs b/src/gui/app1/session/main.cs
index 881cf75c7..4ef40db63 100644
--- a/src/gui/app1/session/main.cs
+++ b/src/gui/app1/session/main.cs
@@ -154,6 +154,7 @@ public partial class ChronoJumpWindow
 
        //notebook tab 7 (backup)
        [Widget] Gtk.Notebook notebook_session_backup;
+       [Widget] Gtk.Label label_backup_why;
        [Widget] Gtk.Label app1s_label_backup_estimated_size;
        [Widget] Gtk.Button app1s_button_backup_select;
        [Widget] Gtk.Button app1s_button_backup_start;


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