added [wallpapers|rootcommands] to menuitems
This commit is contained in:
parent
680128f286
commit
dc836d2b78
4 changed files with 340 additions and 209 deletions
|
@ -20,7 +20,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: MenuCreator.cc,v 1.12 2004/08/29 12:35:29 rathnor Exp $
|
||||
// $Id: MenuCreator.cc,v 1.13 2004/08/29 21:11:24 akir Exp $
|
||||
|
||||
#include "MenuCreator.hh"
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "FbMenuParser.hh"
|
||||
#include "StyleMenuItem.hh"
|
||||
#include "RootCmdMenuItem.hh"
|
||||
|
||||
#include "FbTk/I18n.hh"
|
||||
#include "FbTk/MultiButtonMenuItem.hh"
|
||||
|
@ -93,6 +94,42 @@ static void createStyleMenu(FbTk::Menu &parent, const std::string &label,
|
|||
|
||||
}
|
||||
|
||||
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<string> 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<string>());
|
||||
|
||||
// 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) {}
|
||||
|
@ -165,8 +202,7 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem) {
|
|||
exec_and_hide->add(exec_cmd);
|
||||
RefCount<Command> 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);
|
||||
|
@ -224,7 +260,11 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem) {
|
|||
createStyleMenu(menu, str_label,
|
||||
str_key == "themesmenu" ? str_cmd : str_label);
|
||||
} // end of themesdir
|
||||
|
||||
else if (str_key == "wallpapers" || str_key == "wallpapermenu" ||
|
||||
str_key == "rootcommands") {
|
||||
createRootCmdMenu(menu, str_label, str_label,
|
||||
str_cmd == "" ? "fbsetbg" : str_cmd);
|
||||
} // end of wallpapers
|
||||
else if (str_key == "workspaces") {
|
||||
BScreen *screen = Fluxbox::instance()->findScreen(screen_number);
|
||||
if (screen != 0) {
|
||||
|
|
47
src/RootCmdMenuItem.cc
Normal file
47
src/RootCmdMenuItem.cc
Normal file
|
@ -0,0 +1,47 @@
|
|||
// 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 1.1 2004/08/29 21:11:24 akir Exp $
|
||||
|
||||
#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<FbTk::Command>
|
||||
setwp_cmd(new FbCommands::ExecuteCmd(cmd + " \"" + m_filename + "\""));
|
||||
setCommand(setwp_cmd);
|
||||
setToggleItem(true);
|
||||
}
|
||||
|
||||
|
||||
bool RootCmdMenuItem::isSelected() const {
|
||||
return Fluxbox::instance()->getStyleFilename() == m_filename;
|
||||
}
|
||||
|
40
src/RootCmdMenuItem.hh
Normal file
40
src/RootCmdMenuItem.hh
Normal file
|
@ -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: RootCmdMenuItem.hh,v 1.1 2004/08/29 21:11:24 akir Exp $
|
||||
|
||||
#ifndef ROOTCMDMENUITEM_HH
|
||||
#define ROOTCMDMENUITEM_HH
|
||||
|
||||
#include "FbTk/MenuItem.hh"
|
||||
#include <string>
|
||||
|
||||
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
|
Loading…
Reference in a new issue