libyui  2.42.5
 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 
46 YSettings::YSettings()
47 {
48 }
49 
50 YSettings::~YSettings ()
51 {
52 }
53 
54 void YSettings::setProgSubDir( std::string directory )
55 {
56  if ( progSubDir.empty() )
57  {
58  progSubDir = directory;
59  yuiMilestone () << "Set progSubDir to \"" << directory << "\"" << endl;
60  yuiMilestone () << "progSubDir is now locked." << endl;
61  }
62  else
63  {
64  yuiMilestone () << "Can't set progSubDir to \"" << directory << "\"" << endl;
65  yuiMilestone () << "It is locked to: \"" << progSubDir << "\"" << endl;
66  YUI_THROW ( YUIException ( "progSubDir is locked to: \"" + progSubDir + "\"" ) );
67  }
68 }
69 
71 {
72  yuiMilestone () << "progSubDir: \"" << progSubDir << "\"" << endl;
73 
74  return progSubDir;
75 }
76 
77 
78 void YSettings::setIconsDir( std::string directory )
79 {
80  if ( progIconDir.empty() )
81  {
82  progIconDir = directory;
83  yuiMilestone () << "Set progIconDir to \"" << directory << "\"" << endl;
84  yuiMilestone () << "progIconDir is now locked." << endl;
85  }
86  else
87  {
88  yuiMilestone () << "Can't set progIconDir to \"" << directory << "\"" << endl;
89  yuiMilestone () << "It is locked to: \"" << progIconDir << "\"" << endl;
90  YUI_THROW ( YUIException ( "progIconDir is locked to: \"" + progIconDir + "\"" ) );
91  }
92 }
93 
94 std::string YSettings::getIconsDir ()
95 {
96  if (progIconDir.size())
97  {
98  yuiMilestone () << "progIconDir: \"" << progIconDir << "\"" << endl;
99  return progIconDir;
100  }
101  else if (progSubDir.size())
102  return progSubDir + "/icons/";
103 
104  return THEMEDIR "/icons/";
105 }
106 
107 void YSettings::setThemeDir( std::string directory )
108 {
109  if ( progThemeDir.empty() )
110  {
111  progThemeDir = directory;
112  yuiMilestone () << "Set progThemeDir to \"" << directory << "\"" << endl;
113  yuiMilestone () << "progThemeDir is now locked." << endl;
114  }
115  else
116  {
117  yuiMilestone () << "Can't set progThemeDir to \"" << directory << "\"" << endl;
118  yuiMilestone () << "It is locked to: \"" << progThemeDir << "\"" << endl;
119  YUI_THROW ( YUIException ( "progThemeDir is locked to: \"" + progThemeDir + "\"" ) );
120  }
121 }
122 
124 {
125  if (progThemeDir.size())
126  {
127  yuiMilestone () << "progThemeDir: \"" << progThemeDir << "\"" << endl;
128  return progThemeDir;
129  }
130  else if (progSubDir.size())
131  {
132  //back compatibility if setProgSubDir is set to "/usr/share/YaST2"
133  return progSubDir + "/theme/current/wizard/";
134  }
135 
136  return THEMEDIR "/current/wizard/";
137 }