mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 18:10:38 +00:00
Browser cell and save panel updates.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4937 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
63c2aad32c
commit
b462835083
3 changed files with 233 additions and 74 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
Thu Sep 23 1999 Nicola Pero <n.pero@mi.flashnet.it>
|
||||||
|
|
||||||
|
* Source/NSBrowserCell.m ([-drawInteriorWithFrame:inView:]): Clean
|
||||||
|
up and bug fix for cells without image. Leaf cells (and branch cells
|
||||||
|
with a nil branchimage) should now draw correctly.
|
||||||
|
* Source/NSSavePanel.m ([-_initWithoutGModel]): new method meant
|
||||||
|
to allow the panel run even without a gmodel, or when loading of
|
||||||
|
the gmodel fails. ([-_setDefaults]): set the title to "Save".
|
||||||
|
([+savePanel]): Use always the safer _initWithoutGModel for now.
|
||||||
|
RFM - tidied a little, adding releases for subviews etc (even though
|
||||||
|
the save panel may never be destroyed).
|
||||||
|
|
||||||
Tue Sep 21 1999 Nicola Pero <n.pero@mi.flashnet.it>
|
Tue Sep 21 1999 Nicola Pero <n.pero@mi.flashnet.it>
|
||||||
|
|
||||||
* Source/NSBrowser.m ([-selectedColumn]): fix: ignore unloaded
|
* Source/NSBrowser.m ([-selectedColumn]): fix: ignore unloaded
|
||||||
|
|
|
@ -270,59 +270,48 @@ static Class colorClass;
|
||||||
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
|
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
|
||||||
{
|
{
|
||||||
NSRect title_rect = cellFrame;
|
NSRect title_rect = cellFrame;
|
||||||
NSRect image_rect = cellFrame;
|
|
||||||
NSImage *image = nil;
|
NSImage *image = nil;
|
||||||
NSColor *backColor;
|
NSColor *backColor;
|
||||||
|
|
||||||
control_view = controlView; // remember last view cell was drawn in
|
control_view = controlView; // remember last view cell was drawn in
|
||||||
[controlView lockFocus];
|
[controlView lockFocus];
|
||||||
if (cell_highlighted || cell_state) // temporary hack FAR FIX ME?
|
if (cell_highlighted || cell_state)
|
||||||
{
|
{
|
||||||
backColor = [colorClass selectedControlColor];
|
backColor = [colorClass selectedControlColor];
|
||||||
[backColor set];
|
[backColor set];
|
||||||
if (!_isLeaf)
|
if (!_isLeaf)
|
||||||
{
|
image = _highlightBranchImage;
|
||||||
image = _highlightBranchImage;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
image_rect = NSZeroRect;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
backColor = [[controlView window] backgroundColor];
|
backColor = [[controlView window] backgroundColor];
|
||||||
[backColor set];
|
[backColor set];
|
||||||
if (!_isLeaf)
|
if (!_isLeaf)
|
||||||
{
|
image = _branchImage;
|
||||||
image = _branchImage;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
image_rect = NSZeroRect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
image_rect.size = [image size];
|
|
||||||
// Right justify
|
|
||||||
image_rect.origin.x += cellFrame.size.width - image_rect.size.width - 4.0;
|
|
||||||
image_rect.origin.y += (cellFrame.size.height - image_rect.size.height) / 2.0;
|
|
||||||
//MAX(NSMidY(image_rect) - ([image size].height/2.),0.);
|
|
||||||
|
|
||||||
NSRectFill(cellFrame); // Clear the background
|
NSRectFill(cellFrame); // Clear the background
|
||||||
|
|
||||||
title_rect.size.width -= image_rect.size.width + 8; // draw the title cell
|
|
||||||
[_browserText drawWithFrame: title_rect inView: controlView];
|
|
||||||
|
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
NSPoint position = image_rect.origin;
|
NSRect image_rect;
|
||||||
|
|
||||||
|
image_rect.origin = cellFrame.origin;
|
||||||
|
image_rect.size = [image size];
|
||||||
|
image_rect.origin.x += cellFrame.size.width - image_rect.size.width - 4.0;
|
||||||
|
image_rect.origin.y
|
||||||
|
+= (cellFrame.size.height - image_rect.size.height) / 2.0;
|
||||||
[image setBackgroundColor: backColor];
|
[image setBackgroundColor: backColor];
|
||||||
/*
|
/*
|
||||||
* Images are always drawn with their bottom-left corner at the origin
|
* Images are always drawn with their bottom-left corner at the origin
|
||||||
* so we must adjust the position to take account of a flipped view.
|
* so we must adjust the position to take account of a flipped view.
|
||||||
*/
|
*/
|
||||||
if ([control_view isFlipped])
|
if ([control_view isFlipped])
|
||||||
position.y += [image size].height;
|
image_rect.origin.y += image_rect.size.height;
|
||||||
[image compositeToPoint: position operation: NSCompositeCopy];
|
[image compositeToPoint: image_rect.origin operation: NSCompositeCopy];
|
||||||
|
|
||||||
|
title_rect.size.width -= image_rect.size.width + 8;
|
||||||
}
|
}
|
||||||
|
[_browserText drawWithFrame: title_rect inView: controlView];
|
||||||
[controlView unlockFocus];
|
[controlView unlockFocus];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,17 @@
|
||||||
|
|
||||||
#include <AppKit/IMLoading.h>
|
#include <AppKit/IMLoading.h>
|
||||||
#include <AppKit/NSApplication.h>
|
#include <AppKit/NSApplication.h>
|
||||||
|
#include <AppKit/NSBox.h>
|
||||||
#include <AppKit/NSBrowser.h>
|
#include <AppKit/NSBrowser.h>
|
||||||
#include <AppKit/NSBrowserCell.h>
|
#include <AppKit/NSBrowserCell.h>
|
||||||
|
#include <AppKit/NSButton.h>
|
||||||
|
#include <AppKit/NSFont.h>
|
||||||
|
#include <AppKit/NSImage.h>
|
||||||
|
#include <AppKit/NSImageView.h>
|
||||||
#include <AppKit/NSMatrix.h>
|
#include <AppKit/NSMatrix.h>
|
||||||
#include <AppKit/NSSavePanel.h>
|
#include <AppKit/NSSavePanel.h>
|
||||||
#include <AppKit/NSScreen.h>
|
#include <AppKit/NSScreen.h>
|
||||||
|
#include <AppKit/NSTextField.h>
|
||||||
#include <AppKit/NSWorkspace.h>
|
#include <AppKit/NSWorkspace.h>
|
||||||
#include <Foundation/NSDebug.h>
|
#include <Foundation/NSDebug.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
|
@ -63,11 +69,11 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
@"NSSavePanel -browser: createRowsForColumn: %d inMatrix:", column);
|
@"NSSavePanel -browser: createRowsForColumn: %d inMatrix:", column);
|
||||||
|
|
||||||
// if array is empty, just return (nothing to display)
|
// if array is empty, just return (nothing to display)
|
||||||
if ( ![files lastObject] )
|
if ([files lastObject] == nil)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// sort list of files to display
|
// sort list of files to display
|
||||||
if ( _delegateHasCompareFilter )
|
if (_delegateHasCompareFilter == YES)
|
||||||
{
|
{
|
||||||
int compare(id elem1, id elem2, void *context)
|
int compare(id elem1, id elem2, void *context)
|
||||||
{
|
{
|
||||||
|
@ -82,12 +88,12 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
files = [files sortedArrayUsingSelector: @selector(compare:)];
|
files = [files sortedArrayUsingSelector: @selector(compare:)];
|
||||||
|
|
||||||
count = [files count];
|
count = [files count];
|
||||||
for ( i = 0; i < count; i++ )
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
NSBrowserCell *cell;
|
NSBrowserCell *cell;
|
||||||
|
|
||||||
//if ( i != 0 )
|
//if (i != 0)
|
||||||
[matrix insertRow:i];
|
[matrix insertRow: i];
|
||||||
|
|
||||||
cell = [matrix cellAtRow: i column: 0];
|
cell = [matrix cellAtRow: i column: 0];
|
||||||
[cell setStringValue: [files objectAtIndex: i]];
|
[cell setStringValue: [files objectAtIndex: i]];
|
||||||
|
@ -97,10 +103,10 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
isDirectory: &isDir
|
isDirectory: &isDir
|
||||||
isPackage: &isPackage];
|
isPackage: &isPackage];
|
||||||
|
|
||||||
if ( isPackage && !_treatsFilePackagesAsDirectories )
|
if (isPackage == YES && _treatsFilePackagesAsDirectories == NO)
|
||||||
isDir = NO;
|
isDir = NO;
|
||||||
|
|
||||||
if ( exists && isDir )
|
if (exists == YES && isDir == NO)
|
||||||
[cell setLeaf: NO];
|
[cell setLeaf: NO];
|
||||||
else
|
else
|
||||||
[cell setLeaf: YES];
|
[cell setLeaf: YES];
|
||||||
|
@ -117,11 +123,11 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
|
|
||||||
// iterate through the cells asking the delegate if each filename is valid
|
// iterate through the cells asking the delegate if each filename is valid
|
||||||
// if it says no for any filename, the column is not valid
|
// if it says no for any filename, the column is not valid
|
||||||
if ( _delegateHasFilenameFilter )
|
if (_delegateHasFilenameFilter == YES)
|
||||||
for ( i = 0; i < count; i++ )
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if ( ![_delegate panel: self shouldShowFilename:
|
if (![_delegate panel: self shouldShowFilename:
|
||||||
[[cells objectAtIndex: i] stringValue]] )
|
[[cells objectAtIndex: i] stringValue]])
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,18 +159,161 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
//
|
//
|
||||||
@interface NSSavePanel (PrivateMethods)
|
@interface NSSavePanel (PrivateMethods)
|
||||||
|
|
||||||
|
- (id) _initWithoutGModel;
|
||||||
- (void) _setDefaults;
|
- (void) _setDefaults;
|
||||||
- (void) _setDirectory: (NSString *)path updateBrowser: (BOOL)flag;
|
- (void) _setDirectory: (NSString *)path updateBrowser: (BOOL)flag;
|
||||||
|
|
||||||
@end /* NSSavePanel (PrivateMethods) */
|
@end /* NSSavePanel (PrivateMethods) */
|
||||||
|
|
||||||
@implementation NSSavePanel (PrivateMethods)
|
@implementation NSSavePanel (PrivateMethods)
|
||||||
|
-(id) _initWithoutGModel
|
||||||
|
{
|
||||||
|
[super initWithContentRect: NSMakeRect (100, 100, 280, 350)
|
||||||
|
styleMask: 9 backing: 2 defer: YES];
|
||||||
|
[self setMinSize: NSMakeSize (280, 350)];
|
||||||
|
[[self contentView] setBounds: NSMakeRect (0, 0, 280, 350)];
|
||||||
|
|
||||||
|
_topView = [[NSView alloc] initWithFrame: NSMakeRect (0, 60, 280, 290)];
|
||||||
|
[_topView setBounds: NSMakeRect (0, 0, 280, 290)];
|
||||||
|
[[self contentView] addSubview: _topView];
|
||||||
|
[_topView release];
|
||||||
|
|
||||||
|
_bottomView = [[NSView alloc] initWithFrame: NSMakeRect (0, 0, 280, 60)];
|
||||||
|
[_bottomView setBounds: NSMakeRect (0, 0, 280, 60)];
|
||||||
|
[[self contentView] addSubview: _bottomView];
|
||||||
|
[_bottomView release];
|
||||||
|
|
||||||
|
_browser = [[NSBrowser alloc] initWithFrame: NSMakeRect (10, 10, 260, 196)];
|
||||||
|
[_browser setDelegate: self];
|
||||||
|
[_browser setMaxVisibleColumns: 2];
|
||||||
|
[_browser setHasHorizontalScroller: YES];
|
||||||
|
[_browser setAllowsMultipleSelection: NO];
|
||||||
|
[_browser setTarget: self];
|
||||||
|
[_browser setAction: @selector(_processCellSelection)];
|
||||||
|
[_topView addSubview: _browser];
|
||||||
|
[_browser release];
|
||||||
|
|
||||||
|
// {
|
||||||
|
// NSForm *_formControl;
|
||||||
|
//
|
||||||
|
// _formControl = [NSForm new];
|
||||||
|
// [_formControl addEntry: @"Name:"];
|
||||||
|
// [_formControl setFrame: NSMakeRect (5, 38, 264, 22)];
|
||||||
|
// [_formControl setEntryWidth: 264];
|
||||||
|
// [_bottomView addSubview: _formControl];
|
||||||
|
// _form = [_formControl cellAtIndex: 0];
|
||||||
|
//}
|
||||||
|
_prompt = [[NSTextField alloc] initWithFrame: NSMakeRect (5, 38, 38, 18)];
|
||||||
|
[_prompt setEnabled: NO];
|
||||||
|
[_prompt setBordered: NO];
|
||||||
|
[_prompt setBezeled: NO];
|
||||||
|
[_prompt setDrawsBackground: NO];
|
||||||
|
[_bottomView addSubview: _prompt];
|
||||||
|
[_prompt release];
|
||||||
|
|
||||||
|
// The gmodel says (44, 40, 226, 22), but that makes the upper border
|
||||||
|
// clipped.
|
||||||
|
_form = [[NSTextField alloc] initWithFrame: NSMakeRect (44, 38, 226, 22)];
|
||||||
|
[_form setEditable: YES];
|
||||||
|
[_form setBordered: NO];
|
||||||
|
[_form setBezeled: YES];
|
||||||
|
[_form setDrawsBackground: YES];
|
||||||
|
[_form setContinuous: NO];
|
||||||
|
[_bottomView addSubview: _form];
|
||||||
|
[_form release];
|
||||||
|
|
||||||
|
{
|
||||||
|
NSButton *button;
|
||||||
|
|
||||||
|
button = [[NSButton alloc] initWithFrame: NSMakeRect (18, 5, 28, 28)];
|
||||||
|
[button setBordered: YES];
|
||||||
|
[button setButtonType: NSMomentaryPushButton];
|
||||||
|
[button setImage: [NSImage imageNamed: @"common_Home"]];
|
||||||
|
[button setImagePosition: NSImageOnly];
|
||||||
|
[button setTarget: self];
|
||||||
|
[button setAction: @selector(_setHomeDirectory)];
|
||||||
|
[_bottomView addSubview: button];
|
||||||
|
[button release];
|
||||||
|
|
||||||
|
button = [[NSButton alloc] initWithFrame: NSMakeRect (52, 5, 28, 28)];
|
||||||
|
[button setBordered: YES];
|
||||||
|
[button setButtonType: NSMomentaryPushButton];
|
||||||
|
[button setImage: [NSImage imageNamed: @"common_Mount"]];
|
||||||
|
[button setImagePosition: NSImageOnly];
|
||||||
|
[button setTarget: self];
|
||||||
|
[button setAction: @selector(_mountMedia)];
|
||||||
|
[_bottomView addSubview: button];
|
||||||
|
[button release];
|
||||||
|
|
||||||
|
button = [[NSButton alloc] initWithFrame: NSMakeRect (86, 5, 28, 28)];
|
||||||
|
[button setBordered: YES];
|
||||||
|
[button setButtonType: NSMomentaryPushButton];
|
||||||
|
[button setImage: [NSImage imageNamed: @"common_Unmount"]];
|
||||||
|
[button setImagePosition: NSImageOnly];
|
||||||
|
[button setTarget: self];
|
||||||
|
[button setAction: @selector(_unmountMedia)];
|
||||||
|
[_bottomView addSubview: button];
|
||||||
|
[button release];
|
||||||
|
|
||||||
|
button = [[NSButton alloc] initWithFrame: NSMakeRect (122, 5, 70, 28)];
|
||||||
|
[button setBordered: YES];
|
||||||
|
[button setButtonType: NSMomentaryPushButton];
|
||||||
|
[button setTitle: @"Cancel"];
|
||||||
|
[button setImagePosition: NSNoImage];
|
||||||
|
[button setTarget: self];
|
||||||
|
[button setAction: @selector(cancel:)];
|
||||||
|
[_bottomView addSubview: button];
|
||||||
|
[button release];
|
||||||
|
|
||||||
|
button = [[NSButton alloc] initWithFrame: NSMakeRect (200, 5, 70, 28)];
|
||||||
|
[button setBordered: YES];
|
||||||
|
[button setButtonType: NSMomentaryPushButton];
|
||||||
|
[button setTitle: @"Ok"];
|
||||||
|
[button setImagePosition: NSNoImage];
|
||||||
|
[button setTarget: self];
|
||||||
|
[button setAction: @selector(ok:)];
|
||||||
|
[_bottomView addSubview: button];
|
||||||
|
[button release];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
NSImageView *imageView;
|
||||||
|
|
||||||
|
imageView
|
||||||
|
= [[NSImageView alloc] initWithFrame: NSMakeRect (8, 218, 64, 64)];
|
||||||
|
[imageView setImageFrameStyle: NSImageFrameNone];
|
||||||
|
[imageView setImage:
|
||||||
|
[[NSApplication sharedApplication] applicationIconImage]];
|
||||||
|
[_topView addSubview: imageView];
|
||||||
|
[imageView release];
|
||||||
|
}
|
||||||
|
_titleField
|
||||||
|
= [[NSTextField alloc] initWithFrame: NSMakeRect (80, 240, 224, 21)];
|
||||||
|
[_titleField setSelectable: NO];
|
||||||
|
[_titleField setEditable: NO];
|
||||||
|
[_titleField setDrawsBackground: NO];
|
||||||
|
[_titleField setBezeled: NO];
|
||||||
|
[_titleField setBordered: NO];
|
||||||
|
[_titleField setFont: [NSFont messageFontOfSize: 18]];
|
||||||
|
[_topView addSubview: _titleField];
|
||||||
|
[_titleField release];
|
||||||
|
{
|
||||||
|
NSBox *bar;
|
||||||
|
bar = [[NSBox alloc] initWithFrame: NSMakeRect (0, 210, 310, 2)];
|
||||||
|
[bar setBorderType: NSGrooveBorder];
|
||||||
|
[bar setTitlePosition: NSNoTitle];
|
||||||
|
[_topView addSubview: bar];
|
||||||
|
[bar release];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) _setDefaults
|
- (void) _setDefaults
|
||||||
{
|
{
|
||||||
NSDebugLLog(@"NSSavePanel", @"NSSavePanel -_setDefaults");
|
NSDebugLLog(@"NSSavePanel", @"NSSavePanel -_setDefaults");
|
||||||
[self setDirectory: [[NSFileManager defaultManager] currentDirectoryPath]];
|
[self setDirectory: [[NSFileManager defaultManager] currentDirectoryPath]];
|
||||||
[self setPrompt: @"Name:"];
|
[self setPrompt: @"Name:"];
|
||||||
|
[self setTitle: @"Save"];
|
||||||
[self setRequiredFileType: @""];
|
[self setRequiredFileType: @""];
|
||||||
[self setTreatsFilePackagesAsDirectories: NO];
|
[self setTreatsFilePackagesAsDirectories: NO];
|
||||||
[self setDelegate: nil];
|
[self setDelegate: nil];
|
||||||
|
@ -180,16 +329,16 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
@"NSSavePanel -_setDirectory: %@ updateBrowser:", path);
|
@"NSSavePanel -_setDirectory: %@ updateBrowser:", path);
|
||||||
|
|
||||||
// check that path exists, and if so save it
|
// check that path exists, and if so save it
|
||||||
if ( standardizedPath
|
if (standardizedPath
|
||||||
&& [[NSFileManager defaultManager]
|
&& [[NSFileManager defaultManager]
|
||||||
fileExistsAtPath: path isDirectory: &isDir] && isDir )
|
fileExistsAtPath: path isDirectory: &isDir] && isDir)
|
||||||
{
|
{
|
||||||
if ( _lastValidPath )
|
if (_lastValidPath)
|
||||||
[_lastValidPath autorelease];
|
[_lastValidPath autorelease];
|
||||||
_lastValidPath = [standardizedPath retain];
|
_lastValidPath = [standardizedPath retain];
|
||||||
}
|
}
|
||||||
// set the path in the browser
|
// set the path in the browser
|
||||||
if ( _browser && flag )
|
if (_browser && flag)
|
||||||
[_browser setPath: _lastValidPath];
|
[_browser setPath: _lastValidPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +351,7 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
[self _setDirectory:
|
[self _setDirectory:
|
||||||
[_browser pathToColumn: [_browser lastColumn]] updateBrowser: NO];
|
[_browser pathToColumn: [_browser lastColumn]] updateBrowser: NO];
|
||||||
|
|
||||||
if ( [selectedCell isLeaf] )
|
if ([selectedCell isLeaf])
|
||||||
[_form setStringValue: [selectedCell stringValue]];
|
[_form setStringValue: [selectedCell stringValue]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,18 +383,12 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
+ (id) savePanel
|
+ (id) savePanel
|
||||||
{
|
{
|
||||||
NSDebugLLog(@"NSSavePanel", @"NSSavePanel +savePanel");
|
NSDebugLLog(@"NSSavePanel", @"NSSavePanel +savePanel");
|
||||||
if ( !gnustep_gui_save_panel )
|
if (!gnustep_gui_save_panel)
|
||||||
{
|
{
|
||||||
if ( ![GMModel loadIMFile:@"SavePanel" owner:NSApp] )
|
// if (![GMModel loadIMFile:@"SavePanel" owner:NSApp])
|
||||||
{
|
[[NSSavePanel alloc] _initWithoutGModel];
|
||||||
NSRunAlertPanel(@"SavePanel Error",
|
|
||||||
@"Cannot open the save panel model file",
|
|
||||||
@"Ok",
|
|
||||||
nil,
|
|
||||||
nil);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ( gnustep_gui_save_panel )
|
if (gnustep_gui_save_panel)
|
||||||
[gnustep_gui_save_panel _setDefaults];
|
[gnustep_gui_save_panel _setDefaults];
|
||||||
|
|
||||||
return gnustep_gui_save_panel;
|
return gnustep_gui_save_panel;
|
||||||
|
@ -255,7 +398,7 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
{
|
{
|
||||||
NSDebugLLog(@"NSSavePanel", @"NSSavePanel +allocWithZone");
|
NSDebugLLog(@"NSSavePanel", @"NSSavePanel +allocWithZone");
|
||||||
|
|
||||||
if ( !gnustep_gui_save_panel )
|
if (!gnustep_gui_save_panel)
|
||||||
gnustep_gui_save_panel = (NSSavePanel *)NSAllocateObject(self, 0, z);
|
gnustep_gui_save_panel = (NSSavePanel *)NSAllocateObject(self, 0, z);
|
||||||
|
|
||||||
return gnustep_gui_save_panel;
|
return gnustep_gui_save_panel;
|
||||||
|
@ -267,7 +410,10 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
NSRect addedFrame, contentFrame, bottomFrame, topFrame;
|
NSRect addedFrame, contentFrame, bottomFrame, topFrame;
|
||||||
NSDebugLLog(@"NSSavePanel", @"NSSavePanel -setAccessoryView");
|
NSDebugLLog(@"NSSavePanel", @"NSSavePanel -setAccessoryView");
|
||||||
|
|
||||||
if ( _accessoryView )
|
if (aView == _accessoryView)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_accessoryView != nil)
|
||||||
{
|
{
|
||||||
[_accessoryView removeFromSuperview];
|
[_accessoryView removeFromSuperview];
|
||||||
[self setContentSize: _oldContentFrame.size];
|
[self setContentSize: _oldContentFrame.size];
|
||||||
|
@ -277,7 +423,7 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
|
|
||||||
_accessoryView = aView;
|
_accessoryView = aView;
|
||||||
|
|
||||||
if ( _accessoryView )
|
if (_accessoryView != nil)
|
||||||
{
|
{
|
||||||
// save old values
|
// save old values
|
||||||
_oldContentFrame = [contentView frame];
|
_oldContentFrame = [contentView frame];
|
||||||
|
@ -388,9 +534,10 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
{
|
{
|
||||||
NSDebugLLog(@"NSSavePanel", @"NSSavePanel -runModalForDirectory: filename:");
|
NSDebugLLog(@"NSSavePanel", @"NSSavePanel -runModalForDirectory: filename:");
|
||||||
|
|
||||||
if ( !path || !filename )
|
if (path == nil || filename == nil)
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"NSSavePanel runModalForDirectory: file: does not accept nil arguments."];
|
format: @"NSSavePanel runModalForDirectory:file: "
|
||||||
|
@"does not accept nil arguments."];
|
||||||
|
|
||||||
// must display here so that...
|
// must display here so that...
|
||||||
[self display];
|
[self display];
|
||||||
|
@ -403,7 +550,7 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
|
|
||||||
- (NSString *) directory
|
- (NSString *) directory
|
||||||
{
|
{
|
||||||
if ( _browser )
|
if (_browser != nil)
|
||||||
return [_browser pathToColumn:[_browser lastColumn]];
|
return [_browser pathToColumn:[_browser lastColumn]];
|
||||||
else
|
else
|
||||||
return _lastValidPath;
|
return _lastValidPath;
|
||||||
|
@ -413,11 +560,11 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
{
|
{
|
||||||
NSString *filename = [_form stringValue];
|
NSString *filename = [_form stringValue];
|
||||||
|
|
||||||
if ( [_requiredFileType isEqual: @""] )
|
if ([_requiredFileType isEqual: @""] == YES)
|
||||||
return filename;
|
return filename;
|
||||||
|
|
||||||
// add filetype extension only if the filename does not include it already
|
// add filetype extension only if the filename does not include it already
|
||||||
if ( [[filename pathExtension] isEqual: _requiredFileType] )
|
if ([[filename pathExtension] isEqual: _requiredFileType] == YES)
|
||||||
return filename;
|
return filename;
|
||||||
else
|
else
|
||||||
return [filename stringByAppendingPathExtension:_requiredFileType];
|
return [filename stringByAppendingPathExtension:_requiredFileType];
|
||||||
|
@ -431,8 +578,8 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
|
|
||||||
- (void) ok: (id)sender
|
- (void) ok: (id)sender
|
||||||
{
|
{
|
||||||
if ( _delegateHasValidNameFilter )
|
if (_delegateHasValidNameFilter)
|
||||||
if ( ![_delegate panel:self isValidFilename: [self filename]] )
|
if (![_delegate panel:self isValidFilename: [self filename]])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[NSApp stopModalWithCode: NSOKButton];
|
[NSApp stopModalWithCode: NSOKButton];
|
||||||
|
@ -446,7 +593,7 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
- (void) setDelegate: (id)aDelegate
|
- (void) setDelegate: (id)aDelegate
|
||||||
{
|
{
|
||||||
NSDebugLLog(@"NSSavePanel", @"NSSavePanel -setDelegate");
|
NSDebugLLog(@"NSSavePanel", @"NSSavePanel -setDelegate");
|
||||||
if ( aDelegate == nil )
|
if (aDelegate == nil)
|
||||||
{
|
{
|
||||||
_delegate = nil;
|
_delegate = nil;
|
||||||
_delegateHasCompareFilter = NO;
|
_delegateHasCompareFilter = NO;
|
||||||
|
@ -455,12 +602,18 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_delegateHasCompareFilter = [aDelegate respondsToSelector: @selector(panel:compareFilename:with:caseSensitive:)] ? YES : NO;
|
_delegateHasCompareFilter
|
||||||
_delegateHasFilenameFilter = [aDelegate respondsToSelector: @selector(panel:shouldShowFilename:)] ? YES : NO;
|
= [aDelegate respondsToSelector:
|
||||||
_delegateHasValidNameFilter = [aDelegate respondsToSelector: @selector(panel:isValidFilename:)] ? YES : NO;
|
@selector(panel:compareFilename:with:caseSensitive:)] ? YES : NO;
|
||||||
|
_delegateHasFilenameFilter
|
||||||
|
= [aDelegate respondsToSelector:
|
||||||
|
@selector(panel:shouldShowFilename:)] ? YES : NO;
|
||||||
|
_delegateHasValidNameFilter
|
||||||
|
= [aDelegate respondsToSelector:
|
||||||
|
@selector(panel:isValidFilename:)] ? YES : NO;
|
||||||
|
|
||||||
if ( !_delegateHasCompareFilter && !_delegateHasFilenameFilter
|
if (!_delegateHasCompareFilter && !_delegateHasFilenameFilter
|
||||||
&& !_delegateHasValidNameFilter )
|
&& !_delegateHasValidNameFilter)
|
||||||
[NSException raise:NSInvalidArgumentException
|
[NSException raise:NSInvalidArgumentException
|
||||||
format: @"Delegate supports no save panel delegete methods."];
|
format: @"Delegate supports no save panel delegete methods."];
|
||||||
|
|
||||||
|
@ -494,7 +647,9 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
|
|
||||||
- (NSArray *) directoryContentsAtPath: (NSString *)path showHidden: (BOOL)flag;
|
- (NSArray *) directoryContentsAtPath: (NSString *)path showHidden: (BOOL)flag;
|
||||||
- (NSArray *) hiddenFilesAtPath: (NSString *)path;
|
- (NSArray *) hiddenFilesAtPath: (NSString *)path;
|
||||||
- (BOOL) fileExistsAtPath: (NSString *)path isDirectory: (BOOL *)flag1 isPackage: (BOOL *)flag2;
|
- (BOOL) fileExistsAtPath: (NSString *)path
|
||||||
|
isDirectory: (BOOL *)flag1
|
||||||
|
isPackage: (BOOL *)flag2;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -508,12 +663,12 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
NSEnumerator *enumerator = [rawFiles objectEnumerator];
|
NSEnumerator *enumerator = [rawFiles objectEnumerator];
|
||||||
NSString *filename;
|
NSString *filename;
|
||||||
|
|
||||||
if ( flag || !hiddenFiles )
|
if (flag || !hiddenFiles)
|
||||||
return rawFiles;
|
return rawFiles;
|
||||||
|
|
||||||
while ( (filename = (NSString *)[enumerator nextObject]) )
|
while ((filename = (NSString *)[enumerator nextObject]))
|
||||||
{
|
{
|
||||||
if ( [hiddenFiles indexOfObject: filename] == NSNotFound )
|
if ([hiddenFiles indexOfObject: filename] == NSNotFound)
|
||||||
[files addObject: filename];
|
[files addObject: filename];
|
||||||
}
|
}
|
||||||
return files;
|
return files;
|
||||||
|
@ -530,9 +685,12 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||||
isDirectory: (BOOL *)isDir
|
isDirectory: (BOOL *)isDir
|
||||||
isPackage: (BOOL *)isPackage
|
isPackage: (BOOL *)isPackage
|
||||||
{
|
{
|
||||||
NSArray *extArray = [NSArray arrayWithObjects: @"app", @"bundle", @"debug", @"profile", nil];
|
NSArray *extArray;
|
||||||
|
|
||||||
if ( [extArray indexOfObject: [path pathExtension]] == NSNotFound )
|
extArray = [NSArray arrayWithObjects:
|
||||||
|
@"app", @"bundle", @"debug", @"profile", nil];
|
||||||
|
|
||||||
|
if ([extArray indexOfObject: [path pathExtension]] == NSNotFound)
|
||||||
*isPackage = NO;
|
*isPackage = NO;
|
||||||
else
|
else
|
||||||
*isPackage = YES;
|
*isPackage = YES;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue