From 199123d5fd668b5adcfef29ffaa172d322f65368 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 13 Jul 2011 15:05:42 +0200 Subject: Attach a modifiedSig handler to the session.styleFile resource --- src/FbCommands.cc | 10 +++------- src/RootCmdMenuItem.cc | 3 ++- src/Screen.cc | 5 ----- src/StyleMenuItem.cc | 2 +- src/fluxbox.cc | 8 +++++--- src/fluxbox.hh | 5 +++-- 6 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/FbCommands.cc b/src/FbCommands.cc index 119f378..683c3b9 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc @@ -246,8 +246,8 @@ void ReconfigureFluxboxCmd::execute() { REGISTER_COMMAND(reloadstyle, FbCommands::ReloadStyleCmd, void); void ReloadStyleCmd::execute() { - SetStyleCmd cmd(Fluxbox::instance()->getStyleFilename()); - cmd.execute(); + // setting the value will trigger a reload + *Fluxbox::instance()->getStyleResource() = *Fluxbox::instance()->getStyleResource(); } REGISTER_COMMAND_WITH_ARGS(setstyle, FbCommands::SetStyleCmd, void); @@ -257,11 +257,7 @@ SetStyleCmd::SetStyleCmd(const string &filename):m_filename(filename) { } void SetStyleCmd::execute() { - if (FbTk::ThemeManager::instance().load(m_filename, - Fluxbox::instance()->getStyleOverlayFilename())) { - Fluxbox::instance()->saveStyleFilename(m_filename.c_str()); - Fluxbox::instance()->save_rc(); - } + *Fluxbox::instance()->getStyleResource() = m_filename; } REGISTER_COMMAND_WITH_ARGS(keymode, FbCommands::KeyModeCmd, void); diff --git a/src/RootCmdMenuItem.cc b/src/RootCmdMenuItem.cc index c3642ee..ce6d24a 100644 --- a/src/RootCmdMenuItem.cc +++ b/src/RootCmdMenuItem.cc @@ -43,6 +43,7 @@ RootCmdMenuItem::RootCmdMenuItem(const FbTk::FbString &label, bool RootCmdMenuItem::isSelected() const { - return Fluxbox::instance()->getStyleFilename() == m_filename; + // XXX how do we find out which is the current background? + return false; } diff --git a/src/Screen.cc b/src/Screen.cc index ff7b1b3..97ebffa 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -865,11 +865,6 @@ void BScreen::reconfigure() { // notify objects that the screen is reconfigured m_reconfigure_sig.emit(*this); - // Reload style - FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename(), - fluxbox->getStyleOverlayFilename(), - m_root_theme->screenNum()); - reconfigureTabs(); } diff --git a/src/StyleMenuItem.cc b/src/StyleMenuItem.cc index 8e557a7..348d3c1 100644 --- a/src/StyleMenuItem.cc +++ b/src/StyleMenuItem.cc @@ -42,6 +42,6 @@ StyleMenuItem::StyleMenuItem(const FbTk::FbString &label, const std::string &fil bool StyleMenuItem::isSelected() const { - return Fluxbox::instance()->getStyleFilename() == m_filename; + return Fluxbox::instance()->getStyleResource().get() == m_filename; } diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 37eb0e1..22dfbe3 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -331,6 +331,7 @@ Fluxbox::Fluxbox(int argc, char **argv, #endif // HAVE_RANDR join(m_rc_pseudotrans.modifiedSig(), &FbTk::Transparent::usePseudoTransparent); + join(m_rc_stylefile.modifiedSig(), MemFunIgnoreArgs(*this, &Fluxbox::styleChanged)); load_rc(); grab(); @@ -351,9 +352,6 @@ Fluxbox::Fluxbox(int argc, char **argv, #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); @@ -1010,6 +1008,10 @@ void Fluxbox::windowLayerChanged(FluxboxWindow &win) { CallMemFunWithRefArg(&AtomHandler::updateLayer, win)); } +void Fluxbox::styleChanged() { + FbTk::ThemeManager::instance().load(*getStyleResource(), getStyleOverlayFilename()); +} + void Fluxbox::attachSignals(FluxboxWindow &win) { join(win.stateSig(), FbTk::MemFun(*this, &Fluxbox::windowStateChanged)); join(win.workspaceSig(), FbTk::MemFun(*this, &Fluxbox::windowWorkspaceChanged)); diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 47ab834..78ce093 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -117,7 +117,7 @@ public: FbTk::BoolResource &getPseudoTransResource() { return m_rc_pseudotrans; } Fluxbox::TabsAttachArea getTabsAttachArea() const { return *m_rc_tabs_attach_area; } - const std::string &getStyleFilename() const { return *m_rc_stylefile; } + FbTk::StringResource &getStyleResource() { return m_rc_stylefile; } const std::string &getStyleOverlayFilename() const { return *m_rc_styleoverlayfile; } const std::string &getMenuFilename() const { return *m_rc_menufile; } @@ -138,7 +138,6 @@ public: void shutdown(); void load_rc(BScreen &scr); - void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); } void saveWindowSearch(Window win, WinClient *winclient); // some windows relate to the group, not the client, so we record separately // searchWindow on these windows will give the active client in the group @@ -225,6 +224,8 @@ private: void windowStateChanged(FluxboxWindow &win); /// Called when a window layer changes void windowLayerChanged(FluxboxWindow &win); + /// Called when a style (or it's overlay) changes + void styleChanged(); std::auto_ptr m_l; std::auto_ptr m_fbatoms; -- cgit v0.11.2