summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2008-01-25 07:21:55 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2008-01-25 07:21:55 (GMT)
commit6717a1c805529ea6e1b1c19a591f876c9c8803db (patch)
tree97bb3193601d67f6137723410753b497e429fdf5
parent65df54d635e8ad2029efea1c3c00eccfffe8532d (diff)
downloadfluxbox_lack-6717a1c805529ea6e1b1c19a591f876c9c8803db.zip
fluxbox_lack-6717a1c805529ea6e1b1c19a591f876c9c8803db.tar.bz2
cosmetics
-rw-r--r--src/FbCommands.cc2
-rw-r--r--src/MenuCreator.cc61
-rw-r--r--src/fluxbox.cc2
3 files changed, 34 insertions, 31 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index 5e7f6dc..c815145 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -171,7 +171,7 @@ int ExecuteCmd::run() {
171 setsid(); 171 setsid();
172 putenv(const_cast<char *>(displaystring.c_str())); 172 putenv(const_cast<char *>(displaystring.c_str()));
173 execl(shell, shell, "-c", m_cmd.c_str(), static_cast<void*>(NULL)); 173 execl(shell, shell, "-c", m_cmd.c_str(), static_cast<void*>(NULL));
174 exit(0); 174 exit(EXIT_SUCCESS);
175 175
176 return pid; // compiler happy -> we are happy ;) 176 return pid; // compiler happy -> we are happy ;)
177} 177}
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc
index 12b0f1c..32a046f 100644
--- a/src/MenuCreator.cc
+++ b/src/MenuCreator.cc
@@ -65,7 +65,9 @@ list<size_t> MenuCreator::stacksize_stack;
65 65
66FbTk::StringConvertor MenuCreator::m_stringconvertor(FbTk::StringConvertor::ToFbString); 66FbTk::StringConvertor MenuCreator::m_stringconvertor(FbTk::StringConvertor::ToFbString);
67 67
68static void createStyleMenu(FbTk::Menu &parent, const string &label, 68namespace {
69
70void createStyleMenu(FbTk::Menu &parent, const string &label,
69 const string &directory) { 71 const string &directory) {
70 // perform shell style ~ home directory expansion 72 // perform shell style ~ home directory expansion
71 string stylesdir(FbTk::StringUtil::expandFilename(directory)); 73 string stylesdir(FbTk::StringUtil::expandFilename(directory));
@@ -101,7 +103,7 @@ static void createStyleMenu(FbTk::Menu &parent, const string &label,
101 103
102} 104}
103 105
104static void createRootCmdMenu(FbTk::Menu &parent, const string &label, 106void createRootCmdMenu(FbTk::Menu &parent, const string &label,
105 const string &directory, const string &cmd) { 107 const string &directory, const string &cmd) {
106 // perform shell style ~ home directory expansion 108 // perform shell style ~ home directory expansion
107 string rootcmddir(FbTk::StringUtil::expandFilename(directory)); 109 string rootcmddir(FbTk::StringUtil::expandFilename(directory));
@@ -141,15 +143,15 @@ class ParseItem {
141public: 143public:
142 explicit ParseItem(FbTk::Menu *menu):m_menu(menu) {} 144 explicit ParseItem(FbTk::Menu *menu):m_menu(menu) {}
143 145
144 inline void load(FbTk::Parser &p, FbTk::StringConvertor &m_labelconvertor) { 146 void load(FbTk::Parser &p, FbTk::StringConvertor &m_labelconvertor) {
145 p>>m_key>>m_label>>m_cmd>>m_icon; 147 p>>m_key>>m_label>>m_cmd>>m_icon;
146 m_label.second = m_labelconvertor.recode(m_label.second); 148 m_label.second = m_labelconvertor.recode(m_label.second);
147 } 149 }
148 inline const string &icon() const { return m_icon.second; } 150 const string &icon() const { return m_icon.second; }
149 inline const string &command() const { return m_cmd.second; } 151 const string &command() const { return m_cmd.second; }
150 inline const string &label() const { return m_label.second; } 152 const string &label() const { return m_label.second; }
151 inline const string &key() const { return m_key.second; } 153 const string &key() const { return m_key.second; }
152 inline FbTk::Menu *menu() { return m_menu; } 154 FbTk::Menu *menu() { return m_menu; }
153private: 155private:
154 FbTk::Parser::Item m_key, m_label, m_cmd, m_icon; 156 FbTk::Parser::Item m_key, m_label, m_cmd, m_icon;
155 FbTk::Menu *m_menu; 157 FbTk::Menu *m_menu;
@@ -170,10 +172,10 @@ public:
170 172
171}; 173};
172 174
173static void translateMenuItem(FbTk::Parser &parse, ParseItem &item, FbTk::StringConvertor &labelconvertor); 175void translateMenuItem(FbTk::Parser &parse, ParseItem &item, FbTk::StringConvertor &labelconvertor);
174 176
175 177
176static void parseMenu(FbTk::Parser &pars, FbTk::Menu &menu, FbTk::StringConvertor &label_convertor) { 178void parseMenu(FbTk::Parser &pars, FbTk::Menu &menu, FbTk::StringConvertor &label_convertor) {
177 ParseItem pitem(&menu); 179 ParseItem pitem(&menu);
178 while (!pars.eof()) { 180 while (!pars.eof()) {
179 pitem.load(pars, label_convertor); 181 pitem.load(pars, label_convertor);
@@ -183,7 +185,7 @@ static void parseMenu(FbTk::Parser &pars, FbTk::Menu &menu, FbTk::StringConverto
183 } 185 }
184} 186}
185 187
186static void translateMenuItem(FbTk::Parser &parse, ParseItem &pitem, FbTk::StringConvertor &labelconvertor) { 188void translateMenuItem(FbTk::Parser &parse, ParseItem &pitem, FbTk::StringConvertor &labelconvertor) {
187 if (pitem.menu() == 0) 189 if (pitem.menu() == 0)
188 throw string("translateMenuItem: We must have a menu in ParseItem!"); 190 throw string("translateMenuItem: We must have a menu in ParseItem!");
189 191
@@ -216,12 +218,10 @@ static void translateMenuItem(FbTk::Parser &parse, ParseItem &pitem, FbTk::Strin
216 menu.insert(str_label, exit_cmd); 218 menu.insert(str_label, exit_cmd);
217 } else if (str_key == "exec") { 219 } else if (str_key == "exec") {
218 // execute and hide menu 220 // execute and hide menu
219 using namespace FbTk; 221 FbTk::RefCount<FbTk::Command<void> > exec_cmd(FbTk::CommandParser<void>::instance().parse("exec " + str_cmd));
220 RefCount<Command<void> > exec_cmd(FbTk::CommandParser<void>::instance().parse("exec " + str_cmd));
221 menu.insert(str_label, exec_cmd); 222 menu.insert(str_label, exec_cmd);
222 } else if (str_key == "macrocmd") { 223 } else if (str_key == "macrocmd") {
223 using namespace FbTk; 224 FbTk::RefCount<FbTk::Command<void> > macro_cmd(FbTk::CommandParser<void>::instance().parse("macrocmd " + str_cmd));
224 RefCount<Command<void> > macro_cmd(FbTk::CommandParser<void>::instance().parse("macrocmd " + str_cmd));
225 menu.insert(str_label, macro_cmd); 225 menu.insert(str_label, macro_cmd);
226 } else if (str_key == "style") { // style 226 } else if (str_key == "style") { // style
227 menu.insert(new StyleMenuItem(str_label, str_cmd)); 227 menu.insert(new StyleMenuItem(str_label, str_cmd));
@@ -339,7 +339,7 @@ static void translateMenuItem(FbTk::Parser &parse, ParseItem &pitem, FbTk::Strin
339} 339}
340 340
341 341
342static void parseWindowMenu(FbTk::Parser &parse, FbTk::Menu &menu, FbTk::StringConvertor &labelconvertor) { 342void parseWindowMenu(FbTk::Parser &parse, FbTk::Menu &menu, FbTk::StringConvertor &labelconvertor) {
343 343
344 ParseItem pitem(&menu); 344 ParseItem pitem(&menu);
345 while (!parse.eof()) { 345 while (!parse.eof()) {
@@ -361,19 +361,6 @@ static void parseWindowMenu(FbTk::Parser &parse, FbTk::Menu &menu, FbTk::StringC
361 } 361 }
362} 362}
363 363
364FbTk::Menu *MenuCreator::createMenu(const string &label, int screen_number) {
365 BScreen *screen = Fluxbox::instance()->findScreen(screen_number);
366 if (screen == 0)
367 return 0;
368
369 FbTk::Menu *menu = new FbMenu(screen->menuTheme(),
370 screen->imageControl(),
371 *screen->layerManager().getLayer(Layer::MENU));
372 if (!label.empty())
373 menu->setLabel(label);
374
375 return menu;
376}
377 364
378bool getStart(FbMenuParser &parser, string &label, FbTk::StringConvertor &labelconvertor) { 365bool getStart(FbMenuParser &parser, string &label, FbTk::StringConvertor &labelconvertor) {
379 ParseItem pitem(0); 366 ParseItem pitem(0);
@@ -391,6 +378,22 @@ bool getStart(FbMenuParser &parser, string &label, FbTk::StringConvertor &labelc
391 return true; 378 return true;
392} 379}
393 380
381}; // end of anonymous namespace
382
383FbTk::Menu *MenuCreator::createMenu(const string &label, int screen_number) {
384 BScreen *screen = Fluxbox::instance()->findScreen(screen_number);
385 if (screen == 0)
386 return 0;
387
388 FbTk::Menu *menu = new FbMenu(screen->menuTheme(),
389 screen->imageControl(),
390 *screen->layerManager().getLayer(Layer::MENU));
391 if (!label.empty())
392 menu->setLabel(label);
393
394 return menu;
395}
396
394FbTk::Menu *MenuCreator::createFromFile(const string &filename, int screen_number, bool require_begin) { 397FbTk::Menu *MenuCreator::createFromFile(const string &filename, int screen_number, bool require_begin) {
395 string real_filename = FbTk::StringUtil::expandFilename(filename); 398 string real_filename = FbTk::StringUtil::expandFilename(filename);
396 Fluxbox::instance()->saveMenuFilename(real_filename.c_str()); 399 Fluxbox::instance()->saveMenuFilename(real_filename.c_str());
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index d45a45e..b20a4d9 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -324,7 +324,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
324 cerr << _FB_CONSOLETEXT(main, ScreenRequiresArg, 324 cerr << _FB_CONSOLETEXT(main, ScreenRequiresArg,
325 "error, -screen requires argument", 325 "error, -screen requires argument",
326 "the -screen option requires a file argument") << endl; 326 "the -screen option requires a file argument") << endl;
327 exit(1); 327 exit(EXIT_FAILURE);
328 } 328 }
329 329
330 // "all" is default 330 // "all" is default