+void FGATCDialogNew::frequencyDisplay(const std::string& ident)
+{
+ const char *dialog_name = "atc-freq-display";
+ SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
+ if (!dlg)
+ return;
+
+ _gui->closeDialog(dialog_name);
+
+ SGPropertyNode_ptr freq_group = getNamedNode(dlg, "frequency-list");
+ // remove all frequency entries
+ freq_group->removeChildren("group", false);
+
+ std::string uident(ident);
+ atcUppercase(uident);
+ string label;
+
+ const FGAirport *a = fgFindAirportID(uident);
+ if (!a) {
+ label = "Airport " + ident + " not found in database.";
+ mkDialog(label.c_str());
+ return;
+ }
+
+ // set title
+ label = uident + " Frequencies";
+ dlg->setStringValue("text/label", label.c_str());
+
+ const flightgear::CommStationList& comms(a->commStations());
+ if (comms.empty()) {
+ label = "No frequencies found for airport " + uident;
+ mkDialog(label.c_str());
+ return;
+ }
+
+ for (unsigned int c=0; c < comms.size(); ++c) {
+ flightgear::CommStation* comm = comms[c];
+
+ // add frequency line (modified copy of <group-template>)
+ SGPropertyNode *entry = freq_group->getNode("group", c, true);
+ copyProperties(freq_group->getNode("group-template", true), entry);
+ entry->removeChildren("enabled", true);
+
+ entry->setStringValue("text[0]/label", comm->ident());
+
+ char buf[8];
+ snprintf(buf, 8, "%.2f", comm->freqMHz());
+ if(buf[5] == '3') buf[5] = '2';
+ if(buf[5] == '8') buf[5] = '7';
+ buf[7] = '\0';
+
+ entry->setStringValue("text[1]/label", buf);
+ }
+
+ _gui->showDialog(dialog_name);
+}
+
+static bool doFrequencySearch( const SGPropertyNode* )
+{
+ FGATCDialogNew::instance()->frequencySearch();
+ return true;
+}
+
+static bool doFrequencyDisplay( const SGPropertyNode* args )
+{
+ std::string icao = args->getStringValue("icao");
+ if (icao.empty()) {
+ icao = fgGetString("/sim/atc/freq-airport");
+ }
+
+ FGATCDialogNew::instance()->frequencyDisplay(icao);
+ return true;
+}
+
+FGATCDialogNew * FGATCDialogNew::_instance = NULL;
+