implement smarter reloading for custom menus

This commit is contained in:
Mark Tiefenbruck 2008-05-12 18:13:56 -07:00
parent dcdc783324
commit 68cf309220
3 changed files with 17 additions and 6 deletions

View file

@ -1,5 +1,8 @@
(Format: Year/Month/Day)
Changes for 1.1
*08/05/13:
* Only reload custom menus when necessary (Mark)
FbCommands.cc/hh
*08/05/12:
* Only reload the keys file if the contents have changed (Mark)
Keys.cc/hh fluxbox.cc/hh

View file

@ -343,16 +343,23 @@ void ShowCustomMenuCmd::execute() {
if (screen == 0)
return;
if (m_menu.get()) {
m_menu->removeAll();
m_menu->setLabel("");
} else
if (!m_menu.get() || screen->screenNumber() != m_menu->screenNumber()) {
m_menu.reset(screen->createMenu(""));
m_menu->setReloadHelper(new FbTk::AutoReloadHelper());
m_menu->reloadHelper()->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<ShowCustomMenuCmd>(*this, &ShowCustomMenuCmd::reload)));
m_menu->reloadHelper()->setMainFile(custom_menu_file);
} else
m_menu->reloadHelper()->checkReload();
MenuCreator::createFromFile(custom_menu_file, *m_menu.get());
::showMenu(*screen, *m_menu.get());
}
void ShowCustomMenuCmd::reload() {
m_menu->removeAll();
m_menu->setLabel("");
MenuCreator::createFromFile(custom_menu_file, *m_menu.get(), m_menu->reloadHelper());
}
REGISTER_COMMAND(rootmenu, FbCommands::ShowRootMenuCmd, void);
void ShowRootMenuCmd::execute() {

View file

@ -132,9 +132,10 @@ class ShowCustomMenuCmd: public FbTk::Command<void> {
public:
explicit ShowCustomMenuCmd(const std::string &arguments);
void execute();
void reload();
private:
std::string custom_menu_file;
std::auto_ptr<FbTk::Menu> m_menu;
std::auto_ptr<FbMenu> m_menu;
};
class ShowRootMenuCmd: public FbTk::Command<void> {