Document system change to NSWindow, GC update for NSWindowController

New method implemented in NSWorkspace


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6434 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
jagapen 2000-04-07 23:49:10 +00:00
parent 5e57d2f303
commit 8344d89c2a
4 changed files with 241 additions and 139 deletions

View file

@ -1,3 +1,11 @@
2000-04-07 Jonathan Gapen <jagapen@whitewater.chem.wisc.edu>
* Source/NSWindow.m: Update [-performClose:] to check send
[-windowWillClose:] message to window controller's document.
* Source/NSWindowController.m: Add copyright notice, update
to GC-compatible RETAIN/ASSIGN macros, re-format.
* Source/NSWorkspace.m: [-getInfoForFile:application:type:] Implement.
2000-04-06 Adam Fedor <fedor@gnu.org>
* Source/GSFontInfo.m: allFonts returns GSFontInfo objects.

View file

@ -1780,6 +1780,18 @@ resetCursorRectsForView(NSView *theView)
return;
}
if (_windowController)
{
NSDocument *document = [_windowController document];
if (document && (document != _delegate)
&& [document respondsToSelector: @selector(windowShouldClose:)]
&& ![document windowShouldClose: self])
{
NSBeep();
return;
}
}
if ([_delegate respondsToSelector: @selector(windowShouldClose:)])
{
/*

View file

@ -1,3 +1,25 @@
/*
NSWindowController.m
Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#import <AppKit/NSWindowController.h>
#import <AppKit/NSPanel.h>
#import <AppKit/NSNibLoading.h>
@ -13,7 +35,7 @@
- (id)initWithWindowNibName:(NSString *)windowNibName owner:(id)owner
{
[self initWithWindow:nil];
_windowNibName = [windowNibName retain];
_windowNibName = RETAIN(windowNibName);
_owner = owner;
return self;
}
@ -22,7 +44,7 @@
{
[super init];
_window = [window retain];
_window = RETAIN(window);
_windowFrameAutosaveName = @"";
_wcFlags.shouldCascade = YES;
_wcFlags.shouldCloseDocument = NO;
@ -43,10 +65,10 @@
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[_windowNibName release];
[_windowFrameAutosaveName release];
[_topLevelObjects release];
[_window autorelease];
RELEASE(_windowNibName);
RELEASE(_windowFrameAutosaveName);
RELEASE(_topLevelObjects);
AUTORELEASE(_window);
[super dealloc];
}
@ -62,7 +84,7 @@
- (void)setDocument:(NSDocument *)document
{
_document = document;
ASSIGN(_document, document);
[self _synchronizeWindowTitleWithDocumentName];
}
@ -73,9 +95,7 @@
- (void)setWindowFrameAutosaveName:(NSString *)name
{
[name retain];
[_windowFrameAutosaveName release];
_windowFrameAutosaveName = name;
ASSIGN(_windowFrameAutosaveName, name);
if ([self isWindowLoaded])
{
@ -123,7 +143,7 @@
/*
* If the window is set to isReleasedWhenClosed, it will release
* itself, so nil out our reference so we don't release it again.
* itself, so nil out our reference so we don't release it again
* We may want to unilaterally turn off the setting in the NSWindow
* instance so it doesn't cause problems.
*
@ -162,8 +182,7 @@
// Private method; the nib loading will call this.
- (void)setWindow:(NSWindow *)aWindow
{
[_window autorelease];
_window = [aWindow retain];
ASSIGN(_window, aWindow);
}
- (IBAction)showWindow:(id)sender
@ -299,4 +318,3 @@
}
@end

View file

@ -50,6 +50,8 @@
#define stringify_it(X) #X
#define mkpath(X) stringify_it(X) "/Tools"
#define PosixExecutePermission (0111)
static NSString *GSWorkspaceNotification = @"GSWorkspaceNotification";
@interface _GSWorkspaceCenter: NSNotificationCenter
@ -736,6 +738,68 @@ inFileViewerRootedAtPath: (NSString *)rootFullpath
application: (NSString **)appName
type: (NSString **)type
{
NSFileManager *fm = [NSFileManager defaultManager];
NSDictionary *attributes;
NSString *fileType;
NSString *extension = [fullPath pathExtension];
attributes = [fm fileAttributesAtPath:fullPath traverseLink:YES];
if (attributes)
{
fileType = [attributes fileType];
if ([fileType isEqualToString: NSFileTypeRegular])
{
if ([attributes filePosixPermissions] & PosixExecutePermission)
{
*type = NSShellCommandFileType;
*appName = nil;
}
else
{
*type = NSPlainFileType;
*appName = [self getBestAppInRole:nil forExtension:extension];
}
}
else if([fileType isEqualToString: NSFileTypeDirectory])
{
if ([extension isEqualToString: @"app"]
|| [extension isEqualToString: @"debug"]
|| [extension isEqualToString: @"profile"])
{
*type = NSApplicationFileType;
*appName = nil;
}
else if ([extension isEqualToString: @"bundle"])
{
*type = NSPlainFileType;
*appName = nil;
}
// the idea here is that if the parent directory's fileSystemNumber
// differs, this must be a filesystem mount point
else if ([[fm fileAttributesAtPath:
[fullPath stringByDeletingLastPathComponent]
traverseLink:YES] fileSystemNumber]
!= [attributes fileSystemNumber])
{
*type = NSFilesystemFileType;
*appName = nil;
}
else
{
*type = NSDirectoryFileType;
*appName = nil;
}
}
else
{
// this catches sockets, character special, block special, and
// unknown file types
*type = NSPlainFileType;
*appName = nil;
}
return YES;
}
else
return NO;
}