mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
#2612 Display a neutered add window for magnet links
This commit is contained in:
@@ -100,6 +100,8 @@
|
||||
A21A9BE2106D86A800F1C3C1 /* TrackerNode.m in Sources */ = {isa = PBXBuildFile; fileRef = A21A9BE1106D86A800F1C3C1 /* TrackerNode.m */; };
|
||||
A21A9D41106EC2E800F1C3C1 /* TrackerCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A21A9D40106EC2E800F1C3C1 /* TrackerCell.m */; };
|
||||
A21DFF100A292B2B007C5F76 /* Transfers.png in Resources */ = {isa = PBXBuildFile; fileRef = A21DFF0F0A292B2B007C5F76 /* Transfers.png */; };
|
||||
A21F15AC11729A8B00CF5A9C /* AddMagnetWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = A21F15AA11729A8B00CF5A9C /* AddMagnetWindowController.m */; };
|
||||
A21F15AD11729A9F00CF5A9C /* AddMagnetWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A21F1538117299F100CF5A9C /* AddMagnetWindow.xib */; };
|
||||
A21FBBAB0EDA78C300BC3C51 /* bandwidth.h in Headers */ = {isa = PBXBuildFile; fileRef = A21FBBA90EDA78C300BC3C51 /* bandwidth.h */; };
|
||||
A21FBBAC0EDA78C300BC3C51 /* bandwidth.c in Sources */ = {isa = PBXBuildFile; fileRef = A21FBBAA0EDA78C300BC3C51 /* bandwidth.c */; };
|
||||
A22180980D148A71007D09ED /* GroupsPrefsController.m in Sources */ = {isa = PBXBuildFile; fileRef = A22180970D148A71007D09ED /* GroupsPrefsController.m */; };
|
||||
@@ -537,6 +539,9 @@
|
||||
A21A9D3F106EC2E800F1C3C1 /* TrackerCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TrackerCell.h; path = macosx/TrackerCell.h; sourceTree = "<group>"; };
|
||||
A21A9D40106EC2E800F1C3C1 /* TrackerCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TrackerCell.m; path = macosx/TrackerCell.m; sourceTree = "<group>"; };
|
||||
A21DFF0F0A292B2B007C5F76 /* Transfers.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Transfers.png; path = macosx/Images/Transfers.png; sourceTree = "<group>"; };
|
||||
A21F1539117299F100CF5A9C /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = macosx/en.lproj/AddMagnetWindow.xib; sourceTree = "<group>"; };
|
||||
A21F15AA11729A8B00CF5A9C /* AddMagnetWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AddMagnetWindowController.m; path = macosx/AddMagnetWindowController.m; sourceTree = "<group>"; };
|
||||
A21F15AB11729A8B00CF5A9C /* AddMagnetWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AddMagnetWindowController.h; path = macosx/AddMagnetWindowController.h; sourceTree = "<group>"; };
|
||||
A21FBBA90EDA78C300BC3C51 /* bandwidth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bandwidth.h; path = libtransmission/bandwidth.h; sourceTree = "<group>"; };
|
||||
A21FBBAA0EDA78C300BC3C51 /* bandwidth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = bandwidth.c; path = libtransmission/bandwidth.c; sourceTree = "<group>"; };
|
||||
A22180960D148A71007D09ED /* GroupsPrefsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GroupsPrefsController.h; path = macosx/GroupsPrefsController.h; sourceTree = "<group>"; };
|
||||
@@ -975,6 +980,8 @@
|
||||
A28F4F760E085BDC003A3882 /* ColorTextField.m */,
|
||||
A26AF2820D2DC27C00FF7140 /* AddWindowController.h */,
|
||||
A26AF2830D2DC27C00FF7140 /* AddWindowController.m */,
|
||||
A21F15AB11729A8B00CF5A9C /* AddMagnetWindowController.h */,
|
||||
A21F15AA11729A8B00CF5A9C /* AddMagnetWindowController.m */,
|
||||
A25E74450AF5089E006F11AE /* ExpandedPathToPathTransformer.h */,
|
||||
A25E74440AF5089E006F11AE /* ExpandedPathToPathTransformer.m */,
|
||||
A25E74470AF5089E006F11AE /* ExpandedPathToIconTransformer.h */,
|
||||
@@ -1074,6 +1081,7 @@
|
||||
A23F4FF00D1D98AD002FCB97 /* PrefsWindow.xib */,
|
||||
A29576010D11D63C0093B167 /* Creator.xib */,
|
||||
A26AF27C0D2DBDDF00FF7140 /* AddWindow.xib */,
|
||||
A21F1538117299F100CF5A9C /* AddMagnetWindow.xib */,
|
||||
A215BF5B0F02EBB800350CDB /* GroupRules.xib */,
|
||||
A233BD320D8C6585007EE7B4 /* MessageWindow.xib */,
|
||||
A233BD680D8CF2C7007EE7B4 /* StatsWindow.xib */,
|
||||
@@ -1914,6 +1922,7 @@
|
||||
A209EBD91142F52B002B02D1 /* InfoFileView.xib in Resources */,
|
||||
A209EC12114301C6002B02D1 /* InfoOptionsView.xib in Resources */,
|
||||
A209ECA2114319C3002B02D1 /* InfoWindow.xib in Resources */,
|
||||
A21F15AD11729A9F00CF5A9C /* AddMagnetWindow.xib in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -2099,6 +2108,7 @@
|
||||
A209EB9D1142E59A002B02D1 /* InfoPeersViewController.m in Sources */,
|
||||
A209EBCE1142F2B4002B02D1 /* InfoFileViewController.m in Sources */,
|
||||
A209EBF91142FEEE002B02D1 /* InfoOptionsViewController.m in Sources */,
|
||||
A21F15AC11729A8B00CF5A9C /* AddMagnetWindowController.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -2270,6 +2280,14 @@
|
||||
name = GroupRules.xib;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A21F1538117299F100CF5A9C /* AddMagnetWindow.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
A21F1539117299F100CF5A9C /* en */,
|
||||
);
|
||||
name = AddMagnetWindow.xib;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A22A8D540AEEAFA5007E9CB9 /* Localizable.strings */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
|
||||
58
macosx/AddMagnetWindowController.h
Normal file
58
macosx/AddMagnetWindowController.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/******************************************************************************
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2010 Transmission authors and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@class Controller;
|
||||
@class Torrent;
|
||||
|
||||
@interface AddMagnetWindowController : NSWindowController
|
||||
{
|
||||
IBOutlet NSImageView * fIconView, * fLocationImageView;
|
||||
IBOutlet NSTextField * fNameField, * fLocationField;
|
||||
IBOutlet NSButton * fStartCheck;
|
||||
IBOutlet NSPopUpButton * fGroupPopUp, * fPriorityPopUp;
|
||||
|
||||
Controller * fController;
|
||||
|
||||
Torrent * fTorrent;
|
||||
NSString * fDestination;
|
||||
|
||||
NSInteger fGroupValue;
|
||||
}
|
||||
|
||||
- (id) initWithTorrent: (Torrent *) torrent destination: (NSString *) path controller: (Controller *) controller;
|
||||
|
||||
- (Torrent *) torrent;
|
||||
|
||||
- (void) setDestination: (id) sender;
|
||||
|
||||
- (void) add: (id) sender;
|
||||
- (void) cancelAdd: (id) sender;
|
||||
|
||||
- (void) changePriority: (id) sender;
|
||||
|
||||
- (void) updateGroupMenu: (NSNotification *) notification;
|
||||
|
||||
@end
|
||||
269
macosx/AddMagnetWindowController.m
Normal file
269
macosx/AddMagnetWindowController.m
Normal file
@@ -0,0 +1,269 @@
|
||||
/******************************************************************************
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2010 Transmission authors and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
#import "AddMagnetWindowController.h"
|
||||
#import "Controller.h"
|
||||
#import "ExpandedPathToIconTransformer.h"
|
||||
#import "GroupsController.h"
|
||||
#import "NSStringAdditions.h"
|
||||
#import "Torrent.h"
|
||||
|
||||
#define POPUP_PRIORITY_HIGH 0
|
||||
#define POPUP_PRIORITY_NORMAL 1
|
||||
#define POPUP_PRIORITY_LOW 2
|
||||
|
||||
@interface AddMagnetWindowController (Private)
|
||||
|
||||
- (void) confirmAdd;
|
||||
|
||||
- (void) setDestinationPath: (NSString *) destination;
|
||||
|
||||
- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (NSInteger) code contextInfo: (void *) contextInfo;
|
||||
|
||||
- (void) setGroupsMenu;
|
||||
- (void) changeGroupValue: (id) sender;
|
||||
|
||||
- (void) sameNameAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AddMagnetWindowController
|
||||
|
||||
- (id) initWithTorrent: (Torrent *) torrent destination: (NSString *) path controller: (Controller *) controller
|
||||
{
|
||||
if ((self = [super initWithWindowNibName: @"AddMagnetWindow"]))
|
||||
{
|
||||
fTorrent = torrent;
|
||||
fDestination = [[path stringByExpandingTildeInPath] retain];
|
||||
|
||||
fController = controller;
|
||||
|
||||
fGroupValue = [torrent groupValue];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(updateGroupMenu:)
|
||||
name: @"UpdateGroups" object: nil];
|
||||
|
||||
NSString * name = [fTorrent name];
|
||||
[[self window] setTitle: name];
|
||||
[fNameField setStringValue: name];
|
||||
|
||||
[fIconView setImage: [fTorrent icon]];
|
||||
|
||||
[self setGroupsMenu];
|
||||
[fGroupPopUp selectItemWithTag: fGroupValue];
|
||||
|
||||
NSInteger priorityIndex;
|
||||
switch ([fTorrent priority])
|
||||
{
|
||||
case TR_PRI_HIGH: priorityIndex = POPUP_PRIORITY_HIGH; break;
|
||||
case TR_PRI_NORMAL: priorityIndex = POPUP_PRIORITY_NORMAL; break;
|
||||
case TR_PRI_LOW: priorityIndex = POPUP_PRIORITY_LOW; break;
|
||||
default: NSAssert1(NO, @"Unknown priority for adding torrent: %d", [fTorrent priority]);
|
||||
}
|
||||
[fPriorityPopUp selectItemAtIndex: priorityIndex];
|
||||
|
||||
[fStartCheck setState: [[NSUserDefaults standardUserDefaults] boolForKey: @"AutoStartDownload"] ? NSOnState : NSOffState];
|
||||
|
||||
if (fDestination)
|
||||
[self setDestinationPath: fDestination];
|
||||
else
|
||||
{
|
||||
[fLocationField setStringValue: @""];
|
||||
[fLocationImageView setImage: nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) windowDidLoad
|
||||
{
|
||||
//if there is no destination, prompt for one right away
|
||||
if (!fDestination)
|
||||
[self setDestination: nil];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
|
||||
[fDestination release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (Torrent *) torrent
|
||||
{
|
||||
return fTorrent;
|
||||
}
|
||||
|
||||
- (void) setDestination: (id) sender
|
||||
{
|
||||
NSOpenPanel * panel = [NSOpenPanel openPanel];
|
||||
|
||||
[panel setPrompt: NSLocalizedString(@"Select", "Open torrent -> prompt")];
|
||||
[panel setAllowsMultipleSelection: NO];
|
||||
[panel setCanChooseFiles: NO];
|
||||
[panel setCanChooseDirectories: YES];
|
||||
[panel setCanCreateDirectories: YES];
|
||||
|
||||
[panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the download folder for \"%@\"",
|
||||
"Add -> select destination folder"), [fTorrent name]]];
|
||||
|
||||
[panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: [self window] modalDelegate: self
|
||||
didEndSelector: @selector(folderChoiceClosed:returnCode:contextInfo:) contextInfo: nil];
|
||||
}
|
||||
|
||||
- (void) add: (id) sender
|
||||
{
|
||||
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")];
|
||||
[alert setShowsSuppressionButton: YES];
|
||||
|
||||
[alert beginSheetModalForWindow: [self window] modalDelegate: self
|
||||
didEndSelector: @selector(sameNameAlertDidEnd:returnCode:contextInfo:) contextInfo: nil];
|
||||
}
|
||||
else
|
||||
[self confirmAdd];
|
||||
}
|
||||
|
||||
- (void) cancelAdd: (id) sender
|
||||
{
|
||||
[[self window] performClose: sender];
|
||||
}
|
||||
|
||||
//only called on cancel
|
||||
- (BOOL) windowShouldClose: (id) window
|
||||
{
|
||||
[fController askOpenMagnetConfirmed: self add: NO];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) changePriority: (id) sender
|
||||
{
|
||||
tr_priority_t priority;
|
||||
switch ([sender indexOfSelectedItem])
|
||||
{
|
||||
case POPUP_PRIORITY_HIGH: priority = TR_PRI_HIGH; break;
|
||||
case POPUP_PRIORITY_NORMAL: priority = TR_PRI_NORMAL; break;
|
||||
case POPUP_PRIORITY_LOW: priority = TR_PRI_LOW; break;
|
||||
default: NSAssert1(NO, @"Unknown priority tag for adding torrent: %d", [sender tag]);
|
||||
}
|
||||
[fTorrent setPriority: priority];
|
||||
}
|
||||
|
||||
- (void) updateGroupMenu: (NSNotification *) notification
|
||||
{
|
||||
[self setGroupsMenu];
|
||||
if (![fGroupPopUp selectItemWithTag: fGroupValue])
|
||||
{
|
||||
fGroupValue = -1;
|
||||
[fGroupPopUp selectItemWithTag: fGroupValue];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation AddMagnetWindowController (Private)
|
||||
|
||||
- (void) confirmAdd
|
||||
{
|
||||
[fTorrent setWaitToStart: [fStartCheck state] == NSOnState];
|
||||
[fTorrent setGroupValue: fGroupValue];
|
||||
|
||||
[self close];
|
||||
[fController askOpenMagnetConfirmed: self add: YES]; //ensure last, since it releases this controller
|
||||
}
|
||||
|
||||
- (void) setDestinationPath: (NSString *) destination
|
||||
{
|
||||
destination = [destination stringByExpandingTildeInPath];
|
||||
if (!fDestination || ![fDestination isEqualToString: destination])
|
||||
{
|
||||
[fDestination release];
|
||||
fDestination = [destination retain];
|
||||
|
||||
[fTorrent changeDownloadFolderBeforeUsing: fDestination];
|
||||
}
|
||||
|
||||
[fLocationField setStringValue: [fDestination stringByAbbreviatingWithTildeInPath]];
|
||||
[fLocationField setToolTip: fDestination];
|
||||
|
||||
ExpandedPathToIconTransformer * iconTransformer = [[ExpandedPathToIconTransformer alloc] init];
|
||||
[fLocationImageView setImage: [iconTransformer transformedValue: fDestination]];
|
||||
[iconTransformer release];
|
||||
}
|
||||
|
||||
- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (NSInteger) code contextInfo: (void *) contextInfo
|
||||
{
|
||||
if (code == NSOKButton)
|
||||
[self setDestinationPath: [[openPanel filenames] objectAtIndex: 0]];
|
||||
else
|
||||
{
|
||||
if (!fDestination)
|
||||
[self performSelectorOnMainThread: @selector(cancelAdd:) withObject: nil waitUntilDone: NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setGroupsMenu
|
||||
{
|
||||
NSMenu * groupMenu = [[GroupsController groups] groupMenuWithTarget: self action: @selector(changeGroupValue:) isSmall: NO];
|
||||
[fGroupPopUp setMenu: groupMenu];
|
||||
}
|
||||
|
||||
- (void) changeGroupValue: (id) sender
|
||||
{
|
||||
NSInteger previousGroup = fGroupValue;
|
||||
fGroupValue = [sender tag];
|
||||
|
||||
if ([[GroupsController groups] usesCustomDownloadLocationForIndex: fGroupValue])
|
||||
[self setDestinationPath: [[GroupsController groups] customDownloadLocationForIndex: fGroupValue]];
|
||||
else if ([fDestination isEqualToString: [[GroupsController groups] customDownloadLocationForIndex: previousGroup]])
|
||||
[self setDestinationPath: [[NSUserDefaults standardUserDefaults] stringForKey: @"DownloadFolder"]];
|
||||
else;
|
||||
}
|
||||
|
||||
- (void) sameNameAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
|
||||
{
|
||||
if ([[alert suppressionButton] state] == NSOnState)
|
||||
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningFolderDataSameName"];
|
||||
|
||||
[alert release];
|
||||
|
||||
if (returnCode == NSAlertSecondButtonReturn)
|
||||
[self performSelectorOnMainThread: @selector(confirmAdd) withObject: nil waitUntilDone: NO];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -44,7 +44,7 @@
|
||||
NSString * fDestination, * fTorrentFile;
|
||||
BOOL fLockDestination;
|
||||
|
||||
BOOL fDeleteTorrent, fDeleteEnable;
|
||||
BOOL fDeleteTorrentInitial, fDeleteEnableInitial;
|
||||
NSInteger fGroupValue;
|
||||
|
||||
NSTimer * fTimer;
|
||||
|
||||
@@ -69,8 +69,8 @@
|
||||
|
||||
fTorrentFile = [[torrentFile stringByExpandingTildeInPath] retain];
|
||||
|
||||
fDeleteTorrent = deleteTorrent;
|
||||
fDeleteEnable = canToggleDelete;
|
||||
fDeleteTorrentInitial = deleteTorrent;
|
||||
fDeleteEnableInitial = canToggleDelete;
|
||||
|
||||
fGroupValue = [torrent groupValue];
|
||||
|
||||
@@ -112,8 +112,8 @@
|
||||
|
||||
[fStartCheck setState: [[NSUserDefaults standardUserDefaults] boolForKey: @"AutoStartDownload"] ? NSOnState : NSOffState];
|
||||
|
||||
[fDeleteCheck setState: fDeleteTorrent ? NSOnState : NSOffState];
|
||||
[fDeleteCheck setEnabled: fDeleteEnable];
|
||||
[fDeleteCheck setState: fDeleteTorrentInitial ? NSOnState : NSOffState];
|
||||
[fDeleteCheck setEnabled: fDeleteEnableInitial];
|
||||
|
||||
if (fDestination)
|
||||
[self setDestinationPath: fDestination];
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#import <Quartz/Quartz.h>
|
||||
#import <Growl/Growl.h>
|
||||
|
||||
@class AddMagnetWindowController;
|
||||
@class AddWindowController;
|
||||
@class Badger;
|
||||
@class DragOverlayWindow;
|
||||
@@ -117,13 +118,15 @@ typedef enum
|
||||
}
|
||||
|
||||
- (void) openFiles: (NSArray *) filenames addType: (addType) type forcePath: (NSString *) path;
|
||||
- (void) openMagnet: (NSString *) address;
|
||||
|
||||
- (void) askOpenConfirmed: (AddWindowController *) addController add: (BOOL) add;
|
||||
- (void) openCreatedFile: (NSNotification *) notification;
|
||||
- (void) openFilesWithDict: (NSDictionary *) dictionary;
|
||||
- (void) openShowSheet: (id) sender;
|
||||
|
||||
- (void) openMagnet: (NSString *) address;
|
||||
- (void) askOpenMagnetConfirmed: (AddMagnetWindowController *) addController add: (BOOL) add;
|
||||
|
||||
- (void) invalidOpenAlert: (NSString *) filename;
|
||||
- (void) invalidOpenMagnetAlert: (NSString *) address;
|
||||
- (void) duplicateOpenAlert: (NSString *) name;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#import "GroupsController.h"
|
||||
#import "AboutWindowController.h"
|
||||
#import "AddWindowController.h"
|
||||
#import "AddMagnetWindowController.h"
|
||||
#import "MessageWindowController.h"
|
||||
#import "ButtonToolbarItem.h"
|
||||
#import "GroupToolbarItem.h"
|
||||
@@ -941,6 +942,26 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||
[self updateTorrentsInQueue];
|
||||
}
|
||||
|
||||
- (void) askOpenConfirmed: (AddWindowController *) addController add: (BOOL) add
|
||||
{
|
||||
Torrent * torrent = [addController torrent];
|
||||
[addController release];
|
||||
|
||||
if (add)
|
||||
{
|
||||
[torrent update];
|
||||
[fTorrents addObject: torrent];
|
||||
[torrent release];
|
||||
|
||||
[self updateTorrentsInQueue];
|
||||
}
|
||||
else
|
||||
{
|
||||
[torrent closeRemoveTorrent];
|
||||
[torrent release];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) openMagnet: (NSString *) address
|
||||
{
|
||||
tr_torrent * duplicateTorrent;
|
||||
@@ -959,25 +980,37 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||
return;
|
||||
}
|
||||
|
||||
#warning show add window perhaps?
|
||||
//determine download location
|
||||
NSString * location = nil;
|
||||
if ([fDefaults boolForKey: @"DownloadLocationConstant"])
|
||||
location = [[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath];
|
||||
|
||||
//change the location if the group calls for it (this has to wait until after the torrent is created)
|
||||
if ([[GroupsController groups] usesCustomDownloadLocationForIndex: [torrent groupValue]])
|
||||
{
|
||||
NSString * location = [[GroupsController groups] customDownloadLocationForIndex: [torrent groupValue]];
|
||||
location = [[GroupsController groups] customDownloadLocationForIndex: [torrent groupValue]];
|
||||
[torrent changeDownloadFolderBeforeUsing: location];
|
||||
}
|
||||
|
||||
[torrent setWaitToStart: [fDefaults boolForKey: @"AutoStartDownload"]];
|
||||
|
||||
[torrent update];
|
||||
[fTorrents addObject: torrent];
|
||||
[torrent release];
|
||||
if ([fDefaults boolForKey: @"DownloadAsk"] || !location)
|
||||
{
|
||||
AddMagnetWindowController * addController = [[AddMagnetWindowController alloc] initWithTorrent: torrent destination: location
|
||||
controller: self];
|
||||
[addController showWindow: self];
|
||||
}
|
||||
else
|
||||
{
|
||||
[torrent setWaitToStart: [fDefaults boolForKey: @"AutoStartDownload"]];
|
||||
|
||||
[torrent update];
|
||||
[fTorrents addObject: torrent];
|
||||
[torrent release];
|
||||
}
|
||||
|
||||
[self updateTorrentsInQueue];
|
||||
}
|
||||
|
||||
- (void) askOpenConfirmed: (AddWindowController *) addController add: (BOOL) add
|
||||
- (void) askOpenMagnetConfirmed: (AddMagnetWindowController *) addController add: (BOOL) add
|
||||
{
|
||||
Torrent * torrent = [addController torrent];
|
||||
[addController release];
|
||||
|
||||
@@ -27,6 +27,8 @@ EXTRA_DIST = \
|
||||
zh_TW.lproj \
|
||||
AboutWindowController.h \
|
||||
AboutWindowController.m \
|
||||
AddMagnetWindowController.h \
|
||||
AddMagnetWindowController.m \
|
||||
AddWindowController.h \
|
||||
AddWindowController.m \
|
||||
Badger.h \
|
||||
|
||||
1667
macosx/en.lproj/AddMagnetWindow.xib
Normal file
1667
macosx/en.lproj/AddMagnetWindow.xib
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user