diff options
-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 3b7667a..8f7c8a4 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 | ||
@@ -268,7 +271,7 @@ insertMenuItem(lua::state &l, FbTk::Menu &menu, FbTk::StringConvertor &parent_co | |||
268 | int size = menu.insert(str_label); | 271 | int size = menu.insert(str_label); |
269 | menu.setItemEnabled(size-1, false); | 272 | menu.setItemEnabled(size-1, false); |
270 | } else if(str_key == "icons") { | 273 | } else if(str_key == "icons") { |
271 | FbTk::RefCount<FbTk::Menu> submenu = MenuCreator::createMenuType("iconmenu", screen_number); | 274 | RefMenu submenu = MenuCreator::createMenuType("iconmenu", screen_number); |
272 | if (! submenu) | 275 | if (! submenu) |
273 | return; | 276 | return; |
274 | if (str_label.empty()) | 277 | if (str_label.empty()) |
@@ -276,15 +279,15 @@ insertMenuItem(lua::state &l, FbTk::Menu &menu, FbTk::StringConvertor &parent_co | |||
276 | else | 279 | else |
277 | menu.insert(str_label, submenu); | 280 | menu.insert(str_label, submenu); |
278 | } else if (str_key == "exit") { // exit | 281 | } else if (str_key == "exit") { // exit |
279 | FbTk::RefCount<FbTk::Command<void> > exit_cmd(FbTk::CommandParser<void>::instance().parse("exit")); | 282 | RefCmd exit_cmd(FbTk::CommandParser<void>::instance().parse("exit")); |
280 | if (str_label.empty()) | 283 | if (str_label.empty()) |
281 | menu.insert(_FB_XTEXT(Menu, Exit, "Exit", "Exit Command"), exit_cmd); | 284 | menu.insert(_FB_XTEXT(Menu, Exit, "Exit", "Exit Command"), exit_cmd); |
282 | else | 285 | else |
283 | menu.insert(str_label, exit_cmd); | 286 | menu.insert(str_label, exit_cmd); |
284 | } else if (str_key == "config") { | 287 | } else if (str_key == "config") { |
285 | menu.insert(str_label, FbTk::RefCount<FbTk::Menu>(screen->configMenu()) ); | 288 | menu.insert(str_label, RefMenu(screen->configMenu()) ); |
286 | } else if(str_key == "menu") { | 289 | } else if(str_key == "menu") { |
287 | FbTk::RefCount<FbTk::Menu> t(MenuCreator::createMenu("", screen_number)); | 290 | RefMenu t(MenuCreator::createMenu("", screen_number)); |
288 | l.pushvalue(-1); | 291 | l.pushvalue(-1); |
289 | createMenu_(*t, l, *conv, reloader); | 292 | createMenu_(*t, l, *conv, reloader); |
290 | menu.insert(str_label, t); | 293 | menu.insert(str_label, t); |
@@ -293,11 +296,9 @@ insertMenuItem(lua::state &l, FbTk::Menu &menu, FbTk::StringConvertor &parent_co | |||
293 | const string &str_cmd = getField(l, -1, "param"); | 296 | const string &str_cmd = getField(l, -1, "param"); |
294 | 297 | ||
295 | if(str_key == "command") { | 298 | if(str_key == "command") { |
296 | menu.insert(str_label, FbTk::RefCount<FbTk::Command<void> >( | 299 | menu.insert(str_label, RefCmd( parser.parse(str_cmd)) ); |
297 | parser.parse(str_cmd)) ); | ||
298 | } else if(str_key == "exec") { | 300 | } else if(str_key == "exec") { |
299 | menu.insert(str_label, FbTk::RefCount<FbTk::Command<void> >( | 301 | menu.insert(str_label, RefCmd( parser.parse("exec", str_cmd)) ); |
300 | parser.parse("exec", str_cmd)) ); | ||
301 | } else if(str_key == "style") | 302 | } else if(str_key == "style") |
302 | menu.insert(new StyleMenuItem(str_label, str_cmd)); | 303 | menu.insert(new StyleMenuItem(str_label, str_cmd)); |
303 | else if (str_key == "stylesdir") | 304 | else if (str_key == "stylesdir") |
@@ -310,7 +311,7 @@ insertMenuItem(lua::state &l, FbTk::Menu &menu, FbTk::StringConvertor &parent_co | |||
310 | menu.insert(str_label, createRootCmdMenu(screen_number, str_label, str_cmd, | 311 | menu.insert(str_label, createRootCmdMenu(screen_number, str_label, str_cmd, |
311 | reloader, program) ); | 312 | reloader, program) ); |
312 | } else if (str_key == "workspaces") { | 313 | } else if (str_key == "workspaces") { |
313 | menu.insert(str_label, FbTk::RefCount<FbTk::Menu>(screen->workspaceMenu()) ); | 314 | menu.insert(str_label, RefMenu(screen->workspaceMenu()) ); |
314 | } else { | 315 | } else { |
315 | // finally, try window-related commands | 316 | // finally, try window-related commands |
316 | MenuCreator::createWindowMenuItem(str_key, str_label, menu); | 317 | MenuCreator::createWindowMenuItem(str_key, str_label, menu); |
@@ -413,7 +414,6 @@ FbTk::RefCount<FbMenu> MenuCreator::createMenuType(const string &type, int scree | |||
413 | bool MenuCreator::createWindowMenuItem(const string &type, | 414 | bool MenuCreator::createWindowMenuItem(const string &type, |
414 | const string &label, | 415 | const string &label, |
415 | FbTk::Menu &menu) { | 416 | FbTk::Menu &menu) { |
416 | typedef FbTk::RefCount<FbTk::Command<void> > RefCmd; | ||
417 | _FB_USES_NLS; | 417 | _FB_USES_NLS; |
418 | 418 | ||
419 | static MenuContext context; | 419 | static MenuContext context; |
@@ -495,8 +495,7 @@ bool MenuCreator::createWindowMenuItem(const string &type, | |||
495 | if (screen == 0) | 495 | if (screen == 0) |
496 | return false; | 496 | return false; |
497 | 497 | ||
498 | FbTk::RefCount<FbTk::Menu> submenu( new AlphaMenu(screen->menuTheme(), | 498 | RefMenu submenu( new AlphaMenu(screen->menuTheme(), screen->imageControl(), |
499 | screen->imageControl(), | ||
500 | *screen->layerManager().getLayer(ResourceLayer::MENU)) ); | 499 | *screen->layerManager().getLayer(ResourceLayer::MENU)) ); |
501 | submenu->disableTitle(); | 500 | submenu->disableTitle(); |
502 | menu.insert(label.empty() ? _FB_XTEXT(Configmenu, Transparency, "Transparency", | 501 | menu.insert(label.empty() ? _FB_XTEXT(Configmenu, Transparency, "Transparency", |
@@ -515,13 +514,13 @@ bool MenuCreator::createWindowMenuItem(const string &type, | |||
515 | 514 | ||
516 | } else if (type == "sendto") { | 515 | } else if (type == "sendto") { |
517 | menu.insert(label.empty() ? _FB_XTEXT(Windowmenu, SendTo, "Send To...", "Send to menu item name"): | 516 | menu.insert(label.empty() ? _FB_XTEXT(Windowmenu, SendTo, "Send To...", "Send to menu item name"): |
518 | label, FbTk::RefCount<FbTk::Menu>(new SendToMenu(*Fluxbox::instance()->findScreen(menu.screenNumber()))) ); | 517 | label, RefMenu(new SendToMenu(*Fluxbox::instance()->findScreen(menu.screenNumber()))) ); |
519 | } else if (type == "layer") { | 518 | } else if (type == "layer") { |
520 | BScreen *screen = Fluxbox::instance()->findScreen(menu.screenNumber()); | 519 | BScreen *screen = Fluxbox::instance()->findScreen(menu.screenNumber()); |
521 | if (screen == 0) | 520 | if (screen == 0) |
522 | return false; | 521 | return false; |
523 | 522 | ||
524 | FbTk::RefCount<FbTk::Menu> submenu( new LayerMenu(screen->menuTheme(), | 523 | RefMenu submenu( new LayerMenu(screen->menuTheme(), |
525 | screen->imageControl(), | 524 | screen->imageControl(), |
526 | *screen->layerManager().getLayer(ResourceLayer::MENU), | 525 | *screen->layerManager().getLayer(ResourceLayer::MENU), |
527 | &context, | 526 | &context, |