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

when using the Add window, if the destination and the data have the same name, give a warning stating this (should help avoid the "why can't i seed if i set the destination to the data" problems)

This commit is contained in:
Mitchell Livingston 2008-01-11 19:54:08 +00:00
parent 90f5c61327
commit 8ebe4614b2
3 changed files with 56 additions and 11 deletions

View file

@ -27,17 +27,22 @@
#import "GroupsWindowController.h"
#import "NSStringAdditions.h"
#import "NSMenuAdditions.h"
#import "NSApplicationAdditions.h"
#import "ExpandedPathToIconTransformer.h"
#define UPDATE_SECONDS 1.0
@interface AddWindowController (Private)
- (void) confirmAdd;
- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) contextInfo;
- (void) setGroupsMenu;
- (void) changeGroupValue: (id) sender;
- (void) sameNameAlertDidEnd: (NSAlert *) alert returnCode: (int) returnCode contextInfo: (void *) contextInfo;
@end
@implementation AddWindowController
@ -162,17 +167,28 @@
- (void) add: (id) sender
{
[fTimer invalidate];
fTimer = nil;
if ([[fDestination lastPathComponent] isEqualToString: [fTorrent name]]
&& [[NSUserDefaults standardUserDefaults] boolForKey: @"WarningFolderDataSameName"])
{
NSAlert * alert = [[NSAlert alloc] init];
[alert setMessageText: NSLocalizedString(@"The destination directory and root data directory have the same name.",
"Add torrent -> same name -> title")];
[alert setInformativeText: NSLocalizedString(@"If you are attempting to use already existing data,"
" the root data directory should be inside the destination directory.", "Add torrent -> same name -> message")];
[alert setAlertStyle: NSWarningAlertStyle];
[alert addButtonWithTitle: NSLocalizedString(@"Cancel", "Add torrent -> same name -> button")];
[alert addButtonWithTitle: NSLocalizedString(@"Add", "Add torrent -> same name -> button")];
[fTorrent setWaitToStart: [fStartCheck state] == NSOnState];
[fTorrent setGroupValue: [[fGroupPopUp selectedItem] tag]];
if ([NSApp isOnLeopardOrBetter])
[alert setShowsSuppressionButton: YES];
else
[alert addButtonWithTitle: NSLocalizedString(@"Don't Alert Again", "Add torrent -> same name -> button")];
if ([fDeleteCheck state] == NSOnState)
[fTorrent trashTorrent];
//ensure last, since it releases this controller
[fController askOpenConfirmed: self add: YES];
[alert beginSheetModalForWindow: [self window] modalDelegate: self
didEndSelector: @selector(sameNameAlertDidEnd:returnCode:contextInfo:) contextInfo: nil];
}
else
[self confirmAdd];
}
- (void) cancelAdd: (id) sender
@ -214,6 +230,21 @@
@implementation AddWindowController (Private)
- (void) confirmAdd
{
[fTimer invalidate];
fTimer = nil;
[fTorrent setWaitToStart: [fStartCheck state] == NSOnState];
[fTorrent setGroupValue: [[fGroupPopUp selectedItem] tag]];
if ([fDeleteCheck state] == NSOnState)
[fTorrent trashTorrent];
//ensure last, since it releases this controller
[fController askOpenConfirmed: self add: YES];
}
- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) contextInfo
{
if (code == NSOKButton)
@ -255,4 +286,15 @@
fGroupValue = [sender tag];
}
- (void) sameNameAlertDidEnd: (NSAlert *) alert returnCode: (int) returnCode contextInfo: (void *) contextInfo
{
if (([NSApp isOnLeopardOrBetter] ? [[alert suppressionButton] state] == NSOnState : returnCode == NSAlertThirdButtonReturn))
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningFolderDataSameName"];
[alert release];
if (returnCode == NSAlertSecondButtonReturn)
[self performSelectorOnMainThread: @selector(confirmAdd) withObject: nil waitUntilDone: NO];
}
@end

View file

@ -140,6 +140,8 @@
<false/>
<key>WarningDuplicate</key>
<true/>
<key>WarningFolderDataSameName</key>
<true/>
<key>WarningRemainingSpace</key>
<true/>
</dict>

View file

@ -451,6 +451,7 @@
{
[fDefaults setBool: YES forKey: @"WarningDuplicate"];
[fDefaults setBool: YES forKey: @"WarningRemainingSpace"];
[fDefaults setBool: YES forKey: @"WarningFolderDataSameName"];
}
- (void) setCheckForUpdate: (id) sender