1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-04 02:28:03 +00:00

#2370 On 10.6, revaling files in Finder will select multiple files in the same directory

This commit is contained in:
Mitchell Livingston 2009-08-30 17:50:05 +00:00
parent a32cdcc255
commit 912d76dee4
5 changed files with 49 additions and 13 deletions

View file

@ -43,6 +43,7 @@
#import "StatusBarView.h" #import "StatusBarView.h"
#import "FilterButton.h" #import "FilterButton.h"
#import "BonjourController.h" #import "BonjourController.h"
#import "NSApplicationAdditions.h"
#import "NSStringAdditions.h" #import "NSStringAdditions.h"
#import "ExpandedPathToPathTransformer.h" #import "ExpandedPathToPathTransformer.h"
#import "ExpandedPathToIconTransformer.h" #import "ExpandedPathToIconTransformer.h"
@ -1409,8 +1410,20 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
- (void) revealFile: (id) sender - (void) revealFile: (id) sender
{ {
for (Torrent * torrent in [fTableView selectedTorrents]) NSArray * selected = [fTableView selectedTorrents];
[torrent revealData]; if ([NSApp isOnSnowLeopardOrBetter])
{
NSMutableArray * paths = [NSMutableArray arrayWithCapacity: [selected count]];
for (Torrent * torrent in [fTableView selectedTorrents])
[paths addObject: [NSURL fileURLWithPath: [torrent dataLocation]]];
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: paths];
}
else
{
for (Torrent * torrent in selected)
[[NSWorkspace sharedWorkspace] selectFile: [torrent dataLocation] inFileViewerRootedAtPath: nil];
}
} }
- (void) announceSelectedTorrents: (id) sender - (void) announceSelectedTorrents: (id) sender
@ -4057,7 +4070,15 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
NSString * type = [clickContext objectForKey: @"Type"], * location; NSString * type = [clickContext objectForKey: @"Type"], * location;
if (([type isEqualToString: GROWL_DOWNLOAD_COMPLETE] || [type isEqualToString: GROWL_SEEDING_COMPLETE]) if (([type isEqualToString: GROWL_DOWNLOAD_COMPLETE] || [type isEqualToString: GROWL_SEEDING_COMPLETE])
&& (location = [clickContext objectForKey: @"Location"])) && (location = [clickContext objectForKey: @"Location"]))
[[NSWorkspace sharedWorkspace] selectFile: location inFileViewerRootedAtPath: nil]; {
if ([NSApp isOnSnowLeopardOrBetter])
{
NSURL * file = [NSURL fileURLWithPath: location];
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: [NSArray arrayWithObject: file]];
}
else
[[NSWorkspace sharedWorkspace] selectFile: location inFileViewerRootedAtPath: nil];
}
} }
- (void) rpcCallback: (tr_rpc_callback_type) type forTorrentStruct: (struct tr_torrent *) torrentStruct - (void) rpcCallback: (tr_rpc_callback_type) type forTorrentStruct: (struct tr_torrent *) torrentStruct

View file

@ -27,6 +27,7 @@
#import "FileOutlineView.h" #import "FileOutlineView.h"
#import "FilePriorityCell.h" #import "FilePriorityCell.h"
#import "FileListNode.h" #import "FileListNode.h"
#import "NSApplicationAdditions.h"
#import "QuickLookController.h" #import "QuickLookController.h"
#define ROW_SMALL_HEIGHT 18.0 #define ROW_SMALL_HEIGHT 18.0
@ -313,9 +314,20 @@ typedef enum
{ {
NSString * folder = [fTorrent downloadFolder]; NSString * folder = [fTorrent downloadFolder];
NSIndexSet * indexes = [fOutline selectedRowIndexes]; NSIndexSet * indexes = [fOutline selectedRowIndexes];
for (NSInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i]) if ([NSApp isOnSnowLeopardOrBetter])
[[NSWorkspace sharedWorkspace] selectFile: [folder stringByAppendingPathComponent: {
[[fOutline itemAtRow: i] fullPath]] inFileViewerRootedAtPath: nil]; NSMutableArray * paths = [NSMutableArray arrayWithCapacity: [indexes count]];
for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
[paths addObject: [NSURL fileURLWithPath: [folder stringByAppendingPathComponent: [[fOutline itemAtRow: i] fullPath]]]];
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: paths];
}
else
{
for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
[[NSWorkspace sharedWorkspace] selectFile: [folder stringByAppendingPathComponent: [[fOutline itemAtRow: i] fullPath]]
inFileViewerRootedAtPath: nil];
}
} }
#warning make real view controller (Leopard-only) so that Command-R will work #warning make real view controller (Leopard-only) so that Command-R will work

View file

@ -1178,7 +1178,16 @@ typedef enum
- (void) revealDataFile: (id) sender - (void) revealDataFile: (id) sender
{ {
if ([fTorrents count] > 0) if ([fTorrents count] > 0)
[[fTorrents objectAtIndex: 0] revealData]; {
Torrent * torrent = [fTorrents objectAtIndex: 0];
if ([NSApp isOnSnowLeopardOrBetter])
{
NSURL * file = [NSURL fileURLWithPath: [torrent dataLocation]];
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: [NSArray arrayWithObject: file]];
}
else
[[NSWorkspace sharedWorkspace] selectFile: [torrent dataLocation] inFileViewerRootedAtPath: nil];
}
} }
- (void) setFileFilterText: (id) sender - (void) setFileFilterText: (id) sender

View file

@ -116,7 +116,6 @@
- (tr_priority_t) priority; - (tr_priority_t) priority;
- (void) setPriority: (tr_priority_t) priority; - (void) setPriority: (tr_priority_t) priority;
- (void) revealData;
+ (void) trashFile: (NSString *) path; + (void) trashFile: (NSString *) path;
- (void) trashData; - (void) trashData;
- (void) moveTorrentDataFileTo: (NSString *) folder; - (void) moveTorrentDataFileTo: (NSString *) folder;

View file

@ -436,11 +436,6 @@ int trashDataFile(const char * filename)
return tr_torrentSetPriority(fHandle, priority); return tr_torrentSetPriority(fHandle, priority);
} }
- (void) revealData
{
[[NSWorkspace sharedWorkspace] selectFile: [self dataLocation] inFileViewerRootedAtPath: nil];
}
#warning should be somewhere else? #warning should be somewhere else?
+ (void) trashFile: (NSString *) path + (void) trashFile: (NSString *) path
{ {