diff --git a/Transmission.xcodeproj/project.pbxproj b/Transmission.xcodeproj/project.pbxproj index 16cfbcacb..c1797ebc9 100644 --- a/Transmission.xcodeproj/project.pbxproj +++ b/Transmission.xcodeproj/project.pbxproj @@ -109,6 +109,7 @@ A2305AAC0A3DCCEF00AB2D77 /* ProgressBarEndGreen.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305AA70A3DCCEF00AB2D77 /* ProgressBarEndGreen.png */; }; A2305AAD0A3DCCEF00AB2D77 /* ProgressBarEndGray.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305AA80A3DCCEF00AB2D77 /* ProgressBarEndGray.png */; }; A232D29E0A70903E00973B12 /* Filter.png in Resources */ = {isa = PBXBuildFile; fileRef = A232D29D0A70903E00973B12 /* Filter.png */; }; + A2385DD40BFE06C800B24EF6 /* DragOverlayWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = A2385DD20BFE06C800B24EF6 /* DragOverlayWindow.m */; }; A23BBEB70A9BBE77003F7274 /* BarButton.m in Sources */ = {isa = PBXBuildFile; fileRef = A27431D90A68538400FA780A /* BarButton.m */; }; A24103070AF80E390001C8D0 /* FilterButtonPressedLeft.png in Resources */ = {isa = PBXBuildFile; fileRef = A253F7140A699178008EE24F /* FilterButtonPressedLeft.png */; }; A246004D0A6DCE4600D19088 /* SpeedLimitButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = A246004C0A6DCE4600D19088 /* SpeedLimitButtonPressed.png */; }; @@ -328,6 +329,8 @@ A2305AA70A3DCCEF00AB2D77 /* ProgressBarEndGreen.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarEndGreen.png; path = macosx/Images/ProgressBarEndGreen.png; sourceTree = ""; }; A2305AA80A3DCCEF00AB2D77 /* ProgressBarEndGray.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarEndGray.png; path = macosx/Images/ProgressBarEndGray.png; sourceTree = ""; }; A232D29D0A70903E00973B12 /* Filter.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Filter.png; path = macosx/Images/Filter.png; sourceTree = ""; }; + A2385DD20BFE06C800B24EF6 /* DragOverlayWindow.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = DragOverlayWindow.m; path = macosx/DragOverlayWindow.m; sourceTree = ""; }; + A2385DD30BFE06C800B24EF6 /* DragOverlayWindow.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = DragOverlayWindow.h; path = macosx/DragOverlayWindow.h; sourceTree = ""; }; A2440F9C0BD331A2006A687A /* German */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = German; path = macosx/German.lproj/InfoPlist.strings; sourceTree = ""; }; A2440F9D0BD331A2006A687A /* German */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = German; path = macosx/German.lproj/InfoWindow.nib; sourceTree = ""; }; A2440F9E0BD331A2006A687A /* German */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = German; path = macosx/German.lproj/Localizable.strings; sourceTree = ""; }; @@ -452,6 +455,8 @@ 080E96DDFE201D6D7F000001 /* Sources */ = { isa = PBXGroup; children = ( + A2385DD20BFE06C800B24EF6 /* DragOverlayWindow.m */, + A2385DD30BFE06C800B24EF6 /* DragOverlayWindow.h */, A2265F3F0B5EF5F40093DDA5 /* FileBrowserCell.h */, A2265F400B5EF5F40093DDA5 /* FileBrowserCell.m */, A2BF078F0B066E0800757C92 /* SpeedLimitToTurtleIconTransformer.m */, @@ -993,6 +998,7 @@ A24999230B49F1B5001EADA3 /* ActionPopUpButton.m in Sources */, A2265F420B5EF5F40093DDA5 /* FileBrowserCell.m in Sources */, A2A1CB7A0BF29D5500AE959F /* PeerProgressIndicatorCell.m in Sources */, + A2385DD40BFE06C800B24EF6 /* DragOverlayWindow.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/macosx/Controller.h b/macosx/Controller.h index f7f72fafe..f14bd8873 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -30,6 +30,7 @@ #import "PrefsController.h" #import "InfoWindowController.h" #import "MessageWindowController.h" +#import "DragOverlayWindow.h" #import "Badger.h" #import "ImageBackgroundView.h" #import "BarButton.h" @@ -51,6 +52,7 @@ MessageWindowController * fMessageController; IBOutlet NSWindow * fWindow; + DragOverlayWindow * fOverlayWindow; IBOutlet NSScrollView * fScrollView; IBOutlet TorrentTableView * fTableView; NSToolbar * fToolbar; diff --git a/macosx/Controller.m b/macosx/Controller.m index af2bffa04..1b4bc4c7e 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -187,6 +187,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [fTorrents release]; [fDisplayedTorrents release]; [fBadger release]; + [fOverlayWindow release]; [fAutoImportedNames release]; [fPendingTorrentDownloads release]; @@ -201,6 +202,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [fFilterBar setBackgroundImage: [NSImage imageNamed: @"FilterBarBackground.png"]]; [fWindow setAcceptsMouseMovedEvents: YES]; //ensure filter buttons display correctly + fOverlayWindow = [[DragOverlayWindow alloc] init]; fToolbar = [[NSToolbar alloc] initWithIdentifier: @"Transmission Toolbar"]; [fToolbar setDelegate: self]; @@ -267,8 +269,9 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [fTableView setTorrents: fDisplayedTorrents]; [[fTableView tableColumnWithIdentifier: @"Torrent"] setDataCell: [[TorrentCell alloc] init]]; - [fTableView registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType, - NSURLPboardType, TORRENT_TABLE_VIEW_DATA_TYPE, nil]]; + [fTableView registerForDraggedTypes: [NSArray arrayWithObject: TORRENT_TABLE_VIEW_DATA_TYPE]]; + [fWindow registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType, + NSURLPboardType, nil]]; //register for sleep notifications IONotificationPortRef notify; @@ -521,6 +524,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy tr_natTraversalEnable(fLib, 0); //remember window states and close all windows + #warning needed here? [fDefaults setBool: [[fInfoController window] isVisible] forKey: @"InfoVisible"]; [[NSApp windows] makeObjectsPerformSelector: @selector(close)]; [self showStatusBar: NO animate: NO]; @@ -2005,30 +2009,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy proposedRow: (int) row proposedDropOperation: (NSTableViewDropOperation) operation { NSPasteboard * pasteboard = [info draggingPasteboard]; - if ([[pasteboard types] containsObject: NSFilenamesPboardType]) - { - //check if any files can be added - NSEnumerator * enumerator = [[pasteboard propertyListForType: NSFilenamesPboardType] objectEnumerator]; - NSString * file; - while ((file = [enumerator nextObject])) - { - tr_torrent_t * tempTor; - int error; - if ((tempTor = tr_torrentInit(fLib, [file UTF8String], NULL, 0, &error))) - { - tr_torrentClose(fLib, tempTor); - - [fTableView setDropRow: -1 dropOperation: NSTableViewDropOn]; - return NSDragOperationGeneric; - } - } - } - else if ([[pasteboard types] containsObject: NSURLPboardType]) - { - [fTableView setDropRow: -1 dropOperation: NSTableViewDropOn]; - return NSDragOperationGeneric; - } - else if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE]) + if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE]) { [fTableView setDropRow: row dropOperation: NSTableViewDropAbove]; return NSDragOperationGeneric; @@ -2042,33 +2023,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy row: (int) newRow dropOperation: (NSTableViewDropOperation) operation { NSPasteboard * pasteboard = [info draggingPasteboard]; - if ([[pasteboard types] containsObject: NSFilenamesPboardType]) - { - //create an array of files that can be opened - NSMutableArray * filesToOpen = [[NSMutableArray alloc] init]; - NSEnumerator * enumerator = [[pasteboard propertyListForType: NSFilenamesPboardType] objectEnumerator]; - NSString * file; - while ((file = [enumerator nextObject])) - { - tr_torrent_t * tempTor; - int error; - if ((tempTor = tr_torrentInit(fLib, [file UTF8String], NULL, 0, &error))) - { - tr_torrentClose(fLib, tempTor); - [filesToOpen addObject: file]; - } - } - - [self application: NSApp openFiles: filesToOpen]; - [filesToOpen release]; - } - else if ([[pasteboard types] containsObject: NSURLPboardType]) - { - NSURL * url; - if ((url = [NSURL URLFromPasteboard: pasteboard])) - [self openURL: url]; - } - else if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE]) + if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE]) { //remember selected rows if needed NSArray * selectedTorrents = nil; @@ -2130,6 +2085,87 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [fInfoController updateInfoForTorrents: [fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]]]; } +- (NSDragOperation) draggingEntered: (id ) info +{ + NSPasteboard * pasteboard = [info draggingPasteboard]; + if ([[pasteboard types] containsObject: NSFilenamesPboardType]) + { + //check if any files can be added + NSEnumerator * enumerator = [[pasteboard propertyListForType: NSFilenamesPboardType] objectEnumerator]; + NSString * file; + while ((file = [enumerator nextObject])) + { + tr_torrent_t * tempTor; + int error; + if ((tempTor = tr_torrentInit(fLib, [file UTF8String], NULL, 0, &error))) + { + tr_torrentClose(fLib, tempTor); + + [fOverlayWindow setFrame: [fWindow frame] display: YES]; + [fOverlayWindow orderWindow: NSWindowAbove relativeTo: [fWindow windowNumber]]; + + return NSDragOperationGeneric; + } + } + } + else if ([[pasteboard types] containsObject: NSURLPboardType]) + { + [fOverlayWindow setFrame: [fWindow frame] display: YES]; + [fOverlayWindow orderWindow: NSWindowAbove relativeTo: [fWindow windowNumber]]; + + return NSDragOperationGeneric; + } + else; + + return NSDragOperationNone; +} + +- (void) draggingExited: (id ) sender +{ + [fOverlayWindow close]; +} + +- (BOOL) performDragOperation: (id ) info +{ + [fOverlayWindow close]; + + NSPasteboard * pasteboard = [info draggingPasteboard]; + if ([[pasteboard types] containsObject: NSFilenamesPboardType]) + { + //create an array of files that can be opened + NSMutableArray * filesToOpen = [[NSMutableArray alloc] init]; + NSEnumerator * enumerator = [[pasteboard propertyListForType: NSFilenamesPboardType] objectEnumerator]; + NSString * file; + while ((file = [enumerator nextObject])) + { + tr_torrent_t * tempTor; + int error; + if ((tempTor = tr_torrentInit(fLib, [file UTF8String], NULL, 0, &error))) + { + tr_torrentClose(fLib, tempTor); + [filesToOpen addObject: file]; + } + } + + [self application: NSApp openFiles: filesToOpen]; + [filesToOpen release]; + + return YES; + } + else if ([[pasteboard types] containsObject: NSURLPboardType]) + { + NSURL * url; + if ((url = [NSURL URLFromPasteboard: pasteboard])) + { + [self openURL: url]; + return YES; + } + } + else; + + return NO; +} + - (void) toggleSmallView: (id) sender { BOOL makeSmall = [fDefaults boolForKey: @"SmallView"]; diff --git a/macosx/DragOverlayWindow.h b/macosx/DragOverlayWindow.h new file mode 100644 index 000000000..c1a0e32e6 --- /dev/null +++ b/macosx/DragOverlayWindow.h @@ -0,0 +1,31 @@ +/****************************************************************************** + * $Id$ + * + * Copyright (c) 2007 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 + +@interface DragOverlayWindow : NSWindow +{ +} + +@end diff --git a/macosx/DragOverlayWindow.m b/macosx/DragOverlayWindow.m new file mode 100644 index 000000000..7024f9306 --- /dev/null +++ b/macosx/DragOverlayWindow.m @@ -0,0 +1,46 @@ +/****************************************************************************** + * $Id$ + * + * Copyright (c) 2007 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 "DragOverlayWindow.h" + +@implementation DragOverlayWindow + +- (id) init +{ + if (self = ([super initWithContentRect: NSMakeRect(0, 0, 0, 0) styleMask: NSBorderlessWindowMask + backing: NSBackingStoreBuffered defer: NO])) + { + [self setBackgroundColor: [NSColor blackColor]]; + [self setLevel: NSStatusWindowLevel]; + [self setAlphaValue: 0.5]; + [self setOpaque: NO]; + [self setHasShadow: NO]; + + [self setReleasedWhenClosed: NO]; + [self setIgnoresMouseEvents: YES]; + } + return self; +} + +@end diff --git a/macosx/English.lproj/MainMenu.nib/info.nib b/macosx/English.lproj/MainMenu.nib/info.nib index d442e30fb..6c2d65a5c 100644 --- a/macosx/English.lproj/MainMenu.nib/info.nib +++ b/macosx/English.lproj/MainMenu.nib/info.nib @@ -32,7 +32,7 @@ IBOpenObjects 29 - 1041 + 21 IBSystem Version 8P135 diff --git a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib index edde5575f..4cc3774e6 100644 Binary files a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib and b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib differ