aboutsummaryrefslogtreecommitdiff
path: root/src/SendToMenu.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2005-06-23 03:07:25 (GMT)
committerfluxgen <fluxgen>2005-06-23 03:07:25 (GMT)
commit5373f6d840abaa49685c15fee2f411e77472a7da (patch)
tree46da25845eac32769bad85c264e4edf335cc1783 /src/SendToMenu.cc
parent18cf5862495aa6f37110c90286bb6c315a145526 (diff)
downloadfluxbox_pavel-5373f6d840abaa49685c15fee2f411e77472a7da.zip
fluxbox_pavel-5373f6d840abaa49685c15fee2f411e77472a7da.tar.bz2
moved window menu from FluxboxWindow to BScreen
Diffstat (limited to 'src/SendToMenu.cc')
-rw-r--r--src/SendToMenu.cc60
1 files changed, 27 insertions, 33 deletions
diff --git a/src/SendToMenu.cc b/src/SendToMenu.cc
index c039f16..f0f1dda 100644
--- a/src/SendToMenu.cc
+++ b/src/SendToMenu.cc
@@ -28,39 +28,36 @@
28#include "Screen.hh" 28#include "Screen.hh"
29#include "fluxbox.hh" 29#include "fluxbox.hh"
30#include "Workspace.hh" 30#include "Workspace.hh"
31#include "WindowCmd.hh"
31 32
32#include "FbTk/MultiButtonMenuItem.hh" 33#include "FbTk/MultiButtonMenuItem.hh"
33#include "FbTk/Command.hh" 34#include "FbTk/Command.hh"
34 35
35class SendToCmd: public FbTk::Command { 36class SendToCmd: public FbTk::Command {
36public: 37public:
37 SendToCmd(FluxboxWindow &win, int workspace, bool follow): 38 SendToCmd(int workspace, bool follow):
38 m_win(win),
39 m_workspace(workspace), 39 m_workspace(workspace),
40 m_follow(follow) { } 40 m_follow(follow) { }
41 void execute() { 41 void execute() {
42 m_win.screen().sendToWorkspace(m_workspace, &m_win, m_follow); 42 if (WindowCmd<void>::window() != 0)
43 WindowCmd<void>::window()->screen().sendToWorkspace(m_workspace, WindowCmd<void>::window(), m_follow);
43 } 44 }
44private: 45private:
45 FluxboxWindow &m_win;
46 const int m_workspace; 46 const int m_workspace;
47 const bool m_follow; 47 const bool m_follow;
48}; 48};
49 49
50SendToMenu::SendToMenu(FluxboxWindow &win): 50SendToMenu::SendToMenu(BScreen &screen):
51 FbMenu(win.screen().menuTheme(), 51 FbMenu(screen.menuTheme(),
52 win.screen().imageControl(), 52 screen.imageControl(),
53 *win.screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer())), 53 *screen.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())) {
54 m_win(win) {
55 // listen to: 54 // listen to:
56 // workspace count signal 55 // workspace count signal
57 // workspace names signal 56 // workspace names signal
58 // current workspace signal 57 // current workspace signal
59 // and window's workspace sig 58 screen.workspaceCountSig().attach(this);
60 win.screen().workspaceCountSig().attach(this); 59 screen.workspaceNamesSig().attach(this);
61 win.screen().workspaceNamesSig().attach(this); 60 screen.currentWorkspaceSig().attach(this);
62 win.screen().currentWorkspaceSig().attach(this);
63 win.workspaceSig().attach(this);
64 61
65 disableTitle(); 62 disableTitle();
66 // build menu 63 // build menu
@@ -69,19 +66,7 @@ SendToMenu::SendToMenu(FluxboxWindow &win):
69 66
70void SendToMenu::update(FbTk::Subject *subj) { 67void SendToMenu::update(FbTk::Subject *subj) {
71 if (subj != 0) { 68 if (subj != 0) {
72 // if workspace changed we enable all workspaces except the current one 69 if (subj == &(theme().reconfigSig())) {
73 if (subj == &(m_win.screen().currentWorkspaceSig()) ||
74 subj == &(m_win.workspaceSig())) {
75 // enabled all workspaces
76 const BScreen::Workspaces &wlist = m_win.screen().getWorkspacesList();
77 for (size_t i = 0; i < wlist.size(); ++i)
78 setItemEnabled(i, true);
79 // disable send to on the workspace which the window exist
80 setItemEnabled(m_win.workspaceNumber(), false);
81 updateMenu();
82 // we're done
83 return;
84 } else if (subj == &(theme().reconfigSig())) {
85 // we got reconfig Theme signal, let base menu handle it 70 // we got reconfig Theme signal, let base menu handle it
86 FbTk::Menu::update(subj); 71 FbTk::Menu::update(subj);
87 return; 72 return;
@@ -91,11 +76,11 @@ void SendToMenu::update(FbTk::Subject *subj) {
91 // rebuild menu 76 // rebuild menu
92 77
93 removeAll(); 78 removeAll();
94 79 BScreen *screen = Fluxbox::instance()->findScreen(screenNumber());
95 const BScreen::Workspaces &wlist = m_win.screen().getWorkspacesList(); 80 const BScreen::Workspaces &wlist = screen->getWorkspacesList();
96 for (size_t i = 0; i < wlist.size(); ++i) { 81 for (size_t i = 0; i < wlist.size(); ++i) {
97 FbTk::RefCount<FbTk::Command> sendto_cmd(new SendToCmd(m_win, i, false)); 82 FbTk::RefCount<FbTk::Command> sendto_cmd(new SendToCmd(i, false));
98 FbTk::RefCount<FbTk::Command> sendto_follow_cmd(new SendToCmd(m_win, i, true)); 83 FbTk::RefCount<FbTk::Command> sendto_follow_cmd(new SendToCmd(i, true));
99 84
100 FbTk::MultiButtonMenuItem* item = new FbTk::MultiButtonMenuItem(3, wlist[i]->name().c_str()); 85 FbTk::MultiButtonMenuItem* item = new FbTk::MultiButtonMenuItem(3, wlist[i]->name().c_str());
101 item->setCommand(1, sendto_cmd); 86 item->setCommand(1, sendto_cmd);
@@ -104,7 +89,16 @@ void SendToMenu::update(FbTk::Subject *subj) {
104 insert(item); 89 insert(item);
105 } 90 }
106 91
107 setItemEnabled(m_win.workspaceNumber(), false);
108
109 updateMenu(); 92 updateMenu();
110} 93}
94
95void 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);
100 updateMenu();
101 }
102 FbTk::Menu::show();
103}
104