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,14 +99,18 @@ 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);
}
}
return gnustep_gui_save_panel; //was it loaded?
NSLog(@"Savepanel: %@", [gnustep_gui_save_panel description]);
return gnustep_gui_save_panel;
} }
// //
@ -188,36 +220,40 @@ NSString *standardizedPath=[path stringByStandardizingPath];
// //
- (int)runModalForDirectory:(NSString *)path file:(NSString *)name - (int)runModalForDirectory:(NSString *)path file:(NSString *)name
{ {
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]) /*
[okButton setEnabled: if([self class] == [NSOpenPanel class])
([browser selectedCell] && [self canChooseDirectories]) || [okButton setEnabled:
[[browser selectedCell] isLeaf]]; ([browser selectedCell] && [self canChooseDirectories]) ||
[self makeKeyAndOrderFront:self]; [[browser selectedCell] isLeaf]];
ret = [[NSApplication sharedApplication] runModalForWindow:self]; */
// replace warning [self makeKeyAndOrderFront:self];
if([self class] == [NSSavePanel class] && ret = [[NSApplication sharedApplication] runModalForWindow:self];
[[browser selectedCell] isLeaf] && ret == NSOKButton)
{ // replace warning
// if(NSRunAlertPanel(@"Save",@"The file %@ in %@ exists. Replace it?", /*
// @"Replace",@"Cancel",nil,[form stringValue], if([self class] == [NSSavePanel class] &&
// [self directory]) == NSAlertAlternateReturn) [[browser selectedCell] isLeaf] && ret == NSOKButton) {
return NSCancelButton; //if(NSRunAlertPanel(@"Save",@"The file %@ in %@ exists. Replace it?",
} //dafplace",@"Cancel",nil,[form stringValue],
// [self directory]) == NSAlertAlternateReturn)
return NSCancelButton;
}
*/
return ret; return ret;
} }
- (int)runModal - (int)runModal
{ {
return [self runModalForDirectory:[self directory] file:@""]; return [self runModalForDirectory:[self directory] file:@""];
} }
// //