diff -abBpur -N fluxbox/src/Makefile.am fb-wallpapermenu/src/Makefile.am --- fluxbox/src/Makefile.am 2004-08-12 23:04:06.677729576 +0200 +++ fb-wallpapermenu/src/Makefile.am 2004-08-12 23:03:06.190924968 +0200 @@ -107,6 +107,7 @@ fluxbox_SOURCES = AtomHandler.hh ArrowBu CompareWindow.hh \ Parser.hh Parser.cc FbMenuParser.hh FbMenuParser.cc \ StyleMenuItem.hh StyleMenuItem.cc \ + RootCmdMenuItem.hh RootCmdMenuItem.cc\ MenuCreator.hh MenuCreator.cc \ IconMenu.hh IconMenu.cc \ WorkspaceMenu.hh WorkspaceMenu.cc \ diff -abBpur -N fluxbox/src/MenuCreator.cc fb-wallpapermenu/src/MenuCreator.cc --- fluxbox/src/MenuCreator.cc 2004-08-12 23:04:06.677729576 +0200 +++ fb-wallpapermenu/src/MenuCreator.cc 2004-08-12 23:02:15.489632736 +0200 @@ -38,6 +38,7 @@ #include "FbMenuParser.hh" #include "StyleMenuItem.hh" +#include "RootCmdMenuItem.hh" #include "FbTk/I18n.hh" #include "FbTk/MultiButtonMenuItem.hh" @@ -92,6 +93,42 @@ static void createStyleMenu(FbTk::Menu & } +static void createRootCmdMenu(FbTk::Menu &parent, const string &label, + const string &directory, const string &cmd) { + // perform shell style ~ home directory expansion + string rootcmddir(FbTk::StringUtil::expandFilename(directory)); + + if (!FbTk::Directory::isDirectory(rootcmddir)) + return; + + FbTk::Directory dir(rootcmddir.c_str()); + + // create a vector of all the filenames in the directory + // add sort it + vector filelist(dir.entries()); + for (size_t file_index = 0; file_index < dir.entries(); ++file_index) + filelist[file_index] = dir.readFilename(); + + sort(filelist.begin(), filelist.end(), less()); + + // for each file in directory add filename and path to menu + for (size_t file_index = 0; file_index < dir.entries(); file_index++) { + + string rootcmd(rootcmddir+ '/' + filelist[file_index]); + // add to menu only if the file is a regular file, and not a + // .file or a backup~ file + if ((FbTk::Directory::isRegularFile(rootcmd) && + (filelist[file_index][0] != '.') && + (rootcmd[rootcmd.length() - 1] != '~'))) + parent.insert(new RootCmdMenuItem(filelist[file_index], rootcmd, cmd)); + } + // update menu graphics + parent.update(); + Fluxbox::instance()->saveMenuFilename(rootcmddir.c_str()); + +} + + class ParseItem { public: explicit ParseItem(FbTk::Menu *menu):m_menu(menu) {} @@ -164,8 +201,7 @@ static void translateMenuItem(Parser &pa exec_and_hide->add(exec_cmd); RefCount exec_and_hide_cmd(exec_and_hide); menu.insert(str_label.c_str(), exec_and_hide_cmd); - } - else if (str_key == "style") { // style + } else if (str_key == "style") { // style menu.insert(new StyleMenuItem(str_label, str_cmd)); } else if (str_key == "config") { BScreen *screen = Fluxbox::instance()->findScreen(screen_number); @@ -218,8 +254,11 @@ static void translateMenuItem(Parser &pa } else if (str_key == "stylesdir" || str_key == "stylesmenu") { createStyleMenu(menu, str_label, str_key == "stylesmenu" ? str_cmd : str_label); - } // end of stylesdir - else if (str_key == "workspaces") { + } else if (str_key == "wallpapers" || str_key == "wallpapermenu" || + str_key == "rootcommands") { + createRootCmdMenu(menu, str_label, str_label, + str_cmd == "" ? "fbsetbg" : str_cmd); + } else if (str_key == "workspaces") { BScreen *screen = Fluxbox::instance()->findScreen(screen_number); if (screen != 0) { screen->getWorkspacemenu().setInternalMenu(); diff -abBpur -N fluxbox/src/RootCmdMenuItem.cc fb-wallpapermenu/src/RootCmdMenuItem.cc --- fluxbox/src/RootCmdMenuItem.cc 1970-01-01 01:00:00.000000000 +0100 +++ fb-wallpapermenu/src/RootCmdMenuItem.cc 2004-08-12 23:02:15.489632736 +0200 @@ -0,0 +1,48 @@ +// RootCmdMenuItem.cc for Fluxbox Window Manager +// Copyright (c) 2004 Mathias Gumz +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// 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: RootCmdMenuItem.cc,v $ + +#include "RootCmdMenuItem.hh" + +#include "FbCommands.hh" +#include "fluxbox.hh" + +#include "FbTk/StringUtil.hh" + +RootCmdMenuItem::RootCmdMenuItem(const std::string &label, + const std::string &filename, + const std::string &cmd): + FbTk::MenuItem(label.c_str()), + m_filename(filename) { + + FbTk::RefCount + setwp_cmd(new FbCommands:: + ExecuteCmd(cmd + " " + m_filename)); + setCommand(setwp_cmd); + setToggleItem(true); +} + + +bool RootCmdMenuItem::isSelected() const { + return Fluxbox::instance()->getStyleFilename() == m_filename; +} + diff -abBpur -N fluxbox/src/RootCmdMenuItem.hh fb-wallpapermenu/src/RootCmdMenuItem.hh --- fluxbox/src/RootCmdMenuItem.hh 1970-01-01 01:00:00.000000000 +0100 +++ fb-wallpapermenu/src/RootCmdMenuItem.hh 2004-08-12 23:02:15.489632736 +0200 @@ -0,0 +1,40 @@ +// RootCmdMenuItem.hh for Fluxbox Window Manager +// Copyright (c) 2004 Mathias Gumz +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// 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: $ + +#ifndef ROOTCMDMENUITEM_HH +#define ROOTCMDMENUITEM_HH + +#include "FbTk/MenuItem.hh" +#include + +class RootCmdMenuItem: public FbTk::MenuItem { +public: + RootCmdMenuItem(const std::string &label, + const std::string &filename, + const std::string &cmd = "fbsetbg"); + bool isSelected() const; +private: + const std::string m_filename; +}; + +#endif // ROOTCMDMENUITEM_HH