1
/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */
3
This file is part of Déjà Dup.
4
For copyright information, see AUTHORS.
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.
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.
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/>.
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
30
Additionally, doing lots of simultaneous reads & writes sometimes confuses
31
dconf, so it's nice to be able to avoid those.
34
public class FilteredSettings : Settings
36
public bool read_only {get; set;}
38
public FilteredSettings(string schema, bool ro)
40
Object(schema: schema, read_only: ro);
43
public new void apply() {if (!read_only) base.apply();}
45
public new void set_string(string k, string v) {
46
if (get_string(k) != v)
47
base.set_string(k, v);
49
public new void set_boolean(string k, bool v) {
50
if (get_boolean(k) != v)
51
base.set_boolean(k, v);
53
public new void set_int(string k, int v) {
57
public new void set_value(string k, Variant v) {
58
if (!get_value(k).equal(v))
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);
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());
79
// TODO: bytestring, strv