~ubuntu-branches/ubuntu/saucy/deja-dup/saucy

« back to all changes in this revision

Viewing changes to common/FilteredSettings.vala

  • Committer: Package Import Robot
  • Author(s): Michael Terry
  • Date: 2013-02-04 15:12:32 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20130204151232-3xr9quxod9pltlro
Tags: 25.5-0ubuntu1
* New upstream release
  - Use same partition for temp files as include files (to avoid problems
    with tiny /tmp partitions like tmpfs).  LP: #1100092
  - Tell GNOME 3 about notifications, so the user can disable them
  - Always exclude /run (in case user includes /)
* debian/rules:
  - Be explicit about what features we turn on (ccpanel, nautilus, unity)
* debian/control:
  - Require duplicity 0.6.21

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */
 
2
/*
 
3
    This file is part of Déjà Dup.
 
4
    For copyright information, see AUTHORS.
 
5
 
 
6
    Déjà Dup is free software: you can redistribute it and/or modify
 
7
    it under the terms of the GNU General Public License as published by
 
8
    the Free Software Foundation, either version 3 of the License, or
 
9
    (at your option) any later version.
 
10
 
 
11
    Déjà Dup is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
    GNU General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU General Public License
 
17
    along with Déjà Dup.  If not, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
 
20
using GLib;
 
21
 
 
22
namespace DejaDup {
 
23
 
 
24
/* This is a very simple class that just proxies calls to a Settings object.
 
25
   Its one difference is that it won't set a value that is already set to the
 
26
   requested value.  This prevents us from causing unnecessary 'changed'
 
27
   signals and generally from doing lots writes every time something in the UI
 
28
   is adjusted.
 
29
 
 
30
   Additionally, doing lots of simultaneous reads & writes sometimes confuses
 
31
   dconf, so it's nice to be able to avoid those.
 
32
 */
 
33
 
 
34
public class FilteredSettings : Settings
 
35
{
 
36
  public bool read_only {get; set;}
 
37
 
 
38
  public FilteredSettings(string schema, bool ro)
 
39
  {
 
40
    Object(schema: schema, read_only: ro);
 
41
  }
 
42
 
 
43
  public new void apply() {if (!read_only) base.apply();}
 
44
 
 
45
  public new void set_string(string k, string v) {
 
46
    if (get_string(k) != v)
 
47
     base.set_string(k, v);
 
48
  }
 
49
  public new void set_boolean(string k, bool v) {
 
50
    if (get_boolean(k) != v)
 
51
      base.set_boolean(k, v);
 
52
  }
 
53
  public new void set_int(string k, int v) {
 
54
    if (get_int(k) != v)
 
55
      base.set_int(k, v);
 
56
  }
 
57
  public new void set_value(string k, Variant v) {
 
58
    if (!get_value(k).equal(v))
 
59
      base.set_value(k, v);
 
60
  }
 
61
 
 
62
  // May be uri, or may be a File's parsed path for historical reasons
 
63
  public new string get_uri(string k) {
 
64
    // If we are reading a URI, replace some special keywords.
 
65
    var val = get_string(k);
 
66
    var result = parse_keywords(val);
 
67
    if (result == null)
 
68
      return "";
 
69
    else
 
70
      return result;
 
71
  }
 
72
 
 
73
  public new File[] get_file_list(string k) {
 
74
    // If we are reading a file path, replace some special keywords.
 
75
    var val = get_value(k);
 
76
    return parse_dir_list(val.get_strv());
 
77
  }
 
78
 
 
79
  // TODO: bytestring, strv
 
80
}
 
81
 
 
82
}
 
83