#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 "FilterButton.h"
#import "BonjourController.h"
#import "NSApplicationAdditions.h"
#import "NSStringAdditions.h"
#import "ExpandedPathToPathTransformer.h"
#import "ExpandedPathToIconTransformer.h"
@ -1409,8 +1410,20 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
- (void) revealFile: (id) sender
{
for (Torrent * torrent in [fTableView selectedTorrents])
[torrent revealData];
NSArray * selected = [fTableView selectedTorrents];
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
@ -4057,7 +4070,15 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
NSString * type = [clickContext objectForKey: @"Type"], * location;
if (([type isEqualToString: GROWL_DOWNLOAD_COMPLETE] || [type isEqualToString: GROWL_SEEDING_COMPLETE])
&& (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

View File

@ -27,6 +27,7 @@
#import "FileOutlineView.h"
#import "FilePriorityCell.h"
#import "FileListNode.h"
#import "NSApplicationAdditions.h"
#import "QuickLookController.h"
#define ROW_SMALL_HEIGHT 18.0
@ -313,9 +314,20 @@ typedef enum
{
NSString * folder = [fTorrent downloadFolder];
NSIndexSet * indexes = [fOutline selectedRowIndexes];
for (NSInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
[[NSWorkspace sharedWorkspace] selectFile: [folder stringByAppendingPathComponent:
[[fOutline itemAtRow: i] fullPath]] inFileViewerRootedAtPath: nil];
if ([NSApp isOnSnowLeopardOrBetter])
{
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

View File

@ -1178,7 +1178,16 @@ typedef enum
- (void) revealDataFile: (id) sender
{
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

View File

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

View File

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