Update info, add category that replaces some methods so that the document can be loaded in the tool

This commit is contained in:
Gregory John Casamento 2023-06-30 21:13:56 -04:00
parent af4f72f3f5
commit abdeb60d0c
2 changed files with 88 additions and 9 deletions

View file

@ -54,15 +54,15 @@
ApplicationDescription = "[GNUstep | Graphical] Object Relationship Modeller";
ApplicationIcon = "Gorm.tiff";
ApplicationName = "Gorm";
ApplicationRelease = "Gorm 1.4.0 (Unrelease)";
ApplicationRelease = "Gorm 1.4.0 (Unreleased)";
Authors = ("Gregory John Casamento <greg.casamento@gmail.com>",
"Adam Fedor <fedor@gnu.org>",
"Richard Frith-Macdonald <rfm@gnu.org>",
"Wolfgang Lux <wolfgang.lux@gmail.com>",
"Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>",
"Sergii Stoian <stoyan255@gmail.com>");
Copyright = "Copyright (C) 1999-2022 FSF";
Copyright = "Copyright (C) 1999-2023 FSF";
CopyrightDescription = "Released under the GNU General Public License 3.0";
NSBuildVersion = "1.4.0 (Unreleased)";
NSBuildVersion = "1.4.0";
GSDesktopInstallationDomain=SYSTEM;
}

View file

@ -23,20 +23,96 @@
* USA.
*/
#import <Foundation/NSDictionary.h>
#import <Foundation/NSNotification.h>
#import <Foundation/NSProcessInfo.h>
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import <GormCore/GormPlugin.h>
#import <GormCore/GormDocumentController.h>
#import <GNUstepGUI/GSNibLoading.h>
#import "AppDelegate.h"
static NSMutableArray *__types = nil;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wobjc-protocol-method-implementation"
// Special method category smashes so that we can register types...
@implementation NSDocumentController (ToolPrivate)
- (Class) documentClassForType: (NSString *)type
{
return [GormDocument class];
}
- (NSString *) typeFromFileExtension: (NSString *)fileExtension
{
int i, count = [__types count];
// Check for a document type with the supplied extension
for (i = 0; i < count; i++)
{
NSDictionary *typeInfo = [__types objectAtIndex: i];
NSArray *array = [typeInfo objectForKey: @"NSUnixExtensions"];
NSDebugLog(@"typeInfo = %@", typeInfo);
NSDebugLog(@"fileExtension = %@", fileExtension);
if ([array containsObject: fileExtension])
{
NSString *type = [typeInfo objectForKey: @"NSName"];
NSDebugLog(@"type = %@", type);
return type;
}
}
NSDebugLog(@"FAILED");
return nil;
}
@end
@implementation GormPlugin (ToolPrivate)
- (void) registerDocumentTypeName: (NSString *)name
humanReadableName: (NSString *)hrName
forExtensions: (NSArray *)extensions
{
if (__types == nil)
{
__types = [NSMutableArray arrayWithCapacity: 10];
}
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
name, @"NSName",
hrName, @"NSHumanReadableName",
extensions, @"NSUnixExtensions",
nil];
[__types addObject: dict];
NSDebugLog(@"__types = %@", __types);
}
@end
#pragma GCC diagnostic pop
// AppDelegate...
@implementation AppDelegate
+ (void) initialize
{
if (__types == nil)
{
__types = [NSMutableArray arrayWithCapacity: 10];
}
}
- (void) process
{
NSProcessInfo *pi = [NSProcessInfo processInfo];
GormDocumentController *dc = [GormDocumentController sharedDocumentController];
[NSClassSwapper setIsInInterfaceBuilder: YES];
@ -45,9 +121,12 @@
if ([[pi arguments] count] > 1)
{
NSString *file = [[pi arguments] objectAtIndex: 1];
GormDocumentController *dc = [GormDocumentController sharedDocumentController];
GormDocument *doc = nil;
NSLog(@"file = %@", file);
[dc openDocumentWithContentsOfFile: file display: NO];
doc = [dc openDocumentWithContentsOfFile: file display: NO];
NSLog(@"Document = %@", doc);
}
[NSClassSwapper setIsInInterfaceBuilder: NO];