mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
MACOSX: fix deprecation warnings
This commit is contained in:
parent
b2fd07f191
commit
84de72ac76
@ -40,6 +40,19 @@
|
||||
#include <Foundation/NSURL.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101400
|
||||
|
||||
#ifndef NSControlStateValueOff
|
||||
#define NSControlStateValueOff NSOffState
|
||||
#endif
|
||||
|
||||
#ifndef NSControlStateValueOn
|
||||
#define NSControlStateValueOn NSOnState
|
||||
#endif
|
||||
|
||||
#define NSButtonTypeSwitch NSSwitchButton
|
||||
#endif
|
||||
|
||||
|
||||
@interface BrowserDialogPresenter : NSObject {
|
||||
@public
|
||||
@ -73,7 +86,7 @@
|
||||
NSButton *showHiddenFilesButton = 0;
|
||||
if ([panel respondsToSelector:@selector(setShowsHiddenFiles:)]) {
|
||||
showHiddenFilesButton = [[NSButton alloc] init];
|
||||
[showHiddenFilesButton setButtonType:NSSwitchButton];
|
||||
[showHiddenFilesButton setButtonType:NSButtonTypeSwitch];
|
||||
|
||||
CFStringRef hiddenFilesString = CFStringCreateWithCString(0, _("Show hidden files").encode().c_str(), kCFStringEncodingUTF8);
|
||||
[showHiddenFilesButton setTitle:(NSString*)hiddenFilesString];
|
||||
@ -81,10 +94,10 @@
|
||||
|
||||
[showHiddenFilesButton sizeToFit];
|
||||
if (ConfMan.getBool("gui_browser_show_hidden", Common::ConfigManager::kApplicationDomain)) {
|
||||
[showHiddenFilesButton setState:NSOnState];
|
||||
[showHiddenFilesButton setState:NSControlStateValueOn];
|
||||
[panel setShowsHiddenFiles: YES];
|
||||
} else {
|
||||
[showHiddenFilesButton setState:NSOffState];
|
||||
[showHiddenFilesButton setState:NSControlStateValueOff];
|
||||
[panel setShowsHiddenFiles: NO];
|
||||
}
|
||||
[panel setAccessoryView:showHiddenFilesButton];
|
||||
@ -110,7 +123,7 @@
|
||||
}
|
||||
|
||||
- (IBAction) showHiddenFiles : (id) sender {
|
||||
if ([sender state] == NSOnState) {
|
||||
if ([sender state] == NSControlStateValueOn) {
|
||||
[_panel setShowsHiddenFiles: YES];
|
||||
ConfMan.setBool("gui_browser_show_hidden", true, Common::ConfigManager::kApplicationDomain);
|
||||
} else {
|
||||
|
@ -32,6 +32,10 @@
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <CoreFoundation/CFString.h>
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
|
||||
#define NSPasteboardTypeString NSStringPboardType
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
|
||||
typedef unsigned long NSUInteger;
|
||||
|
||||
@ -47,16 +51,15 @@ enum {
|
||||
#endif
|
||||
|
||||
bool hasTextInClipboardMacOSX() {
|
||||
return [[NSPasteboard generalPasteboard] availableTypeFromArray:[NSArray arrayWithObject:NSStringPboardType]] != nil;
|
||||
return [[NSPasteboard generalPasteboard] availableTypeFromArray:[NSArray arrayWithObject:NSPasteboardTypeString]] != nil;
|
||||
}
|
||||
|
||||
Common::U32String getTextFromClipboardMacOSX() {
|
||||
if (!hasTextInClipboardMacOSX())
|
||||
return Common::U32String();
|
||||
// Note: on OS X 10.6 and above it is recommended to use NSPasteboardTypeString rather than NSStringPboardType.
|
||||
// But since we still target older version use NSStringPboardType.
|
||||
|
||||
NSPasteboard *pb = [NSPasteboard generalPasteboard];
|
||||
NSString *str = [pb stringForType:NSStringPboardType];
|
||||
NSString *str = [pb stringForType:NSPasteboardTypeString];
|
||||
if (str == nil)
|
||||
return Common::U32String();
|
||||
|
||||
@ -82,7 +85,7 @@ Common::U32String getTextFromClipboardMacOSX() {
|
||||
|
||||
bool setTextInClipboardMacOSX(const Common::U32String &text) {
|
||||
NSPasteboard *pb = [NSPasteboard generalPasteboard];
|
||||
[pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
|
||||
[pb declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil];
|
||||
|
||||
#ifdef SCUMM_LITTLE_ENDIAN
|
||||
NSStringEncoding stringEncoding = NSUTF32LittleEndianStringEncoding;
|
||||
@ -90,7 +93,7 @@ bool setTextInClipboardMacOSX(const Common::U32String &text) {
|
||||
NSStringEncoding stringEncoding = NSUTF32BigEndianStringEncoding;
|
||||
#endif
|
||||
NSString *nsstring = [[NSString alloc] initWithBytes:text.c_str() length:4*text.size() encoding: stringEncoding];
|
||||
bool status = [pb setString:nsstring forType:NSStringPboardType];
|
||||
bool status = [pb setString:nsstring forType:NSPasteboardTypeString];
|
||||
[nsstring release];
|
||||
return status;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user