mirror of
https://github.com/transmission/transmission
synced 2025-02-20 13:16:53 +00:00
make consecutive move sheets show correctly
This commit is contained in:
parent
a3ca76cced
commit
8f918ad819
6 changed files with 68 additions and 54 deletions
|
@ -134,11 +134,10 @@
|
|||
- (void) removeDeleteDataAndTorrent: (id) sender;
|
||||
|
||||
- (void) moveDataFiles: (id) sender;
|
||||
- (void) moveDataFileForTorrents: (NSMutableArray *) torrents;
|
||||
|
||||
- (void) copyTorrentFile: (id) sender;
|
||||
- (void) copyTorrentFiles: (id) sender;
|
||||
- (void) copyTorrentFileForTorrents: (NSMutableArray *) torrents;
|
||||
- (void) saveTorrentCopySheetClosed: (NSSavePanel *) panel returnCode: (int) code
|
||||
contextInfo: (NSMutableArray *) torrents;
|
||||
|
||||
- (void) revealFile: (id) sender;
|
||||
|
||||
|
|
|
@ -1136,14 +1136,46 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
- (void) moveDataFiles: (id) sender
|
||||
{
|
||||
NSEnumerator * enumerator = [[fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]] objectEnumerator];
|
||||
Torrent * torrent;
|
||||
while ((torrent = [enumerator nextObject]))
|
||||
[torrent moveTorrent];
|
||||
[self moveDataFileForTorrents: [[NSMutableArray alloc] initWithArray:
|
||||
[fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]]]];
|
||||
}
|
||||
|
||||
#warning move to Torrent
|
||||
- (void) copyTorrentFile: (id) sender
|
||||
- (void) moveDataFileForTorrents: (NSMutableArray *) torrents
|
||||
{
|
||||
if ([torrents count] <= 0)
|
||||
{
|
||||
[torrents release];
|
||||
return;
|
||||
}
|
||||
|
||||
Torrent * torrent = [torrents objectAtIndex: 0];
|
||||
|
||||
NSOpenPanel * panel = [NSOpenPanel openPanel];
|
||||
|
||||
[panel setPrompt: NSLocalizedString(@"Select", "Move torrent -> prompt")];
|
||||
[panel setAllowsMultipleSelection: NO];
|
||||
[panel setCanChooseFiles: NO];
|
||||
[panel setCanChooseDirectories: YES];
|
||||
[panel setCanCreateDirectories: YES];
|
||||
|
||||
[panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the new folder for \"%@\"",
|
||||
"Move torrent -> select destination folder"), [torrent name]]];
|
||||
|
||||
[panel beginSheetForDirectory: nil file: [torrent name] modalForWindow: fWindow modalDelegate: self
|
||||
didEndSelector: @selector(moveDataFileChoiceClosed:returnCode:contextInfo:) contextInfo: torrents];
|
||||
}
|
||||
|
||||
- (void) moveDataFileChoiceClosed: (NSOpenPanel *) panel returnCode: (int) code contextInfo: (NSMutableArray *) torrents
|
||||
{
|
||||
//move torrent data file to new location
|
||||
if (code == NSOKButton)
|
||||
[[torrents objectAtIndex: 0] moveTorrentDataFileTo: [[panel filenames] objectAtIndex: 0]];
|
||||
|
||||
[torrents removeObjectAtIndex: 0];
|
||||
[self performSelectorOnMainThread: @selector(moveDataFileForTorrents:) withObject: torrents waitUntilDone: NO];
|
||||
}
|
||||
|
||||
- (void) copyTorrentFiles: (id) sender
|
||||
{
|
||||
[self copyTorrentFileForTorrents: [[NSMutableArray alloc] initWithArray:
|
||||
[fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]]]];
|
||||
|
@ -1151,7 +1183,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
- (void) copyTorrentFileForTorrents: (NSMutableArray *) torrents
|
||||
{
|
||||
if ([torrents count] == 0)
|
||||
if ([torrents count] <= 0)
|
||||
{
|
||||
[torrents release];
|
||||
return;
|
||||
|
@ -1190,10 +1222,9 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
- (void) saveTorrentCopySheetClosed: (NSSavePanel *) panel returnCode: (int) code contextInfo: (NSMutableArray *) torrents
|
||||
{
|
||||
//if save successful, copy torrent to new location with name of data file
|
||||
//copy torrent to new location with name of data file
|
||||
if (code == NSOKButton)
|
||||
[[NSFileManager defaultManager] copyPath: [[torrents objectAtIndex: 0] torrentLocation]
|
||||
toPath: [panel filename] handler: nil];
|
||||
[[torrents objectAtIndex: 0] copyTorrentFileTo: [panel filename]];
|
||||
|
||||
[torrents removeObjectAtIndex: 0];
|
||||
[self performSelectorOnMainThread: @selector(copyTorrentFileForTorrents:) withObject: torrents waitUntilDone: NO];
|
||||
|
@ -2672,7 +2703,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
return canUseTable && [fTableView numberOfSelectedRows] > 0;
|
||||
|
||||
//enable copy torrent file item
|
||||
if (action == @selector(copyTorrentFile:))
|
||||
if (action == @selector(copyTorrentFiles:))
|
||||
return canUseTable && [fTableView numberOfSelectedRows] > 0;
|
||||
|
||||
//enable reverse sort item
|
||||
|
|
2
macosx/English.lproj/MainMenu.nib/classes.nib
generated
2
macosx/English.lproj/MainMenu.nib/classes.nib
generated
|
@ -7,7 +7,7 @@
|
|||
announceSelectedTorrents = id;
|
||||
applyFilter = id;
|
||||
applySpeedLimit = id;
|
||||
copyTorrentFile = id;
|
||||
copyTorrentFiles = id;
|
||||
doNothing = id;
|
||||
linkForums = id;
|
||||
linkHomepage = id;
|
||||
|
|
BIN
macosx/English.lproj/MainMenu.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/MainMenu.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -115,7 +115,8 @@
|
|||
- (void) revealPublicTorrent;
|
||||
- (void) trashData;
|
||||
- (void) trashTorrent;
|
||||
- (void) moveTorrent;
|
||||
- (void) moveTorrentDataFileTo: (NSString *) folder;
|
||||
- (void) copyTorrentFileTo: (NSString *) path;
|
||||
|
||||
- (BOOL) alertForRemainingDiskSpace;
|
||||
- (BOOL) alertForFolderAvailable;
|
||||
|
|
|
@ -691,58 +691,41 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
[self trashFile: [self publicTorrentLocation]];
|
||||
}
|
||||
|
||||
- (void) moveTorrent
|
||||
- (void) moveTorrentDataFileTo: (NSString *) folder
|
||||
{
|
||||
NSOpenPanel * panel = [NSOpenPanel openPanel];
|
||||
|
||||
[panel setPrompt: NSLocalizedString(@"Select", "Move torrent -> prompt")];
|
||||
[panel setAllowsMultipleSelection: NO];
|
||||
[panel setCanChooseFiles: NO];
|
||||
[panel setCanChooseDirectories: YES];
|
||||
[panel setCanCreateDirectories: YES];
|
||||
|
||||
[panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the new folder for \"%@\"",
|
||||
"Move torrent -> select destination folder"), [self name]]];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"MakeWindowKey" object: nil];
|
||||
[panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: [NSApp keyWindow] modalDelegate: self
|
||||
didEndSelector: @selector(moveTorrentChoiceClosed:returnCode:contextInfo:) contextInfo: nil];
|
||||
}
|
||||
|
||||
- (void) moveTorrentChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) context
|
||||
{
|
||||
if (code != NSOKButton)
|
||||
return;
|
||||
|
||||
NSString * folder = [[openPanel filenames] objectAtIndex: 0];
|
||||
if (![[self downloadFolder] isEqualToString: folder] || ![fDownloadFolder isEqualToString: folder])
|
||||
{
|
||||
//pause without actually stopping
|
||||
tr_setDownloadLimit(fHandle, 0);
|
||||
tr_setUploadLimit(fHandle, 0);
|
||||
|
||||
if ([[NSFileManager defaultManager] movePath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]
|
||||
toPath: [folder stringByAppendingPathComponent: [self name]] handler: nil])
|
||||
#warning check if moving inside itself
|
||||
[[NSFileManager defaultManager] movePath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]
|
||||
toPath: [folder stringByAppendingPathComponent: [self name]] handler: nil];
|
||||
|
||||
//get rid of both incomplete folder and old download folder, even if move failed
|
||||
fUseIncompleteFolder = NO;
|
||||
if (fIncompleteFolder)
|
||||
{
|
||||
//get rid of both incomplete folder and download folder
|
||||
fUseIncompleteFolder = NO;
|
||||
if (fIncompleteFolder)
|
||||
{
|
||||
[fIncompleteFolder release];
|
||||
fIncompleteFolder = nil;
|
||||
}
|
||||
[fDownloadFolder release];
|
||||
fDownloadFolder = [folder retain];
|
||||
|
||||
tr_torrentSetFolder(fHandle, [fDownloadFolder UTF8String]);
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateInfoSettings" object: nil];
|
||||
[fIncompleteFolder release];
|
||||
fIncompleteFolder = nil;
|
||||
}
|
||||
[fDownloadFolder release];
|
||||
fDownloadFolder = [folder retain];
|
||||
|
||||
tr_torrentSetFolder(fHandle, [fDownloadFolder UTF8String]);
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateInfoSettings" object: nil];
|
||||
|
||||
[self updateSpeedSetting];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) copyTorrentFileTo: (NSString *) path
|
||||
{
|
||||
[[NSFileManager defaultManager] copyPath: [self torrentLocation] toPath: path handler: nil];
|
||||
}
|
||||
|
||||
- (BOOL) alertForRemainingDiskSpace
|
||||
{
|
||||
if ([self allDownloaded] || ![fDefaults boolForKey: @"WarningRemainingSpace"])
|
||||
|
|
Loading…
Reference in a new issue