home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / Rhapsody / Graphics / ImageBrowser-1.0 / Controller.m < prev    next >
Encoding:
Text File  |  1998-01-11  |  2.2 KB  |  80 lines

  1. #import "Controller.h"
  2. #import "DAImageBrowser.h"
  3. #import "DAAbout.h"
  4. #import "DAPreferences.h"
  5.  
  6. @implementation Controller
  7.  
  8. - (void)applicationDidFinishLaunching:(NSNotification *)notification;
  9. {
  10.     NSDictionary    *filterTypes = [[NSUserDefaults standardUserDefaults] dictionaryForKey:FilterForExtensionsDefault];
  11.     if ( filterTypes == nil )
  12.     {
  13.         NSArray    *keys = [NSArray arrayWithObjects:@"tiff", @"gif", @"jpg", nil];
  14.         NSArray    *objects = [NSArray arrayWithObjects:@"Tagged Image File Format", @"Graphics Interchange Format", @"You know .. J-PEG", nil];
  15.  
  16.         NSDictionary *types = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
  17.         NSDictionary *defaults = [NSDictionary dictionaryWithObject:types forKey:FilterForExtensionsDefault];
  18.  
  19.  
  20.         [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
  21.     }
  22.  
  23. }
  24. - (void)openDirectory:(id)sender
  25. {
  26.     [DAImageBrowser openNewDirectory];
  27. }
  28.  
  29. - (void)openInfo:(id)sender
  30. {
  31.     [[DAAbout shared] display];
  32. }
  33.  
  34. - (void)openPreferences:(id)sender
  35. {
  36.     [[DAPreferences shared] display];
  37. }
  38.  
  39. - (void)browserDirectoryService:(NSPasteboard *)pboard userData:(NSString *)data error:(NSString **)error
  40. {
  41.     NSArray    *types = [pboard types];
  42.  
  43.     NSLog( @"Perfoming service" );
  44.     if ( [types containsObject:NSFilenamesPboardType])
  45.     {
  46.        NSArray    *filesArray = [pboard propertyListForType:NSFilenamesPboardType];
  47.  
  48.         NSLog( @"     %@", filesArray );
  49.  
  50.         if ( [filesArray count] > 0 )
  51.         {
  52.             NSEnumerator *fileEnum = [filesArray objectEnumerator];
  53.             NSString    *file = nil;
  54.  
  55.             while ( file = [fileEnum nextObject] )
  56.             {
  57.                 DAImageBrowser *browser = [[DAImageBrowser allocDocumentZone:@"DAImageBrowserService"] init];
  58.  
  59.                 [browser setRoot:file];
  60.                 [browser display];
  61.                 NSLog( @"     opened file %@", file );
  62.             }
  63.         }
  64.         else
  65.         {
  66.             *error = @"No selected directories";
  67.         }
  68.     }
  69.     else
  70.     {
  71.         /*
  72.         *error = NSLocalizedString(@"Error: Pasteboard doesn't contain a string.", @"Pasteboard couldn't give string.");
  73.     */
  74.         *error = @"Could not determine directory to browse";
  75.     }
  76.     return;
  77. }
  78.  
  79. @end
  80.