aboutsummaryrefslogtreecommitdiff
path: root/src/FbCommands.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbCommands.cc')
-rw-r--r--src/FbCommands.cc62
1 files changed, 39 insertions, 23 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index c815145..8875ec2 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -73,18 +73,15 @@ namespace {
73 73
74void showMenu(const BScreen &screen, FbTk::Menu &menu) { 74void showMenu(const BScreen &screen, FbTk::Menu &menu) {
75 75
76 // special case for root menu 76 // check if menu has changed
77 if (&menu == &screen.rootMenu()) { 77 if (typeid(menu) == typeid(FbMenu)) {
78 Fluxbox* fb = Fluxbox::instance(); 78 FbMenu *fbmenu = static_cast<FbMenu *>(&menu);
79 if(fb->menuTimestampsChanged()) { 79 if (fbmenu->reloadHelper())
80 // we dont show the menu here because fluxbox 80 fbmenu->reloadHelper()->checkReload();
81 // will bring up the rootmenu after the timed
82 // reread of the menu
83 fb->rereadMenu(true);
84 return;
85 }
86 } 81 }
87 82
83 FbMenu::setWindow(FocusControl::focusedFbWindow());
84
88 Window root_ret; // not used 85 Window root_ret; // not used
89 Window window_ret; // not used 86 Window window_ret; // not used
90 87
@@ -246,7 +243,14 @@ void SaveResources::execute() {
246 Fluxbox::instance()->save_rc(); 243 Fluxbox::instance()->save_rc();
247} 244}
248 245
249REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(restart, FbCommands::RestartFluxboxCmd, void); 246REGISTER_COMMAND_PARSER(restart, RestartFluxboxCmd::parse, void);
247
248FbTk::Command<void> *RestartFluxboxCmd::parse(const string &command,
249 const string &args, bool trusted) {
250 if (!trusted && !args.empty())
251 return 0;
252 return new RestartFluxboxCmd(args);
253}
250 254
251RestartFluxboxCmd::RestartFluxboxCmd(const string &cmd):m_cmd(cmd){ 255RestartFluxboxCmd::RestartFluxboxCmd(const string &cmd):m_cmd(cmd){
252} 256}
@@ -279,10 +283,11 @@ SetStyleCmd::SetStyleCmd(const string &filename):m_filename(filename) {
279} 283}
280 284
281void SetStyleCmd::execute() { 285void SetStyleCmd::execute() {
282 Fluxbox::instance()->saveStyleFilename(m_filename.c_str()); 286 if (FbTk::ThemeManager::instance().load(m_filename,
283 Fluxbox::instance()->save_rc(); 287 Fluxbox::instance()->getStyleOverlayFilename())) {
284 FbTk::ThemeManager::instance().load(m_filename, 288 Fluxbox::instance()->saveStyleFilename(m_filename.c_str());
285 Fluxbox::instance()->getStyleOverlayFilename()); 289 Fluxbox::instance()->save_rc();
290 }
286} 291}
287 292
288REGISTER_COMMAND_WITH_ARGS(keymode, FbCommands::KeyModeCmd, void); 293REGISTER_COMMAND_WITH_ARGS(keymode, FbCommands::KeyModeCmd, void);
@@ -335,8 +340,8 @@ void ShowClientMenuCmd::execute() {
335 m_list.push_back(static_cast<FluxboxWindow *>(*it)); 340 m_list.push_back(static_cast<FluxboxWindow *>(*it));
336 } 341 }
337 342
338 m_menu = new ClientMenu(*screen, m_list, 0); 343 m_menu.reset(new ClientMenu(*screen, m_list, 0));
339 ::showMenu(*screen, **m_menu); 344 ::showMenu(*screen, *m_menu.get());
340} 345}
341 346
342REGISTER_COMMAND_WITH_ARGS(custommenu, FbCommands::ShowCustomMenuCmd, void); 347REGISTER_COMMAND_WITH_ARGS(custommenu, FbCommands::ShowCustomMenuCmd, void);
@@ -347,11 +352,22 @@ void ShowCustomMenuCmd::execute() {
347 BScreen *screen = Fluxbox::instance()->mouseScreen(); 352 BScreen *screen = Fluxbox::instance()->mouseScreen();
348 if (screen == 0) 353 if (screen == 0)
349 return; 354 return;
350 m_menu = MenuCreator::createFromFile(custom_menu_file, 355
351 screen->screenNumber(), true); 356 if (!m_menu.get() || screen->screenNumber() != m_menu->screenNumber()) {
352 if (!m_menu.get()) 357 m_menu.reset(screen->createMenu(""));
353 return; 358 m_menu->setReloadHelper(new FbTk::AutoReloadHelper());
354 ::showMenu(*screen, **m_menu); 359 m_menu->reloadHelper()->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<ShowCustomMenuCmd>(*this, &ShowCustomMenuCmd::reload)));
360 m_menu->reloadHelper()->setMainFile(custom_menu_file);
361 } else
362 m_menu->reloadHelper()->checkReload();
363
364 ::showMenu(*screen, *m_menu.get());
365}
366
367void ShowCustomMenuCmd::reload() {
368 m_menu->removeAll();
369 m_menu->setLabel("");
370 MenuCreator::createFromFile(custom_menu_file, *m_menu.get(), m_menu->reloadHelper());
355} 371}
356 372
357REGISTER_COMMAND(rootmenu, FbCommands::ShowRootMenuCmd, void); 373REGISTER_COMMAND(rootmenu, FbCommands::ShowRootMenuCmd, void);
@@ -556,4 +572,4 @@ void DeiconifyCmd::execute() {
556 }; 572 };
557} 573}
558 574
559}; // end namespace FbCommands 575} // end namespace FbCommands