Anonymous avatar Anonymous committed 282ca09

register apps once
- allow apps to change their lists of notifications for all and default, but maintain the user's custom list.

Comments (0)

Files changed (4)

GrowlApplicationTicket.h

 
 #pragma mark -
 
+- (NSSet *) allNotifications;
+- (void) setAllNotifications:(NSSet *) inSet;
+
+- (NSSet *) defaultNotifications;
+- (void) setDefaultNotifications:(NSSet *) inSet;
+
+#pragma mark -
+
 - (void) registerParentForNotifications:(NSSet *) inSet;
 - (void) unregisterParentForNotifications:(NSArray *) inArray;
 @end

GrowlApplicationTicket.m

 }
 
 #pragma mark -
+
+- (NSSet *) allNotifications {
+	return _allNotifications;
+}
+
+- (void) setAllNotifications:(NSSet *) inSet {
+	[inSet retain];
+	[_allNotifications release];
+	_allNotifications = inSet;
+}
+
+- (NSSet *) defaultNotifications {
+	return _defaultNotifications;
+}
+
+- (void) setDefaultNotifications:(NSSet *) inSet {
+	[inSet retain];
+	[_defaultNotifications release];
+	_defaultNotifications = inSet;
+}
+
+
+#pragma mark -
 - (void) registerParentForNotifications:(NSSet *) inSet {
 	NSEnumerator *note = [inSet objectEnumerator];
 	id obj = nil;

GrowlController.h

 #import "GrowlDefines.h" //this should not be needed
 
 @interface GrowlController : NSObject {
-	NSMutableArray				*_tickets;				//Application tickets
+	NSMutableDictionary			*_tickets;				//Application tickets
 	id <GrowlDisplayPlugin>		*_displayController;
 }
 

GrowlController.m

 
 #import "GrowlController.h"
 #import "GrowlApplicationTicket.h"
+#import "NSAdditions.h"
 
 @implementation GrowlController
 
 															selector:@selector( _registerApplication: ) 
 																name:GROWL_APP_REGISTRATION
 															  object:nil]; 
-		_tickets = [[NSMutableArray alloc] init];
+		_tickets = [[NSMutableDictionary alloc] init];
 
 		_displayController = [self loadDisplay];
 		[_displayController loadPlugin];
 	NSSet *defaultNotes = [NSSet setWithArray:[[note userInfo] objectForKey:GROWL_NOTIFICATIONS_DEFAULT]];
 	
 	//add category to NSWorkspace for -iconForApplication later
-	NSImage *appIcon = nil;
+	NSImage *appIcon = [[NSWorkspace sharedWorkspace] iconForApplication:appName];
+	NSLog( @"AppIcon - %@", appIcon );
 	
 	GrowlApplicationTicket *newApp = [[GrowlApplicationTicket alloc] initWithApplication:appName 
 																				withIcon:appIcon
 																		   andDefaultSet:defaultNotes 
 																			  fromParent:self];
 	
-	[_tickets addObject:newApp];
-	
-	NSLog( @"%@ has registered", appName );	
+	if ( ! [_tickets objectForKey:appName] ) {
+		[_tickets setValue:newApp forKey:appName];
+		NSLog( @"%@ has registered", appName );
+	} else {
+		NSLog( @"%@ has already registered", appName );
+		GrowlApplicationTicket *aApp = [_tickets objectForKey:appName];
+		[aApp setAllNotifications:allNotes];
+		[aApp setDefaultNotifications:defaultNotes];
+	}
 	
 }
 
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.