all repos — fluxbox @ ec235918df48427817521d6df9fde4cbe56c82d7

custom fork of the fluxbox windowmanager

verbose setting on theme warnings
fluxgen fluxgen
commit

ec235918df48427817521d6df9fde4cbe56c82d7

parent

95021a60ab0017c0544b3d239d5aa5e3d0d6daf9

2 files changed, 44 insertions(+), 40 deletions(-)

jump to
M src/FbTk/Theme.ccsrc/FbTk/Theme.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Theme.cc,v 1.16 2003/08/28 15:46:13 fluxgen Exp $ +// $Id: Theme.cc,v 1.17 2003/08/28 23:06:27 fluxgen Exp $ #include "Theme.hh"

@@ -78,16 +78,18 @@

template <> void ThemeItem<FbTk::Font>::setFromString(const char *str) { if (m_value.load(str) == false) { - cerr<<"FbTk::Theme: Error loading font "<< - ((m_value.isAntialias() || m_value.utf8()) ? "(" : "")<< + if (FbTk::ThemeManager::instance().verbose()) { + cerr<<"FbTk::Theme: Error loading font "<< + ((m_value.isAntialias() || m_value.utf8()) ? "(" : "")<< - (m_value.isAntialias() ? "antialias" : "")<< - (m_value.utf8() ? " utf8" : "")<< + (m_value.isAntialias() ? "antialias" : "")<< + (m_value.utf8() ? " utf8" : "")<< - ((m_value.isAntialias() || m_value.utf8()) ? ") " : "")<< - "for \""<<name()<<"\" or \""<<altName()<<"\": "<<str<<endl; + ((m_value.isAntialias() || m_value.utf8()) ? ") " : "")<< + "for \""<<name()<<"\" or \""<<altName()<<"\": "<<str<<endl; - cerr<<"FbTk::Theme: Setting default value"<<endl; + cerr<<"FbTk::Theme: Setting default value"<<endl; + } setDefaultValue(); }

@@ -131,7 +133,8 @@

std::auto_ptr<PixmapWithMask> pm(Image::load(pixmap_name, m_tm.screenNum())); if (pm.get() == 0) { - cerr<<"Resource("<<name()+".pixmap"<<"): Failed to load image: "<<pixmap_name<<endl; + if (FbTk::ThemeManager::instance().verbose()) + cerr<<"Resource("<<name()+".pixmap"<<"): Failed to load image: "<<pixmap_name<<endl; m_value.pixmap() = 0; } else m_value.pixmap() = pm->pixmap().release();

@@ -175,7 +178,8 @@

template <> void ThemeItem<FbTk::Color>::setFromString(const char *str) { if (!m_value.setFromString(str, m_tm.screenNum())) { - cerr<<"FbTk::Theme: Error loading color value for \""<<name()<<"\" or \""<<altName()<<"\"."<<endl; + if (FbTk::ThemeManager::instance().verbose()) + cerr<<"FbTk::Theme: Error loading color value for \""<<name()<<"\" or \""<<altName()<<"\"."<<endl; setDefaultValue(); } }

@@ -185,19 +189,11 @@ template <>

void ThemeItem<FbTk::Color>::load() { } Theme::Theme(int screen_num):m_screen_num(screen_num) { - - if (!ThemeManager::instance().registerTheme(*this)) { - // should it be fatal or not? - cerr<<"FbTk::Theme Warning: Failed to register Theme"<<endl; - } + ThemeManager::instance().registerTheme(*this); } Theme::~Theme() { - if (!ThemeManager::instance().unregisterTheme(*this)) { -#ifdef DEBUG - cerr<<"Warning: Theme not registered!"<<endl; -#endif // DEBUG - } + ThemeManager::instance().unregisterTheme(*this); } ThemeManager &ThemeManager::instance() {

@@ -206,7 +202,8 @@ return tm;

} ThemeManager::ThemeManager(): - m_max_screens(ScreenCount(FbTk::App::instance()->display())) { + m_max_screens(ScreenCount(FbTk::App::instance()->display())), + m_verbose(false) { }

@@ -255,8 +252,8 @@ ThemeItem_base *resource = *i;

if (!loadItem(*resource)) { // try fallback resource in theme if (!tm.fallback(*resource)) { - cerr<<"Failed to read theme item: "<<resource->name()<<endl; - cerr<<"Setting default value"<<endl; + if (verbose()) + cerr<<"Failed to read theme item: "<<resource->name()<<endl; resource->setDefaultValue(); } }

@@ -295,22 +292,22 @@ return "";

} /* -void ThemeManager::listItems() { - ThemeList::iterator it = m_themelist.begin(); - ThemeList::iterator it_end = m_themelist.end(); - for (; it != it_end; ++it) { - std::list<ThemeItem_base *>::iterator item = (*it)->itemList().begin(); - std::list<ThemeItem_base *>::iterator item_end = (*it)->itemList().end(); - for (; item != item_end; ++item) { - cerr<<(*item)->name()<<":"<<endl; - if (typeid(**item) == typeid(ThemeItem<Texture>)) { - cerr<<(*item)->name()<<".pixmap:"<<endl; - cerr<<(*item)->name()<<".color:"<<endl; - cerr<<(*item)->name()<<".colorTo:"<<endl; - } - } - } + void ThemeManager::listItems() { + ThemeList::iterator it = m_themelist.begin(); + ThemeList::iterator it_end = m_themelist.end(); + for (; it != it_end; ++it) { + std::list<ThemeItem_base *>::iterator item = (*it)->itemList().begin(); + std::list<ThemeItem_base *>::iterator item_end = (*it)->itemList().end(); + for (; item != item_end; ++item) { + cerr<<(*item)->name()<<":"<<endl; + if (typeid(**item) == typeid(ThemeItem<Texture>)) { + cerr<<(*item)->name()<<".pixmap:"<<endl; + cerr<<(*item)->name()<<".color:"<<endl; + cerr<<(*item)->name()<<".colorTo:"<<endl; + } + } + } -} + } */ }; // end namespace FbTk
M src/FbTk/Theme.hhsrc/FbTk/Theme.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Theme.hh,v 1.8 2003/08/28 14:19:27 fluxgen Exp $ +// $Id: Theme.hh,v 1.9 2003/08/28 23:05:29 fluxgen Exp $ /** @file holds ThemeItem<T>, Theme and ThemeManager which is the base for any theme

@@ -106,6 +106,8 @@ template <typename T>

void remove(ThemeItem<T> &item); virtual bool fallback(ThemeItem_base &base) { return false; } FbTk::Subject &reconfigSig() { return m_reconfig_sig; } + + private: const int m_screen_num; typedef std::list<ThemeItem_base *> ItemList;

@@ -121,11 +123,15 @@ */

class ThemeManager { public: static ThemeManager &instance(); + bool load(const std::string &filename); std::string resourceValue(const std::string &name, const std::string &altname); void loadTheme(Theme &tm); bool loadItem(ThemeItem_base &resource); bool loadItem(ThemeItem_base &resource, const std::string &name, const std::string &altname); + + bool verbose() const { return m_verbose; } + void setVerbose(bool value) { m_verbose = value; } private: ThemeManager(); ~ThemeManager() { }

@@ -141,6 +147,7 @@ typedef std::list<FbTk::Theme *> ThemeList;

ThemeList m_themelist; const int m_max_screens; XrmDatabaseHelper m_database; + bool m_verbose; };