[chronojump] Backup "tomorrow" now is "next time" to avoid bothering user every day.



commit 39395067f1d17dc4ffdae64737473b73b24fae07
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sat Aug 21 12:12:35 2021 +0200

    Backup "tomorrow" now is "next time" to avoid bothering user every day.

 glade/app1.glade               | 124 +++++++----------------------------------
 src/gui/app1/session/backup.cs |  37 +++++++-----
 src/gui/app1/session/main.cs   |   2 +-
 src/sqlite/preferences.cs      |   2 +-
 4 files changed, 47 insertions(+), 118 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 91085c798..26faf2fe3 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -25669,6 +25669,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -31980,6 +31983,18 @@ Concentric</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">6</property>
                                                             <child>
+                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="pack_type">end</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_capturing">
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">4</property>
@@ -32016,18 +32031,6 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="pack_type">end</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_no_capturing">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -41323,6 +41326,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -46559,8 +46565,8 @@ then click this button.</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkButton" 
id="app1s_button_backup_scheduled_remind_tomorrow">
-                                                            <property name="label" translatable="yes">Remind 
me tomorrow</property>
+                                                            <widget class="GtkButton" 
id="app1s_button_backup_scheduled_remind_next_time">
+                                                            <property name="label" translatable="yes">Remind 
me next time</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="receives_default">True</property>
@@ -46650,94 +46656,6 @@ then click this button.</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <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>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">3</property>
-                                                            </packing>
-                                                            </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>
@@ -46748,7 +46666,7 @@ then click this button.</property>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
-                                                            <property name="position">4</property>
+                                                            <property name="position">3</property>
                                                             </packing>
                                                             </child>
                                                             </widget>
diff --git a/src/gui/app1/session/backup.cs b/src/gui/app1/session/backup.cs
index c114e982c..d0a8e87d8 100644
--- a/src/gui/app1/session/backup.cs
+++ b/src/gui/app1/session/backup.cs
@@ -75,7 +75,7 @@ public partial class ChronoJumpWindow
 
        private bool shouldAskBackupScheduled ()
        {
-               // 1) if next days is -1 (never ask agan), do not show widget
+               // 1) if next days is -1 (never ask again), do not show widget
                if(preferences.backupScheduledNextDays < 0)
                        return false;
 
@@ -116,9 +116,16 @@ public partial class ChronoJumpWindow
 
        private void on_app1s_button_backup_scheduled_remind_clicked (object o, EventArgs args)
        {
-               int days = 1;
-               if (o == (object) app1s_button_backup_scheduled_remind_tomorrow)
-                       days = 1;
+               /*
+                  There is a remind_next_time and not a remind_tomorrow, because tomorrow will be days = 1.
+                  But, next day after the backup will continue being days = 1, bothering the user again 
(everyday).
+                  Using next_time (meaning: next Chronojump start), nothing is changed on sqlite,
+                  message will appear next time, days will be always 30 by default or 60 or 90 if last time 
selected one of those.
+                */
+
+               int days = 0;
+               if (o == (object) app1s_button_backup_scheduled_remind_next_time)
+                       days = 0;
                else if (o == (object) app1s_button_backup_scheduled_remind_30d)
                        days = 30;
                else if (o == (object) app1s_button_backup_scheduled_remind_60d)
@@ -126,10 +133,11 @@ public partial class ChronoJumpWindow
                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));
+               string message = Catalog.GetString("You will be prompted for a backup the next time you start 
Chronojump.");
+               if(days > 0)
+                       message = string.Format(Catalog.GetString("You will be prompted for a backup in {0} 
days."), days);
+
+               app1_backup_remind_or_never_do (days, message);
        }
 
        private void on_app1s_button_backup_scheduled_never_clicked (object o, EventArgs args)
@@ -140,13 +148,16 @@ public partial class ChronoJumpWindow
 
        private void app1_backup_remind_or_never_do (int days, string message)
        {
-               // 1) Sqlite changes
-               Sqlite.Open(); // ---->
+               if(days > 0)
+               {
+                       // 1) Sqlite changes
+                       Sqlite.Open(); // ---->
 
-               SqlitePreferences.Update(SqlitePreferences.BackupScheduledCreatedDateStr, 
UtilDate.ToSql(DateTime.Now), true);
-               SqlitePreferences.Update(SqlitePreferences.BackupScheduledNextDaysStr, days.ToString(), true);
+                       SqlitePreferences.Update(SqlitePreferences.BackupScheduledCreatedDateStr, 
UtilDate.ToSql(DateTime.Now), true);
+                       SqlitePreferences.Update(SqlitePreferences.BackupScheduledNextDaysStr, 
days.ToString(), true);
 
-               Sqlite.Close(); // <----
+                       Sqlite.Close(); // <----
+               }
 
                // 2) gui changes
                label_backup_why.Visible = false;
diff --git a/src/gui/app1/session/main.cs b/src/gui/app1/session/main.cs
index 2842a66c3..880c12e89 100644
--- a/src/gui/app1/session/main.cs
+++ b/src/gui/app1/session/main.cs
@@ -172,7 +172,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Button app1s_button_delete_old_incomplete;
        [Widget] Gtk.Button app1s_button_old_backups_delete_do;
        [Widget] Gtk.Label app1s_label_old_backups_delete_done;
-       [Widget] Gtk.Button app1s_button_backup_scheduled_remind_tomorrow;
+       [Widget] Gtk.Button app1s_button_backup_scheduled_remind_next_time;
        [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;
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index cbf2deb60..833636a27 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -40,7 +40,7 @@ class SqlitePreferences : Sqlite
        public const string LastBackupDirStr = "lastBackupDir";
        public const string LastBackupDatetimeStr = "lastBackupDatetime"; //merely informational
        public const string BackupScheduledCreatedDateStr = "backupScheduledCreatedDate"; //when was 
scheduled (not when is the backup)
-       public const string BackupScheduledNextDaysStr = "backupScheduledNextDays"; // days to the backup (-1 
is no scheduled backup and never ask again, 1 is tomorrow, 90 is 90 days)
+       public const string BackupScheduledNextDaysStr = "backupScheduledNextDays"; // days to the backup (-1 
is no scheduled backup and never ask again, 30/60/90 is 30/60/90 days)
 
        //person (appearance)
        public const string PersonSelectWinImages = "personSelectWinImages";


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