Permalink
Browse files

Copying Pallet from gsoc09-gui branch to contrib

git-svn-id: http://svn.macports.org/repository/macports/contrib/Pallet@65496 d073be05-634f-4543-b044-5fe20cf6d1d6
  • Loading branch information...
0 parents commit 6497ab2b6c3b7afd65ea1b05e9a6667cfe4878fa @juanger committed Mar 26, 2010
@@ -0,0 +1,28 @@
+//
+// NotificationsListener.h
+// MPGUI
+//
+// Created by Juan Germán Castañeda Echevarría on 8/4/09.
+// Copyright 2009 UNAM. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#import <MacPorts/MPNotifications.h>
+
+
+@interface ActivityController : NSObject {
+ IBOutlet NSTextField *currentTask;
+ IBOutlet NSTableView *operations;
+ IBOutlet NSProgressIndicator *progress;
+ BOOL busy;
+}
+
+@property BOOL busy;
+
+- (void)subscribeToNotifications;
+- (void)gotMPMSG:(NSNotification *)notification;
+- (void)gotMPINFO:(NSNotification *)notification;
+- (void)gotMPDEFAULT:(NSNotification *)notification;
+- (void)gotMPERROR:(NSNotification *)notification;
+
+@end
@@ -0,0 +1,76 @@
+//
+// NotificationsListener.m
+// MPGUI
+//
+// Created by Juan Germán Castañeda Echevarría on 8/4/09.
+// Copyright 2009 UNAM. All rights reserved.
+//
+
+#import "ActivityController.h"
+
+
+@implementation ActivityController
+
+@synthesize busy;
+
+- (void)awakeFromNib {
+ [progress setUsesThreadedAnimation:YES];
+ [self setBusy:NO];
+ [self subscribeToNotifications];
+}
+
+- (void)subscribeToNotifications {
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(gotMPMSG:)
+ name:MPMSG object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(gotMPDEFAULT:)
+ name:MPDEFAULT object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(gotMPINFO:)
+ name:MPINFO object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(gotMPERROR:)
+ name:MPERROR object:nil];
+ // [[NSNotificationCenter defaultCenter] addObserver:self
+ // selector:@selector()
+ // name:MPWARN object:nil];
+ // [[NSNotificationCenter defaultCenter] addObserver:self
+ // selector:@selector()
+ // name:MPDEBUG object:nil];
+}
+
+- (void)gotMPINFO:(NSNotification *)notification {
+ NSString *msg = [[notification userInfo] objectForKey:MPMESSAGE];
+ NSLog(@"GOT MPINFO NOTIFICATION: %@", msg);
+ // Starting up: A port command has been started
+ if ([msg isEqual:@"Starting up"]) {
+ [currentTask setStringValue:[[notification userInfo] objectForKey:MPMETHOD]];
+ [self setBusy:YES];
+ return;
+ }
+ // Shutting down: The command has finished
+ if ([msg isEqual:@"Shutting down"]) {
+ [currentTask setStringValue:@"" ];
+ [self setBusy:NO];
+ return;
+ }
+}
+
+- (void)gotMPMSG:(NSNotification *)notification {
+ NSString *msg = [[notification userInfo] objectForKey:MPMESSAGE];
+ NSLog(@"GOT MPMSG NOTIFICATION: %@", msg);
+}
+
+- (void)gotMPDEFAULT:(NSNotification *)notification {
+ NSString *msg = [[notification userInfo] objectForKey:MPMESSAGE];
+ NSLog(@"GOT MPDEFAULT NOTIFICATION: %@", msg);
+}
+
+- (void)gotMPERROR:(NSNotification *)notification {
+ NSString *msg = [[notification userInfo] objectForKey:MPMESSAGE];
+ NSLog(@"GOT ERROR NOTIFICATION: %@", msg);
+ //TODO: Display an alert
+}
+
+@end
Binary file not shown.
Binary file not shown.
Oops, something went wrong.

0 comments on commit 6497ab2

Please sign in to comment.