diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-05-13 01:13:56 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-05-13 01:13:56 (GMT) |
commit | 68cf3092208830e075c4fe5eddfdcbef3f11596a (patch) | |
tree | d0a8ed49f827286c2494968b0a336934912bff9e /src | |
parent | dcdc78332431ff2b258c54a99d6fac382c6a0595 (diff) | |
download | fluxbox_paul-68cf3092208830e075c4fe5eddfdcbef3f11596a.zip fluxbox_paul-68cf3092208830e075c4fe5eddfdcbef3f11596a.tar.bz2 |
implement smarter reloading for custom menus
Diffstat (limited to 'src')
-rw-r--r-- | src/FbCommands.cc | 17 | ||||
-rw-r--r-- | src/FbCommands.hh | 3 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc index 3a09b69..e0d0768 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc | |||
@@ -343,16 +343,23 @@ void ShowCustomMenuCmd::execute() { | |||
343 | if (screen == 0) | 343 | if (screen == 0) |
344 | return; | 344 | return; |
345 | 345 | ||
346 | if (m_menu.get()) { | 346 | if (!m_menu.get() || screen->screenNumber() != m_menu->screenNumber()) { |
347 | m_menu->removeAll(); | ||
348 | m_menu->setLabel(""); | ||
349 | } else | ||
350 | m_menu.reset(screen->createMenu("")); | 347 | m_menu.reset(screen->createMenu("")); |
348 | m_menu->setReloadHelper(new FbTk::AutoReloadHelper()); | ||
349 | m_menu->reloadHelper()->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<ShowCustomMenuCmd>(*this, &ShowCustomMenuCmd::reload))); | ||
350 | m_menu->reloadHelper()->setMainFile(custom_menu_file); | ||
351 | } else | ||
352 | m_menu->reloadHelper()->checkReload(); | ||
351 | 353 | ||
352 | MenuCreator::createFromFile(custom_menu_file, *m_menu.get()); | ||
353 | ::showMenu(*screen, *m_menu.get()); | 354 | ::showMenu(*screen, *m_menu.get()); |
354 | } | 355 | } |
355 | 356 | ||
357 | void ShowCustomMenuCmd::reload() { | ||
358 | m_menu->removeAll(); | ||
359 | m_menu->setLabel(""); | ||
360 | MenuCreator::createFromFile(custom_menu_file, *m_menu.get(), m_menu->reloadHelper()); | ||
361 | } | ||
362 | |||
356 | REGISTER_COMMAND(rootmenu, FbCommands::ShowRootMenuCmd, void); | 363 | REGISTER_COMMAND(rootmenu, FbCommands::ShowRootMenuCmd, void); |
357 | 364 | ||
358 | void ShowRootMenuCmd::execute() { | 365 | void ShowRootMenuCmd::execute() { |
diff --git a/src/FbCommands.hh b/src/FbCommands.hh index 3ad45c4..811fb78 100644 --- a/src/FbCommands.hh +++ b/src/FbCommands.hh | |||
@@ -132,9 +132,10 @@ class ShowCustomMenuCmd: public FbTk::Command<void> { | |||
132 | public: | 132 | public: |
133 | explicit ShowCustomMenuCmd(const std::string &arguments); | 133 | explicit ShowCustomMenuCmd(const std::string &arguments); |
134 | void execute(); | 134 | void execute(); |
135 | void reload(); | ||
135 | private: | 136 | private: |
136 | std::string custom_menu_file; | 137 | std::string custom_menu_file; |
137 | std::auto_ptr<FbTk::Menu> m_menu; | 138 | std::auto_ptr<FbMenu> m_menu; |
138 | }; | 139 | }; |
139 | 140 | ||
140 | class ShowRootMenuCmd: public FbTk::Command<void> { | 141 | class ShowRootMenuCmd: public FbTk::Command<void> { |