home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / YellowBox / Kits / MiscTableScroll-138.1 / Examples / ScrollDir / DirController.m < prev    next >
Encoding:
Text File  |  1998-03-31  |  4.2 KB  |  137 lines

  1. //=============================================================================
  2. //
  3. //    Copyright (C) 1995-1997 by Paul S. McCarthy and Eric Sunshine.
  4. //        Written by Paul S. McCarthy and Eric Sunshine.
  5. //                All Rights Reserved.
  6. //
  7. //    This notice may not be removed from this source code.
  8. //
  9. //    This object is included in the MiscKit by permission from the authors
  10. //    and its use is governed by the MiscKit license, found in the file
  11. //    "License.rtf" in the MiscKit distribution.  Please refer to that file
  12. //    for a list of all applicable permissions and restrictions.
  13. //
  14. //=============================================================================
  15. //-----------------------------------------------------------------------------
  16. // DirController.m
  17. //
  18. //    Manages application which demonstrates use of TableScroll.
  19. //
  20. //-----------------------------------------------------------------------------
  21. //-----------------------------------------------------------------------------
  22. // $Id: DirController.m,v 1.2 97/03/23 01:41:00 sunshine Exp $
  23. // $Log:    DirController.m,v $
  24. // Revision 1.2  97/03/23  01:41:00  sunshine
  25. // v29.2: Brought into syncrhonization with LazyScrollDir v13.1 for OPENSTSEP.
  26. // 
  27. // Revision 1.1  97/03/21  18:30:47  sunshine
  28. // v28: Directory controller.
  29. //-----------------------------------------------------------------------------
  30. #import "DirController.h"
  31. #import "Defaults.h"
  32. #import "DirWindow.h"
  33. #import "SD_PageLayout.h"
  34. #import <AppKit/NSNibLoading.h>
  35. #import <AppKit/NSOpenPanel.h>
  36. #import <AppKit/NSTextField.h>
  37.  
  38. @implementation DirController
  39.  
  40. //-----------------------------------------------------------------------------
  41. // - init
  42. //-----------------------------------------------------------------------------
  43. - (id)init
  44.     {
  45.     [super init];
  46.     infoPanel = 0;
  47.     return self;
  48.     }
  49.  
  50.  
  51. //-----------------------------------------------------------------------------
  52. // - dealloc
  53. //-----------------------------------------------------------------------------
  54. - (void)dealloc
  55.     {
  56.     if (infoPanel)
  57.     [infoPanel release];
  58.     [super dealloc];
  59.     }
  60.  
  61.  
  62. //-----------------------------------------------------------------------------
  63. // - applicationDidFinishLaunching:
  64. //-----------------------------------------------------------------------------
  65. - (void)applicationDidFinishLaunching:(NSNotification*)n
  66.     {
  67.     [DirWindow launchDir:0];
  68.     }
  69.  
  70.  
  71. //-----------------------------------------------------------------------------
  72. // - applicationWillTerminate:
  73. //-----------------------------------------------------------------------------
  74. - (void)applicationWillTerminate:(NSNotification*)n
  75.     {
  76.     [Defaults commit];
  77.     }
  78.  
  79.  
  80. //-----------------------------------------------------------------------------
  81. // - runPageLayout:
  82. //-----------------------------------------------------------------------------
  83. - (void)runPageLayout:(id)sender
  84.     {
  85.     [[SD_PageLayout pageLayout] runModal];
  86.     }
  87.  
  88.  
  89. //-----------------------------------------------------------------------------
  90. // - new:
  91. //-----------------------------------------------------------------------------
  92. - (void)new:(id)sender
  93.     {
  94.     static NSOpenPanel* panel = 0;
  95.     if (panel == 0)
  96.     {
  97.     panel = [[NSOpenPanel openPanel] retain];
  98.     [panel setTitle:@"Open Directory"];
  99.     [panel setPrompt:@"Directory:"];
  100.     [panel setCanChooseDirectories:YES];
  101.     [panel setCanChooseFiles:NO];
  102.     [panel setAllowsMultipleSelection:YES];
  103.     [panel setTreatsFilePackagesAsDirectories:YES];
  104.     }
  105.  
  106.     if ([panel runModal] == NSOKButton)
  107.         {
  108.     unsigned int i;
  109.     NSArray* filenames = [panel filenames];
  110.     for (i = [filenames count]; i-- > 0; )
  111.         [DirWindow launchDir:[filenames objectAtIndex:i]];
  112.     } 
  113.     }
  114.  
  115.  
  116. //-----------------------------------------------------------------------------
  117. // - info:
  118. //-----------------------------------------------------------------------------
  119. - (void)info:(id)sender
  120.     {
  121.     if (infoPanel == 0)
  122.     {
  123.     NSString* s;
  124.     [NSBundle loadNibNamed:@"Info" owner:self];
  125.     s = [[NSBundle bundleForClass:[self class]]
  126.             pathForResource:@"README" ofType:@"rtf"];
  127.     if (s == 0)
  128.         s = [[NSBundle bundleForClass:[self class]]
  129.             pathForResource:@"README" ofType:@"rtfd"];
  130.     if (s != 0)
  131.         [infoText readRTFDFromFile:s];
  132.     }
  133.     [infoPanel makeKeyAndOrderFront:self]; 
  134.     }
  135.  
  136. @end
  137.