diff options
author | fluxgen <fluxgen> | 2003-01-12 18:19:45 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-01-12 18:19:45 (GMT) |
commit | 55b9d5ffb0c2fd52ff4bf3805840ca3ebf9083fa (patch) | |
tree | 22389e0772fd84852ef994bbf5b597a67f3ab44a /src/Windowmenu.cc | |
parent | 6c7f8c4d15333b22f3556447446d55b9325e28e7 (diff) | |
download | fluxbox-55b9d5ffb0c2fd52ff4bf3805840ca3ebf9083fa.zip fluxbox-55b9d5ffb0c2fd52ff4bf3805840ca3ebf9083fa.tar.bz2 |
replaced by FbTk Menu
Diffstat (limited to 'src/Windowmenu.cc')
-rw-r--r-- | src/Windowmenu.cc | 303 |
1 files changed, 0 insertions, 303 deletions
diff --git a/src/Windowmenu.cc b/src/Windowmenu.cc deleted file mode 100644 index 65655ce..0000000 --- a/src/Windowmenu.cc +++ /dev/null | |||
@@ -1,303 +0,0 @@ | |||
1 | // Windowmenu.cc for Fluxbox | ||
2 | // Copyright (c) 2001-2002 Henrik Kinnunen (fluxgen@linuxmail.org) | ||
3 | // Windowmenu.cc for Blackbox - an X11 Window manager | ||
4 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) | ||
5 | // | ||
6 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
7 | // copy of this software and associated documentation files (the "Software"), | ||
8 | // to deal in the Software without restriction, including without limitation | ||
9 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
10 | // and/or sell copies of the Software, and to permit persons to whom the | ||
11 | // Software is furnished to do so, subject to the following conditions: | ||
12 | // | ||
13 | // The above copyright notice and this permission notice shall be included in | ||
14 | // all copies or substantial portions of the Software. | ||
15 | // | ||
16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
19 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
22 | // DEALINGS IN THE SOFTWARE. | ||
23 | |||
24 | // $Id: Windowmenu.cc,v 1.23 2003/01/05 22:31:36 fluxgen Exp $ | ||
25 | |||
26 | //use GNU extensions | ||
27 | #ifndef _GNU_SOURCE | ||
28 | #define _GNU_SOURCE | ||
29 | #endif // _GNU_SOURCE | ||
30 | |||
31 | #ifdef HAVE_CONFIG_H | ||
32 | #include "config.h" | ||
33 | #endif // HAVE_CONFIG_H | ||
34 | |||
35 | #include "i18n.hh" | ||
36 | #include "fluxbox.hh" | ||
37 | #include "Screen.hh" | ||
38 | #include "Window.hh" | ||
39 | #include "Windowmenu.hh" | ||
40 | #include "Workspace.hh" | ||
41 | |||
42 | #include <cstring> | ||
43 | |||
44 | Windowmenu::Windowmenu(FluxboxWindow &win) : Basemenu(win.getScreen()), | ||
45 | window(win), | ||
46 | screen(win.getScreen()), | ||
47 | sendToMenu(win), | ||
48 | sendGroupToMenu(win) { | ||
49 | |||
50 | setTitleVisibility(False); | ||
51 | setMovable(False); | ||
52 | setInternalMenu(); | ||
53 | |||
54 | I18n *i18n = I18n::instance(); | ||
55 | |||
56 | using namespace FBNLS; | ||
57 | insert(i18n->getMessage( | ||
58 | WindowmenuSet, WindowmenuSendTo, | ||
59 | "Send To ..."), | ||
60 | &sendToMenu); | ||
61 | |||
62 | insert(i18n->getMessage( | ||
63 | WindowmenuSet, WindowmenuSendGroupTo, | ||
64 | "Send Group To ..."), | ||
65 | &sendGroupToMenu); | ||
66 | |||
67 | insert(i18n->getMessage( | ||
68 | WindowmenuSet, WindowmenuShade, | ||
69 | "Shade"), | ||
70 | BScreen::WINDOWSHADE); | ||
71 | insert(i18n->getMessage( | ||
72 | WindowmenuSet, WindowmenuIconify, | ||
73 | "Iconify"), | ||
74 | BScreen::WINDOWICONIFY); | ||
75 | insert(i18n->getMessage( | ||
76 | WindowmenuSet, WindowmenuMaximize, | ||
77 | "Maximize"), | ||
78 | BScreen::WINDOWMAXIMIZE); | ||
79 | insert(i18n->getMessage( | ||
80 | WindowmenuSet, WindowmenuRaise, | ||
81 | "Raise"), | ||
82 | BScreen::WINDOWRAISE); | ||
83 | insert(i18n->getMessage( | ||
84 | WindowmenuSet, WindowmenuLower, | ||
85 | "Lower"), | ||
86 | BScreen::WINDOWLOWER); | ||
87 | insert(i18n->getMessage( | ||
88 | WindowmenuSet, WindowmenuStick, | ||
89 | "Stick"), | ||
90 | BScreen::WINDOWSTICK); | ||
91 | insert(i18n->getMessage( | ||
92 | WindowmenuSet, WindowmenuKillClient, | ||
93 | "Kill Client"), | ||
94 | BScreen::WINDOWKILL); | ||
95 | insert(i18n->getMessage( | ||
96 | WindowmenuSet, WindowmenuClose, | ||
97 | "Close"), | ||
98 | BScreen::WINDOWCLOSE); | ||
99 | insert(i18n->getMessage( | ||
100 | WindowmenuSet, WindowmenuTab, | ||
101 | "Tab"), | ||
102 | BScreen::WINDOWTAB); | ||
103 | |||
104 | update(); | ||
105 | |||
106 | setItemEnabled(2, window.hasTitlebar()); | ||
107 | setItemEnabled(3, window.isIconifiable()); | ||
108 | setItemEnabled(4, window.isMaximizable()); | ||
109 | setItemEnabled(9, window.isClosable()); | ||
110 | setItemEnabled(10, window.isGroupable()); // tab option | ||
111 | |||
112 | } | ||
113 | |||
114 | |||
115 | Windowmenu::~Windowmenu() { | ||
116 | |||
117 | } | ||
118 | |||
119 | |||
120 | void Windowmenu::show() { | ||
121 | if (isItemEnabled(2)) | ||
122 | setItemSelected(2, window.isShaded()); | ||
123 | if (isItemEnabled(4)) | ||
124 | setItemSelected(4, window.isMaximized()); | ||
125 | if (isItemEnabled(7)) | ||
126 | setItemSelected(7, window.isStuck()); | ||
127 | |||
128 | Basemenu::show(); | ||
129 | } | ||
130 | |||
131 | |||
132 | void Windowmenu::itemSelected(int button, unsigned int index) { | ||
133 | BasemenuItem *item = find(index); | ||
134 | hide(); | ||
135 | switch (item->function()) { | ||
136 | case BScreen::WINDOWSHADE: | ||
137 | if (window.isIconic()) | ||
138 | break; | ||
139 | |||
140 | window.shade(); | ||
141 | if (window.hasTab()) | ||
142 | window.getTab()->shade(); | ||
143 | break; | ||
144 | |||
145 | case BScreen::WINDOWICONIFY: | ||
146 | if (!window.isIconic()) | ||
147 | window.iconify(); | ||
148 | else | ||
149 | window.deiconify(); // restore window | ||
150 | |||
151 | break; | ||
152 | |||
153 | case BScreen::WINDOWMAXIMIZE: | ||
154 | window.maximize(); | ||
155 | break; | ||
156 | |||
157 | case BScreen::WINDOWCLOSE: | ||
158 | window.close(); | ||
159 | break; | ||
160 | |||
161 | case BScreen::WINDOWRAISE: | ||
162 | if (window.isIconic()) | ||
163 | break; | ||
164 | |||
165 | if (window.hasTab()) | ||
166 | window.getTab()->raise(); //raise tabs | ||
167 | screen->getWorkspace(window.getWorkspaceNumber())->raiseWindow(&window); | ||
168 | break; | ||
169 | |||
170 | case BScreen::WINDOWLOWER: | ||
171 | if (window.isIconic()) | ||
172 | break; | ||
173 | |||
174 | screen->getWorkspace(window.getWorkspaceNumber())->lowerWindow(&window); | ||
175 | if (window.hasTab()) | ||
176 | window.getTab()->lower(); //lower tabs AND all it's windows | ||
177 | break; | ||
178 | |||
179 | case BScreen::WINDOWSTICK: | ||
180 | window.stick(); | ||
181 | break; | ||
182 | |||
183 | case BScreen::WINDOWKILL: | ||
184 | XKillClient(BaseDisplay::getXDisplay(), | ||
185 | window.getClientWindow()); | ||
186 | break; | ||
187 | case BScreen::WINDOWTAB: | ||
188 | window.setTab(!window.hasTab()); | ||
189 | break; | ||
190 | } | ||
191 | } | ||
192 | |||
193 | |||
194 | void Windowmenu::reconfigure() { | ||
195 | setItemEnabled(1, window.hasTitlebar()); | ||
196 | setItemEnabled(2, window.isIconifiable()); | ||
197 | setItemEnabled(3, window.isMaximizable()); | ||
198 | setItemEnabled(8, window.isClosable()); | ||
199 | setItemEnabled(10, window.isResizable()); // tab option only enabled if resizable | ||
200 | |||
201 | sendToMenu.reconfigure(); | ||
202 | sendGroupToMenu.reconfigure(); | ||
203 | |||
204 | Basemenu::reconfigure(); | ||
205 | } | ||
206 | |||
207 | |||
208 | Windowmenu::SendtoWorkspacemenu::SendtoWorkspacemenu(FluxboxWindow &win): Basemenu(win.getScreen()), | ||
209 | m_fbwindow(win) | ||
210 | { | ||
211 | setTitleVisibility(false); | ||
212 | setMovable(false); | ||
213 | setInternalMenu(); | ||
214 | update(); | ||
215 | } | ||
216 | |||
217 | |||
218 | void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, unsigned int index) { | ||
219 | if (button > 2) | ||
220 | return; | ||
221 | |||
222 | if (index <= screen()->getCount()) { | ||
223 | |||
224 | // no need to send it to a workspace it already exist on | ||
225 | if (index == screen()->getCurrentWorkspaceID()) | ||
226 | return; | ||
227 | |||
228 | if (button == 1) { // send to workspace without changing workspace | ||
229 | screen()->sendToWorkspace(index, &m_fbwindow, false); | ||
230 | } else if (button == 2) { // send to workspace and change workspace | ||
231 | screen()->sendToWorkspace(index, &m_fbwindow, true); | ||
232 | } | ||
233 | } | ||
234 | |||
235 | hide(); | ||
236 | } | ||
237 | |||
238 | |||
239 | void Windowmenu::SendtoWorkspacemenu::update() { | ||
240 | unsigned int i, r = numberOfItems(); | ||
241 | |||
242 | if (numberOfItems() != 0) { | ||
243 | for (i = 0; i < r; ++i) | ||
244 | remove(0); | ||
245 | } | ||
246 | for (i = 0; i < screen()->getCount(); ++i) | ||
247 | insert(screen()->getWorkspace(i)->name().c_str()); | ||
248 | |||
249 | Basemenu::update(); | ||
250 | } | ||
251 | |||
252 | |||
253 | void Windowmenu::SendtoWorkspacemenu::show() { | ||
254 | update(); | ||
255 | |||
256 | Basemenu::show(); | ||
257 | } | ||
258 | |||
259 | Windowmenu::SendGroupToWorkspacemenu:: | ||
260 | SendGroupToWorkspacemenu(FluxboxWindow &win):SendtoWorkspacemenu(win) | ||
261 | { | ||
262 | |||
263 | } | ||
264 | |||
265 | void Windowmenu::SendGroupToWorkspacemenu::itemSelected(int button, unsigned int index) { | ||
266 | if (button > 2) | ||
267 | return; | ||
268 | |||
269 | if (index <= screen()->getCount()) { | ||
270 | if (index == screen()->getCurrentWorkspaceID()) | ||
271 | return; | ||
272 | if (fbwin().isStuck()) | ||
273 | fbwin().stick(); | ||
274 | |||
275 | // if the window is iconic, deiconify it | ||
276 | if (fbwin().isIconic()) | ||
277 | fbwin().deiconify(); | ||
278 | |||
279 | if (button == 1) { | ||
280 | // TODO: use reassociateGroup from BScreen instead | ||
281 | if (fbwin().hasTab()) { | ||
282 | for (Tab *first = Tab::getFirst(fbwin().getTab()); | ||
283 | first!=0; first=first->next()) { | ||
284 | first->withdraw(); | ||
285 | first->getWindow()->withdraw(); | ||
286 | screen()->reassociateWindow(first->getWindow(), index, true); | ||
287 | |||
288 | } | ||
289 | } else { | ||
290 | fbwin().withdraw(); | ||
291 | screen()->reassociateWindow(&fbwin(), index, true); | ||
292 | } | ||
293 | |||
294 | } | ||
295 | |||
296 | if (button == 2) | ||
297 | screen()->changeWorkspaceID(index); | ||
298 | } | ||
299 | hide(); | ||
300 | } | ||
301 | |||
302 | |||
303 | |||