From 2cea640e33b3ab1d188660acbd199fcbece3b95e Mon Sep 17 00:00:00 2001 From: Alexander Kojevnikov Date: Sun, 27 Mar 2011 17:13:13 +0800 Subject: [PATCH] Add Preferences.save() --- src/spek-preferences.vala | 8 ++++++-- src/spek-window.vala | 10 ++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/spek-preferences.vala b/src/spek-preferences.vala index 328b8ac..b079efb 100644 --- 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 index bd25bd1..f0a50bd 100644 --- 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; } }