first commit of (unfinished) dialog when adding torrents
This commit is contained in:
parent
81f32f28d2
commit
e9e5638664
|
@ -119,6 +119,8 @@
|
|||
A261F1E40A69A1B10002815A /* Growl.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = A261F1DB0A69A1610002815A /* Growl.framework */; };
|
||||
A26397550D0F714300D36DF2 /* ActionPopUpButton.m in Sources */ = {isa = PBXBuildFile; fileRef = A26397540D0F714300D36DF2 /* ActionPopUpButton.m */; };
|
||||
A26AF21A0D2DA35A00FF7140 /* FileOutlineController.m in Sources */ = {isa = PBXBuildFile; fileRef = A26AF2190D2DA35A00FF7140 /* FileOutlineController.m */; };
|
||||
A26AF27E0D2DBDDF00FF7140 /* AddWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A26AF27C0D2DBDDF00FF7140 /* AddWindow.xib */; };
|
||||
A26AF2840D2DC27C00FF7140 /* AddWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = A26AF2830D2DC27C00FF7140 /* AddWindowController.m */; };
|
||||
A26E75880CB6AA7500226674 /* InfoOptions.png in Resources */ = {isa = PBXBuildFile; fileRef = A26E75870CB6AA7500226674 /* InfoOptions.png */; };
|
||||
A26E75960CB6AB4800226674 /* InfoGeneral.png in Resources */ = {isa = PBXBuildFile; fileRef = A26E75950CB6AB4800226674 /* InfoGeneral.png */; };
|
||||
A2710E770A86796000CE4F7D /* PrefsWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = A2710E750A86796000CE4F7D /* PrefsWindow.m */; };
|
||||
|
@ -513,6 +515,9 @@
|
|||
A26AF10B0D2855FC00FF7140 /* ru */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ru; path = macosx/ru.lproj/StatsWindow.xib; sourceTree = "<group>"; };
|
||||
A26AF2180D2DA35A00FF7140 /* FileOutlineController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileOutlineController.h; path = macosx/FileOutlineController.h; sourceTree = "<group>"; };
|
||||
A26AF2190D2DA35A00FF7140 /* FileOutlineController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FileOutlineController.m; path = macosx/FileOutlineController.m; sourceTree = "<group>"; };
|
||||
A26AF27D0D2DBDDF00FF7140 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = macosx/English.lproj/AddWindow.xib; sourceTree = "<group>"; };
|
||||
A26AF2820D2DC27C00FF7140 /* AddWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AddWindowController.h; path = macosx/AddWindowController.h; sourceTree = "<group>"; };
|
||||
A26AF2830D2DC27C00FF7140 /* AddWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AddWindowController.m; path = macosx/AddWindowController.m; sourceTree = "<group>"; };
|
||||
A26E75870CB6AA7500226674 /* InfoOptions.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = InfoOptions.png; path = macosx/Images/InfoOptions.png; sourceTree = "<group>"; };
|
||||
A26E75950CB6AB4800226674 /* InfoGeneral.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = InfoGeneral.png; path = macosx/Images/InfoGeneral.png; sourceTree = "<group>"; };
|
||||
A2710E740A86796000CE4F7D /* PrefsWindow.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PrefsWindow.h; path = macosx/PrefsWindow.h; sourceTree = "<group>"; };
|
||||
|
@ -788,6 +793,8 @@
|
|||
4DCCBB3C09C3D71100D3CABF /* TorrentCell.m */,
|
||||
A25AFDE70D1038AD0092A1BA /* MenuLabel.h */,
|
||||
A25AFDE80D1038AD0092A1BA /* MenuLabel.m */,
|
||||
A26AF2820D2DC27C00FF7140 /* AddWindowController.h */,
|
||||
A26AF2830D2DC27C00FF7140 /* AddWindowController.m */,
|
||||
A26397530D0F714300D36DF2 /* ActionPopUpButton.h */,
|
||||
A26397540D0F714300D36DF2 /* ActionPopUpButton.m */,
|
||||
A2BF078E0B066E0800757C92 /* SpeedLimitToTurtleIconTransformer.h */,
|
||||
|
@ -879,6 +886,7 @@
|
|||
A29576010D11D63C0093B167 /* Creator.xib */,
|
||||
A29576060D11D70E0093B167 /* MessageWindow.xib */,
|
||||
A25892750CF1FCE800CCCDDF /* StatsWindow.xib */,
|
||||
A26AF27C0D2DBDDF00FF7140 /* AddWindow.xib */,
|
||||
A22180B50D148F0F007D09ED /* GroupsWindow.xib */,
|
||||
A231274B0D11D0B7003F9AFF /* AboutWindow.xib */,
|
||||
A20B6FA40C4D97840034AB1D /* PriorityNone.png */,
|
||||
|
@ -1602,6 +1610,7 @@
|
|||
A20152640D1C1BE70081714F /* PinTemplate.png in Resources */,
|
||||
A23F4FF20D1D98AD002FCB97 /* PrefsWindow.xib in Resources */,
|
||||
A23F50020D1D99D7002FCB97 /* MainMenu.xib in Resources */,
|
||||
A26AF27E0D2DBDDF00FF7140 /* AddWindow.xib in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -1751,6 +1760,7 @@
|
|||
A25AFDE90D1038AD0092A1BA /* MenuLabel.m in Sources */,
|
||||
A22180980D148A71007D09ED /* GroupsWindowController.m in Sources */,
|
||||
A26AF21A0D2DA35A00FF7140 /* FileOutlineController.m in Sources */,
|
||||
A26AF2840D2DC27C00FF7140 /* AddWindowController.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -1935,6 +1945,14 @@
|
|||
name = StatsWindow.xib;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A26AF27C0D2DBDDF00FF7140 /* AddWindow.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
A26AF27D0D2DBDDF00FF7140 /* English */,
|
||||
);
|
||||
name = AddWindow.xib;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A29576010D11D63C0093B167 /* Creator.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/******************************************************************************
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2008 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 AddWindowController : NSWindowController
|
||||
{
|
||||
IBOutlet NSImageView * fIconView, * fLocationImageView;
|
||||
IBOutlet NSTextField * fNameField, * fStatusField, * fLocationField;
|
||||
IBOutlet NSButton * fStartCheck;
|
||||
|
||||
Controller * fController;
|
||||
|
||||
Torrent * fTorrent;
|
||||
NSString * fDestination;
|
||||
}
|
||||
|
||||
- (id) initWithTorrent: (Torrent *) torrent destination: (NSString *) path controller: (Controller *) controller;
|
||||
|
||||
- (void) setDestination: (id) sender;
|
||||
|
||||
|
||||
|
||||
|
||||
- (void) add: (id) sender;
|
||||
- (void) cancelAdd: (id) sender;
|
||||
|
||||
@end
|
|
@ -0,0 +1,160 @@
|
|||
/******************************************************************************
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2008 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 "AddWindowController.h"
|
||||
#import "Controller.h"
|
||||
#import "Torrent.h"
|
||||
#import "NSStringAdditions.h"
|
||||
#import "ExpandedPathToIconTransformer.h"
|
||||
|
||||
@interface AddWindowController (Private)
|
||||
|
||||
- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) contextInfo;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AddWindowController
|
||||
|
||||
- (id) initWithTorrent: (Torrent *) torrent destination: (NSString *) path controller: (Controller *) controller
|
||||
{
|
||||
if ((self = [super initWithWindowNibName: @"AddWindow"]))
|
||||
{
|
||||
fTorrent = torrent;
|
||||
if (path)
|
||||
fDestination = [[path stringByExpandingTildeInPath] retain];
|
||||
|
||||
fController = controller;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
NSString * name = [fTorrent name];
|
||||
[[self window] setTitle: name];
|
||||
[fNameField setStringValue: name];
|
||||
|
||||
NSImage * icon = [[fTorrent icon] copy];
|
||||
[icon setFlipped: NO];
|
||||
[fIconView setImage: icon];
|
||||
[icon release];
|
||||
|
||||
NSString * statusString = [NSString stringForFileSize: [fTorrent size]];
|
||||
if ([fTorrent folder])
|
||||
{
|
||||
NSString * fileString;
|
||||
int count = [fTorrent fileCount];
|
||||
if (count != 1)
|
||||
fileString = [NSString stringWithFormat: NSLocalizedString(@"%d Files, ", "Add torrent -> info"), count];
|
||||
else
|
||||
fileString = NSLocalizedString(@"1 File, ", "Add torrent -> info");
|
||||
statusString = [fileString stringByAppendingString: statusString];
|
||||
}
|
||||
[fStatusField setStringValue: statusString];
|
||||
|
||||
[fStartCheck setState: [[NSUserDefaults standardUserDefaults] boolForKey: @"AutoStartDownload"] ? NSOnState : NSOffState];
|
||||
|
||||
if (fDestination)
|
||||
{
|
||||
[fLocationField setStringValue: [fDestination stringByAbbreviatingWithTildeInPath]];
|
||||
[fLocationField setToolTip: fDestination];
|
||||
|
||||
ExpandedPathToIconTransformer * iconTransformer = [[ExpandedPathToIconTransformer alloc] init];
|
||||
[fLocationImageView setImage: [iconTransformer transformedValue: fDestination]];
|
||||
[iconTransformer release];
|
||||
}
|
||||
else
|
||||
{
|
||||
//if there is no destination, prompt for one right away
|
||||
[self setDestination: nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[fDestination release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (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
|
||||
{
|
||||
[fController askOpenConfirmed: fTorrent];
|
||||
|
||||
#warning remove if necessary
|
||||
|
||||
[self release];
|
||||
}
|
||||
|
||||
- (void) cancelAdd: (id) sender
|
||||
{
|
||||
[fTorrent closeRemoveTorrent];
|
||||
[fTorrent release];
|
||||
|
||||
[self release];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation AddWindowController (Private)
|
||||
|
||||
- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) contextInfo
|
||||
{
|
||||
if (code == NSOKButton)
|
||||
{
|
||||
[fDestination release];
|
||||
fDestination = [[[openPanel filenames] objectAtIndex: 0] retain];
|
||||
|
||||
[fLocationField setStringValue: [fDestination stringByAbbreviatingWithTildeInPath]];
|
||||
[fLocationField setToolTip: fDestination];
|
||||
|
||||
ExpandedPathToIconTransformer * iconTransformer = [[ExpandedPathToIconTransformer alloc] init];
|
||||
[fLocationImageView setImage: [iconTransformer transformedValue: fDestination]];
|
||||
[iconTransformer release];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!fDestination)
|
||||
[self cancelAdd: nil];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
|
@ -111,6 +111,7 @@
|
|||
- (void) openFiles: (NSArray *) filenames;
|
||||
- (void) openFiles: (NSArray *) filenames forcePath: (NSString *) path ignoreDownloadFolder: (BOOL) ignore
|
||||
deleteTorrentFile: (torrentFileState) deleteTorrent;
|
||||
- (void) askOpenConfirmed: (Torrent *) torrent;
|
||||
- (void) openCreatedFile: (NSNotification *) notification;
|
||||
- (void) openFilesWithDict: (NSDictionary *) dictionary;
|
||||
- (void) openFilesAsk: (NSMutableArray *) files deleteTorrentFile: (torrentFileState) deleteTorrent;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#import "TorrentTableView.h"
|
||||
#import "CreatorWindowController.h"
|
||||
#import "StatsWindowController.h"
|
||||
#import "AddWindowController.h"
|
||||
#import "GroupsWindowController.h"
|
||||
#import "AboutWindowController.h"
|
||||
#import "ButtonToolbarItem.h"
|
||||
|
@ -223,6 +224,13 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
[fIPCController setPrefsController: fPrefsController];
|
||||
fRemoteQuit = NO;
|
||||
|
||||
//setting from previous
|
||||
if ([[fDefaults stringForKey: @"DownloadChoice"] isEqualToString: @"Constant"])
|
||||
{
|
||||
[fDefaults setBool: YES forKey: @"DownloadLocationConstant"];
|
||||
[fDefaults removeObjectForKey: @"DownloadChoice"];
|
||||
}
|
||||
|
||||
[GrowlApplicationBridge setGrowlDelegate: self];
|
||||
[[UKKQueue sharedFileWatcher] setDelegate: self];
|
||||
}
|
||||
|
@ -664,8 +672,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
{
|
||||
NSString * path = [[fPendingTorrentDownloads objectForKey: [[download request] URL]] objectForKey: @"Path"];
|
||||
|
||||
[self openFiles: [NSArray arrayWithObject: path] forcePath: nil ignoreDownloadFolder:
|
||||
![[fDefaults stringForKey: @"DownloadChoice"] isEqualToString: @"Constant"] deleteTorrentFile: TORRENT_FILE_DELETE];
|
||||
[self openFiles: [NSArray arrayWithObject: path] forcePath: nil ignoreDownloadFolder: YES deleteTorrentFile: TORRENT_FILE_DELETE];
|
||||
|
||||
[fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
|
||||
[download release];
|
||||
|
@ -681,6 +688,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
[self openFiles: filenames forcePath: nil ignoreDownloadFolder: NO deleteTorrentFile: TORRENT_FILE_DEFAULT];
|
||||
}
|
||||
|
||||
#warning change ignore to add, and add an ignore only for torrents downloaded
|
||||
- (void) openFiles: (NSArray *) filenames forcePath: (NSString *) path ignoreDownloadFolder: (BOOL) ignore
|
||||
deleteTorrentFile: (torrentFileState) deleteTorrent
|
||||
{
|
||||
|
@ -709,14 +717,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
return;
|
||||
}
|
||||
|
||||
NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"];
|
||||
if (ignore || (!path && [downloadChoice isEqualToString: @"Ask"]))
|
||||
{
|
||||
[self openFilesAsk: [filenames mutableCopy] deleteTorrentFile: deleteTorrent];
|
||||
return;
|
||||
}
|
||||
|
||||
if (!path && [downloadChoice isEqualToString: @"Constant"]
|
||||
if (!path && [fDefaults boolForKey: @"DownloadLocationConstant"]
|
||||
&& access([[[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath] UTF8String], 0))
|
||||
{
|
||||
NSOpenPanel * panel = [NSOpenPanel openPanel];
|
||||
|
@ -749,10 +750,12 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
NSString * location;
|
||||
if (path)
|
||||
location = path;
|
||||
else if ([downloadChoice isEqualToString: @"Constant"])
|
||||
else if ([fDefaults boolForKey: @"DownloadLocationConstant"])
|
||||
location = [[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath];
|
||||
else
|
||||
else if (!ignore)
|
||||
location = [torrentPath stringByDeletingLastPathComponent];
|
||||
else
|
||||
location = nil;
|
||||
|
||||
tr_ctor * ctor = tr_ctorNew(fLib);
|
||||
tr_ctorSetMetainfoFromFile(ctor, [torrentPath UTF8String]);
|
||||
|
@ -768,17 +771,31 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
if (!(torrent = [[Torrent alloc] initWithPath: torrentPath location: location deleteTorrentFile: deleteTorrent lib: fLib]))
|
||||
continue;
|
||||
|
||||
//add it to the "File > Open Recent" menu
|
||||
//add it to the "File -> Open Recent" menu
|
||||
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
|
||||
|
||||
[torrent update];
|
||||
[fTorrents addObject: torrent];
|
||||
[torrent release];
|
||||
if ([fDefaults boolForKey: @"DownloadAsk"])
|
||||
[[[AddWindowController alloc] initWithTorrent: torrent destination: location controller: self] showWindow: self];
|
||||
else
|
||||
{
|
||||
[torrent update];
|
||||
[fTorrents addObject: torrent];
|
||||
[torrent release];
|
||||
}
|
||||
}
|
||||
|
||||
[self updateTorrentsInQueue];
|
||||
}
|
||||
|
||||
- (void) askOpenConfirmed: (Torrent *) torrent
|
||||
{
|
||||
[torrent update];
|
||||
[fTorrents addObject: torrent];
|
||||
[torrent release];
|
||||
|
||||
[self updateTorrentsInQueue];
|
||||
}
|
||||
|
||||
- (void) openCreatedFile: (NSNotification *) notification
|
||||
{
|
||||
NSDictionary * dict = [notification userInfo];
|
||||
|
@ -817,91 +834,6 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
[dictionary release];
|
||||
}
|
||||
|
||||
//called by the main open method to show sheet for choosing download location
|
||||
- (void) openFilesAsk: (NSMutableArray *) files deleteTorrentFile: (torrentFileState) deleteTorrent
|
||||
{
|
||||
//determine the next file that can be opened
|
||||
NSString * torrentPath;
|
||||
int canAdd;
|
||||
tr_info info;
|
||||
tr_ctor * ctor;
|
||||
while ([files count] > 0)
|
||||
{
|
||||
torrentPath = [[files objectAtIndex: 0] retain];
|
||||
|
||||
ctor = tr_ctorNew(fLib);
|
||||
tr_ctorSetMetainfoFromFile(ctor, [torrentPath UTF8String]);
|
||||
canAdd = tr_torrentParse(fLib, ctor, &info);
|
||||
tr_ctorFree(ctor);
|
||||
|
||||
if (canAdd == TR_OK)
|
||||
break;
|
||||
else if (canAdd == TR_EDUPLICATE)
|
||||
[self duplicateOpenAlert: [NSString stringWithUTF8String: info.name]];
|
||||
else;
|
||||
|
||||
tr_metainfoFree(&info);
|
||||
[files removeObjectAtIndex: 0];
|
||||
}
|
||||
|
||||
//no files left to open
|
||||
if ([files count] <= 0)
|
||||
{
|
||||
[files release];
|
||||
[self updateTorrentHistory];
|
||||
return;
|
||||
}
|
||||
|
||||
[files removeObjectAtIndex: 0];
|
||||
|
||||
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 \"%@\"",
|
||||
"Open torrent -> select destination folder"), [NSString stringWithUTF8String: info.name]]];
|
||||
tr_metainfoFree(&info);
|
||||
|
||||
NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: torrentPath, @"Path",
|
||||
files, @"Files", [NSNumber numberWithInt: deleteTorrent], @"DeleteTorrent", nil];
|
||||
[torrentPath release];
|
||||
|
||||
[panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
|
||||
didEndSelector: @selector(folderChoiceClosed:returnCode:contextInfo:) contextInfo: dictionary];
|
||||
}
|
||||
|
||||
- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (NSDictionary *) dictionary
|
||||
{
|
||||
if (code == NSOKButton)
|
||||
{
|
||||
NSString * torrentPath = [dictionary objectForKey: @"Path"];
|
||||
Torrent * torrent = [[Torrent alloc] initWithPath: torrentPath location: [[openPanel filenames] objectAtIndex: 0]
|
||||
deleteTorrentFile: [[dictionary objectForKey: @"DeleteTorrent"] intValue] lib: fLib];
|
||||
|
||||
//add it to the "File > Open Recent" menu
|
||||
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
|
||||
|
||||
[torrent update];
|
||||
[fTorrents addObject: torrent];
|
||||
[torrent release];
|
||||
|
||||
[self updateTorrentsInQueue];
|
||||
}
|
||||
|
||||
[self performSelectorOnMainThread: @selector(openFilesAskWithDict:) withObject: dictionary waitUntilDone: NO];
|
||||
}
|
||||
|
||||
- (void) openFilesAskWithDict: (NSDictionary *) dictionary
|
||||
{
|
||||
[self openFilesAsk: [dictionary objectForKey: @"Files"]
|
||||
deleteTorrentFile: [[dictionary objectForKey: @"DeleteTorrent"] intValue]];
|
||||
[dictionary release];
|
||||
}
|
||||
|
||||
//called on by applescript
|
||||
- (void) open: (NSArray *) files
|
||||
{
|
||||
|
@ -2365,6 +2297,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
[newNames replaceObjectAtIndex: i withObject: [path stringByAppendingPathComponent: file]];
|
||||
}
|
||||
|
||||
#warning fix!!!!!!!!!!
|
||||
BOOL ask = [[fDefaults stringForKey: @"DownloadChoice"] isEqualToString: @"Ask"];
|
||||
|
||||
NSEnumerator * enumerator = [newNames objectEnumerator];
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
+ (void) createTorrentFile: (tr_handle *) handle;
|
||||
+ (void) createTorrentFile: (tr_handle *) handle forFile: (NSString *) file;
|
||||
|
||||
- (id) initWithWindowNibName: (NSString *) name handle: (tr_handle *) handle path: (NSString *) path;
|
||||
- (id) initWithHandle: (tr_handle *) handle path: (NSString *) path;
|
||||
|
||||
- (void) setLocation: (id) sender;
|
||||
- (void) create: (id) sender;
|
||||
|
|
|
@ -43,19 +43,19 @@
|
|||
if (!(path = [CreatorWindowController chooseFile]))
|
||||
return;
|
||||
|
||||
CreatorWindowController * creator = [[self alloc] initWithWindowNibName: @"Creator" handle: handle path: path];
|
||||
CreatorWindowController * creator = [[self alloc] initWithHandle: handle path: path];
|
||||
[creator showWindow: nil];
|
||||
}
|
||||
|
||||
+ (void) createTorrentFile: (tr_handle *) handle forFile: (NSString *) file
|
||||
{
|
||||
CreatorWindowController * creator = [[self alloc] initWithWindowNibName: @"Creator" handle: handle path: file];
|
||||
CreatorWindowController * creator = [[self alloc] initWithHandle: handle path: file];
|
||||
[creator showWindow: nil];
|
||||
}
|
||||
|
||||
- (id) initWithWindowNibName: (NSString *) name handle: (tr_handle *) handle path: (NSString *) path
|
||||
- (id) initWithHandle: (tr_handle *) handle path: (NSString *) path
|
||||
{
|
||||
if ((self = [super initWithWindowNibName: name]))
|
||||
if ((self = [super initWithWindowNibName: @"Creator"]))
|
||||
{
|
||||
fStarted = NO;
|
||||
|
||||
|
|
|
@ -42,12 +42,14 @@
|
|||
<true/>
|
||||
<key>DisplayStatusProgressSelected</key>
|
||||
<false/>
|
||||
<key>DownloadChoice</key>
|
||||
<string>Constant</string>
|
||||
<key>DownloadAsk</key>
|
||||
<false/>
|
||||
<key>DownloadFolder</key>
|
||||
<string>~/Downloads</string>
|
||||
<key>DownloadLimit</key>
|
||||
<integer>100</integer>
|
||||
<key>DownloadLocationConstant</key>
|
||||
<false/>
|
||||
<key>DownloadSound</key>
|
||||
<string>Glass</string>
|
||||
<key>EncryptionPrefer</key>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -33,7 +33,6 @@
|
|||
|
||||
IBOutlet FileOutlineView * fOutline;
|
||||
|
||||
#warning generate outside nib
|
||||
IBOutlet NSMenuItem * fFileCheckItem, * fFileUncheckItem,
|
||||
* fFilePriorityNormal, * fFilePriorityHigh, * fFilePriorityLow;
|
||||
}
|
||||
|
|
|
@ -37,13 +37,14 @@
|
|||
|
||||
//set table header tool tips
|
||||
if ([NSApp isOnLeopardOrBetter])
|
||||
{NSLog(@"hafhdash");
|
||||
{
|
||||
[[fOutline tableColumnWithIdentifier: @"Check"] setHeaderToolTip: NSLocalizedString(@"Download",
|
||||
"file table -> header tool tip")];
|
||||
[[fOutline tableColumnWithIdentifier: @"Priority"] setHeaderToolTip: NSLocalizedString(@"Priority",
|
||||
"file table -> header tool tip")];
|
||||
}
|
||||
|
||||
#warning generate menu in code?
|
||||
//set priority item images
|
||||
[fFilePriorityNormal setImage: [NSImage imageNamed: @"PriorityNormal.png"]];
|
||||
[fFilePriorityLow setImage: [NSImage imageNamed: @"PriorityLow.png"]];
|
||||
|
@ -74,8 +75,9 @@
|
|||
- (int) outlineView: (NSOutlineView *) outlineView numberOfChildrenOfItem: (id) item
|
||||
{
|
||||
if (!item)
|
||||
return [[fTorrent fileList] count];
|
||||
return [[item objectForKey: @"IsFolder"] boolValue] ? [[item objectForKey: @"Children"] count] : 0;
|
||||
return fTorrent ? [[fTorrent fileList] count] : 0;
|
||||
else
|
||||
return [[item objectForKey: @"IsFolder"] boolValue] ? [[item objectForKey: @"Children"] count] : 0;
|
||||
}
|
||||
|
||||
- (BOOL) outlineView: (NSOutlineView *) outlineView isItemExpandable: (id) item
|
||||
|
|
|
@ -379,7 +379,6 @@ typedef enum
|
|||
[self updateOptions];
|
||||
|
||||
[fPeerTable reloadData];
|
||||
[fFileController reloadData];
|
||||
}
|
||||
|
||||
- (void) updateInfoStats
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
#define DOWNLOAD_FOLDER 0
|
||||
#define DOWNLOAD_TORRENT 2
|
||||
#define DOWNLOAD_ASK 3
|
||||
|
||||
#define UPDATE_SECONDS 86400
|
||||
|
||||
|
@ -111,13 +110,7 @@
|
|||
[self setPrefView: nil];
|
||||
|
||||
//set download folder
|
||||
NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"];
|
||||
if ([downloadChoice isEqualToString: @"Constant"])
|
||||
[fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
|
||||
else if ([downloadChoice isEqualToString: @"Torrent"])
|
||||
[fFolderPopUp selectItemAtIndex: DOWNLOAD_TORRENT];
|
||||
else
|
||||
[fFolderPopUp selectItemAtIndex: DOWNLOAD_ASK];
|
||||
[fFolderPopUp selectItemAtIndex: [fDefaults boolForKey: @"DownloadLocationConstant"] ? DOWNLOAD_FOLDER : DOWNLOAD_TORRENT];
|
||||
|
||||
//set stop ratio
|
||||
[self updateRatioStopField];
|
||||
|
@ -477,18 +470,7 @@
|
|||
|
||||
- (void) setDownloadLocation: (id) sender
|
||||
{
|
||||
switch ([fFolderPopUp indexOfSelectedItem])
|
||||
{
|
||||
case DOWNLOAD_FOLDER:
|
||||
[fDefaults setObject: @"Constant" forKey: @"DownloadChoice"];
|
||||
break;
|
||||
case DOWNLOAD_TORRENT:
|
||||
[fDefaults setObject: @"Torrent" forKey: @"DownloadChoice"];
|
||||
break;
|
||||
case DOWNLOAD_ASK:
|
||||
[fDefaults setObject: @"Ask" forKey: @"DownloadChoice"];
|
||||
break;
|
||||
}
|
||||
[fDefaults setBool: [fFolderPopUp indexOfSelectedItem] == DOWNLOAD_FOLDER forKey: @"DownloadLocationConstant"];
|
||||
}
|
||||
|
||||
- (void) folderSheetShow: (id) sender
|
||||
|
@ -630,13 +612,7 @@
|
|||
else
|
||||
{
|
||||
//reset if cancelled
|
||||
NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"];
|
||||
if ([downloadChoice isEqualToString: @"Constant"])
|
||||
[fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
|
||||
else if ([downloadChoice isEqualToString: @"Torrent"])
|
||||
[fFolderPopUp selectItemAtIndex: DOWNLOAD_TORRENT];
|
||||
else
|
||||
[fFolderPopUp selectItemAtIndex: DOWNLOAD_ASK];
|
||||
[fFolderPopUp selectItemAtIndex: [fDefaults boolForKey: @"DownloadLocationConstant"] ? DOWNLOAD_FOLDER : DOWNLOAD_TORRENT];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,8 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
|
||||
@implementation Torrent
|
||||
|
||||
#warning add init for add dialog
|
||||
|
||||
- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (torrentFileState) torrentDelete
|
||||
lib: (tr_handle *) lib
|
||||
{
|
||||
|
@ -1479,6 +1481,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
if (fPublicTorrent)
|
||||
fPublicTorrentLocation = [path retain];
|
||||
|
||||
#warning can it be nil? -- doesn't need the default value, since it'll be passed in
|
||||
fDownloadFolder = downloadFolder ? downloadFolder : [fDefaults stringForKey: @"DownloadFolder"];
|
||||
fDownloadFolder = [[fDownloadFolder stringByExpandingTildeInPath] retain];
|
||||
|
||||
|
|
Loading…
Reference in New Issue