new files
This commit is contained in:
parent
c912f7a32a
commit
18cf586249
4 changed files with 83 additions and 1 deletions
46
src/LayerMenu.cc
Normal file
46
src/LayerMenu.cc
Normal file
|
@ -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();
|
||||
}
|
|
@ -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}
|
||||
|
||||
|
|
3
src/WindowCmd.cc
Normal file
3
src/WindowCmd.cc
Normal file
|
@ -0,0 +1,3 @@
|
|||
#include "WindowCmd.hh"
|
||||
|
||||
FluxboxWindow *WindowCmd_base::s_win = 0;
|
32
src/WindowCmd.hh
Normal file
32
src/WindowCmd.hh
Normal file
|
@ -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
|
Loading…
Reference in a new issue