libyui  3.0.10
/usr/src/RPM/BUILD/libyui-3.0.10/src/YSettings.cc
00001 /*
00002   Copyright (c) 2012 Björn Esser
00003 
00004   Permission is hereby granted, free of charge, to any person obtaining
00005   a copy of this software and associated documentation files (the
00006   "Software"), to deal in the Software without restriction, including
00007   without limitation the rights to use, copy, modify, merge, publish,
00008   distribute, sublicense, and/or sell
00009   copies of the Software, and to permit persons to whom the Software is
00010   furnished to do so, subject to the following conditions:
00011 
00012   The above copyright notice and this permission notice shall be
00013   included in all copies or substantial portions of the Software.
00014 
00015   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
00018   SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00019   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
00020   OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
00021   THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00022 */
00023 
00024 
00025 /*-/
00026 
00027   File:         YSettings.cc
00028 
00029   Author:       Björn Esser <bjoern.esser@gmail.com>
00030 
00031 /-*/
00032 
00033 #include "YSettings.h"
00034 #include "YUIException.h"
00035 
00036 #define YUILogComponent "ui"
00037 #include "YUILog.h"
00038 #include "Libyui_config.h"
00039 
00040 using std::endl;
00041 
00042 std::string  YSettings::_progDir = "";
00043 std::string  YSettings::_iconDir = "";
00044 std::string  YSettings::_themeDir = "";
00045 std::string  YSettings::_localeDir = "";
00046 
00047 YSettings::YSettings() 
00048 {
00049 }
00050 
00051 YSettings::~YSettings ()
00052 {
00053 }
00054 
00055 void YSettings::setProgDir( std::string directory )
00056 {
00057   if ( _progDir.empty() )
00058   {
00059     _progDir = directory;
00060     yuiMilestone () << "Set progDir to \"" << directory << "\"" << endl;
00061     yuiMilestone () << "progDir is now locked." << endl;
00062   }
00063   else
00064   {
00065     yuiMilestone () << "Can't set progDir to \"" << directory << "\"" << endl;
00066     yuiMilestone () << "It is locked to: \"" << _progDir << "\"" << endl;
00067     YUI_THROW ( YUIException ( "progSubDir is locked to: \"" + _progDir + "\"" ) );
00068   }
00069 }
00070 
00071 std::string YSettings::progDir ()
00072 {
00073   yuiMilestone () << "progDir: \"" << _progDir << "\"" << endl;
00074 
00075   return _progDir;
00076 }
00077 
00078 
00079 void YSettings::setIconDir( std::string directory )
00080 {
00081   if ( _iconDir.empty() )
00082   {
00083     _iconDir = directory;
00084     yuiMilestone () << "Set iconDir to \"" << directory << "\"" << endl;
00085     yuiMilestone () << "iconDir is now locked." << endl;
00086   }
00087   else
00088   {
00089     yuiMilestone () << "Can't set iconDir to \"" << directory << "\"" << endl;
00090     yuiMilestone () << "It is locked to: \"" << _iconDir << "\"" << endl;
00091     YUI_THROW ( YUIException ( "progIconDir is locked to: \"" + _iconDir + "\"" ) );
00092   }
00093 }
00094 
00095 std::string YSettings::iconDir ()
00096 {
00097   if (_iconDir.size())
00098   {
00099     yuiMilestone () << "iconDir: \"" << _iconDir << "\"" << endl;
00100     return _iconDir;
00101   }
00102   else if (_progDir.size())
00103     return _progDir + "/icons/";
00104   
00105   return THEMEDIR "/icons/";
00106 }
00107 
00108 void YSettings::setThemeDir( std::string directory )
00109 {
00110   if ( _themeDir.empty() )
00111   {
00112     _themeDir = directory;
00113     yuiMilestone () << "Set themeDir to \"" << directory << "\"" << endl;
00114     yuiMilestone () << "themeDir is now locked." << endl;
00115   }
00116   else
00117   {
00118     yuiMilestone () << "Can't set themeDir to \"" << directory << "\"" << endl;
00119     yuiMilestone () << "It is locked to: \"" << _themeDir << "\"" << endl;
00120     YUI_THROW ( YUIException ( "themeDir is locked to: \"" + _themeDir + "\"" ) );
00121   }
00122 }
00123 
00124 std::string YSettings::themeDir ()
00125 {
00126   if ( _themeDir.size() )
00127   {
00128     yuiMilestone () << "themeDir: \"" << _themeDir << "\"" << endl;
00129     return _themeDir;
00130   }
00131   else if ( _progDir.size() )
00132   {
00133     //back compatibility if setProgSubDir is set to "/usr/share/YaST2"
00134     return _progDir + "/theme/current/wizard/";
00135   }
00136 
00137   return THEMEDIR "/current/wizard/";
00138 }
00139 
00140 
00141 void YSettings::setLocaleDir( std::string directory )
00142 {
00143   if ( _localeDir.empty() )
00144   {
00145     _localeDir = directory;
00146     yuiMilestone () << "Set localeDir to \"" << directory << "\"" << endl;
00147     yuiMilestone () << "localeDir is now locked." << endl;
00148   }
00149   else
00150   {
00151     yuiMilestone () << "Can't set localeDir to \"" << directory << "\"" << endl;
00152     yuiMilestone () << "It is locked to: \"" << _localeDir << "\"" << endl;
00153     YUI_THROW ( YUIException ( "localeDir is locked to: \"" + _localeDir + "\"" ) );
00154   }
00155 }
00156 
00157 std::string YSettings::localeDir ()
00158 {
00159   if ( _localeDir.size() )
00160   {
00161     yuiMilestone () << "localeDir: \"" << _localeDir << "\"" << endl;
00162     return _localeDir;
00163   }
00164   else if ( _progDir.size() )
00165   {
00166     //back compatibility if ProgDir is set to "/usr/share/YaST2"
00167     return _progDir + "/locale/";
00168   }
00169 
00170   return "/usr/share/locale/";
00171 }
00172 
00173 
 All Classes Functions Variables Enumerations Friends