diff --git a/src/AttentionNoticeHandler.cc b/src/AttentionNoticeHandler.cc index f8aafdea..999b9d4e 100644 --- a/src/AttentionNoticeHandler.cc +++ b/src/AttentionNoticeHandler.cc @@ -30,7 +30,7 @@ #include "FbTk/Resource.hh" namespace { -class ToggleFrameFocusCmd: public FbTk::Command { +class ToggleFrameFocusCmd: public FbTk::Command { public: ToggleFrameFocusCmd(Focusable &client): m_client(client), @@ -82,7 +82,7 @@ void AttentionNoticeHandler::addAttention(Focusable &client) { timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = **timeout_res * 1000; - RefCount cmd(new ToggleFrameFocusCmd(client)); + RefCount > cmd(new ToggleFrameFocusCmd(client)); timer->setCommand(cmd); timer->setTimeout(timeout); timer->fireOnce(false); // will repeat until window has focus diff --git a/src/ClockTool.cc b/src/ClockTool.cc index adc6adc9..ae782661 100644 --- a/src/ClockTool.cc +++ b/src/ClockTool.cc @@ -24,7 +24,7 @@ #include "ToolTheme.hh" #include "Screen.hh" -#include "FbTk/ObjectRegistry.hh" +#include "FbTk/CommandParser.hh" #include "CommandDialog.hh" #include "fluxbox.hh" @@ -116,7 +116,7 @@ private: ClockTool &m_tool; }; -class EditClockFormatCmd: public FbTk::Command { +class EditClockFormatCmd: public FbTk::Command { public: void execute() { BScreen *screen = Fluxbox::instance()->mouseScreen(); @@ -126,7 +126,7 @@ public: CommandDialog *dialog = new CommandDialog(*screen, "Edit Clock Format", "SetResourceValue " + resourcename + " "); - FbTk::RefCount cmd(FbTk::ObjectRegistry::instance().parse("reconfigure")); + FbTk::RefCount > cmd(FbTk::CommandParser::instance().parse("reconfigure")); dialog->setPostCommand(cmd); dialog->setText(screen->resourceManager().resourceValue(resourcename)); dialog->show(); @@ -160,7 +160,7 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent, // if nothing has changed, it wont update the graphics m_timer.setInterval(1); // m_timer.setTimeout(delay); // don't need to set timeout on interval timer - FbTk::RefCount update_graphic(new FbTk::SimpleCommand(*this, + FbTk::RefCount > update_graphic(new FbTk::SimpleCommand(*this, &ClockTool::updateTime)); m_timer.setCommand(update_graphic); m_timer.start(); @@ -168,11 +168,11 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent, m_button.setGC(m_theme->textGC()); // setup menu - FbTk::RefCount saverc(FbTk::ObjectRegistry::instance().parse("saverc")); + FbTk::RefCount > saverc(FbTk::CommandParser::instance().parse("saverc")); FbTk::MenuItem *item = new ClockMenuItem(*this); item->setCommand(saverc); menu.insert(item); - FbTk::RefCount editformat_cmd(new EditClockFormatCmd()); + FbTk::RefCount > editformat_cmd(new EditClockFormatCmd()); menu.insert(_FB_XTEXT(Toolbar, ClockEditFormat, "Edit Clock Format", "edit Clock Format") , editformat_cmd); diff --git a/src/CommandDialog.cc b/src/CommandDialog.cc index 1c9005e3..346a1a44 100644 --- a/src/CommandDialog.cc +++ b/src/CommandDialog.cc @@ -25,7 +25,7 @@ #include "Screen.hh" #include "FbWinFrameTheme.hh" #include "WinClient.hh" -#include "FbTk/ObjectRegistry.hh" +#include "FbTk/CommandParser.hh" #include "FocusControl.hh" #include "fluxbox.hh" @@ -136,8 +136,8 @@ void CommandDialog::keyPressEvent(XKeyEvent &event) { if (ks == XK_Return) { hide(); // hide and return focus to a FluxboxWindow - // create command from line - auto_ptr cmd(FbTk::ObjectRegistry::instance().parse(m_precommand + m_textbox.text())); + // create Command from line + auto_ptr > cmd(FbTk::CommandParser::instance().parse(m_precommand + m_textbox.text())); if (cmd.get()) cmd->execute(); // post execute @@ -167,8 +167,8 @@ void CommandDialog::tabComplete() { return; } - FbTk::ObjectRegistry::CreatorMap::const_iterator it = FbTk::ObjectRegistry::instance().creatorMap().begin(); - const FbTk::ObjectRegistry::CreatorMap::const_iterator it_end = FbTk::ObjectRegistry::instance().creatorMap().end(); + FbTk::ObjectRegistry::Creator *>::CreatorMap::const_iterator it = FbTk::ObjectRegistry::Creator *>::instance().creatorMap().begin(); + const FbTk::ObjectRegistry::Creator *>::CreatorMap::const_iterator it_end = FbTk::ObjectRegistry::Creator *>::instance().creatorMap().end(); vector matches; for (; it != it_end; ++it) { if ((*it).first.find(prefix) == 0) { diff --git a/src/CommandDialog.hh b/src/CommandDialog.hh index 9f102b9b..bd0a6df3 100644 --- a/src/CommandDialog.hh +++ b/src/CommandDialog.hh @@ -44,10 +44,10 @@ public: /// Sets the entry text. void setText(const std::string &text); /** - * Sets the command to be execute after the command is done. + * Sets the command to be executed after the command is done. * @param postcommand the command. */ - void setPostCommand(FbTk::RefCount &postcommand) { + void setPostCommand(FbTk::RefCount > &postcommand) { m_postcommand = postcommand; } void show(); @@ -71,11 +71,13 @@ private: FbTk::TextBox m_textbox; //< entry field FbTk::TextButton m_label; //< text in the titlebar FbTk::GContext m_gc; - FbTk::RefCount m_postcommand; ///< command to do after the first command was issued (like reconfigure) + /// command to do after the first command was issued (like reconfigure) + FbTk::RefCount > m_postcommand; BScreen &m_screen; int m_move_x, m_move_y; Pixmap m_pixmap; - const std::string m_precommand; ///< command to be used before the text (usefull for setting workspace name) + /// command to be used before the text (usefull for setting workspace name) + const std::string m_precommand; }; diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc index f08112be..4c027d9f 100644 --- a/src/CurrentWindowCmd.cc +++ b/src/CurrentWindowCmd.cc @@ -29,7 +29,7 @@ #include "WinClient.hh" #include "FocusControl.hh" -#include "FbTk/ObjectRegistry.hh" +#include "FbTk/CommandParser.hh" #include "FbTk/stringstream.hh" #include "FbTk/StringUtil.hh" @@ -37,7 +37,7 @@ using FbTk::Command; namespace { -FbTk::Command *createCurrentWindowCmd(const std::string &command, +FbTk::Command *createCurrentWindowCmd(const std::string &command, const std::string &args, bool trusted) { if (command == "minimizewindow" || command == "minimize" || command == "iconify") return new CurrentWindowCmd(&FluxboxWindow::iconify); @@ -86,35 +86,35 @@ FbTk::Command *createCurrentWindowCmd(const std::string &command, return 0; } -REGISTER_OBJECT_PARSER(minimizewindow, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(minimize, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(iconify, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(maximizewindow, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(maximize, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(maximizevertical, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(maximizehorizontal, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(raise, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(raiselayer, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(lower, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(lowerlayer, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(activate, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(focus, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(close, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(killwindow, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(kill, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(shade, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(shadewindow, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(shadeon, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(shadeoff, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(stick, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(stickwindow, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(toggledecor, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(nexttab, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(prevtab, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(movetableft, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(movetabright, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(detachclient, createCurrentWindowCmd, Command); -REGISTER_OBJECT_PARSER(windowmenu, createCurrentWindowCmd, Command); +REGISTER_COMMAND_PARSER(minimizewindow, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(minimize, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(iconify, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(maximizewindow, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(maximize, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(maximizevertical, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(maximizehorizontal, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(raise, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(raiselayer, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(lower, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(lowerlayer, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(activate, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(focus, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(close, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(killwindow, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(kill, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(shade, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(shadewindow, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(shadeon, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(shadeoff, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(stick, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(stickwindow, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(toggledecor, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(nexttab, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(prevtab, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(movetableft, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(movetabright, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(detachclient, createCurrentWindowCmd, void); +REGISTER_COMMAND_PARSER(windowmenu, createCurrentWindowCmd, void); }; // end anonymous namespace @@ -130,7 +130,7 @@ FluxboxWindow &WindowHelperCmd::fbwindow() { return *FocusControl::focusedFbWindow(); } -bool WindowHelperBoolCmd::bool_execute() { +bool WindowHelperBoolCmd::execute() { if (WindowCmd::window() || FocusControl::focusedFbWindow()) return real_execute(); return false; @@ -156,7 +156,7 @@ void CurrentWindowCmd::real_execute() { namespace { -FbTk::Command *parseIntCmd(const string &command, const string &args, +FbTk::Command *parseIntCmd(const string &command, const string &args, bool trusted) { int num = (command == "sethead" ? 0 : 1); FbTk_istringstream iss(args.c_str()); @@ -181,14 +181,14 @@ FbTk::Command *parseIntCmd(const string &command, const string &args, return 0; } -REGISTER_OBJECT_PARSER(sethead, parseIntCmd, Command); -REGISTER_OBJECT_PARSER(tab, parseIntCmd, Command); -REGISTER_OBJECT_PARSER(sendtonextworkspace, parseIntCmd, Command); -REGISTER_OBJECT_PARSER(sendtoprevworkspace, parseIntCmd, Command); -REGISTER_OBJECT_PARSER(taketonextworkspace, parseIntCmd, Command); -REGISTER_OBJECT_PARSER(taketoprevworkspace, parseIntCmd, Command); -REGISTER_OBJECT_PARSER(sendtoworkspace, parseIntCmd, Command); -REGISTER_OBJECT_PARSER(taketoworkspace, parseIntCmd, Command); +REGISTER_COMMAND_PARSER(sethead, parseIntCmd, void); +REGISTER_COMMAND_PARSER(tab, parseIntCmd, void); +REGISTER_COMMAND_PARSER(sendtonextworkspace, parseIntCmd, void); +REGISTER_COMMAND_PARSER(sendtoprevworkspace, parseIntCmd, void); +REGISTER_COMMAND_PARSER(taketonextworkspace, parseIntCmd, void); +REGISTER_COMMAND_PARSER(taketoprevworkspace, parseIntCmd, void); +REGISTER_COMMAND_PARSER(sendtoworkspace, parseIntCmd, void); +REGISTER_COMMAND_PARSER(taketoworkspace, parseIntCmd, void); }; // end anonymous namespace @@ -251,7 +251,7 @@ void GoToTabCmd::real_execute() { (*it)->focus(); } -REGISTER_OBJECT(startmoving, StartMovingCmd, Command); +REGISTER_COMMAND(startmoving, StartMovingCmd, void); void StartMovingCmd::real_execute() { const XEvent &last = Fluxbox::instance()->lastEvent(); @@ -261,7 +261,7 @@ void StartMovingCmd::real_execute() { } } -FbTk::Command *StartResizingCmd::parse(const string &cmd, const string &args, +FbTk::Command *StartResizingCmd::parse(const string &cmd, const string &args, bool trusted) { FluxboxWindow::ResizeModel mode = FluxboxWindow::DEFAULTRESIZE; std::vector tokens; @@ -294,7 +294,7 @@ FbTk::Command *StartResizingCmd::parse(const string &cmd, const string &args, return new StartResizingCmd(mode); } -REGISTER_OBJECT_PARSER(startresizing, StartResizingCmd::parse, Command); +REGISTER_COMMAND_PARSER(startresizing, StartResizingCmd::parse, void); void StartResizingCmd::real_execute() { const XEvent &last = Fluxbox::instance()->lastEvent(); @@ -308,7 +308,7 @@ void StartResizingCmd::real_execute() { } } -REGISTER_OBJECT(starttabbing, StartTabbingCmd, Command); +REGISTER_COMMAND(starttabbing, StartTabbingCmd, void); void StartTabbingCmd::real_execute() { const XEvent &last = Fluxbox::instance()->lastEvent(); @@ -318,7 +318,7 @@ void StartTabbingCmd::real_execute() { } } -FbTk::Command *MoveCmd::parse(const string &command, const string &args, +FbTk::Command *MoveCmd::parse(const string &command, const string &args, bool trusted) { FbTk_istringstream is(args.c_str()); int dx = 0, dy = 0; @@ -339,11 +339,11 @@ FbTk::Command *MoveCmd::parse(const string &command, const string &args, return new MoveCmd(dx, dy); } -REGISTER_OBJECT_PARSER(move, MoveCmd::parse, Command); -REGISTER_OBJECT_PARSER(moveright, MoveCmd::parse, Command); -REGISTER_OBJECT_PARSER(moveleft, MoveCmd::parse, Command); -REGISTER_OBJECT_PARSER(moveup, MoveCmd::parse, Command); -REGISTER_OBJECT_PARSER(movedown, MoveCmd::parse, Command); +REGISTER_COMMAND_PARSER(move, MoveCmd::parse, void); +REGISTER_COMMAND_PARSER(moveright, MoveCmd::parse, void); +REGISTER_COMMAND_PARSER(moveleft, MoveCmd::parse, void); +REGISTER_COMMAND_PARSER(moveup, MoveCmd::parse, void); +REGISTER_COMMAND_PARSER(movedown, MoveCmd::parse, void); MoveCmd::MoveCmd(const int step_size_x, const int step_size_y) : m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } @@ -354,7 +354,7 @@ void MoveCmd::real_execute() { fbwindow().y() + m_step_size_y); } -FbTk::Command *ResizeCmd::parse(const string &command, const string &args, +FbTk::Command *ResizeCmd::parse(const string &command, const string &args, bool trusted) { FbTk_istringstream is(args.c_str()); int dx = 0, dy = 0; @@ -371,10 +371,10 @@ FbTk::Command *ResizeCmd::parse(const string &command, const string &args, return new ResizeCmd(dx, dy); } -REGISTER_OBJECT_PARSER(resize, ResizeCmd::parse, Command); -REGISTER_OBJECT_PARSER(resizeto, ResizeCmd::parse, Command); -REGISTER_OBJECT_PARSER(resizehorizontal, ResizeCmd::parse, Command); -REGISTER_OBJECT_PARSER(resizevertical, ResizeCmd::parse, Command); +REGISTER_COMMAND_PARSER(resize, ResizeCmd::parse, void); +REGISTER_COMMAND_PARSER(resizeto, ResizeCmd::parse, void); +REGISTER_COMMAND_PARSER(resizehorizontal, ResizeCmd::parse, void); +REGISTER_COMMAND_PARSER(resizevertical, ResizeCmd::parse, void); ResizeCmd::ResizeCmd(const int step_size_x, const int step_size_y) : m_step_size_x(step_size_x), m_step_size_y(step_size_y) { } @@ -390,7 +390,7 @@ void ResizeCmd::real_execute() { fbwindow().resize(w, h); } -FbTk::Command *MoveToCmd::parse(const string &cmd, const string &args, +FbTk::Command *MoveToCmd::parse(const string &cmd, const string &args, bool trusted) { typedef std::vector StringTokens; StringTokens tokens; @@ -435,7 +435,7 @@ FbTk::Command *MoveToCmd::parse(const string &cmd, const string &args, } -REGISTER_OBJECT_PARSER(moveto, MoveToCmd::parse, Command); +REGISTER_COMMAND_PARSER(moveto, MoveToCmd::parse, void); MoveToCmd::MoveToCmd(const int step_size_x, const int step_size_y, const unsigned int refc) : m_step_size_x(step_size_x), m_step_size_y(step_size_y), m_refc(refc) { } @@ -472,14 +472,14 @@ void ResizeToCmd::real_execute() { fbwindow().resize(m_step_size_x, m_step_size_y); } -REGISTER_OBJECT(fullscreen, FullscreenCmd, Command); +REGISTER_COMMAND(fullscreen, FullscreenCmd, void); FullscreenCmd::FullscreenCmd() { } void FullscreenCmd::real_execute() { fbwindow().setFullscreen(!fbwindow().isFullscreen()); } -FbTk::Command *SetAlphaCmd::parse(const string &command, const string &args, +FbTk::Command *SetAlphaCmd::parse(const string &command, const string &args, bool trusted) { typedef std::vector StringTokens; StringTokens tokens; @@ -504,7 +504,7 @@ FbTk::Command *SetAlphaCmd::parse(const string &command, const string &args, return new SetAlphaCmd(focused, relative, unfocused, un_rel); } -REGISTER_OBJECT_PARSER(setalpha, SetAlphaCmd::parse, Command); +REGISTER_COMMAND_PARSER(setalpha, SetAlphaCmd::parse, void); SetAlphaCmd::SetAlphaCmd(int focused, bool relative, int unfocused, bool un_relative) : @@ -536,7 +536,7 @@ void SetAlphaCmd::real_execute() { fbwindow().setUnfocusedAlpha(m_unfocus); } -REGISTER_OBJECT_WITH_ARGS_NSBASE(matches, MatchCmd, FbTk, BoolCommand); +REGISTER_COMMAND_WITH_ARGS(matches, MatchCmd, bool); bool MatchCmd::real_execute() { return m_pat.match(winclient()); diff --git a/src/CurrentWindowCmd.hh b/src/CurrentWindowCmd.hh index 6b4359a8..157855cc 100644 --- a/src/CurrentWindowCmd.hh +++ b/src/CurrentWindowCmd.hh @@ -29,7 +29,7 @@ /// helper class for window commands /// calls real_execute if there's a focused window or a window in button press/release window -class WindowHelperCmd: public FbTk::Command { +class WindowHelperCmd: public FbTk::Command { public: explicit WindowHelperCmd() { } @@ -40,11 +40,11 @@ protected: virtual void real_execute() = 0; }; -class WindowHelperBoolCmd: public FbTk::BoolCommand { +class WindowHelperBoolCmd: public FbTk::Command { public: explicit WindowHelperBoolCmd() { } - bool bool_execute(); + bool execute(); protected: FluxboxWindow &fbwindow(); @@ -149,7 +149,7 @@ protected: class StartResizingCmd: public WindowHelperCmd { public: explicit StartResizingCmd(FluxboxWindow::ResizeModel mode):m_mode(mode) { } - static FbTk::Command *parse(const std::string &command, + static FbTk::Command *parse(const std::string &command, const std::string &args, bool trusted); protected: void real_execute(); @@ -169,7 +169,7 @@ protected: class MoveCmd: public WindowHelperCmd { public: explicit MoveCmd(const int step_size_x, const int step_size_y); - static FbTk::Command *parse(const std::string &command, + static FbTk::Command *parse(const std::string &command, const std::string &args, bool trusted); protected: void real_execute(); @@ -183,7 +183,7 @@ private: class ResizeCmd: public WindowHelperCmd{ public: explicit ResizeCmd(int step_size_x, int step_size_y); - static FbTk::Command *parse(const std::string &command, + static FbTk::Command *parse(const std::string &command, const std::string &args, bool trusted); protected: void real_execute(); @@ -206,7 +206,7 @@ public: IGNORE_Y = 1 << 9 }; explicit MoveToCmd(const int step_size_x, const int step_size_y, const unsigned int refc); - static FbTk::Command *parse(const std::string &command, + static FbTk::Command *parse(const std::string &command, const std::string &args, bool trusted); protected: void real_execute(); @@ -238,7 +238,7 @@ protected: class SetAlphaCmd: public WindowHelperCmd { public: SetAlphaCmd(int focus, bool rel, int unfocus, bool unrel); - static FbTk::Command *parse(const std::string &command, + static FbTk::Command *parse(const std::string &command, const std::string &args, bool trusted); protected: void real_execute(); diff --git a/src/FbCommands.cc b/src/FbCommands.cc index 1569704e..5e7f6dc4 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc @@ -31,7 +31,7 @@ #include "FbTk/Theme.hh" #include "FbTk/Menu.hh" -#include "FbTk/ObjectRegistry.hh" +#include "FbTk/CommandParser.hh" #include "FbTk/StringUtil.hh" #include "FbTk/stringstream.hh" @@ -123,9 +123,9 @@ namespace FbCommands { using FbTk::Command; -REGISTER_UNTRUSTED_OBJECT_WITH_ARGS(exec, FbCommands::ExecuteCmd, Command); -REGISTER_UNTRUSTED_OBJECT_WITH_ARGS(execute, FbCommands::ExecuteCmd, Command); -REGISTER_UNTRUSTED_OBJECT_WITH_ARGS(execcommand, FbCommands::ExecuteCmd, Command); +REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(exec, FbCommands::ExecuteCmd, void); +REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(execute, FbCommands::ExecuteCmd, void); +REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(execcommand, FbCommands::ExecuteCmd, void); ExecuteCmd::ExecuteCmd(const string &cmd, int screen_num):m_cmd(cmd), m_screen_num(screen_num) { @@ -176,7 +176,7 @@ int ExecuteCmd::run() { return pid; // compiler happy -> we are happy ;) } -FbTk::Command *ExportCmd::parse(const string &command, const string &args, +FbTk::Command *ExportCmd::parse(const string &command, const string &args, bool trusted) { string name = args; FbTk::StringUtil::removeFirstWhitespace(name); @@ -193,9 +193,9 @@ FbTk::Command *ExportCmd::parse(const string &command, const string &args, return new ExportCmd(name, value); } -REGISTER_OBJECT_PARSER(setenv, ExportCmd::parse, Command); -REGISTER_OBJECT_PARSER(export, ExportCmd::parse, Command); -REGISTER_OBJECT_PARSER(setresourcevalue, ExportCmd::parse, Command); +REGISTER_COMMAND_PARSER(setenv, ExportCmd::parse, void); +REGISTER_COMMAND_PARSER(export, ExportCmd::parse, void); +REGISTER_COMMAND_PARSER(setresourcevalue, ExportCmd::parse, void); ExportCmd::ExportCmd(const string& name, const string& value) : m_name(name), m_value(value) { @@ -233,20 +233,20 @@ void ExportCmd::execute() { } } -REGISTER_OBJECT(exit, FbCommands::ExitFluxboxCmd, Command); -REGISTER_OBJECT(quit, FbCommands::ExitFluxboxCmd, Command); +REGISTER_COMMAND(exit, FbCommands::ExitFluxboxCmd, void); +REGISTER_COMMAND(quit, FbCommands::ExitFluxboxCmd, void); void ExitFluxboxCmd::execute() { Fluxbox::instance()->shutdown(); } -REGISTER_OBJECT(saverc, FbCommands::SaveResources, Command); +REGISTER_COMMAND(saverc, FbCommands::SaveResources, void); void SaveResources::execute() { Fluxbox::instance()->save_rc(); } -REGISTER_UNTRUSTED_OBJECT_WITH_ARGS(restart, FbCommands::RestartFluxboxCmd, Command); +REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(restart, FbCommands::RestartFluxboxCmd, void); RestartFluxboxCmd::RestartFluxboxCmd(const string &cmd):m_cmd(cmd){ } @@ -258,21 +258,21 @@ void RestartFluxboxCmd::execute() { Fluxbox::instance()->restart(m_cmd.c_str()); } -REGISTER_OBJECT(reconfigure, FbCommands::ReconfigureFluxboxCmd, Command); -REGISTER_OBJECT(reconfig, FbCommands::ReconfigureFluxboxCmd, Command); +REGISTER_COMMAND(reconfigure, FbCommands::ReconfigureFluxboxCmd, void); +REGISTER_COMMAND(reconfig, FbCommands::ReconfigureFluxboxCmd, void); void ReconfigureFluxboxCmd::execute() { Fluxbox::instance()->reconfigure(); } -REGISTER_OBJECT(reloadstyle, FbCommands::ReloadStyleCmd, Command); +REGISTER_COMMAND(reloadstyle, FbCommands::ReloadStyleCmd, void); void ReloadStyleCmd::execute() { SetStyleCmd cmd(Fluxbox::instance()->getStyleFilename()); cmd.execute(); } -REGISTER_OBJECT_WITH_ARGS(setstyle, FbCommands::SetStyleCmd, Command); +REGISTER_COMMAND_WITH_ARGS(setstyle, FbCommands::SetStyleCmd, void); SetStyleCmd::SetStyleCmd(const string &filename):m_filename(filename) { @@ -285,7 +285,7 @@ void SetStyleCmd::execute() { Fluxbox::instance()->getStyleOverlayFilename()); } -REGISTER_OBJECT_WITH_ARGS(keymode, FbCommands::KeyModeCmd, Command); +REGISTER_COMMAND_WITH_ARGS(keymode, FbCommands::KeyModeCmd, void); KeyModeCmd::KeyModeCmd(const string &arguments):m_keymode(arguments),m_end_args("None Escape") { string::size_type second_pos = m_keymode.find_first_of(" \t", 0); @@ -302,13 +302,13 @@ void KeyModeCmd::execute() { Fluxbox::instance()->keys()->keyMode(m_keymode); } -REGISTER_OBJECT(hidemenus, FbCommands::HideMenuCmd, Command); +REGISTER_COMMAND(hidemenus, FbCommands::HideMenuCmd, void); void HideMenuCmd::execute() { FbTk::Menu::hideShownMenu(); } -FbTk::Command *ShowClientMenuCmd::parse(const string &command, +FbTk::Command *ShowClientMenuCmd::parse(const string &command, const string &args, bool trusted) { int opts; string pat; @@ -316,7 +316,7 @@ FbTk::Command *ShowClientMenuCmd::parse(const string &command, return new ShowClientMenuCmd(opts, pat); } -REGISTER_OBJECT_PARSER(clientmenu, ShowClientMenuCmd::parse, Command); +REGISTER_COMMAND_PARSER(clientmenu, ShowClientMenuCmd::parse, void); void ShowClientMenuCmd::execute() { BScreen *screen = Fluxbox::instance()->mouseScreen(); @@ -339,7 +339,7 @@ void ShowClientMenuCmd::execute() { ::showMenu(*screen, **m_menu); } -REGISTER_OBJECT_WITH_ARGS(custommenu, FbCommands::ShowCustomMenuCmd, Command); +REGISTER_COMMAND_WITH_ARGS(custommenu, FbCommands::ShowCustomMenuCmd, void); ShowCustomMenuCmd::ShowCustomMenuCmd(const string &arguments) : custom_menu_file(arguments) {} @@ -354,7 +354,7 @@ void ShowCustomMenuCmd::execute() { ::showMenu(*screen, **m_menu); } -REGISTER_OBJECT(rootmenu, FbCommands::ShowRootMenuCmd, Command); +REGISTER_COMMAND(rootmenu, FbCommands::ShowRootMenuCmd, void); void ShowRootMenuCmd::execute() { BScreen *screen = Fluxbox::instance()->mouseScreen(); @@ -364,7 +364,7 @@ void ShowRootMenuCmd::execute() { ::showMenu(*screen, screen->rootMenu()); } -REGISTER_OBJECT(workspacemenu, FbCommands::ShowWorkspaceMenuCmd, Command); +REGISTER_COMMAND(workspacemenu, FbCommands::ShowWorkspaceMenuCmd, void); void ShowWorkspaceMenuCmd::execute() { BScreen *screen = Fluxbox::instance()->mouseScreen(); @@ -374,7 +374,7 @@ void ShowWorkspaceMenuCmd::execute() { ::showMenu(*screen, screen->workspaceMenu()); } -REGISTER_OBJECT_WITH_ARGS(setworkspacename, FbCommands::SetWorkspaceNameCmd, Command); +REGISTER_COMMAND_WITH_ARGS(setworkspacename, FbCommands::SetWorkspaceNameCmd, void); SetWorkspaceNameCmd::SetWorkspaceNameCmd(const string &name, int spaceid): m_name(name), m_workspace(spaceid) { @@ -403,7 +403,7 @@ void SetWorkspaceNameCmd::execute() { Fluxbox::instance()->save_rc(); } -REGISTER_OBJECT(setworkspacenamedialog, FbCommands::WorkspaceNameDialogCmd, Command); +REGISTER_COMMAND(setworkspacenamedialog, FbCommands::WorkspaceNameDialogCmd, void); void WorkspaceNameDialogCmd::execute() { @@ -416,7 +416,7 @@ void WorkspaceNameDialogCmd::execute() { win->show(); } -REGISTER_OBJECT(commanddialog, FbCommands::CommandDialogCmd, Command); +REGISTER_COMMAND(commanddialog, FbCommands::CommandDialogCmd, void); void CommandDialogCmd::execute() { BScreen *screen = Fluxbox::instance()->mouseScreen(); @@ -443,7 +443,7 @@ void SetResourceValueCmd::execute() { Fluxbox::instance()->save_rc(); } -REGISTER_OBJECT(setresourcevaluedialog, FbCommands::SetResourceValueDialogCmd, Command); +REGISTER_COMMAND(setresourcevaluedialog, FbCommands::SetResourceValueDialogCmd, void); void SetResourceValueDialogCmd::execute() { BScreen *screen = Fluxbox::instance()->mouseScreen(); @@ -454,7 +454,7 @@ void SetResourceValueDialogCmd::execute() { win->show(); }; -REGISTER_UNTRUSTED_OBJECT_WITH_ARGS(bindkey, FbCommands::BindKeyCmd, Command); +REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(bindkey, FbCommands::BindKeyCmd, void); BindKeyCmd::BindKeyCmd(const string &keybind):m_keybind(keybind) { } @@ -469,7 +469,7 @@ void BindKeyCmd::execute() { } } -FbTk::Command *DeiconifyCmd::parse(const string &command, const string &args, +FbTk::Command *DeiconifyCmd::parse(const string &command, const string &args, bool trusted) { FbTk_istringstream iss(args.c_str()); string mode; @@ -502,7 +502,7 @@ FbTk::Command *DeiconifyCmd::parse(const string &command, const string &args, return new DeiconifyCmd(DeiconifyCmd::LASTWORKSPACE, dest); } -REGISTER_OBJECT_PARSER(deiconify, DeiconifyCmd::parse, Command); +REGISTER_COMMAND_PARSER(deiconify, DeiconifyCmd::parse, void); DeiconifyCmd::DeiconifyCmd(Mode mode, Destination dest) : m_mode(mode), m_dest(dest) { } diff --git a/src/FbCommands.hh b/src/FbCommands.hh index d784a758..f9c33af0 100644 --- a/src/FbCommands.hh +++ b/src/FbCommands.hh @@ -34,7 +34,7 @@ namespace FbCommands { /// executes a system command -class ExecuteCmd: public FbTk::Command { +class ExecuteCmd: public FbTk::Command { public: ExecuteCmd(const std::string &cmd, int screen_num = -1); void execute(); @@ -48,11 +48,11 @@ private: }; /// sets environment -class ExportCmd : public FbTk::Command { +class ExportCmd : public FbTk::Command { public: ExportCmd(const std::string& name, const std::string& value); void execute(); - static FbTk::Command *parse(const std::string &command, + static FbTk::Command *parse(const std::string &command, const std::string &args, bool trusted); private: std::string m_name; @@ -60,19 +60,19 @@ private: }; /// exit fluxbox -class ExitFluxboxCmd: public FbTk::Command { +class ExitFluxboxCmd: public FbTk::Command { public: void execute(); }; /// saves resources -class SaveResources: public FbTk::Command { +class SaveResources: public FbTk::Command { public: void execute(); }; /// restarts fluxbox -class RestartFluxboxCmd: public FbTk::Command { +class RestartFluxboxCmd: public FbTk::Command { public: RestartFluxboxCmd(const std::string &cmd); void execute(); @@ -81,17 +81,17 @@ private: }; /// reconfigures fluxbox -class ReconfigureFluxboxCmd: public FbTk::Command { +class ReconfigureFluxboxCmd: public FbTk::Command { public: void execute(); }; -class ReloadStyleCmd: public FbTk::Command { +class ReloadStyleCmd: public FbTk::Command { public: void execute(); }; -class SetStyleCmd: public FbTk::Command { +class SetStyleCmd: public FbTk::Command { public: explicit SetStyleCmd(const std::string &filename); void execute(); @@ -99,7 +99,7 @@ private: std::string m_filename; }; -class KeyModeCmd: public FbTk::Command { +class KeyModeCmd: public FbTk::Command { public: explicit KeyModeCmd(const std::string &arguments); void execute(); @@ -108,17 +108,17 @@ private: std::string m_end_args; }; -class HideMenuCmd: public FbTk::Command { +class HideMenuCmd: public FbTk::Command { public: void execute(); }; -class ShowClientMenuCmd: public FbTk::Command { +class ShowClientMenuCmd: public FbTk::Command { public: ShowClientMenuCmd(int option, std::string &pat): m_option(option|FocusableList::LIST_GROUPS), m_pat(pat.c_str()) { } void execute(); - static FbTk::Command *parse(const std::string &command, + static FbTk::Command *parse(const std::string &command, const std::string &args, bool trusted); private: const int m_option; @@ -127,7 +127,7 @@ private: FbTk::RefCount m_menu; }; -class ShowCustomMenuCmd: public FbTk::Command { +class ShowCustomMenuCmd: public FbTk::Command { public: explicit ShowCustomMenuCmd(const std::string &arguments); void execute(); @@ -136,17 +136,17 @@ private: FbTk::RefCount m_menu; }; -class ShowRootMenuCmd: public FbTk::Command { +class ShowRootMenuCmd: public FbTk::Command { public: void execute(); }; -class ShowWorkspaceMenuCmd: public FbTk::Command { +class ShowWorkspaceMenuCmd: public FbTk::Command { public: void execute(); }; -class SetWorkspaceNameCmd: public FbTk::Command { +class SetWorkspaceNameCmd: public FbTk::Command { public: SetWorkspaceNameCmd(const std::string &name, int spaceid = -1); void execute(); @@ -155,18 +155,18 @@ private: int m_workspace; }; -class WorkspaceNameDialogCmd: public FbTk::Command { +class WorkspaceNameDialogCmd: public FbTk::Command { public: void execute(); }; -class CommandDialogCmd: public FbTk::Command { +class CommandDialogCmd: public FbTk::Command { public: void execute(); }; -class SetResourceValueCmd: public FbTk::Command { +class SetResourceValueCmd: public FbTk::Command { public: SetResourceValueCmd(const std::string &resourcename, const std::string &value); void execute(); @@ -175,12 +175,12 @@ private: const std::string m_value; }; -class SetResourceValueDialogCmd: public FbTk::Command { +class SetResourceValueDialogCmd: public FbTk::Command { public: void execute(); }; -class BindKeyCmd: public FbTk::Command { +class BindKeyCmd: public FbTk::Command { public: BindKeyCmd(const std::string &keybind); void execute(); @@ -189,7 +189,7 @@ private: }; /// deiconifies iconified windows -class DeiconifyCmd: public FbTk::Command { +class DeiconifyCmd: public FbTk::Command { public: enum Mode { LAST, @@ -207,7 +207,7 @@ public: DeiconifyCmd(Mode mode= LASTWORKSPACE, Destination dest= CURRENT); void execute(); - static FbTk::Command *parse(const std::string &command, + static FbTk::Command *parse(const std::string &command, const std::string &args, bool trusted); private: Mode m_mode; diff --git a/src/FbTk/BoolMenuItem.hh b/src/FbTk/BoolMenuItem.hh index 73900660..47d6db4c 100644 --- a/src/FbTk/BoolMenuItem.hh +++ b/src/FbTk/BoolMenuItem.hh @@ -32,7 +32,7 @@ class Accessor; class BoolMenuItem: public FbTk::MenuItem { public: BoolMenuItem(const FbTk::FbString &label, Accessor &item, - FbTk::RefCount &cmd): + FbTk::RefCount > &cmd): FbTk::MenuItem(label, cmd), m_item(item) { FbTk::MenuItem::setSelected(m_item); setToggleItem(true); diff --git a/src/FbTk/Button.cc b/src/FbTk/Button.cc index 25f9a5c0..bcdc90e8 100644 --- a/src/FbTk/Button.cc +++ b/src/FbTk/Button.cc @@ -62,7 +62,7 @@ Button::~Button() { } } -void Button::setOnClick(RefCount &cmd, int button) { +void Button::setOnClick(RefCount > &cmd, int button) { // we only handle buttons 1 to 5 if (button > 5 || button == 0) return; diff --git a/src/FbTk/Button.hh b/src/FbTk/Button.hh index d6414b37..bcf909b6 100644 --- a/src/FbTk/Button.hh +++ b/src/FbTk/Button.hh @@ -42,7 +42,7 @@ public: virtual ~Button(); /// sets action when the button is clicked with #button mouse btn - void setOnClick(RefCount &com, int button = 1); + void setOnClick(RefCount > &com, int button = 1); /// sets the pixmap to be viewed when the button is pressed virtual void setPressedPixmap(Pixmap pm); @@ -83,7 +83,7 @@ private: GC m_gc; ///< graphic context for button bool m_pressed; ///< if the button is pressed bool *mark_if_deleted; ///< if the button is deleted and this is set, make it true - RefCount m_onclick[5]; ///< what to do when this button is clicked with button num + RefCount > m_onclick[5]; ///< what to do when this button is clicked with button num }; } // namespace FbTk diff --git a/src/FbTk/Command.hh b/src/FbTk/Command.hh index 5d38cb8c..f1eb8f25 100644 --- a/src/FbTk/Command.hh +++ b/src/FbTk/Command.hh @@ -25,18 +25,11 @@ namespace FbTk { /// Interface class for commands +template class Command { public: virtual ~Command() { } - virtual void execute() = 0; -}; - -/// Interface class for boolean commands -class BoolCommand: public Command { -public: - virtual ~BoolCommand() { } - virtual void execute() { bool_execute(); } - virtual bool bool_execute() = 0; + virtual Ret execute() = 0; }; } // end namespace FbTk diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc index 394939a3..1281b562 100644 --- a/src/FbTk/ImageControl.cc +++ b/src/FbTk/ImageControl.cc @@ -112,7 +112,7 @@ ImageControl::ImageControl(int screen_num, bool dither, if (cache_timeout && s_timed_cache) { m_timer.setTimeout(cache_timeout); - RefCount clean_cache(new SimpleCommand(*this, &ImageControl::cleanCache)); + RefCount > clean_cache(new SimpleCommand(*this, &ImageControl::cleanCache)); m_timer.setCommand(clean_cache); m_timer.start(); } diff --git a/src/FbTk/LogicCommands.cc b/src/FbTk/LogicCommands.cc index fedffe96..3545b61f 100644 --- a/src/FbTk/LogicCommands.cc +++ b/src/FbTk/LogicCommands.cc @@ -21,7 +21,7 @@ #include "LogicCommands.hh" -#include "ObjectRegistry.hh" +#include "CommandParser.hh" #include "StringUtil.hh" #include @@ -39,11 +39,11 @@ M *addCommands(M *macro, const string &args, bool trusted) { std::string blah; std::vector cmds; StringUtil::stringTokensBetween(cmds, args, blah, '{', '}'); - RefCount cmd(0); + RefCount > cmd(0); std::vector::iterator it = cmds.begin(), it_end = cmds.end(); for (; it != it_end; ++it) { - cmd = ObjectRegistry::instance().parse(*it, trusted); + cmd = CommandParser::instance().parse(*it, trusted); if (*cmd) macro->add(cmd); } @@ -54,14 +54,14 @@ M *addCommands(M *macro, const string &args, bool trusted) { return 0; } -BoolCommand *parseLogicCommand(const string &command, const string &args, +Command *parseLogicCommand(const string &command, const string &args, bool trusted) { if (command == "not") { - BoolCommand *boolcmd = - ObjectRegistry::instance().parse(args, trusted); + Command *boolcmd = + CommandParser::instance().parse(args, trusted); if (!boolcmd) return 0; - RefCount ref(boolcmd); + RefCount > ref(boolcmd); return new NotCommand(ref); } else if (command == "and") return addCommands(new AndCommand(), args, trusted); @@ -72,41 +72,41 @@ BoolCommand *parseLogicCommand(const string &command, const string &args, return 0; } -REGISTER_OBJECT_PARSER(not, parseLogicCommand, BoolCommand); -REGISTER_OBJECT_PARSER(and, parseLogicCommand, BoolCommand); -REGISTER_OBJECT_PARSER(or, parseLogicCommand, BoolCommand); -REGISTER_OBJECT_PARSER(xor, parseLogicCommand, BoolCommand); +REGISTER_COMMAND_PARSER(not, parseLogicCommand, bool); +REGISTER_COMMAND_PARSER(and, parseLogicCommand, bool); +REGISTER_COMMAND_PARSER(or, parseLogicCommand, bool); +REGISTER_COMMAND_PARSER(xor, parseLogicCommand, bool); }; // end anonymous namespace -Command *IfCommand::parse(const std::string &command, const std::string &args, +Command *IfCommand::parse(const std::string &command, const std::string &args, bool trusted) { std::string blah; std::vector cmds; - RefCount cond(0); - RefCount t(0), f(0); + RefCount > cond(0); + RefCount > t(0), f(0); StringUtil::stringTokensBetween(cmds, args, blah, '{', '}'); if (cmds.size() < 3) return 0; - cond = ObjectRegistry::instance().parse(cmds[0], trusted); + cond = CommandParser::instance().parse(cmds[0], trusted); if (*cond == 0) return 0; - t = ObjectRegistry::instance().parse(cmds[1], trusted); + t = CommandParser::instance().parse(cmds[1], trusted); if (cmds.size() >= 3) - f = ObjectRegistry::instance().parse(cmds[2], trusted); + f = CommandParser::instance().parse(cmds[2], trusted); if (*t == 0 && *f == 0) return 0; return new IfCommand(cond, t, f); } -REGISTER_OBJECT_PARSER(if, IfCommand::parse, Command); -REGISTER_OBJECT_PARSER(cond, IfCommand::parse, Command); +REGISTER_COMMAND_PARSER(if, IfCommand::parse, void); +REGISTER_COMMAND_PARSER(cond, IfCommand::parse, void); -void OrCommand::add(RefCount &com) { +void OrCommand::add(RefCount > &com) { m_commandlist.push_back(com); } @@ -114,15 +114,15 @@ size_t OrCommand::size() const { return m_commandlist.size(); } -bool OrCommand::bool_execute() { +bool OrCommand::execute() { for (size_t i=0; i < m_commandlist.size(); ++i) { - if (m_commandlist[i]->bool_execute()) + if (m_commandlist[i]->execute()) return true; } return false; } -void AndCommand::add(RefCount &com) { +void AndCommand::add(RefCount > &com) { m_commandlist.push_back(com); } @@ -130,15 +130,15 @@ size_t AndCommand::size() const { return m_commandlist.size(); } -bool AndCommand::bool_execute() { +bool AndCommand::execute() { for (size_t i=0; i < m_commandlist.size(); ++i) { - if (!m_commandlist[i]->bool_execute()) + if (!m_commandlist[i]->execute()) return false; } return true; } -void XorCommand::add(RefCount &com) { +void XorCommand::add(RefCount > &com) { m_commandlist.push_back(com); } @@ -146,10 +146,10 @@ size_t XorCommand::size() const { return m_commandlist.size(); } -bool XorCommand::bool_execute() { +bool XorCommand::execute() { bool ret = false; for (size_t i=0; i < m_commandlist.size(); ++i) - ret ^= m_commandlist[i]->bool_execute(); + ret ^= m_commandlist[i]->execute(); return ret; } diff --git a/src/FbTk/LogicCommands.hh b/src/FbTk/LogicCommands.hh index 96d648e4..5e844733 100644 --- a/src/FbTk/LogicCommands.hh +++ b/src/FbTk/LogicCommands.hh @@ -30,66 +30,66 @@ namespace FbTk { -/// executes a boolcommand and uses the result to decide what to do -class IfCommand: public Command { +/// executes a Command and uses the result to decide what to do +class IfCommand: public Command { public: - IfCommand(RefCount &cond, - RefCount &t, RefCount &f): + IfCommand(RefCount > &cond, + RefCount > &t, RefCount > &f): m_cond(cond), m_t(t), m_f(f) { } void execute() { - if (m_cond->bool_execute()) { + if (m_cond->execute()) { if (*m_t) m_t->execute(); } else if (*m_f) m_f->execute(); } - static Command *parse(const std::string &cmd, const std::string &args, + static Command *parse(const std::string &cmd, const std::string &args, bool trusted); private: - RefCount m_cond; - RefCount m_t, m_f; + RefCount > m_cond; + RefCount > m_t, m_f; }; -/// executes a list of boolcommands until one is true -class OrCommand: public BoolCommand { +/// executes a list of Commands until one is true +class OrCommand: public Command { public: - void add(RefCount &com); + void add(RefCount > &com); size_t size() const; - bool bool_execute(); + bool execute(); private: - std::vector > m_commandlist; + std::vector > > m_commandlist; }; -/// executes a list of boolcommands until one is false -class AndCommand: public BoolCommand { +/// executes a list of Commands until one is false +class AndCommand: public Command { public: - void add(RefCount &com); + void add(RefCount > &com); size_t size() const; - bool bool_execute(); + bool execute(); private: - std::vector > m_commandlist; + std::vector > > m_commandlist; }; -/// executes a list of boolcommands, returning the parity -class XorCommand: public BoolCommand { +/// executes a list of Commands, returning the parity +class XorCommand: public Command { public: - void add(RefCount &com); + void add(RefCount > &com); size_t size() const; - bool bool_execute(); + bool execute(); private: - std::vector > m_commandlist; + std::vector > > m_commandlist; }; -/// executes a boolcommand and returns the negation -class NotCommand: public BoolCommand { +/// executes a Command and returns the negation +class NotCommand: public Command { public: - NotCommand(RefCount &com): m_command(com) { } - bool bool_execute() { return !m_command->bool_execute(); } + NotCommand(RefCount > &com): m_command(com) { } + bool execute() { return !m_command->execute(); } private: - RefCount m_command; + RefCount > m_command; }; } // end namespace FbTk diff --git a/src/FbTk/MacroCommand.cc b/src/FbTk/MacroCommand.cc index 63e532f0..372cde99 100644 --- a/src/FbTk/MacroCommand.cc +++ b/src/FbTk/MacroCommand.cc @@ -21,7 +21,7 @@ #include "MacroCommand.hh" -#include "ObjectRegistry.hh" +#include "CommandParser.hh" #include "StringUtil.hh" #include @@ -36,11 +36,11 @@ M *addCommands(M *macro, const std::string &args, bool trusted) { std::string blah; std::list cmds; StringUtil::stringTokensBetween(cmds, args, blah, '{', '}'); - RefCount cmd(0); + RefCount > cmd(0); std::list::iterator it = cmds.begin(), it_end = cmds.end(); for (; it != it_end; ++it) { - cmd = ObjectRegistry::instance().parse(*it, trusted); + cmd = CommandParser::instance().parse(*it, trusted); if (*cmd) macro->add(cmd); } @@ -52,21 +52,21 @@ M *addCommands(M *macro, const std::string &args, bool trusted) { return 0; } -Command *parseMacroCmd(const std::string &command, const std::string &args, +Command *parseMacroCmd(const std::string &command, const std::string &args, bool trusted) { if (command == "macrocmd") - return addCommands(new MacroCommand, args, trusted); + return addCommands(new MacroCommand, args, trusted); else if (command == "togglecmd") - return addCommands(new ToggleCommand, args, trusted); + return addCommands(new ToggleCommand, args, trusted); return 0; } -REGISTER_OBJECT_PARSER(macrocmd, parseMacroCmd, Command); -REGISTER_OBJECT_PARSER(togglecmd, parseMacroCmd, Command); +REGISTER_COMMAND_PARSER(macrocmd, parseMacroCmd, void); +REGISTER_COMMAND_PARSER(togglecmd, parseMacroCmd, void); }; // end anonymous namespace -void MacroCommand::add(RefCount &com) { +void MacroCommand::add(RefCount > &com) { m_commandlist.push_back(com); } @@ -83,7 +83,7 @@ ToggleCommand::ToggleCommand() { m_state = 0; } -void ToggleCommand::add(RefCount &com) { +void ToggleCommand::add(RefCount > &com) { m_commandlist.push_back(com); } diff --git a/src/FbTk/MacroCommand.hh b/src/FbTk/MacroCommand.hh index a7d92042..932ecafc 100644 --- a/src/FbTk/MacroCommand.hh +++ b/src/FbTk/MacroCommand.hh @@ -30,26 +30,26 @@ namespace FbTk { /// executes a list of commands -class MacroCommand:public Command { +class MacroCommand:public Command { public: - void add(RefCount &com); + void add(RefCount > &com); size_t size() const; virtual void execute(); private: - std::vector > m_commandlist; + std::vector > > m_commandlist; }; /// executes one command at a time -class ToggleCommand:public Command { +class ToggleCommand:public Command { public: ToggleCommand(); - void add(RefCount &com); + void add(RefCount > &com); size_t size() const; virtual void execute(); private: - std::vector > m_commandlist; + std::vector > > m_commandlist; size_t m_state; }; diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 51fca9d7..696d8475 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -95,12 +95,12 @@ Menu::Menu(FbTk::ThemeProxy &tm, ImageControl &imgctrl): m_need_update(true) { // setup timers - RefCount show_cmd(new SimpleCommand(*this, &Menu::openSubmenu)); + RefCount > show_cmd(new SimpleCommand(*this, &Menu::openSubmenu)); m_submenu_timer.setCommand(show_cmd); m_submenu_timer.fireOnce(true); - RefCount hide_cmd(new SimpleCommand(*this, &Menu::closeMenu)); + RefCount > hide_cmd(new SimpleCommand(*this, &Menu::closeMenu)); m_hide_timer.setCommand(hide_cmd); m_hide_timer.fireOnce(true); @@ -198,7 +198,7 @@ Menu::~Menu() { s_focused = 0; } -int Menu::insert(const FbString &label, RefCount &cmd, int pos) { +int Menu::insert(const FbString &label, RefCount > &cmd, int pos) { return insert(new MenuItem(label, cmd, this), pos); } diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 2f372343..4ebab83a 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh @@ -38,7 +38,7 @@ namespace FbTk { -class Command; +class Command; class MenuItem; class ImageControl; class RefCount; @@ -63,7 +63,7 @@ public: */ //@{ /// add a menu item with a label and a command - int insert(const FbString &label, RefCount &cmd, int pos=-1); + int insert(const FbString &label, RefCount > &cmd, int pos=-1); /// add empty menu item int insert(const FbString &label, int pos=-1); /// add submenu diff --git a/src/FbTk/MenuItem.cc b/src/FbTk/MenuItem.cc index 1e8c8e96..81765b18 100644 --- a/src/FbTk/MenuItem.cc +++ b/src/FbTk/MenuItem.cc @@ -37,7 +37,7 @@ void MenuItem::click(int button, int time, unsigned int mods) { if (m_menu && m_close_on_click && (mods & ControlMask) == 0) m_menu->hide(); // we need a local variable, since the command may destroy this object - RefCount tmp(m_command); + RefCount > tmp(m_command); tmp->execute(); } } diff --git a/src/FbTk/MenuItem.hh b/src/FbTk/MenuItem.hh index 8c730361..9150849a 100644 --- a/src/FbTk/MenuItem.hh +++ b/src/FbTk/MenuItem.hh @@ -69,7 +69,7 @@ public: m_toggle_item(false) { } /// create a menu item with a specific command to be executed on click - MenuItem(const FbString &label, RefCount &cmd, Menu *menu = 0) + MenuItem(const FbString &label, RefCount > &cmd, Menu *menu = 0) : m_label(label), m_menu(menu), m_submenu(0), @@ -91,7 +91,7 @@ public: { } virtual ~MenuItem() { } - void setCommand(RefCount &cmd) { m_command = cmd; } + void setCommand(RefCount > &cmd) { m_command = cmd; } virtual void setSelected(bool selected) { m_selected = selected; } virtual void setEnabled(bool enabled) { m_enabled = enabled; } virtual void setLabel(const FbString &label) { m_label = label; } @@ -140,8 +140,8 @@ public: virtual void click(int button, int time, unsigned int mods); /// must use this to show submenu to ensure consistency for object like window menu in ClientMenu (see Workspace.cc) virtual void showSubmenu(); - RefCount &command() { return m_command; } - const RefCount &command() const { return m_command; } + RefCount > &command() { return m_command; } + const RefCount > &command() const { return m_command; } //@} void setMenu(Menu &menu) { m_menu = &menu; } @@ -151,7 +151,7 @@ private: FbString m_label; ///< label of this item Menu *m_menu; ///< the menu we live in Menu *m_submenu; ///< a submenu, 0 if we don't have one - RefCount m_command; ///< command to be executed + RefCount > m_command; ///< command to be executed bool m_enabled, m_selected; bool m_close_on_click, m_toggle_item; int m_index; diff --git a/src/FbTk/MultiButtonMenuItem.cc b/src/FbTk/MultiButtonMenuItem.cc index 42a096d9..6fd8feee 100644 --- a/src/FbTk/MultiButtonMenuItem.cc +++ b/src/FbTk/MultiButtonMenuItem.cc @@ -45,7 +45,7 @@ MultiButtonMenuItem::~MultiButtonMenuItem() { delete [] m_button_exe; } -void MultiButtonMenuItem::setCommand(int button, FbTk::RefCount &cmd) { +void MultiButtonMenuItem::setCommand(int button, FbTk::RefCount > &cmd) { if (button <= 0 || button > static_cast(buttons()) || buttons() == 0) return; m_button_exe[button - 1] = cmd; @@ -66,7 +66,7 @@ void MultiButtonMenuItem::init(int buttons) { m_buttons = buttons; if (m_buttons != 0) - m_button_exe = new FbTk::RefCount[m_buttons]; + m_button_exe = new FbTk::RefCount >[m_buttons]; else m_button_exe = 0; } diff --git a/src/FbTk/MultiButtonMenuItem.hh b/src/FbTk/MultiButtonMenuItem.hh index 6d717afa..5d67bdf4 100644 --- a/src/FbTk/MultiButtonMenuItem.hh +++ b/src/FbTk/MultiButtonMenuItem.hh @@ -34,7 +34,7 @@ public: MultiButtonMenuItem(int buttons, const FbString &label, Menu *submenu); virtual ~MultiButtonMenuItem(); /// sets command to specified button - void setCommand(int button, FbTk::RefCount &cmd); + void setCommand(int button, FbTk::RefCount > &cmd); /// executes command for the button click virtual void click(int button, int time, unsigned int mods); /// @return number of buttons this instance handles @@ -43,7 +43,7 @@ public: private: void init(int buttons); - FbTk::RefCount *m_button_exe; + FbTk::RefCount > *m_button_exe; unsigned int m_buttons; }; diff --git a/src/FbTk/ObjectRegistry.hh b/src/FbTk/ObjectRegistry.hh index d6a97d9c..e68d6305 100644 --- a/src/FbTk/ObjectRegistry.hh +++ b/src/FbTk/ObjectRegistry.hh @@ -22,124 +22,30 @@ #ifndef OBJECTREGISTRY_HH #define OBJECTREGISTRY_HH -#include "StringUtil.hh" - #include - -using std::string; +#include namespace FbTk { -#define REGISTER_OBJECT_PARSER(name, parser, type) \ - namespace { \ - static const bool p_register_##type_##name = FbTk::ObjectRegistry::instance().registerObject(#name, parser); \ - } - -#define REGISTER_OBJECT_PARSER_NSBASE(name, parser, space, base) \ - namespace { \ - static const bool p_register_##type_##name = FbTk::ObjectRegistry::instance().registerObject(#name, parser); \ - } - -/* Include some basic Object creators */ -template -Base *ObjectCreator(const string &name, const string &args, bool trusted) { - return new Derived(); -} - -#define REGISTER_OBJECT(name, derived, base) \ - namespace { \ - static const bool p_register_##type_##name = FbTk::ObjectRegistry::instance().registerObject(#name, FbTk::ObjectCreator); \ - } - -#define REGISTER_OBJECT_NSBASE(name, derived, space, base) \ - namespace { \ - static const bool p_register_##type_##name = FbTk::ObjectRegistry::instance().registerObject(#name, FbTk::ObjectCreator); \ - } - -template -Base *ObjectCreatorWithArgs(const string &name, const string &args, - bool trusted) { - return new Derived(args); -} - -#define REGISTER_OBJECT_WITH_ARGS(name, derived, base) \ - namespace { \ - static const bool p_register_##type_##name = FbTk::ObjectRegistry::instance().registerObject(#name, FbTk::ObjectCreatorWithArgs); \ - } - -#define REGISTER_OBJECT_WITH_ARGS_NSBASE(name, derived, space, base) \ - namespace { \ - static const bool p_register_##type_##name = FbTk::ObjectRegistry::instance().registerObject(#name, FbTk::ObjectCreatorWithArgs); \ - } - -template -Base *UntrustedObjectCreator(const string &name, const string &args, - bool trusted) { - if (!trusted) return 0; - return new Derived(); -} - -#define REGISTER_UNTRUSTED_OBJECT(name, derived, base) \ - namespace { \ - static const bool p_register_##type_##name = FbTk::ObjectRegistry::instance().registerObject(#name, FbTk::UntrustedObjectCreator); \ - } - -#define REGISTER_UNTRUSTED_OBJECT_NSBASE(name, derived, space, base) \ - namespace { \ - static const bool p_register_##type_##name = FbTk::ObjectRegistry::instance().registerObject(#name, FbTk::UntrustedObjectCreator); \ - } - -template -Base * UntrustedObjectCreatorWithArgs(const string &name, const string &args, - bool trusted) { - if (!trusted) return 0; - return new Derived(args); -} - -#define REGISTER_UNTRUSTED_OBJECT_WITH_ARGS(name, derived, base) \ - namespace { \ - static const bool p_register_##type_##name = FbTk::ObjectRegistry::instance().registerObject(#name, FbTk::UntrustedObjectCreatorWithArgs); \ - } - -#define REGISTER_UNTRUSTED_OBJECT_WITH_ARGS_NSBASE(name, derived, space, base) \ - namespace { \ - static const bool p_register_##type_##name = FbTk::ObjectRegistry::instance().registerObject(#name, FbTk::UntrustedObjectCreatorWithArgs); \ - } - -template +template class ObjectRegistry { public: - typedef Base * CreateFunction(const string &name, const string &args, bool trusted); - typedef std::map CreatorMap; + typedef std::map CreatorMap; - static ObjectRegistry &instance() { - static ObjectRegistry s_instance; + static ObjectRegistry &instance() { + static ObjectRegistry s_instance; return s_instance; } - Base *parse(const string &name, const string &args, bool trusted = true) const { - string lc = StringUtil::toLower(name); - typename CreatorMap::const_iterator it = m_creators.find(lc.c_str()); + Creator lookup(const std::string &name) { + typename CreatorMap::const_iterator it = m_creators.find(name); if (it == m_creators.end()) return 0; - else - return it->second(lc, args, trusted); + return it->second; } - Base *parse(const string &line, bool trusted = true) const { - // parse args and command - string command, args; - StringUtil::getFirstWord(line, command, args); - StringUtil::removeFirstWhitespace(args); - StringUtil::removeTrailingWhitespace(args); - - // now we have parsed command and args - return parse(command, args, trusted); - } - - bool registerObject(string name, CreateFunction createFunction) { - name = StringUtil::toLower(name); - m_creators[name] = createFunction; + bool registerObject(const std::string &name, Creator creator) { + m_creators[name] = creator; return true; } diff --git a/src/FbTk/SimpleCommand.hh b/src/FbTk/SimpleCommand.hh index 7ae91a5b..1c4c39ac 100644 --- a/src/FbTk/SimpleCommand.hh +++ b/src/FbTk/SimpleCommand.hh @@ -26,9 +26,9 @@ namespace FbTk { -/// a simple command +/// a simple command template -class SimpleCommand: public Command { +class SimpleCommand: public Command { public: typedef ReturnType (Receiver::* Action)(); SimpleCommand(Receiver &r, Action a): @@ -39,18 +39,6 @@ private: Action m_action; }; -template -class SimpleBoolCommand: public BoolCommand { -public: - typedef ReturnType (Receiver::* Action)(); - SimpleBoolCommand(Receiver &r, Action a): - m_receiver(r), m_action(a) { } - bool bool_execute() { return (bool)(m_receiver.*m_action)(); } -private: - Receiver &m_receiver; - Action m_action; -}; - } // end namespace FbTk #endif // FBTK_SIMPLECOMMAND_HH diff --git a/src/FbTk/Timer.cc b/src/FbTk/Timer.cc index ff568dc0..f235476f 100644 --- a/src/FbTk/Timer.cc +++ b/src/FbTk/Timer.cc @@ -24,7 +24,7 @@ #include "Timer.hh" -#include "ObjectRegistry.hh" +#include "CommandParser.hh" #include "StringUtil.hh" //use GNU extensions @@ -53,7 +53,7 @@ Timer::Timer():m_timing(false), m_once(false), m_interval(0) { } -Timer::Timer(RefCount &handler): +Timer::Timer(RefCount > &handler): m_handler(handler), m_timing(false), m_once(false), @@ -79,7 +79,7 @@ void Timer::setTimeout(const timeval &t) { m_timeout.tv_usec = t.tv_usec; } -void Timer::setCommand(RefCount &cmd) { +void Timer::setCommand(RefCount > &cmd) { m_handler = cmd; } @@ -247,7 +247,7 @@ void Timer::addTimer(Timer *timer) { } -Command *DelayedCmd::parse(const std::string &command, +Command *DelayedCmd::parse(const std::string &command, const std::string &args, bool trusted) { std::string cmd_str; @@ -255,7 +255,7 @@ Command *DelayedCmd::parse(const std::string &command, if (err == 0) return 0; - RefCount cmd(ObjectRegistry::instance().parse(cmd_str, trusted)); + RefCount > cmd(CommandParser::instance().parse(cmd_str, trusted)); if (*cmd == 0) return 0; @@ -265,9 +265,9 @@ Command *DelayedCmd::parse(const std::string &command, return new DelayedCmd(cmd, delay); } -REGISTER_OBJECT_PARSER(delay, DelayedCmd::parse, Command); +REGISTER_COMMAND_PARSER(delay, DelayedCmd::parse, void); -DelayedCmd::DelayedCmd(RefCount &cmd, unsigned int timeout) { +DelayedCmd::DelayedCmd(RefCount > &cmd, unsigned int timeout) { timeval to; // defaults to 200ms to.tv_sec = timeout/1000000; to.tv_usec = timeout % 1000000; diff --git a/src/FbTk/Timer.hh b/src/FbTk/Timer.hh index 01f48609..4893fdb8 100644 --- a/src/FbTk/Timer.hh +++ b/src/FbTk/Timer.hh @@ -57,7 +57,7 @@ namespace FbTk { class Timer { public: Timer(); - explicit Timer(RefCount &handler); + explicit Timer(RefCount > &handler); virtual ~Timer(); void fireOnce(bool once) { m_once = once; } @@ -65,7 +65,7 @@ public: void setTimeout(time_t val); /// set timeout void setTimeout(const timeval &val); - void setCommand(RefCount &cmd); + void setCommand(RefCount > &cmd); void setInterval(int val) { m_interval = val; } /// start timing void start(); @@ -96,7 +96,7 @@ private: typedef std::list TimerList; static TimerList m_timerlist; ///< list of all timers, sorted by next trigger time (start + timeout) - RefCount m_handler; ///< what to do on a timeout + RefCount > m_handler; ///< what to do on a timeout bool m_timing; ///< clock running? bool m_once; ///< do timeout only once? @@ -108,11 +108,11 @@ private: }; /// executes a command after a specified timeout -class DelayedCmd: public Command { +class DelayedCmd: public Command { public: - DelayedCmd(RefCount &cmd, unsigned int timeout = 200000); + DelayedCmd(RefCount > &cmd, unsigned int timeout = 200000); void execute(); - static Command *parse(const std::string &command, + static Command *parse(const std::string &command, const std::string &args, bool trusted); private: Timer m_timer; diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 6196cf3f..643fc494 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -44,7 +44,7 @@ template class FocusableTheme; namespace FbTk { class ImageControl; -class Command; +template class Command; class Texture; class XLayer; } diff --git a/src/FocusModelMenuItem.hh b/src/FocusModelMenuItem.hh index db023f5a..d75e8a03 100644 --- a/src/FocusModelMenuItem.hh +++ b/src/FocusModelMenuItem.hh @@ -28,7 +28,7 @@ #include "FbTk/RefCount.hh" namespace FbTk { -class Command; +template class Command; } #include "FocusControl.hh" @@ -37,7 +37,7 @@ class FocusModelMenuItem : public FbTk::MenuItem { public: FocusModelMenuItem(const FbTk::FbString &label, FocusControl &focus_control, FocusControl::FocusModel model, - FbTk::RefCount &cmd): + FbTk::RefCount > &cmd): FbTk::MenuItem(label, cmd), m_focus_control(focus_control), m_focusmodel(model) { @@ -61,7 +61,7 @@ public: TabFocusModelMenuItem(const FbTk::FbString &label, FocusControl &focus_control, FocusControl::TabFocusModel model, - FbTk::RefCount &cmd): + FbTk::RefCount > &cmd): FbTk::MenuItem(label, cmd), m_focus_control(focus_control), m_tabfocusmodel(model) { diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index d8579f24..8aa0db8f 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -30,7 +30,7 @@ #include "IconButton.hh" #include "Workspace.hh" #include "FbMenu.hh" -#include "FbTk/ObjectRegistry.hh" +#include "FbTk/CommandParser.hh" #include "WinClient.hh" #include "FocusControl.hh" #include "FbCommands.hh" @@ -103,7 +103,7 @@ class ToolbarModeMenuItem : public FbTk::MenuItem { public: ToolbarModeMenuItem(const FbTk::FbString &label, IconbarTool &handler, string mode, - FbTk::RefCount &cmd): + FbTk::RefCount > &cmd): FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) { setCloseOnClick(false); } @@ -122,7 +122,7 @@ class ToolbarAlignMenuItem: public FbTk::MenuItem { public: ToolbarAlignMenuItem(const FbTk::FbString &label, IconbarTool &handler, FbTk::Container::Alignment mode, - FbTk::RefCount &cmd): + FbTk::RefCount > &cmd): FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) { setCloseOnClick(false); } @@ -143,7 +143,7 @@ void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { menu.setLabel(_FB_XTEXT(Toolbar, IconbarMode, "Iconbar Mode", "Menu title - chooses which set of icons are shown in the iconbar")); - RefCount saverc_cmd(new FbCommands::SaveResources()); + RefCount > saverc_cmd(new FbCommands::SaveResources()); menu.insert(new ToolbarModeMenuItem(_FB_XTEXT(Toolbar, IconbarModeNone, @@ -208,9 +208,9 @@ void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { menu.updateMenu(); } -typedef FbTk::RefCount RefCmd; +typedef FbTk::RefCount > RefCmd; -class ShowMenu: public FbTk::Command { +class ShowMenu: public FbTk::Command { public: explicit ShowMenu(FluxboxWindow &win):m_win(win) { } void execute() { @@ -229,7 +229,7 @@ private: FluxboxWindow &m_win; }; -class FocusCommand: public FbTk::Command { +class FocusCommand: public FbTk::Command { public: explicit FocusCommand(Focusable &win): m_win(win) { } void execute() { @@ -283,11 +283,11 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, using namespace FbTk; // setup use pixmap item to reconfig iconbar and save resource on click MacroCommand *save_and_reconfig = new MacroCommand(); - RefCount reconfig(new SimpleCommand(*this, &IconbarTool::renderTheme)); - RefCount save(FbTk::ObjectRegistry::instance().parse("saverc")); + RefCount > reconfig(new SimpleCommand(*this, &IconbarTool::renderTheme)); + RefCount > save(FbTk::CommandParser::instance().parse("saverc")); save_and_reconfig->add(reconfig); save_and_reconfig->add(save); - RefCount s_and_reconfig(save_and_reconfig); + RefCount > s_and_reconfig(save_and_reconfig); m_menu.insert(new FbTk::BoolMenuItem(_FB_XTEXT(Toolbar, ShowIcons, "Show Pictures", "chooses if little icons are shown next to title in the iconbar"), m_rc_use_pixmap, s_and_reconfig)); diff --git a/src/Keys.cc b/src/Keys.cc index 7fcd354d..7187c472 100644 --- a/src/Keys.cc +++ b/src/Keys.cc @@ -30,7 +30,7 @@ #include "FbTk/Command.hh" #include "FbTk/RefCount.hh" #include "FbTk/KeyUtil.hh" -#include "FbTk/ObjectRegistry.hh" +#include "FbTk/CommandParser.hh" #include "FbTk/I18n.hh" #ifdef HAVE_CONFIG_H @@ -135,7 +135,7 @@ public: unsigned int key; // key code or button number int context; // ON_TITLEBAR, etc.: bitwise-or of all desired contexts bool isdouble; - FbTk::RefCount m_command; + FbTk::RefCount > m_command; keylist_t keylist; }; @@ -461,7 +461,7 @@ bool Keys::addBinding(const string &linebuffer) { const char *str = FbTk::StringUtil::strcasestr(linebuffer.c_str(), val[argc].c_str() + 1); // +1 to skip ':' if (str) - current_key->m_command = FbTk::ObjectRegistry::instance().parse(str); + current_key->m_command = FbTk::CommandParser::instance().parse(str); if (!str || *current_key->m_command == 0 || mod) { delete first_new_key; diff --git a/src/LayerMenu.cc b/src/LayerMenu.cc index 1a52f040..f1d9dd9f 100644 --- a/src/LayerMenu.cc +++ b/src/LayerMenu.cc @@ -50,7 +50,7 @@ LayerMenu::LayerMenu(FbTk::ThemeProxy &tm, {0, 0, _FB_XTEXT(Layer, Desktop, "Desktop", "Layer desktop"), Layer::DESKTOP}, }; - FbTk::RefCount saverc_cmd(new FbCommands::SaveResources()); + FbTk::RefCount > saverc_cmd(new FbCommands::SaveResources()); for (size_t i=0; i < 6; ++i) { // TODO: fetch nls string diff --git a/src/LayerMenu.hh b/src/LayerMenu.hh index 68b8dece..8de0eba9 100644 --- a/src/LayerMenu.hh +++ b/src/LayerMenu.hh @@ -40,7 +40,7 @@ public: class LayerMenuItem : public FbTk::MenuItem { public: LayerMenuItem(const FbTk::FbString &label, LayerObject *object, - int layernum, FbTk::RefCount &cmd): + int layernum, FbTk::RefCount > &cmd): FbTk::MenuItem(label, cmd), m_object(object), m_layernum(layernum) {} LayerMenuItem(const FbTk::FbString &label, LayerObject *object, diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 71c1b56a..12b0f1cb 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc @@ -24,7 +24,7 @@ #include "defaults.hh" #include "Screen.hh" -#include "FbTk/ObjectRegistry.hh" +#include "FbTk/CommandParser.hh" #include "fluxbox.hh" #include "Window.hh" #include "WindowCmd.hh" @@ -209,7 +209,7 @@ static void translateMenuItem(FbTk::Parser &parse, ParseItem &pitem, FbTk::Strin else menu.insert(str_label, submenu); } else if (str_key == "exit") { // exit - FbTk::RefCount exit_cmd(FbTk::ObjectRegistry::instance().parse("exit")); + FbTk::RefCount > exit_cmd(FbTk::CommandParser::instance().parse("exit")); if (str_label.empty()) menu.insert(_FB_XTEXT(Menu, Exit, "Exit", "Exit Command"), exit_cmd); else @@ -217,11 +217,11 @@ static void translateMenuItem(FbTk::Parser &parse, ParseItem &pitem, FbTk::Strin } else if (str_key == "exec") { // execute and hide menu using namespace FbTk; - RefCount exec_cmd(FbTk::ObjectRegistry::instance().parse("exec " + str_cmd)); + RefCount > exec_cmd(FbTk::CommandParser::instance().parse("exec " + str_cmd)); menu.insert(str_label, exec_cmd); } else if (str_key == "macrocmd") { using namespace FbTk; - RefCount macro_cmd(FbTk::ObjectRegistry::instance().parse("macrocmd " + str_cmd)); + RefCount > macro_cmd(FbTk::CommandParser::instance().parse("macrocmd " + str_cmd)); menu.insert(str_label, macro_cmd); } else if (str_key == "style") { // style menu.insert(new StyleMenuItem(str_label, str_cmd)); @@ -313,10 +313,10 @@ static void translateMenuItem(FbTk::Parser &parse, ParseItem &pitem, FbTk::Strin } else if (str_key == "endencoding") { MenuCreator::endEncoding(); } - else { // ok, if we didn't find any special menu item we try with command FbTk::Parser - // we need to attach command with arguments so command FbTk::Parser can parse it + else { // ok, if we didn't find any special menu item we try with command parser + // we need to attach command with arguments so command parser can parse it string line = str_key + " " + str_cmd; - FbTk::RefCount command(FbTk::ObjectRegistry::instance().parse(line)); + FbTk::RefCount > command(FbTk::CommandParser::instance().parse(line)); if (*command != 0) { // special NLS default labels if (str_label.empty()) { @@ -507,7 +507,7 @@ FbTk::Menu *MenuCreator::createMenuType(const string &type, int screen_num) { bool MenuCreator::createWindowMenuItem(const string &type, const string &label, FbTk::Menu &menu) { - typedef FbTk::RefCount RefCmd; + typedef FbTk::RefCount > RefCmd; _FB_USES_NLS; static MenuContext context; diff --git a/src/Remember.cc b/src/Remember.cc index 92a66630..8a5b29e1 100644 --- a/src/Remember.cc +++ b/src/Remember.cc @@ -238,7 +238,7 @@ bool handleStartupItem(const string &line, int offset) { FbCommands::ExecuteCmd *tmp_exec_cmd = new FbCommands::ExecuteCmd(str, screen); #ifdef DEBUG - cerr<<"Executing startup command '"< '"<execute(); delete tmp_exec_cmd; diff --git a/src/RootCmdMenuItem.cc b/src/RootCmdMenuItem.cc index 5cce10ca..c3642ee7 100644 --- a/src/RootCmdMenuItem.cc +++ b/src/RootCmdMenuItem.cc @@ -34,7 +34,7 @@ RootCmdMenuItem::RootCmdMenuItem(const FbTk::FbString &label, m_filename(filename) { std::string prog = cmd.empty() ? realProgramName("fbsetbg") : cmd; - FbTk::RefCount + FbTk::RefCount > setwp_cmd(new FbCommands::ExecuteCmd(prog + " \"" + m_filename + "\"")); setCommand(setwp_cmd); setToggleItem(true); diff --git a/src/Screen.cc b/src/Screen.cc index eba9eb7b..ddfb65f3 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -48,7 +48,7 @@ #include "WinClient.hh" #include "FbWinFrame.hh" #include "Strut.hh" -#include "FbTk/ObjectRegistry.hh" +#include "FbTk/CommandParser.hh" #include "AtomHandler.hh" #include "HeadArea.hh" #include "FbCommands.hh" @@ -168,7 +168,7 @@ class TabPlacementMenuItem: public FbTk::MenuItem { public: TabPlacementMenuItem(FbTk::FbString & label, BScreen &screen, FbWinFrame::TabPlacement place, - FbTk::RefCount &cmd): + FbTk::RefCount > &cmd): FbTk::MenuItem(label, cmd), m_screen(screen), m_place(place) { @@ -773,7 +773,7 @@ void BScreen::propertyNotify(Atom atom) { &ret_bytes_after, (unsigned char **)&str); } - FbTk::RefCount cmd(FbTk::ObjectRegistry::instance().parse(str, false)); + FbTk::RefCount > cmd(FbTk::CommandParser::instance().parse(str, false)); if (cmd.get()) cmd->execute(); XFree(str); @@ -1479,9 +1479,9 @@ void BScreen::initMenu() { if (m_rootmenu.get() == 0) { _FB_USES_NLS; m_rootmenu.reset(createMenu(_FB_XTEXT(Menu, DefaultRootMenu, "Fluxbox default menu", "Title of fallback root menu"))); - FbTk::RefCount restart_fb(FbTk::ObjectRegistry::instance().parse("restart")); - FbTk::RefCount exit_fb(FbTk::ObjectRegistry::instance().parse("exit")); - FbTk::RefCount execute_xterm(FbTk::ObjectRegistry::instance().parse("exec xterm")); + FbTk::RefCount > restart_fb(FbTk::CommandParser::instance().parse("restart")); + FbTk::RefCount > exit_fb(FbTk::CommandParser::instance().parse("exit")); + FbTk::RefCount > execute_xterm(FbTk::CommandParser::instance().parse("exec xterm")); m_rootmenu->setInternalMenu(); m_rootmenu->insert("xterm", execute_xterm); m_rootmenu->insert(_FB_XTEXT(Menu, Restart, "Restart", "Restart command"), @@ -1523,20 +1523,20 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand(); FbTk::MacroCommand *s_a_reconftabs_macro = new FbTk::MacroCommand(); - FbTk::RefCount saverc_cmd(new FbTk::SimpleCommand( + FbTk::RefCount > saverc_cmd(new FbTk::SimpleCommand( *Fluxbox::instance(), &Fluxbox::save_rc)); - FbTk::RefCount reconf_cmd(FbTk::ObjectRegistry::instance().parse("reconfigure")); + FbTk::RefCount > reconf_cmd(FbTk::CommandParser::instance().parse("reconfigure")); - FbTk::RefCount reconftabs_cmd(new FbTk::SimpleCommand( + FbTk::RefCount > reconftabs_cmd(new FbTk::SimpleCommand( *this, &BScreen::reconfigureTabs)); s_a_reconf_macro->add(saverc_cmd); s_a_reconf_macro->add(reconf_cmd); s_a_reconftabs_macro->add(saverc_cmd); s_a_reconftabs_macro->add(reconftabs_cmd); - FbTk::RefCount save_and_reconfigure(s_a_reconf_macro); - FbTk::RefCount save_and_reconftabs(s_a_reconftabs_macro); + FbTk::RefCount > save_and_reconfigure(s_a_reconf_macro); + FbTk::RefCount > save_and_reconftabs(s_a_reconftabs_macro); // create focus menu // we don't set this to internal menu so will // be deleted toghether with the parent @@ -1693,7 +1693,7 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { // in order to save system resources, don't save or reconfigure alpha // settings until after the user is done changing them - FbTk::RefCount delayed_save_and_reconf( + FbTk::RefCount > delayed_save_and_reconf( new FbTk::DelayedCmd(save_and_reconfigure)); FbTk::MenuItem *focused_alpha_item = diff --git a/src/SendToMenu.cc b/src/SendToMenu.cc index 44840dd0..ae261b9d 100644 --- a/src/SendToMenu.cc +++ b/src/SendToMenu.cc @@ -32,7 +32,7 @@ #include "FbTk/MultiButtonMenuItem.hh" #include "FbTk/Command.hh" -class SendToCmd: public FbTk::Command { +class SendToCmd: public FbTk::Command { public: SendToCmd(int workspace, bool follow): m_workspace(workspace), @@ -78,8 +78,8 @@ void SendToMenu::update(FbTk::Subject *subj) { BScreen *screen = Fluxbox::instance()->findScreen(screenNumber()); const BScreen::Workspaces &wlist = screen->getWorkspacesList(); for (size_t i = 0; i < wlist.size(); ++i) { - FbTk::RefCount sendto_cmd(new SendToCmd(i, false)); - FbTk::RefCount sendto_follow_cmd(new SendToCmd(i, true)); + FbTk::RefCount > sendto_cmd(new SendToCmd(i, false)); + FbTk::RefCount > sendto_follow_cmd(new SendToCmd(i, true)); FbTk::MultiButtonMenuItem* item = new FbTk::MultiButtonMenuItem(3, wlist[i]->name()); item->setCommand(1, sendto_cmd); diff --git a/src/Slit.cc b/src/Slit.cc index b412eecf..18c21f4b 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -176,7 +176,7 @@ namespace { class SlitClientMenuItem: public FbTk::MenuItem{ public: - explicit SlitClientMenuItem(Slit& slit, SlitClient &client, FbTk::RefCount &cmd): + explicit SlitClientMenuItem(Slit& slit, SlitClient &client, FbTk::RefCount > &cmd): FbTk::MenuItem(client.matchName().c_str(), cmd), m_slit(slit), m_client(client) { setCommand(cmd); FbTk::MenuItem::setSelected(client.visible()); @@ -207,7 +207,7 @@ private: class SlitDirMenuItem: public FbTk::MenuItem { public: - SlitDirMenuItem(const FbTk::FbString &label, Slit &slit, FbTk::RefCount &cmd) + SlitDirMenuItem(const FbTk::FbString &label, Slit &slit, FbTk::RefCount > &cmd) :FbTk::MenuItem(label,cmd), m_slit(slit), m_label(label) { @@ -242,7 +242,7 @@ private: class PlaceSlitMenuItem: public FbTk::MenuItem { public: - PlaceSlitMenuItem(const FbTk::FbString &label, Slit &slit, Slit::Placement place, FbTk::RefCount &cmd): + PlaceSlitMenuItem(const FbTk::FbString &label, Slit &slit, Slit::Placement place, FbTk::RefCount > &cmd): FbTk::MenuItem(label, cmd), m_slit(slit), m_place(place) { setCloseOnClick(false); } @@ -317,7 +317,7 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) // setup timer m_timer.setTimeout(200); // default timeout m_timer.fireOnce(true); - FbTk::RefCount toggle_hidden(new FbTk::SimpleCommand(*this, &Slit::toggleHidden)); + FbTk::RefCount > toggle_hidden(new FbTk::SimpleCommand(*this, &Slit::toggleHidden)); m_timer.setCommand(toggle_hidden); @@ -1178,14 +1178,14 @@ void Slit::updateClientmenu() { m_clientlist_menu.removeAll(); m_clientlist_menu.setLabel(_FB_XTEXT(Slit, ClientsMenu, "Clients", "Slit client menu")); - FbTk::RefCount cycle_up(new FbTk::SimpleCommand(*this, &Slit::cycleClientsUp)); - FbTk::RefCount cycle_down(new FbTk::SimpleCommand(*this, &Slit::cycleClientsDown)); + FbTk::RefCount > cycle_up(new FbTk::SimpleCommand(*this, &Slit::cycleClientsUp)); + FbTk::RefCount > cycle_down(new FbTk::SimpleCommand(*this, &Slit::cycleClientsDown)); m_clientlist_menu.insert(_FB_XTEXT(Slit, CycleUp, "Cycle Up", "Cycle clients upwards"), cycle_up); m_clientlist_menu.insert(_FB_XTEXT(Slit, CycleDown, "Cycle Down", "Cycle clients downwards"), cycle_down); m_clientlist_menu.insert(new FbTk::MenuSeparator()); - FbTk::RefCount reconfig(new FbTk::SimpleCommand(*this, &Slit::reconfigure)); + FbTk::RefCount > reconfig(new FbTk::SimpleCommand(*this, &Slit::reconfigure)); SlitClients::iterator it = m_client_list.begin(); for (; it != m_client_list.end(); ++it) { if ((*it) != 0 && (*it)->window() != 0) @@ -1193,7 +1193,7 @@ void Slit::updateClientmenu() { } m_clientlist_menu.insert(new FbTk::MenuSeparator()); - FbTk::RefCount savecmd(new FbTk::SimpleCommand(*this, &Slit::saveClientList)); + FbTk::RefCount > savecmd(new FbTk::SimpleCommand(*this, &Slit::saveClientList)); m_clientlist_menu.insert(_FB_XTEXT(Slit, SaveSlitList, "Save SlitList", "Saves the current order in the slit"), @@ -1224,9 +1224,9 @@ void Slit::setupMenu() { FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand(); FbTk::MacroCommand *s_a_reconf_slit_macro = new FbTk::MacroCommand(); - FbTk::RefCount saverc_cmd(new FbCommands::SaveResources()); - FbTk::RefCount reconf_cmd(new FbCommands::ReconfigureFluxboxCmd()); - FbTk::RefCount reconf_slit_cmd(new FbTk::SimpleCommand(*this, &Slit::reconfigure)); + FbTk::RefCount > saverc_cmd(new FbCommands::SaveResources()); + FbTk::RefCount > reconf_cmd(new FbCommands::ReconfigureFluxboxCmd()); + FbTk::RefCount > reconf_slit_cmd(new FbTk::SimpleCommand(*this, &Slit::reconfigure)); s_a_reconf_macro->add(saverc_cmd); s_a_reconf_macro->add(reconf_cmd); @@ -1234,8 +1234,8 @@ void Slit::setupMenu() { s_a_reconf_slit_macro->add(saverc_cmd); s_a_reconf_slit_macro->add(reconf_slit_cmd); - FbTk::RefCount save_and_reconfigure(s_a_reconf_macro); - FbTk::RefCount save_and_reconfigure_slit(s_a_reconf_slit_macro); + FbTk::RefCount > save_and_reconfigure(s_a_reconf_macro); + FbTk::RefCount > save_and_reconfigure_slit(s_a_reconf_slit_macro); // it'll be freed by the slitmenu (since not marked internal) @@ -1280,10 +1280,10 @@ void Slit::setupMenu() { 0, 255, m_slitmenu); // setup command for alpha value MacroCommand *alpha_macrocmd = new MacroCommand(); - RefCount alpha_cmd(new SimpleCommand(*this, &Slit::updateAlpha)); + RefCount > alpha_cmd(new SimpleCommand(*this, &Slit::updateAlpha)); alpha_macrocmd->add(saverc_cmd); alpha_macrocmd->add(alpha_cmd); - RefCount set_alpha_cmd(alpha_macrocmd); + RefCount > set_alpha_cmd(alpha_macrocmd); alpha_menuitem->setCommand(set_alpha_cmd); m_slitmenu.insert(alpha_menuitem); diff --git a/src/StyleMenuItem.cc b/src/StyleMenuItem.cc index fde036f5..628935d0 100644 --- a/src/StyleMenuItem.cc +++ b/src/StyleMenuItem.cc @@ -32,7 +32,7 @@ StyleMenuItem::StyleMenuItem(const FbTk::FbString &label, const std::string &fil m_filename(filename) { // perform shell style ~ home directory expansion // and insert style - FbTk::RefCount + FbTk::RefCount > setstyle_cmd(new FbCommands:: SetStyleCmd(m_filename)); setCommand(setstyle_cmd); diff --git a/src/ToolFactory.cc b/src/ToolFactory.cc index 87299cc7..074ae711 100644 --- a/src/ToolFactory.cc +++ b/src/ToolFactory.cc @@ -34,7 +34,7 @@ #include "WorkspaceNameTheme.hh" #include "ButtonTheme.hh" -#include "FbTk/ObjectRegistry.hh" +#include "FbTk/CommandParser.hh" #include "Screen.hh" #include "Toolbar.hh" #include "fluxbox.hh" @@ -42,7 +42,7 @@ #include namespace { -class ShowMenuAboveToolbar: public FbTk::Command { +class ShowMenuAboveToolbar: public FbTk::Command { public: explicit ShowMenuAboveToolbar(Toolbar &tbar):m_tbar(tbar) { } void execute() { @@ -92,7 +92,7 @@ ToolbarItem *ToolFactory::create(const std::string &name, const FbTk::FbWindow & WorkspaceNameTool *witem = new WorkspaceNameTool(parent, *m_workspace_theme, screen()); using namespace FbTk; - RefCount showmenu(new ShowMenuAboveToolbar(tbar)); + RefCount > showmenu(new ShowMenuAboveToolbar(tbar)); witem->button().setOnClick(showmenu); item = witem; } else if (name == "iconbar") { @@ -104,7 +104,7 @@ ToolbarItem *ToolFactory::create(const std::string &name, const FbTk::FbWindow & } else if (name == "nextworkspace" || name == "prevworkspace") { - FbTk::RefCount cmd(FbTk::ObjectRegistry::instance().parse(name)); + FbTk::RefCount > cmd(FbTk::CommandParser::instance().parse(name)); if (*cmd == 0) // we need a command return 0; @@ -124,7 +124,7 @@ ToolbarItem *ToolFactory::create(const std::string &name, const FbTk::FbWindow & } else if (name == "nextwindow" || name == "prevwindow") { - FbTk::RefCount cmd(FbTk::ObjectRegistry::instance().parse(name)); + FbTk::RefCount > cmd(FbTk::CommandParser::instance().parse(name)); if (*cmd == 0) // we need a command return 0; diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 24bc66d1..de19d1dc 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -40,7 +40,7 @@ #endif // XINERAMA #include "Strut.hh" -#include "FbTk/ObjectRegistry.hh" +#include "FbTk/CommandParser.hh" #include "Layer.hh" #include "FbTk/I18n.hh" @@ -159,7 +159,7 @@ getString() const { } // end namespace FbTk namespace { -class SetToolbarPlacementCmd: public FbTk::Command { +class SetToolbarPlacementCmd: public FbTk::Command { public: SetToolbarPlacementCmd(Toolbar &tbar, Toolbar::Placement place):m_tbar(tbar), m_place(place) { } void execute() { @@ -266,7 +266,7 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): // setup hide timer m_hide_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay()); - FbTk::RefCount toggle_hidden(new FbTk::SimpleCommand(*this, &Toolbar::toggleHidden)); + FbTk::RefCount > toggle_hidden(new FbTk::SimpleCommand(*this, &Toolbar::toggleHidden)); m_hide_timer.setCommand(toggle_hidden); m_hide_timer.fireOnce(true); @@ -813,14 +813,14 @@ void Toolbar::setupMenus(bool skip_new_placement) { _FB_USES_NLS; using namespace FbTk; - typedef RefCount RefCommand; + typedef RefCount > RefCommand; typedef SimpleCommand ToolbarCommand; menu().setLabel(_FB_XTEXT(Toolbar, Toolbar, "Toolbar", "Title of Toolbar menu")); RefCommand reconfig_toolbar(new ToolbarCommand(*this, &Toolbar::reconfigure)); - RefCommand save_resources(FbTk::ObjectRegistry::instance().parse("saverc")); + RefCommand save_resources(FbTk::CommandParser::instance().parse("saverc")); MacroCommand *toolbar_menuitem_macro = new MacroCommand(); toolbar_menuitem_macro->add(reconfig_toolbar); toolbar_menuitem_macro->add(save_resources); @@ -924,10 +924,10 @@ void Toolbar::setupMenus(bool skip_new_placement) { 0, 255, menu()); // setup command for alpha value MacroCommand *alpha_macrocmd = new MacroCommand(); - RefCount alpha_cmd(new SimpleCommand(*this, &Toolbar::updateAlpha)); + RefCount > alpha_cmd(new SimpleCommand(*this, &Toolbar::updateAlpha)); alpha_macrocmd->add(save_resources); alpha_macrocmd->add(alpha_cmd); - RefCount set_alpha_cmd(alpha_macrocmd); + RefCount > set_alpha_cmd(alpha_macrocmd); alpha_menuitem->setCommand(set_alpha_cmd); menu().insert(alpha_menuitem); diff --git a/src/Window.cc b/src/Window.cc index da0a9fae..3e1ad4e2 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -221,7 +221,7 @@ void tempRaiseFluxboxWindow(FluxboxWindow &win) { } -class SetClientCmd:public FbTk::Command { +class SetClientCmd:public FbTk::Command { public: explicit SetClientCmd(WinClient &client):m_client(client) { } @@ -446,7 +446,7 @@ void FluxboxWindow::init() { m_client->x = wattrib.x; m_client->y = wattrib.y; m_timer.setTimeout(fluxbox.getAutoRaiseDelay()); - FbTk::RefCount raise_cmd(new FbTk::SimpleCommand(*this, + FbTk::RefCount > raise_cmd(new FbTk::SimpleCommand(*this, &FluxboxWindow::raise)); m_timer.setCommand(raise_cmd); m_timer.fireOnce(true); @@ -3971,7 +3971,7 @@ void FluxboxWindow::updateButtons() { frame().removeAllButtons(); using namespace FbTk; - typedef RefCount CommandRef; + typedef RefCount > CommandRef; typedef SimpleCommand WindowCmd; CommandRef iconify_cmd(new WindowCmd(*this, &FluxboxWindow::iconify)); @@ -4142,7 +4142,7 @@ void FluxboxWindow::associateClient(WinClient &client) { frame().theme().unfocusedTheme()->iconbarTheme(), client); frame().createTab(*btn); - FbTk::RefCount setcmd(new SetClientCmd(client)); + FbTk::RefCount > setcmd(new SetClientCmd(client)); btn->setOnClick(setcmd, 1); btn->setTextPadding(Fluxbox::instance()->getTabsPadding()); btn->setPixmap(screen().getTabsUsePixmap()); diff --git a/src/WindowCmd.hh b/src/WindowCmd.hh index 22722836..f979f2ba 100644 --- a/src/WindowCmd.hh +++ b/src/WindowCmd.hh @@ -51,7 +51,7 @@ protected: /// executes action for a dynamic context set in WindowCmd_base template -class WindowCmd: public WindowCmd_base, public FbTk::Command { +class WindowCmd: public WindowCmd_base, public FbTk::Command { public: typedef ReturnType (FluxboxWindow::* Action)(); WindowCmd(Action a):m_action(a) {} diff --git a/src/WorkspaceCmd.cc b/src/WorkspaceCmd.cc index bc71e32b..aba59143 100644 --- a/src/WorkspaceCmd.cc +++ b/src/WorkspaceCmd.cc @@ -31,7 +31,7 @@ #include "WindowCmd.hh" #include "FbTk/KeyUtil.hh" -#include "FbTk/ObjectRegistry.hh" +#include "FbTk/CommandParser.hh" #include "FbTk/stringstream.hh" #include "FbTk/StringUtil.hh" @@ -45,16 +45,14 @@ #include using std::string; -using FbTk::Command; -using FbTk::BoolCommand; -REGISTER_OBJECT_PARSER(map, WindowListCmd::parse, Command); -REGISTER_OBJECT_PARSER(foreach, WindowListCmd::parse, Command); +REGISTER_COMMAND_PARSER(map, WindowListCmd::parse, void); +REGISTER_COMMAND_PARSER(foreach, WindowListCmd::parse, void); -FbTk::Command *WindowListCmd::parse(const string &command, const string &args, +FbTk::Command *WindowListCmd::parse(const string &command, const string &args, bool trusted) { - FbTk::Command *cmd = 0; - FbTk::BoolCommand *filter = 0; + FbTk::Command *cmd = 0; + FbTk::Command *filter = 0; std::vector tokens; int opts; string pat; @@ -63,19 +61,19 @@ FbTk::Command *WindowListCmd::parse(const string &command, const string &args, if (tokens.empty()) return 0; - cmd = FbTk::ObjectRegistry::instance().parse(tokens[0], trusted); + cmd = FbTk::CommandParser::instance().parse(tokens[0], trusted); if (!cmd) return 0; if (tokens.size() > 1) { FocusableList::parseArgs(tokens[1], opts, pat); - filter = FbTk::ObjectRegistry::instance().parse(pat, + filter = FbTk::CommandParser::instance().parse(pat, trusted); } - return new WindowListCmd(FbTk::RefCount(cmd), opts, - FbTk::RefCount(filter)); + return new WindowListCmd(FbTk::RefCount >(cmd), opts, + FbTk::RefCount >(filter)); } void WindowListCmd::execute() { @@ -92,29 +90,29 @@ void WindowListCmd::execute() { WindowCmd::setWindow((*it)->fbwindow()); else if (typeid(**it) == typeid(WinClient)) WindowCmd::setClient(dynamic_cast(*it)); - if (!*m_filter || m_filter->bool_execute()) + if (!*m_filter || m_filter->execute()) m_cmd->execute(); } WindowCmd::setClient(old); } } -FbTk::BoolCommand *SomeCmd::parse(const string &command, const string &args, +FbTk::Command *SomeCmd::parse(const string &command, const string &args, bool trusted) { - FbTk::BoolCommand *boolcmd = - FbTk::ObjectRegistry::instance().parse(args, + FbTk::Command *boolcmd = + FbTk::CommandParser::instance().parse(args, trusted); if (!boolcmd) return 0; if (command == "some") - return new SomeCmd(FbTk::RefCount(boolcmd)); - return new EveryCmd(FbTk::RefCount(boolcmd)); + return new SomeCmd(FbTk::RefCount >(boolcmd)); + return new EveryCmd(FbTk::RefCount >(boolcmd)); } -REGISTER_OBJECT_PARSER(some, SomeCmd::parse, BoolCommand); -REGISTER_OBJECT_PARSER(every, SomeCmd::parse, BoolCommand); +REGISTER_COMMAND_PARSER(some, SomeCmd::parse, bool); +REGISTER_COMMAND_PARSER(every, SomeCmd::parse, bool); -bool SomeCmd::bool_execute() { +bool SomeCmd::execute() { BScreen *screen = Fluxbox::instance()->keyScreen(); if (screen != 0) { FocusControl::Focusables win_list(screen->focusControl().creationOrderList().clientList()); @@ -127,7 +125,7 @@ bool SomeCmd::bool_execute() { WinClient *client = dynamic_cast(*it); if (!client) continue; WindowCmd::setClient(client); - if (m_cmd->bool_execute()) + if (m_cmd->execute()) return true; } WindowCmd::setClient(old); @@ -135,7 +133,7 @@ bool SomeCmd::bool_execute() { return false; } -bool EveryCmd::bool_execute() { +bool EveryCmd::execute() { BScreen *screen = Fluxbox::instance()->keyScreen(); if (screen != 0) { FocusControl::Focusables win_list(screen->focusControl().creationOrderList().clientList()); @@ -148,7 +146,7 @@ bool EveryCmd::bool_execute() { WinClient *client = dynamic_cast(*it); if (!client) continue; WindowCmd::setClient(client); - if (!m_cmd->bool_execute()) + if (!m_cmd->execute()) return false; } WindowCmd::setClient(old); @@ -158,7 +156,7 @@ bool EveryCmd::bool_execute() { namespace { -FbTk::Command *parseWindowList(const string &command, +FbTk::Command *parseWindowList(const string &command, const string &args, bool trusted) { int opts; string pat; @@ -179,11 +177,11 @@ FbTk::Command *parseWindowList(const string &command, return 0; } -REGISTER_OBJECT_PARSER(attach, parseWindowList, Command); -REGISTER_OBJECT_PARSER(nextwindow, parseWindowList, Command); -REGISTER_OBJECT_PARSER(nextgroup, parseWindowList, Command); -REGISTER_OBJECT_PARSER(prevwindow, parseWindowList, Command); -REGISTER_OBJECT_PARSER(prevgroup, parseWindowList, Command); +REGISTER_COMMAND_PARSER(attach, parseWindowList, void); +REGISTER_COMMAND_PARSER(nextwindow, parseWindowList, void); +REGISTER_COMMAND_PARSER(nextgroup, parseWindowList, void); +REGISTER_COMMAND_PARSER(prevwindow, parseWindowList, void); +REGISTER_COMMAND_PARSER(prevgroup, parseWindowList, void); }; // end anonymous namespace @@ -219,7 +217,7 @@ void PrevWindowCmd::execute() { screen->cycleFocus(m_option, &m_pat, true); } -FbTk::Command *GoToWindowCmd::parse(const string &command, +FbTk::Command *GoToWindowCmd::parse(const string &command, const string &arguments, bool trusted) { int num, opts; string args, pat; @@ -232,7 +230,7 @@ FbTk::Command *GoToWindowCmd::parse(const string &command, return new GoToWindowCmd(num, opts, pat); } -REGISTER_OBJECT_PARSER(gotowindow, GoToWindowCmd::parse, Command); +REGISTER_COMMAND_PARSER(gotowindow, GoToWindowCmd::parse, void); void GoToWindowCmd::execute() { BScreen *screen = Fluxbox::instance()->keyScreen(); @@ -243,7 +241,7 @@ void GoToWindowCmd::execute() { } } -FbTk::Command *DirFocusCmd::parse(const string &command, +FbTk::Command *DirFocusCmd::parse(const string &command, const string &args, bool trusted) { if (command == "focusup") return new DirFocusCmd(FocusControl::FOCUSUP); @@ -256,10 +254,10 @@ FbTk::Command *DirFocusCmd::parse(const string &command, return 0; } -REGISTER_OBJECT_PARSER(focusup, DirFocusCmd::parse, Command); -REGISTER_OBJECT_PARSER(focusdown, DirFocusCmd::parse, Command); -REGISTER_OBJECT_PARSER(focusleft, DirFocusCmd::parse, Command); -REGISTER_OBJECT_PARSER(focusright, DirFocusCmd::parse, Command); +REGISTER_COMMAND_PARSER(focusup, DirFocusCmd::parse, void); +REGISTER_COMMAND_PARSER(focusdown, DirFocusCmd::parse, void); +REGISTER_COMMAND_PARSER(focusleft, DirFocusCmd::parse, void); +REGISTER_COMMAND_PARSER(focusright, DirFocusCmd::parse, void); void DirFocusCmd::execute() { BScreen *screen = Fluxbox::instance()->keyScreen(); @@ -271,7 +269,7 @@ void DirFocusCmd::execute() { screen->focusControl().dirFocus(*win, m_dir); } -REGISTER_OBJECT(addworkspace, AddWorkspaceCmd, Command); +REGISTER_COMMAND(addworkspace, AddWorkspaceCmd, void); void AddWorkspaceCmd::execute() { BScreen *screen = Fluxbox::instance()->mouseScreen(); @@ -279,7 +277,7 @@ void AddWorkspaceCmd::execute() { screen->addWorkspace(); } -REGISTER_OBJECT(removelastworkspace, RemoveLastWorkspaceCmd, Command); +REGISTER_COMMAND(removelastworkspace, RemoveLastWorkspaceCmd, void); void RemoveLastWorkspaceCmd::execute() { BScreen *screen = Fluxbox::instance()->mouseScreen(); @@ -289,7 +287,7 @@ void RemoveLastWorkspaceCmd::execute() { namespace { -FbTk::Command *parseIntCmd(const string &command, const string &args, +FbTk::Command *parseIntCmd(const string &command, const string &args, bool trusted) { int num = 1; FbTk_istringstream iss(args.c_str()); @@ -308,11 +306,11 @@ FbTk::Command *parseIntCmd(const string &command, const string &args, return 0; } -REGISTER_OBJECT_PARSER(nextworkspace, parseIntCmd, Command); -REGISTER_OBJECT_PARSER(prevworkspace, parseIntCmd, Command); -REGISTER_OBJECT_PARSER(rightworkspace, parseIntCmd, Command); -REGISTER_OBJECT_PARSER(leftworkspace, parseIntCmd, Command); -REGISTER_OBJECT_PARSER(workspace, parseIntCmd, Command); +REGISTER_COMMAND_PARSER(nextworkspace, parseIntCmd, void); +REGISTER_COMMAND_PARSER(prevworkspace, parseIntCmd, void); +REGISTER_COMMAND_PARSER(rightworkspace, parseIntCmd, void); +REGISTER_COMMAND_PARSER(leftworkspace, parseIntCmd, void); +REGISTER_COMMAND_PARSER(workspace, parseIntCmd, void); }; // end anonymous namespace @@ -355,7 +353,7 @@ void JumpToWorkspaceCmd::execute() { } } -REGISTER_OBJECT(arrangewindows, ArrangeWindowsCmd, Command); +REGISTER_COMMAND(arrangewindows, ArrangeWindowsCmd, void); /** try to arrange the windows on the current workspace in a 'clever' way. @@ -481,7 +479,7 @@ void ArrangeWindowsCmd::execute() { } } -REGISTER_OBJECT(showdesktop, ShowDesktopCmd, Command); +REGISTER_COMMAND(showdesktop, ShowDesktopCmd, void); void ShowDesktopCmd::execute() { BScreen *screen = Fluxbox::instance()->mouseScreen(); @@ -497,7 +495,7 @@ void ShowDesktopCmd::execute() { } } -REGISTER_OBJECT(closeallwindows, CloseAllWindowsCmd, Command); +REGISTER_COMMAND(closeallwindows, CloseAllWindowsCmd, void); void CloseAllWindowsCmd::execute() { BScreen *screen = Fluxbox::instance()->mouseScreen(); diff --git a/src/WorkspaceCmd.hh b/src/WorkspaceCmd.hh index f0948949..d50c0bf6 100644 --- a/src/WorkspaceCmd.hh +++ b/src/WorkspaceCmd.hh @@ -28,45 +28,45 @@ #include "ClientPattern.hh" #include "FocusControl.hh" -class WindowListCmd: public FbTk::Command { +class WindowListCmd: public FbTk::Command { public: - WindowListCmd(FbTk::RefCount cmd, int opts, - FbTk::RefCount filter): + WindowListCmd(FbTk::RefCount > cmd, int opts, + FbTk::RefCount > filter): m_cmd(cmd), m_opts(opts), m_filter(filter) { } void execute(); - static FbTk::Command *parse(const std::string &command, + static FbTk::Command *parse(const std::string &command, const std::string &args, bool trusted); private: - FbTk::RefCount m_cmd; + FbTk::RefCount > m_cmd; int m_opts; - FbTk::RefCount m_filter; + FbTk::RefCount > m_filter; }; -class SomeCmd: public FbTk::BoolCommand { +class SomeCmd: public FbTk::Command { public: - SomeCmd(FbTk::RefCount cmd): m_cmd(cmd) { } + SomeCmd(FbTk::RefCount > cmd): m_cmd(cmd) { } - bool bool_execute(); - static FbTk::BoolCommand *parse(const std::string &command, + bool execute(); + static FbTk::Command *parse(const std::string &command, const std::string &args, bool trusted); private: - FbTk::RefCount m_cmd; + FbTk::RefCount > m_cmd; }; -class EveryCmd: public FbTk::BoolCommand { +class EveryCmd: public FbTk::Command { public: - EveryCmd(FbTk::RefCount cmd): m_cmd(cmd) { } + EveryCmd(FbTk::RefCount > cmd): m_cmd(cmd) { } - bool bool_execute(); + bool execute(); private: - FbTk::RefCount m_cmd; + FbTk::RefCount > m_cmd; }; -class AttachCmd: public FbTk::Command { +class AttachCmd: public FbTk::Command { public: explicit AttachCmd(const std::string &pat): m_pat(pat.c_str()) { } void execute(); @@ -74,7 +74,7 @@ private: const ClientPattern m_pat; }; -class NextWindowCmd: public FbTk::Command { +class NextWindowCmd: public FbTk::Command { public: explicit NextWindowCmd(int option, std::string &pat): m_option(option), m_pat(pat.c_str()) { } @@ -84,7 +84,7 @@ private: const ClientPattern m_pat; }; -class PrevWindowCmd: public FbTk::Command { +class PrevWindowCmd: public FbTk::Command { public: explicit PrevWindowCmd(int option, std::string &pat): m_option(option), m_pat(pat.c_str()) { } @@ -94,12 +94,12 @@ private: const ClientPattern m_pat; }; -class GoToWindowCmd: public FbTk::Command { +class GoToWindowCmd: public FbTk::Command { public: GoToWindowCmd(int num, int option, std::string &pat): m_num(num), m_option(option), m_pat(pat.c_str()) { } void execute(); - static FbTk::Command *parse(const std::string &command, + static FbTk::Command *parse(const std::string &command, const std::string &args, bool trusted); private: const int m_num; @@ -107,27 +107,27 @@ private: const ClientPattern m_pat; }; -class DirFocusCmd: public FbTk::Command { +class DirFocusCmd: public FbTk::Command { public: explicit DirFocusCmd(const FocusControl::FocusDir dir): m_dir(dir) { } void execute(); - static FbTk::Command *parse(const std::string &command, + static FbTk::Command *parse(const std::string &command, const std::string &args, bool trusted); private: const FocusControl::FocusDir m_dir; }; -class AddWorkspaceCmd: public FbTk::Command { +class AddWorkspaceCmd: public FbTk::Command { public: void execute(); }; -class RemoveLastWorkspaceCmd: public FbTk::Command { +class RemoveLastWorkspaceCmd: public FbTk::Command { public: void execute(); }; -class NextWorkspaceCmd: public FbTk::Command { +class NextWorkspaceCmd: public FbTk::Command { public: explicit NextWorkspaceCmd(int option):m_option(option) { } void execute(); @@ -135,7 +135,7 @@ private: const int m_option; }; -class PrevWorkspaceCmd: public FbTk::Command { +class PrevWorkspaceCmd: public FbTk::Command { public: explicit PrevWorkspaceCmd(int option):m_option(option) { } void execute(); @@ -143,7 +143,7 @@ private: const int m_option; }; -class LeftWorkspaceCmd: public FbTk::Command { +class LeftWorkspaceCmd: public FbTk::Command { public: explicit LeftWorkspaceCmd(int num=1):m_param(num == 0 ? 1 : num) { } void execute(); @@ -151,7 +151,7 @@ private: const int m_param; }; -class RightWorkspaceCmd: public FbTk::Command { +class RightWorkspaceCmd: public FbTk::Command { public: explicit RightWorkspaceCmd(int num=1):m_param(num == 0 ? 1 : num) { } void execute(); @@ -159,7 +159,7 @@ private: const int m_param; }; -class JumpToWorkspaceCmd: public FbTk::Command { +class JumpToWorkspaceCmd: public FbTk::Command { public: explicit JumpToWorkspaceCmd(int workspace_num); void execute(); @@ -168,17 +168,17 @@ private: }; /// arranges windows in current workspace to rows and columns -class ArrangeWindowsCmd: public FbTk::Command { +class ArrangeWindowsCmd: public FbTk::Command { public: void execute(); }; -class ShowDesktopCmd: public FbTk::Command { +class ShowDesktopCmd: public FbTk::Command { public: void execute(); }; -class CloseAllWindowsCmd: public FbTk::Command { +class CloseAllWindowsCmd: public FbTk::Command { public: void execute(); }; diff --git a/src/WorkspaceMenu.cc b/src/WorkspaceMenu.cc index 3f417edb..5a831701 100644 --- a/src/WorkspaceMenu.cc +++ b/src/WorkspaceMenu.cc @@ -25,7 +25,7 @@ #include "Workspace.hh" #include "WorkspaceCmd.hh" #include "MenuCreator.hh" -#include "FbTk/ObjectRegistry.hh" +#include "FbTk/CommandParser.hh" #include "FbCommands.hh" #include "Layer.hh" @@ -92,7 +92,7 @@ void WorkspaceMenu::update(FbTk::Subject *subj) { FbTk::MultiButtonMenuItem* mb_menu = new FbTk::MultiButtonMenuItem(5, wkspc->name().c_str(), &wkspc->menu()); - FbTk::RefCount jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID())); + FbTk::RefCount > jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID())); mb_menu->setCommand(3, jump_cmd); insert(mb_menu, workspace + IDX_AFTER_ICONS); } @@ -124,28 +124,28 @@ void WorkspaceMenu::init(BScreen &screen) { FbTk::MultiButtonMenuItem* mb_menu = new FbTk::MultiButtonMenuItem(5, wkspc->name().c_str(), &wkspc->menu()); - FbTk::RefCount jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID())); + FbTk::RefCount > jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID())); mb_menu->setCommand(2, jump_cmd); insert(mb_menu, workspace + IDX_AFTER_ICONS); } setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true); - RefCount saverc_cmd(new FbCommands::SaveResources()); + RefCount > saverc_cmd(new FbCommands::SaveResources()); MacroCommand *new_workspace_macro = new MacroCommand(); - RefCount addworkspace(new SimpleCommand(screen, &BScreen::addWorkspace)); + RefCount > addworkspace(new SimpleCommand(screen, (SimpleCommand::Action)&BScreen::addWorkspace)); new_workspace_macro->add(addworkspace); new_workspace_macro->add(saverc_cmd); - RefCount new_workspace_cmd(new_workspace_macro); + RefCount > new_workspace_cmd(new_workspace_macro); MacroCommand *remove_workspace_macro = new MacroCommand(); - RefCount rmworkspace(new SimpleCommand(screen, &BScreen::removeLastWorkspace)); + RefCount > rmworkspace(new SimpleCommand(screen, (SimpleCommand::Action)&BScreen::removeLastWorkspace)); remove_workspace_macro->add(rmworkspace); remove_workspace_macro->add(saverc_cmd); - RefCount remove_last_cmd(remove_workspace_macro); + RefCount > remove_last_cmd(remove_workspace_macro); - RefCount start_edit(FbTk::ObjectRegistry::instance().parse("setworkspacenamedialog")); + RefCount > start_edit(FbTk::CommandParser::instance().parse("setworkspacenamedialog")); insert(new FbTk::MenuSeparator()); insert(_FB_XTEXT(Workspace, NewWorkspace, "New Workspace", "Add a new workspace"), diff --git a/src/Xinerama.hh b/src/Xinerama.hh index 4e7d06f2..f58b4f0d 100644 --- a/src/Xinerama.hh +++ b/src/Xinerama.hh @@ -40,7 +40,7 @@ template class XineramaHeadMenuItem : public FbTk::MenuItem { public: XineramaHeadMenuItem(const FbTk::FbString &label, ItemType &object, int headnum, - FbTk::RefCount &cmd): + FbTk::RefCount > &cmd): FbTk::MenuItem(label,cmd), m_object(object), m_headnum(headnum) {} XineramaHeadMenuItem(const FbTk::FbString &label, ItemType &object, int headnum): FbTk::MenuItem(label), m_object(object), m_headnum(headnum) {} @@ -79,7 +79,7 @@ XineramaHeadMenu::XineramaHeadMenu( m_object(item) { setLabel(title); - FbTk::RefCount saverc_cmd(new FbTk::SimpleCommand( + FbTk::RefCount > saverc_cmd(new FbTk::SimpleCommand( *Fluxbox::instance(), &Fluxbox::save_rc)); char tname[128]; diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 5a6db71d..2ebf931d 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -263,7 +263,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile // Because when the command is executed we shouldn't do reconfig directly // because it could affect ongoing menu stuff so we need to reconfig in // the next event "round". - FbTk::RefCount reconfig_cmd(new FbTk::SimpleCommand(*this, &Fluxbox::timed_reconfigure)); + FbTk::RefCount > reconfig_cmd(new FbTk::SimpleCommand(*this, &Fluxbox::timed_reconfigure)); timeval to; to.tv_sec = 0; to.tv_usec = 1; @@ -1034,7 +1034,7 @@ void Fluxbox::handleSignal(int signum) { break; default: fprintf(stderr, - _FB_CONSOLETEXT(BaseDisplay, SignalCaught, "%s: signal %d caught\n", "signal catch debug message. Include %s for command and %d for signal number").c_str(), + _FB_CONSOLETEXT(BaseDisplay, SignalCaught, "%s: signal %d caught\n", "signal catch debug message. Include %s for Command and %d for signal number").c_str(), m_argv[0], signum); if (! m_starting && ! re_enter) {