1
// SendToMenu.cc for Fluxbox
2
// Copyright (c) 2003 - 2005 Henrik Kinnunen (fluxgen at fluxbox dot org)
3
// and Simon Bowden (rathnor at users.sourceforge.net)
5
// Permission is hereby granted, free of charge, to any person obtaining a
6
// copy of this software and associated documentation files (the "Software"),
7
// to deal in the Software without restriction, including without limitation
8
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
// and/or sell copies of the Software, and to permit persons to whom the
10
// Software is furnished to do so, subject to the following conditions:
12
// The above copyright notice and this permission notice shall be included in
13
// all copies or substantial portions of the Software.
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
// DEALINGS IN THE SOFTWARE.
23
// $Id: SendToMenu.cc 4062 2005-06-23 03:07:25Z fluxgen $
25
#include "SendToMenu.hh"
30
#include "Workspace.hh"
31
#include "WindowCmd.hh"
33
#include "FbTk/MultiButtonMenuItem.hh"
34
#include "FbTk/Command.hh"
36
class SendToCmd: public FbTk::Command {
38
SendToCmd(int workspace, bool follow):
39
m_workspace(workspace),
42
if (WindowCmd<void>::window() != 0)
43
WindowCmd<void>::window()->screen().sendToWorkspace(m_workspace, WindowCmd<void>::window(), m_follow);
46
const int m_workspace;
50
SendToMenu::SendToMenu(BScreen &screen):
51
FbMenu(screen.menuTheme(),
52
screen.imageControl(),
53
*screen.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())) {
55
// workspace count signal
56
// workspace names signal
57
// current workspace signal
58
screen.workspaceCountSig().attach(this);
59
screen.workspaceNamesSig().attach(this);
60
screen.currentWorkspaceSig().attach(this);
67
void SendToMenu::update(FbTk::Subject *subj) {
69
if (subj == &(theme().reconfigSig())) {
70
// we got reconfig Theme signal, let base menu handle it
71
FbTk::Menu::update(subj);
79
BScreen *screen = Fluxbox::instance()->findScreen(screenNumber());
80
const BScreen::Workspaces &wlist = screen->getWorkspacesList();
81
for (size_t i = 0; i < wlist.size(); ++i) {
82
FbTk::RefCount<FbTk::Command> sendto_cmd(new SendToCmd(i, false));
83
FbTk::RefCount<FbTk::Command> sendto_follow_cmd(new SendToCmd(i, true));
85
FbTk::MultiButtonMenuItem* item = new FbTk::MultiButtonMenuItem(3, wlist[i]->name().c_str());
86
item->setCommand(1, sendto_cmd);
87
item->setCommand(2, sendto_follow_cmd);
88
item->setCommand(3, sendto_cmd);
95
void SendToMenu::show() {
96
if (WindowCmd<void>::window() != 0) {
97
for (unsigned int i=0; i < numberOfItems(); ++i)
98
setItemEnabled(i, true);
99
setItemEnabled(WindowCmd<void>::window()->workspaceNumber(), false);