diff options
author | fluxgen <fluxgen> | 2003-08-28 23:06:27 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-08-28 23:06:27 (GMT) |
commit | ec235918df48427817521d6df9fde4cbe56c82d7 (patch) | |
tree | 10bb5170094eb004b5b294ecf882168b611572bd | |
parent | 95021a60ab0017c0544b3d239d5aa5e3d0d6daf9 (diff) | |
download | fluxbox_paul-ec235918df48427817521d6df9fde4cbe56c82d7.zip fluxbox_paul-ec235918df48427817521d6df9fde4cbe56c82d7.tar.bz2 |
verbose setting on theme warnings
-rw-r--r-- | src/FbTk/Theme.cc | 75 | ||||
-rw-r--r-- | src/FbTk/Theme.hh | 9 |
2 files changed, 44 insertions, 40 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() { | |||
78 | template <> | 78 | template <> |
79 | void ThemeItem<FbTk::Font>::setFromString(const char *str) { | 79 | void 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() { | |||
175 | template <> | 178 | template <> |
176 | void ThemeItem<FbTk::Color>::setFromString(const char *str) { | 179 | void 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 <> | |||
185 | void ThemeItem<FbTk::Color>::load() { } | 189 | void ThemeItem<FbTk::Color>::load() { } |
186 | 190 | ||
187 | Theme::Theme(int screen_num):m_screen_num(screen_num) { | 191 | Theme::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 | ||
195 | Theme::~Theme() { | 195 | Theme::~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 | ||
203 | ThemeManager &ThemeManager::instance() { | 199 | ThemeManager &ThemeManager::instance() { |
@@ -206,7 +202,8 @@ ThemeManager &ThemeManager::instance() { | |||
206 | } | 202 | } |
207 | 203 | ||
208 | ThemeManager::ThemeManager(): | 204 | ThemeManager::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 | /* |
298 | void 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 |
diff --git a/src/FbTk/Theme.hh b/src/FbTk/Theme.hh index 563796d..b939747 100644 --- a/src/FbTk/Theme.hh +++ b/src/FbTk/Theme.hh | |||
@@ -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.hh,v 1.8 2003/08/28 14:19:27 fluxgen Exp $ | 22 | // $Id: Theme.hh,v 1.9 2003/08/28 23:05:29 fluxgen Exp $ |
23 | 23 | ||
24 | /** | 24 | /** |
25 | @file holds ThemeItem<T>, Theme and ThemeManager which is the base for any theme | 25 | @file holds ThemeItem<T>, Theme and ThemeManager which is the base for any theme |
@@ -106,6 +106,8 @@ public: | |||
106 | void remove(ThemeItem<T> &item); | 106 | void remove(ThemeItem<T> &item); |
107 | virtual bool fallback(ThemeItem_base &base) { return false; } | 107 | virtual bool fallback(ThemeItem_base &base) { return false; } |
108 | FbTk::Subject &reconfigSig() { return m_reconfig_sig; } | 108 | FbTk::Subject &reconfigSig() { return m_reconfig_sig; } |
109 | |||
110 | |||
109 | private: | 111 | private: |
110 | const int m_screen_num; | 112 | const int m_screen_num; |
111 | typedef std::list<ThemeItem_base *> ItemList; | 113 | typedef std::list<ThemeItem_base *> ItemList; |
@@ -121,11 +123,15 @@ private: | |||
121 | class ThemeManager { | 123 | class ThemeManager { |
122 | public: | 124 | public: |
123 | static ThemeManager &instance(); | 125 | static ThemeManager &instance(); |
126 | |||
124 | bool load(const std::string &filename); | 127 | bool load(const std::string &filename); |
125 | std::string resourceValue(const std::string &name, const std::string &altname); | 128 | std::string resourceValue(const std::string &name, const std::string &altname); |
126 | void loadTheme(Theme &tm); | 129 | void loadTheme(Theme &tm); |
127 | bool loadItem(ThemeItem_base &resource); | 130 | bool loadItem(ThemeItem_base &resource); |
128 | bool loadItem(ThemeItem_base &resource, const std::string &name, const std::string &altname); | 131 | bool loadItem(ThemeItem_base &resource, const std::string &name, const std::string &altname); |
132 | |||
133 | bool verbose() const { return m_verbose; } | ||
134 | void setVerbose(bool value) { m_verbose = value; } | ||
129 | private: | 135 | private: |
130 | ThemeManager(); | 136 | ThemeManager(); |
131 | ~ThemeManager() { } | 137 | ~ThemeManager() { } |
@@ -141,6 +147,7 @@ private: | |||
141 | ThemeList m_themelist; | 147 | ThemeList m_themelist; |
142 | const int m_max_screens; | 148 | const int m_max_screens; |
143 | XrmDatabaseHelper m_database; | 149 | XrmDatabaseHelper m_database; |
150 | bool m_verbose; | ||
144 | }; | 151 | }; |
145 | 152 | ||
146 | 153 | ||