From f36d558ad438aef7a6ef7b97948bfe0994928523 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Mon, 25 Jun 2007 22:26:33 +0000 Subject: [PATCH] fix #233 (move menu item applies to all items) --- macosx/Controller.h | 2 +- macosx/Controller.m | 43 ++++++++++++++++------------------- macosx/InfoWindowController.m | 2 +- macosx/Torrent.m | 6 ++--- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/macosx/Controller.h b/macosx/Controller.h index c097a5a15..47408afe1 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -144,7 +144,7 @@ - (void) removeDeleteDataAndTorrent: (id) sender; - (void) moveDataFiles: (id) sender; -- (void) moveDataFileForTorrents: (NSMutableArray *) torrents; +- (void) moveDataFileChoiceClosed: (NSOpenPanel *) panel returnCode: (int) code contextInfo: (NSArray *) torrents; - (void) copyTorrentFiles: (id) sender; - (void) copyTorrentFileForTorrents: (NSMutableArray *) torrents; diff --git a/macosx/Controller.m b/macosx/Controller.m index 69fc2c54e..29c0a4650 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1183,43 +1183,38 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy - (void) moveDataFiles: (id) sender { - [self moveDataFileForTorrents: [[NSMutableArray alloc] initWithArray: - [fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]]]]; -} - -- (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]]]; + + NSArray * torrents = [[fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]] retain]; + int count = [torrents count]; + if (count == 1) + [panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the new folder for \"%@\".", + "Move torrent -> select destination folder"), [[torrents objectAtIndex: 0] name]]]; + else + [panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the new folder for %d data files.", + "Move torrent -> select destination folder"), count]]; - [panel beginSheetForDirectory: nil file: [torrent name] modalForWindow: fWindow modalDelegate: self + [panel beginSheetForDirectory: nil file: nil modalForWindow: fWindow modalDelegate: self didEndSelector: @selector(moveDataFileChoiceClosed:returnCode:contextInfo:) contextInfo: torrents]; } -- (void) moveDataFileChoiceClosed: (NSOpenPanel *) panel returnCode: (int) code contextInfo: (NSMutableArray *) torrents +- (void) moveDataFileChoiceClosed: (NSOpenPanel *) panel returnCode: (int) code contextInfo: (NSArray *) torrents { - //move torrent data file to new location if (code == NSOKButton) - [[torrents objectAtIndex: 0] moveTorrentDataFileTo: [[panel filenames] objectAtIndex: 0]]; + { + //move torrent data file to new location + NSEnumerator * enumerator = [torrents objectEnumerator]; + Torrent * torrent; + while ((torrent = [enumerator nextObject])) + [torrent moveTorrentDataFileTo: [[panel filenames] objectAtIndex: 0]]; + } - [torrents removeObjectAtIndex: 0]; - [self performSelectorOnMainThread: @selector(moveDataFileForTorrents:) withObject: torrents waitUntilDone: NO]; + [torrents release]; } - (void) copyTorrentFiles: (id) sender diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index 9b81b7724..ff071e98d 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -887,7 +887,7 @@ { NSString * identifier = [tableColumn identifier]; if ([identifier isEqualToString: @"Check"]) - { + { Torrent * torrent = [fTorrents objectAtIndex: 0]; [torrent setFileCheckState: [object intValue] != NSOffState ? NSOnState : NSOffState forIndexes: [item objectForKey: @"Indexes"]]; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index ca968c1de..c76b7f899 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -797,11 +797,11 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 { NSAlert * alert = [[NSAlert alloc] init]; [alert setMessageText: NSLocalizedString(@"A folder cannot be moved to inside itself.", - "Move inside iteself alert -> title")]; + "Move inside itself alert -> title")]; [alert setInformativeText: [NSString stringWithFormat: NSLocalizedString(@"The move operation of \"%@\" cannot be done.", - "Move inside iteself alert -> message"), [self name]]]; - [alert addButtonWithTitle: NSLocalizedString(@"OK", "Move inside iteself alert -> button")]; + "Move inside itself alert -> message"), [self name]]]; + [alert addButtonWithTitle: NSLocalizedString(@"OK", "Move inside itself alert -> button")]; [alert runModal]; [alert release];