From de30b3f98fbcfc45f11baac6375e9aeef9a3bd37 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Mon, 12 Aug 2013 00:13:18 +0200 Subject: [PATCH] Define LinkApp::isOpk() also when OPK support is disabled This reduces the number of required preprocessor directives, leading to more readable code and more code being examined by the compiler (useful to spot problems). Since the method is inlined, the compiler should be able to eliminate the same amount of code that the preprocessor would, only at a later stage of the compilation. --- src/contextmenu.cpp | 13 ++++++------- src/gmenu2x.cpp | 42 ++++++++++++++++-------------------------- src/linkapp.h | 1 + 3 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/contextmenu.cpp b/src/contextmenu.cpp index 03f8abe..ca35859 100644 --- a/src/contextmenu.cpp +++ b/src/contextmenu.cpp @@ -49,18 +49,17 @@ ContextMenu::ContextMenu(GMenu2X &gmenu2x, Menu &menu) * This is not a good idea as it'll break things if * a new config option is added to the contextual menu. */ -#if defined(HAVE_LIBOPK) && !defined(ENABLE_CPUFREQ) - if (!app->isOpk() || !app->getSelectorDir().empty()) + if (!app->isOpk() +#if defined(ENABLE_CPUFREQ) + || true #endif - { + || !app->getSelectorDir().empty() + ) { options.push_back(std::make_shared( tr.translate("Edit $1", app->getTitle().c_str(), NULL), std::bind(&GMenu2X::editLink, &gmenu2x))); } -#ifdef HAVE_LIBOPK - if (!app->isOpk()) -#endif - { + if (!app->isOpk()) { options.push_back(std::make_shared( tr.translate("Delete $1 link", app->getTitle().c_str(), NULL), std::bind(&GMenu2X::deleteLink, &gmenu2x))); diff --git a/src/gmenu2x.cpp b/src/gmenu2x.cpp index d1afb41..765fa14 100644 --- a/src/gmenu2x.cpp +++ b/src/gmenu2x.cpp @@ -880,43 +880,33 @@ void GMenu2X::editLink() { string diagIcon = linkApp->getIconPath(); SettingsDialog sd(this, input, ts, diagTitle, diagIcon); -#ifdef HAVE_LIBOPK if (!linkApp->isOpk()) { -#endif - sd.addSetting(new MenuSettingString(this, ts, tr["Title"], tr["Link title"], &linkTitle, diagTitle, diagIcon)); - sd.addSetting(new MenuSettingString(this, ts, tr["Description"], tr["Link description"], &linkDescription, diagTitle, diagIcon)); - sd.addSetting(new MenuSettingMultiString(this, ts, tr["Section"], tr["The section this link belongs to"], &newSection, &menu->getSections())); - sd.addSetting(new MenuSettingImage(this, ts, tr["Icon"], - tr.translate("Select an icon for the link: $1", - linkTitle.c_str(), NULL), &linkIcon, "png")); - sd.addSetting(new MenuSettingFile(this, ts, tr["Manual"], - tr["Select a graphic/textual manual or a readme"], - &linkManual, "man.png,txt")); -#ifdef HAVE_LIBOPK + sd.addSetting(new MenuSettingString(this, ts, tr["Title"], tr["Link title"], &linkTitle, diagTitle, diagIcon)); + sd.addSetting(new MenuSettingString(this, ts, tr["Description"], tr["Link description"], &linkDescription, diagTitle, diagIcon)); + sd.addSetting(new MenuSettingMultiString(this, ts, tr["Section"], tr["The section this link belongs to"], &newSection, &menu->getSections())); + sd.addSetting(new MenuSettingImage(this, ts, tr["Icon"], + tr.translate("Select an icon for the link: $1", + linkTitle.c_str(), NULL), &linkIcon, "png")); + sd.addSetting(new MenuSettingFile(this, ts, tr["Manual"], + tr["Select a graphic/textual manual or a readme"], + &linkManual, "man.png,txt")); } if (!linkApp->isOpk() || !linkApp->getSelectorDir().empty()) { -#endif - sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Directory"], tr["Directory to scan for the selector"], &linkSelDir)); - sd.addSetting(new MenuSettingBool(this, ts, tr["Selector Browser"], tr["Allow the selector to change directory"], &linkSelBrowser)); -#ifdef HAVE_LIBOPK + sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Directory"], tr["Directory to scan for the selector"], &linkSelDir)); + sd.addSetting(new MenuSettingBool(this, ts, tr["Selector Browser"], tr["Allow the selector to change directory"], &linkSelBrowser)); } -#endif #ifdef ENABLE_CPUFREQ sd.addSetting(new MenuSettingInt(this, ts, tr["Clock frequency"], tr["Cpu clock frequency to set when launching this link"], &linkClock, cpuFreqMin, confInt["maxClock"], cpuFreqMultiple)); #endif -#ifdef HAVE_LIBOPK if (!linkApp->isOpk()) { -#endif - sd.addSetting(new MenuSettingString(this, ts, tr["Selector Filter"], tr["Selector filter (Separate values with a comma)"], &linkSelFilter, diagTitle, diagIcon)); - sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Screenshots"], tr["Directory of the screenshots for the selector"], &linkSelScreens)); - sd.addSetting(new MenuSettingFile(this, ts, tr["Selector Aliases"], tr["File containing a list of aliases for the selector"], &linkSelAliases)); - sd.addSetting(new MenuSettingBool(this, ts, tr["Don't Leave"], tr["Don't quit GMenu2X when launching this link"], &linkApp->runsInBackgroundRef())); + sd.addSetting(new MenuSettingString(this, ts, tr["Selector Filter"], tr["Selector filter (Separate values with a comma)"], &linkSelFilter, diagTitle, diagIcon)); + sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Screenshots"], tr["Directory of the screenshots for the selector"], &linkSelScreens)); + sd.addSetting(new MenuSettingFile(this, ts, tr["Selector Aliases"], tr["File containing a list of aliases for the selector"], &linkSelAliases)); + sd.addSetting(new MenuSettingBool(this, ts, tr["Don't Leave"], tr["Don't quit GMenu2X when launching this link"], &linkApp->runsInBackgroundRef())); #if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) - sd.addSetting(new MenuSettingBool(this, ts, tr["Display Console"], tr["Must be enabled for console-based applications"], &linkApp->consoleApp)); + sd.addSetting(new MenuSettingBool(this, ts, tr["Display Console"], tr["Must be enabled for console-based applications"], &linkApp->consoleApp)); #endif -#ifdef HAVE_LIBOPK } -#endif if (sd.exec() && sd.edited()) { linkApp->setTitle(linkTitle); diff --git a/src/linkapp.h b/src/linkapp.h index e78689b..e9ad5bf 100644 --- a/src/linkapp.h +++ b/src/linkapp.h @@ -68,6 +68,7 @@ public: #else LinkApp(GMenu2X *gmenu2x, Touchscreen &ts, InputManager &inputMgr, const char* linkfile); + bool isOpk() { return false; } #endif virtual void loadIcon();