1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 17:47:37 +00:00

Holding down option and using the open menu item now ignores the default download location and asks where to download.

This commit is contained in:
Mitchell Livingston 2006-08-02 00:04:04 +00:00
parent 8bddde255c
commit 4b5300939c
5 changed files with 48 additions and 26 deletions

View file

@ -53,6 +53,8 @@
IBOutlet TorrentTableView * fTableView;
NSToolbar * fToolbar;
IBOutlet NSMenuItem * fOpenIgnoreDownloadFolder;
IBOutlet NSMenuItem * fAdvancedBarItem, * fSmallViewItem,
* fSpeedLimitItem, * fSpeedLimitDockItem;
IBOutlet NSButton * fActionButton, * fSpeedLimitButton;
@ -91,8 +93,9 @@
Badger * fBadger;
}
- (void) openFiles: (NSArray *) filenames;
- (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore;
- (void) openShowSheet: (id) sender;
- (void) openSheetClosed: (NSOpenPanel *) s returnCode: (int) code contextInfo: (void *) info;
- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo;

View file

@ -430,6 +430,21 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
}
}
- (NSArray *) torrentsAtIndexes: (NSIndexSet *) indexSet
{
if ([fFilteredTorrents respondsToSelector: @selector(objectsAtIndexes:)])
return [fFilteredTorrents objectsAtIndexes: indexSet];
else
{
NSMutableArray * torrents = [NSMutableArray arrayWithCapacity: [indexSet count]];
unsigned int i;
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
[torrents addObject: [fFilteredTorrents objectAtIndex: i]];
return torrents;
}
}
- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code
contextInfo: (Torrent *) torrent
{
@ -446,6 +461,11 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
}
- (void) application: (NSApplication *) sender openFiles: (NSArray *) filenames
{
[self openFiles: filenames ignoreDownloadFolder: NO];
}
- (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore
{
NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"], * torrentPath;
Torrent * torrent;
@ -459,7 +479,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[[NSDocumentController sharedDocumentController]
noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
if ([downloadChoice isEqualToString: @"Ask"])
if (ignore || [downloadChoice isEqualToString: @"Ask"])
{
NSOpenPanel * panel = [NSOpenPanel openPanel];
@ -498,25 +518,15 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[self updateTorrentHistory];
}
- (NSArray *) torrentsAtIndexes: (NSIndexSet *) indexSet
{
if ([fFilteredTorrents respondsToSelector: @selector(objectsAtIndexes:)])
return [fFilteredTorrents objectsAtIndexes: indexSet];
else
{
NSMutableArray * torrents = [NSMutableArray arrayWithCapacity: [indexSet count]];
unsigned int i;
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
[torrents addObject: [fFilteredTorrents objectAtIndex: i]];
return torrents;
}
}
//called on by applescript
- (void) open: (NSArray *) files
{
[self performSelectorOnMainThread: @selector(openFromSheet:) withObject: files waitUntilDone: NO];
[self performSelectorOnMainThread: @selector(openFiles:) withObject: files waitUntilDone: NO];
}
- (void) openFiles: (NSArray *) filenames
{
[self openFiles: filenames ignoreDownloadFolder: NO];
}
- (void) openShowSheet: (id) sender
@ -529,18 +539,26 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[panel beginSheetForDirectory: nil file: nil types: [NSArray arrayWithObject: @"torrent"]
modalForWindow: fWindow modalDelegate: self didEndSelector:
@selector(openSheetClosed:returnCode:contextInfo:) contextInfo: nil];
@selector(openSheetClosed:returnCode:contextInfo:)
contextInfo: [NSNumber numberWithBool: sender == fOpenIgnoreDownloadFolder]];
}
- (void) openSheetClosed: (NSOpenPanel *) panel returnCode: (int) code contextInfo: (void *) info
- (void) openSheetClosed: (NSOpenPanel *) panel returnCode: (int) code contextInfo: (NSNumber *) ignore
{
if (code == NSOKButton)
[self performSelectorOnMainThread: @selector(openFromSheet:) withObject: [panel filenames] waitUntilDone: NO];
{
NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:
[panel filenames], @"Files", ignore, @"Ignore", nil];
[self performSelectorOnMainThread: @selector(openFromSheet:) withObject: dictionary waitUntilDone: NO];
}
}
- (void) openFromSheet: (NSArray *) filenames
- (void) openFromSheet: (NSDictionary *) dictionary
{
[self application: NSApp openFiles: filenames];
[self openFiles: [dictionary objectForKey: @"Files"]
ignoreDownloadFolder: [[dictionary objectForKey: @"Ignore"] boolValue]];
[dictionary release];
}
- (void) resumeSelectedTorrents: (id) sender
@ -1430,7 +1448,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame)
{
oldCount = [fTorrents count];
[self openFromSheet: [NSArray arrayWithObject: [path stringByAppendingPathComponent: file]]];
[self openFiles: [NSArray arrayWithObject: [path stringByAppendingPathComponent: file]]];
//import only actually happened if the torrent array is larger
if (oldCount < [fTorrents count])

View file

@ -51,6 +51,7 @@
fNameSortItem = NSMenuItem;
fNextInfoTabItem = NSMenuItem;
fNoFilterButton = BarButton;
fOpenIgnoreDownloadFolder = NSMenuItem;
fOrderSortActionItem = NSMenuItem;
fOrderSortItem = NSMenuItem;
fPauseFilterButton = BarButton;

View file

@ -13,7 +13,7 @@
<key>1603</key>
<string>337 545 477 67 0 0 1152 842 </string>
<key>29</key>
<string>207 725 451 44 0 0 1152 842 </string>
<string>227 675 451 44 0 0 1152 842 </string>
<key>456</key>
<string>396 374 216 206 0 0 1152 842 </string>
<key>581</key>

Binary file not shown.