diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-07-03 12:00:48 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2011-11-01 09:57:20 (GMT) |
commit | ad42ae5c403274502768df904d7b1aeb7174c2ed (patch) | |
tree | 6dc28d724ca52617be7827a2971f081a9dca67e6 | |
parent | 96d14bf5abde4faf7312d43bfd3e339f75fabc0d (diff) | |
download | fluxbox_paul-ad42ae5c403274502768df904d7b1aeb7174c2ed.zip fluxbox_paul-ad42ae5c403274502768df904d7b1aeb7174c2ed.tar.bz2 |
Slight simplification of MenuCreator using typedefs
-rw-r--r-- | src/MenuCreator.cc | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 46f233d..abd6691 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc | |||
@@ -66,7 +66,10 @@ using FbTk::AutoReloadHelper; | |||
66 | 66 | ||
67 | namespace { | 67 | namespace { |
68 | 68 | ||
69 | FbTk::RefCount<FbTk::Menu> createStyleMenu(int screen_number, const string &label, | 69 | typedef FbTk::RefCount<FbTk::Menu> RefMenu; |
70 | typedef FbTk::RefCount<FbTk::Command<void> > RefCmd; | ||
71 | |||
72 | RefMenu createStyleMenu(int screen_number, const string &label, | ||
70 | AutoReloadHelper *reloader, const string &directory) { | 73 | AutoReloadHelper *reloader, const string &directory) { |
71 | 74 | ||
72 | FbTk::RefCount<FbMenu> menu(MenuCreator::createMenu(label, screen_number)); | 75 | FbTk::RefCount<FbMenu> menu(MenuCreator::createMenu(label, screen_number)); |
@@ -107,7 +110,7 @@ FbTk::RefCount<FbTk::Menu> createStyleMenu(int screen_number, const string &labe | |||
107 | return menu; | 110 | return menu; |
108 | } | 111 | } |
109 | 112 | ||
110 | FbTk::RefCount<FbTk::Menu> createRootCmdMenu(int screen_number, const string &label, | 113 | RefMenu createRootCmdMenu(int screen_number, const string &label, |
111 | const string &directory, AutoReloadHelper *reloader, | 114 | const string &directory, AutoReloadHelper *reloader, |
112 | const string &cmd) { | 115 | const string &cmd) { |
113 | 116 | ||
@@ -267,7 +270,7 @@ insertMenuItem(lua::state &l, FbTk::Menu &menu, FbTk::StringConvertor &parent_co | |||
267 | int size = menu.insert(str_label); | 270 | int size = menu.insert(str_label); |
268 | menu.setItemEnabled(size-1, false); | 271 | menu.setItemEnabled(size-1, false); |
269 | } else if(str_key == "icons") { | 272 | } else if(str_key == "icons") { |
270 | FbTk::RefCount<FbTk::Menu> submenu = MenuCreator::createMenuType("iconmenu", screen_number); | 273 | RefMenu submenu = MenuCreator::createMenuType("iconmenu", screen_number); |
271 | if (! submenu) | 274 | if (! submenu) |
272 | return; | 275 | return; |
273 | if (str_label.empty()) | 276 | if (str_label.empty()) |
@@ -275,15 +278,15 @@ insertMenuItem(lua::state &l, FbTk::Menu &menu, FbTk::StringConvertor &parent_co | |||
275 | else | 278 | else |
276 | menu.insert(str_label, submenu); | 279 | menu.insert(str_label, submenu); |
277 | } else if (str_key == "exit") { // exit | 280 | } else if (str_key == "exit") { // exit |
278 | FbTk::RefCount<FbTk::Command<void> > exit_cmd(FbTk::CommandParser<void>::instance().parse("exit")); | 281 | RefCmd exit_cmd(FbTk::CommandParser<void>::instance().parse("exit")); |
279 | if (str_label.empty()) | 282 | if (str_label.empty()) |
280 | menu.insert(_FB_XTEXT(Menu, Exit, "Exit", "Exit Command"), exit_cmd); | 283 | menu.insert(_FB_XTEXT(Menu, Exit, "Exit", "Exit Command"), exit_cmd); |
281 | else | 284 | else |
282 | menu.insert(str_label, exit_cmd); | 285 | menu.insert(str_label, exit_cmd); |
283 | } else if (str_key == "config") { | 286 | } else if (str_key == "config") { |
284 | menu.insert(str_label, FbTk::RefCount<FbTk::Menu>(screen->configMenu()) ); | 287 | menu.insert(str_label, RefMenu(screen->configMenu()) ); |
285 | } else if(str_key == "menu") { | 288 | } else if(str_key == "menu") { |
286 | FbTk::RefCount<FbTk::Menu> t(MenuCreator::createMenu("", screen_number)); | 289 | RefMenu t(MenuCreator::createMenu("", screen_number)); |
287 | l.pushvalue(-1); | 290 | l.pushvalue(-1); |
288 | createMenu_(*t, l, *conv, reloader); | 291 | createMenu_(*t, l, *conv, reloader); |
289 | menu.insert(str_label, t); | 292 | menu.insert(str_label, t); |
@@ -292,11 +295,9 @@ insertMenuItem(lua::state &l, FbTk::Menu &menu, FbTk::StringConvertor &parent_co | |||
292 | const string &str_cmd = getField(l, -1, "param"); | 295 | const string &str_cmd = getField(l, -1, "param"); |
293 | 296 | ||
294 | if(str_key == "command") { | 297 | if(str_key == "command") { |
295 | menu.insert(str_label, FbTk::RefCount<FbTk::Command<void> >( | 298 | menu.insert(str_label, RefCmd( parser.parse(str_cmd)) ); |
296 | parser.parse(str_cmd)) ); | ||
297 | } else if(str_key == "exec") { | 299 | } else if(str_key == "exec") { |
298 | menu.insert(str_label, FbTk::RefCount<FbTk::Command<void> >( | 300 | menu.insert(str_label, RefCmd( parser.parse("exec", str_cmd)) ); |
299 | parser.parse("exec", str_cmd)) ); | ||
300 | } else if(str_key == "style") | 301 | } else if(str_key == "style") |
301 | menu.insert(new StyleMenuItem(str_label, str_cmd)); | 302 | menu.insert(new StyleMenuItem(str_label, str_cmd)); |
302 | else if (str_key == "stylesdir") | 303 | else if (str_key == "stylesdir") |
@@ -309,7 +310,7 @@ insertMenuItem(lua::state &l, FbTk::Menu &menu, FbTk::StringConvertor &parent_co | |||
309 | menu.insert(str_label, createRootCmdMenu(screen_number, str_label, str_cmd, | 310 | menu.insert(str_label, createRootCmdMenu(screen_number, str_label, str_cmd, |
310 | reloader, program) ); | 311 | reloader, program) ); |
311 | } else if (str_key == "workspaces") { | 312 | } else if (str_key == "workspaces") { |
312 | menu.insert(str_label, FbTk::RefCount<FbTk::Menu>(screen->workspaceMenu()) ); | 313 | menu.insert(str_label, RefMenu(screen->workspaceMenu()) ); |
313 | } else { | 314 | } else { |
314 | // finally, try window-related commands | 315 | // finally, try window-related commands |
315 | MenuCreator::createWindowMenuItem(str_key, str_label, menu); | 316 | MenuCreator::createWindowMenuItem(str_key, str_label, menu); |
@@ -411,7 +412,6 @@ FbTk::RefCount<FbMenu> MenuCreator::createMenuType(const string &type, int scree | |||
411 | bool MenuCreator::createWindowMenuItem(const string &type, | 412 | bool MenuCreator::createWindowMenuItem(const string &type, |
412 | const string &label, | 413 | const string &label, |
413 | FbTk::Menu &menu) { | 414 | FbTk::Menu &menu) { |
414 | typedef FbTk::RefCount<FbTk::Command<void> > RefCmd; | ||
415 | _FB_USES_NLS; | 415 | _FB_USES_NLS; |
416 | 416 | ||
417 | static MenuContext context; | 417 | static MenuContext context; |
@@ -493,8 +493,7 @@ bool MenuCreator::createWindowMenuItem(const string &type, | |||
493 | if (screen == 0) | 493 | if (screen == 0) |
494 | return false; | 494 | return false; |
495 | 495 | ||
496 | FbTk::RefCount<FbTk::Menu> submenu( new AlphaMenu(screen->menuTheme(), | 496 | RefMenu submenu( new AlphaMenu(screen->menuTheme(), screen->imageControl(), |
497 | screen->imageControl(), | ||
498 | *screen->layerManager().getLayer(ResourceLayer::MENU)) ); | 497 | *screen->layerManager().getLayer(ResourceLayer::MENU)) ); |
499 | submenu->disableTitle(); | 498 | submenu->disableTitle(); |
500 | menu.insert(label.empty() ? _FB_XTEXT(Configmenu, Transparency, "Transparency", | 499 | menu.insert(label.empty() ? _FB_XTEXT(Configmenu, Transparency, "Transparency", |
@@ -513,13 +512,13 @@ bool MenuCreator::createWindowMenuItem(const string &type, | |||
513 | 512 | ||
514 | } else if (type == "sendto") { | 513 | } else if (type == "sendto") { |
515 | menu.insert(label.empty() ? _FB_XTEXT(Windowmenu, SendTo, "Send To...", "Send to menu item name"): | 514 | menu.insert(label.empty() ? _FB_XTEXT(Windowmenu, SendTo, "Send To...", "Send to menu item name"): |
516 | label, FbTk::RefCount<FbTk::Menu>(new SendToMenu(*Fluxbox::instance()->findScreen(menu.screenNumber()))) ); | 515 | label, RefMenu(new SendToMenu(*Fluxbox::instance()->findScreen(menu.screenNumber()))) ); |
517 | } else if (type == "layer") { | 516 | } else if (type == "layer") { |
518 | BScreen *screen = Fluxbox::instance()->findScreen(menu.screenNumber()); | 517 | BScreen *screen = Fluxbox::instance()->findScreen(menu.screenNumber()); |
519 | if (screen == 0) | 518 | if (screen == 0) |
520 | return false; | 519 | return false; |
521 | 520 | ||
522 | FbTk::RefCount<FbTk::Menu> submenu( new LayerMenu(screen->menuTheme(), | 521 | RefMenu submenu( new LayerMenu(screen->menuTheme(), |
523 | screen->imageControl(), | 522 | screen->imageControl(), |
524 | *screen->layerManager().getLayer(ResourceLayer::MENU), | 523 | *screen->layerManager().getLayer(ResourceLayer::MENU), |
525 | &context, | 524 | &context, |