X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FGUI%2FCocoaFileDialog.mm;h=352fa3c15b66844cf0fc02b31fbad5cb8fbb390f;hb=846fd2169832c8938f04386139de746a06e80d4b;hp=c2bdbd9321babc05e09b410208251ac3792b5642;hpb=c70bd65922fcb4678c4772d7b9b0e13f59023928;p=flightgear.git diff --git a/src/GUI/CocoaFileDialog.mm b/src/GUI/CocoaFileDialog.mm index c2bdbd932..352fa3c15 100644 --- a/src/GUI/CocoaFileDialog.mm +++ b/src/GUI/CocoaFileDialog.mm @@ -1,9 +1,27 @@ +// CocoaFileDialog.mm - Cocoa implementation of file-dialog interface + +// Copyright (C) 2013 James Turner +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// #include "CocoaFileDialog.hxx" -// bring it all in! -#include +#include +#include #include @@ -13,19 +31,15 @@ #include #include +#include #include
#include
#include -static NSString* stdStringToCocoa(const std::string& s) -{ - return [NSString stringWithUTF8String:s.c_str()]; -} - -static NSURL* pathToNSURL(const SGPath& aPath) -{ - return [NSURL fileURLWithPath:stdStringToCocoa(aPath.str())]; -} +// 10.6 compiler won't accept block-scoped locals in Objective-C++, +// so making these globals. +static NSString* completion_path = nil; +static SGPath completion_sgpath; class CocoaFileDialog::CocoaFileDialogPrivate { @@ -117,14 +131,11 @@ void CocoaFileDialog::exec() [d->panel beginSheetModalForWindow:cocoaWindow completionHandler:^(NSInteger result) { - NSString* path = nil; - SGPath sgpath; - if (result == NSFileHandlingPanelOKButton) { - path = [[d->panel URL] path]; + completion_path = [[d->panel URL] path]; //NSLog(@"the URL is: %@", d->panel URL]); - sgpath = ([path UTF8String]); - _callback->onFileDialogDone(this, sgpath); + completion_sgpath = ([completion_path UTF8String]); + _callback->onFileDialogDone(this, completion_sgpath); } }]; }