commit 2cea640e33b3ab1d188660acbd199fcbece3b95e
parent d772055446fc7a1c75d3fa7aaa01b71ea31a8da3
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date: Sun, 27 Mar 2011 17:13:13 +0800
Add Preferences.save()
Diffstat:
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/spek-preferences.vala b/src/spek-preferences.vala
@@ -50,8 +50,7 @@ namespace Spek {
}
~Preferences () {
- var output = FileStream.open (file_name, "w+");
- output.puts (key_file.to_data ());
+ save ();
}
private static Preferences _instance;
@@ -64,6 +63,11 @@ namespace Spek {
}
}
+ public void save () {
+ var output = FileStream.open (file_name, "w+");
+ output.puts (key_file.to_data ());
+ }
+
public bool check_update {
get {
try {
diff --git a/src/spek-window.vala b/src/spek-window.vala
@@ -285,7 +285,8 @@ namespace Spek {
private void * check_version () {
// Does the user want to check for updates?
- var check = Preferences.instance.check_update;
+ var prefs = Preferences.instance;
+ var check = prefs.check_update;
if (!check) {
return null;
}
@@ -295,7 +296,7 @@ namespace Spek {
time_val.get_current_time ();
Date today = Date ();
today.set_time_val (time_val);
- int day = Preferences.instance.last_update;
+ int day = prefs.last_update;
int diff = (int) today.get_julian () - day;
if (diff < 7) {
return null;
@@ -312,8 +313,9 @@ namespace Spek {
}
// Update the preferences.
- Preferences.instance.check_update = check;
- Preferences.instance.last_update = (int) today.get_julian ();
+ prefs.check_update = check;
+ prefs.last_update = (int) today.get_julian ();
+ prefs.save ();
return null;
}
}