X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fsynfigapp%2Fsettings.cpp;h=73d927f6ee6642bb4731b65a31b3cc6ceae6beb4;hb=976e5da32d8b20f054abf4cf2895ae466bcc7370;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..73d927f 100644 --- a/synfig-studio/trunk/src/synfigapp/settings.cpp +++ b/synfig-studio/trunk/src/synfigapp/settings.cpp @@ -1,20 +1,21 @@ /* === 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 ** -** 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 */ /* ========================================================================= */ @@ -90,7 +91,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 +104,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 +120,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 +129,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 +158,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 +167,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,15 +179,15 @@ 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; @@ -180,15 +197,15 @@ Settings::save_to_file(const synfig::String& filename)const file<<*iter<<'='<