mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
Changes to correct a minor crash and to allow the user to access the system images from within Gorm.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@19338 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a987861958
commit
17e6bc1492
11 changed files with 135 additions and 66 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
|||
2004-05-15 11:14 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Gorm.m: Add call to [GormDocument closeAllEditors] to
|
||||
avoid a crash when the user attempts to open a document, then
|
||||
cancels. The document wasn't properly released.
|
||||
* GormDocument.h: Removed the images and sounds arrays. This
|
||||
information is kept in the editor and these arrays are redundant.
|
||||
Also exposed the closeAllEditors method.
|
||||
* GormDocument.m: Removed references to the images and sounds
|
||||
array. Changed load/save logic to use the list from the editors
|
||||
themselves.
|
||||
* GormFunctions.[hm]: Added function to retrieve the names of the
|
||||
images from the system directory named systemImagesList().
|
||||
* GormImageEditor.m: Modified to call the new function and add the
|
||||
images to the editor when it is first instantiated.
|
||||
* GormPrivate.h: Added objects method to GormGenericEditor's interface.
|
||||
* GormSoundInspector.h: Changed _currentSound to id.
|
||||
* GormSoundInspector.m: Uses _currentSound to make certain that the
|
||||
same GormSound object isn't reinspected, thus wasting time loading
|
||||
it over and over.
|
||||
|
||||
2004-05-14 22:11 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormDocument.m: [GormDocument _closeAllEditors]
|
||||
|
|
1
Gorm.m
1
Gorm.m
|
@ -581,6 +581,7 @@ NSString *GormResizeCellNotification = @"GormResizeCellNotification";
|
|||
[documents addObject: doc];
|
||||
if ([doc openDocument: sender] == nil)
|
||||
{
|
||||
[doc closeAllEditors];
|
||||
[documents removeObjectIdenticalTo: doc];
|
||||
doc = nil;
|
||||
}
|
||||
|
|
|
@ -67,8 +67,6 @@
|
|||
NSMenuItem *quitItem; /* Replaced during test */
|
||||
NSMutableArray *savedEditors;
|
||||
NSMutableArray *hidden;
|
||||
NSMutableSet *sounds;
|
||||
NSMutableSet *images;
|
||||
NSMutableArray *openEditors;
|
||||
}
|
||||
- (void) addConnector: (id<IBConnectors>)aConnector;
|
||||
|
@ -149,6 +147,7 @@
|
|||
- (BOOL) renameConnectionsForClassNamed: (NSString *)name
|
||||
toName: (NSString *)newName;
|
||||
- (BOOL) isTopLevelObject: (id)obj;
|
||||
- (void) closeAllEditors;
|
||||
|
||||
// class loading
|
||||
- (id) loadClass: (id)sender;
|
||||
|
|
110
GormDocument.m
110
GormDocument.m
|
@ -1459,7 +1459,7 @@ static NSImage *classesImage = nil;
|
|||
[savedEditors removeAllObjects];
|
||||
}
|
||||
|
||||
- (void) _closeAllEditors
|
||||
- (void) closeAllEditors
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id<IBConnectors> con;
|
||||
|
@ -1534,7 +1534,7 @@ static NSImage *classesImage = nil;
|
|||
// deactivate the document...
|
||||
[self setDocumentActive: NO];
|
||||
[self setSelectionFromEditor: nil];
|
||||
[self _closeAllEditors]; // shut down all of the editors..
|
||||
[self closeAllEditors]; // shut down all of the editors..
|
||||
[nc postNotificationName: IBWillCloseDocumentNotification
|
||||
object: self];
|
||||
[nc removeObserver: self]; // stop listening to all notifications.
|
||||
|
@ -1668,10 +1668,6 @@ static NSImage *classesImage = nil;
|
|||
// for saving the editors when the gorm file is persisted.
|
||||
savedEditors = [NSMutableArray new];
|
||||
|
||||
// sounds & images
|
||||
sounds = [NSMutableSet new];
|
||||
images = [NSMutableSet new];
|
||||
|
||||
style = NSTitledWindowMask | NSClosableWindowMask
|
||||
| NSResizableWindowMask | NSMiniaturizableWindowMask;
|
||||
window = [[NSWindow alloc] initWithContentRect: winrect
|
||||
|
@ -2255,7 +2251,6 @@ static NSImage *classesImage = nil;
|
|||
NSDebugLog(@"Add the sound %@", file);
|
||||
soundPath = [documentPath stringByAppendingPathComponent: file];
|
||||
[soundsView addObject: [self _createSoundPlaceHolder: soundPath]];
|
||||
[sounds addObject: soundPath];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2282,7 +2277,6 @@ static NSImage *classesImage = nil;
|
|||
{
|
||||
NSDebugLog(@"Add the image %@", file);
|
||||
[imagesView addObject: placeHolder];
|
||||
[images addObject: imagePath];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3056,62 +3050,69 @@ static NSImage *classesImage = nil;
|
|||
// copy sounds into the new folder...
|
||||
if (archiveResult)
|
||||
{
|
||||
NSEnumerator *en = [sounds objectEnumerator];
|
||||
NSArray *sounds = [soundsView objects];
|
||||
NSArray *images = [imagesView objects];
|
||||
id object = nil;
|
||||
|
||||
NSEnumerator *en = [sounds objectEnumerator];
|
||||
while ((object = [en nextObject]) != nil)
|
||||
{
|
||||
NSString *soundPath;
|
||||
BOOL copied = NO;
|
||||
|
||||
soundPath = [documentPath stringByAppendingPathComponent:
|
||||
[object lastPathComponent]];
|
||||
if(![object isEqualToString: soundPath])
|
||||
if(![object isSystemSound])
|
||||
{
|
||||
copied = [mgr copyPath: object
|
||||
toPath: soundPath
|
||||
handler: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
// mark as copied if paths are equal...
|
||||
copied = YES;
|
||||
}
|
||||
|
||||
if (!copied)
|
||||
{
|
||||
NSDebugLog(@"Could not find sound at path %@", object);
|
||||
NSString *soundPath;
|
||||
NSString *path = [object soundPath];
|
||||
BOOL copied = NO;
|
||||
|
||||
soundPath = [documentPath stringByAppendingPathComponent:
|
||||
[path lastPathComponent]];
|
||||
if(![path isEqualToString: soundPath])
|
||||
{
|
||||
copied = [mgr copyPath: path
|
||||
toPath: soundPath
|
||||
handler: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
// mark as copied if paths are equal...
|
||||
copied = YES;
|
||||
}
|
||||
|
||||
if (!copied)
|
||||
{
|
||||
NSDebugLog(@"Could not find sound at path %@", object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
en = [images objectEnumerator];
|
||||
|
||||
while ((object = [en nextObject]) != nil)
|
||||
{
|
||||
NSString *imagePath;
|
||||
BOOL copied = NO;
|
||||
|
||||
imagePath = [documentPath stringByAppendingPathComponent:
|
||||
[object lastPathComponent]];
|
||||
|
||||
if(![object isEqualToString: imagePath])
|
||||
if(![object isSystemImage])
|
||||
{
|
||||
copied = [mgr copyPath: object
|
||||
toPath: imagePath
|
||||
handler: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
// mark it as copied if paths are equal.
|
||||
copied = YES;
|
||||
}
|
||||
|
||||
if (!copied)
|
||||
{
|
||||
NSDebugLog(@"Could not find image at path %@", object);
|
||||
NSString *imagePath;
|
||||
NSString *path = [object imagePath];
|
||||
BOOL copied = NO;
|
||||
|
||||
imagePath = [documentPath stringByAppendingPathComponent:
|
||||
[path lastPathComponent]];
|
||||
|
||||
if(![path isEqualToString: imagePath])
|
||||
{
|
||||
copied = [mgr copyPath: path
|
||||
toPath: imagePath
|
||||
handler: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
// mark it as copied if paths are equal.
|
||||
copied = YES;
|
||||
}
|
||||
|
||||
if (!copied)
|
||||
{
|
||||
NSDebugLog(@"Could not find image at path %@", object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3854,7 +3855,6 @@ shouldEditTableColumn: (NSTableColumn *)tableColumn
|
|||
filename = [filenames objectAtIndex:i];
|
||||
NSDebugLog(@"Loading sound file: %@",filenames);
|
||||
[soundsView addObject: [self _createSoundPlaceHolder: filename]];
|
||||
[sounds addObject: filename];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -3886,7 +3886,6 @@ shouldEditTableColumn: (NSTableColumn *)tableColumn
|
|||
filename = [filenames objectAtIndex:i];
|
||||
NSDebugLog(@"Loading image file: %@",filename);
|
||||
[imagesView addObject: [self _createImagePlaceHolder: filename]];
|
||||
[images addObject: filename];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -3894,11 +3893,6 @@ shouldEditTableColumn: (NSTableColumn *)tableColumn
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (void) addImage: (NSString*) path
|
||||
{
|
||||
[images addObject: path];
|
||||
}
|
||||
|
||||
- (NSString *) description
|
||||
{
|
||||
return [NSString stringWithFormat: @"<%s: %lx> = %@",
|
||||
|
|
|
@ -56,4 +56,6 @@ NSColor *colorFromDict(NSDictionary *colorString);
|
|||
// color to string
|
||||
NSDictionary *colorToDict(NSColor *color);
|
||||
|
||||
// get the list of images...
|
||||
NSArray *systemImagesList();
|
||||
#endif
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
#include "GormViewEditor.h"
|
||||
#include <AppKit/AppKit.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSFileManager.h>
|
||||
#include <Foundation/NSPathUtilities.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
||||
// find all subitems for the given items...
|
||||
void findAllWithArray(id item, NSMutableArray *array)
|
||||
|
@ -217,3 +221,26 @@ NSDictionary *colorToDict(NSColor *color)
|
|||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSArray *systemImagesList()
|
||||
{
|
||||
NSString *system = [NSOpenStepRootDirectory() stringByAppendingPathComponent: @"System"];
|
||||
NSString *lib = [system stringByAppendingPathComponent: @"Library"];
|
||||
NSString *path = [lib stringByAppendingPathComponent: @"Images"];
|
||||
NSArray *contents = [[NSFileManager defaultManager] directoryContentsAtPath: path];
|
||||
NSEnumerator *en = [contents objectEnumerator];
|
||||
NSMutableArray *result = [NSMutableArray array];
|
||||
id obj;
|
||||
NSArray *fileTypes = [NSImage imageFileTypes];
|
||||
|
||||
while((obj = [en nextObject]) != nil)
|
||||
{
|
||||
if([fileTypes containsObject: [obj pathExtension]])
|
||||
{
|
||||
NSString *pathString = [path stringByAppendingPathComponent: obj];
|
||||
[result addObject: pathString];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -304,4 +304,9 @@
|
|||
[document setSelectionFromEditor: self];
|
||||
[self makeSelectionVisible: YES];
|
||||
}
|
||||
|
||||
- (NSArray *) objects
|
||||
{
|
||||
return objects;
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -143,10 +143,7 @@ static int handled_mask= NSDragOperationCopy|NSDragOperationGeneric|NSDragOperat
|
|||
{
|
||||
NSLog(@"here %@", [data objectAtIndex: i]);
|
||||
[self addObject: placeHolder];
|
||||
[(GormDocument *)document addImage: [data objectAtIndex: i]];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
@ -198,6 +195,9 @@ static int handled_mask= NSDragOperationCopy|NSDragOperationGeneric|NSDragOperat
|
|||
if (self != nil)
|
||||
{
|
||||
NSButtonCell *proto;
|
||||
NSArray *list;
|
||||
NSEnumerator *en;
|
||||
id obj;
|
||||
|
||||
[self registerForDraggedTypes: [NSArray arrayWithObjects:
|
||||
NSFilenamesPboardType, nil]];
|
||||
|
@ -224,7 +224,23 @@ static int handled_mask= NSDragOperationCopy|NSDragOperationGeneric|NSDragOperat
|
|||
[self setPrototype: proto];
|
||||
RELEASE(proto);
|
||||
NSMapInsert(docMap, (void*)aDocument, (void*)self);
|
||||
[self addObject: anObject];
|
||||
|
||||
// do not insert it if it's nil.
|
||||
if(anObject != nil)
|
||||
{
|
||||
[self addObject: anObject];
|
||||
}
|
||||
|
||||
// add all of the system objects...
|
||||
list = systemImagesList();
|
||||
en = [list objectEnumerator];
|
||||
while((obj = [en nextObject]) != nil)
|
||||
{
|
||||
NSString *name = [[obj lastPathComponent] stringByDeletingPathExtension];
|
||||
GormImage *image = [[GormImage alloc] initWithName: name path: obj];
|
||||
[image setSystemImage: YES];
|
||||
[self addObject: image];
|
||||
}
|
||||
|
||||
// set up the notification...
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
|
|
|
@ -204,6 +204,8 @@ extern NSString *GormResizeCellNotification;
|
|||
- (void) orderFront;
|
||||
- (void) pasteInSelection;
|
||||
- (NSRect) rectForObject: (id)anObject;
|
||||
|
||||
- (NSArray *) objects;
|
||||
@end
|
||||
|
||||
// private methods...
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
@interface GormSoundInspector : IBInspector
|
||||
{
|
||||
NSSound *_currentSound;
|
||||
id *_currentSound;
|
||||
GormSoundView *soundView;
|
||||
}
|
||||
- (void) stop: (id)sender;
|
||||
|
|
|
@ -68,11 +68,13 @@
|
|||
- (void) setObject: (id)anObject
|
||||
{
|
||||
// if its not nil, load it...
|
||||
if(anObject != nil)
|
||||
if(anObject != nil && anObject != _currentSound)
|
||||
{
|
||||
if([anObject isKindOfClass: [GormSound class]])
|
||||
{
|
||||
id snd;
|
||||
|
||||
_currentSound = anObject;
|
||||
NSDebugLog(@"Sound inspector notified: %@",anObject);
|
||||
snd = AUTORELEASE([[NSSound alloc] initWithContentsOfFile: [anObject soundPath]
|
||||
byReference: YES]);
|
||||
|
|
Loading…
Reference in a new issue