summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-06-24 16:27:18 (GMT)
committerfluxgen <fluxgen>2003-06-24 16:27:18 (GMT)
commit44fbcc447e957d63696e9e2654d9c52803474ebf (patch)
treef68476b388595fdb5b62b98be538e8972a723b4c /src
parent11a0b784b3c3143675ba6b666c57682f4f688e15 (diff)
downloadfluxbox_lack-44fbcc447e957d63696e9e2654d9c52803474ebf.zip
fluxbox_lack-44fbcc447e957d63696e9e2654d9c52803474ebf.tar.bz2
cleaning, moved toolbar mode resource here
Diffstat (limited to 'src')
-rw-r--r--src/ToolbarHandler.cc98
-rw-r--r--src/ToolbarHandler.hh13
2 files changed, 84 insertions, 27 deletions
diff --git a/src/ToolbarHandler.cc b/src/ToolbarHandler.cc
index a2b960f..d7cf8f0 100644
--- a/src/ToolbarHandler.cc
+++ b/src/ToolbarHandler.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: ToolbarHandler.cc,v 1.16 2003/06/24 10:37:39 fluxgen Exp $ 23// $Id: ToolbarHandler.cc,v 1.17 2003/06/24 16:27:18 fluxgen Exp $
24 24
25/** 25/**
26 * The ToolbarHandler class acts as a rough interface to the toolbar. 26 * The ToolbarHandler class acts as a rough interface to the toolbar.
@@ -41,6 +41,58 @@
41#include "IntResMenuItem.hh" 41#include "IntResMenuItem.hh"
42#include "BoolMenuItem.hh" 42#include "BoolMenuItem.hh"
43 43
44#include <string>
45
46using namespace std;
47
48template<>
49void FbTk::Resource<ToolbarHandler::ToolbarMode>::
50setFromString(const char *strval) {
51 if (strcasecmp(strval, "Off") == 0)
52 m_value = ToolbarHandler::OFF;
53 else if (strcasecmp(strval, "None") == 0)
54 m_value = ToolbarHandler::NONE;
55 else if (strcasecmp(strval, "Icons") == 0)
56 m_value = ToolbarHandler::ICONS;
57 else if (strcasecmp(strval, "WorkspaceIcons") == 0)
58 m_value = ToolbarHandler::WORKSPACEICONS;
59 else if (strcasecmp(strval, "Workspace") == 0)
60 m_value = ToolbarHandler::WORKSPACE;
61 else if (strcasecmp(strval, "AllWindows") == 0)
62 m_value = ToolbarHandler::ALLWINDOWS;
63 else
64 setDefaultValue();
65}
66
67
68template<>
69string FbTk::Resource<ToolbarHandler::ToolbarMode>::
70getString() {
71 switch (m_value) {
72 case ToolbarHandler::OFF:
73 return string("Off");
74 break;
75 case ToolbarHandler::NONE:
76 return string("None");
77 break;
78 case ToolbarHandler::LASTMODE:
79 case ToolbarHandler::ICONS:
80 return string("Icons");
81 break;
82 case ToolbarHandler::WORKSPACEICONS:
83 return string("WorkspaceIcons");
84 break;
85 case ToolbarHandler::WORKSPACE:
86 return string("Workspace");
87 break;
88 case ToolbarHandler::ALLWINDOWS:
89 return string("AllWindows");
90 break;
91 }
92 // default string
93 return string("Icons");
94}
95
44namespace { 96namespace {
45 97
46class ToolbarModeMenuItem : public FbTk::MenuItem { 98class ToolbarModeMenuItem : public FbTk::MenuItem {
@@ -50,7 +102,7 @@ public:
50 FbTk::RefCount<FbTk::Command> &cmd): 102 FbTk::RefCount<FbTk::Command> &cmd):
51 FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) { 103 FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) {
52 } 104 }
53 bool isEnabled() const { return m_handler.getMode() != m_mode; } 105 bool isEnabled() const { return m_handler.mode() != m_mode; }
54 void click(int button, int time) { 106 void click(int button, int time) {
55 m_handler.setMode(m_mode); 107 m_handler.setMode(m_mode);
56 FbTk::MenuItem::click(button, time); 108 FbTk::MenuItem::click(button, time);
@@ -88,26 +140,29 @@ void setupModeMenu(FbTk::Menu &menu, ToolbarHandler &handler) {
88 140
89}; // end anonymous namespace 141}; // end anonymous namespace
90 142
91ToolbarHandler::ToolbarHandler(BScreen &screen, ToolbarMode mode) 143ToolbarHandler::ToolbarHandler(BScreen &screen)
92 : m_screen(screen), m_mode(mode), m_toolbar(0), m_current_workspace(0), 144 : m_screen(screen),
145 m_rc_mode(screen.resourceManager(), ToolbarHandler::ICONS,
146 screen.name() + ".toolbar.mode", screen.altName() + ".Toolbar.Mode"),
147 m_toolbar(0),
148 m_current_workspace(0),
93 m_modemenu(*screen.menuTheme(), 149 m_modemenu(*screen.menuTheme(),
94 screen.screenNumber(), screen.imageControl()), 150 screen.screenNumber(), screen.imageControl()),
95 m_toolbarmenu(*screen.menuTheme(), 151 m_toolbarmenu(*screen.menuTheme(),
96 screen.screenNumber(), screen.imageControl()) 152 screen.screenNumber(), screen.imageControl()) {
97{
98 m_modemenu.setInternalMenu(); 153 m_modemenu.setInternalMenu();
99 m_toolbarmenu.setInternalMenu(); 154 m_toolbarmenu.setInternalMenu();
100 setupModeMenu(m_modemenu, *this); 155 setupModeMenu(m_modemenu, *this);
101 setMode(mode, false); // the atomhandler part will initialise it shortly 156 setMode(*m_rc_mode, false); // the atomhandler part will initialise it shortly
102} 157}
103 158
104void ToolbarHandler::setMode(ToolbarMode mode, bool initialise) { 159void ToolbarHandler::setMode(ToolbarMode newmode, bool initialise) {
105 if (mode < 0 || mode >= LASTMODE || (mode == m_mode && initialise)) 160 if (newmode < 0 || newmode >= LASTMODE || (newmode == mode() && initialise))
106 return; 161 return;
107 162
108 m_screen.saveToolbarMode(mode); 163 *m_rc_mode = newmode;
109 if (mode == OFF) { 164
110 m_mode = mode; 165 if (newmode == OFF) {
111 m_toolbarmenu.removeAll(); 166 m_toolbarmenu.removeAll();
112 //TODO: nls 167 //TODO: nls
113 m_toolbarmenu.insert("Mode...", &m_modemenu); 168 m_toolbarmenu.insert("Mode...", &m_modemenu);
@@ -127,7 +182,7 @@ void ToolbarHandler::setMode(ToolbarMode mode, bool initialise) {
127 } 182 }
128 183
129 184
130 if (mode == NONE) { 185 if (newmode == NONE) {
131 // disableIconBar will clean up 186 // disableIconBar will clean up
132 m_toolbar->disableIconBar(); 187 m_toolbar->disableIconBar();
133 } else { 188 } else {
@@ -136,8 +191,7 @@ void ToolbarHandler::setMode(ToolbarMode mode, bool initialise) {
136 m_toolbar->enableIconBar(); 191 m_toolbar->enableIconBar();
137 m_toolbar->delAllIcons(); 192 m_toolbar->delAllIcons();
138 } 193 }
139 // reset Toolbar, and reload it (initForScreen) 194
140 m_mode = mode;
141 if (initialise) 195 if (initialise)
142 initForScreen(m_screen); 196 initForScreen(m_screen);
143} 197}
@@ -145,7 +199,7 @@ void ToolbarHandler::setMode(ToolbarMode mode, bool initialise) {
145void ToolbarHandler::initForScreen(BScreen &screen) { 199void ToolbarHandler::initForScreen(BScreen &screen) {
146 if (&m_screen != &screen) 200 if (&m_screen != &screen)
147 return; 201 return;
148 switch (m_mode) { 202 switch (mode()) {
149 case OFF: 203 case OFF:
150 break; 204 break;
151 case NONE: 205 case NONE:
@@ -207,7 +261,7 @@ void ToolbarHandler::setupWindow(FluxboxWindow &win) {
207 if (&win.screen() != &m_screen) 261 if (&win.screen() != &m_screen)
208 return; 262 return;
209 263
210 switch (m_mode) { 264 switch (mode()) {
211 case OFF: 265 case OFF:
212 case NONE: 266 case NONE:
213 break; 267 break;
@@ -236,7 +290,7 @@ void ToolbarHandler::updateWindowClose(FluxboxWindow &win) {
236 return; 290 return;
237 291
238 // check status of window (in current workspace, etc) and remove if necessary 292 // check status of window (in current workspace, etc) and remove if necessary
239 switch (m_mode) { 293 switch (mode()) {
240 case OFF: 294 case OFF:
241 case NONE: 295 case NONE:
242 break; 296 break;
@@ -265,7 +319,7 @@ void ToolbarHandler::updateState(FluxboxWindow &win) {
265 return; 319 return;
266 320
267 // this function only relevant for icons 321 // this function only relevant for icons
268 switch (m_mode) { 322 switch (mode()) {
269 case OFF: 323 case OFF:
270 case NONE: 324 case NONE:
271 case WORKSPACE: 325 case WORKSPACE:
@@ -296,7 +350,9 @@ void ToolbarHandler::updateWorkspace(FluxboxWindow &win) {
296 return; 350 return;
297 351
298 // don't care about current workspace except if in workspace mode 352 // don't care about current workspace except if in workspace mode
299 if (!(m_mode == WORKSPACE || (m_mode == WORKSPACEICONS && win.isIconic()))) return; 353 if (!(mode() == WORKSPACE ||
354 (mode() == WORKSPACEICONS && win.isIconic())))
355 return;
300 356
301 if (win.workspaceNumber() == m_current_workspace) { 357 if (win.workspaceNumber() == m_current_workspace) {
302 //!! TODO 358 //!! TODO
@@ -317,7 +373,7 @@ void ToolbarHandler::updateCurrentWorkspace(BScreen &screen) {
317 return; 373 return;
318 // if only displaying current workspace, update list 374 // if only displaying current workspace, update list
319 // otherwise ignore it 375 // otherwise ignore it
320 if (m_mode != WORKSPACE && m_mode != WORKSPACEICONS) 376 if (mode() != WORKSPACE && mode() != WORKSPACEICONS)
321 return; 377 return;
322 m_toolbar->delAllIcons(); 378 m_toolbar->delAllIcons();
323 initForScreen(m_screen); 379 initForScreen(m_screen);
diff --git a/src/ToolbarHandler.hh b/src/ToolbarHandler.hh
index 4017e53..3986cc0 100644
--- a/src/ToolbarHandler.hh
+++ b/src/ToolbarHandler.hh
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: ToolbarHandler.hh,v 1.3 2003/06/18 13:35:36 fluxgen Exp $ 23// $Id: ToolbarHandler.hh,v 1.4 2003/06/24 16:27:18 fluxgen Exp $
24 24
25#ifndef TOOLBARHANDLER_HH 25#ifndef TOOLBARHANDLER_HH
26#define TOOLBARHANDLER_HH 26#define TOOLBARHANDLER_HH
@@ -28,6 +28,7 @@
28#include "AtomHandler.hh" 28#include "AtomHandler.hh"
29#include "Menu.hh" 29#include "Menu.hh"
30#include "Toolbar.hh" 30#include "Toolbar.hh"
31#include "Resource.hh"
31 32
32class BScreen; 33class BScreen;
33class FluxboxWindow; 34class FluxboxWindow;
@@ -44,14 +45,14 @@ public:
44 LASTMODE 45 LASTMODE
45 }; 46 };
46 47
47 ToolbarHandler(BScreen &screen, ToolbarMode mode); 48 explicit ToolbarHandler(BScreen &screen);
48 ~ToolbarHandler() { } 49 ~ToolbarHandler() { }
49 50
50 void setMode(ToolbarMode mode, bool initialise = true); 51 void setMode(ToolbarMode mode, bool initialise = true);
51 ToolbarMode getMode() { return m_mode; }; 52 ToolbarMode mode() const { return *m_rc_mode; };
52 53
53 inline const Toolbar *getToolbar() const { return m_toolbar.get(); } 54 inline const Toolbar *toolbar() const { return m_toolbar.get(); }
54 inline Toolbar *getToolbar() { return m_toolbar.get(); } 55 inline Toolbar *toolbar() { return m_toolbar.get(); }
55 56
56 57
57 void initForScreen(BScreen &screen); 58 void initForScreen(BScreen &screen);
@@ -84,7 +85,7 @@ public:
84 85
85private: 86private:
86 BScreen &m_screen; 87 BScreen &m_screen;
87 ToolbarMode m_mode; 88 FbTk::Resource<ToolbarMode> m_rc_mode;
88 std::auto_ptr<Toolbar> m_toolbar; 89 std::auto_ptr<Toolbar> m_toolbar;
89 unsigned int m_current_workspace; 90 unsigned int m_current_workspace;
90 91