aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/WorkspaceMenu.cc47
1 files changed, 20 insertions, 27 deletions
diff --git a/src/WorkspaceMenu.cc b/src/WorkspaceMenu.cc
index a8a6399..d0d01bc 100644
--- a/src/WorkspaceMenu.cc
+++ b/src/WorkspaceMenu.cc
@@ -38,7 +38,7 @@
38#include "FbTk/MultiButtonMenuItem.hh" 38#include "FbTk/MultiButtonMenuItem.hh"
39#include "FbTk/MemFun.hh" 39#include "FbTk/MemFun.hh"
40 40
41#include <typeinfo> 41namespace {
42 42
43// the menu consists of (* means static) 43// the menu consists of (* means static)
44// - icons * 0 44// - icons * 0
@@ -50,15 +50,27 @@
50// - remove last * 6 50// - remove last * 6
51// 51//
52 52
53#define IDX_AFTER_ICONS 2 53const unsigned int IDX_AFTER_ICONS = 2;
54#define NR_STATIC_ITEMS 6 54const unsigned int NR_STATIC_ITEMS = 6;
55
56void add_workspaces(WorkspaceMenu& menu, BScreen& screen) {
57 for (size_t i = 0; i < screen.numberOfWorkspaces(); ++i) {
58 Workspace* w = screen.getWorkspace(i);
59 w->menu().setInternalMenu();
60 FbTk::MultiButtonMenuItem* submenu = new FbTk::MultiButtonMenuItem(5, FbTk::BiDiString(w->name()), &w->menu());
61 FbTk::RefCount<FbTk::Command<void> > jump_cmd(new JumpToWorkspaceCmd(w->workspaceID()));
62 submenu->setCommand(3, jump_cmd);
63 menu.insert(submenu, i + IDX_AFTER_ICONS);
64 }
65}
66
67} // end of anonymous namespace
55 68
56WorkspaceMenu::WorkspaceMenu(BScreen &screen): 69WorkspaceMenu::WorkspaceMenu(BScreen &screen):
57 FbMenu(screen.menuTheme(), 70 FbMenu(screen.menuTheme(),
58 screen.imageControl(), 71 screen.imageControl(),
59 *screen.layerManager().getLayer(Layer::MENU)) { 72 *screen.layerManager().getLayer(Layer::MENU)) {
60 73
61
62 init(screen); 74 init(screen);
63} 75}
64 76
@@ -66,18 +78,7 @@ void WorkspaceMenu::workspaceInfoChanged( BScreen& screen ) {
66 while (numberOfItems() > NR_STATIC_ITEMS) { 78 while (numberOfItems() > NR_STATIC_ITEMS) {
67 remove(IDX_AFTER_ICONS); 79 remove(IDX_AFTER_ICONS);
68 } 80 }
69 // for each workspace add workspace name and it's menu 81 ::add_workspaces(*this, screen);
70 // to our workspace menu
71 for (size_t workspace = 0; workspace < screen.numberOfWorkspaces();
72 ++workspace) {
73 Workspace *wkspc = screen.getWorkspace(workspace);
74 wkspc->menu().setInternalMenu();
75 FbTk::MultiButtonMenuItem* mb_menu = new FbTk::MultiButtonMenuItem(5, FbTk::BiDiString(wkspc->name()), &wkspc->menu());
76 FbTk::RefCount<FbTk::Command<void> > jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID()));
77 mb_menu->setCommand(3, jump_cmd);
78 insert(mb_menu, workspace + IDX_AFTER_ICONS);
79 }
80
81 updateMenu(); 82 updateMenu();
82} 83}
83 84
@@ -113,17 +114,9 @@ void WorkspaceMenu::init(BScreen &screen) {
113 insert(_FB_XTEXT(Menu, Icons, "Icons", "Iconic windows menu title"), 114 insert(_FB_XTEXT(Menu, Icons, "Icons", "Iconic windows menu title"),
114 MenuCreator::createMenuType("iconmenu", screen.screenNumber())); 115 MenuCreator::createMenuType("iconmenu", screen.screenNumber()));
115 insert(new FbTk::MenuSeparator()); 116 insert(new FbTk::MenuSeparator());
116 // for each workspace add workspace name and it's menu to our workspace menu
117 for (size_t workspace = 0; workspace < screen.numberOfWorkspaces(); ++workspace) {
118 Workspace *wkspc = screen.getWorkspace(workspace);
119 wkspc->menu().setInternalMenu();
120 FbTk::MultiButtonMenuItem* mb_menu = new FbTk::MultiButtonMenuItem(5, FbTk::BiDiString(wkspc->name()), &wkspc->menu());
121 FbTk::RefCount<FbTk::Command<void> > jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID()));
122 mb_menu->setCommand(3, jump_cmd);
123 insert(mb_menu, workspace + IDX_AFTER_ICONS);
124 }
125 setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true);
126 117
118 ::add_workspaces(*this, screen);
119 setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true);
127 120
128 RefCount<Command<void> > saverc_cmd(new FbCommands::SaveResources()); 121 RefCount<Command<void> > saverc_cmd(new FbCommands::SaveResources());
129 122
@@ -148,6 +141,6 @@ void WorkspaceMenu::init(BScreen &screen) {
148 start_edit); 141 start_edit);
149 insert(_FB_XTEXT(Workspace, RemoveLast, "Remove Last", "Remove the last workspace"), 142 insert(_FB_XTEXT(Workspace, RemoveLast, "Remove Last", "Remove the last workspace"),
150 remove_last_cmd); 143 remove_last_cmd);
151 144
152 updateMenu(); 145 updateMenu();
153} 146}