diff --git a/macosx/Controller.m b/macosx/Controller.m index 989877b3a..d169032b6 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1838,7 +1838,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy { if ([notification isEqualToString: UKFileWatcherWriteNotification]) { - if (![fDefaults boolForKey: @"AutoImport"]) + if (![fDefaults boolForKey: @"AutoImport"] || ![fDefaults stringForKey: @"AutoImportDirectory"]) return; if (fAutoImportTimer) @@ -1873,10 +1873,11 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy - (void) checkAutoImportDirectory { - if (![fDefaults boolForKey: @"AutoImport"]) + NSString * path; + if (![fDefaults boolForKey: @"AutoImport"] || !(path = [fDefaults stringForKey: @"AutoImportDirectory"])) return; - NSString * path = [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]; + path = [path stringByExpandingTildeInPath]; NSArray * importedNames; if (!(importedNames = [[NSFileManager defaultManager] directoryContentsAtPath: path])) diff --git a/macosx/Defaults.plist b/macosx/Defaults.plist index aceed4d7f..85f786d27 100644 --- a/macosx/Defaults.plist +++ b/macosx/Defaults.plist @@ -4,8 +4,6 @@ AutoImport - AutoImportDirectory - ~/Desktop AutoSize AutoStartDownload diff --git a/macosx/English.lproj/PrefsWindow.nib/info.nib b/macosx/English.lproj/PrefsWindow.nib/info.nib index a6e5e2ad9..0e2a3759b 100644 --- a/macosx/English.lproj/PrefsWindow.nib/info.nib +++ b/macosx/English.lproj/PrefsWindow.nib/info.nib @@ -7,7 +7,7 @@ IBEditorPositions 153 - 294 444 563 268 0 0 1152 842 + 206 273 563 268 0 0 1152 842 28 294 421 563 313 0 0 1152 842 41 @@ -23,8 +23,7 @@ IBOpenObjects - 28 - 153 + 41 IBSystem Version 8P135 diff --git a/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib b/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib index 1824c3b96..b63661b01 100644 Binary files a/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib and b/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib differ diff --git a/macosx/PrefsController.m b/macosx/PrefsController.m index 2ec15dc9a..c7469f8b3 100644 --- a/macosx/PrefsController.m +++ b/macosx/PrefsController.m @@ -66,9 +66,9 @@ } //set auto import - if ([fDefaults boolForKey: @"AutoImport"]) - [[UKKQueue sharedFileWatcher] addPath: - [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]]; + NSString * autoPath; + if ([fDefaults boolForKey: @"AutoImport"] && (autoPath = [fDefaults stringForKey: @"AutoImportDirectory"])) + [[UKKQueue sharedFileWatcher] addPath: [autoPath stringByExpandingTildeInPath]]; //set bind port int bindPort = [fDefaults integerForKey: @"BindPort"]; @@ -536,13 +536,19 @@ - (void) setAutoImport: (id) sender { - NSString * path = [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]; - if ([fDefaults boolForKey: @"AutoImport"]) - [[UKKQueue sharedFileWatcher] addPath: path]; + NSString * path; + if ((path = [fDefaults stringForKey: @"AutoImportDirectory"])) + { + path = [path stringByExpandingTildeInPath]; + if ([fDefaults boolForKey: @"AutoImport"]) + [[UKKQueue sharedFileWatcher] addPath: path]; + else + [[UKKQueue sharedFileWatcher] removePathFromQueue: path]; + + [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoImportSettingChange" object: self]; + } else - [[UKKQueue sharedFileWatcher] removePathFromQueue: path]; - - [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoImportSettingChange" object: self]; + [self importFolderSheetShow: nil]; } - (void) importFolderSheetShow: (id) sender @@ -654,17 +660,22 @@ - (void) importFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info { + NSString * path = [fDefaults stringForKey: @"AutoImportDirectory"]; if (code == NSOKButton) { UKKQueue * sharedQueue = [UKKQueue sharedFileWatcher]; - [sharedQueue removePathFromQueue: [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]]; + if (path) + [sharedQueue removePathFromQueue: [path stringByExpandingTildeInPath]]; - [fDefaults setObject: [[openPanel filenames] objectAtIndex: 0] forKey: @"AutoImportDirectory"]; - - [sharedQueue addPath: [[fDefaults stringForKey: @"AutoImportDirectory"] stringByExpandingTildeInPath]]; + path = [[openPanel filenames] objectAtIndex: 0]; + [fDefaults setObject: path forKey: @"AutoImportDirectory"]; + [sharedQueue addPath: [path stringByExpandingTildeInPath]]; [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoImportSettingChange" object: self]; } + else if (!path) + [fDefaults setBool: NO forKey: @"AutoImport"]; + [fImportFolderPopUp selectItemAtIndex: 0]; }