From 4a7a143713c7febe7d3a7df9c044ed767b8bd3c6 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Sun, 16 Dec 2007 00:50:59 -0800 Subject: load style before loading theme objects, remove duplicate theme load --- src/ButtonTheme.cc | 1 + src/FbTk/MenuTheme.cc | 1 + src/FbTk/Theme.cc | 12 +++++++----- src/FbWinFrameTheme.cc | 1 + src/MenuTheme.cc | 1 + src/RootTheme.cc | 1 + src/Screen.cc | 6 ------ src/SlitTheme.cc | 1 + src/ToolTheme.cc | 1 + src/ToolbarTheme.cc | 1 + src/WinButtonTheme.cc | 1 + src/fluxbox.cc | 6 +++--- 12 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/ButtonTheme.cc b/src/ButtonTheme.cc index 3966410..46d74ca 100644 --- a/src/ButtonTheme.cc +++ b/src/ButtonTheme.cc @@ -39,6 +39,7 @@ ButtonTheme::ButtonTheme(int screen_num, m_name(name), m_fallbackname(extra_fallback), m_altfallbackname(extra_fallback_alt) { + FbTk::ThemeManager::instance().loadTheme(*this); } bool ButtonTheme::fallback(FbTk::ThemeItem_base &item) { diff --git a/src/FbTk/MenuTheme.cc b/src/FbTk/MenuTheme.cc index 3b03697..46da48e 100644 --- a/src/FbTk/MenuTheme.cc +++ b/src/FbTk/MenuTheme.cc @@ -98,6 +98,7 @@ MenuTheme::MenuTheme(int screen_num): d_text_gc.setForeground(*d_text); hilite_gc.setForeground(hilite->color()); + ThemeManager::instance().loadTheme(*this); } MenuTheme::~MenuTheme() { diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc index cd03f5e..1c69bb4 100644 --- a/src/FbTk/Theme.cc +++ b/src/FbTk/Theme.cc @@ -97,12 +97,14 @@ bool ThemeManager::registerTheme(Theme &tm) { // valid screen num? if (m_max_screens < tm.screenNum() || tm.screenNum() < 0) return false; - // TODO: use find and return false if it's already there - // instead of unique - m_themes[tm.screenNum()].push_back(&tm); - m_themes[tm.screenNum()].unique(); - return true; + ThemeList::const_iterator it = m_themes[tm.screenNum()].begin(), + it_end = m_themes[tm.screenNum()].end(); + if (std::find(it, it_end, &tm) == it_end) { + m_themes[tm.screenNum()].push_back(&tm); + return true; + } + return false; } bool ThemeManager::unregisterTheme(Theme &tm) { diff --git a/src/FbWinFrameTheme.cc b/src/FbWinFrameTheme.cc index 33a45a8..1175297 100644 --- a/src/FbWinFrameTheme.cc +++ b/src/FbWinFrameTheme.cc @@ -74,6 +74,7 @@ FbWinFrameTheme::FbWinFrameTheme(int screen_num): m_cursor_right_side = XCreateFontCursor(disp, XC_right_side); m_cursor_bottom_side = XCreateFontCursor(disp, XC_bottom_side); + FbTk::ThemeManager::instance().loadTheme(*this); reconfigTheme(); } diff --git a/src/MenuTheme.cc b/src/MenuTheme.cc index 4d6f55c..682239c 100644 --- a/src/MenuTheme.cc +++ b/src/MenuTheme.cc @@ -55,4 +55,5 @@ void FbTk::ThemeItem::setFromString(const char *str) { MenuTheme::MenuTheme(int screen_num):FbTk::MenuTheme(screen_num), m_shapeplace(*this, "menu.roundCorners", "Menu.RoundCorners") { *m_shapeplace = Shape::NONE; + FbTk::ThemeManager::instance().loadTheme(*this); } diff --git a/src/RootTheme.cc b/src/RootTheme.cc index 90478e3..892e219 100644 --- a/src/RootTheme.cc +++ b/src/RootTheme.cc @@ -159,6 +159,7 @@ RootTheme::RootTheme(FbTk::ImageControl &image_control): m_opgc.setFunction(GXxor); m_opgc.setSubwindowMode(IncludeInferiors); m_opgc.setLineAttributes(1, LineSolid, CapNotLast, JoinMiter); + FbTk::ThemeManager::instance().loadTheme(*this); } RootTheme::~RootTheme() { diff --git a/src/Screen.cc b/src/Screen.cc index d27f8c4..a74ba0e 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -525,12 +525,6 @@ BScreen::BScreen(FbTk::ResourceManager &rm, // and after we've load the resources // else we get some bad handle/grip height/width // FbTk::ThemeManager::instance().loadTheme(*m_windowtheme.get()); - //!! TODO: For some strange reason we must load everything, - // else the focus label doesn't get updated - // This must be fixed in the future. - FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename(), - fluxbox->getStyleOverlayFilename(), - m_root_theme->screenNum()); m_root_theme->setLineAttributes(*resource.gc_line_width, *resource.gc_line_style, *resource.gc_cap_style, diff --git a/src/SlitTheme.cc b/src/SlitTheme.cc index a9d1a07..7f2081b 100644 --- a/src/SlitTheme.cc +++ b/src/SlitTheme.cc @@ -34,6 +34,7 @@ SlitTheme::SlitTheme(int screen_num):FbTk::Theme(screen_num), m_border_color.setDefaultValue(); // default texture type m_texture->setType(FbTk::Texture::SOLID); + FbTk::ThemeManager::instance().loadTheme(*this); } diff --git a/src/ToolTheme.cc b/src/ToolTheme.cc index 61710ec..2432655 100644 --- a/src/ToolTheme.cc +++ b/src/ToolTheme.cc @@ -31,6 +31,7 @@ ToolTheme::ToolTheme(int screen_num, const std::string &name, const std::string m_border(*this, name, altname), m_alpha(255) { + FbTk::ThemeManager::instance().loadTheme(*this); } ToolTheme::~ToolTheme() { diff --git a/src/ToolbarTheme.cc b/src/ToolbarTheme.cc index a9f1c1c..8cadb02 100644 --- a/src/ToolbarTheme.cc +++ b/src/ToolbarTheme.cc @@ -42,6 +42,7 @@ ToolbarTheme::ToolbarTheme(int screen_num): *m_shape = false; *m_height = 0; *m_button_size = -1; + FbTk::ThemeManager::instance().loadTheme(*this); } ToolbarTheme::~ToolbarTheme() { diff --git a/src/WinButtonTheme.cc b/src/WinButtonTheme.cc index ac6d5f7..6c7003e 100644 --- a/src/WinButtonTheme.cc +++ b/src/WinButtonTheme.cc @@ -58,6 +58,7 @@ WinButtonTheme::WinButtonTheme(int screen_num, FbWinFrameTheme &frame_theme): m_stuck_unfocus_pm(*this, "window.stuck.unfocus.pixmap", "Window.Stuck.Unfocus.Pixmap"), m_frame_theme(frame_theme) { + FbTk::ThemeManager::instance().loadTheme(*this); } WinButtonTheme::~WinButtonTheme() { diff --git a/src/fluxbox.cc b/src/fluxbox.cc index d22f496..29b3509 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -318,6 +318,9 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile #endif // HAVE_GETPID + // setup theme manager to have our style file ready to be scanned + FbTk::ThemeManager::instance().load(getStyleFilename(), getStyleOverlayFilename()); + // Create keybindings handler and load keys file // Note: this needs to be done before creating screens m_key.reset(new Keys); @@ -410,9 +413,6 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile XAllowEvents(disp, ReplayPointer, CurrentTime); - // setup theme manager to have our style file ready to be scanned - FbTk::ThemeManager::instance().load(getStyleFilename(), getStyleOverlayFilename()); - //XSynchronize(disp, False); sync(false); -- cgit v0.11.2