mirror of
https://github.com/transmission/transmission.git
synced 2025-12-23 20:08:43 +00:00
fixed problem when opening multiple torrents at once when "always ask" was enabled
also, don't add files to the recently opened menu unless it actually is added
This commit is contained in:
@@ -670,8 +670,11 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||||||
[self performSelectorOnMainThread: @selector(openFilesWithDict:) withObject: dictionary waitUntilDone: NO];
|
[self performSelectorOnMainThread: @selector(openFilesWithDict:) withObject: dictionary waitUntilDone: NO];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
[[dictionary objectForKey: @"Filenames"] release];
|
||||||
[dictionary release];
|
[dictionary release];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void) openFilesWithDict: (NSDictionary *) dictionary
|
- (void) openFilesWithDict: (NSDictionary *) dictionary
|
||||||
{
|
{
|
||||||
@@ -686,12 +689,13 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||||||
- (void) openFilesAsk: (NSMutableArray *) files forceDeleteTorrent: (BOOL) delete
|
- (void) openFilesAsk: (NSMutableArray *) files forceDeleteTorrent: (BOOL) delete
|
||||||
{
|
{
|
||||||
NSString * torrentPath;
|
NSString * torrentPath;
|
||||||
Torrent * torrent;
|
tr_torrent_t * tempTor;
|
||||||
|
int error;
|
||||||
|
|
||||||
//determine next file that can be opened
|
//determine next file that can be opened
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if ([files count] == 0) //recursive base case
|
if ([files count] == 0) //no files left to open
|
||||||
{
|
{
|
||||||
[files release];
|
[files release];
|
||||||
|
|
||||||
@@ -699,14 +703,11 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
torrentPath = [files objectAtIndex: 0];
|
torrentPath = [[files objectAtIndex: 0] retain];
|
||||||
torrent = [[Torrent alloc] initWithPath: torrentPath forceDeleteTorrent: delete lib: fLib];
|
tempTor = tr_torrentInit(fLib, [torrentPath UTF8String], 0, &error);
|
||||||
|
|
||||||
[files removeObjectAtIndex: 0];
|
[files removeObjectAtIndex: 0];
|
||||||
} while (!torrent);
|
} while (!tempTor);
|
||||||
|
|
||||||
//add it to the "File > Open Recent" menu
|
|
||||||
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
|
|
||||||
|
|
||||||
NSOpenPanel * panel = [NSOpenPanel openPanel];
|
NSOpenPanel * panel = [NSOpenPanel openPanel];
|
||||||
|
|
||||||
@@ -716,26 +717,34 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||||||
[panel setCanChooseDirectories: YES];
|
[panel setCanChooseDirectories: YES];
|
||||||
|
|
||||||
[panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the download folder for \"%@\"",
|
[panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the download folder for \"%@\"",
|
||||||
"Open torrent -> select destination folder"), [torrent name]]];
|
"Open torrent -> select destination folder"),
|
||||||
|
[NSString stringWithUTF8String: tr_torrentInfo(tempTor)->name]]];
|
||||||
|
|
||||||
NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: torrent, @"Torrent", files, @"Files",
|
NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: torrentPath, @"Path",
|
||||||
[NSNumber numberWithBool: delete], @"Delete", nil];
|
files, @"Files", [NSNumber numberWithBool: delete], @"Delete", nil];
|
||||||
|
[torrentPath release];
|
||||||
|
|
||||||
|
tr_torrentClose(fLib, tempTor);
|
||||||
[panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
|
[panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
|
||||||
didEndSelector: @selector(folderChoiceClosed:returnCode:contextInfo:) contextInfo: dictionary];
|
didEndSelector: @selector(folderChoiceClosed:returnCode:contextInfo:) contextInfo: dictionary];
|
||||||
[torrent release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (NSDictionary *) dictionary
|
- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (NSDictionary *) dictionary
|
||||||
{
|
{
|
||||||
Torrent * torrent = [dictionary objectForKey: @"Torrent"];
|
|
||||||
|
|
||||||
if (code == NSOKButton)
|
if (code == NSOKButton)
|
||||||
{
|
{
|
||||||
|
NSString * torrentPath = [dictionary objectForKey: @"Path"];
|
||||||
|
Torrent * torrent = [[Torrent alloc] initWithPath: torrentPath forceDeleteTorrent:
|
||||||
|
[[dictionary objectForKey: @"Delete"] boolValue] lib: fLib];
|
||||||
|
|
||||||
|
//add it to the "File > Open Recent" menu
|
||||||
|
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
|
||||||
|
|
||||||
[torrent setDownloadFolder: [[openPanel filenames] objectAtIndex: 0]];
|
[torrent setDownloadFolder: [[openPanel filenames] objectAtIndex: 0]];
|
||||||
[torrent update];
|
[torrent update];
|
||||||
|
|
||||||
[fTorrents addObject: torrent];
|
[fTorrents addObject: torrent];
|
||||||
|
[torrent release];
|
||||||
|
|
||||||
[self updateTorrentsInQueue];
|
[self updateTorrentsInQueue];
|
||||||
}
|
}
|
||||||
@@ -1995,24 +2004,20 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||||||
|
|
||||||
- (NSRect) windowFrameByAddingHeight: (float) height checkLimits: (BOOL) check
|
- (NSRect) windowFrameByAddingHeight: (float) height checkLimits: (BOOL) check
|
||||||
{
|
{
|
||||||
|
//convert pixels to points
|
||||||
NSRect windowFrame = [fWindow frame];
|
NSRect windowFrame = [fWindow frame];
|
||||||
NSSize windowSize = windowFrame.size;
|
NSSize windowSize = [fScrollView convertSize: windowFrame.size fromView: nil];
|
||||||
NSSize minSize = [fWindow minSize];
|
|
||||||
NSSize maxSize = [[fWindow screen] visibleFrame].size;
|
|
||||||
|
|
||||||
/* Convert pixels to points */
|
|
||||||
windowSize = [fScrollView convertSize: windowSize fromView: nil];
|
|
||||||
minSize = [fScrollView convertSize: minSize fromView: nil];
|
|
||||||
maxSize = [fScrollView convertSize: maxSize fromView: nil];
|
|
||||||
|
|
||||||
windowSize.height += height;
|
windowSize.height += height;
|
||||||
|
|
||||||
if (check)
|
if (check)
|
||||||
{
|
{
|
||||||
|
NSSize minSize = [fScrollView convertSize: [fWindow minSize] fromView: nil];
|
||||||
|
|
||||||
if (windowSize.height < minSize.height)
|
if (windowSize.height < minSize.height)
|
||||||
windowSize.height = minSize.height;
|
windowSize.height = minSize.height;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
NSSize maxSize = [fScrollView convertSize: [[fWindow screen] visibleFrame].size fromView: nil];
|
||||||
if ([fStatusBar isHidden])
|
if ([fStatusBar isHidden])
|
||||||
maxSize.height -= [fStatusBar frame].size.height;
|
maxSize.height -= [fStatusBar frame].size.height;
|
||||||
if ([fFilterBar isHidden])
|
if ([fFilterBar isHidden])
|
||||||
@@ -2022,7 +2027,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert points to pixels */
|
//convert points to pixels
|
||||||
windowSize = [fScrollView convertSize: windowSize toView: nil];
|
windowSize = [fScrollView convertSize: windowSize toView: nil];
|
||||||
|
|
||||||
windowFrame.origin.y -= (windowSize.height - windowFrame.size.height);
|
windowFrame.origin.y -= (windowSize.height - windowFrame.size.height);
|
||||||
|
|||||||
Reference in New Issue
Block a user