diff options
author | Max Horn | 2012-10-15 14:30:18 +0200 |
---|---|---|
committer | Thierry Crozat | 2012-11-18 01:29:08 +0000 |
commit | a49f55878a152eb9bd206e874d54bdf8e9ec281d (patch) | |
tree | 1eb9a20e746631f92e47b5f396e7df705f5142c8 /gui | |
parent | 93eb6ec64aa2ee2e276c7c2ddd57a269b539af28 (diff) | |
download | scummvm-rg350-a49f55878a152eb9bd206e874d54bdf8e9ec281d.tar.gz scummvm-rg350-a49f55878a152eb9bd206e874d54bdf8e9ec281d.tar.bz2 scummvm-rg350-a49f55878a152eb9bd206e874d54bdf8e9ec281d.zip |
OSX: Improve native OS X browser dialog
Signed-off-by: Thierry Crozat <criezy@scummvm.org>
Diffstat (limited to 'gui')
-rw-r--r-- | gui/browser.h | 1 | ||||
-rw-r--r-- | gui/browser_osx.mm | 40 |
2 files changed, 32 insertions, 9 deletions
diff --git a/gui/browser.h b/gui/browser.h index e5cc12ad8e..5cf091fbf4 100644 --- a/gui/browser.h +++ b/gui/browser.h @@ -48,6 +48,7 @@ public: protected: #ifdef MACOSX const void *_titleRef; + const void *_chooseRef; #else ListWidget *_fileList; StaticTextWidget *_currentPath; diff --git a/gui/browser_osx.mm b/gui/browser_osx.mm index b8aa7c50ee..1d5e6f2f57 100644 --- a/gui/browser_osx.mm +++ b/gui/browser_osx.mm @@ -28,6 +28,7 @@ #include "common/config-manager.h" #include "common/system.h" #include "common/algorithm.h" +#include "common/translation.h" #include <AppKit/NSOpenPanel.h> #include <Foundation/NSString.h> @@ -36,12 +37,29 @@ namespace GUI { BrowserDialog::BrowserDialog(const char *title, bool dirBrowser) : Dialog("Browser") { - _titleRef = CFStringCreateWithCString(0, title, CFStringGetSystemEncoding()); + + // remember whether this is a file browser or a directory browser. _isDirBrowser = dirBrowser; + + // Get current encoding +#ifdef USE_TRANSLATION + CFStringRef encStr = CFStringCreateWithCString(NULL, TransMan.getCurrentCharset().c_str(), kCFStringEncodingASCII); + CFStringEncoding stringEncoding = CFStringConvertIANACharSetNameToEncoding(encStr); + CFRelease(encStr); +#else + CFStringEncoding stringEncoding = kCFStringEncodingASCII; +#endif + + // Convert title to NSString + _titleRef = CFStringCreateWithCString(0, title, stringEncoding); + + // Convert button text to NSString + _chooseRef = CFStringCreateWithCString(0, _("Choose"), stringEncoding); } BrowserDialog::~BrowserDialog() { CFRelease(_titleRef); + CFRelease(_chooseRef); } int BrowserDialog::runModal() { @@ -58,16 +76,20 @@ int BrowserDialog::runModal() { // Temporarily show the real mouse CGDisplayShowCursor(kCGDirectMainDisplay); - - NSOpenPanel * panel = [NSOpenPanel openPanel]; - [panel setCanChooseDirectories:YES]; - if ([panel runModalForTypes:nil] == NSOKButton) { - const char *filename = [[panel filename] UTF8String]; - _choice = Common::FSNode(filename); - choiceMade = true; + NSOpenPanel *panel = [NSOpenPanel openPanel]; + [panel setCanChooseFiles:!_isDirBrowser]; + [panel setCanChooseDirectories:_isDirBrowser]; + [panel setTitle:(NSString *)_titleRef]; + [panel setPrompt:(NSString *)_chooseRef]; + if ([panel runModal] == NSOKButton) { + NSURL *url = [panel URL]; + if ([url isFileURL]) { + const char *filename = [[url path] UTF8String]; + _choice = Common::FSNode(filename); + choiceMade = true; + } } - // If we were in fullscreen mode, switch back if (wasFullscreen) { g_system->beginGFXTransaction(); |