Changeset 1034


Ignore:
Timestamp:
Oct 27, 2006, 7:14:04 PM (15 years ago)
Author:
livings124
Message:

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.

Location:
trunk
Files:
4 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Transmission.xcodeproj/project.pbxproj

    r1026 r1034  
    9393                A2173E1C0A33C1B300B0D8AB /* ActionButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = A2173E1B0A33C1B300B0D8AB /* ActionButtonPressed.png */; };
    9494                A21DFF100A292B2B007C5F76 /* Transfers.png in Resources */ = {isa = PBXBuildFile; fileRef = A21DFF0F0A292B2B007C5F76 /* Transfers.png */; };
     95                A21F5B890AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = A21F5B870AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m */; };
     96                A21F5C040AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = A21F5C020AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m */; };
    9597                A22A8D560AEEAFA5007E9CB9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A22A8D540AEEAFA5007E9CB9 /* Localizable.strings */; };
    9698                A2305A800A3DC9E400AB2D77 /* ProgressBarWhite.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305A7C0A3DC9E400AB2D77 /* ProgressBarWhite.png */; };
     
    288290                4DCCBB3C09C3D71100D3CABF /* TorrentCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = TorrentCell.m; path = macosx/TorrentCell.m; sourceTree = "<group>"; };
    289291                4DCCBB3D09C3D71100D3CABF /* TorrentCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = TorrentCell.h; path = macosx/TorrentCell.h; sourceTree = "<group>"; };
    290                 4DDBB71909E16BAE00284745 /* transmissioncli */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = transmissioncli; sourceTree = BUILT_PRODUCTS_DIR; };
     292                4DDBB71909E16BAE00284745 /* transmissioncli */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = transmissioncli; sourceTree = BUILT_PRODUCTS_DIR; };
    291293                4DDBB71B09E16BF100284745 /* transmissioncli.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = transmissioncli.c; path = cli/transmissioncli.c; sourceTree = "<group>"; };
    292294                4DDFDD20099A5D8E00189D81 /* DownloadBadge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = DownloadBadge.png; path = macosx/Images/DownloadBadge.png; sourceTree = "<group>"; };
     
    318320                A2173E1B0A33C1B300B0D8AB /* ActionButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ActionButtonPressed.png; path = macosx/Images/ActionButtonPressed.png; sourceTree = "<group>"; };
    319321                A21DFF0F0A292B2B007C5F76 /* Transfers.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Transfers.png; path = macosx/Images/Transfers.png; sourceTree = "<group>"; };
     322                A21F5B860AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ActionMenuRatioToDisplayRatioTransformer.h; path = macosx/ActionMenuRatioToDisplayRatioTransformer.h; sourceTree = "<group>"; };
     323                A21F5B870AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ActionMenuRatioToDisplayRatioTransformer.m; path = macosx/ActionMenuRatioToDisplayRatioTransformer.m; sourceTree = "<group>"; };
     324                A21F5C010AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ActionMenuSpeedToDisplayLimitTransformer.h; path = macosx/ActionMenuSpeedToDisplayLimitTransformer.h; sourceTree = "<group>"; };
     325                A21F5C020AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ActionMenuSpeedToDisplayLimitTransformer.m; path = macosx/ActionMenuSpeedToDisplayLimitTransformer.m; sourceTree = "<group>"; };
    320326                A22A8D550AEEAFA5007E9CB9 /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = macosx/English.lproj/Localizable.strings; sourceTree = "<group>"; };
    321327                A2305A7C0A3DC9E400AB2D77 /* ProgressBarWhite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarWhite.png; path = macosx/Images/ProgressBarWhite.png; sourceTree = "<group>"; };
     
    425431                        isa = PBXGroup;
    426432                        children = (
     433                                A21F5C010AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.h */,
     434                                A21F5C020AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m */,
     435                                A21F5B860AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.h */,
     436                                A21F5B870AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m */,
    427437                                A2A306530AAD24A80049E2AC /* UKFileWatcher.h */,
    428438                                A2A306540AAD24A80049E2AC /* UKFileWatcher.m */,
     
    923933                                A29C8B370ACC6EB3000ED9F9 /* PortChecker.m in Sources */,
    924934                                A2AA579D0ADFCAB400CA59F6 /* PiecesImageView.m in Sources */,
     935                                A21F5B890AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m in Sources */,
     936                                A21F5C040AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m in Sources */,
    925937                        );
    926938                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/macosx/Controller.h

    r1030 r1034  
    164164- (void) setLimitGlobalEnabled: (id) sender;
    165165- (void) setQuickLimitGlobal: (id) sender;
    166 - (void) limitGlobalChange: (NSNotification *) notification;
    167 
    168 - (void) setRatioGlobalEnabled: (id) sender;
     166
    169167- (void) setQuickRatioGlobal: (id) sender;
    170 - (void) ratioGlobalChange: (NSNotification *) notification;
    171168
    172169- (void) checkWaitingForStopped: (NSNotification *) notification;
  • trunk/macosx/Controller.m

    r1030 r1034  
    3131#import "StringAdditions.h"
    3232#import "UKKQueue.h"
     33#import "ActionMenuSpeedToDisplayLimitTransformer.h"
     34#import "ActionMenuRatioToDisplayRatioTransformer.h"
    3335
    3436#import <Sparkle/Sparkle.h>
     
    7274    [[NSUserDefaults standardUserDefaults] registerDefaults: [NSDictionary dictionaryWithContentsOfFile:
    7375        [[NSBundle mainBundle] pathForResource: @"Defaults" ofType: @"plist"]]];
     76   
     77    //set custom value transformers
     78    ActionMenuSpeedToDisplayLimitTransformer * limitTransformer =
     79                        [[[ActionMenuSpeedToDisplayLimitTransformer alloc] init] autorelease];
     80    [NSValueTransformer setValueTransformer: limitTransformer forName: @"ActionMenuSpeedToDisplayLimitTransformer"];
     81   
     82    ActionMenuRatioToDisplayRatioTransformer * ratioTransformer =
     83                        [[[ActionMenuRatioToDisplayRatioTransformer alloc] init] autorelease];
     84    [NSValueTransformer setValueTransformer: ratioTransformer forName: @"ActionMenuRatioToDisplayRatioTransformer"];
    7485}
    7586
     
    281292    [currentFilterButton setEnabled: YES];
    282293   
    283     //set upload limit action button
    284     [fUploadLimitItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Limit (%d KB/s)",
    285                     "Action context menu -> upload limit"), [fDefaults integerForKey: @"UploadLimit"]]];
    286     if ([fDefaults boolForKey: @"CheckUpload"])
    287         [fUploadLimitItem setState: NSOnState];
    288     else
    289         [fUploadNoLimitItem setState: NSOnState];
    290 
    291         //set download limit action menu
    292     [fDownloadLimitItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Limit (%d KB/s)",
    293                     "Action context menu -> download limit"), [fDefaults integerForKey: @"DownloadLimit"]]];
    294     if ([fDefaults boolForKey: @"CheckDownload"])
    295         [fDownloadLimitItem setState: NSOnState];
    296     else
    297         [fDownloadNoLimitItem setState: NSOnState];
    298    
    299     //set ratio action menu
    300     [fRatioSetItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Stop at Ratio (%.2f)",
    301                                 "Action context menu -> ratio stop"), [fDefaults floatForKey: @"RatioLimit"]]];
    302     if ([fDefaults boolForKey: @"RatioCheck"])
    303         [fRatioSetItem setState: NSOnState];
    304     else
    305         [fRatioNotSetItem setState: NSOnState];
    306    
    307294    //observe notifications
    308295    NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
     
    317304                    name: SUUpdaterWillRestartNotification object: nil];
    318305    fUpdateInProgress = NO;
    319    
    320     [nc addObserver: self selector: @selector(limitGlobalChange:)
    321                     name: @"LimitGlobalChange" object: nil];
    322    
    323     [nc addObserver: self selector: @selector(ratioGlobalChange:)
    324                     name: @"RatioGlobalChange" object: nil];
    325306   
    326307    [nc addObserver: self selector: @selector(autoSpeedLimitChange:)
     
    13191300        : ([NSColor currentControlTint] == NSBlueControlTint ? fSpeedLimitBlueImage : fSpeedLimitGraphiteImage)];
    13201301   
    1321     [fPrefsController enableSpeedLimit: fSpeedLimitEnabled];
     1302    [fPrefsController applySpeedSettings: nil];
    13221303}
    13231304
     
    13631344}
    13641345
     1346#warning get rid of
    13651347- (void) setLimitGlobalEnabled: (id) sender
    13661348{
    1367     [fPrefsController setQuickLimitEnabled: (sender == fUploadLimitItem || sender == fDownloadLimitItem)
    1368         type: (sender == fUploadLimitItem || sender == fUploadNoLimitItem) ? @"Upload" : @"Download"];
     1349    [fPrefsController applySpeedSettings: nil];
    13691350}
    13701351
    13711352- (void) setQuickLimitGlobal: (id) sender
    13721353{
    1373     [fPrefsController setQuickLimit: [[sender title] intValue]
    1374         type: [sender menu] == fUploadMenu ? @"Upload" : @"Download"];
    1375 }
    1376 
    1377 - (void) limitGlobalChange: (NSNotification *) notification
    1378 {
    1379     NSMenuItem * limitItem, * noLimitItem;
    1380     BOOL enable;
    1381     int limit;
    1382     if ([[notification object] boolValue])
    1383     {
    1384         limitItem = fUploadLimitItem;
    1385         noLimitItem = fUploadNoLimitItem;
    1386        
    1387         enable = [fDefaults boolForKey: @"CheckUpload"];
    1388         limit = [fDefaults integerForKey: @"UploadLimit"];
    1389     }
    1390     else
    1391     {
    1392         limitItem = fDownloadLimitItem;
    1393         noLimitItem = fDownloadNoLimitItem;
    1394        
    1395         enable = [fDefaults boolForKey: @"CheckDownload"];
    1396         limit = [fDefaults integerForKey: @"DownloadLimit"];
    1397     }
    1398    
    1399     [limitItem setState: enable ? NSOnState : NSOffState];
    1400     [noLimitItem setState: !enable ? NSOnState : NSOffState];
    1401    
    1402     [limitItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Limit (%d KB/s)",
    1403                             "Action context menu -> upload/download limit"), limit]];
    1404    
    1405     [[notification object] release];
    1406 }
    1407 
    1408 - (void) setRatioGlobalEnabled: (id) sender
    1409 {
    1410     [fPrefsController setQuickRatioEnabled: sender == fRatioSetItem];
     1354    [fDefaults setInteger: [[sender title] intValue] forKey: [sender menu] == fUploadMenu ? @"UploadLimit" : @"DownloadLimit"];
     1355    [fDefaults setBool: YES forKey: [sender menu] == fUploadMenu ? @"CheckUpload" : @"CheckDownload"];
     1356   
     1357    [fPrefsController applySpeedSettings: nil];
    14111358}
    14121359
    14131360- (void) setQuickRatioGlobal: (id) sender
    14141361{
    1415     [fPrefsController setQuickRatio: [[sender title] floatValue]];
    1416 }
    1417 
    1418 - (void) ratioGlobalChange: (NSNotification *) notification
    1419 {
    1420     BOOL enable = [fDefaults boolForKey: @"RatioCheck"];
    1421     [fRatioSetItem setState: enable ? NSOnState : NSOffState];
    1422     [fRatioNotSetItem setState: !enable ? NSOnState : NSOffState];
    1423    
    1424     [fRatioSetItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Stop at Ratio (%.2f)",
    1425                                 "Action context menu -> ratio stop"), [fDefaults floatForKey: @"RatioLimit"]]];
     1362    [fDefaults setBool: YES forKey: @"RatioCheck"];
     1363    [fDefaults setFloat: [[sender title] floatValue] forKey: @"RatioLimit"];
    14261364}
    14271365
  • trunk/macosx/English.lproj/MainMenu.nib/classes.nib

    r1030 r1034  
    2323                setQuickLimitGlobal = id;
    2424                setQuickRatioGlobal = id;
    25                 setRatioGlobalEnabled = id;
    2625                setSort = id;
    2726                showInfo = id;
  • trunk/macosx/English.lproj/MainMenu.nib/info.nib

    r1030 r1034  
    88        <dict>
    99                <key>1041</key>
    10                 <string>379 362 208 130 0 0 1024 746 </string>
     10                <string>438 418 208 130 0 0 1152 842 </string>
    1111                <key>1480</key>
    1212                <string>366 546 420 63 0 0 1152 842 </string>
     
    2828        <key>IBOldestOS</key>
    2929        <integer>3</integer>
    30         <key>IBOpenObjects</key>
    31         <array>
    32                 <integer>29</integer>
    33                 <integer>21</integer>
    34         </array>
    3530        <key>IBSystem Version</key>
    3631        <string>8L127</string>
  • trunk/macosx/English.lproj/PrefsWindow.nib/classes.nib

    r1030 r1034  
    66        {
    77            ACTIONS = {
     8                applySpeedSettings = id;
    89                folderSheetShow = id;
    910                helpForNetwork = id;
     
    1516                setBadge = id;
    1617                setDownloadLocation = id;
    17                 setLimit = id;
    18                 setLimitCheck = id;
    19                 setMoveTorrent = id;
    2018                setNat = id;
    21                 setPlaySound = id;
    2219                setPort = id;
    2320                setQueueNumber = id;
    24                 setRatio = id;
    25                 setRatioCheck = id;
    26                 setShowMessage = id;
    2721                setSound = id;
    28                 setSpeedLimit = id;
    29                 setStartAtOpen = id;
    3022                setUpdate = id;
    31                 setUseQueue = id;
    3223            };
    3324            CLASS = PrefsController;
    3425            LANGUAGE = ObjC;
    3526            OUTLETS = {
    36                 fAutoImportCheck = NSButton;
    37                 fAutoSizeCheck = NSButton;
    38                 fBadgeDownloadRateCheck = NSButton;
    39                 fBadgeUploadRateCheck = NSButton;
    4027                fBandwidthView = NSView;
    41                 fCopyTorrentCheck = NSButton;
    42                 fDeleteOriginalTorrentCheck = NSButton;
    4328                fDownloadCheck = NSButton;
    4429                fDownloadField = NSTextField;
     
    5136                fNatStatusImage = NSImageView;
    5237                fNetworkView = NSView;
    53                 fPlayDownloadSoundCheck = NSButton;
    54                 fPlaySeedingSoundCheck = NSButton;
    55                 fPortField = NSTextField;
    5638                fPortStatusField = NSTextField;
    5739                fPortStatusImage = NSImageView;
    5840                fPortStatusProgress = NSProgressIndicator;
    59                 fQueueCheck = NSButton;
    60                 fQueueNumberField = NSTextField;
    61                 fQuitCheck = NSButton;
    62                 fQuitDownloadingCheck = NSButton;
    63                 fRatioCheck = NSButton;
    64                 fRatioField = NSTextField;
    65                 fRemoveCheck = NSButton;
    66                 fRemoveDownloadingCheck = NSButton;
    6741                fSeedingSoundPopUp = NSPopUpButton;
    68                 fSpeedLimitAutoCheck = NSButton;
    69                 fSpeedLimitAutoOffField = NSTextField;
    70                 fSpeedLimitAutoOnField = NSTextField;
    7142                fSpeedLimitDownloadField = NSTextField;
    7243                fSpeedLimitUploadField = NSTextField;
    73                 fStartAtOpenCheck = NSButton;
    7444                fTransfersView = NSView;
    7545                fUpdatePopUp = NSPopUpButton;
  • trunk/macosx/English.lproj/PrefsWindow.nib/info.nib

    r1030 r1034  
    88        <dict>
    99                <key>153</key>
    10                 <string>30 315 577 267 0 0 1024 746 </string>
     10                <string>294 445 563 267 0 0 1152 842 </string>
    1111                <key>28</key>
    12                 <string>22 331 577 290 0 0 1024 746 </string>
     12                <string>294 434 563 290 0 0 1152 842 </string>
    1313                <key>41</key>
    14                 <string>213 415 563 317 0 0 1152 842 </string>
     14                <string>294 420 563 317 0 0 1152 842 </string>
    1515                <key>66</key>
    1616                <string>294 507 563 144 0 0 1152 842 </string>
     
    2222                <integer>253</integer>
    2323        </array>
     24        <key>IBOpenObjects</key>
     25        <array>
     26                <integer>153</integer>
     27        </array>
    2428        <key>IBSystem Version</key>
    2529        <string>8L127</string>
  • trunk/macosx/InfoWindowController.m

    r1026 r1034  
    558558- (void) revealTorrentFile: (id) sender
    559559{
    560     [[fTorrents objectAtIndex: 0] revealPublicTorrent];
     560    if ([fTorrents count] > 0)
     561        [[fTorrents objectAtIndex: 0] revealPublicTorrent];
    561562}
    562563
    563564- (void) revealDataFile: (id) sender
    564565{
    565     [[fTorrents objectAtIndex: 0] revealData];
     566    if ([fTorrents count] > 0)
     567        [[fTorrents objectAtIndex: 0] revealData];
    566568}
    567569
  • trunk/macosx/PrefsController.h

    r1030 r1034  
    3232    tr_handle_t * fHandle;
    3333   
     34    NSUserDefaults          * fDefaults;
     35   
    3436    NSToolbar               * fToolbar;
    3537    IBOutlet NSView         * fGeneralView, * fTransfersView, * fBandwidthView, * fNetworkView;
     
    3739    IBOutlet NSPopUpButton  * fFolderPopUp, * fImportFolderPopUp,
    3840                            * fDownloadSoundPopUp, * fSeedingSoundPopUp;
    39     IBOutlet NSButton       * fQuitCheck, * fRemoveCheck,
    40                             * fQuitDownloadingCheck, * fRemoveDownloadingCheck,
    41                             * fBadgeDownloadRateCheck, * fBadgeUploadRateCheck,
    42                             * fPlayDownloadSoundCheck, * fPlaySeedingSoundCheck,
    43                             * fCopyTorrentCheck, * fDeleteOriginalTorrentCheck,
    44                             * fAutoImportCheck, * fAutoSizeCheck;
    4541   
    4642    SUUpdater               * fUpdater;
     
    4844
    4945    IBOutlet NSTextField    * fUploadField, * fDownloadField,
    50                             * fSpeedLimitUploadField, * fSpeedLimitDownloadField,
    51                             * fSpeedLimitAutoOnField, * fSpeedLimitAutoOffField;
    52     IBOutlet NSButton       * fUploadCheck, * fDownloadCheck,
    53                             * fSpeedLimitAutoCheck;
     46                            * fSpeedLimitUploadField, * fSpeedLimitDownloadField;
     47    IBOutlet NSButton       * fUploadCheck, * fDownloadCheck;
    5448
    55     IBOutlet NSTextField            * fPortField, * fNatStatusField, * fPortStatusField;
     49    IBOutlet NSTextField            * fNatStatusField,
     50                                    * fPortStatusField;
    5651    IBOutlet NSButton               * fNatCheck;
    5752    IBOutlet NSImageView            * fNatStatusImage, * fPortStatusImage;
     
    5954    NSTimer                         * fNatStatusTimer;
    6055    int                             fNatStatus;
    61    
    62     IBOutlet NSButton       * fRatioCheck;
    63     IBOutlet NSTextField    * fRatioField;
    64    
    65     IBOutlet NSButton       * fQueueCheck, * fStartAtOpenCheck;
    66     IBOutlet NSTextField    * fQueueNumberField;
    67 
    68     NSString                * fDownloadFolder, * fImportFolder;
    69     NSUserDefaults          * fDefaults;
    7056}
    7157
     
    7359- (void) setUpdater: (SUUpdater *) updater;
    7460
    75 - (void) setShowMessage:    (id) sender;
    7661- (void) setBadge:          (id) sender;
    77 - (void) setPlaySound:      (id) sender;
    7862- (void) setSound:          (id) sender;
    7963- (void) setUpdate:         (id) sender;
    8064
    81 - (void) setStartAtOpen:    (id) sender;
    82 
    83 - (void) setUseQueue:       (id) sender;
    8465- (void) setQueueNumber:    (id) sender;
    8566
    86 - (void) setMoveTorrent:        (id) sender;
    8767- (void) setDownloadLocation:   (id) sender;
    8868- (void) folderSheetShow:       (id) sender;
     
    9474- (void) updateNatStatus;
    9575
    96 - (void) setSpeedLimit: (id) sender;
    97 
    9876- (void) setAutoSpeedLimitCheck: (id) sender;
    9977- (void) setAutoSpeedLimitHour: (id) sender;
    10078
    101 - (void) setLimit:          (id) sender;
    102 - (void) setLimitCheck:     (id) sender;
    103 - (void) setQuickLimitEnabled:   (BOOL) enable type: (NSString *) type;
    104 - (void) setQuickLimit:     (int) limit type: (NSString *) type;
    105 
    106 - (void) enableSpeedLimit: (BOOL) enable;
     79- (void) applySpeedSettings: (id) sender;
    10780
    10881- (void) setAutoImport: (id) sender;
     
    11184- (void) setAutoSize: (id) sender;
    11285
    113 - (void) setRatio:          (id) sender;
    114 - (void) setRatioCheck:     (id) sender;
    115 - (void) setQuickRatioEnabled:   (BOOL) enable;
    116 - (void) setQuickRatio: (float) ratioLimit;
    117 
    11886- (void) helpForNetwork: (id) sender;
    11987
  • trunk/macosx/PrefsController.m

    r1033 r1034  
    2727#import "UKKQueue.h"
    2828
    29 #define MIN_PORT    1
    30 #define MAX_PORT    65535
    31 
    3229#define DOWNLOAD_FOLDER     0
    3330#define DOWNLOAD_TORRENT    2
     
    7168        }
    7269       
    73         //set download folder and import folder
    74         fDownloadFolder = [[[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath] retain];
    75         fImportFolder = [[[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath] retain];
    76        
    7770        //set auto import
    7871        if ([fDefaults boolForKey: @"AutoImport"])
    79             [[UKKQueue sharedFileWatcher] addPath: fImportFolder];
     72            [[UKKQueue sharedFileWatcher] addPath:
     73                [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
    8074       
    8175        //set bind port
     
    8882       
    8983        //actually set bandwidth limits
    90         if ([fDefaults boolForKey: @"SpeedLimit"])
    91         {
    92             tr_setUploadLimit(fHandle, [fDefaults integerForKey: @"SpeedLimitUploadLimit"]);
    93             tr_setDownloadLimit(fHandle, [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]);
    94         }
    95         else
    96         {
    97             tr_setUploadLimit(fHandle, [fDefaults boolForKey: @"CheckUpload"]
    98                                             ? [fDefaults integerForKey: @"UploadLimit"] : -1);
    99             tr_setDownloadLimit(fHandle, [fDefaults boolForKey: @"CheckDownload"]
    100                                             ? [fDefaults integerForKey: @"DownloadLimit"] : -1);
    101         }
     84        [self applySpeedSettings: nil];
    10285    }
    10386    return self;
     
    10891    if (fNatStatusTimer)
    10992        [fNatStatusTimer invalidate];
    110 
    111     [fDownloadFolder release];
    112     [fImportFolder release];
     93   
    11394    [super dealloc];
    11495}
     
    138119    //set auto import
    139120    [self updateImportPopUp];
    140  
    141     BOOL autoImport = [fDefaults boolForKey: @"AutoImport"];
    142     [fAutoImportCheck setState: autoImport];
    143     [fImportFolderPopUp setEnabled: autoImport];
    144    
    145     //set auto size
    146     [fAutoSizeCheck setState: [fDefaults boolForKey: @"AutoSize"]];
    147    
    148     //set bind port
    149     int bindPort = [fDefaults integerForKey: @"BindPort"];
    150     [fPortField setIntValue: bindPort];
     121   
    151122    [self updatePortStatus];
    152    
    153     //set NAT
    154     [fNatCheck setState: [fDefaults boolForKey: @"NatTraversal"]];
    155123   
    156124    fNatStatus = -1;
     
    158126    fNatStatusTimer = [NSTimer scheduledTimerWithTimeInterval: 5.0 target: self
    159127                        selector: @selector(updateNatStatus) userInfo: nil repeats: YES];
    160    
    161     //set upload limit
    162     BOOL checkUpload = [fDefaults boolForKey: @"CheckUpload"];
    163     [fUploadCheck setState: checkUpload];
    164     [fUploadField setIntValue: [fDefaults integerForKey: @"UploadLimit"]];
    165     [fUploadField setEnabled: checkUpload];
    166 
    167         //set download limit
    168     BOOL checkDownload = [fDefaults boolForKey: @"CheckDownload"];
    169     [fDownloadCheck setState: checkDownload];
    170     [fDownloadField setIntValue: [fDefaults integerForKey: @"DownloadLimit"]];
    171     [fDownloadField setEnabled: checkDownload];
    172    
    173     //set speed limit
    174     [fSpeedLimitUploadField setIntValue: [fDefaults integerForKey: @"SpeedLimitUploadLimit"]];
    175     [fSpeedLimitDownloadField setIntValue: [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]];
    176    
    177     //set auto speed limit
    178     BOOL speedLimitAuto = [fDefaults boolForKey: @"SpeedLimitAuto"];
    179     [fSpeedLimitAutoCheck setState: speedLimitAuto];
    180    
    181     int speedLimitAutoOnHour = [fDefaults integerForKey: @"SpeedLimitAutoOnHour"];
    182     [fSpeedLimitAutoOnField setStringValue: [NSString stringWithFormat: @"%02d", speedLimitAutoOnHour]];
    183     [fSpeedLimitAutoOnField setEnabled: speedLimitAuto];
    184    
    185     int speedLimitAutoOffHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"];
    186     [fSpeedLimitAutoOffField setStringValue: [NSString stringWithFormat: @"%02d", speedLimitAutoOffHour]];
    187     [fSpeedLimitAutoOffField setEnabled: speedLimitAuto];
    188    
    189     //set ratio limit
    190     BOOL ratioCheck = [fDefaults boolForKey: @"RatioCheck"];
    191     [fRatioCheck setState: ratioCheck];
    192     [fRatioField setEnabled: ratioCheck];
    193     [fRatioField setFloatValue: [fDefaults floatForKey: @"RatioLimit"]];
    194    
    195     //set remove and quit prompts
    196     BOOL isQuitCheck = [fDefaults boolForKey: @"CheckQuit"],
    197         isRemoveCheck = [fDefaults boolForKey: @"CheckRemove"];
    198    
    199     [fQuitCheck setState: isQuitCheck];
    200     [fRemoveCheck setState: isRemoveCheck];
    201    
    202     [fQuitDownloadingCheck setState: [fDefaults boolForKey: @"CheckQuitDownloading"]];
    203     [fQuitDownloadingCheck setEnabled: isQuitCheck];
    204     [fRemoveDownloadingCheck setState: [fDefaults boolForKey: @"CheckRemoveDownloading"]];
    205     [fRemoveDownloadingCheck setEnabled: isRemoveCheck];
    206 
    207     //set dock badging
    208     [fBadgeDownloadRateCheck setState: [fDefaults boolForKey: @"BadgeDownloadRate"]];
    209     [fBadgeUploadRateCheck setState: [fDefaults boolForKey: @"BadgeUploadRate"]];
    210128   
    211129    //set play sound
     
    232150    [fDownloadSoundPopUp addItemsWithTitles: sounds];
    233151   
    234     BOOL playDownloadSound = [fDefaults boolForKey: @"PlayDownloadSound"];
    235     [fPlayDownloadSoundCheck setState: playDownloadSound];
    236     [fDownloadSoundPopUp setEnabled: playDownloadSound];
    237    
    238152    int downloadSoundIndex = [fDownloadSoundPopUp indexOfItemWithTitle: [fDefaults stringForKey: @"DownloadSound"]];
    239153    if (downloadSoundIndex >= 0)
     
    246160    [fSeedingSoundPopUp addItemsWithTitles: sounds];
    247161   
    248     BOOL playSeedingSound = [fDefaults boolForKey: @"PlaySeedingSound"];
    249     [fPlaySeedingSoundCheck setState: playSeedingSound];
    250     [fSeedingSoundPopUp setEnabled: playSeedingSound];
    251    
    252162    int seedingSoundIndex = [fDownloadSoundPopUp indexOfItemWithTitle: [fDefaults stringForKey: @"SeedingSound"]];
    253163    if (seedingSoundIndex >= 0)
     
    255165    else
    256166        [fDefaults setObject: [fSeedingSoundPopUp titleOfSelectedItem] forKey: @"SeedingSound"];
    257    
    258     //set start settings
    259     BOOL useQueue = [fDefaults boolForKey: @"Queue"];
    260     [fQueueCheck setState: useQueue];
    261     [fQueueNumberField setEnabled: useQueue];
    262     [fQueueNumberField setIntValue: [fDefaults integerForKey: @"QueueDownloadNumber"]];
    263    
    264     [fStartAtOpenCheck setState: [fDefaults boolForKey: @"AutoStartDownload"]];
    265    
    266     //set private torrents
    267     BOOL copyTorrents = [fDefaults boolForKey: @"SavePrivateTorrent"];
    268     [fCopyTorrentCheck setState: copyTorrents];
    269    
    270     [fDeleteOriginalTorrentCheck setEnabled: copyTorrents];
    271     [fDeleteOriginalTorrentCheck setState: [fDefaults boolForKey: @"DeleteOriginalTorrent"]];
    272167
    273168    //set update check
     
    286181}
    287182
    288 - (NSToolbarItem *) toolbar: (NSToolbar *) t itemForItemIdentifier:
    289     (NSString *) ident willBeInsertedIntoToolbar: (BOOL) flag
     183- (NSToolbarItem *) toolbar: (NSToolbar *) toolbar itemForItemIdentifier: (NSString *) ident
     184                    willBeInsertedIntoToolbar: (BOOL) flag
    290185{
    291186    NSToolbarItem * item;
     
    347242- (void) setPort: (id) sender
    348243{
    349     int bindPort = [sender intValue];
    350     if (![[NSString stringWithInt: bindPort] isEqualToString: [sender stringValue]]
    351             || bindPort < MIN_PORT || bindPort > MAX_PORT)
    352     {
    353         NSBeep();
    354         bindPort = [fDefaults integerForKey: @"BindPort"];
    355         [sender setIntValue: bindPort];
    356     }
    357     else
    358     {
    359         tr_setBindPort(fHandle, bindPort);
    360         [fDefaults setInteger: bindPort forKey: @"BindPort"];
    361        
    362         [self updateNatStatus];
    363         [self updatePortStatus];
    364     }
     244    tr_setBindPort(fHandle, [fDefaults integerForKey: @"BindPort"]);
     245    [self updateNatStatus];
     246    [self updatePortStatus];
    365247}
    366248
     
    413295- (void) setNat: (id) sender
    414296{
    415     BOOL enable = [sender state] == NSOnState;
    416     enable ? tr_natTraversalEnable(fHandle) : tr_natTraversalDisable(fHandle);
    417     [fDefaults setBool: enable forKey: @"NatTraversal"];
    418    
     297    [fDefaults boolForKey: @"NatTraversal"] ? tr_natTraversalEnable(fHandle) : tr_natTraversalDisable(fHandle);
    419298    [self updateNatStatus];
    420299}
     
    448327}
    449328
    450 - (void) setLimit: (id) sender
    451 {
    452     NSString * key;
    453     NSButton * check;
    454     NSString * type;
    455     if (sender == fUploadField)
    456     {
    457         key = @"UploadLimit";
    458         check = fUploadCheck;
    459         type = @"Upload";
    460     }
    461     else
    462     {
    463         key = @"DownloadLimit";
    464         check = fDownloadCheck;
    465         type = @"Download";
    466     }
    467 
    468     int limit = [sender intValue];
    469     if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", limit]] || limit < 0)
    470     {
    471         NSBeep();
    472         limit = [fDefaults integerForKey: key];
    473         [sender setIntValue: limit];
    474     }
    475     else
    476     {
    477         if (![fDefaults boolForKey: @"SpeedLimit"])
    478         {
    479             int realLimit = [check state] ? limit : -1;
    480             if (sender == fUploadField)
    481                 tr_setUploadLimit(fHandle, realLimit);
    482             else
    483                 tr_setDownloadLimit(fHandle, realLimit);
    484         }
    485        
    486         [fDefaults setInteger: limit forKey: key];
    487     }
    488    
    489     [[NSNotificationCenter defaultCenter] postNotificationName: @"LimitGlobalChange"
    490                                             object: [[NSNumber alloc] initWithBool: sender == fUploadField]];
    491 }
    492 
    493 - (void) setLimitCheck: (id) sender
    494 {
    495     NSString * key;
    496     NSTextField * field;
    497     if (sender == fUploadCheck)
    498     {
    499         key = @"CheckUpload";
    500         field = fUploadField;
    501     }
    502     else
    503     {
    504         key = @"CheckDownload";
    505         field = fDownloadField;
    506     }
    507    
    508     BOOL check = [sender state] == NSOnState;
    509     [fDefaults setBool: check forKey: key];
    510    
    511     [self setLimit: field];
    512     [field setEnabled: check];
    513 }
    514 
    515 - (void) setQuickLimitEnabled: (BOOL) enable type: (NSString *) type
    516 {
    517     //if interface is loaded, perform change as if user performed it
    518     #warning better way?
    519     if (fToolbar)
    520     {
    521         NSButton * check = [type isEqualToString: @"Upload"] ? fUploadCheck : fDownloadCheck;
    522         [check setState: enable ? NSOnState : NSOffState];
    523         [self setLimitCheck: check];
    524     }
    525     else
    526     {
    527         BOOL upload = [type isEqualToString: @"Upload"];
    528         [fDefaults setBool: enable forKey: upload ? @"CheckUpload" : @"CheckDownload"];
    529        
    530         [[NSNotificationCenter defaultCenter] postNotificationName: @"LimitGlobalChange"
    531                                                 object: [[NSNumber alloc] initWithBool: upload]];
    532     }
    533 }
    534 
    535 - (void) setQuickLimit: (int) limit type: (NSString *) type
    536 {
    537     //if interface is loaded, perform change as if user performed it
    538     if (fToolbar)
    539     {
    540         NSButton * check;
    541         if ([type isEqualToString: @"Upload"])
    542         {
    543             [fUploadField setIntValue: limit];
    544             check = fUploadCheck;
    545         }
    546         else
    547         {
    548             [fDownloadField setIntValue: limit];
    549             check = fDownloadCheck;
    550         }
    551         [check setState: NSOnState];
    552         [self setLimitCheck: check];
    553     }
    554     else
    555     {
    556         BOOL upload = [type isEqualToString: @"Upload"];
    557         [fDefaults setBool: YES forKey: upload ? @"CheckUpload" : @"CheckDownload"];
    558         [fDefaults setInteger: limit forKey: upload ? @"UploadLimit" : @"DownloadLimit"];
    559        
    560         [[NSNotificationCenter defaultCenter] postNotificationName: @"LimitGlobalChange"
    561                                                 object: [[NSNumber alloc] initWithBool: upload]];
    562     }
    563 }
    564 
    565 - (void) enableSpeedLimit: (BOOL) enable
    566 {
    567     if ([fDefaults boolForKey: @"SpeedLimit"] != enable)
    568     {
    569         [fDefaults setBool: enable forKey: @"SpeedLimit"];
    570        
    571         if (enable)
    572         {
    573             tr_setUploadLimit(fHandle, [fDefaults integerForKey: @"SpeedLimitUploadLimit"]);
    574             tr_setDownloadLimit(fHandle, [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]);
    575         }
    576         else
    577         {
    578             tr_setUploadLimit(fHandle, [fDefaults boolForKey: @"CheckUpload"]
     329- (void) applySpeedSettings: (id) sender
     330{
     331    if ([fDefaults boolForKey: @"SpeedLimit"])
     332    {
     333        tr_setUploadLimit(fHandle, [fDefaults integerForKey: @"SpeedLimitUploadLimit"]);
     334        tr_setDownloadLimit(fHandle, [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]);
     335    }
     336    else
     337    {
     338        tr_setUploadLimit(fHandle, [fDefaults boolForKey: @"CheckUpload"]
    579339                                        ? [fDefaults integerForKey: @"UploadLimit"] : -1);
    580             tr_setDownloadLimit(fHandle, [fDefaults boolForKey: @"CheckDownload"]
    581                                             ? [fDefaults integerForKey: @"DownloadLimit"] : -1);
    582         }
    583     }
    584 }
    585 
    586 - (void) setSpeedLimit: (id) sender
    587 {
    588     NSString * key = sender == fSpeedLimitUploadField ? @"SpeedLimitUploadLimit" : @"SpeedLimitDownloadLimit";
    589 
    590     int limit = [sender intValue];
    591     if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", limit]] || limit < 0)
    592     {
    593         NSBeep();
    594         limit = [fDefaults integerForKey: key];
    595         [sender setIntValue: limit];
    596     }
    597     else
    598     {
    599         if ([fDefaults boolForKey: @"SpeedLimit"])
    600         {
    601             if (sender == fSpeedLimitUploadField)
    602                 tr_setUploadLimit(fHandle, limit);
    603             else
    604                 tr_setDownloadLimit(fHandle, limit);
    605         }
    606        
    607         [fDefaults setInteger: limit forKey: key];
     340        tr_setDownloadLimit(fHandle, [fDefaults boolForKey: @"CheckDownload"]
     341                                        ? [fDefaults integerForKey: @"DownloadLimit"] : -1);
    608342    }
    609343}
     
    611345- (void) setAutoSpeedLimitCheck: (id) sender
    612346{
    613     BOOL check = [sender state] == NSOnState;
    614    
    615     [fDefaults setBool: check forKey: @"SpeedLimitAuto"];
    616 
    617     [self setAutoSpeedLimitHour: fSpeedLimitAutoOnField];
    618     [fSpeedLimitAutoOnField setEnabled: check];
    619    
    620     [self setAutoSpeedLimitHour: fSpeedLimitAutoOffField];
    621     [fSpeedLimitAutoOffField setEnabled: check];
    622 }
    623 
     347    [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoSpeedLimitChange" object: self];
     348}
     349
     350#warning check if same value
    624351- (void) setAutoSpeedLimitHour: (id) sender
    625352{
    626     NSString * key = (sender == fSpeedLimitAutoOnField) ? @"SpeedLimitAutoOnHour" : @"SpeedLimitAutoOffHour";
    627 
    628     int hour = [sender intValue];
    629    
    630     //allow numbers under ten in the format 0x
    631     if (!([[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", hour]]
    632         || [[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%02d", hour]]) || hour < 0 || hour > 23
    633         || [fSpeedLimitAutoOnField intValue] == [fSpeedLimitAutoOffField intValue])
    634     {
    635         NSBeep();
    636         hour = [fDefaults integerForKey: key];
    637         [sender setStringValue: [NSString stringWithFormat: @"%02d", hour]];
    638     }
    639     else
    640         [fDefaults setInteger: hour forKey: key];
    641    
    642     [sender setStringValue: [NSString stringWithFormat: @"%02d", hour]]; //ensure number has 2 digits
    643    
    644353    [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoSpeedLimitChange" object: self];
    645 }
    646 
    647 - (void) setRatio: (id) sender
    648 {
    649     float ratioLimit = [sender floatValue];
    650     if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%.2f", ratioLimit]]
    651             || ratioLimit < 0)
    652     {
    653         NSBeep();
    654         ratioLimit = [fDefaults floatForKey: @"RatioLimit"];
    655         [sender setFloatValue: ratioLimit];
    656     }
    657     else
    658         [fDefaults setFloat: ratioLimit forKey: @"RatioLimit"];
    659    
    660     [[NSNotificationCenter defaultCenter] postNotificationName: @"RatioGlobalChange" object: nil];
    661 }
    662 
    663 - (void) setRatioCheck: (id) sender
    664 {
    665     BOOL check = [sender state] == NSOnState;
    666     [fDefaults setBool: check forKey: @"RatioCheck"];
    667    
    668     [self setRatio: fRatioField];
    669     [fRatioField setEnabled: check];
    670 }
    671 
    672 - (void) setQuickRatioEnabled: (BOOL) enable
    673 {
    674     //if interface is loaded, perform change as if user performed it
    675     if (fToolbar)
    676     {
    677         int state = enable ? NSOnState : NSOffState;
    678        
    679         [fRatioCheck setState: state];
    680         [self setRatioCheck: fRatioCheck];
    681     }
    682     else
    683     {
    684         [fDefaults setBool: enable forKey: @"RatioCheck"];
    685        
    686         [[NSNotificationCenter defaultCenter] postNotificationName: @"RatioGlobalChange" object: nil];
    687     }
    688 }
    689 
    690 - (void) setQuickRatio: (float) ratioLimit
    691 {
    692     //if interface is loaded, perform change as if user performed it
    693     if (fToolbar)
    694     {
    695         [fRatioField setFloatValue: ratioLimit];
    696        
    697         [fRatioCheck setState: NSOnState];
    698         [self setRatioCheck: fRatioCheck];
    699     }
    700     else
    701     {
    702         [fDefaults setBool: YES forKey: @"RatioCheck"];
    703         [fDefaults setFloat: ratioLimit forKey: @"RatioLimit"];
    704        
    705         [[NSNotificationCenter defaultCenter] postNotificationName: @"RatioGlobalChange" object: nil];
    706     }
    707 }
    708 
    709 - (void) setShowMessage: (id) sender
    710 {
    711     BOOL state = [sender state];
    712 
    713     if (sender == fQuitCheck)
    714     {
    715         [fDefaults setBool: state forKey: @"CheckQuit"];
    716         [fQuitDownloadingCheck setEnabled: state];
    717     }
    718     else if (sender == fRemoveCheck)
    719     {
    720         [fDefaults setBool: state forKey: @"CheckRemove"];
    721         [fRemoveDownloadingCheck setEnabled: state];
    722     }
    723     if (sender == fQuitDownloadingCheck)
    724         [fDefaults setBool: state forKey: @"CheckQuitDownloading"];
    725     else if (sender == fRemoveDownloadingCheck)
    726         [fDefaults setBool: state forKey: @"CheckRemoveDownloading"];
    727     else;
    728354}
    729355
    730356- (void) setBadge: (id) sender
    731357{   
    732     if (sender == fBadgeDownloadRateCheck)
    733         [fDefaults setBool: [sender state] forKey: @"BadgeDownloadRate"];
    734     else if (sender == fBadgeUploadRateCheck)
    735         [fDefaults setBool: [sender state] forKey: @"BadgeUploadRate"];
    736     else;
    737    
    738358    [[NSNotificationCenter defaultCenter] postNotificationName: @"DockBadgeChange" object: self];
    739 }
    740 
    741 - (void) setPlaySound: (id) sender
    742 {
    743     BOOL state = [sender state];
    744 
    745     if (sender == fPlayDownloadSoundCheck)
    746     {
    747         [fDownloadSoundPopUp setEnabled: state];
    748         [fDefaults setBool: state forKey: @"PlayDownloadSound"];
    749     }
    750     else if (sender == fPlaySeedingSoundCheck)
    751     {
    752         [fSeedingSoundPopUp setEnabled: state];
    753         [fDefaults setBool: state forKey: @"PlaySeedingSound"];
    754     }
    755     else;
    756359}
    757360
     
    764367        [sound play];
    765368
     369    #warning use bindings
    766370    if (sender == fDownloadSoundPopUp)
    767371        [fDefaults setObject: soundName forKey: @"DownloadSound"];
     
    797401}
    798402
    799 - (void) setStartAtOpen: (id) sender
    800 {
    801     [fDefaults setBool: [sender state] == NSOnState forKey: @"AutoStartDownload"];
    802 }
    803 
    804 - (void) setUseQueue: (id) sender
    805 {
    806     BOOL useQueue = [sender state] == NSOnState;
    807    
    808     [fDefaults setBool: useQueue forKey: @"Queue"];
    809     [self setQueueNumber: fQueueNumberField];
    810     [fQueueNumberField setEnabled: useQueue];
    811 }
    812 
     403#warning out of range/wrong value
    813404- (void) setQueueNumber: (id) sender
    814405{
    815     int queueNumber = [sender intValue];
    816     if (![[sender stringValue] isEqualToString: [NSString stringWithInt: queueNumber]] || queueNumber < 1)
    817     {
    818         NSBeep();
    819         queueNumber = [fDefaults integerForKey: @"QueueDownloadNumber"];
    820         [sender setIntValue: queueNumber];
    821     }
    822     else
    823         [fDefaults setInteger: queueNumber forKey: @"QueueDownloadNumber"];
    824    
    825406    [[NSNotificationCenter defaultCenter] postNotificationName: @"GlobalStartSettingChange" object: self];
    826407}
    827408
    828 - (void) setMoveTorrent: (id) sender
    829 {
    830     int state = [sender state];
    831     if (sender == fCopyTorrentCheck)
    832     {
    833         [fDefaults setBool: state forKey: @"SavePrivateTorrent"];
    834        
    835         [fDeleteOriginalTorrentCheck setEnabled: state];
    836         if (state == NSOffState)
    837         {
    838             [fDeleteOriginalTorrentCheck setState: NSOffState];
    839             [fDefaults setBool: NO forKey: @"DeleteOriginalTorrent"];
    840         }
    841     }
    842     else
    843         [fDefaults setBool: state forKey: @"DeleteOriginalTorrent"];
    844 }
    845 
    846409- (void) setDownloadLocation: (id) sender
    847410{
    848     //Download folder
     411    //download folder
    849412    switch ([fFolderPopUp indexOfSelectedItem])
    850413    {
     
    878441- (void) setAutoImport: (id) sender
    879442{
    880     int state = [fAutoImportCheck state];
    881     [fDefaults setBool: state forKey: @"AutoImport"];
    882     [fImportFolderPopUp setEnabled: state];
    883    
    884     if (state == NSOnState)
    885         [[UKKQueue sharedFileWatcher] addPath: fImportFolder];
    886     else
    887         [[UKKQueue sharedFileWatcher] removePathFromQueue: fImportFolder];
     443    if ([fDefaults boolForKey: @"AutoImport"])
     444        [[UKKQueue sharedFileWatcher] addPath:
     445            [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
     446    else
     447        [[UKKQueue sharedFileWatcher] removePathFromQueue:
     448            [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
    888449   
    889450    [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoImportSettingChange" object: self];
     
    907468- (void) setAutoSize: (id) sender
    908469{
    909     [fDefaults setBool: [sender state] forKey: @"AutoSize"];
    910    
    911470    [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoSizeSettingChange" object: self];
    912471}
     
    975534    if (code == NSOKButton)
    976535    {
    977         [fDownloadFolder release];
    978         fDownloadFolder = [[[openPanel filenames] objectAtIndex: 0] retain];
    979        
    980536        [fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
    981         [fDefaults setObject: fDownloadFolder forKey: @"DownloadFolder"];
     537        [fDefaults setObject: [[openPanel filenames] objectAtIndex: 0] forKey: @"DownloadFolder"];
    982538        [fDefaults setObject: @"Constant" forKey: @"DownloadChoice"];
    983539       
     
    1000556{
    1001557    //get and resize the icon
    1002     NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFile: fDownloadFolder];
     558    NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFile:
     559                        [[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath]];
    1003560    [icon setScalesWhenResized: YES];
    1004561    [icon setSize: NSMakeSize(16.0, 16.0)];
     
    1006563    //update menu item
    1007564    NSMenuItem * menuItem = (NSMenuItem *) [fFolderPopUp itemAtIndex: 0];
    1008     [menuItem setTitle: [fDownloadFolder lastPathComponent]];
     565    [menuItem setTitle: [[fDefaults stringForKey: @"DownloadFolder"] lastPathComponent]];
    1009566    [menuItem setImage: icon];
    1010567}
     
    1015572    {
    1016573        UKKQueue * sharedQueue = [UKKQueue sharedFileWatcher];
    1017         [sharedQueue removePathFromQueue: fImportFolder];
    1018        
    1019         [fImportFolder release];
    1020         fImportFolder = [[[openPanel filenames] objectAtIndex: 0] retain];
    1021        
    1022         [fDefaults setObject: fImportFolder forKey: @"AutoImportDirectory"];
     574        [sharedQueue removePathFromQueue: [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
     575       
     576        [fDefaults setObject: [[openPanel filenames] objectAtIndex: 0] forKey: @"AutoImportDirectory"];
    1023577       
    1024578        [self updateImportPopUp];
    1025579       
    1026         [sharedQueue addPath: fImportFolder];
     580        [sharedQueue addPath: [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
    1027581       
    1028582        [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoImportSettingChange" object: self];
     
    1034588{
    1035589    //get and resize the icon
    1036     NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFile: fImportFolder];
     590    NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFile:
     591                        [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
    1037592    [icon setScalesWhenResized: YES];
    1038593    [icon setSize: NSMakeSize(16.0, 16.0)];
     
    1040595    //update menu item
    1041596    NSMenuItem * menuItem = (NSMenuItem *) [fImportFolderPopUp itemAtIndex: 0];
    1042     [menuItem setTitle: [fImportFolder lastPathComponent]];
     597    [menuItem setTitle: [[fDefaults stringForKey: @"AutoImportDirectory"] lastPathComponent]];
    1043598    [menuItem setImage: icon];
    1044599}
Note: See TracChangeset for help on using the changeset viewer.