// // Pasteboard Inspector // // Copyright (c) 2008-2010 Thomas K. Dyas . All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // #import "AppController.h" #import "PasteboardInspectorController.h" @implementation AppController - (id) init { if ((self = [super init]) != nil) { inspectors = [[NSMutableArray alloc] init]; dockMenu = [[NSMenu alloc] initWithTitle:@"DockMenu"]; [dockMenu addItemWithTitle:@"Update Dyanmic Services" action:@selector(updateDynamicServices:) keyEquivalent:@""]; } return self; } - (void) dealloc { [inspectors release]; [dockMenu release]; [super dealloc]; } - (void) applicationDidFinishLaunching:(NSNotification *)aNotification { [NSApp setServicesProvider:self]; } - (void) inspectPasteboard:(NSPasteboard *)pboard { PasteboardInspectorController * inspector = [[PasteboardInspectorController alloc] initWithPasteboard:pboard]; [inspectors addObject:inspector]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(inspectorWillClose:) name:NSWindowWillCloseNotification object:[inspector window]]; [inspector showWindow:self]; [inspector release]; } - (void) inspectorWillClose:(NSNotification *)aNotification { NSWindow * window = [aNotification object]; [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowWillCloseNotification object:window]; PasteboardInspectorController * inspector = [window windowController]; [inspectors removeObject:inspector]; } - (void) inspectServicesPasteboard:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error { [self inspectPasteboard:pboard]; } - (void) generateTestImage:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error { [pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil]; NSString* html = @""; [pboard setString:html forType:NSHTMLPboardType]; } - (void) generateTestString:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error { [pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil]; [pboard setString:@"The slow brown fox jumped over the lazy dogs" forType:NSStringPboardType]; } - (IBAction) inspectGeneralPasteboard:(id)sender { [self inspectPasteboard:[NSPasteboard generalPasteboard]]; } - (IBAction) updateDynamicServices:(id)sender { NSUpdateDynamicServices(); } - (NSMenu *)applicationDockMenu:(NSApplication *)sender { return [[dockMenu retain] autorelease]; } @end