From d919892957f000bce5d492361a3d137ea022c09f Mon Sep 17 00:00:00 2001 From: fluxgen Date: Thu, 3 Jul 2003 13:57:58 +0000 Subject: added visual enable thing for style menus so one can see which style is currently selected --- src/Screen.cc | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/Screen.cc b/src/Screen.cc index 5a62820..54432b3 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.199 2003/07/01 12:39:09 fluxgen Exp $ +// $Id: Screen.cc,v 1.200 2003/07/03 13:57:58 fluxgen Exp $ #include "Screen.hh" @@ -178,6 +178,25 @@ private: namespace { +class StyleMenuItem: public FbTk::MenuItem { +public: + StyleMenuItem(const std::string &label, const std::string &filename):FbTk::MenuItem(label.c_str()), + m_filename(FbTk::StringUtil:: + expandFilename(filename)) { + // perform shell style ~ home directory expansion + // and insert style + FbTk::RefCount + setstyle_cmd(new FbCommands:: + SetStyleCmd(m_filename)); + setCommand(setstyle_cmd); + } + bool isSelected() const { + return Fluxbox::instance()->getStyleFilename() == m_filename; + } +private: + const std::string m_filename; +}; + class AddWorkspaceCmd:public FbTk::Command { public: explicit AddWorkspaceCmd(BScreen &scrn):m_screen(scrn) { } @@ -1745,21 +1764,13 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) { if (!( str_label.size() && str_cmd.size())) { fprintf(stderr, i18n-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenSTYLEError, + getMessage(FBNLS::ScreenSet, FBNLS::ScreenSTYLEError, "BScreen::parseMenuFile: [style] error, " "no menu label and/or filename defined\n")); cerr<<"Row: "< - setstyle_cmd(new FbCommands:: - SetStyleCmd(FbTk::StringUtil:: - expandFilename(str_cmd))); - menu.insert(str_label.c_str(), setstyle_cmd); - - } + } else + menu.insert(new StyleMenuItem(str_label, str_cmd)); + } else if (str_key == "config") { if (! str_label.size()) { fprintf(stderr, @@ -2055,9 +2066,8 @@ void BScreen::createStyleMenu(FbTk::Menu &menu, strncpy(style + slen + 1, filelist[file_index].c_str(), nlen + 1); if ( !stat(style, &statbuf) && S_ISREG(statbuf.st_mode)) { - FbTk::RefCount setstyle_cmd(new FbCommands:: - SetStyleCmd(style)); - menu.insert(filelist[file_index].c_str(), setstyle_cmd); + FbTk::MenuItem *item = new StyleMenuItem(filelist[file_index], style); + menu.insert(item); } } // update menu graphics -- cgit v0.11.2