1
/******************************************************************************
2
* Copyright (C) 2011 Michael Hofmann <mh21@piware.de> *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 3 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License along *
15
* with this program; if not, write to the Free Software Foundation, Inc., *
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
17
******************************************************************************/
19
public class SettingsConversion : Object {
20
public SettingsConversion() {
23
public uint oldversion() {
24
var settings = Utils.generalsettings();
25
return settings.get_value("settings-version").get_uint32();
28
public bool is_current() {
29
return this.oldversion() == 2;
32
public void convert() {
33
var settings = Utils.generalsettings();
35
while (!this.is_current()) {
36
switch (this.oldversion()) {
38
this.convert_version1();
41
settings.set_value("settings-version", this.oldversion() + 1);
45
private void convert_version1() {
46
var oldsettings = new FixedGSettings.Settings.with_path
47
("de.mh21.indicator.multiload.version1", "/apps/indicators/multiload/");
48
foreach (var key in oldsettings.list_keys()) {
49
var value = oldsettings.get_value(key);
50
oldsettings.reset(key);
51
var defaultvalue = oldsettings.get_value(key);
52
if (!value.equal(defaultvalue)) {
53
// TODO: this is not converting between 1 and 2, but between 1 and current
54
// no problem yet as we are only at settings version 2
56
case "cpuload-alpha4":
57
Utils.graphsettings("cpu").set_value("alpha", value);
59
case "memload-alpha4":
60
Utils.graphsettings("mem").set_value("alpha", value);
62
case "netload-alpha3":
63
Utils.graphsettings("net").set_value("alpha", value);
65
case "swapload-alpha1":
66
Utils.graphsettings("swap").set_value("alpha", value);
68
case "loadavg-alpha1":
69
Utils.graphsettings("load").set_value("alpha", value);
71
case "diskload-alpha2":
72
Utils.graphsettings("disk").set_value("alpha", value);
75
Utils.graphsettings("cpu").set_value("enabled", value);
78
Utils.graphsettings("mem").set_value("enabled", value);
81
Utils.graphsettings("net").set_value("enabled", value);
84
Utils.graphsettings("swap").set_value("enabled", value);
87
Utils.graphsettings("load").set_value("enabled", value);
90
Utils.graphsettings("disk").set_value("enabled", value);
92
case "cpuload-color0":
93
Utils.tracesettings("cpu", "cpu1").set_value("color", value);
95
case "cpuload-color1":
96
Utils.tracesettings("cpu", "cpu2").set_value("color", value);
98
case "cpuload-color2":
99
Utils.tracesettings("cpu", "cpu3").set_value("color", value);
101
case "cpuload-color3":
102
Utils.tracesettings("cpu", "cpu4").set_value("color", value);
104
case "cpuload-color4":
105
Utils.graphsettings("cpu").set_value("background-color", value);
107
case "memload-color0":
108
Utils.tracesettings("mem", "mem1").set_value("color", value);
110
case "memload-color1":
111
Utils.tracesettings("mem", "mem2").set_value("color", value);
113
case "memload-color2":
114
Utils.tracesettings("mem", "mem3").set_value("color", value);
116
case "memload-color3":
117
Utils.tracesettings("mem", "mem4").set_value("color", value);
119
case "memload-color4":
120
Utils.graphsettings("mem").set_value("background-color", value);
122
case "netload-color0":
123
Utils.tracesettings("net", "net1").set_value("color", value);
125
case "netload-color1":
126
Utils.tracesettings("net", "net2").set_value("color", value);
128
case "netload-color2":
129
Utils.tracesettings("net", "net3").set_value("color", value);
131
case "netload-color3":
132
Utils.graphsettings("net").set_value("background-color", value);
134
case "swapload-color0":
135
Utils.tracesettings("swap", "swap1").set_value("color", value);
137
case "swapload-color1":
138
Utils.graphsettings("swap").set_value("background-color", value);
140
case "loadavg-color0":
141
Utils.tracesettings("load", "load1").set_value("color", value);
143
case "loadavg-color1":
144
Utils.graphsettings("load").set_value("background-color", value);
146
case "diskload-color0":
147
Utils.tracesettings("disk", "disk1").set_value("color", value);
149
case "diskload-color1":
150
Utils.tracesettings("disk", "disk2").set_value("color", value);
152
case "diskload-color2":
153
Utils.graphsettings("disk").set_value("background-color", value);
156
Utils.generalsettings().set_value("speed", value);
159
Utils.generalsettings().set_value("size", value);
162
Utils.generalsettings().set_value("height", value);
164
case "system-monitor":
165
Utils.generalsettings().set_value("system-monitor", value);
168
Utils.generalsettings().set_value("autostart", value);