Anonymous avatar Anonymous committed 9ae2edb

Connected the add sheet so now you can add notifications about stuff.
- Filled in some details about the notifications userInfo
- and some other stuff

Comments (0)

Files changed (5)

Beep.nib/classes.nib

 {
     IBClasses = (
         {
-            ACTIONS = {addNotification = id; registerBeep = id; sendNotification = id; }; 
+            ACTIONS = {
+                addNotification = id; 
+                endPanel = id; 
+                registerBeep = id; 
+                sendNotification = id; 
+                showAddSheet = id; 
+            }; 
             CLASS = BeepController; 
             LANGUAGE = ObjC; 
             OUTLETS = {
+                "_beepWindow" = NSWindow; 
                 "_newNotificationDefault" = NSButton; 
                 "_newNotificationDescription" = NSTextField; 
                 "_newNotificationImage" = NSImageView; 

Beep.nib/info.nib

 	<string>349.0</string>
 	<key>IBOpenObjects</key>
 	<array>
+		<integer>29</integer>
 		<integer>21</integer>
-		<integer>29</integer>
 		<integer>255</integer>
 	</array>
 	<key>IBSystem Version</key>
Add a comment to this file

Beep.nib/keyedobjects.nib

Binary file modified.

     IBOutlet NSTextField	*_newNotificationTitle;				// The name of this note
 	
 	//main window
+	IBOutlet NSWindow		*_beepWindow;						// The main window
     IBOutlet NSTableView	*_notificationsTable;				// The table of notifications
-    IBOutlet NSButton		*_registered;						// The magic button the registers/unregisters
+    IBOutlet NSButton		*_registered;						// The magic button that registers/unregisters
     IBOutlet NSButton		*_removeNotification;				// The remove button (TBR)
 	
 	//data
 - (IBAction)addNotification:(id)sender;
 - (IBAction)registerBeep:(id)sender;
 - (IBAction)sendNotification:(id)sender;
+- (IBAction) endPanel:(id)sender;
 @end
 #import "BeepController.h"
 
+#define GROWL_NOTIFICATION_DEFAULT @"NotificationDefault"
+
 @implementation BeepController
 
 - (id) init {
 	if ( self = [super init] ) {
-		_notifications = [[_notifications init] alloc];
+		_notifications = [[NSMutableArray alloc] init];
 	}
 	return self;
 }
 
+- (void) dealloc {
+	[_notifications release];
+	_notifications = nil;
+}
+
+#pragma mark -
+
+- (IBAction)showAddSheet:(id)sender { 
+	[NSApp beginSheet:_newNotificationPanel 
+	   modalForWindow:_beepWindow 
+		modalDelegate:nil 
+	   didEndSelector:nil 
+		  contextInfo:nil];
+	
+	[NSApp runModalForWindow:_newNotificationPanel];
+	[NSApp endSheet:_newNotificationPanel];
+	[_newNotificationPanel orderOut:self];
+}
+
 - (IBAction)addNotification:(id)sender {
-
+	//get Sheet fields and add to the known notifications
+	NSNumber *defaultValue = [NSNumber numberWithBool:[_newNotificationDefault state] == NSOnState];
+	NSDictionary *aNuDict = [NSDictionary dictionaryWithObjectsAndKeys:			[_newNotificationTitle stringValue], GROWL_NOTIFICATION_TITLE,
+																				[_newNotificationDescription stringValue], GROWL_NOTIFICATION_DESCRIPTION,
+																				[_newNotificationImage image], GROWL_NOTIFICATION_ICON,
+																				defaultValue, GROWL_NOTIFICATION_DEFAULT,
+																				nil];
+	[_notifications addObject:aNuDict];
+	NSLog( @"%@ added to %@", aNuDict, _notifications);
+	[_notificationsTable reloadData];
+	
+	[self endPanel:self];
 }
 
 - (IBAction)registerBeep:(id)sender {
 }
 
 - (IBAction)sendNotification:(id)sender {
+	//send a notification for the selected table cell
+}
 
+- (IBAction) endPanel:(id)sender {
+	[NSApp stopModal];
 }
 
 #pragma mark Table Data Source
 }
 
 - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex {
-	return [[_notifications objectAtIndex:rowIndex] objectForKey:@"NotificationName"];
+	return [[_notifications objectAtIndex:rowIndex] objectForKey:GROWL_NOTIFICATION_TITLE];
 }
 
 #pragma mark Table Delegate Methods
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.