X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fsynfigapp%2Fsettings.cpp;h=c3b3810e149725443376d3f92af6bdf2186121c0;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=06690a3d70d5c6a085f4bc937aaec4da84186eed;hpb=02252941b29de64037116f4d37991a38d9ff0d94;p=synfig.git diff --git a/synfig-studio/trunk/src/synfigapp/settings.cpp b/synfig-studio/trunk/src/synfigapp/settings.cpp index 06690a3..c3b3810 100644 --- a/synfig-studio/trunk/src/synfigapp/settings.cpp +++ b/synfig-studio/trunk/src/synfigapp/settings.cpp @@ -1,20 +1,22 @@ /* === S Y N F I G ========================================================= */ -/*! \file template.cpp +/*! \file settings.cpp ** \brief Template File ** -** $Id: settings.cpp,v 1.2 2005/01/12 04:08:32 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 Chris Moore ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. ** \endlegal */ /* ========================================================================= */ @@ -30,9 +32,12 @@ #include #include +#include #include "settings.h" #include +#include "general.h" + #endif /* === U S I N G =========================================================== */ @@ -90,7 +95,7 @@ Settings::get_value(const synfig::String& key, synfig::String& value)const if(key.size()>iter->first.size() && String(key.begin(),key.begin()+iter->first.size())==iter->first) { synfig::String key_(key.begin()+iter->first.size()+1,key.end()); - + // If the domain has it, then we have got a hit if(iter->second->get_value(key_,value)) return true; @@ -103,7 +108,7 @@ Settings::get_value(const synfig::String& key, synfig::String& value)const value=simple_value_map.find(key)->second; return true; } - + // key not found return false; } @@ -119,7 +124,7 @@ Settings::set_value(const synfig::String& key,const synfig::String& value) if(key.size()>iter->first.size() && String(key.begin(),key.begin()+iter->first.size())==iter->first) { synfig::String key_(key.begin()+iter->first.size()+1,key.end()); - + return iter->second->set_value(key_,value); } } @@ -128,6 +133,19 @@ Settings::set_value(const synfig::String& key,const synfig::String& value) return true; } +//! Compare two key names, putting pref.* keys first +static bool +compare_pref_first (synfig::String first, synfig::String second) +{ + return first.substr(0, 5) == "pref." + ? second.substr(0, 5) == "pref." + ? first < second + : true + : second.substr(0, 5) == "pref." + ? false + : first < second; +} + Settings::KeyList Settings::get_key_list()const { @@ -144,7 +162,7 @@ Settings::get_key_list()const key_list.push_back(iter->first+'.'+*key_iter); } } - + // Get keys from the simple variables { ValueBaseMap::const_iterator iter; @@ -153,8 +171,11 @@ Settings::get_key_list()const } // Sort the keys - key_list.sort(); - + // We make sure the 'pref.*' keys come first to fix bug 1694393, + // where windows were being created before the parameter + // specifying which window manager hint to use had been loaded + key_list.sort(compare_pref_first); + return key_list; } @@ -162,33 +183,34 @@ bool Settings::save_to_file(const synfig::String& filename)const { synfig::String tmp_filename(filename+".TMP"); - + try { std::ofstream file(tmp_filename.c_str()); if(!file)return false; - + KeyList key_list(get_key_list()); - + // Save the keys { KeyList::const_iterator iter; for(iter=key_list.begin();iter!=key_list.end();++iter) { if(!file)return false; - file<<*iter<<'='<