From 5a91d8747e4ab0bb25b85c82e49f6f74d8e14e05 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sat, 20 Dec 2003 17:42:04 +0000 Subject: bindkey command --- src/FbCommandFactory.cc | 5 ++++- src/FbCommands.cc | 18 ++++++++++++++++-- src/FbCommands.hh | 10 +++++++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc index 91348fa..d3ea8ce 100644 --- a/src/FbCommandFactory.cc +++ b/src/FbCommandFactory.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbCommandFactory.cc,v 1.23 2003/12/19 18:17:08 fluxgen Exp $ +// $Id: FbCommandFactory.cc,v 1.24 2003/12/20 17:42:04 fluxgen Exp $ #include "FbCommandFactory.hh" @@ -61,6 +61,7 @@ FbCommandFactory::FbCommandFactory() { // setup commands that we can handle const char* commands[] = { "arrangewindows", + "bindkey", "close", "commanddialog", "detachclient", @@ -153,6 +154,8 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, return new FbTk::SimpleCommand(*Fluxbox::instance(), &Fluxbox::shutdown); else if (command == "commanddialog") // run specified fluxbox command return new CommandDialogCmd(); + else if (command == "bindkey") + return new BindKeyCmd(arguments); else if (command == "setresourcevalue") { // we need to parse arguments as: // diff --git a/src/FbCommands.cc b/src/FbCommands.cc index 91ec11c..d4ad87e 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc @@ -19,13 +19,14 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbCommands.cc,v 1.21 2003/12/19 17:22:04 fluxgen Exp $ +// $Id: FbCommands.cc,v 1.22 2003/12/20 17:41:32 fluxgen Exp $ #include "FbCommands.hh" #include "fluxbox.hh" #include "Screen.hh" #include "CommandDialog.hh" #include "Workspace.hh" +#include "Keys.hh" #include "FbTk/Theme.hh" #include "FbTk/Menu.hh" @@ -33,6 +34,7 @@ #include #include +#include #include using namespace std; @@ -106,7 +108,6 @@ SetStyleCmd::SetStyleCmd(const std::string &filename):m_filename(filename) { } void SetStyleCmd::execute() { - cerr<<"SetStyle: "<saveStyleFilename(m_filename.c_str()); Fluxbox::instance()->save_rc(); FbTk::ThemeManager::instance().load(m_filename); @@ -236,4 +237,17 @@ void SetResourceValueDialogCmd::execute() { win->show(); }; +BindKeyCmd::BindKeyCmd(const std::string &keybind):m_keybind(keybind) { } + +void BindKeyCmd::execute() { + if (Fluxbox::instance()->keys() != 0) { + if (Fluxbox::instance()->keys()->addBinding(m_keybind)) { + ofstream ofile(Fluxbox::instance()->keys()->filename().c_str(), ios::app); + if (!ofile) + return; + ofile<