From 74bcaba766f922fb6c424766c27e467639c80762 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sat, 29 Aug 2009 20:28:52 +0000 Subject: [PATCH] require 10.6 (and Xcode 3.2) for development, and kill some more deprecated methods too --- Transmission.xcodeproj/project.pbxproj | 17 ++++++++---- macosx/InfoWindowController.m | 5 +--- macosx/NSApplicationAdditions.h | 29 ++++++++++++++++++++ macosx/NSApplicationAdditions.m | 34 +++++++++++++++++++++++ macosx/QuickLookController.m | 4 +-- macosx/Torrent.m | 3 -- macosx/TorrentCell.h | 1 - macosx/TorrentCell.m | 38 ++++++++++++++------------ 8 files changed, 99 insertions(+), 32 deletions(-) create mode 100644 macosx/NSApplicationAdditions.h create mode 100644 macosx/NSApplicationAdditions.m diff --git a/Transmission.xcodeproj/project.pbxproj b/Transmission.xcodeproj/project.pbxproj index 499ef68d7..81544a3da 100644 --- a/Transmission.xcodeproj/project.pbxproj +++ b/Transmission.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 45; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ @@ -164,6 +164,7 @@ A29AF4F90D01BAEB00D097EC /* UpArrowTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = A29AF4F80D01BAEB00D097EC /* UpArrowTemplate.png */; }; A29B0C270BD15FEF0006F230 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = A2F8951E0A2D4BA500ED2127 /* Credits.rtf */; }; A29C8B370ACC6EB3000ED9F9 /* PortChecker.m in Sources */ = {isa = PBXBuildFile; fileRef = A29C8B350ACC6EB3000ED9F9 /* PortChecker.m */; }; + A29D84041049C25600D1987A /* NSApplicationAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = A29D84031049C25600D1987A /* NSApplicationAdditions.m */; }; A29DF8B90DB2544C00D04E5A /* resume.c in Sources */ = {isa = PBXBuildFile; fileRef = A29DF8B60DB2544C00D04E5A /* resume.c */; }; A29DF8BA0DB2544C00D04E5A /* resume.h in Headers */ = {isa = PBXBuildFile; fileRef = A29DF8B70DB2544C00D04E5A /* resume.h */; }; A29DF8BB0DB2544C00D04E5A /* torrent.h in Headers */ = {isa = PBXBuildFile; fileRef = A29DF8B80DB2544C00D04E5A /* torrent.h */; }; @@ -627,6 +628,8 @@ A29AF4F80D01BAEB00D097EC /* UpArrowTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = UpArrowTemplate.png; path = macosx/Images/UpArrowTemplate.png; sourceTree = ""; }; A29C8B340ACC6EB3000ED9F9 /* PortChecker.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PortChecker.h; path = macosx/PortChecker.h; sourceTree = ""; }; A29C8B350ACC6EB3000ED9F9 /* PortChecker.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = PortChecker.m; path = macosx/PortChecker.m; sourceTree = ""; }; + A29D84021049C25600D1987A /* NSApplicationAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NSApplicationAdditions.h; path = macosx/NSApplicationAdditions.h; sourceTree = ""; }; + A29D84031049C25600D1987A /* NSApplicationAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NSApplicationAdditions.m; path = macosx/NSApplicationAdditions.m; sourceTree = ""; }; A29DF8B60DB2544C00D04E5A /* resume.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = resume.c; path = libtransmission/resume.c; sourceTree = ""; }; A29DF8B70DB2544C00D04E5A /* resume.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = resume.h; path = libtransmission/resume.h; sourceTree = ""; }; A29DF8B80DB2544C00D04E5A /* torrent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = torrent.h; path = libtransmission/torrent.h; sourceTree = ""; }; @@ -899,6 +902,8 @@ children = ( 32CA4F630368D1EE00C91783 /* Transmission_Prefix.pch */, 29B97316FDCFA39411CA2CEA /* main.m */, + A29D84021049C25600D1987A /* NSApplicationAdditions.h */, + A29D84031049C25600D1987A /* NSApplicationAdditions.m */, 4DF0C5AA0899190500DD8943 /* Controller.h */, 4DF0C5A90899190500DD8943 /* Controller.m */, 4DFBC2DD09C0970D00D5C571 /* Torrent.h */, @@ -1673,9 +1678,10 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; + ORGANIZATIONNAME = "The Transmission Project"; }; buildConfigurationList = 4DF0C59A089918A300DD8943 /* Build configuration list for PBXProject "Transmission" */; - compatibilityVersion = "Xcode 3.1"; + compatibilityVersion = "Xcode 3.2"; hasScannedForEncodings = 1; knownRegions = ( English, @@ -1983,6 +1989,7 @@ A222EA7B0E6C32C4009FB003 /* BlocklistScheduler.m in Sources */, A232F07E0EEA034A00041646 /* BonjourController.m in Sources */, A23F526F0F14395900AA02E3 /* PredicateEditorRowTemplateAny.m in Sources */, + A29D84041049C25600D1987A /* NSApplicationAdditions.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2367,7 +2374,7 @@ OTHER_LDFLAGS = ""; PREBINDING = NO; PRELINK_LIBS = ""; - SDKROOT = macosx10.5; + SDKROOT = macosx10.6; STRIP_INSTALLED_PRODUCT = NO; VALID_ARCHS = "i386 ppc ppc7400 ppc970 x86_64"; }; @@ -2508,7 +2515,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_LDFLAGS = ""; PREBINDING = NO; - SDKROOT = macosx10.5; + SDKROOT = macosx10.6; VALID_ARCHS = "i386 ppc ppc7400 ppc970 x86_64"; }; name = Release; @@ -2598,7 +2605,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_LDFLAGS = ""; PREBINDING = NO; - SDKROOT = macosx10.5; + SDKROOT = macosx10.6; STRIP_INSTALLED_PRODUCT = NO; VALID_ARCHS = "i386 ppc ppc7400 ppc970 x86_64"; }; diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index 12188cc40..f336fd135 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -394,10 +394,7 @@ typedef enum [fFileController setTorrent: torrent]; - NSImage * icon = [[torrent icon] copy]; - [icon setFlipped: NO]; - [fImageView setImage: icon]; - [icon release]; + [fImageView setImage: [torrent icon]]; NSString * name = [torrent name]; [fNameField setStringValue: name]; diff --git a/macosx/NSApplicationAdditions.h b/macosx/NSApplicationAdditions.h new file mode 100644 index 000000000..b07c71953 --- /dev/null +++ b/macosx/NSApplicationAdditions.h @@ -0,0 +1,29 @@ +/****************************************************************************** + * $Id$ + * + * Copyright (c) 2009 Transmission authors and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + *****************************************************************************/ + +@interface NSApplication (NSApplicationAdditions) + +- (BOOL) isOnSnowLeopardOrBetter; + +@end diff --git a/macosx/NSApplicationAdditions.m b/macosx/NSApplicationAdditions.m new file mode 100644 index 000000000..1bd35c890 --- /dev/null +++ b/macosx/NSApplicationAdditions.m @@ -0,0 +1,34 @@ +/****************************************************************************** + * $Id$ + * + * Copyright (c) 2009 Transmission authors and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + *****************************************************************************/ + +#import "NSApplicationAdditions.h" + +@implementation NSApplication (NSApplicationAdditions) + +- (BOOL) isOnSnowLeopardOrBetter +{ + return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5; +} + +@end diff --git a/macosx/QuickLookController.m b/macosx/QuickLookController.m index ff6112692..e421cc06a 100644 --- a/macosx/QuickLookController.m +++ b/macosx/QuickLookController.m @@ -26,6 +26,7 @@ #import "QuickLook.h" #define QLPreviewPanel NSClassFromString(@"QLPreviewPanel") +#import "NSApplicationAdditions.h" #import "Controller.h" #import "InfoWindowController.h" @@ -147,8 +148,7 @@ QuickLookController * fQuickLookInstance = nil; //load the QuickLook framework and set the delegate //animation types: 0 = none; 1 = fade; 2 = zoom //disable on Snow Leopard for now - const NSInteger appKitVersionNumber10_5 = 949; - fQuickLookAvailable = floor(NSAppKitVersionNumber) <= appKitVersionNumber10_5 + fQuickLookAvailable = ![NSApp isOnSnowLeopardOrBetter] && [[NSBundle bundleWithPath: @"/System/Library/PrivateFrameworks/QuickLookUI.framework"] load]; if (fQuickLookAvailable) [[[QLPreviewPanel sharedPreviewPanel] windowController] setDelegate: self]; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 1925cf3e7..5470241dc 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -653,11 +653,8 @@ int trashDataFile(const char * filename) - (NSImage *) icon { if (!fIcon) - { fIcon = [[[NSWorkspace sharedWorkspace] iconForFileType: [self isFolder] ? NSFileTypeForHFSTypeCode('fldr') : [[self name] pathExtension]] retain]; - [fIcon setFlipped: YES]; - } return fIcon; } diff --git a/macosx/TorrentCell.h b/macosx/TorrentCell.h index 3260947c7..21e4f9aaa 100644 --- a/macosx/TorrentCell.h +++ b/macosx/TorrentCell.h @@ -25,7 +25,6 @@ @interface TorrentCell : NSActionCell { NSUserDefaults * fDefaults; - NSImage * fErrorImage; NSMutableDictionary * fTitleAttributes, * fStatusAttributes; diff --git a/macosx/TorrentCell.m b/macosx/TorrentCell.m index 369d10d10..072d2633c 100644 --- a/macosx/TorrentCell.m +++ b/macosx/TorrentCell.m @@ -25,6 +25,7 @@ #import "TorrentCell.h" #import "TorrentTableView.h" #import "GroupsController.h" +#import "NSApplicationAdditions.h" #import "NSStringAdditions.h" #import "ProgressGradients.h" @@ -78,6 +79,8 @@ - (NSString *) statusString; - (NSString *) minimalStatusString; +- (void) drawImage: (NSImage *) image inRect: (NSRect) rect; //use until 10.5 dropped + @end @implementation TorrentCell @@ -420,24 +423,20 @@ //error image const BOOL error = [torrent isErrorOrWarning]; - if (error && !fErrorImage) - { - fErrorImage = [NSImage imageNamed: @"Error.png"]; - [fErrorImage setFlipped: YES]; - } + NSImage * errorImage = error ? [NSImage imageNamed: @"Error.png"] : nil; //icon if (!minimal || !(!fTracking && fHoverAction)) //don't show in minimal mode when hovered over { - NSImage * icon = (minimal && error) ? fErrorImage : [torrent icon]; - [icon drawInRect: iconRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0f]; + NSImage * icon = (minimal && error) ? errorImage : [torrent icon]; + [self drawImage: icon inRect: iconRect]; } if (error && !minimal) { NSRect errorRect = NSMakeRect(NSMaxX(iconRect) - IMAGE_SIZE_MIN, NSMaxY(iconRect) - IMAGE_SIZE_MIN, IMAGE_SIZE_MIN, IMAGE_SIZE_MIN); - [fErrorImage drawInRect: errorRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0f]; + [self drawImage: errorImage inRect: errorRect]; } //text color @@ -510,9 +509,7 @@ controlImage = [NSImage imageNamed: [@"Resume" stringByAppendingString: controlImageSuffix]]; } - [controlImage setFlipped: YES]; - [controlImage drawInRect: [self controlButtonRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver - fraction: 1.0f]; + [self drawImage: controlImage inRect: [self controlButtonRectForBounds: cellFrame]]; //reveal button NSString * revealImageString; @@ -524,9 +521,7 @@ revealImageString = @"RevealOff.png"; NSImage * revealImage = [NSImage imageNamed: revealImageString]; - [revealImage setFlipped: YES]; - [revealImage drawInRect: [self revealButtonRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver - fraction: 1.0f]; + [self drawImage: revealImage inRect: [self revealButtonRectForBounds: cellFrame]]; //action button NSString * actionImageString; @@ -540,9 +535,7 @@ if (actionImageString) { NSImage * actionImage = [NSImage imageNamed: actionImageString]; - [actionImage setFlipped: YES]; - [actionImage drawInRect: [self actionButtonRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver - fraction: 1.0f]; + [self drawImage: actionImage inRect: [self actionButtonRectForBounds: cellFrame]]; } //status @@ -841,4 +834,15 @@ } } +- (void) drawImage: (NSImage *) image inRect: (NSRect) rect +{ + if ([NSApp isOnSnowLeopardOrBetter]) + [image drawInRect: rect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0 respectFlipped: YES hints: nil]; + else + { + [image setFlipped: YES]; + [image drawInRect: rect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0]; + } +} + @end