--- gigedit/trunk/src/gigedit/Settings.cpp 2016/04/26 17:42:26 2891 +++ gigedit/trunk/src/gigedit/Settings.cpp 2016/04/26 18:06:31 2892 @@ -11,6 +11,13 @@ #include #include #include +#include + +#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 40) || GTKMM_MAJOR_VERSION < 2 +# define HAS_GLIB_KEYFILE_SAVE_TO_FILE 0 +#else +# define HAS_GLIB_KEYFILE_SAVE_TO_FILE 1 +#endif static std::string configDir() { //printf("configDir '%s'\n", g_get_user_config_dir()); @@ -30,6 +37,19 @@ return "Global"; } +#if !HAS_GLIB_KEYFILE_SAVE_TO_FILE + +static bool saveToFile(Glib::KeyFile* keyfile, std::string filename) { + Glib::ustring s = keyfile->to_data(); + std::ofstream out; + out.open(filename.c_str(), std::ios_base::out | std::ios_base::trunc); + out << s; + out.close(); + return true; +} + +#endif // ! HAS_GLIB_KEYFILE_SAVE_TO_FILE + static Settings* _instance = NULL; Settings* Settings::singleton() { @@ -85,7 +105,11 @@ } try { +#if HAS_GLIB_KEYFILE_SAVE_TO_FILE bool ok = file.save_to_file(configFile()); +#else + bool ok = saveToFile(&file, configFile()); +#endif if (!ok) { std::cerr << "Failed saving gigedit config to '" << configFile() << "'\n" << std::flush; } else {