spek

Acoustic spectrum analyser https://github.com/alexkay/spek spek.cc
git clone http://git.hanabi.in/repos/spek.git
Log | Files | Refs | README

spek-preferences.cc (1787B)


      1 #include <wx/string.h>
      2 
      3 #include "spek-platform.h"
      4 
      5 #include "spek-preferences.h"
      6 
      7 SpekPreferences& SpekPreferences::get()
      8 {
      9     static SpekPreferences instance;
     10     return instance;
     11 }
     12 
     13 void SpekPreferences::init()
     14 {
     15     if (this->locale) {
     16         delete this->locale;
     17     }
     18     this->locale = new wxLocale();
     19 
     20     int lang = wxLANGUAGE_DEFAULT;
     21     wxString code = this->get_language();
     22     if (spek_platform_can_change_language() && !code.IsEmpty()) {
     23         const wxLanguageInfo *info = wxLocale::FindLanguageInfo(code);
     24         if (info) {
     25             lang = info->Language;
     26         }
     27     }
     28     this->locale->Init(lang);
     29     this->locale->AddCatalog(GETTEXT_PACKAGE);
     30 }
     31 
     32 SpekPreferences::SpekPreferences() : locale(NULL)
     33 {
     34     wxString path = spek_platform_config_path("spek");
     35     this->config = new wxFileConfig(
     36         wxEmptyString,
     37         wxEmptyString,
     38         path,
     39         wxEmptyString,
     40         wxCONFIG_USE_LOCAL_FILE,
     41         wxConvUTF8
     42     );
     43 }
     44 
     45 bool SpekPreferences::get_check_update()
     46 {
     47     bool result = true;
     48     this->config->Read("/update/check", &result);
     49     return result;
     50 }
     51 
     52 void SpekPreferences::set_check_update(bool value)
     53 {
     54     this->config->Write("/update/check", value);
     55     this->config->Flush();
     56 }
     57 
     58 long SpekPreferences::get_last_update()
     59 {
     60     long result = 0;
     61     this->config->Read("/update/last", &result);
     62     return result;
     63 }
     64 
     65 void SpekPreferences::set_last_update(long value)
     66 {
     67     this->config->Write("/update/last", value);
     68     this->config->Flush();
     69 }
     70 
     71 wxString SpekPreferences::get_language()
     72 {
     73     wxString result("");
     74     this->config->Read("/general/language", &result);
     75     return result;
     76 }
     77 
     78 void SpekPreferences::set_language(const wxString& value)
     79 {
     80     this->config->Write("/general/language", value);
     81     this->config->Flush();
     82 }