Fake class for gmodel loading, loads from gmodel.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3254 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
tremblay2 1998-11-19 21:55:18 +00:00
parent ee07f0239c
commit f0dd01323e

View file

@ -1,4 +1,4 @@
/* /* -*- C++ -*-
NSSavePanel.m NSSavePanel.m
Standard save panel for saving files Standard save panel for saving files
@ -41,6 +41,8 @@
#include <AppKit/NSSavePanel.h> #include <AppKit/NSSavePanel.h>
#include <AppKit/NSOpenPanel.h> #include <AppKit/NSOpenPanel.h>
#include <AppKit/NSBrowserCell.h> #include <AppKit/NSBrowserCell.h>
#include <AppKit/IMLoading.h>
#include <extensions/GMArchiver.h>
// toDo: // toDo:
// - interactive directory creation in SavePanel // - interactive directory creation in SavePanel
@ -49,12 +51,38 @@
// files // files
//
// Fake class for gmodel
//
// //
// Class variables // Class variables
// //
static NSSavePanel *gnustep_gui_save_panel = nil; static NSSavePanel *gnustep_gui_save_panel = nil;
@interface _SavePanel : NSObject
@end
@implementation _SavePanel
//
// Model stuff
//
- (id)initWithModelUnarchiver :(GMUnarchiver*)unarchiver
{
if (!gnustep_gui_save_panel)
gnustep_gui_save_panel = [unarchiver decodeObjectWithName:@"panel"];
return self;
}
- (void)encodeWithModelArchiver :(GMArchiver *)archiver
{
if (gnustep_gui_save_panel)
[archiver encodeObject:gnustep_gui_save_panel withName:@"panel"];
}
@end
// Save panel
@implementation NSSavePanel @implementation NSSavePanel
// //
@ -63,7 +91,7 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
+ (void)initialize + (void)initialize
{ {
if (self == [NSSavePanel class]) if (self == [NSSavePanel class])
[self setVersion:1]; // Initial version [self setVersion:1]; //initial version
} }
// //
@ -71,13 +99,17 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
// //
+ (NSSavePanel *)savePanel + (NSSavePanel *)savePanel
{ {
if(!gnustep_gui_save_panel) if(!gnustep_gui_save_panel) {
{ if (![GMModel loadIMFile :
// PanelLoader *pl = [PanelLoader panelLoader]; @"/usr/GNUstep/Library/Model/SavePanel.gmodel"
// gnustep_gui_save_panel = (NSSavePanel *)[pl loadPanel: @"NSSavePanel"]; owner:[_SavePanel alloc]]) {
gnustep_gui_save_panel = [[NSSavePanel alloc] init]; fprintf(stderr, "Cannot open save panel model file\n");
exit(1);
}
} }
//was it loaded?
NSLog(@"Savepanel: %@", [gnustep_gui_save_panel description]);
return gnustep_gui_save_panel; return gnustep_gui_save_panel;
} }
@ -190,27 +222,31 @@ NSString *standardizedPath=[path stringByStandardizingPath];
{ {
int ret; int ret;
[browser loadColumnZero]; //[browser loadColumnZero];
[self setDirectory:path]; [self setDirectory:path];
[browser setPath:[NSString stringWithFormat:@"%@/%@", //[browser setPath:[NSString stringWithFormat:@"%@/%@",
[self directory], name]]; //[self directory], name]];
[form setStringValue:name]; //[form setStringValue:name];
[self selectText:self]; // or should it be browser? [self selectText:self]; // or should it be browser?
/*
if([self class] == [NSOpenPanel class]) if([self class] == [NSOpenPanel class])
[okButton setEnabled: [okButton setEnabled:
([browser selectedCell] && [self canChooseDirectories]) || ([browser selectedCell] && [self canChooseDirectories]) ||
[[browser selectedCell] isLeaf]]; [[browser selectedCell] isLeaf]];
*/
[self makeKeyAndOrderFront:self]; [self makeKeyAndOrderFront:self];
ret = [[NSApplication sharedApplication] runModalForWindow:self]; ret = [[NSApplication sharedApplication] runModalForWindow:self];
// replace warning // replace warning
/*
if([self class] == [NSSavePanel class] && if([self class] == [NSSavePanel class] &&
[[browser selectedCell] isLeaf] && ret == NSOKButton) [[browser selectedCell] isLeaf] && ret == NSOKButton) {
{
//if(NSRunAlertPanel(@"Save",@"The file %@ in %@ exists. Replace it?", //if(NSRunAlertPanel(@"Save",@"The file %@ in %@ exists. Replace it?",
// @"Replace",@"Cancel",nil,[form stringValue], //dafplace",@"Cancel",nil,[form stringValue],
// [self directory]) == NSAlertAlternateReturn) // [self directory]) == NSAlertAlternateReturn)
return NSCancelButton; return NSCancelButton;
} }
*/
return ret; return ret;
} }