aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/IconMenu.cc64
-rw-r--r--src/IconMenu.hh38
-rw-r--r--src/WorkspaceMenu.cc115
-rw-r--r--src/WorkspaceMenu.hh40
4 files changed, 257 insertions, 0 deletions
diff --git a/src/IconMenu.cc b/src/IconMenu.cc
new file mode 100644
index 0000000..16d7b27
--- /dev/null
+++ b/src/IconMenu.cc
@@ -0,0 +1,64 @@
1// IconMenu.cc for Fluxbox
2// Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
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// $Id: IconMenu.cc,v 1.1 2004/05/02 20:51:36 fluxgen Exp $
23
24#include "IconMenu.hh"
25
26#include "Screen.hh"
27#include "IconMenuItem.hh"
28#include "fluxbox.hh"
29#include "I18n.hh"
30
31static void updateItems(FbTk::Menu &menu, BScreen &screen) {
32 menu.removeAll();
33 BScreen::Icons::iterator it = screen.getIconList().begin();
34 BScreen::Icons::iterator it_end = screen.getIconList().end();
35 for (; it != it_end; ++it) {
36 FluxboxWindow::ClientList::iterator client_it = (*it)->clientList().begin();
37 FluxboxWindow::ClientList::iterator client_it_end = (*it)->clientList().end();
38 for (; client_it != client_it_end; ++client_it)
39 menu.insert(new IconMenuItem(**client_it));
40 }
41 menu.update();
42}
43
44IconMenu::IconMenu(BScreen &screen):
45 FbMenu(screen.menuTheme(),
46 screen.imageControl(),
47 *screen.layerManager().
48 getLayer(Fluxbox::instance()->getMenuLayer())) {
49
50 setLabel(I18n::instance()->getMessage(FBNLS::IconSet,
51 FBNLS::IconIcons, "Icons"));
52 screen.iconListSig().attach(this);
53 updateItems(*this, screen);
54}
55
56void IconMenu::update(FbTk::Subject *subj) {
57 if (subj == 0)
58 FbTk::Menu::update(subj);
59 else if (typeid(*subj) == typeid(BScreen::ScreenSubject)) {
60 BScreen &screen = static_cast<BScreen::ScreenSubject *>(subj)->screen();
61 updateItems(*this, screen);
62 } else
63 FbTk::Menu::update(subj);
64}
diff --git a/src/IconMenu.hh b/src/IconMenu.hh
new file mode 100644
index 0000000..a9cb045
--- /dev/null
+++ b/src/IconMenu.hh
@@ -0,0 +1,38 @@
1// IconMenu.hh for Fluxbox
2// Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
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// $Id: IconMenu.hh,v 1.1 2004/05/02 20:51:36 fluxgen Exp $
23
24#ifndef ICONMENU_HH
25#define ICONMENU_HH
26
27#include "FbMenu.hh"
28
29class BScreen;
30
31class IconMenu: public FbMenu {
32public:
33 explicit IconMenu(BScreen &screen);
34 virtual ~IconMenu() { }
35 void update(FbTk::Subject *subj);
36};
37
38#endif // ICONMENU_HH
diff --git a/src/WorkspaceMenu.cc b/src/WorkspaceMenu.cc
new file mode 100644
index 0000000..575ddeb
--- /dev/null
+++ b/src/WorkspaceMenu.cc
@@ -0,0 +1,115 @@
1// WorkspaceMenu.cc for Fluxbox
2// Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
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// $Id: WorkspaceMenu.cc,v 1.1 2004/05/02 20:51:36 fluxgen Exp $
23
24#include "WorkspaceMenu.hh"
25
26#include "Screen.hh"
27#include "fluxbox.hh"
28#include "Workspace.hh"
29#include "MenuCreator.hh"
30#include "I18n.hh"
31
32#include "FbTk/SimpleCommand.hh"
33#include "FbTk/RefCount.hh"
34#include "FbTk/MenuItem.hh"
35
36WorkspaceMenu::WorkspaceMenu(BScreen &screen):
37 FbMenu(screen.menuTheme(),
38 screen.imageControl(),
39 *screen.layerManager().
40 getLayer(Fluxbox::instance()->getMenuLayer())) {
41
42
43 init(screen);
44}
45
46void WorkspaceMenu::update(FbTk::Subject *subj) {
47 if (subj != 0 && typeid(*subj) == typeid(BScreen::ScreenSubject)) {
48 BScreen::ScreenSubject &screen_subj = *static_cast<BScreen::ScreenSubject *>(subj);
49 BScreen &screen = screen_subj.screen();
50 if (subj == &screen.currentWorkspaceSig()) {
51 FbTk::MenuItem *item = 0;
52 for (unsigned int i = 2; i < numberOfItems(); ++i) {
53 item = find(i);
54 if (item && item->isSelected()) {
55 setItemSelected(i, false);
56 FbTk::Menu::update(i);
57 break;
58 }
59 }
60 setItemSelected(screen.currentWorkspace()->workspaceID() + 2, true);
61 FbTk::Menu::update(screen.currentWorkspace()->workspaceID() + 2);
62 } else if (subj == &screen.workspaceCountSig() ||
63 subj == &screen.workspaceNamesSig()) {
64 while (numberOfItems() != 3) {
65 remove(2);
66 }
67 // for each workspace add workspace name and it's menu
68 // to our workspace menu
69 for (size_t workspace = 0; workspace < screen.getCount();
70 ++workspace) {
71 Workspace *wkspc = screen.getWorkspace(workspace);
72 wkspc->menu().setInternalMenu();
73 insert(wkspc->name().c_str(), &wkspc->menu(), numberOfItems() - 1);
74 }
75
76 FbTk::Menu::update(-1);
77 }
78 } else {
79 FbTk::Menu::update(subj);
80 }
81}
82
83void WorkspaceMenu::init(BScreen &screen) {
84 screen.currentWorkspaceSig().attach(this);
85 screen.workspaceCountSig().attach(this);
86 screen.workspaceNamesSig().attach(this);
87 I18n &i18n = *I18n::instance();
88 using namespace FbTk;
89 using namespace FBNLS;
90
91 removeAll();
92
93 setLabel(i18n.getMessage(WorkspacemenuSet, WorkspacemenuWorkspacesTitle,
94 "Workspace"));
95 RefCount<Command> new_workspace(new SimpleCommand<BScreen, int>(screen, &BScreen::addWorkspace));
96 RefCount<Command> remove_last(new SimpleCommand<BScreen, int>(screen, &BScreen::removeLastWorkspace));
97 insert(i18n.getMessage(WorkspacemenuSet, WorkspacemenuNewWorkspace,
98 "New Workspace"),
99 new_workspace);
100 insert(i18n.getMessage(WorkspacemenuSet, WorkspacemenuRemoveLast,
101 "Remove Last"),
102 remove_last);
103 // for each workspace add workspace name and it's menu to our workspace menu
104 for (size_t workspace = 0; workspace < screen.getCount(); ++workspace) {
105 Workspace *wkspc = screen.getWorkspace(workspace);
106 wkspc->menu().setInternalMenu();
107 insert(wkspc->name().c_str(), &wkspc->menu());
108 }
109 setItemSelected(screen.currentWorkspace()->workspaceID() + 2, true);
110
111 insert(i18n.getMessage(IconSet, IconIcons,
112 "Icons"),
113 MenuCreator::createMenuType("iconmenu", screen.screenNumber()));
114 FbMenu::update();
115}
diff --git a/src/WorkspaceMenu.hh b/src/WorkspaceMenu.hh
new file mode 100644
index 0000000..77f1006
--- /dev/null
+++ b/src/WorkspaceMenu.hh
@@ -0,0 +1,40 @@
1// WorkspaceMenu.hh for Fluxbox
2// Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
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// $Id: WorkspaceMenu.hh,v 1.1 2004/05/02 20:51:36 fluxgen Exp $
23
24#ifndef WORKSPACEMENU_HH
25#define WORKSPACEMENU_HH
26
27#include "FbMenu.hh"
28
29class BScreen;
30
31class WorkspaceMenu: public FbMenu {
32public:
33 explicit WorkspaceMenu(BScreen &screen);
34 virtual ~WorkspaceMenu() { }
35 void update(FbTk::Subject *subj);
36private:
37 void init(BScreen &screen);
38};
39
40#endif // WORKSPACEMENU_HH