new files
fluxgen fluxgen
4 files changed,
83 insertions(+),
1 deletions(-)
A
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<FbTk::Command> saverc_cmd(new FbTk::SimpleCommand<Fluxbox>( + *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(); +}
M
src/Makefile.am
→
src/Makefile.am
@@ -100,7 +100,7 @@ WinButton.hh WinButton.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 @@ FocusModelMenuItem.hh \
ToggleMenu.hh \ HeadArea.hh HeadArea.cc \ Resources.cc \ + WindowCmd.hh WindowCmd.cc \ ${newwmspec_SOURCE} ${gnome_SOURCE} \ ${REMEMBER_SOURCE} ${REGEXP_SOURCE} ${TOOLBAR_SOURCE}
A
src/WindowCmd.cc
@@ -0,0 +1,3 @@
+#include "WindowCmd.hh" + +FluxboxWindow *WindowCmd_base::s_win = 0;
A
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 <typename ReturnType=void> +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