/[svn]/gigedit/trunk/src/gigedit/Settings.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/Settings.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2891 by schoenebeck, Tue Apr 26 17:42:26 2016 UTC revision 2892 by schoenebeck, Tue Apr 26 18:06:31 2016 UTC
# Line 11  Line 11 
11  #include <glibmm/keyfile.h>  #include <glibmm/keyfile.h>
12  #include <iostream>  #include <iostream>
13  #include <stdio.h>  #include <stdio.h>
14    #include <fstream>
15    
16    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 40) || GTKMM_MAJOR_VERSION < 2
17    # define HAS_GLIB_KEYFILE_SAVE_TO_FILE 0
18    #else
19    # define HAS_GLIB_KEYFILE_SAVE_TO_FILE 1
20    #endif
21    
22  static std::string configDir() {  static std::string configDir() {
23      //printf("configDir '%s'\n", g_get_user_config_dir());      //printf("configDir '%s'\n", g_get_user_config_dir());
# Line 30  static std::string groupName(Settings::G Line 37  static std::string groupName(Settings::G
37      return "Global";      return "Global";
38  }  }
39    
40    #if !HAS_GLIB_KEYFILE_SAVE_TO_FILE
41    
42    static bool saveToFile(Glib::KeyFile* keyfile, std::string filename) {
43        Glib::ustring s = keyfile->to_data();
44        std::ofstream out;
45        out.open(filename.c_str(), std::ios_base::out | std::ios_base::trunc);
46        out << s;
47        out.close();
48        return true;
49    }
50    
51    #endif // ! HAS_GLIB_KEYFILE_SAVE_TO_FILE
52    
53  static Settings* _instance = NULL;  static Settings* _instance = NULL;
54            
55  Settings* Settings::singleton() {  Settings* Settings::singleton() {
# Line 85  void Settings::onPropertyChanged(Glib::P Line 105  void Settings::onPropertyChanged(Glib::P
105      }      }
106    
107      try {      try {
108    #if HAS_GLIB_KEYFILE_SAVE_TO_FILE
109          bool ok = file.save_to_file(configFile());          bool ok = file.save_to_file(configFile());
110    #else
111            bool ok = saveToFile(&file, configFile());
112    #endif
113          if (!ok) {          if (!ok) {
114              std::cerr << "Failed saving gigedit config to '" << configFile() << "'\n" << std::flush;              std::cerr << "Failed saving gigedit config to '" << configFile() << "'\n" << std::flush;
115          } else {          } else {

Legend:
Removed from v.2891  
changed lines
  Added in v.2892

  ViewVC Help
Powered by ViewVC