diff --git a/src/GUI/FGCocoaMenuBar.mm b/src/GUI/FGCocoaMenuBar.mm index eeacee81a..916195f4a 100644 --- a/src/GUI/FGCocoaMenuBar.mm +++ b/src/GUI/FGCocoaMenuBar.mm @@ -109,23 +109,25 @@ static void setItemShortcutFromString(NSMenuItem* item, const string& s) [item setKeyEquivalentModifierMask:modifiers]; } -class EnabledListener : public SGPropertyChangeListener -{ -public: - EnabledListener(NSMenuItem* i) : - item(i) - {} - - - virtual void valueChanged(SGPropertyNode *node) +namespace { + class CocoaEnabledListener : public SGPropertyChangeListener { - BOOL b = node->getBoolValue(); - [item setEnabled:b]; - } - -private: - NSMenuItem* item; -}; + public: + CocoaEnabledListener(NSMenuItem* i) : + item(i) + {} + + + virtual void valueChanged(SGPropertyNode *node) + { + BOOL b = node->getBoolValue(); + [item setEnabled:b]; + } + + private: + NSMenuItem* item; + }; +} // of anonymous namespace FGCocoaMenuBar::CocoaMenuBarPrivate::CocoaMenuBarPrivate() { @@ -173,7 +175,7 @@ void FGCocoaMenuBar::CocoaMenuBarPrivate::menuFromProps(NSMenu* menu, SGProperty setItemShortcutFromString(item, shortcut); } - n->getNode("enabled")->addChangeListener(new EnabledListener(item)); + n->getNode("enabled")->addChangeListener(new CocoaEnabledListener(item)); [item setTarget:delegate]; [item setAction:@selector(itemAction:)]; } @@ -263,7 +265,7 @@ void FGCocoaMenuBar::init() n->setBoolValue("enabled", true); } - n->getNode("enabled")->addChangeListener(new EnabledListener(item)); + n->getNode("enabled")->addChangeListener(new CocoaEnabledListener(item)); } } diff --git a/src/GUI/FGPUIMenuBar.cxx b/src/GUI/FGPUIMenuBar.cxx index a7d8ba0eb..57336d284 100644 --- a/src/GUI/FGPUIMenuBar.cxx +++ b/src/GUI/FGPUIMenuBar.cxx @@ -314,7 +314,9 @@ FGPUIMenuBar::make_object_map(SGPropertyNode * node) } } -struct EnabledListener : SGPropertyChangeListener { +namespace { + + struct EnabledListener : SGPropertyChangeListener { void valueChanged(SGPropertyNode *node) { NewGUI * gui = (NewGUI *)globals->get_subsystem("gui"); if (!gui) @@ -325,6 +327,8 @@ struct EnabledListener : SGPropertyChangeListener { } }; +} // of anonymous namespace + void FGPUIMenuBar::add_enabled_listener(SGPropertyNode * node) {