← Back to team overview

deja-dup-team team mailing list archive

[Merge] lp:~tobedeprez/deja-dup/deja-dup into lp:deja-dup

 

Tobe Deprez has proposed merging lp:~tobedeprez/deja-dup/deja-dup into lp:deja-dup.

    Requested reviews:
    Déjà Dup Maintainers (deja-dup-team)


This branch lets the user choose how often a full backup should be made.
-- 
https://code.launchpad.net/~tobedeprez/deja-dup/deja-dup/+merge/16803
Your team Déjà Dup Maintainers is subscribed to branch lp:deja-dup.
=== modified file 'common/CommonUtils.vala'
--- common/CommonUtils.vala	2009-11-25 17:34:40 +0000
+++ common/CommonUtils.vala	2010-01-04 19:18:14 +0000
@@ -30,6 +30,7 @@
 public const string PERIODIC_KEY = "/apps/deja-dup/periodic";
 public const string PERIODIC_PERIOD_KEY = "/apps/deja-dup/periodic-period";
 public const string DELETE_AFTER_KEY = "/apps/deja-dup/delete-after";
+public const string FULL_BACKUP_KEY = "/apps/deja-dup/full-backup";
 
 public void update_last_run_timestamp() throws Error
 {
@@ -242,6 +243,7 @@
 public int get_full_backup_threshold()
 {
   int threshold = 7 * 6; // default to 6 weeks
+  
   try {
     // So, there are a few factors affecting how often to make a fresh full
     // backup:
@@ -281,6 +283,23 @@
   }
   catch (Error e) {warning("%s\n", e.message);}
   
+  //Look if the user has choosen how often to do a full backup
+  try{
+    int full_backup = client.get_int(FULL_BACKUP_KEY);
+    
+    switch (full_backup) {
+      case (0-1): //let deja-dup choose automatically when to do a full backup
+      break;
+      case 0: //never do a full backup
+        threshold = 0;
+      break;
+      default:
+        threshold = full_backup;
+      break;
+    }
+  }
+  catch (Error e) {warning("%s\n", e.message);}
+  
   return threshold;
 }
 
@@ -293,7 +312,14 @@
   date.set_time_val(now);
   
   var days = get_full_backup_threshold();
-  date.subtract_days(days);
+  
+  //set date to begin of time, so there will never be a full backup
+  if (days == 0) {
+    now.tv_sec = 0;
+    date.set_time_val (now);
+  }
+  else
+    date.subtract_days(days);
   
   return date;
 }

=== modified file 'preferences/PreferencesDialog.vala'
--- preferences/PreferencesDialog.vala	2009-11-13 04:47:00 +0000
+++ preferences/PreferencesDialog.vala	2010-01-04 19:18:15 +0000
@@ -207,6 +207,20 @@
                  3, 3);
     ++row;
     
+    w = new DejaDup.ConfigFull(DejaDup.FULL_BACKUP_KEY);
+    label = new Gtk.Label("%s".printf(_("_How often to do a full backup:")));
+    label.set("mnemonic-widget", w,
+              "use-underline", true,
+              "xalign", 0.0f);
+    label_sizes.add_widget(label);
+    table.attach(label, 0, 1, row, row + 1,
+                 0, Gtk.AttachOptions.FILL, 3, 3);
+    table.attach(w, 1, 3, row, row + 1,
+                 Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND,
+                 Gtk.AttachOptions.FILL,
+                 3, 3);
+                
+    
     if (location_label_noedit != null)
       handle_location_label_changed(location_label_noedit);
     else

=== added file 'widgets/ConfigFull.vala'
--- widgets/ConfigFull.vala	1970-01-01 00:00:00 +0000
+++ widgets/ConfigFull.vala	2010-01-04 19:18:15 +0000
@@ -0,0 +1,107 @@
+/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */
+/*
+    This file is part of Déjà Dup.
+    © 2009 Michael Terry <mike@xxxxxxxxxxx>
+
+    Déjà Dup is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    Déjà Dup is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Déjà Dup.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+using GLib;
+
+namespace DejaDup {
+
+public class ConfigFull : ConfigChoice
+{
+  public ConfigFull(string key) {
+    Object(key: key);
+  }
+  
+  construct {
+    var store = new Gtk.ListStore(2, typeof(string), typeof(int));
+    
+    Gtk.TreeIter iter;
+    int i = 0;
+    
+    store.insert_with_values(out iter, i++, 0, _("Automatic"), 1, -1);
+    store.insert_with_values(out iter, i++, 0, _("Never"), 1, 0);
+    store.insert_with_values(out iter, i++, 0, _("Each week"), 1, 7);
+    store.insert_with_values(out iter, i++, 0, _("Each two weeks"), 1, 14);
+    store.insert_with_values(out iter, i++, 0, _("Each month"), 1, 28*2);
+    store.insert_with_values(out iter, i++, 0, _("Each three months"), 1, 28*3);
+    store.insert_with_values(out iter, i++, 0, _("Each six months"), 1, 365/2);
+    store.insert_with_values(out iter, i++, 0, _("Each year"), 1, 365);
+    
+    store.set_sort_column_id(1, Gtk.SortType.ASCENDING);
+    
+    init(store, 1);
+  }
+  
+  protected override void handle_changed()
+  {
+    Value? val = get_current_value();
+    int intval = val == null ? 0 : val.get_int();
+    
+    try {
+        client.set_int(key, intval);
+    }
+    catch (Error e) {
+      warning("%s\n", e.message);
+    }
+    
+    choice_changed(intval.to_string());
+  }
+  
+  protected override void set_from_config()
+  {
+    int confval;
+    try {
+        confval = client.get_int(key);
+    }
+    catch (Error e) {
+      warning("%s\n", e.message);
+      return;
+    }
+    if (confval < -1)
+      confval = -1;
+    
+    bool valid;
+    Gtk.TreeIter iter;
+    valid = combo.model.get_iter_first(out iter);
+    
+    while (valid) {
+      Value val;
+      combo.model.get_value(iter, gconf_col, out val);
+      int intval = val.get_int();
+      
+      if (intval == confval) {
+        combo.set_active_iter(iter);
+        break;
+      }
+      valid = combo.model.iter_next(ref iter);
+    }
+    
+    // If we didn't find the time, user must have set it to something non
+    // standard.  Let's add an entry to the combo.
+    if (!valid) {
+      var store = (Gtk.ListStore)combo.model;
+      store.insert_with_values(out iter, 0, 0,
+                               ngettext("Each %d day", "Each %d days", confval).printf(confval),
+                               1, confval);
+      combo.set_active_iter(iter);
+    }
+  }
+}
+
+}
+

=== modified file 'widgets/Makefile.am'
--- widgets/Makefile.am	2009-12-29 15:00:18 +0000
+++ widgets/Makefile.am	2010-01-04 19:18:15 +0000
@@ -41,6 +41,7 @@
 	ConfigChoice.vala \
 	ConfigDelete.vala \
 	ConfigEntry.vala \
+	ConfigFull.vala \
 	ConfigLabel.vala \
 	ConfigLabelBool.vala \
 	ConfigLabelList.vala \


Follow ups