-- (void)setLaunchesAtLogin:(BOOL)flag
-{
- NSMutableDictionary *loginwindow;
- NSMutableArray *loginarray;
- ITDebugLog(@"Setting launches at login: %i", flag);
- [df synchronize];
- loginwindow = [[df persistentDomainForName:@"loginwindow"] mutableCopy];
- loginarray = [loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"];
-
- if (flag) {
- NSDictionary *itemDict = [NSDictionary dictionaryWithObjectsAndKeys:
- [[NSBundle mainBundle] bundlePath], @"Path",
- [NSNumber numberWithInt:0], @"Hide", nil];
- [loginarray addObject:itemDict];
- } else {
- int i;
- for (i = 0; i < [loginarray count]; i++) {
- NSDictionary *tempDict = [loginarray objectAtIndex:i];
- if ([[[tempDict objectForKey:@"Path"] lastPathComponent] isEqualToString:[[[NSBundle mainBundle] bundlePath] lastPathComponent]]) {
- [loginarray removeObjectAtIndex:i];
- break;
- }
- }
- }
- [df setPersistentDomain:loginwindow forName:@"loginwindow"];
- [df synchronize];
- [loginwindow release];
- ITDebugLog(@"Finished setting launches at login.");
-}
-