Preliminary support for .gmodel conversion. Fixes for sound support.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@14927 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2002-11-05 05:42:45 +00:00
parent afc80059b8
commit 0f7df4cc3d
4 changed files with 132 additions and 11 deletions

View file

@ -1,3 +1,10 @@
2002-11-05 Gregory John Casamento <greg_casamento@yahoo.com>
* GormDocument.m: added -[GormDocument openGModel:] to allow the
loading of .gmodel files for conversion into .gorm files.
* GormSoundInspector.m: Corrected a problem w/ deleting sounds which
was causing a core dump.
2002-11-03 Gregory John Casamento <greg_casamento@yahoo.com>
* GormDocument.m: Added methods for class support

View file

@ -106,6 +106,9 @@
// sound support
- (id) openSound: (id)sender;
// import gmodel
- (id) openGModel: (id)sender;
@end
#endif

View file

@ -28,11 +28,39 @@
#include "GormOutlineView.h"
#include <AppKit/NSSound.h>
// gmodel compatibility headers...
#include <AppKit/GMArchiver.h>
#include <AppKit/IMLoading.h>
#include <AppKit/IMCustomObject.h>
// forward declaration...
static Class gmodel_class(NSString *className);
NSString *IBDidOpenDocumentNotification = @"IBDidOpenDocumentNotification";
NSString *IBWillSaveDocumentNotification = @"IBWillSaveDocumentNotification";
NSString *IBDidSaveDocumentNotification = @"IBDidSaveDocumentNotification";
NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
// category to allow extraction of information from a gmodel file..
/*
@interface GMModel (GormAdditions)
- (NSArray *) objects;
- (NSArray *) connections;
@end
@implementation GMModel (GormAdditions)
- (NSArray *) objects
{
return objects;
}
- (NSArray *) connections
{
return connections;
}
@end
*/
@implementation GormFirstResponder
- (NSImage*) imageForViewer
{
@ -1818,11 +1846,11 @@ static NSImage *classesImage = nil;
if ([[NSUserDefaults standardUserDefaults] boolForKey: @"OpenNibs"] == YES)
{
fileTypes = [NSArray arrayWithObjects: @"gorm", @"nib", nil];
fileTypes = [NSArray arrayWithObjects: @"gorm", @"gmodel", @"nib", nil];
}
else
{
fileTypes = [NSArray arrayWithObjects: @"gorm", nil];
fileTypes = [NSArray arrayWithObjects: @"gorm", @"gmodel", nil];
}
[oPanel setAllowsMultipleSelection: NO];
[oPanel setCanChooseFiles: YES];
@ -1832,9 +1860,19 @@ static NSImage *classesImage = nil;
types: fileTypes];
if (result == NSOKButton)
{
NSString *filename = [oPanel filename];
NSString *ext = [filename pathExtension];
[[NSUserDefaults standardUserDefaults] setObject: [oPanel directory]
forKey:@"OpenDir"];
return [self loadDocument: [oPanel filename]];
if([ext isEqualToString:@"gorm"] || [ext isEqualToString:@"nib"])
{
return [self loadDocument: filename];
}
else if([ext isEqualToString:@"gmodel"])
{
return [self openGModel: filename];
}
}
return nil; /* Failed */
}
@ -2912,5 +2950,64 @@ shouldEditTableColumn: (NSTableColumn *)tableColumn
return nil;
}
// importing of legacy gmodel files.
- (id) openGModel: (NSString *)path
{
id unarchiver = nil;
id decoded = nil;
Class unarchiverClass = gmodel_class(@"GMUnarchiver");
NSLog (@"loading gmodel file %@...", path);
unarchiver = [unarchiverClass unarchiverWithContentsOfFile: path];
[unarchiver decodeClassName: @"IMCustomView" asClassName: @"GormCustomView"];
[unarchiver decodeClassName: @"IMCustomObject" asClassName: @"GormProxyObject"];
if (!unarchiver)
{
NSLog(@"Failed to load gmodel file %@!!",path);
return nil;
}
decoded = [unarchiver decodeObjectWithName:@"RootObject"];
[decoded _makeConnections];
NSLog(@"testing...");
// NSLog(@"objects = %@, connections = %@",[decoded objects], [decoded connections]);
return self;
}
@end
static
Class gmodel_class(NSString *className)
{
static Class gmclass = Nil;
if (gmclass == Nil)
{
NSBundle *theBundle;
NSEnumerator *benum;
NSString *path;
/* Find the bundle */
benum = [NSStandardLibraryPaths() objectEnumerator];
while ((path = [benum nextObject]))
{
path = [path stringByAppendingPathComponent: @"Bundles"];
path = [path stringByAppendingPathComponent: @"libgmodel.bundle"];
if ([[NSFileManager defaultManager] fileExistsAtPath: path])
break;
path = nil;
}
NSCAssert(path != nil, @"Unable to load gmodel bundle");
NSDebugLog(@"Loading gmodel from %@", path);
theBundle = [NSBundle bundleWithPath: path];
NSCAssert(theBundle != nil, @"Can't init gmodel bundle");
gmclass = [theBundle classNamed: className];
NSCAssert(gmclass, @"Can't load gmodel bundle");
}
return gmclass;
}

View file

@ -78,8 +78,21 @@
- (void) handleNotification: (NSNotification*)aNotification
{
id sndobject = [[[aNotification object] selection] objectAtIndex: 0];
id selection = [[aNotification object] selection];
id sndobject = nil;
// get the sound object...
if(selection != nil)
{
if([selection count] > 0)
{
sndobject = [selection objectAtIndex: 0];
}
}
// if its not nil, load it...
if(sndobject != nil)
{
if([sndobject isKindOfClass: [GormSound class]])
{
NSLog(@"Sound inspector notified: %@",sndobject);
@ -90,6 +103,7 @@
NSLog(@"Loaded sound");
}
}
}
- (void) awakeFromNib
{