[chronojump] Implemented scheduled backups: remind tomorrow or in 30/60/90 days



commit e4b3e6aabbbe8eb4ee5498b5d7814aad6fc15a1e
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Aug 19 18:10:08 2021 +0200

    Implemented scheduled backups: remind tomorrow or in 30/60/90 days

 glade/app1.glade               | 12 ++++++++----
 src/gui/app1/session/backup.cs | 33 +++++++++++++++++++++++++++++----
 src/gui/app1/session/main.cs   |  4 ++++
 3 files changed, 41 insertions(+), 8 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index be9824248..468c5e925 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -46529,11 +46529,12 @@ then click this button.</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkButton" id="button12">
+                                                            <widget class="GtkButton" 
id="app1s_button_backup_scheduled_remind_tomorrow">
                                                             <property name="label" translatable="yes">Remind 
me tomorrow</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_remind_clicked" swapped="no"/>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -46563,11 +46564,12 @@ then click this button.</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <child>
-                                                            <widget class="GtkButton" id="button17">
+                                                            <widget class="GtkButton" 
id="app1s_button_backup_scheduled_remind_30d">
                                                             <property name="label">30</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_remind_clicked" swapped="no"/>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -46576,11 +46578,12 @@ then click this button.</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkButton" id="button18">
+                                                            <widget class="GtkButton" 
id="app1s_button_backup_scheduled_remind_60d">
                                                             <property name="label">60</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_remind_clicked" swapped="no"/>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -46589,11 +46592,12 @@ then click this button.</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkButton" id="button19">
+                                                            <widget class="GtkButton" 
id="app1s_button_backup_scheduled_remind_90d">
                                                             <property name="label">90</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_remind_clicked" swapped="no"/>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/gui/app1/session/backup.cs b/src/gui/app1/session/backup.cs
index a4c91d869..fcde51aef 100644
--- a/src/gui/app1/session/backup.cs
+++ b/src/gui/app1/session/backup.cs
@@ -114,17 +114,42 @@ public partial class ChronoJumpWindow
 
        private void on_app1s_button_backup_scheduled_remind_clicked (object o, EventArgs args)
        {
-               //if (o == (object) button_) ..
+               int days = 1;
+               if (o == (object) app1s_button_backup_scheduled_remind_tomorrow)
+                       days = 1;
+               else if (o == (object) app1s_button_backup_scheduled_remind_30d)
+                       days = 30;
+               else if (o == (object) app1s_button_backup_scheduled_remind_60d)
+                       days = 60;
+               else if (o == (object) app1s_button_backup_scheduled_remind_90d)
+                       days = 90;
+
+               app1_backup_remind_or_never_do (days, string.Format(Catalog.GetPluralString(
+                                               "You will be prompted for a backup in one day.",
+                                               "You will be prompted for a backup in {0} days.",
+                                               days), days));
        }
 
        private void on_app1s_button_backup_scheduled_never_clicked (object o, EventArgs args)
        {
-               SqlitePreferences.Update(SqlitePreferences.BackupScheduledNextDaysStr, "-1", false);
+               app1_backup_remind_or_never_do (-1, Catalog.GetString("You will no longer be bothered with 
scheduled backups, but you can continue backing up by clicking on") +
+                               " " + Catalog.GetString("Session") + " / " + Catalog.GetString("More") + ".");
+       }
+
+       private void app1_backup_remind_or_never_do (int days, string message)
+       {
+               // 1) Sqlite changes
+               Sqlite.Open(); // ---->
+
+               SqlitePreferences.Update(SqlitePreferences.BackupScheduledCreatedDateStr, 
UtilDate.ToSql(DateTime.Now), true);
+               SqlitePreferences.Update(SqlitePreferences.BackupScheduledNextDaysStr, days.ToString(), true);
+
+               Sqlite.Close(); // <----
 
+               // 2) gui changes
                label_backup_why.Visible = false;
                notebook_session_backup.Page = 
Convert.ToInt32(notebook_session_backup_pages.SCHEDULED_FEEDBACK);
-               app1s_label_remind_feedback.Text =
-                       Catalog.GetString("You will no longer be bothered with scheduled backups, but you can 
continue backing up by clicking on Session / More.");
+               app1s_label_remind_feedback.Text = message;
 
                backup_cancel_close_show_more_notebook = false; //clicking on close should not show session 
more
                app1s_label_backup_cancel_close.Text = Catalog.GetString("Close");
diff --git a/src/gui/app1/session/main.cs b/src/gui/app1/session/main.cs
index da6f35d3f..e0a5db7e5 100644
--- a/src/gui/app1/session/main.cs
+++ b/src/gui/app1/session/main.cs
@@ -169,6 +169,10 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.ProgressBar app1s_pulsebarBackupActivity;
        [Widget] Gtk.ProgressBar app1s_pulsebarBackupDirs;
        [Widget] Gtk.ProgressBar app1s_pulsebarBackupSecondDirs;
+       [Widget] Gtk.Button app1s_button_backup_scheduled_remind_tomorrow;
+       [Widget] Gtk.Button app1s_button_backup_scheduled_remind_30d;
+       [Widget] Gtk.Button app1s_button_backup_scheduled_remind_60d;
+       [Widget] Gtk.Button app1s_button_backup_scheduled_remind_90d;
        [Widget] Gtk.Label app1s_label_remind_feedback;
 
        //notebook tab 8 (export)


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