diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2008-08-14 05:52:39 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2008-08-14 05:52:39 (GMT) |
commit | e169d33552c8e7070aa6e13da0187f2013b4cfc3 (patch) | |
tree | ae9e92c7e885791c7f47645184070cbcd441ab94 /src/IconbarTool.cc | |
parent | c82e7c0080f8a5c14dcf95ec92dc42f59ea9dd8b (diff) | |
parent | 91ca3bc5c8e2b892a9a81b18246f72aba7deebfd (diff) | |
download | fluxbox-e169d33552c8e7070aa6e13da0187f2013b4cfc3.zip fluxbox-e169d33552c8e7070aa6e13da0187f2013b4cfc3.tar.bz2 |
Merge branch 'master' into to_push
Diffstat (limited to 'src/IconbarTool.cc')
-rw-r--r-- | src/IconbarTool.cc | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index b2a57d0..f2ed082 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc | |||
@@ -39,7 +39,7 @@ | |||
39 | #include "FbTk/STLUtil.hh" | 39 | #include "FbTk/STLUtil.hh" |
40 | #include "FbTk/I18n.hh" | 40 | #include "FbTk/I18n.hh" |
41 | #include "FbTk/Menu.hh" | 41 | #include "FbTk/Menu.hh" |
42 | #include "FbTk/MenuItem.hh" | 42 | #include "FbTk/RadioMenuItem.hh" |
43 | #include "FbTk/BoolMenuItem.hh" | 43 | #include "FbTk/BoolMenuItem.hh" |
44 | #include "FbTk/RefCount.hh" | 44 | #include "FbTk/RefCount.hh" |
45 | #include "FbTk/SimpleCommand.hh" | 45 | #include "FbTk/SimpleCommand.hh" |
@@ -99,18 +99,18 @@ void FbTk::Resource<FbTk::Container::Alignment>::setFromString(const char *str) | |||
99 | 99 | ||
100 | namespace { | 100 | namespace { |
101 | 101 | ||
102 | class ToolbarModeMenuItem : public FbTk::MenuItem { | 102 | class ToolbarModeMenuItem : public FbTk::RadioMenuItem { |
103 | public: | 103 | public: |
104 | ToolbarModeMenuItem(const FbTk::FbString &label, IconbarTool &handler, | 104 | ToolbarModeMenuItem(const FbTk::FbString &label, IconbarTool &handler, |
105 | string mode, | 105 | string mode, |
106 | FbTk::RefCount<FbTk::Command<void> > &cmd): | 106 | FbTk::RefCount<FbTk::Command<void> > &cmd): |
107 | FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) { | 107 | FbTk::RadioMenuItem(label, cmd), m_handler(handler), m_mode(mode) { |
108 | setCloseOnClick(false); | 108 | setCloseOnClick(false); |
109 | } | 109 | } |
110 | bool isEnabled() const { return m_handler.mode() != m_mode; } | 110 | bool isSelected() const { return m_handler.mode() == m_mode; } |
111 | void click(int button, int time, unsigned int mods) { | 111 | void click(int button, int time, unsigned int mods) { |
112 | m_handler.setMode(m_mode); | 112 | m_handler.setMode(m_mode); |
113 | FbTk::MenuItem::click(button, time, mods); | 113 | FbTk::RadioMenuItem::click(button, time, mods); |
114 | } | 114 | } |
115 | 115 | ||
116 | private: | 116 | private: |
@@ -118,18 +118,18 @@ private: | |||
118 | string m_mode; | 118 | string m_mode; |
119 | }; | 119 | }; |
120 | 120 | ||
121 | class ToolbarAlignMenuItem: public FbTk::MenuItem { | 121 | class ToolbarAlignMenuItem: public FbTk::RadioMenuItem { |
122 | public: | 122 | public: |
123 | ToolbarAlignMenuItem(const FbTk::FbString &label, IconbarTool &handler, | 123 | ToolbarAlignMenuItem(const FbTk::FbString &label, IconbarTool &handler, |
124 | FbTk::Container::Alignment mode, | 124 | FbTk::Container::Alignment mode, |
125 | FbTk::RefCount<FbTk::Command<void> > &cmd): | 125 | FbTk::RefCount<FbTk::Command<void> > &cmd): |
126 | FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) { | 126 | FbTk::RadioMenuItem(label, cmd), m_handler(handler), m_mode(mode) { |
127 | setCloseOnClick(false); | 127 | setCloseOnClick(false); |
128 | } | 128 | } |
129 | bool isEnabled() const { return m_handler.alignment() != m_mode; } | 129 | bool isSelected() const { return m_handler.alignment() == m_mode; } |
130 | void click(int button, int time, unsigned int mods) { | 130 | void click(int button, int time, unsigned int mods) { |
131 | m_handler.setAlignment(m_mode); | 131 | m_handler.setAlignment(m_mode); |
132 | FbTk::MenuItem::click(button, time, mods); | 132 | FbTk::RadioMenuItem::click(button, time, mods); |
133 | } | 133 | } |
134 | 134 | ||
135 | private: | 135 | private: |
@@ -214,16 +214,11 @@ class ShowMenu: public FbTk::Command<void> { | |||
214 | public: | 214 | public: |
215 | explicit ShowMenu(FluxboxWindow &win):m_win(win) { } | 215 | explicit ShowMenu(FluxboxWindow &win):m_win(win) { } |
216 | void execute() { | 216 | void execute() { |
217 | // hide the menu if it's already showing for this FluxboxWindow | ||
218 | if (m_win.menu().isVisible() && FbMenu::window() == &m_win) { | ||
219 | m_win.menu().hide(); | ||
220 | return; | ||
221 | } | ||
222 | // get last button pos | 217 | // get last button pos |
223 | const XEvent &event = Fluxbox::instance()->lastEvent(); | 218 | const XEvent &event = Fluxbox::instance()->lastEvent(); |
224 | int x = event.xbutton.x_root - (m_win.menu().width() / 2); | 219 | int x = event.xbutton.x_root - (m_win.menu().width() / 2); |
225 | int y = event.xbutton.y_root - (m_win.menu().height() / 2); | 220 | int y = event.xbutton.y_root - (m_win.menu().height() / 2); |
226 | m_win.showMenu(x, y); | 221 | m_win.popupMenu(x, y); |
227 | } | 222 | } |
228 | private: | 223 | private: |
229 | FluxboxWindow &m_win; | 224 | FluxboxWindow &m_win; |