Commits

Anonymous committed 9d82339

suck it down CFPreferences, suck it down long and hard
- Growl can now add and remove itself from the loginItems
- The button is now on, when it is already set.
- next is if it's already running

Comments (0)

Files changed (1)

 
 - (void) mainViewDidLoad {
 	//load prefs and set IBOutlets accordingly
+	NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
+	[defs addSuiteNamed:@"loginwindow"];
+	NSString *helperPath = [[[self bundle] resourcePath] stringByAppendingString:@"/GrowlHelperApp.app"];
+	
+	NSDictionary *growlEntry = [NSDictionary dictionaryWithObjectsAndKeys:  helperPath, [NSString stringWithString:@"Path"],
+																			[NSNumber numberWithBool:NO], [NSString stringWithString:@"Hide"],
+																			nil];
+	
+	if ( [[defs objectForKey:@"AutoLaunchedApplicationDictionary"] containsObject:growlEntry] ) 
+		[_startGrowlLoginButton setState:NSOnState];
 }
 
 - (IBAction) startGrowl:(id) sender {
 }
 
 - (IBAction) startGrowlAtLogin:(id) sender {
-	NSLog( @"start Growl At Login" );
-	//insert code here
+	NSUserDefaults *defs = [[NSUserDefaults alloc] init];
+	[defs addSuiteNamed:@"loginwindow"];
+	NSMutableDictionary *loginWindowPrefs = [[[defs persistentDomainForName:@"loginwindow"] mutableCopy] autorelease];
+	NSMutableArray *loginItems = [[[loginWindowPrefs objectForKey:@"AutoLaunchedApplicationDictionary"] mutableCopy] autorelease]; //it lies, its an array
+	NSString *helperPath = [[[self bundle] resourcePath] stringByAppendingString:@"/GrowlHelperApp.app"];
+	
+	NSDictionary *growlEntry = [NSDictionary dictionaryWithObjectsAndKeys:  helperPath, [NSString stringWithString:@"Path"],
+																			[NSNumber numberWithBool:NO], [NSString stringWithString:@"Hide"],
+																			nil];
+	
+	if ( [_startGrowlLoginButton state] == NSOnState ) {
+		NSLog( @"start Growl At Login" );
+		
+		[loginItems addObject:growlEntry];
+	} else {
+		NSLog( @"Don't start Growl At Login" );
+		[loginItems removeObject:growlEntry];
+	}
+
+	[loginWindowPrefs setObject:[NSArray arrayWithArray:loginItems] 
+						 forKey:@"AutoLaunchedApplicationDictionary"];
+	[defs setPersistentDomain:[NSDictionary dictionaryWithDictionary:loginWindowPrefs] 
+					  forName:@"loginwindow"];
+	[defs synchronize];	
 }
 
 @end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.