all repos — fluxbox @ 467fefaae453e0c1eae0340f1d1d7d89eafd3e22

custom fork of the fluxbox windowmanager

more more fun with the window menu
Mark Tiefenbruck mark@fluxbox.org
commit

467fefaae453e0c1eae0340f1d1d7d89eafd3e22

parent

130012c01056250e969d02bc82a26e4a28899e1a

5 files changed, 84 insertions(+), 55 deletions(-)

jump to
M src/AlphaMenu.ccsrc/AlphaMenu.cc

@@ -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 @@ FbTk::ImageControl &imgctrl, FbTk::XLayer &layer):

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;
M src/AlphaMenu.hhsrc/AlphaMenu.hh

@@ -25,6 +25,7 @@ #define ALPHAMENU_HH

#include "ToggleMenu.hh" #include "WindowCmd.hh" +#include "WindowMenuAccessor.hh" #include "FbTk/MenuItem.hh" class AlphaMenu : public ToggleMenu {

@@ -47,7 +48,7 @@ setCloseOnClick(false);

} 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) {
M src/MenuCreator.ccsrc/MenuCreator.cc

@@ -28,6 +28,7 @@ #include "FbTk/CommandParser.hh"

#include "fluxbox.hh" #include "Window.hh" #include "WindowCmd.hh" +#include "WindowMenuAccessor.hh" #include "ClientMenu.hh" #include "WorkspaceMenu.hh"

@@ -480,7 +481,7 @@

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 @@ maximize_item->setCommand(2, maximize_vert_cmd);

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 @@ "Raise", "Raise the window"):

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,
M src/WindowCmd.hhsrc/WindowCmd.hh

@@ -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
A src/WindowMenuAccessor.hh

@@ -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