source: trunk/macosx/PrefsController.m @ 1304

Last change on this file since 1304 was 1304, checked in by livings124, 15 years ago

bindings + formatters = trouble....revert to glue code for speed limit, torrent limit, and port fields in prefs...more to come later

  • Property svn:keywords set to Date Rev Author Id
File size: 21.1 KB
Line 
1/******************************************************************************
2 * $Id: PrefsController.m 1304 2006-12-31 21:38:35Z livings124 $
3 *
4 * Copyright (c) 2005-2006 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#import "PrefsController.h"
26#import "StringAdditions.h"
27#import "UKKQueue.h"
28
29#define DOWNLOAD_FOLDER     0
30#define DOWNLOAD_TORRENT    2
31#define DOWNLOAD_ASK        3
32
33#define UPDATE_DAILY    0
34#define UPDATE_WEEKLY   1
35#define UPDATE_NEVER    2
36
37#define TOOLBAR_GENERAL     @"TOOLBAR_GENERAL"
38#define TOOLBAR_TRANSFERS   @"TOOLBAR_TRANSFERS"
39#define TOOLBAR_BANDWIDTH   @"TOOLBAR_BANDWIDTH"
40#define TOOLBAR_NETWORK     @"TOOLBAR_NETWORK"
41
42@interface PrefsController (Private)
43
44- (void) setPrefView: (id) sender;
45
46- (void) folderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
47- (void) incompleteFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
48- (void) importFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
49
50@end
51
52@implementation PrefsController
53
54- (id) initWithWindowNibName: (NSString *) name handle: (tr_handle_t *) handle
55{
56    if ((self = [self initWithWindowNibName: name]))
57    {
58        fDefaults = [NSUserDefaults standardUserDefaults];
59        fHandle = handle;
60       
61        //checks for old version upload speed of -1
62        if ([fDefaults integerForKey: @"UploadLimit"] < 0)
63        {
64            [fDefaults setInteger: 20 forKey: @"UploadLimit"];
65            [fDefaults setBool: NO forKey: @"CheckUpload"];
66        }
67       
68        //set auto import
69        if ([fDefaults boolForKey: @"AutoImport"])
70            [[UKKQueue sharedFileWatcher] addPath:
71                [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
72       
73        //set bind port
74        int bindPort = [fDefaults integerForKey: @"BindPort"];
75        tr_setBindPort(fHandle, bindPort);
76       
77        //set NAT
78        if ([fDefaults boolForKey: @"NatTraversal"])
79            tr_natTraversalEnable(fHandle);
80       
81        //actually set bandwidth limits
82        [self applySpeedSettings: nil];
83       
84        //set play sound
85        NSMutableArray * sounds = [NSMutableArray array];
86        NSEnumerator * soundEnumerator,
87                    * soundDirectoriesEnumerator = [[NSArray arrayWithObjects: @"System/Library/Sounds",
88                            [NSHomeDirectory() stringByAppendingPathComponent: @"Library/Sounds"], nil] objectEnumerator];
89        NSString * soundPath, * sound;
90       
91        //get list of all sounds and sort alphabetically
92        while ((soundPath = [soundDirectoriesEnumerator nextObject]))
93            if (soundEnumerator = [[NSFileManager defaultManager] enumeratorAtPath: soundPath])
94                while ((sound = [soundEnumerator nextObject]))
95                {
96                    sound = [sound stringByDeletingPathExtension];
97                    if ([NSSound soundNamed: sound])
98                        [sounds addObject: sound];
99                }
100       
101        fSounds = [[sounds sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)] retain];
102    }
103    return self;
104}
105
106- (void) dealloc
107{
108    if (fNatStatusTimer)
109        [fNatStatusTimer invalidate];
110    [fSounds release];
111   
112    [super dealloc];
113}
114
115- (void) awakeFromNib
116{
117    fToolbar = [[NSToolbar alloc] initWithIdentifier: @"Preferences Toolbar"];
118    [fToolbar setDelegate: self];
119    [fToolbar setAllowsUserCustomization: NO];
120    [[self window] setToolbar: fToolbar];
121    [fToolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
122    [fToolbar setSizeMode: NSToolbarSizeModeRegular];
123
124    [fToolbar setSelectedItemIdentifier: TOOLBAR_GENERAL];
125    [self setPrefView: nil];
126   
127    //set download folder
128    NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"];
129    if ([downloadChoice isEqualToString: @"Constant"])
130        [fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
131    else if ([downloadChoice isEqualToString: @"Torrent"])
132        [fFolderPopUp selectItemAtIndex: DOWNLOAD_TORRENT];
133    else
134        [fFolderPopUp selectItemAtIndex: DOWNLOAD_ASK];
135   
136    //set torrent limits
137    [fUploadTorrentField setIntValue: [fDefaults integerForKey: @"UploadLimitTorrent"]];
138    [fDownloadTorrentField setIntValue: [fDefaults integerForKey: @"DownloadLimitTorrent"]];
139   
140    //set speed limit
141    [fSpeedLimitUploadField setIntValue: [fDefaults integerForKey: @"SpeedLimitUploadLimit"]];
142    [fSpeedLimitDownloadField setIntValue: [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]];
143   
144    //set port
145    [fPortField setIntValue: [fDefaults integerForKey: @"BindPort"]];
146   
147    [self updatePortStatus];
148   
149    fNatStatus = -1;
150    [self updateNatStatus];
151    fNatStatusTimer = [NSTimer scheduledTimerWithTimeInterval: 5.0 target: self
152                        selector: @selector(updateNatStatus) userInfo: nil repeats: YES];
153
154    //set update check
155    NSString * updateCheck = [fDefaults stringForKey: @"UpdateCheck"];
156    if ([updateCheck isEqualToString: @"Weekly"])
157        [fUpdatePopUp selectItemAtIndex: UPDATE_WEEKLY];
158    else if ([updateCheck isEqualToString: @"Never"])
159        [fUpdatePopUp selectItemAtIndex: UPDATE_NEVER];
160    else
161        [fUpdatePopUp selectItemAtIndex: UPDATE_DAILY];
162}
163
164- (void) setUpdater: (SUUpdater *) updater
165{
166    fUpdater = updater;
167}
168
169- (NSToolbarItem *) toolbar: (NSToolbar *) toolbar itemForItemIdentifier: (NSString *) ident
170                    willBeInsertedIntoToolbar: (BOOL) flag
171{
172    NSToolbarItem * item;
173    item = [[NSToolbarItem alloc] initWithItemIdentifier: ident];
174
175    if ([ident isEqualToString: TOOLBAR_GENERAL])
176    {
177        [item setLabel: NSLocalizedString(@"General", "Preferences -> General toolbar item title")];
178        [item setImage: [NSImage imageNamed: @"Preferences.png"]];
179        [item setTarget: self];
180        [item setAction: @selector(setPrefView:)];
181        [item setAutovalidates: NO];
182    }
183    else if ([ident isEqualToString: TOOLBAR_TRANSFERS])
184    {
185        [item setLabel: NSLocalizedString(@"Transfers", "Preferences -> Transfers toolbar item title")];
186        [item setImage: [NSImage imageNamed: @"Transfers.png"]];
187        [item setTarget: self];
188        [item setAction: @selector(setPrefView:)];
189        [item setAutovalidates: NO];
190    }
191    else if ([ident isEqualToString: TOOLBAR_BANDWIDTH])
192    {
193        [item setLabel: NSLocalizedString(@"Bandwidth", "Preferences -> Bandwidth toolbar item title")];
194        [item setImage: [NSImage imageNamed: @"Bandwidth.png"]];
195        [item setTarget: self];
196        [item setAction: @selector(setPrefView:)];
197        [item setAutovalidates: NO];
198    }
199    else if ([ident isEqualToString: TOOLBAR_NETWORK])
200    {
201        [item setLabel: NSLocalizedString(@"Network", "Preferences -> Network toolbar item title")];
202        [item setImage: [NSImage imageNamed: @"Network.png"]];
203        [item setTarget: self];
204        [item setAction: @selector(setPrefView:)];
205        [item setAutovalidates: NO];
206    }
207    else
208    {
209        [item release];
210        return nil;
211    }
212
213    return item;
214}
215
216- (NSArray *) toolbarSelectableItemIdentifiers: (NSToolbar *) toolbar
217{
218    return [self toolbarDefaultItemIdentifiers: toolbar];
219}
220
221- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar
222{
223    return [self toolbarAllowedItemIdentifiers: toolbar];
224}
225
226- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar
227{
228    return [NSArray arrayWithObjects: TOOLBAR_GENERAL, TOOLBAR_TRANSFERS,
229                                        TOOLBAR_BANDWIDTH, TOOLBAR_NETWORK, nil];
230}
231
232- (void) setPort: (id) sender
233{
234    int port = [sender intValue];
235    if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", port]])
236    {
237        NSBeep();
238        [sender setIntValue: [fDefaults integerForKey: @"BindPort"]];
239        return;
240    }
241   
242    [fDefaults setInteger: port forKey: @"BindPort"];
243   
244    tr_setBindPort(fHandle, [fDefaults integerForKey: @"BindPort"]);
245    [self updateNatStatus];
246    [self updatePortStatus];
247}
248
249- (void) updatePortStatus
250{
251    PortChecker * portChecker = [[PortChecker alloc] initWithDelegate: self];
252
253    [fPortStatusField setStringValue: [NSLocalizedString(@"Checking port status",
254                                        "Preferences -> Network -> port status") stringByAppendingEllipsis]];
255    [fPortStatusImage setImage: nil];
256    [fPortStatusProgress startAnimation: self];
257       
258    [portChecker probePort: [fDefaults integerForKey: @"BindPort"]];
259}
260
261- (void) portCheckerDidFinishProbing: (PortChecker *) portChecker
262{
263    [fPortStatusProgress stopAnimation: self];
264    switch ([portChecker status])
265    {
266        case PORT_STATUS_OPEN:
267            [fPortStatusField setStringValue: NSLocalizedString(@"Port is open", "Preferences -> Network -> port status")];
268            [fPortStatusImage setImage: [NSImage imageNamed: @"GreenDot.tiff"]];
269            break;
270        case PORT_STATUS_STEALTH:
271            [fPortStatusField setStringValue: NSLocalizedString(@"Port is stealth", "Preferences -> Network -> port status")];
272            [fPortStatusImage setImage: [NSImage imageNamed: @"RedDot.tiff"]];
273            break;
274        case PORT_STATUS_CLOSED:
275            [fPortStatusField setStringValue: NSLocalizedString(@"Port is closed", "Preferences -> Network -> port status")];
276            [fPortStatusImage setImage: [NSImage imageNamed: @"RedDot.tiff"]];
277            break;
278        case PORT_STATUS_ERROR:
279            [fPortStatusField setStringValue: NSLocalizedString(@"Unable to check port status",
280                                                "Preferences -> Network -> port status")];
281            [fPortStatusImage setImage: [NSImage imageNamed: @"YellowDot.tiff"]];
282            break;
283    }
284    [portChecker release];
285}
286
287- (void) setNat: (id) sender
288{
289    [fDefaults boolForKey: @"NatTraversal"] ? tr_natTraversalEnable(fHandle) : tr_natTraversalDisable(fHandle);
290    [self updateNatStatus];
291}
292
293- (void) updateNatStatus
294{
295    int status = tr_natTraversalStatus(fHandle);
296    if (fNatStatus == status)
297        return;
298    fNatStatus = status;
299   
300    if (status == 2)
301    {
302        [fNatStatusField setStringValue: NSLocalizedString(@"Port successfully mapped",
303                                            "Preferences -> Network -> port map status")];
304        [fNatStatusImage setImage: [NSImage imageNamed: @"GreenDot.tiff"]];
305    }
306    else if (status == 3 || status == 4)
307    {
308        [fNatStatusField setStringValue: NSLocalizedString(@"Error mapping port",
309                                            "Preferences -> Network -> port map status")];
310        [fNatStatusImage setImage: [NSImage imageNamed: @"RedDot.tiff"]];
311    }
312    else
313    {
314        [fNatStatusField setStringValue: @""];
315        [fNatStatusImage setImage: nil];
316    }
317   
318    [self updatePortStatus];
319}
320
321- (void) applySpeedSettings: (id) sender
322{
323    if ([fDefaults boolForKey: @"SpeedLimit"])
324    {
325        tr_setGlobalUploadLimit(fHandle, [fDefaults integerForKey: @"SpeedLimitUploadLimit"]);
326        tr_setGlobalDownloadLimit(fHandle, [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]);
327    }
328    else
329    {
330        tr_setGlobalUploadLimit(fHandle, [fDefaults boolForKey: @"CheckUpload"]
331                                        ? [fDefaults integerForKey: @"UploadLimit"] : -1);
332        tr_setGlobalDownloadLimit(fHandle, [fDefaults boolForKey: @"CheckDownload"]
333                                        ? [fDefaults integerForKey: @"DownloadLimit"] : -1);
334    }
335}
336
337- (void) applyTorrentLimitSetting: (id) sender
338{
339    [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateSpeedSetting" object: self];
340}
341
342- (void) setTorrentLimit: (id) sender
343{
344    BOOL upload = sender == fUploadTorrentField;
345   
346    int limit = [sender intValue];
347    if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", limit]])
348    {
349        NSBeep();
350        [sender setIntValue: [fDefaults integerForKey: upload ? @"UploadLimitTorrent" : @"DownloadLimitTorrent"]];
351        return;
352    }
353   
354    [fDefaults setInteger: limit forKey: upload ? @"UploadLimitTorrent" : @"DownloadLimitTorrent"];
355   
356    [self applyTorrentLimitSetting: self];
357}
358
359- (void) setSpeedLimit: (id) sender
360{
361    BOOL upload = sender == fSpeedLimitUploadField;
362   
363    int limit = [sender intValue];
364    if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", limit]])
365    {
366        NSBeep();
367        [sender setIntValue: [fDefaults integerForKey: upload ? @"SpeedLimitUploadLimit" : @"SpeedLimitDownloadLimit"]];
368        return;
369    }
370   
371    [fDefaults setInteger: limit forKey: upload ? @"SpeedLimitUploadLimit" : @"SpeedLimitDownloadLimit"];
372   
373    [self applySpeedSettings: self];
374}
375
376- (void) setAutoSpeedLimit: (id) sender
377{
378    [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoSpeedLimitChange" object: self];
379}
380
381- (void) setBadge: (id) sender
382{   
383    [[NSNotificationCenter defaultCenter] postNotificationName: @"DockBadgeChange" object: self];
384}
385
386- (void) setSound: (id) sender
387{
388    //play sound when selecting
389    NSString * soundName = [sender titleOfSelectedItem];
390    NSSound * sound;
391    if ((sound = [NSSound soundNamed: soundName]))
392        [sound play];
393}
394
395- (void) setUpdate: (id) sender
396{
397    int index = [fUpdatePopUp indexOfSelectedItem];
398    NSTimeInterval seconds;
399    if (index == UPDATE_DAILY)
400    {
401        [fDefaults setObject: @"Daily" forKey: @"UpdateCheck"];
402        seconds = 86400;
403    }
404    else if (index == UPDATE_WEEKLY)
405    {
406        [fDefaults setObject: @"Weekly" forKey: @"UpdateCheck"];
407        seconds = 604800;
408    }
409    else
410    {
411        [fDefaults setObject: @"Never" forKey: @"UpdateCheck"];
412        seconds = 0;
413    }
414
415    [fDefaults setInteger: seconds forKey: @"SUScheduledCheckInterval"];
416   
417    if (fUpdater)
418        [fUpdater scheduleCheckWithInterval: seconds];
419}
420
421- (void) setQueueNumber: (id) sender
422{
423    [[NSNotificationCenter defaultCenter] postNotificationName: @"GlobalStartSettingChange" object: self];
424}
425
426- (void) setDownloadLocation: (id) sender
427{
428    //download folder
429    switch ([fFolderPopUp indexOfSelectedItem])
430    {
431        case DOWNLOAD_FOLDER:
432            [fDefaults setObject: @"Constant" forKey: @"DownloadChoice"];
433            break;
434        case DOWNLOAD_TORRENT:
435            [fDefaults setObject: @"Torrent" forKey: @"DownloadChoice"];
436            break;
437        case DOWNLOAD_ASK:
438            [fDefaults setObject: @"Ask" forKey: @"DownloadChoice"];
439            break;
440    }
441}
442
443- (void) folderSheetShow: (id) sender
444{
445    NSOpenPanel * panel = [NSOpenPanel openPanel];
446
447    [panel setPrompt: @"Select"];
448    [panel setAllowsMultipleSelection: NO];
449    [panel setCanChooseFiles: NO];
450    [panel setCanChooseDirectories: YES];
451    [panel setCanCreateDirectories: YES];
452
453    [panel beginSheetForDirectory: nil file: nil types: nil
454        modalForWindow: [self window] modalDelegate: self didEndSelector:
455        @selector(folderSheetClosed:returnCode:contextInfo:) contextInfo: nil];
456}
457
458- (void) incompleteFolderSheetShow: (id) sender
459{
460    NSOpenPanel * panel = [NSOpenPanel openPanel];
461
462    [panel setPrompt: @"Select"];
463    [panel setAllowsMultipleSelection: NO];
464    [panel setCanChooseFiles: NO];
465    [panel setCanChooseDirectories: YES];
466    [panel setCanCreateDirectories: YES];
467
468    [panel beginSheetForDirectory: nil file: nil types: nil
469        modalForWindow: [self window] modalDelegate: self didEndSelector:
470        @selector(incompleteFolderSheetClosed:returnCode:contextInfo:) contextInfo: nil];
471}
472
473- (void) setAutoImport: (id) sender
474{
475    NSString * path = [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath];
476    if ([fDefaults boolForKey: @"AutoImport"])
477        [[UKKQueue sharedFileWatcher] addPath: path];
478    else
479        [[UKKQueue sharedFileWatcher] removePathFromQueue: path];
480   
481    [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoImportSettingChange" object: self];
482}
483
484- (void) importFolderSheetShow: (id) sender
485{
486    NSOpenPanel * panel = [NSOpenPanel openPanel];
487
488    [panel setPrompt: @"Select"];
489    [panel setAllowsMultipleSelection: NO];
490    [panel setCanChooseFiles: NO];
491    [panel setCanChooseDirectories: YES];
492    [panel setCanCreateDirectories: YES];
493
494    [panel beginSheetForDirectory: nil file: nil types: nil
495        modalForWindow: [self window] modalDelegate: self didEndSelector:
496        @selector(importFolderSheetClosed:returnCode:contextInfo:) contextInfo: nil];
497}
498
499- (void) setAutoSize: (id) sender
500{
501    [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoSizeSettingChange" object: self];
502}
503
504- (void) helpForNetwork: (id) sender
505{
506    [[NSHelpManager sharedHelpManager] openHelpAnchor: @"PortForwarding"
507        inBook: [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleHelpBookName"]];
508}
509
510@end
511
512@implementation PrefsController (Private)
513
514- (void) setPrefView: (id) sender
515{
516    NSView * view = fGeneralView;
517    if (sender)
518    {
519        NSString * identifier = [sender itemIdentifier];
520        if ([identifier isEqualToString: TOOLBAR_TRANSFERS])
521            view = fTransfersView;
522        else if ([identifier isEqualToString: TOOLBAR_BANDWIDTH])
523            view = fBandwidthView;
524        else if ([identifier isEqualToString: TOOLBAR_NETWORK])
525            view = fNetworkView;
526        else;
527    }
528   
529    NSWindow * window = [self window];
530    if ([window contentView] == view)
531        return;
532   
533    NSRect windowRect = [window frame];
534    int difference = [view frame].size.height - [[window contentView] frame].size.height;
535    windowRect.origin.y -= difference;
536    windowRect.size.height += difference;
537   
538    [view setHidden: YES];
539    [window setContentView: view];
540    [window setFrame: windowRect display: YES animate: YES];
541    [view setHidden: NO];
542   
543    //set title label
544    if (sender)
545        [window setTitle: [sender label]];
546    else
547    {
548        NSToolbarItem * item;
549        NSEnumerator * enumerator = [[fToolbar items] objectEnumerator];
550        while ((item = [enumerator nextObject]))
551            if ([[item itemIdentifier] isEqualToString: [fToolbar selectedItemIdentifier]])
552            {
553                [window setTitle: [item label]];
554                break;
555            }
556    }
557   
558    //for network view make sure progress indicator hides itself
559    if (view == fNetworkView && [fPortStatusImage image])
560        [fPortStatusProgress setDisplayedWhenStopped: NO];
561}
562
563- (void) folderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
564{
565    if (code == NSOKButton)
566    {
567        [fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
568        [fDefaults setObject: [[openPanel filenames] objectAtIndex: 0] forKey: @"DownloadFolder"];
569        [fDefaults setObject: @"Constant" forKey: @"DownloadChoice"];
570    }
571    else
572    {
573        //reset if cancelled
574        NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"];
575        if ([downloadChoice isEqualToString: @"Constant"])
576            [fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
577        else if ([downloadChoice isEqualToString: @"Torrent"])
578            [fFolderPopUp selectItemAtIndex: DOWNLOAD_TORRENT];
579        else
580            [fFolderPopUp selectItemAtIndex: DOWNLOAD_ASK];
581    }
582}
583
584- (void) incompleteFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
585{
586    if (code == NSOKButton)
587        [fDefaults setObject: [[openPanel filenames] objectAtIndex: 0] forKey: @"IncompleteDownloadFolder"];
588    [fIncompleteFolderPopUp selectItemAtIndex: 0];
589}
590
591- (void) importFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
592{
593    if (code == NSOKButton)
594    {
595        UKKQueue * sharedQueue = [UKKQueue sharedFileWatcher];
596        [sharedQueue removePathFromQueue: [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
597       
598        [fDefaults setObject: [[openPanel filenames] objectAtIndex: 0] forKey: @"AutoImportDirectory"];
599       
600        [sharedQueue addPath: [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]];
601       
602        [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoImportSettingChange" object: self];
603    }
604    [fImportFolderPopUp selectItemAtIndex: 0];
605}
606
607@end
Note: See TracBrowser for help on using the repository browser.