libyui  2.42.6
 All Classes Functions Variables Enumerations Friends
YSettings.cc
1 /*
2  Copyright (c) 2012 Björn Esser
3 
4  Permission is hereby granted, free of charge, to any person obtaining
5  a copy of this software and associated documentation files (the
6  "Software"), to deal in the Software without restriction, including
7  without limitation the rights to use, copy, modify, merge, publish,
8  distribute, sublicense, and/or sell
9  copies of the Software, and to permit persons to whom the Software is
10  furnished to do so, subject to the following conditions:
11 
12  The above copyright notice and this permission notice shall be
13  included in all copies or substantial portions of the Software.
14 
15  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
18  SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
21  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23 
24 
25 /*-/
26 
27  File: YSettings.cc
28 
29  Author: Björn Esser <bjoern.esser@gmail.com>
30 
31 /-*/
32 
33 #include "YSettings.h"
34 #include "YUIException.h"
35 
36 #define YUILogComponent "ui"
37 #include "YUILog.h"
38 #include "Libyui_config.h"
39 
40 using std::endl;
41 
42 std::string YSettings::progSubDir = "";
43 std::string YSettings::progIconDir = "";
44 std::string YSettings::progThemeDir = "";
45 std::string YSettings::progLocaleDir = "";
46 
47 YSettings::YSettings()
48 {
49 }
50 
51 YSettings::~YSettings ()
52 {
53 }
54 
55 void YSettings::setProgSubDir( std::string directory )
56 {
57  if ( progSubDir.empty() )
58  {
59  progSubDir = directory;
60  yuiMilestone () << "Set progSubDir to \"" << directory << "\"" << endl;
61  yuiMilestone () << "progSubDir is now locked." << endl;
62  }
63  else
64  {
65  yuiMilestone () << "Can't set progSubDir to \"" << directory << "\"" << endl;
66  yuiMilestone () << "It is locked to: \"" << progSubDir << "\"" << endl;
67  YUI_THROW ( YUIException ( "progSubDir is locked to: \"" + progSubDir + "\"" ) );
68  }
69 }
70 
72 {
73  yuiMilestone () << "progSubDir: \"" << progSubDir << "\"" << endl;
74 
75  return progSubDir;
76 }
77 
78 
79 void YSettings::setIconsDir( std::string directory )
80 {
81  if ( progIconDir.empty() )
82  {
83  progIconDir = directory;
84  yuiMilestone () << "Set progIconDir to \"" << directory << "\"" << endl;
85  yuiMilestone () << "progIconDir is now locked." << endl;
86  }
87  else
88  {
89  yuiMilestone () << "Can't set progIconDir to \"" << directory << "\"" << endl;
90  yuiMilestone () << "It is locked to: \"" << progIconDir << "\"" << endl;
91  YUI_THROW ( YUIException ( "progIconDir is locked to: \"" + progIconDir + "\"" ) );
92  }
93 }
94 
95 std::string YSettings::getIconsDir ()
96 {
97  if (progIconDir.size())
98  {
99  yuiMilestone () << "progIconDir: \"" << progIconDir << "\"" << endl;
100  return progIconDir;
101  }
102  else if (progSubDir.size())
103  return progSubDir + "/icons/";
104 
105  return THEMEDIR "/icons/";
106 }
107 
108 void YSettings::setThemeDir( std::string directory )
109 {
110  if ( progThemeDir.empty() )
111  {
112  progThemeDir = directory;
113  yuiMilestone () << "Set progThemeDir to \"" << directory << "\"" << endl;
114  yuiMilestone () << "progThemeDir is now locked." << endl;
115  }
116  else
117  {
118  yuiMilestone () << "Can't set progThemeDir to \"" << directory << "\"" << endl;
119  yuiMilestone () << "It is locked to: \"" << progThemeDir << "\"" << endl;
120  YUI_THROW ( YUIException ( "progThemeDir is locked to: \"" + progThemeDir + "\"" ) );
121  }
122 }
123 
125 {
126  if (progThemeDir.size())
127  {
128  yuiMilestone () << "progThemeDir: \"" << progThemeDir << "\"" << endl;
129  return progThemeDir;
130  }
131  else if (progSubDir.size())
132  {
133  //back compatibility if setProgSubDir is set to "/usr/share/YaST2"
134  return progSubDir + "/theme/current/wizard/";
135  }
136 
137  return THEMEDIR "/current/wizard/";
138 }
139 
140 
141 void YSettings::setLocaleDir( std::string directory )
142 {
143  if ( progLocaleDir.empty() )
144  {
145  progLocaleDir = directory;
146  yuiMilestone () << "Set progLocaleDir to \"" << directory << "\"" << endl;
147  yuiMilestone () << "progLocaleDir is now locked." << endl;
148  }
149  else
150  {
151  yuiMilestone () << "Can't set progLocaleDir to \"" << directory << "\"" << endl;
152  yuiMilestone () << "It is locked to: \"" << progLocaleDir << "\"" << endl;
153  YUI_THROW ( YUIException ( "progLocaleDir is locked to: \"" + progLocaleDir + "\"" ) );
154  }
155 }
156 
158 {
159  if (progLocaleDir.size())
160  {
161  yuiMilestone () << "progLocaleDir: \"" << progLocaleDir << "\"" << endl;
162  return progLocaleDir;
163  }
164  else if (progSubDir.size())
165  {
166  //back compatibility if setProgSubDir is set to "/usr/share/YaST2"
167  return progSubDir + "/locale/";
168  }
169 
170  return "/usr/share/locale/";
171 }
172 
173