From 18cf5862495aa6f37110c90286bb6c315a145526 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Thu, 23 Jun 2005 02:57:24 +0000 Subject: new files --- src/LayerMenu.cc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 3 ++- src/WindowCmd.cc | 3 +++ src/WindowCmd.hh | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 src/LayerMenu.cc create mode 100644 src/WindowCmd.cc create mode 100644 src/WindowCmd.hh diff --git a/src/LayerMenu.cc b/src/LayerMenu.cc new file mode 100644 index 0000000..afcd4ac --- /dev/null +++ b/src/LayerMenu.cc @@ -0,0 +1,46 @@ +#include "LayerMenu.hh" + +#include "fluxbox.hh" + +#include "FbTk/RefCount.hh" +#include "FbTk/SimpleCommand.hh" +#include "FbTk/I18n.hh" + +LayerMenu::LayerMenu(MenuTheme &tm, FbTk::ImageControl &imgctrl, + FbTk::XLayer &layer, LayerObject *object, bool save_rc): + ToggleMenu(tm, imgctrl, layer) { + _FB_USES_NLS; + + Fluxbox *fluxbox = Fluxbox::instance(); + + struct { + int set; + int base; + const char *default_str; + int layernum; + } layer_menuitems[] = { + //TODO: nls + {0, 0, _FBTEXT(Layer, AboveDock, "Above Dock", "Layer above dock"), fluxbox->getAboveDockLayer()}, + {0, 0, _FBTEXT(Layer, Dock, "Dock", "Layer dock"), fluxbox->getDockLayer()}, + {0, 0, _FBTEXT(Layer, Top, "Top", "Layer top"), fluxbox->getTopLayer()}, + {0, 0, _FBTEXT(Layer, Normal, "Normal", "Layer normal"), fluxbox->getNormalLayer()}, + {0, 0, _FBTEXT(Layer, Bottom, "Bottom", "Layer bottom"), fluxbox->getBottomLayer()}, + {0, 0, _FBTEXT(Layer, Desktop, "Desktop", "Layer desktop"), fluxbox->getDesktopLayer()}, + }; + + FbTk::RefCount saverc_cmd(new FbTk::SimpleCommand( + *Fluxbox::instance(), + &Fluxbox::save_rc)); + + for (size_t i=0; i < 6; ++i) { + // TODO: fetch nls string + if (save_rc) { + insert(new LayerMenuItem(layer_menuitems[i].default_str, + object, layer_menuitems[i].layernum, saverc_cmd)); + } else { + insert(new LayerMenuItem(layer_menuitems[i].default_str, + object, layer_menuitems[i].layernum)); + } + } + updateMenu(); +} diff --git a/src/Makefile.am b/src/Makefile.am index f49d2ae..9e15d8b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -100,7 +100,7 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \ WinButtonTheme.hh WinButtonTheme.cc \ Window.cc Window.hh \ Workspace.cc Workspace.hh \ - FbCommands.hh FbCommands.cc LayerMenu.hh \ + FbCommands.hh FbCommands.cc LayerMenu.hh LayerMenu.cc \ IntResMenuItem.hh IntResMenuItem.cc FbMenu.hh FbMenu.cc \ WinClient.hh WinClient.cc \ Strut.hh \ @@ -128,6 +128,7 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \ ToggleMenu.hh \ HeadArea.hh HeadArea.cc \ Resources.cc \ + WindowCmd.hh WindowCmd.cc \ ${newwmspec_SOURCE} ${gnome_SOURCE} \ ${REMEMBER_SOURCE} ${REGEXP_SOURCE} ${TOOLBAR_SOURCE} diff --git a/src/WindowCmd.cc b/src/WindowCmd.cc new file mode 100644 index 0000000..c84849f --- /dev/null +++ b/src/WindowCmd.cc @@ -0,0 +1,3 @@ +#include "WindowCmd.hh" + +FluxboxWindow *WindowCmd_base::s_win = 0; diff --git a/src/WindowCmd.hh b/src/WindowCmd.hh new file mode 100644 index 0000000..309e62b --- /dev/null +++ b/src/WindowCmd.hh @@ -0,0 +1,32 @@ +#ifndef WINDOWCMD_HH +#define WINDOWCMD_HH + +#include "FbTk/Command.hh" +#include "Window.hh" + +/// holds context for WindowCmd +class WindowCmd_base { +public: + static void setWindow(FluxboxWindow *win) { s_win = win; } + static FluxboxWindow *window() { return s_win; } +protected: + static FluxboxWindow *s_win; +}; + + +/// executes action for a dynamic context set in WindowCmd_base +template +class WindowCmd: public WindowCmd_base, public FbTk::Command { +public: + typedef ReturnType (FluxboxWindow::* Action)(); + WindowCmd(Action a):m_action(a) {} + void execute() { + if (window() != 0) + (*window().*m_action)(); + } +private: + Action m_action; +}; + + +#endif // WINDOWCMD_HH -- cgit v0.11.2