Partial use of bindings in prefs/action menu. This is still experimental and evolving, with the most obvious problem that entering an invalid value causes an annoying error sheet to appear.

This commit is contained in:
Mitchell Livingston
2006-10-27 19:14:04 +00:00
parent 21c2aba63b
commit 00fe6a984f
16 changed files with 152 additions and 650 deletions

View File

@@ -92,6 +92,8 @@
A21610FC0A050B1700E8E4C1 /* MenuButton.m in Sources */ = {isa = PBXBuildFile; fileRef = A21610FB0A050B1700E8E4C1 /* MenuButton.m */; };
A2173E1C0A33C1B300B0D8AB /* ActionButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = A2173E1B0A33C1B300B0D8AB /* ActionButtonPressed.png */; };
A21DFF100A292B2B007C5F76 /* Transfers.png in Resources */ = {isa = PBXBuildFile; fileRef = A21DFF0F0A292B2B007C5F76 /* Transfers.png */; };
A21F5B890AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = A21F5B870AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m */; };
A21F5C040AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = A21F5C020AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m */; };
A22A8D560AEEAFA5007E9CB9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A22A8D540AEEAFA5007E9CB9 /* Localizable.strings */; };
A2305A800A3DC9E400AB2D77 /* ProgressBarWhite.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305A7C0A3DC9E400AB2D77 /* ProgressBarWhite.png */; };
A2305A810A3DC9E400AB2D77 /* ProgressBarBlue.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305A7D0A3DC9E400AB2D77 /* ProgressBarBlue.png */; };
@@ -287,7 +289,7 @@
4DAB87C40ABE1F730081CF7E /* http.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = http.c; path = libtransmission/http.c; sourceTree = "<group>"; };
4DCCBB3C09C3D71100D3CABF /* TorrentCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = TorrentCell.m; path = macosx/TorrentCell.m; sourceTree = "<group>"; };
4DCCBB3D09C3D71100D3CABF /* TorrentCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = TorrentCell.h; path = macosx/TorrentCell.h; sourceTree = "<group>"; };
4DDBB71909E16BAE00284745 /* transmissioncli */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = transmissioncli; sourceTree = BUILT_PRODUCTS_DIR; };
4DDBB71909E16BAE00284745 /* transmissioncli */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = transmissioncli; sourceTree = BUILT_PRODUCTS_DIR; };
4DDBB71B09E16BF100284745 /* transmissioncli.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = transmissioncli.c; path = cli/transmissioncli.c; sourceTree = "<group>"; };
4DDFDD20099A5D8E00189D81 /* DownloadBadge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = DownloadBadge.png; path = macosx/Images/DownloadBadge.png; sourceTree = "<group>"; };
4DDFDD21099A5D8E00189D81 /* UploadBadge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = UploadBadge.png; path = macosx/Images/UploadBadge.png; sourceTree = "<group>"; };
@@ -317,6 +319,10 @@
A21610FB0A050B1700E8E4C1 /* MenuButton.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MenuButton.m; path = macosx/MenuButton.m; sourceTree = "<group>"; };
A2173E1B0A33C1B300B0D8AB /* ActionButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ActionButtonPressed.png; path = macosx/Images/ActionButtonPressed.png; sourceTree = "<group>"; };
A21DFF0F0A292B2B007C5F76 /* Transfers.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Transfers.png; path = macosx/Images/Transfers.png; sourceTree = "<group>"; };
A21F5B860AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ActionMenuRatioToDisplayRatioTransformer.h; path = macosx/ActionMenuRatioToDisplayRatioTransformer.h; sourceTree = "<group>"; };
A21F5B870AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ActionMenuRatioToDisplayRatioTransformer.m; path = macosx/ActionMenuRatioToDisplayRatioTransformer.m; sourceTree = "<group>"; };
A21F5C010AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ActionMenuSpeedToDisplayLimitTransformer.h; path = macosx/ActionMenuSpeedToDisplayLimitTransformer.h; sourceTree = "<group>"; };
A21F5C020AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ActionMenuSpeedToDisplayLimitTransformer.m; path = macosx/ActionMenuSpeedToDisplayLimitTransformer.m; sourceTree = "<group>"; };
A22A8D550AEEAFA5007E9CB9 /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = macosx/English.lproj/Localizable.strings; sourceTree = "<group>"; };
A2305A7C0A3DC9E400AB2D77 /* ProgressBarWhite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarWhite.png; path = macosx/Images/ProgressBarWhite.png; sourceTree = "<group>"; };
A2305A7D0A3DC9E400AB2D77 /* ProgressBarBlue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarBlue.png; path = macosx/Images/ProgressBarBlue.png; sourceTree = "<group>"; };
@@ -424,6 +430,10 @@
080E96DDFE201D6D7F000001 /* Sources */ = {
isa = PBXGroup;
children = (
A21F5C010AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.h */,
A21F5C020AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m */,
A21F5B860AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.h */,
A21F5B870AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m */,
A2A306530AAD24A80049E2AC /* UKFileWatcher.h */,
A2A306540AAD24A80049E2AC /* UKFileWatcher.m */,
A2A306550AAD24A80049E2AC /* UKFNSubscribeFileWatcher.h */,
@@ -922,6 +932,8 @@
A291DAAF0AC8BEB6003385E9 /* PiecesView.m in Sources */,
A29C8B370ACC6EB3000ED9F9 /* PortChecker.m in Sources */,
A2AA579D0ADFCAB400CA59F6 /* PiecesImageView.m in Sources */,
A21F5B890AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m in Sources */,
A21F5C040AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -0,0 +1,8 @@
#import <Foundation/Foundation.h>
@interface ActionMenuRatioToDisplayRatioTransformer : NSValueTransformer
{
}
@end

View File

@@ -0,0 +1,23 @@
#import "ActionMenuRatioToDisplayRatioTransformer.h"
@implementation ActionMenuRatioToDisplayRatioTransformer
+ (Class) transformedValueClass
{
return [NSString class];
}
+ (BOOL) allowsReverseTransformation
{
return NO;
}
- (id) transformedValue: (id) value
{
return value == nil ? nil : [NSString stringWithFormat: NSLocalizedString(@"Stop at Ratio (%.2f)",
"Action context menu -> ratio stop"), [value floatValue]];
}
@end

View File

@@ -0,0 +1,8 @@
#import <Foundation/Foundation.h>
@interface ActionMenuSpeedToDisplayLimitTransformer : NSValueTransformer
{
}
@end

View File

@@ -0,0 +1,23 @@
#import "ActionMenuSpeedToDisplayLimitTransformer.h"
@implementation ActionMenuSpeedToDisplayLimitTransformer
+ (Class) transformedValueClass
{
return [NSString class];
}
+ (BOOL) allowsReverseTransformation
{
return NO;
}
- (id) transformedValue: (id) value
{
return value == nil ? nil : [NSString stringWithFormat: NSLocalizedString(@"Limit (%d KB/s)",
"Action context menu -> upload/download limit"), [value intValue]];
}
@end

View File

@@ -163,11 +163,8 @@
- (void) setLimitGlobalEnabled: (id) sender;
- (void) setQuickLimitGlobal: (id) sender;
- (void) limitGlobalChange: (NSNotification *) notification;
- (void) setRatioGlobalEnabled: (id) sender;
- (void) setQuickRatioGlobal: (id) sender;
- (void) ratioGlobalChange: (NSNotification *) notification;
- (void) checkWaitingForStopped: (NSNotification *) notification;
- (void) checkToStartWaiting: (Torrent *) finishedTorrent;

View File

@@ -30,6 +30,8 @@
#import "TorrentTableView.h"
#import "StringAdditions.h"
#import "UKKQueue.h"
#import "ActionMenuSpeedToDisplayLimitTransformer.h"
#import "ActionMenuRatioToDisplayRatioTransformer.h"
#import <Sparkle/Sparkle.h>
@@ -71,6 +73,15 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
{
[[NSUserDefaults standardUserDefaults] registerDefaults: [NSDictionary dictionaryWithContentsOfFile:
[[NSBundle mainBundle] pathForResource: @"Defaults" ofType: @"plist"]]];
//set custom value transformers
ActionMenuSpeedToDisplayLimitTransformer * limitTransformer =
[[[ActionMenuSpeedToDisplayLimitTransformer alloc] init] autorelease];
[NSValueTransformer setValueTransformer: limitTransformer forName: @"ActionMenuSpeedToDisplayLimitTransformer"];
ActionMenuRatioToDisplayRatioTransformer * ratioTransformer =
[[[ActionMenuRatioToDisplayRatioTransformer alloc] init] autorelease];
[NSValueTransformer setValueTransformer: ratioTransformer forName: @"ActionMenuRatioToDisplayRatioTransformer"];
}
- (id) init
@@ -280,30 +291,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[currentFilterButton setEnabled: YES];
//set upload limit action button
[fUploadLimitItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Limit (%d KB/s)",
"Action context menu -> upload limit"), [fDefaults integerForKey: @"UploadLimit"]]];
if ([fDefaults boolForKey: @"CheckUpload"])
[fUploadLimitItem setState: NSOnState];
else
[fUploadNoLimitItem setState: NSOnState];
//set download limit action menu
[fDownloadLimitItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Limit (%d KB/s)",
"Action context menu -> download limit"), [fDefaults integerForKey: @"DownloadLimit"]]];
if ([fDefaults boolForKey: @"CheckDownload"])
[fDownloadLimitItem setState: NSOnState];
else
[fDownloadNoLimitItem setState: NSOnState];
//set ratio action menu
[fRatioSetItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Stop at Ratio (%.2f)",
"Action context menu -> ratio stop"), [fDefaults floatForKey: @"RatioLimit"]]];
if ([fDefaults boolForKey: @"RatioCheck"])
[fRatioSetItem setState: NSOnState];
else
[fRatioNotSetItem setState: NSOnState];
//observe notifications
NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
@@ -317,12 +304,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
name: SUUpdaterWillRestartNotification object: nil];
fUpdateInProgress = NO;
[nc addObserver: self selector: @selector(limitGlobalChange:)
name: @"LimitGlobalChange" object: nil];
[nc addObserver: self selector: @selector(ratioGlobalChange:)
name: @"RatioGlobalChange" object: nil];
[nc addObserver: self selector: @selector(autoSpeedLimitChange:)
name: @"AutoSpeedLimitChange" object: nil];
@@ -1318,7 +1299,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[fSpeedLimitButton setImage: !fSpeedLimitEnabled ? fSpeedLimitNormalImage
: ([NSColor currentControlTint] == NSBlueControlTint ? fSpeedLimitBlueImage : fSpeedLimitGraphiteImage)];
[fPrefsController enableSpeedLimit: fSpeedLimitEnabled];
[fPrefsController applySpeedSettings: nil];
}
- (void) autoSpeedLimitChange: (NSNotification *) notification
@@ -1362,67 +1343,24 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
}
}
#warning get rid of
- (void) setLimitGlobalEnabled: (id) sender
{
[fPrefsController setQuickLimitEnabled: (sender == fUploadLimitItem || sender == fDownloadLimitItem)
type: (sender == fUploadLimitItem || sender == fUploadNoLimitItem) ? @"Upload" : @"Download"];
[fPrefsController applySpeedSettings: nil];
}
- (void) setQuickLimitGlobal: (id) sender
{
[fPrefsController setQuickLimit: [[sender title] intValue]
type: [sender menu] == fUploadMenu ? @"Upload" : @"Download"];
}
- (void) limitGlobalChange: (NSNotification *) notification
{
NSMenuItem * limitItem, * noLimitItem;
BOOL enable;
int limit;
if ([[notification object] boolValue])
{
limitItem = fUploadLimitItem;
noLimitItem = fUploadNoLimitItem;
enable = [fDefaults boolForKey: @"CheckUpload"];
limit = [fDefaults integerForKey: @"UploadLimit"];
}
else
{
limitItem = fDownloadLimitItem;
noLimitItem = fDownloadNoLimitItem;
enable = [fDefaults boolForKey: @"CheckDownload"];
limit = [fDefaults integerForKey: @"DownloadLimit"];
}
[fDefaults setInteger: [[sender title] intValue] forKey: [sender menu] == fUploadMenu ? @"UploadLimit" : @"DownloadLimit"];
[fDefaults setBool: YES forKey: [sender menu] == fUploadMenu ? @"CheckUpload" : @"CheckDownload"];
[limitItem setState: enable ? NSOnState : NSOffState];
[noLimitItem setState: !enable ? NSOnState : NSOffState];
[limitItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Limit (%d KB/s)",
"Action context menu -> upload/download limit"), limit]];
[[notification object] release];
}
- (void) setRatioGlobalEnabled: (id) sender
{
[fPrefsController setQuickRatioEnabled: sender == fRatioSetItem];
[fPrefsController applySpeedSettings: nil];
}
- (void) setQuickRatioGlobal: (id) sender
{
[fPrefsController setQuickRatio: [[sender title] floatValue]];
}
- (void) ratioGlobalChange: (NSNotification *) notification
{
BOOL enable = [fDefaults boolForKey: @"RatioCheck"];
[fRatioSetItem setState: enable ? NSOnState : NSOffState];
[fRatioNotSetItem setState: !enable ? NSOnState : NSOffState];
[fRatioSetItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Stop at Ratio (%.2f)",
"Action context menu -> ratio stop"), [fDefaults floatForKey: @"RatioLimit"]]];
[fDefaults setBool: YES forKey: @"RatioCheck"];
[fDefaults setFloat: [[sender title] floatValue] forKey: @"RatioLimit"];
}
- (void) checkWaitingForStopped: (NSNotification *) notification

View File

@@ -22,7 +22,6 @@
setLimitGlobalEnabled = id;
setQuickLimitGlobal = id;
setQuickRatioGlobal = id;
setRatioGlobalEnabled = id;
setSort = id;
showInfo = id;
showMainWindow = id;

View File

@@ -7,7 +7,7 @@
<key>IBEditorPositions</key>
<dict>
<key>1041</key>
<string>379 362 208 130 0 0 1024 746 </string>
<string>438 418 208 130 0 0 1152 842 </string>
<key>1480</key>
<string>366 546 420 63 0 0 1152 842 </string>
<key>1603</key>
@@ -27,11 +27,6 @@
<array/>
<key>IBOldestOS</key>
<integer>3</integer>
<key>IBOpenObjects</key>
<array>
<integer>29</integer>
<integer>21</integer>
</array>
<key>IBSystem Version</key>
<string>8L127</string>
</dict>

Binary file not shown.

View File

@@ -5,6 +5,7 @@
{CLASS = NSDatePicker; LANGUAGE = ObjC; SUPERCLASS = NSControl; },
{
ACTIONS = {
applySpeedSettings = id;
folderSheetShow = id;
helpForNetwork = id;
importFolderSheetShow = id;
@@ -14,32 +15,16 @@
setAutoSpeedLimitHour = id;
setBadge = id;
setDownloadLocation = id;
setLimit = id;
setLimitCheck = id;
setMoveTorrent = id;
setNat = id;
setPlaySound = id;
setPort = id;
setQueueNumber = id;
setRatio = id;
setRatioCheck = id;
setShowMessage = id;
setSound = id;
setSpeedLimit = id;
setStartAtOpen = id;
setUpdate = id;
setUseQueue = id;
};
CLASS = PrefsController;
LANGUAGE = ObjC;
OUTLETS = {
fAutoImportCheck = NSButton;
fAutoSizeCheck = NSButton;
fBadgeDownloadRateCheck = NSButton;
fBadgeUploadRateCheck = NSButton;
fBandwidthView = NSView;
fCopyTorrentCheck = NSButton;
fDeleteOriginalTorrentCheck = NSButton;
fDownloadCheck = NSButton;
fDownloadField = NSTextField;
fDownloadSoundPopUp = NSPopUpButton;
@@ -50,27 +35,12 @@
fNatStatusField = NSTextField;
fNatStatusImage = NSImageView;
fNetworkView = NSView;
fPlayDownloadSoundCheck = NSButton;
fPlaySeedingSoundCheck = NSButton;
fPortField = NSTextField;
fPortStatusField = NSTextField;
fPortStatusImage = NSImageView;
fPortStatusProgress = NSProgressIndicator;
fQueueCheck = NSButton;
fQueueNumberField = NSTextField;
fQuitCheck = NSButton;
fQuitDownloadingCheck = NSButton;
fRatioCheck = NSButton;
fRatioField = NSTextField;
fRemoveCheck = NSButton;
fRemoveDownloadingCheck = NSButton;
fSeedingSoundPopUp = NSPopUpButton;
fSpeedLimitAutoCheck = NSButton;
fSpeedLimitAutoOffField = NSTextField;
fSpeedLimitAutoOnField = NSTextField;
fSpeedLimitDownloadField = NSTextField;
fSpeedLimitUploadField = NSTextField;
fStartAtOpenCheck = NSButton;
fTransfersView = NSView;
fUpdatePopUp = NSPopUpButton;
fUploadCheck = NSButton;

View File

@@ -7,11 +7,11 @@
<key>IBEditorPositions</key>
<dict>
<key>153</key>
<string>30 315 577 267 0 0 1024 746 </string>
<string>294 445 563 267 0 0 1152 842 </string>
<key>28</key>
<string>22 331 577 290 0 0 1024 746 </string>
<string>294 434 563 290 0 0 1152 842 </string>
<key>41</key>
<string>213 415 563 317 0 0 1152 842 </string>
<string>294 420 563 317 0 0 1152 842 </string>
<key>66</key>
<string>294 507 563 144 0 0 1152 842 </string>
</dict>
@@ -21,6 +21,10 @@
<array>
<integer>253</integer>
</array>
<key>IBOpenObjects</key>
<array>
<integer>153</integer>
</array>
<key>IBSystem Version</key>
<string>8L127</string>
</dict>

View File

@@ -557,12 +557,14 @@
- (void) revealTorrentFile: (id) sender
{
[[fTorrents objectAtIndex: 0] revealPublicTorrent];
if ([fTorrents count] > 0)
[[fTorrents objectAtIndex: 0] revealPublicTorrent];
}
- (void) revealDataFile: (id) sender
{
[[fTorrents objectAtIndex: 0] revealData];
if ([fTorrents count] > 0)
[[fTorrents objectAtIndex: 0] revealData];
}
- (void) revealFile: (id) sender

View File

@@ -31,59 +31,39 @@
{
tr_handle_t * fHandle;
NSUserDefaults * fDefaults;
NSToolbar * fToolbar;
IBOutlet NSView * fGeneralView, * fTransfersView, * fBandwidthView, * fNetworkView;
IBOutlet NSPopUpButton * fFolderPopUp, * fImportFolderPopUp,
* fDownloadSoundPopUp, * fSeedingSoundPopUp;
IBOutlet NSButton * fQuitCheck, * fRemoveCheck,
* fQuitDownloadingCheck, * fRemoveDownloadingCheck,
* fBadgeDownloadRateCheck, * fBadgeUploadRateCheck,
* fPlayDownloadSoundCheck, * fPlaySeedingSoundCheck,
* fCopyTorrentCheck, * fDeleteOriginalTorrentCheck,
* fAutoImportCheck, * fAutoSizeCheck;
SUUpdater * fUpdater;
IBOutlet NSPopUpButton * fUpdatePopUp;
IBOutlet NSTextField * fUploadField, * fDownloadField,
* fSpeedLimitUploadField, * fSpeedLimitDownloadField,
* fSpeedLimitAutoOnField, * fSpeedLimitAutoOffField;
IBOutlet NSButton * fUploadCheck, * fDownloadCheck,
* fSpeedLimitAutoCheck;
* fSpeedLimitUploadField, * fSpeedLimitDownloadField;
IBOutlet NSButton * fUploadCheck, * fDownloadCheck;
IBOutlet NSTextField * fPortField, * fNatStatusField, * fPortStatusField;
IBOutlet NSTextField * fNatStatusField,
* fPortStatusField;
IBOutlet NSButton * fNatCheck;
IBOutlet NSImageView * fNatStatusImage, * fPortStatusImage;
IBOutlet NSProgressIndicator * fPortStatusProgress;
NSTimer * fNatStatusTimer;
int fNatStatus;
IBOutlet NSButton * fRatioCheck;
IBOutlet NSTextField * fRatioField;
IBOutlet NSButton * fQueueCheck, * fStartAtOpenCheck;
IBOutlet NSTextField * fQueueNumberField;
NSString * fDownloadFolder, * fImportFolder;
NSUserDefaults * fDefaults;
}
- (id) initWithWindowNibName: (NSString *) name handle: (tr_handle_t *) handle;
- (void) setUpdater: (SUUpdater *) updater;
- (void) setShowMessage: (id) sender;
- (void) setBadge: (id) sender;
- (void) setPlaySound: (id) sender;
- (void) setSound: (id) sender;
- (void) setUpdate: (id) sender;
- (void) setStartAtOpen: (id) sender;
- (void) setUseQueue: (id) sender;
- (void) setQueueNumber: (id) sender;
- (void) setMoveTorrent: (id) sender;
- (void) setDownloadLocation: (id) sender;
- (void) folderSheetShow: (id) sender;
@@ -93,28 +73,16 @@
- (void) setNat: (id) sender;
- (void) updateNatStatus;
- (void) setSpeedLimit: (id) sender;
- (void) setAutoSpeedLimitCheck: (id) sender;
- (void) setAutoSpeedLimitHour: (id) sender;
- (void) setLimit: (id) sender;
- (void) setLimitCheck: (id) sender;
- (void) setQuickLimitEnabled: (BOOL) enable type: (NSString *) type;
- (void) setQuickLimit: (int) limit type: (NSString *) type;
- (void) enableSpeedLimit: (BOOL) enable;
- (void) applySpeedSettings: (id) sender;
- (void) setAutoImport: (id) sender;
- (void) importFolderSheetShow: (id) sender;
- (void) setAutoSize: (id) sender;
- (void) setRatio: (id) sender;
- (void) setRatioCheck: (id) sender;
- (void) setQuickRatioEnabled: (BOOL) enable;
- (void) setQuickRatio: (float) ratioLimit;
- (void) helpForNetwork: (id) sender;
@end

View File

@@ -26,9 +26,6 @@
#import "StringAdditions.h"
#import "UKKQueue.h"
#define MIN_PORT 1
#define MAX_PORT 65535
#define DOWNLOAD_FOLDER 0
#define DOWNLOAD_TORRENT 2
#define DOWNLOAD_ASK 3
@@ -70,13 +67,10 @@
[fDefaults setBool: NO forKey: @"CheckUpload"];
}
//set download folder and import folder
fDownloadFolder = [[[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath] retain];
fImportFolder = [[[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath] retain];
//set auto import
if ([fDefaults boolForKey: @"AutoImport"])
[[UKKQueue sharedFileWatcher] addPath: fImportFolder];
[[UKKQueue sharedFileWatcher] addPath:
[[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
//set bind port
int bindPort = [fDefaults integerForKey: @"BindPort"];
@@ -87,18 +81,7 @@
tr_natTraversalEnable(fHandle);
//actually set bandwidth limits
if ([fDefaults boolForKey: @"SpeedLimit"])
{
tr_setUploadLimit(fHandle, [fDefaults integerForKey: @"SpeedLimitUploadLimit"]);
tr_setDownloadLimit(fHandle, [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]);
}
else
{
tr_setUploadLimit(fHandle, [fDefaults boolForKey: @"CheckUpload"]
? [fDefaults integerForKey: @"UploadLimit"] : -1);
tr_setDownloadLimit(fHandle, [fDefaults boolForKey: @"CheckDownload"]
? [fDefaults integerForKey: @"DownloadLimit"] : -1);
}
[self applySpeedSettings: nil];
}
return self;
}
@@ -107,9 +90,7 @@
{
if (fNatStatusTimer)
[fNatStatusTimer invalidate];
[fDownloadFolder release];
[fImportFolder release];
[super dealloc];
}
@@ -137,77 +118,14 @@
//set auto import
[self updateImportPopUp];
BOOL autoImport = [fDefaults boolForKey: @"AutoImport"];
[fAutoImportCheck setState: autoImport];
[fImportFolderPopUp setEnabled: autoImport];
//set auto size
[fAutoSizeCheck setState: [fDefaults boolForKey: @"AutoSize"]];
//set bind port
int bindPort = [fDefaults integerForKey: @"BindPort"];
[fPortField setIntValue: bindPort];
[self updatePortStatus];
//set NAT
[fNatCheck setState: [fDefaults boolForKey: @"NatTraversal"]];
fNatStatus = -1;
[self updateNatStatus];
fNatStatusTimer = [NSTimer scheduledTimerWithTimeInterval: 5.0 target: self
selector: @selector(updateNatStatus) userInfo: nil repeats: YES];
//set upload limit
BOOL checkUpload = [fDefaults boolForKey: @"CheckUpload"];
[fUploadCheck setState: checkUpload];
[fUploadField setIntValue: [fDefaults integerForKey: @"UploadLimit"]];
[fUploadField setEnabled: checkUpload];
//set download limit
BOOL checkDownload = [fDefaults boolForKey: @"CheckDownload"];
[fDownloadCheck setState: checkDownload];
[fDownloadField setIntValue: [fDefaults integerForKey: @"DownloadLimit"]];
[fDownloadField setEnabled: checkDownload];
//set speed limit
[fSpeedLimitUploadField setIntValue: [fDefaults integerForKey: @"SpeedLimitUploadLimit"]];
[fSpeedLimitDownloadField setIntValue: [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]];
//set auto speed limit
BOOL speedLimitAuto = [fDefaults boolForKey: @"SpeedLimitAuto"];
[fSpeedLimitAutoCheck setState: speedLimitAuto];
int speedLimitAutoOnHour = [fDefaults integerForKey: @"SpeedLimitAutoOnHour"];
[fSpeedLimitAutoOnField setStringValue: [NSString stringWithFormat: @"%02d", speedLimitAutoOnHour]];
[fSpeedLimitAutoOnField setEnabled: speedLimitAuto];
int speedLimitAutoOffHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"];
[fSpeedLimitAutoOffField setStringValue: [NSString stringWithFormat: @"%02d", speedLimitAutoOffHour]];
[fSpeedLimitAutoOffField setEnabled: speedLimitAuto];
//set ratio limit
BOOL ratioCheck = [fDefaults boolForKey: @"RatioCheck"];
[fRatioCheck setState: ratioCheck];
[fRatioField setEnabled: ratioCheck];
[fRatioField setFloatValue: [fDefaults floatForKey: @"RatioLimit"]];
//set remove and quit prompts
BOOL isQuitCheck = [fDefaults boolForKey: @"CheckQuit"],
isRemoveCheck = [fDefaults boolForKey: @"CheckRemove"];
[fQuitCheck setState: isQuitCheck];
[fRemoveCheck setState: isRemoveCheck];
[fQuitDownloadingCheck setState: [fDefaults boolForKey: @"CheckQuitDownloading"]];
[fQuitDownloadingCheck setEnabled: isQuitCheck];
[fRemoveDownloadingCheck setState: [fDefaults boolForKey: @"CheckRemoveDownloading"]];
[fRemoveDownloadingCheck setEnabled: isRemoveCheck];
//set dock badging
[fBadgeDownloadRateCheck setState: [fDefaults boolForKey: @"BadgeDownloadRate"]];
[fBadgeUploadRateCheck setState: [fDefaults boolForKey: @"BadgeUploadRate"]];
//set play sound
NSMutableArray * sounds = [NSMutableArray array];
NSEnumerator * soundEnumerator,
@@ -231,10 +149,6 @@
[fDownloadSoundPopUp removeAllItems];
[fDownloadSoundPopUp addItemsWithTitles: sounds];
BOOL playDownloadSound = [fDefaults boolForKey: @"PlayDownloadSound"];
[fPlayDownloadSoundCheck setState: playDownloadSound];
[fDownloadSoundPopUp setEnabled: playDownloadSound];
int downloadSoundIndex = [fDownloadSoundPopUp indexOfItemWithTitle: [fDefaults stringForKey: @"DownloadSound"]];
if (downloadSoundIndex >= 0)
[fDownloadSoundPopUp selectItemAtIndex: downloadSoundIndex];
@@ -245,30 +159,11 @@
[fSeedingSoundPopUp removeAllItems];
[fSeedingSoundPopUp addItemsWithTitles: sounds];
BOOL playSeedingSound = [fDefaults boolForKey: @"PlaySeedingSound"];
[fPlaySeedingSoundCheck setState: playSeedingSound];
[fSeedingSoundPopUp setEnabled: playSeedingSound];
int seedingSoundIndex = [fDownloadSoundPopUp indexOfItemWithTitle: [fDefaults stringForKey: @"SeedingSound"]];
if (seedingSoundIndex >= 0)
[fSeedingSoundPopUp selectItemAtIndex: seedingSoundIndex];
else
[fDefaults setObject: [fSeedingSoundPopUp titleOfSelectedItem] forKey: @"SeedingSound"];
//set start settings
BOOL useQueue = [fDefaults boolForKey: @"Queue"];
[fQueueCheck setState: useQueue];
[fQueueNumberField setEnabled: useQueue];
[fQueueNumberField setIntValue: [fDefaults integerForKey: @"QueueDownloadNumber"]];
[fStartAtOpenCheck setState: [fDefaults boolForKey: @"AutoStartDownload"]];
//set private torrents
BOOL copyTorrents = [fDefaults boolForKey: @"SavePrivateTorrent"];
[fCopyTorrentCheck setState: copyTorrents];
[fDeleteOriginalTorrentCheck setEnabled: copyTorrents];
[fDeleteOriginalTorrentCheck setState: [fDefaults boolForKey: @"DeleteOriginalTorrent"]];
//set update check
NSString * updateCheck = [fDefaults stringForKey: @"UpdateCheck"];
@@ -285,8 +180,8 @@
fUpdater = updater;
}
- (NSToolbarItem *) toolbar: (NSToolbar *) t itemForItemIdentifier:
(NSString *) ident willBeInsertedIntoToolbar: (BOOL) flag
- (NSToolbarItem *) toolbar: (NSToolbar *) toolbar itemForItemIdentifier: (NSString *) ident
willBeInsertedIntoToolbar: (BOOL) flag
{
NSToolbarItem * item;
item = [[NSToolbarItem alloc] initWithItemIdentifier: ident];
@@ -346,22 +241,9 @@
- (void) setPort: (id) sender
{
int bindPort = [sender intValue];
if (![[NSString stringWithInt: bindPort] isEqualToString: [sender stringValue]]
|| bindPort < MIN_PORT || bindPort > MAX_PORT)
{
NSBeep();
bindPort = [fDefaults integerForKey: @"BindPort"];
[sender setIntValue: bindPort];
}
else
{
tr_setBindPort(fHandle, bindPort);
[fDefaults setInteger: bindPort forKey: @"BindPort"];
[self updateNatStatus];
[self updatePortStatus];
}
tr_setBindPort(fHandle, [fDefaults integerForKey: @"BindPort"]);
[self updateNatStatus];
[self updatePortStatus];
}
- (void) updatePortStatus
@@ -412,10 +294,7 @@
- (void) setNat: (id) sender
{
BOOL enable = [sender state] == NSOnState;
enable ? tr_natTraversalEnable(fHandle) : tr_natTraversalDisable(fHandle);
[fDefaults setBool: enable forKey: @"NatTraversal"];
[fDefaults boolForKey: @"NatTraversal"] ? tr_natTraversalEnable(fHandle) : tr_natTraversalDisable(fHandle);
[self updateNatStatus];
}
@@ -447,314 +326,38 @@
[self updatePortStatus];
}
- (void) setLimit: (id) sender
- (void) applySpeedSettings: (id) sender
{
NSString * key;
NSButton * check;
NSString * type;
if (sender == fUploadField)
if ([fDefaults boolForKey: @"SpeedLimit"])
{
key = @"UploadLimit";
check = fUploadCheck;
type = @"Upload";
tr_setUploadLimit(fHandle, [fDefaults integerForKey: @"SpeedLimitUploadLimit"]);
tr_setDownloadLimit(fHandle, [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]);
}
else
{
key = @"DownloadLimit";
check = fDownloadCheck;
type = @"Download";
}
int limit = [sender intValue];
if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", limit]] || limit < 0)
{
NSBeep();
limit = [fDefaults integerForKey: key];
[sender setIntValue: limit];
}
else
{
if (![fDefaults boolForKey: @"SpeedLimit"])
{
int realLimit = [check state] ? limit : -1;
if (sender == fUploadField)
tr_setUploadLimit(fHandle, realLimit);
else
tr_setDownloadLimit(fHandle, realLimit);
}
[fDefaults setInteger: limit forKey: key];
}
[[NSNotificationCenter defaultCenter] postNotificationName: @"LimitGlobalChange"
object: [[NSNumber alloc] initWithBool: sender == fUploadField]];
}
- (void) setLimitCheck: (id) sender
{
NSString * key;
NSTextField * field;
if (sender == fUploadCheck)
{
key = @"CheckUpload";
field = fUploadField;
}
else
{
key = @"CheckDownload";
field = fDownloadField;
}
BOOL check = [sender state] == NSOnState;
[fDefaults setBool: check forKey: key];
[self setLimit: field];
[field setEnabled: check];
}
- (void) setQuickLimitEnabled: (BOOL) enable type: (NSString *) type
{
//if interface is loaded, perform change as if user performed it
#warning better way?
if (fToolbar)
{
NSButton * check = [type isEqualToString: @"Upload"] ? fUploadCheck : fDownloadCheck;
[check setState: enable ? NSOnState : NSOffState];
[self setLimitCheck: check];
}
else
{
BOOL upload = [type isEqualToString: @"Upload"];
[fDefaults setBool: enable forKey: upload ? @"CheckUpload" : @"CheckDownload"];
[[NSNotificationCenter defaultCenter] postNotificationName: @"LimitGlobalChange"
object: [[NSNumber alloc] initWithBool: upload]];
}
}
- (void) setQuickLimit: (int) limit type: (NSString *) type
{
//if interface is loaded, perform change as if user performed it
if (fToolbar)
{
NSButton * check;
if ([type isEqualToString: @"Upload"])
{
[fUploadField setIntValue: limit];
check = fUploadCheck;
}
else
{
[fDownloadField setIntValue: limit];
check = fDownloadCheck;
}
[check setState: NSOnState];
[self setLimitCheck: check];
}
else
{
BOOL upload = [type isEqualToString: @"Upload"];
[fDefaults setBool: YES forKey: upload ? @"CheckUpload" : @"CheckDownload"];
[fDefaults setInteger: limit forKey: upload ? @"UploadLimit" : @"DownloadLimit"];
[[NSNotificationCenter defaultCenter] postNotificationName: @"LimitGlobalChange"
object: [[NSNumber alloc] initWithBool: upload]];
}
}
- (void) enableSpeedLimit: (BOOL) enable
{
if ([fDefaults boolForKey: @"SpeedLimit"] != enable)
{
[fDefaults setBool: enable forKey: @"SpeedLimit"];
if (enable)
{
tr_setUploadLimit(fHandle, [fDefaults integerForKey: @"SpeedLimitUploadLimit"]);
tr_setDownloadLimit(fHandle, [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]);
}
else
{
tr_setUploadLimit(fHandle, [fDefaults boolForKey: @"CheckUpload"]
tr_setUploadLimit(fHandle, [fDefaults boolForKey: @"CheckUpload"]
? [fDefaults integerForKey: @"UploadLimit"] : -1);
tr_setDownloadLimit(fHandle, [fDefaults boolForKey: @"CheckDownload"]
? [fDefaults integerForKey: @"DownloadLimit"] : -1);
}
}
}
- (void) setSpeedLimit: (id) sender
{
NSString * key = sender == fSpeedLimitUploadField ? @"SpeedLimitUploadLimit" : @"SpeedLimitDownloadLimit";
int limit = [sender intValue];
if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", limit]] || limit < 0)
{
NSBeep();
limit = [fDefaults integerForKey: key];
[sender setIntValue: limit];
}
else
{
if ([fDefaults boolForKey: @"SpeedLimit"])
{
if (sender == fSpeedLimitUploadField)
tr_setUploadLimit(fHandle, limit);
else
tr_setDownloadLimit(fHandle, limit);
}
[fDefaults setInteger: limit forKey: key];
tr_setDownloadLimit(fHandle, [fDefaults boolForKey: @"CheckDownload"]
? [fDefaults integerForKey: @"DownloadLimit"] : -1);
}
}
- (void) setAutoSpeedLimitCheck: (id) sender
{
BOOL check = [sender state] == NSOnState;
[fDefaults setBool: check forKey: @"SpeedLimitAuto"];
[self setAutoSpeedLimitHour: fSpeedLimitAutoOnField];
[fSpeedLimitAutoOnField setEnabled: check];
[self setAutoSpeedLimitHour: fSpeedLimitAutoOffField];
[fSpeedLimitAutoOffField setEnabled: check];
}
- (void) setAutoSpeedLimitHour: (id) sender
{
NSString * key = (sender == fSpeedLimitAutoOnField) ? @"SpeedLimitAutoOnHour" : @"SpeedLimitAutoOffHour";
int hour = [sender intValue];
//allow numbers under ten in the format 0x
if (!([[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", hour]]
|| [[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%02d", hour]]) || hour < 0 || hour > 23
|| [fSpeedLimitAutoOnField intValue] == [fSpeedLimitAutoOffField intValue])
{
NSBeep();
hour = [fDefaults integerForKey: key];
[sender setStringValue: [NSString stringWithFormat: @"%02d", hour]];
}
else
[fDefaults setInteger: hour forKey: key];
[sender setStringValue: [NSString stringWithFormat: @"%02d", hour]]; //ensure number has 2 digits
[[NSNotificationCenter defaultCenter] postNotificationName: @"AutoSpeedLimitChange" object: self];
}
- (void) setRatio: (id) sender
#warning check if same value
- (void) setAutoSpeedLimitHour: (id) sender
{
float ratioLimit = [sender floatValue];
if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%.2f", ratioLimit]]
|| ratioLimit < 0)
{
NSBeep();
ratioLimit = [fDefaults floatForKey: @"RatioLimit"];
[sender setFloatValue: ratioLimit];
}
else
[fDefaults setFloat: ratioLimit forKey: @"RatioLimit"];
[[NSNotificationCenter defaultCenter] postNotificationName: @"RatioGlobalChange" object: nil];
}
- (void) setRatioCheck: (id) sender
{
BOOL check = [sender state] == NSOnState;
[fDefaults setBool: check forKey: @"RatioCheck"];
[self setRatio: fRatioField];
[fRatioField setEnabled: check];
}
- (void) setQuickRatioEnabled: (BOOL) enable
{
//if interface is loaded, perform change as if user performed it
if (fToolbar)
{
int state = enable ? NSOnState : NSOffState;
[fRatioCheck setState: state];
[self setRatioCheck: fRatioCheck];
}
else
{
[fDefaults setBool: enable forKey: @"RatioCheck"];
[[NSNotificationCenter defaultCenter] postNotificationName: @"RatioGlobalChange" object: nil];
}
}
- (void) setQuickRatio: (float) ratioLimit
{
//if interface is loaded, perform change as if user performed it
if (fToolbar)
{
[fRatioField setFloatValue: ratioLimit];
[fRatioCheck setState: NSOnState];
[self setRatioCheck: fRatioCheck];
}
else
{
[fDefaults setBool: YES forKey: @"RatioCheck"];
[fDefaults setFloat: ratioLimit forKey: @"RatioLimit"];
[[NSNotificationCenter defaultCenter] postNotificationName: @"RatioGlobalChange" object: nil];
}
}
- (void) setShowMessage: (id) sender
{
BOOL state = [sender state];
if (sender == fQuitCheck)
{
[fDefaults setBool: state forKey: @"CheckQuit"];
[fQuitDownloadingCheck setEnabled: state];
}
else if (sender == fRemoveCheck)
{
[fDefaults setBool: state forKey: @"CheckRemove"];
[fRemoveDownloadingCheck setEnabled: state];
}
if (sender == fQuitDownloadingCheck)
[fDefaults setBool: state forKey: @"CheckQuitDownloading"];
else if (sender == fRemoveDownloadingCheck)
[fDefaults setBool: state forKey: @"CheckRemoveDownloading"];
else;
[[NSNotificationCenter defaultCenter] postNotificationName: @"AutoSpeedLimitChange" object: self];
}
- (void) setBadge: (id) sender
{
if (sender == fBadgeDownloadRateCheck)
[fDefaults setBool: [sender state] forKey: @"BadgeDownloadRate"];
else if (sender == fBadgeUploadRateCheck)
[fDefaults setBool: [sender state] forKey: @"BadgeUploadRate"];
else;
[[NSNotificationCenter defaultCenter] postNotificationName: @"DockBadgeChange" object: self];
}
- (void) setPlaySound: (id) sender
{
BOOL state = [sender state];
if (sender == fPlayDownloadSoundCheck)
{
[fDownloadSoundPopUp setEnabled: state];
[fDefaults setBool: state forKey: @"PlayDownloadSound"];
}
else if (sender == fPlaySeedingSoundCheck)
{
[fSeedingSoundPopUp setEnabled: state];
[fDefaults setBool: state forKey: @"PlaySeedingSound"];
}
else;
}
- (void) setSound: (id) sender
{
//play sound when selecting
@@ -763,6 +366,7 @@
if ((sound = [NSSound soundNamed: soundName]))
[sound play];
#warning use bindings
if (sender == fDownloadSoundPopUp)
[fDefaults setObject: soundName forKey: @"DownloadSound"];
else if (sender == fSeedingSoundPopUp)
@@ -796,56 +400,15 @@
[fUpdater scheduleCheckWithInterval: seconds];
}
- (void) setStartAtOpen: (id) sender
{
[fDefaults setBool: [sender state] == NSOnState forKey: @"AutoStartDownload"];
}
- (void) setUseQueue: (id) sender
{
BOOL useQueue = [sender state] == NSOnState;
[fDefaults setBool: useQueue forKey: @"Queue"];
[self setQueueNumber: fQueueNumberField];
[fQueueNumberField setEnabled: useQueue];
}
#warning out of range/wrong value
- (void) setQueueNumber: (id) sender
{
int queueNumber = [sender intValue];
if (![[sender stringValue] isEqualToString: [NSString stringWithInt: queueNumber]] || queueNumber < 1)
{
NSBeep();
queueNumber = [fDefaults integerForKey: @"QueueDownloadNumber"];
[sender setIntValue: queueNumber];
}
else
[fDefaults setInteger: queueNumber forKey: @"QueueDownloadNumber"];
[[NSNotificationCenter defaultCenter] postNotificationName: @"GlobalStartSettingChange" object: self];
}
- (void) setMoveTorrent: (id) sender
{
int state = [sender state];
if (sender == fCopyTorrentCheck)
{
[fDefaults setBool: state forKey: @"SavePrivateTorrent"];
[fDeleteOriginalTorrentCheck setEnabled: state];
if (state == NSOffState)
{
[fDeleteOriginalTorrentCheck setState: NSOffState];
[fDefaults setBool: NO forKey: @"DeleteOriginalTorrent"];
}
}
else
[fDefaults setBool: state forKey: @"DeleteOriginalTorrent"];
}
- (void) setDownloadLocation: (id) sender
{
//Download folder
//download folder
switch ([fFolderPopUp indexOfSelectedItem])
{
case DOWNLOAD_FOLDER:
@@ -877,14 +440,12 @@
- (void) setAutoImport: (id) sender
{
int state = [fAutoImportCheck state];
[fDefaults setBool: state forKey: @"AutoImport"];
[fImportFolderPopUp setEnabled: state];
if (state == NSOnState)
[[UKKQueue sharedFileWatcher] addPath: fImportFolder];
if ([fDefaults boolForKey: @"AutoImport"])
[[UKKQueue sharedFileWatcher] addPath:
[[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
else
[[UKKQueue sharedFileWatcher] removePathFromQueue: fImportFolder];
[[UKKQueue sharedFileWatcher] removePathFromQueue:
[[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
[[NSNotificationCenter defaultCenter] postNotificationName: @"AutoImportSettingChange" object: self];
}
@@ -906,8 +467,6 @@
- (void) setAutoSize: (id) sender
{
[fDefaults setBool: [sender state] forKey: @"AutoSize"];
[[NSNotificationCenter defaultCenter] postNotificationName: @"AutoSizeSettingChange" object: self];
}
@@ -974,11 +533,8 @@
{
if (code == NSOKButton)
{
[fDownloadFolder release];
fDownloadFolder = [[[openPanel filenames] objectAtIndex: 0] retain];
[fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
[fDefaults setObject: fDownloadFolder forKey: @"DownloadFolder"];
[fDefaults setObject: [[openPanel filenames] objectAtIndex: 0] forKey: @"DownloadFolder"];
[fDefaults setObject: @"Constant" forKey: @"DownloadChoice"];
[self updatePopUp];
@@ -999,13 +555,14 @@
- (void) updatePopUp
{
//get and resize the icon
NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFile: fDownloadFolder];
NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFile:
[[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath]];
[icon setScalesWhenResized: YES];
[icon setSize: NSMakeSize(16.0, 16.0)];
//update menu item
NSMenuItem * menuItem = (NSMenuItem *) [fFolderPopUp itemAtIndex: 0];
[menuItem setTitle: [fDownloadFolder lastPathComponent]];
[menuItem setTitle: [[fDefaults stringForKey: @"DownloadFolder"] lastPathComponent]];
[menuItem setImage: icon];
}
@@ -1014,16 +571,13 @@
if (code == NSOKButton)
{
UKKQueue * sharedQueue = [UKKQueue sharedFileWatcher];
[sharedQueue removePathFromQueue: fImportFolder];
[sharedQueue removePathFromQueue: [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
[fImportFolder release];
fImportFolder = [[[openPanel filenames] objectAtIndex: 0] retain];
[fDefaults setObject: fImportFolder forKey: @"AutoImportDirectory"];
[fDefaults setObject: [[openPanel filenames] objectAtIndex: 0] forKey: @"AutoImportDirectory"];
[self updateImportPopUp];
[sharedQueue addPath: fImportFolder];
[sharedQueue addPath: [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
[[NSNotificationCenter defaultCenter] postNotificationName: @"AutoImportSettingChange" object: self];
}
@@ -1033,13 +587,14 @@
- (void) updateImportPopUp
{
//get and resize the icon
NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFile: fImportFolder];
NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFile:
[[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
[icon setScalesWhenResized: YES];
[icon setSize: NSMakeSize(16.0, 16.0)];
//update menu item
NSMenuItem * menuItem = (NSMenuItem *) [fImportFolderPopUp itemAtIndex: 0];
[menuItem setTitle: [fImportFolder lastPathComponent]];
[menuItem setTitle: [[fDefaults stringForKey: @"AutoImportDirectory"] lastPathComponent]];
[menuItem setImage: icon];
}