aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Theme.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-28 23:06:27 (GMT)
committerfluxgen <fluxgen>2003-08-28 23:06:27 (GMT)
commitec235918df48427817521d6df9fde4cbe56c82d7 (patch)
tree10bb5170094eb004b5b294ecf882168b611572bd /src/FbTk/Theme.cc
parent95021a60ab0017c0544b3d239d5aa5e3d0d6daf9 (diff)
downloadfluxbox_pavel-ec235918df48427817521d6df9fde4cbe56c82d7.zip
fluxbox_pavel-ec235918df48427817521d6df9fde4cbe56c82d7.tar.bz2
verbose setting on theme warnings
Diffstat (limited to 'src/FbTk/Theme.cc')
-rw-r--r--src/FbTk/Theme.cc75
1 files changed, 36 insertions, 39 deletions
diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc
index 4afb7eb..ed7ba73 100644
--- a/src/FbTk/Theme.cc
+++ b/src/FbTk/Theme.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Theme.cc,v 1.16 2003/08/28 15:46:13 fluxgen Exp $ 22// $Id: Theme.cc,v 1.17 2003/08/28 23:06:27 fluxgen Exp $
23 23
24#include "Theme.hh" 24#include "Theme.hh"
25 25
@@ -78,16 +78,18 @@ void ThemeItem<FbTk::Font>::setDefaultValue() {
78template <> 78template <>
79void ThemeItem<FbTk::Font>::setFromString(const char *str) { 79void ThemeItem<FbTk::Font>::setFromString(const char *str) {
80 if (m_value.load(str) == false) { 80 if (m_value.load(str) == false) {
81 cerr<<"FbTk::Theme: Error loading font "<< 81 if (FbTk::ThemeManager::instance().verbose()) {
82 ((m_value.isAntialias() || m_value.utf8()) ? "(" : "")<< 82 cerr<<"FbTk::Theme: Error loading font "<<
83 ((m_value.isAntialias() || m_value.utf8()) ? "(" : "")<<
83 84
84 (m_value.isAntialias() ? "antialias" : "")<< 85 (m_value.isAntialias() ? "antialias" : "")<<
85 (m_value.utf8() ? " utf8" : "")<< 86 (m_value.utf8() ? " utf8" : "")<<
86 87
87 ((m_value.isAntialias() || m_value.utf8()) ? ") " : "")<< 88 ((m_value.isAntialias() || m_value.utf8()) ? ") " : "")<<
88 "for \""<<name()<<"\" or \""<<altName()<<"\": "<<str<<endl; 89 "for \""<<name()<<"\" or \""<<altName()<<"\": "<<str<<endl;
89 90
90 cerr<<"FbTk::Theme: Setting default value"<<endl; 91 cerr<<"FbTk::Theme: Setting default value"<<endl;
92 }
91 setDefaultValue(); 93 setDefaultValue();
92 } 94 }
93 95
@@ -131,7 +133,8 @@ void ThemeItem<FbTk::Texture>::load() {
131 133
132 std::auto_ptr<PixmapWithMask> pm(Image::load(pixmap_name, m_tm.screenNum())); 134 std::auto_ptr<PixmapWithMask> pm(Image::load(pixmap_name, m_tm.screenNum()));
133 if (pm.get() == 0) { 135 if (pm.get() == 0) {
134 cerr<<"Resource("<<name()+".pixmap"<<"): Failed to load image: "<<pixmap_name<<endl; 136 if (FbTk::ThemeManager::instance().verbose())
137 cerr<<"Resource("<<name()+".pixmap"<<"): Failed to load image: "<<pixmap_name<<endl;
135 m_value.pixmap() = 0; 138 m_value.pixmap() = 0;
136 } else 139 } else
137 m_value.pixmap() = pm->pixmap().release(); 140 m_value.pixmap() = pm->pixmap().release();
@@ -175,7 +178,8 @@ void ThemeItem<FbTk::Color>::setDefaultValue() {
175template <> 178template <>
176void ThemeItem<FbTk::Color>::setFromString(const char *str) { 179void ThemeItem<FbTk::Color>::setFromString(const char *str) {
177 if (!m_value.setFromString(str, m_tm.screenNum())) { 180 if (!m_value.setFromString(str, m_tm.screenNum())) {
178 cerr<<"FbTk::Theme: Error loading color value for \""<<name()<<"\" or \""<<altName()<<"\"."<<endl; 181 if (FbTk::ThemeManager::instance().verbose())
182 cerr<<"FbTk::Theme: Error loading color value for \""<<name()<<"\" or \""<<altName()<<"\"."<<endl;
179 setDefaultValue(); 183 setDefaultValue();
180 } 184 }
181} 185}
@@ -185,19 +189,11 @@ template <>
185void ThemeItem<FbTk::Color>::load() { } 189void ThemeItem<FbTk::Color>::load() { }
186 190
187Theme::Theme(int screen_num):m_screen_num(screen_num) { 191Theme::Theme(int screen_num):m_screen_num(screen_num) {
188 192 ThemeManager::instance().registerTheme(*this);
189 if (!ThemeManager::instance().registerTheme(*this)) {
190 // should it be fatal or not?
191 cerr<<"FbTk::Theme Warning: Failed to register Theme"<<endl;
192 }
193} 193}
194 194
195Theme::~Theme() { 195Theme::~Theme() {
196 if (!ThemeManager::instance().unregisterTheme(*this)) { 196 ThemeManager::instance().unregisterTheme(*this);
197#ifdef DEBUG
198 cerr<<"Warning: Theme not registered!"<<endl;
199#endif // DEBUG
200 }
201} 197}
202 198
203ThemeManager &ThemeManager::instance() { 199ThemeManager &ThemeManager::instance() {
@@ -206,7 +202,8 @@ ThemeManager &ThemeManager::instance() {
206} 202}
207 203
208ThemeManager::ThemeManager(): 204ThemeManager::ThemeManager():
209 m_max_screens(ScreenCount(FbTk::App::instance()->display())) { 205 m_max_screens(ScreenCount(FbTk::App::instance()->display())),
206 m_verbose(false) {
210 207
211} 208}
212 209
@@ -255,8 +252,8 @@ void ThemeManager::loadTheme(Theme &tm) {
255 if (!loadItem(*resource)) { 252 if (!loadItem(*resource)) {
256 // try fallback resource in theme 253 // try fallback resource in theme
257 if (!tm.fallback(*resource)) { 254 if (!tm.fallback(*resource)) {
258 cerr<<"Failed to read theme item: "<<resource->name()<<endl; 255 if (verbose())
259 cerr<<"Setting default value"<<endl; 256 cerr<<"Failed to read theme item: "<<resource->name()<<endl;
260 resource->setDefaultValue(); 257 resource->setDefaultValue();
261 } 258 }
262 } 259 }
@@ -295,22 +292,22 @@ std::string ThemeManager::resourceValue(const std::string &name, const std::stri
295} 292}
296 293
297/* 294/*
298void ThemeManager::listItems() { 295 void ThemeManager::listItems() {
299 ThemeList::iterator it = m_themelist.begin(); 296 ThemeList::iterator it = m_themelist.begin();
300 ThemeList::iterator it_end = m_themelist.end(); 297 ThemeList::iterator it_end = m_themelist.end();
301 for (; it != it_end; ++it) { 298 for (; it != it_end; ++it) {
302 std::list<ThemeItem_base *>::iterator item = (*it)->itemList().begin(); 299 std::list<ThemeItem_base *>::iterator item = (*it)->itemList().begin();
303 std::list<ThemeItem_base *>::iterator item_end = (*it)->itemList().end(); 300 std::list<ThemeItem_base *>::iterator item_end = (*it)->itemList().end();
304 for (; item != item_end; ++item) { 301 for (; item != item_end; ++item) {
305 cerr<<(*item)->name()<<":"<<endl; 302 cerr<<(*item)->name()<<":"<<endl;
306 if (typeid(**item) == typeid(ThemeItem<Texture>)) { 303 if (typeid(**item) == typeid(ThemeItem<Texture>)) {
307 cerr<<(*item)->name()<<".pixmap:"<<endl; 304 cerr<<(*item)->name()<<".pixmap:"<<endl;
308 cerr<<(*item)->name()<<".color:"<<endl; 305 cerr<<(*item)->name()<<".color:"<<endl;
309 cerr<<(*item)->name()<<".colorTo:"<<endl; 306 cerr<<(*item)->name()<<".colorTo:"<<endl;
310 } 307 }
311 } 308 }
312 } 309 }
313 310
314} 311 }
315*/ 312*/
316}; // end namespace FbTk 313}; // end namespace FbTk