more more fun with the window menu
This commit is contained in:
parent
130012c010
commit
467fefaae4
5 changed files with 84 additions and 55 deletions
|
@ -23,10 +23,8 @@
|
|||
#include "AlphaMenu.hh"
|
||||
|
||||
#include "Window.hh"
|
||||
#include "WindowCmd.hh"
|
||||
#include "Screen.hh"
|
||||
#include "Workspace.hh"
|
||||
#include "WindowCmd.hh"
|
||||
#include "fluxbox.hh"
|
||||
#include "Layer.hh"
|
||||
#include "FbTk/IntMenuItem.hh"
|
||||
|
@ -39,10 +37,10 @@ AlphaMenu::AlphaMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm,
|
|||
ToggleMenu(tm, imgctrl, layer)
|
||||
{
|
||||
|
||||
static WindowAccessor<int> m_focused_alpha((WindowAccessor<int>::Getter)&FluxboxWindow::getFocusedAlpha,
|
||||
(WindowAccessor<int>::Setter)&FluxboxWindow::setFocusedAlpha, 255);
|
||||
static WindowAccessor<int> m_unfocused_alpha((WindowAccessor<int>::Getter)&FluxboxWindow::getUnfocusedAlpha,
|
||||
(WindowAccessor<int>::Setter)&FluxboxWindow::setUnfocusedAlpha, 255);
|
||||
static WindowMenuAccessor<int> m_focused_alpha((WindowMenuAccessor<int>::Getter)&FluxboxWindow::getFocusedAlpha,
|
||||
(WindowMenuAccessor<int>::Setter)&FluxboxWindow::setFocusedAlpha, 255);
|
||||
static WindowMenuAccessor<int> m_unfocused_alpha((WindowMenuAccessor<int>::Getter)&FluxboxWindow::getUnfocusedAlpha,
|
||||
(WindowMenuAccessor<int>::Setter)&FluxboxWindow::setUnfocusedAlpha, 255);
|
||||
|
||||
_FB_USES_NLS;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "ToggleMenu.hh"
|
||||
#include "WindowCmd.hh"
|
||||
#include "WindowMenuAccessor.hh"
|
||||
#include "FbTk/MenuItem.hh"
|
||||
|
||||
class AlphaMenu : public ToggleMenu {
|
||||
|
@ -47,7 +48,7 @@ public:
|
|||
}
|
||||
|
||||
bool isSelected() const {
|
||||
static ConstWindowAccessor<bool> s_is_default(&FluxboxWindow::getUseDefaultAlpha, true);
|
||||
static ConstWindowMenuAccessor<bool> s_is_default(&FluxboxWindow::getUseDefaultAlpha, true);
|
||||
return s_is_default;
|
||||
}
|
||||
void click(int button, int time, unsigned int mods) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "fluxbox.hh"
|
||||
#include "Window.hh"
|
||||
#include "WindowCmd.hh"
|
||||
#include "WindowMenuAccessor.hh"
|
||||
|
||||
#include "ClientMenu.hh"
|
||||
#include "WorkspaceMenu.hh"
|
||||
|
@ -480,7 +481,7 @@ bool MenuCreator::createWindowMenuItem(const string &type,
|
|||
static MenuContext context;
|
||||
|
||||
if (type == "shade") {
|
||||
static WindowAccessor<bool> res(&FluxboxWindow::isShaded, &FluxboxWindow::setShaded, false);
|
||||
static WindowMenuAccessor<bool> res(&FluxboxWindow::isShaded, &FluxboxWindow::setShaded, false);
|
||||
menu.insert(new FbTk::BoolMenuItem(
|
||||
label.empty()?_FB_XTEXT(Windowmenu, Shade, "Shade", "Shade the window"):label,
|
||||
res));
|
||||
|
@ -504,7 +505,7 @@ bool MenuCreator::createWindowMenuItem(const string &type,
|
|||
maximize_item->setCommand(3, maximize_horiz_cmd);
|
||||
menu.insert(maximize_item);
|
||||
} else if (type == "iconify") {
|
||||
static WindowAccessor<bool> res(&FluxboxWindow::isIconic, &FluxboxWindow::setIconic, false);
|
||||
static WindowMenuAccessor<bool> res(&FluxboxWindow::isIconic, &FluxboxWindow::setIconic, false);
|
||||
menu.insert(new FbTk::BoolMenuItem(
|
||||
label.empty() ?
|
||||
_FB_XTEXT(Windowmenu, Iconify,
|
||||
|
@ -536,7 +537,7 @@ bool MenuCreator::createWindowMenuItem(const string &type,
|
|||
label, raise_cmd);
|
||||
|
||||
} else if (type == "stick") {
|
||||
static WindowAccessor<bool> res(&FluxboxWindow::isStuck, &FluxboxWindow::setStuck, false);
|
||||
static WindowMenuAccessor<bool> res(&FluxboxWindow::isStuck, &FluxboxWindow::setStuck, false);
|
||||
menu.insert(new FbTk::BoolMenuItem(
|
||||
label.empty() ?
|
||||
_FB_XTEXT(Windowmenu, Stick,
|
||||
|
|
|
@ -63,49 +63,4 @@ private:
|
|||
Action m_action;
|
||||
};
|
||||
|
||||
/// accesses values in current window
|
||||
template <typename Ret, typename Def=Ret>
|
||||
class WindowAccessor: public FbTk::Accessor<Ret> {
|
||||
public:
|
||||
typedef Ret (FluxboxWindow:: *Getter)() const;
|
||||
typedef void (FluxboxWindow:: *Setter)(Ret);
|
||||
WindowAccessor(Getter g, Setter s, Def def):
|
||||
m_getter(g), m_setter(s), m_def(def) { }
|
||||
|
||||
operator Ret() const {
|
||||
FluxboxWindow *fbwin = WindowCmd<void>::window();
|
||||
return fbwin ? (fbwin->*m_getter)() : m_def;
|
||||
}
|
||||
FbTk::Accessor<Ret> &operator =(const Ret &val) {
|
||||
FluxboxWindow *fbwin = WindowCmd<void>::window();
|
||||
if (fbwin)
|
||||
(fbwin->*m_setter)(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
Getter m_getter;
|
||||
Setter m_setter;
|
||||
Def m_def;
|
||||
};
|
||||
|
||||
/// same as above but only reads
|
||||
template <typename Ret, typename Def=Ret>
|
||||
class ConstWindowAccessor: public FbTk::Accessor<Ret> {
|
||||
public:
|
||||
typedef Ret (FluxboxWindow:: *Getter)() const;
|
||||
ConstWindowAccessor(Getter g, Def def):
|
||||
m_getter(g), m_def(def) { }
|
||||
|
||||
operator Ret() const {
|
||||
FluxboxWindow *fbwin = WindowCmd<void>::window();
|
||||
return fbwin ? (fbwin->*m_getter)() : m_def;
|
||||
}
|
||||
FbTk::Accessor<Ret> &operator =(const Ret &val) { return *this; }
|
||||
|
||||
private:
|
||||
Getter m_getter;
|
||||
Def m_def;
|
||||
};
|
||||
|
||||
#endif // WINDOWCMD_HH
|
||||
|
|
74
src/WindowMenuAccessor.hh
Normal file
74
src/WindowMenuAccessor.hh
Normal file
|
@ -0,0 +1,74 @@
|
|||
// WindowMenuAccessor.hh
|
||||
// Copyright (c) 2008 Fluxbox Team (fluxgen at fluxbox dot org)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef WINDOW_MENU_ACCESSOR_HH
|
||||
#define WINDOW_MENU_ACCESSOR_HH
|
||||
|
||||
#include "FbTk/Accessor.hh"
|
||||
|
||||
#include "FbMenu.hh"
|
||||
|
||||
/// accesses values in current window
|
||||
template <typename Ret, typename Def=Ret>
|
||||
class WindowMenuAccessor: public FbTk::Accessor<Ret> {
|
||||
public:
|
||||
typedef Ret (FluxboxWindow:: *Getter)() const;
|
||||
typedef void (FluxboxWindow:: *Setter)(Ret);
|
||||
WindowMenuAccessor(Getter g, Setter s, Def def):
|
||||
m_getter(g), m_setter(s), m_def(def) { }
|
||||
|
||||
operator Ret() const {
|
||||
FluxboxWindow *fbwin = FbMenu::window();
|
||||
return fbwin ? (fbwin->*m_getter)() : m_def;
|
||||
}
|
||||
FbTk::Accessor<Ret> &operator =(const Ret &val) {
|
||||
FluxboxWindow *fbwin = FbMenu::window();
|
||||
if (fbwin)
|
||||
(fbwin->*m_setter)(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
Getter m_getter;
|
||||
Setter m_setter;
|
||||
Def m_def;
|
||||
};
|
||||
|
||||
/// same as above but only reads
|
||||
template <typename Ret, typename Def=Ret>
|
||||
class ConstWindowMenuAccessor: public FbTk::Accessor<Ret> {
|
||||
public:
|
||||
typedef Ret (FluxboxWindow:: *Getter)() const;
|
||||
ConstWindowMenuAccessor(Getter g, Def def):
|
||||
m_getter(g), m_def(def) { }
|
||||
|
||||
operator Ret() const {
|
||||
FluxboxWindow *fbwin = FbMenu::window();
|
||||
return fbwin ? (fbwin->*m_getter)() : m_def;
|
||||
}
|
||||
FbTk::Accessor<Ret> &operator =(const Ret &val) { return *this; }
|
||||
|
||||
private:
|
||||
Getter m_getter;
|
||||
Def m_def;
|
||||
};
|
||||
|
||||
#endif // WINDOW_MENU_ACCESSOR_HH
|
Loading…
Reference in a new issue