home *** CD-ROM | disk | FTP | other *** search
- //=============================================================================
- //
- // Copyright (C) 1995 by Paul S. McCarthy and Eric Sunshine.
- // Written by Paul S. McCarthy and Eric Sunshine.
- // All Rights Reserved.
- //
- // This notice may not be removed from this source code.
- //
- // This object is included in the MiscKit by permission from the authors
- // and its use is governed by the MiscKit license, found in the file
- // "License.rtf" in the MiscKit distribution. Please refer to that file
- // for a list of all applicable permissions and restrictions.
- //
- //=============================================================================
- //-----------------------------------------------------------------------------
- // DirController.m
- //
- // Manages application which demonstrates use of TableScroll.
- //
- //-----------------------------------------------------------------------------
- //-----------------------------------------------------------------------------
- // $Id$
- // $Log$
- //-----------------------------------------------------------------------------
-
- #import "DirController.h"
- #import "DirWindow.h"
-
- @implementation DirController
-
- //-----------------------------------------------------------------------------
- // - init
- //-----------------------------------------------------------------------------
- - init
- {
- [super init];
- infoPanel = 0;
- return self;
- }
-
-
- //-----------------------------------------------------------------------------
- // - free
- //-----------------------------------------------------------------------------
- - free
- {
- if (infoPanel)
- [infoPanel free];
- return [super free];
- }
-
-
- //-----------------------------------------------------------------------------
- // - appDidInit:
- //-----------------------------------------------------------------------------
- - appDidInit: sender
- {
- [DirWindow launchDir:0];
- return self;
- }
-
-
- //-----------------------------------------------------------------------------
- // - new:
- //-----------------------------------------------------------------------------
- - new:sender
- {
- int rc;
- OpenPanel* panel = [OpenPanel new];
- [panel setTitle: "Open Directory"];
- [panel setPrompt:"Directory:"];
- [panel chooseDirectories: YES];
- [panel allowMultipleFiles: NO]; // OpenPanel screws up multiple dirs.
- [panel setTreatsFilePackagesAsDirectories: YES];
- rc = [panel runModal];
- [panel close];
- if (rc == NX_OKTAG)
- {
- char const* const* filename;
- char const* dir = [panel directory];
- if (dir == 0) dir = "";
- for (filename = [panel filenames]; *filename != 0; filename++)
- {
- char buff[ FILENAME_MAX * 2 + 1 ];
- strcat( strcat( strcpy( buff, dir ), "/" ), *filename );
- [DirWindow launchDir: buff];
- }
- }
- return self;
- }
-
-
- //-----------------------------------------------------------------------------
- // - info:
- //-----------------------------------------------------------------------------
- - info:sender
- {
- if (infoPanel == 0)
- {
- char buff[ FILENAME_MAX + 1 ];
- id const bundle = [NXBundle bundleForClass:[self class]];
- [bundle getPath:buff forResource:"Info" ofType:"nib"];
- [NXApp loadNibFile:buff owner:self withNames:NO fromZone:[self zone]];
-
- if (![bundle getPath:buff forResource:"README" ofType:"rtf"])
- [bundle getPath:buff forResource:"README" ofType:"rtfd"];
- [infoText openRTFDFrom:buff];
- }
- [infoPanel makeKeyAndOrderFront:self];
- return self;
- }
-
- @end
-