diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-05-28 09:32:57 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-05-28 09:32:57 (GMT) |
commit | 467fefaae453e0c1eae0340f1d1d7d89eafd3e22 (patch) | |
tree | d0dfbeae07795965a27a860adb8f1fe65ab0b57c | |
parent | 130012c01056250e969d02bc82a26e4a28899e1a (diff) | |
download | fluxbox_paul-467fefaae453e0c1eae0340f1d1d7d89eafd3e22.zip fluxbox_paul-467fefaae453e0c1eae0340f1d1d7d89eafd3e22.tar.bz2 |
more more fun with the window menu
-rw-r--r-- | src/AlphaMenu.cc | 10 | ||||
-rw-r--r-- | src/AlphaMenu.hh | 3 | ||||
-rw-r--r-- | src/MenuCreator.cc | 7 | ||||
-rw-r--r-- | src/WindowCmd.hh | 45 | ||||
-rw-r--r-- | src/WindowMenuAccessor.hh | 74 |
5 files changed, 84 insertions, 55 deletions
diff --git a/src/AlphaMenu.cc b/src/AlphaMenu.cc index ef67956..03aca47 100644 --- a/src/AlphaMenu.cc +++ b/src/AlphaMenu.cc | |||
@@ -23,10 +23,8 @@ | |||
23 | #include "AlphaMenu.hh" | 23 | #include "AlphaMenu.hh" |
24 | 24 | ||
25 | #include "Window.hh" | 25 | #include "Window.hh" |
26 | #include "WindowCmd.hh" | ||
27 | #include "Screen.hh" | 26 | #include "Screen.hh" |
28 | #include "Workspace.hh" | 27 | #include "Workspace.hh" |
29 | #include "WindowCmd.hh" | ||
30 | #include "fluxbox.hh" | 28 | #include "fluxbox.hh" |
31 | #include "Layer.hh" | 29 | #include "Layer.hh" |
32 | #include "FbTk/IntMenuItem.hh" | 30 | #include "FbTk/IntMenuItem.hh" |
@@ -39,10 +37,10 @@ AlphaMenu::AlphaMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm, | |||
39 | ToggleMenu(tm, imgctrl, layer) | 37 | ToggleMenu(tm, imgctrl, layer) |
40 | { | 38 | { |
41 | 39 | ||
42 | static WindowAccessor<int> m_focused_alpha((WindowAccessor<int>::Getter)&FluxboxWindow::getFocusedAlpha, | 40 | static WindowMenuAccessor<int> m_focused_alpha((WindowMenuAccessor<int>::Getter)&FluxboxWindow::getFocusedAlpha, |
43 | (WindowAccessor<int>::Setter)&FluxboxWindow::setFocusedAlpha, 255); | 41 | (WindowMenuAccessor<int>::Setter)&FluxboxWindow::setFocusedAlpha, 255); |
44 | static WindowAccessor<int> m_unfocused_alpha((WindowAccessor<int>::Getter)&FluxboxWindow::getUnfocusedAlpha, | 42 | static WindowMenuAccessor<int> m_unfocused_alpha((WindowMenuAccessor<int>::Getter)&FluxboxWindow::getUnfocusedAlpha, |
45 | (WindowAccessor<int>::Setter)&FluxboxWindow::setUnfocusedAlpha, 255); | 43 | (WindowMenuAccessor<int>::Setter)&FluxboxWindow::setUnfocusedAlpha, 255); |
46 | 44 | ||
47 | _FB_USES_NLS; | 45 | _FB_USES_NLS; |
48 | 46 | ||
diff --git a/src/AlphaMenu.hh b/src/AlphaMenu.hh index 41580c3..833b0d2 100644 --- a/src/AlphaMenu.hh +++ b/src/AlphaMenu.hh | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include "ToggleMenu.hh" | 26 | #include "ToggleMenu.hh" |
27 | #include "WindowCmd.hh" | 27 | #include "WindowCmd.hh" |
28 | #include "WindowMenuAccessor.hh" | ||
28 | #include "FbTk/MenuItem.hh" | 29 | #include "FbTk/MenuItem.hh" |
29 | 30 | ||
30 | class AlphaMenu : public ToggleMenu { | 31 | class AlphaMenu : public ToggleMenu { |
@@ -47,7 +48,7 @@ public: | |||
47 | } | 48 | } |
48 | 49 | ||
49 | bool isSelected() const { | 50 | bool isSelected() const { |
50 | static ConstWindowAccessor<bool> s_is_default(&FluxboxWindow::getUseDefaultAlpha, true); | 51 | static ConstWindowMenuAccessor<bool> s_is_default(&FluxboxWindow::getUseDefaultAlpha, true); |
51 | return s_is_default; | 52 | return s_is_default; |
52 | } | 53 | } |
53 | void click(int button, int time, unsigned int mods) { | 54 | void click(int button, int time, unsigned int mods) { |
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 1af5482..8c3ee6b 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "fluxbox.hh" | 28 | #include "fluxbox.hh" |
29 | #include "Window.hh" | 29 | #include "Window.hh" |
30 | #include "WindowCmd.hh" | 30 | #include "WindowCmd.hh" |
31 | #include "WindowMenuAccessor.hh" | ||
31 | 32 | ||
32 | #include "ClientMenu.hh" | 33 | #include "ClientMenu.hh" |
33 | #include "WorkspaceMenu.hh" | 34 | #include "WorkspaceMenu.hh" |
@@ -480,7 +481,7 @@ bool MenuCreator::createWindowMenuItem(const string &type, | |||
480 | static MenuContext context; | 481 | static MenuContext context; |
481 | 482 | ||
482 | if (type == "shade") { | 483 | if (type == "shade") { |
483 | static WindowAccessor<bool> res(&FluxboxWindow::isShaded, &FluxboxWindow::setShaded, false); | 484 | static WindowMenuAccessor<bool> res(&FluxboxWindow::isShaded, &FluxboxWindow::setShaded, false); |
484 | menu.insert(new FbTk::BoolMenuItem( | 485 | menu.insert(new FbTk::BoolMenuItem( |
485 | label.empty()?_FB_XTEXT(Windowmenu, Shade, "Shade", "Shade the window"):label, | 486 | label.empty()?_FB_XTEXT(Windowmenu, Shade, "Shade", "Shade the window"):label, |
486 | res)); | 487 | res)); |
@@ -504,7 +505,7 @@ bool MenuCreator::createWindowMenuItem(const string &type, | |||
504 | maximize_item->setCommand(3, maximize_horiz_cmd); | 505 | maximize_item->setCommand(3, maximize_horiz_cmd); |
505 | menu.insert(maximize_item); | 506 | menu.insert(maximize_item); |
506 | } else if (type == "iconify") { | 507 | } else if (type == "iconify") { |
507 | static WindowAccessor<bool> res(&FluxboxWindow::isIconic, &FluxboxWindow::setIconic, false); | 508 | static WindowMenuAccessor<bool> res(&FluxboxWindow::isIconic, &FluxboxWindow::setIconic, false); |
508 | menu.insert(new FbTk::BoolMenuItem( | 509 | menu.insert(new FbTk::BoolMenuItem( |
509 | label.empty() ? | 510 | label.empty() ? |
510 | _FB_XTEXT(Windowmenu, Iconify, | 511 | _FB_XTEXT(Windowmenu, Iconify, |
@@ -536,7 +537,7 @@ bool MenuCreator::createWindowMenuItem(const string &type, | |||
536 | label, raise_cmd); | 537 | label, raise_cmd); |
537 | 538 | ||
538 | } else if (type == "stick") { | 539 | } else if (type == "stick") { |
539 | static WindowAccessor<bool> res(&FluxboxWindow::isStuck, &FluxboxWindow::setStuck, false); | 540 | static WindowMenuAccessor<bool> res(&FluxboxWindow::isStuck, &FluxboxWindow::setStuck, false); |
540 | menu.insert(new FbTk::BoolMenuItem( | 541 | menu.insert(new FbTk::BoolMenuItem( |
541 | label.empty() ? | 542 | label.empty() ? |
542 | _FB_XTEXT(Windowmenu, Stick, | 543 | _FB_XTEXT(Windowmenu, Stick, |
diff --git a/src/WindowCmd.hh b/src/WindowCmd.hh index f979f2b..34699ad 100644 --- a/src/WindowCmd.hh +++ b/src/WindowCmd.hh | |||
@@ -63,49 +63,4 @@ private: | |||
63 | Action m_action; | 63 | Action m_action; |
64 | }; | 64 | }; |
65 | 65 | ||
66 | /// accesses values in current window | ||
67 | template <typename Ret, typename Def=Ret> | ||
68 | class WindowAccessor: public FbTk::Accessor<Ret> { | ||
69 | public: | ||
70 | typedef Ret (FluxboxWindow:: *Getter)() const; | ||
71 | typedef void (FluxboxWindow:: *Setter)(Ret); | ||
72 | WindowAccessor(Getter g, Setter s, Def def): | ||
73 | m_getter(g), m_setter(s), m_def(def) { } | ||
74 | |||
75 | operator Ret() const { | ||
76 | FluxboxWindow *fbwin = WindowCmd<void>::window(); | ||
77 | return fbwin ? (fbwin->*m_getter)() : m_def; | ||
78 | } | ||
79 | FbTk::Accessor<Ret> &operator =(const Ret &val) { | ||
80 | FluxboxWindow *fbwin = WindowCmd<void>::window(); | ||
81 | if (fbwin) | ||
82 | (fbwin->*m_setter)(val); | ||
83 | return *this; | ||
84 | } | ||
85 | |||
86 | private: | ||
87 | Getter m_getter; | ||
88 | Setter m_setter; | ||
89 | Def m_def; | ||
90 | }; | ||
91 | |||
92 | /// same as above but only reads | ||
93 | template <typename Ret, typename Def=Ret> | ||
94 | class ConstWindowAccessor: public FbTk::Accessor<Ret> { | ||
95 | public: | ||
96 | typedef Ret (FluxboxWindow:: *Getter)() const; | ||
97 | ConstWindowAccessor(Getter g, Def def): | ||
98 | m_getter(g), m_def(def) { } | ||
99 | |||
100 | operator Ret() const { | ||
101 | FluxboxWindow *fbwin = WindowCmd<void>::window(); | ||
102 | return fbwin ? (fbwin->*m_getter)() : m_def; | ||
103 | } | ||
104 | FbTk::Accessor<Ret> &operator =(const Ret &val) { return *this; } | ||
105 | |||
106 | private: | ||
107 | Getter m_getter; | ||
108 | Def m_def; | ||
109 | }; | ||
110 | |||
111 | #endif // WINDOWCMD_HH | 66 | #endif // WINDOWCMD_HH |
diff --git a/src/WindowMenuAccessor.hh b/src/WindowMenuAccessor.hh new file mode 100644 index 0000000..91994b9 --- /dev/null +++ b/src/WindowMenuAccessor.hh | |||
@@ -0,0 +1,74 @@ | |||
1 | // WindowMenuAccessor.hh | ||
2 | // Copyright (c) 2008 Fluxbox Team (fluxgen at fluxbox dot org) | ||
3 | // | ||
4 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | // copy of this software and associated documentation files (the "Software"), | ||
6 | // to deal in the Software without restriction, including without limitation | ||
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | // and/or sell copies of the Software, and to permit persons to whom the | ||
9 | // Software is furnished to do so, subject to the following conditions: | ||
10 | // | ||
11 | // The above copyright notice and this permission notice shall be included in | ||
12 | // all copies or substantial portions of the Software. | ||
13 | // | ||
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | // DEALINGS IN THE SOFTWARE. | ||
21 | |||
22 | #ifndef WINDOW_MENU_ACCESSOR_HH | ||
23 | #define WINDOW_MENU_ACCESSOR_HH | ||
24 | |||
25 | #include "FbTk/Accessor.hh" | ||
26 | |||
27 | #include "FbMenu.hh" | ||
28 | |||
29 | /// accesses values in current window | ||
30 | template <typename Ret, typename Def=Ret> | ||
31 | class WindowMenuAccessor: public FbTk::Accessor<Ret> { | ||
32 | public: | ||
33 | typedef Ret (FluxboxWindow:: *Getter)() const; | ||
34 | typedef void (FluxboxWindow:: *Setter)(Ret); | ||
35 | WindowMenuAccessor(Getter g, Setter s, Def def): | ||
36 | m_getter(g), m_setter(s), m_def(def) { } | ||
37 | |||
38 | operator Ret() const { | ||
39 | FluxboxWindow *fbwin = FbMenu::window(); | ||
40 | return fbwin ? (fbwin->*m_getter)() : m_def; | ||
41 | } | ||
42 | FbTk::Accessor<Ret> &operator =(const Ret &val) { | ||
43 | FluxboxWindow *fbwin = FbMenu::window(); | ||
44 | if (fbwin) | ||
45 | (fbwin->*m_setter)(val); | ||
46 | return *this; | ||
47 | } | ||
48 | |||
49 | private: | ||
50 | Getter m_getter; | ||
51 | Setter m_setter; | ||
52 | Def m_def; | ||
53 | }; | ||
54 | |||
55 | /// same as above but only reads | ||
56 | template <typename Ret, typename Def=Ret> | ||
57 | class ConstWindowMenuAccessor: public FbTk::Accessor<Ret> { | ||
58 | public: | ||
59 | typedef Ret (FluxboxWindow:: *Getter)() const; | ||
60 | ConstWindowMenuAccessor(Getter g, Def def): | ||
61 | m_getter(g), m_def(def) { } | ||
62 | |||
63 | operator Ret() const { | ||
64 | FluxboxWindow *fbwin = FbMenu::window(); | ||
65 | return fbwin ? (fbwin->*m_getter)() : m_def; | ||
66 | } | ||
67 | FbTk::Accessor<Ret> &operator =(const Ret &val) { return *this; } | ||
68 | |||
69 | private: | ||
70 | Getter m_getter; | ||
71 | Def m_def; | ||
72 | }; | ||
73 | |||
74 | #endif // WINDOW_MENU_ACCESSOR_HH | ||