aboutsummaryrefslogtreecommitdiff
path: root/src/WorkspaceMenu.cc
diff options
context:
space:
mode:
authorHenrik Kinnunen <fluxgen@fluxbox.org>2008-09-18 20:27:16 (GMT)
committerHenrik Kinnunen <fluxgen@fluxbox.org>2008-09-18 20:27:16 (GMT)
commit2f4db57898920a3f17eaaa2586a39dad76d5c7e8 (patch)
treed107bebec3ddb8800970dfbc482c493d5e0187ab /src/WorkspaceMenu.cc
parente4d4717703b365bc14f189bf36b3edb1e4430b90 (diff)
downloadfluxbox_pavel-2f4db57898920a3f17eaaa2586a39dad76d5c7e8.zip
fluxbox_pavel-2f4db57898920a3f17eaaa2586a39dad76d5c7e8.tar.bz2
Changed workspace count signal in BScreen to use the new signal system.
Diffstat (limited to 'src/WorkspaceMenu.cc')
-rw-r--r--src/WorkspaceMenu.cc50
1 files changed, 29 insertions, 21 deletions
diff --git a/src/WorkspaceMenu.cc b/src/WorkspaceMenu.cc
index 3bef2b6..33cfb7f 100644
--- a/src/WorkspaceMenu.cc
+++ b/src/WorkspaceMenu.cc
@@ -36,6 +36,7 @@
36#include "FbTk/MenuItem.hh" 36#include "FbTk/MenuItem.hh"
37#include "FbTk/MenuSeparator.hh" 37#include "FbTk/MenuSeparator.hh"
38#include "FbTk/MultiButtonMenuItem.hh" 38#include "FbTk/MultiButtonMenuItem.hh"
39#include "FbTk/MemFun.hh"
39 40
40#include <typeinfo> 41#include <typeinfo>
41 42
@@ -61,6 +62,27 @@ WorkspaceMenu::WorkspaceMenu(BScreen &screen):
61 init(screen); 62 init(screen);
62} 63}
63 64
65void WorkspaceMenu::workspaceInfoChanged( BScreen& screen ) {
66 while (numberOfItems() > NR_STATIC_ITEMS) {
67 remove(IDX_AFTER_ICONS);
68 }
69 // for each workspace add workspace name and it's menu
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,
76 wkspc->name().c_str(),
77 &wkspc->menu());
78 FbTk::RefCount<FbTk::Command<void> > jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID()));
79 mb_menu->setCommand(3, jump_cmd);
80 insert(mb_menu, workspace + IDX_AFTER_ICONS);
81 }
82
83 updateMenu(-1);
84}
85
64void WorkspaceMenu::update(FbTk::Subject *subj) { 86void WorkspaceMenu::update(FbTk::Subject *subj) {
65 87
66 if (subj != 0 && typeid(*subj) == typeid(BScreen::ScreenSubject)) { 88 if (subj != 0 && typeid(*subj) == typeid(BScreen::ScreenSubject)) {
@@ -78,26 +100,8 @@ void WorkspaceMenu::update(FbTk::Subject *subj) {
78 } 100 }
79 setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true); 101 setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true);
80 updateMenu(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS); 102 updateMenu(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS);
81 } else if (subj == &screen.workspaceCountSig() || 103 } else if ( subj == &screen.workspaceNamesSig() ) {
82 subj == &screen.workspaceNamesSig()) { 104 workspaceInfoChanged( screen );
83 while (numberOfItems() > NR_STATIC_ITEMS) {
84 remove(IDX_AFTER_ICONS);
85 }
86 // for each workspace add workspace name and it's menu
87 // to our workspace menu
88 for (size_t workspace = 0; workspace < screen.numberOfWorkspaces();
89 ++workspace) {
90 Workspace *wkspc = screen.getWorkspace(workspace);
91 wkspc->menu().setInternalMenu();
92 FbTk::MultiButtonMenuItem* mb_menu = new FbTk::MultiButtonMenuItem(5,
93 wkspc->name().c_str(),
94 &wkspc->menu());
95 FbTk::RefCount<FbTk::Command<void> > jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID()));
96 mb_menu->setCommand(3, jump_cmd);
97 insert(mb_menu, workspace + IDX_AFTER_ICONS);
98 }
99
100 updateMenu(-1);
101 } 105 }
102 } else { 106 } else {
103 FbTk::Menu::update(subj); 107 FbTk::Menu::update(subj);
@@ -106,8 +110,12 @@ void WorkspaceMenu::update(FbTk::Subject *subj) {
106 110
107void WorkspaceMenu::init(BScreen &screen) { 111void WorkspaceMenu::init(BScreen &screen) {
108 screen.currentWorkspaceSig().attach(this); 112 screen.currentWorkspaceSig().attach(this);
109 screen.workspaceCountSig().attach(this); 113
110 screen.workspaceNamesSig().attach(this); 114 screen.workspaceNamesSig().attach(this);
115
116 join( screen.workspaceCountSig(),
117 FbTk::MemFun( *this, &WorkspaceMenu::workspaceInfoChanged ) );
118
111 using namespace FbTk; 119 using namespace FbTk;
112 _FB_USES_NLS; 120 _FB_USES_NLS;
113 121