mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 21:50:46 +00:00
Support typed in absolute paths and drag and drop of a single file.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@17993 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e8275452b1
commit
914ac48552
3 changed files with 243 additions and 101 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2003-10-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSOpenPanel.m: Allow users to type in an absolute path name.
|
||||||
|
Support DnD of filename into panel.
|
||||||
|
* Source/NSSavePanel.m: ditto. Also, if the name of a non-existent
|
||||||
|
directory is typed in, provide a prompt to create the directory as
|
||||||
|
in NeXTstep/OPENSTEP.
|
||||||
|
|
||||||
2003-10-27 Richard Frith-Macdonald <rfm@gnu.org>
|
2003-10-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSServicesManager.m: Tidy last patch to match use of
|
* Source/GSServicesManager.m: Tidy last patch to match use of
|
||||||
|
|
|
@ -104,10 +104,10 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
{
|
{
|
||||||
NSMatrix *matrix;
|
NSMatrix *matrix;
|
||||||
|
|
||||||
if(column == -1)
|
if (column == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
matrix = [_browser matrixInColumn:column];
|
matrix = [_browser matrixInColumn: column];
|
||||||
|
|
||||||
if ([_browser allowsMultipleSelection])
|
if ([_browser allowsMultipleSelection])
|
||||||
{
|
{
|
||||||
|
@ -115,41 +115,41 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
|
|
||||||
selectedCells = [matrix selectedCells];
|
selectedCells = [matrix selectedCells];
|
||||||
|
|
||||||
if([selectedCells count] <= 1)
|
if ([selectedCells count] <= 1)
|
||||||
{
|
{
|
||||||
if(_canChooseDirectories == NO ||
|
if (_canChooseDirectories == NO ||
|
||||||
[[matrix selectedCell] isLeaf] == YES)
|
[[matrix selectedCell] isLeaf] == YES)
|
||||||
[super _selectTextInColumn:column];
|
[super _selectTextInColumn: column];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[self _selectCellName:[[_form cellAtIndex: 0] stringValue]];
|
[self _selectCellName: [[_form cellAtIndex: 0] stringValue]];
|
||||||
// [_form selectTextAtIndex:0];
|
// [_form selectTextAtIndex: 0];
|
||||||
[_okButton setEnabled:YES];
|
[_okButton setEnabled: YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[_form abortEditing];
|
[_form abortEditing];
|
||||||
[[_form cellAtIndex: 0] setStringValue:@""];
|
[[_form cellAtIndex: 0] setStringValue:@""];
|
||||||
// [_form selectTextAtIndex:0];
|
// [_form selectTextAtIndex: 0];
|
||||||
[_form setNeedsDisplay:YES];
|
[_form setNeedsDisplay: YES];
|
||||||
[_okButton setEnabled:YES];
|
[_okButton setEnabled: YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(_canChooseDirectories == NO || [[matrix selectedCell] isLeaf] == YES)
|
if (_canChooseDirectories == NO || [[matrix selectedCell] isLeaf] == YES)
|
||||||
[super _selectTextInColumn:column];
|
[super _selectTextInColumn: column];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if([[[_form cellAtIndex: 0] stringValue] length] > 0)
|
if ([[[_form cellAtIndex: 0] stringValue] length] > 0)
|
||||||
{
|
{
|
||||||
[self _selectCellName:[[_form cellAtIndex: 0] stringValue]];
|
[self _selectCellName: [[_form cellAtIndex: 0] stringValue]];
|
||||||
// [_form selectTextAtIndex:0];
|
// [_form selectTextAtIndex: 0];
|
||||||
[_form setNeedsDisplay:YES];
|
[_form setNeedsDisplay: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
[_okButton setEnabled:YES];
|
[_okButton setEnabled: YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,14 +163,14 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
NSRange range;
|
NSRange range;
|
||||||
int i, titleLength, cellLength, numberOfCells;
|
int i, titleLength, cellLength, numberOfCells;
|
||||||
|
|
||||||
matrix = [_browser matrixInColumn:[_browser lastColumn]];
|
matrix = [_browser matrixInColumn: [_browser lastColumn]];
|
||||||
if([matrix selectedCell])
|
if ([matrix selectedCell])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
titleLength = [title length];
|
titleLength = [title length];
|
||||||
if(!titleLength)
|
if (!titleLength)
|
||||||
{
|
{
|
||||||
[_okButton setEnabled:NO];
|
[_okButton setEnabled: NO];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,25 +180,25 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
cells = [matrix cells];
|
cells = [matrix cells];
|
||||||
numberOfCells = [cells count];
|
numberOfCells = [cells count];
|
||||||
|
|
||||||
for(i = 0; i < numberOfCells; i++)
|
for (i = 0; i < numberOfCells; i++)
|
||||||
{
|
{
|
||||||
cellString = [[matrix cellAtRow:i column:0] stringValue];
|
cellString = [[matrix cellAtRow: i column: 0] stringValue];
|
||||||
|
|
||||||
cellLength = [cellString length];
|
cellLength = [cellString length];
|
||||||
if(cellLength < titleLength)
|
if (cellLength < titleLength)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
result = [self _compareFilename:[cellString substringWithRange:range]
|
result = [self _compareFilename: [cellString substringWithRange: range]
|
||||||
with:title];
|
with: title];
|
||||||
|
|
||||||
if(result == NSOrderedSame)
|
if (result == NSOrderedSame)
|
||||||
{
|
{
|
||||||
[matrix selectCellAtRow:i column:0];
|
[matrix selectCellAtRow: i column: 0];
|
||||||
[matrix scrollCellToVisibleAtRow:i column:0];
|
[matrix scrollCellToVisibleAtRow: i column: 0];
|
||||||
[_okButton setEnabled:YES];
|
[_okButton setEnabled: YES];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(result == NSOrderedDescending)
|
else if (result == NSOrderedDescending)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,13 +215,13 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
|
|
||||||
if (filename == nil)
|
if (filename == nil)
|
||||||
filename = @"";
|
filename = @"";
|
||||||
else if([filename isEqual: @""] == NO)
|
else if ([filename isEqual: @""] == NO)
|
||||||
[_okButton setEnabled: YES];
|
[_okButton setEnabled: YES];
|
||||||
|
|
||||||
if (_canChooseDirectories == NO)
|
if (_canChooseDirectories == NO)
|
||||||
{
|
{
|
||||||
if([_browser allowsMultipleSelection] == YES)
|
if ([_browser allowsMultipleSelection] == YES)
|
||||||
[_browser setAllowsBranchSelection:NO];
|
[_browser setAllowsBranchSelection: NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
[super _setupForDirectory: path file: filename];
|
[super _setupForDirectory: path file: filename];
|
||||||
|
@ -430,11 +430,11 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
/** Displays the open panel in a modal session, with the directory
|
/** Displays the open panel in a modal session, with the directory
|
||||||
path shown and file name (if any) selected. Files are filtered for the
|
path shown and file name (if any) selected. Files are filtered for the
|
||||||
specified types. If the directory is nil, then the directory shown in
|
specified types. If the directory is nil, then the directory shown in
|
||||||
the opena panel is the last directory selected.
|
the open panel is the last directory selected.
|
||||||
*/
|
*/
|
||||||
- (int) runModalForDirectory: (NSString *)path
|
- (int) runModalForDirectory: (NSString *)path
|
||||||
file: (NSString *)name
|
file: (NSString *)name
|
||||||
types: (NSArray *)fileTypes
|
types: (NSArray *)fileTypes
|
||||||
{
|
{
|
||||||
ASSIGN (_fileTypes, fileTypes);
|
ASSIGN (_fileTypes, fileTypes);
|
||||||
|
|
||||||
|
@ -442,10 +442,10 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
file: name];
|
file: name];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int)runModalForDirectory:(NSString *)path
|
- (int) runModalForDirectory: (NSString *)path
|
||||||
file:(NSString *)name
|
file: (NSString *)name
|
||||||
types:(NSArray *)fileTypes
|
types: (NSArray *)fileTypes
|
||||||
relativeToWindow:(NSWindow*)window
|
relativeToWindow: (NSWindow*)window
|
||||||
{
|
{
|
||||||
ASSIGN (_fileTypes, fileTypes);
|
ASSIGN (_fileTypes, fileTypes);
|
||||||
|
|
||||||
|
@ -454,22 +454,22 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
relativeToWindow: window];
|
relativeToWindow: window];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)beginSheetForDirectory:(NSString *)path
|
- (void) beginSheetForDirectory: (NSString *)path
|
||||||
file:(NSString *)name
|
file: (NSString *)name
|
||||||
types:(NSArray *)fileTypes
|
types: (NSArray *)fileTypes
|
||||||
modalForWindow:(NSWindow *)docWindow
|
modalForWindow: (NSWindow *)docWindow
|
||||||
modalDelegate:(id)delegate
|
modalDelegate: (id)delegate
|
||||||
didEndSelector:(SEL)didEndSelector
|
didEndSelector: (SEL)didEndSelector
|
||||||
contextInfo:(void *)contextInfo
|
contextInfo: (void *)contextInfo
|
||||||
{
|
{
|
||||||
ASSIGN (_fileTypes, fileTypes);
|
ASSIGN (_fileTypes, fileTypes);
|
||||||
|
|
||||||
[self beginSheetForDirectory: path
|
[self beginSheetForDirectory: path
|
||||||
file: name
|
file: name
|
||||||
modalForWindow: docWindow
|
modalForWindow: docWindow
|
||||||
modalDelegate: delegate
|
modalDelegate: delegate
|
||||||
didEndSelector: didEndSelector
|
didEndSelector: didEndSelector
|
||||||
contextInfo: contextInfo];
|
contextInfo: contextInfo];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) ok: (id)sender
|
- (void) ok: (id)sender
|
||||||
|
@ -478,6 +478,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
NSBrowserCell *selectedCell = nil;
|
NSBrowserCell *selectedCell = nil;
|
||||||
NSArray *selectedCells = nil;
|
NSArray *selectedCells = nil;
|
||||||
int selectedColumn, lastColumn;
|
int selectedColumn, lastColumn;
|
||||||
|
NSString *tmp;
|
||||||
|
|
||||||
selectedColumn = [_browser selectedColumn];
|
selectedColumn = [_browser selectedColumn];
|
||||||
lastColumn = [_browser lastColumn];
|
lastColumn = [_browser lastColumn];
|
||||||
|
@ -489,8 +490,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
{
|
{
|
||||||
selectedCells = [matrix selectedCells];
|
selectedCells = [matrix selectedCells];
|
||||||
|
|
||||||
if (selectedColumn == lastColumn &&
|
if (selectedColumn == lastColumn && [selectedCells count] == 1)
|
||||||
[selectedCells count] == 1)
|
|
||||||
selectedCell = [selectedCells objectAtIndex: 0];
|
selectedCell = [selectedCells objectAtIndex: 0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -518,21 +518,29 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_canChooseDirectories == NO
|
else if (_canChooseDirectories == NO
|
||||||
&& (![_browser allowsMultipleSelection] || !selectedCells
|
&& (![_browser allowsMultipleSelection] || !selectedCells
|
||||||
|| selectedColumn != lastColumn || ![selectedCells count]))
|
|| selectedColumn != lastColumn || ![selectedCells count]))
|
||||||
{
|
{
|
||||||
[_form selectTextAtIndex: 0];
|
[_form selectTextAtIndex: 0];
|
||||||
[_form setNeedsDisplay: YES];
|
[_form setNeedsDisplay: YES];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIGN (_directory, [_browser pathToColumn:[_browser lastColumn]]);
|
ASSIGN (_directory, [_browser pathToColumn: [_browser lastColumn]]);
|
||||||
|
|
||||||
if (selectedCell)
|
if (selectedCell)
|
||||||
ASSIGN (_fullFileName, [_directory stringByAppendingPathComponent:
|
tmp = [selectedCell stringValue];
|
||||||
[selectedCell stringValue]]);
|
|
||||||
else
|
else
|
||||||
ASSIGN (_fullFileName, [_directory stringByAppendingPathComponent:
|
tmp = [[_form cellAtIndex: 0] stringValue];
|
||||||
[[_form cellAtIndex: 0] stringValue]]);
|
|
||||||
|
if ([tmp isAbsolutePath] == YES)
|
||||||
|
{
|
||||||
|
ASSIGN (_fullFileName, tmp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ASSIGN (_fullFileName, [_directory stringByAppendingPathComponent: tmp]);
|
||||||
|
}
|
||||||
|
|
||||||
if (_delegateHasValidNameFilter)
|
if (_delegateHasValidNameFilter)
|
||||||
{
|
{
|
||||||
|
@ -550,6 +558,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
|
|
||||||
_OKButtonPressed = YES;
|
_OKButtonPressed = YES;
|
||||||
[NSApp stopModal];
|
[NSApp stopModal];
|
||||||
|
|
||||||
[self close];
|
[self close];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,17 +613,26 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
NSComparisonResult result;
|
NSComparisonResult result;
|
||||||
NSRange range;
|
NSRange range;
|
||||||
|
|
||||||
matrix = [_browser matrixInColumn: [_browser lastColumn]];
|
|
||||||
s = [[[aNotification userInfo] objectForKey: @"NSFieldEditor"] string];
|
s = [[[aNotification userInfo] objectForKey: @"NSFieldEditor"] string];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the user typed in an absolute path, display it.
|
||||||
|
*/
|
||||||
|
if ([s isAbsolutePath] == YES)
|
||||||
|
{
|
||||||
|
[self setDirectory: s];
|
||||||
|
}
|
||||||
|
|
||||||
sLength = [s length];
|
sLength = [s length];
|
||||||
range.location = 0;
|
range.location = 0;
|
||||||
range.length = sLength;
|
range.length = sLength;
|
||||||
|
|
||||||
if(sLength == 0)
|
matrix = [_browser matrixInColumn: [_browser lastColumn]];
|
||||||
|
|
||||||
|
if (sLength == 0)
|
||||||
{
|
{
|
||||||
[matrix deselectAllCells];
|
[matrix deselectAllCells];
|
||||||
if(_canChooseDirectories == NO)
|
if (_canChooseDirectories == NO)
|
||||||
[_okButton setEnabled: NO];
|
[_okButton setEnabled: NO];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -624,20 +642,20 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
selectedRow = [matrix selectedRow];
|
selectedRow = [matrix selectedRow];
|
||||||
cells = [matrix cells];
|
cells = [matrix cells];
|
||||||
|
|
||||||
if(selectedString)
|
if (selectedString)
|
||||||
{
|
{
|
||||||
cellLength = [selectedString length];
|
cellLength = [selectedString length];
|
||||||
|
|
||||||
if(cellLength < sLength)
|
if (cellLength < sLength)
|
||||||
range.length = cellLength;
|
range.length = cellLength;
|
||||||
|
|
||||||
result = [selectedString compare: s options: 0 range: range];
|
result = [selectedString compare: s options: 0 range: range];
|
||||||
|
|
||||||
if(result == NSOrderedSame)
|
if (result == NSOrderedSame)
|
||||||
return;
|
return;
|
||||||
else if(result == NSOrderedAscending)
|
else if (result == NSOrderedAscending)
|
||||||
result = NSOrderedDescending;
|
result = NSOrderedDescending;
|
||||||
else if(result == NSOrderedDescending)
|
else if (result == NSOrderedDescending)
|
||||||
result = NSOrderedAscending;
|
result = NSOrderedAscending;
|
||||||
|
|
||||||
range.length = sLength;
|
range.length = sLength;
|
||||||
|
@ -645,21 +663,21 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
else
|
else
|
||||||
result = NSOrderedDescending;
|
result = NSOrderedDescending;
|
||||||
|
|
||||||
if(result == NSOrderedDescending)
|
if (result == NSOrderedDescending)
|
||||||
{
|
{
|
||||||
int numberOfCells = [cells count];
|
int numberOfCells = [cells count];
|
||||||
|
|
||||||
for(i = selectedRow+1; i < numberOfCells; i++)
|
for (i = selectedRow+1; i < numberOfCells; i++)
|
||||||
{
|
{
|
||||||
selectedString = [[matrix cellAtRow: i column: 0] stringValue];
|
selectedString = [[matrix cellAtRow: i column: 0] stringValue];
|
||||||
|
|
||||||
cellLength = [selectedString length];
|
cellLength = [selectedString length];
|
||||||
if(cellLength < sLength)
|
if (cellLength < sLength)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
result = [selectedString compare: s options: 0 range: range];
|
result = [selectedString compare: s options: 0 range: range];
|
||||||
|
|
||||||
if(result == NSOrderedSame)
|
if (result == NSOrderedSame)
|
||||||
{
|
{
|
||||||
[matrix deselectAllCells];
|
[matrix deselectAllCells];
|
||||||
[matrix selectCellAtRow: i column: 0];
|
[matrix selectCellAtRow: i column: 0];
|
||||||
|
@ -671,17 +689,17 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(i = selectedRow; i >= 0; --i)
|
for (i = selectedRow; i >= 0; --i)
|
||||||
{
|
{
|
||||||
selectedString = [[matrix cellAtRow: i column: 0] stringValue];
|
selectedString = [[matrix cellAtRow: i column: 0] stringValue];
|
||||||
|
|
||||||
cellLength = [selectedString length];
|
cellLength = [selectedString length];
|
||||||
if(cellLength < sLength)
|
if (cellLength < sLength)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
result = [selectedString compare: s options: 0 range: range];
|
result = [selectedString compare: s options: 0 range: range];
|
||||||
|
|
||||||
if(result == NSOrderedSame)
|
if (result == NSOrderedSame)
|
||||||
{
|
{
|
||||||
[matrix deselectAllCells];
|
[matrix deselectAllCells];
|
||||||
[matrix selectCellAtRow: i column: 0];
|
[matrix selectCellAtRow: i column: 0];
|
||||||
|
|
|
@ -48,6 +48,8 @@
|
||||||
#include "AppKit/NSImage.h"
|
#include "AppKit/NSImage.h"
|
||||||
#include "AppKit/NSImageView.h"
|
#include "AppKit/NSImageView.h"
|
||||||
#include "AppKit/NSMatrix.h"
|
#include "AppKit/NSMatrix.h"
|
||||||
|
#include "AppKit/NSPasteboard.h"
|
||||||
|
#include "AppKit/NSDragging.h"
|
||||||
#include "AppKit/NSSavePanel.h"
|
#include "AppKit/NSSavePanel.h"
|
||||||
#include "AppKit/NSTextField.h"
|
#include "AppKit/NSTextField.h"
|
||||||
#include "AppKit/NSWorkspace.h"
|
#include "AppKit/NSWorkspace.h"
|
||||||
|
@ -90,6 +92,64 @@ static BOOL _gs_display_reading_progress = NO;
|
||||||
- (NSComparisonResult) _compareFilename: (NSString *)n1 with: (NSString *)n2;
|
- (NSComparisonResult) _compareFilename: (NSString *)n1 with: (NSString *)n2;
|
||||||
@end /* NSSavePanel (PrivateMethods) */
|
@end /* NSSavePanel (PrivateMethods) */
|
||||||
|
|
||||||
|
@interface PanelView : NSView
|
||||||
|
{
|
||||||
|
NSSavePanel *owner;
|
||||||
|
}
|
||||||
|
- (id) initWithFrame: (NSRect)r owner: (NSSavePanel*)p;
|
||||||
|
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender;
|
||||||
|
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation PanelView
|
||||||
|
|
||||||
|
- (unsigned int) draggingEntered: (id <NSDraggingInfo>)sender
|
||||||
|
{
|
||||||
|
NSPasteboard *pb;
|
||||||
|
|
||||||
|
pb = [sender draggingPasteboard];
|
||||||
|
if ([[pb types] indexOfObject: NSFilenamesPboardType] == NSNotFound)
|
||||||
|
{
|
||||||
|
return NSDragOperationNone;
|
||||||
|
}
|
||||||
|
return NSDragOperationAll;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithFrame: (NSRect)r owner: (NSSavePanel*)p
|
||||||
|
{
|
||||||
|
if ((self = [super initWithFrame: r]) != nil)
|
||||||
|
{
|
||||||
|
owner = p;
|
||||||
|
[self registerForDraggedTypes: [NSArray arrayWithObjects:
|
||||||
|
NSFilenamesPboardType, nil]];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
|
||||||
|
{
|
||||||
|
NSArray *types;
|
||||||
|
NSPasteboard *dragPb;
|
||||||
|
|
||||||
|
dragPb = [sender draggingPasteboard];
|
||||||
|
types = [dragPb types];
|
||||||
|
if ([types containsObject: NSFilenamesPboardType] == YES)
|
||||||
|
{
|
||||||
|
NSArray *names = [dragPb propertyListForType: NSFilenamesPboardType];
|
||||||
|
NSString *file = [names lastObject];
|
||||||
|
|
||||||
|
[owner setDirectory: file];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation NSSavePanel (_PrivateMethods)
|
@implementation NSSavePanel (_PrivateMethods)
|
||||||
-(id) _initWithoutGModel
|
-(id) _initWithoutGModel
|
||||||
{
|
{
|
||||||
|
@ -98,6 +158,7 @@ static BOOL _gs_display_reading_progress = NO;
|
||||||
NSImage *image;
|
NSImage *image;
|
||||||
NSRect r;
|
NSRect r;
|
||||||
id lastKeyView;
|
id lastKeyView;
|
||||||
|
id panelView;
|
||||||
|
|
||||||
// Track window resizing so we can change number of browser columns.
|
// Track window resizing so we can change number of browser columns.
|
||||||
[[NSNotificationCenter defaultCenter] addObserver: self
|
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||||
|
@ -114,10 +175,15 @@ static BOOL _gs_display_reading_progress = NO;
|
||||||
styleMask: (NSTitledWindowMask | NSResizableWindowMask)
|
styleMask: (NSTitledWindowMask | NSResizableWindowMask)
|
||||||
backing: 2 defer: YES];
|
backing: 2 defer: YES];
|
||||||
[self setMinSize: [self frame].size];
|
[self setMinSize: [self frame].size];
|
||||||
[[self contentView] setBounds: NSMakeRect (0, 0, 308, 317)];
|
|
||||||
|
r = NSMakeRect (0, 0, 308, 317);
|
||||||
|
panelView = [[PanelView alloc] initWithFrame: r owner: self];
|
||||||
|
[self setContentView: panelView];
|
||||||
|
RELEASE(panelView);
|
||||||
|
[[self contentView] setBounds: r];
|
||||||
|
|
||||||
r = NSMakeRect (0, 64, 308, 245);
|
r = NSMakeRect (0, 64, 308, 245);
|
||||||
_topView = [[NSView alloc] initWithFrame: r];
|
_topView = [[PanelView alloc] initWithFrame: r owner: self];
|
||||||
[_topView setBounds: r];
|
[_topView setBounds: r];
|
||||||
[_topView setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
|
[_topView setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
|
||||||
[_topView setAutoresizesSubviews: YES];
|
[_topView setAutoresizesSubviews: YES];
|
||||||
|
@ -125,7 +191,7 @@ static BOOL _gs_display_reading_progress = NO;
|
||||||
[_topView release];
|
[_topView release];
|
||||||
|
|
||||||
r = NSMakeRect (0, 0, 308, 64);
|
r = NSMakeRect (0, 0, 308, 64);
|
||||||
_bottomView = [[NSView alloc] initWithFrame: r];
|
_bottomView = [[PanelView alloc] initWithFrame: r owner: self];
|
||||||
[_bottomView setBounds: r];
|
[_bottomView setBounds: r];
|
||||||
[_bottomView setAutoresizingMask: NSViewWidthSizable|NSViewMaxYMargin];
|
[_bottomView setAutoresizingMask: NSViewWidthSizable|NSViewMaxYMargin];
|
||||||
[_bottomView setAutoresizesSubviews: YES];
|
[_bottomView setAutoresizesSubviews: YES];
|
||||||
|
@ -333,7 +399,7 @@ static BOOL _gs_display_reading_progress = NO;
|
||||||
NSBrowserCell *selectedCell;
|
NSBrowserCell *selectedCell;
|
||||||
BOOL isLeaf;
|
BOOL isLeaf;
|
||||||
|
|
||||||
if(column == -1)
|
if (column == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
matrix = [_browser matrixInColumn:column];
|
matrix = [_browser matrixInColumn:column];
|
||||||
|
@ -349,7 +415,7 @@ static BOOL _gs_display_reading_progress = NO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if([[[_form cellAtIndex: 0] stringValue] length] > 0)
|
if ([[[_form cellAtIndex: 0] stringValue] length] > 0)
|
||||||
{
|
{
|
||||||
[_okButton setEnabled:YES];
|
[_okButton setEnabled:YES];
|
||||||
[self _selectCellName:[[_form cellAtIndex: 0] stringValue]];
|
[self _selectCellName:[[_form cellAtIndex: 0] stringValue]];
|
||||||
|
@ -375,34 +441,34 @@ static BOOL _gs_display_reading_progress = NO;
|
||||||
int i, titleLength, cellLength, numberOfCells;
|
int i, titleLength, cellLength, numberOfCells;
|
||||||
|
|
||||||
matrix = [_browser matrixInColumn:[_browser lastColumn]];
|
matrix = [_browser matrixInColumn:[_browser lastColumn]];
|
||||||
if([matrix selectedCell])
|
if ([matrix selectedCell])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
titleLength = [title length];
|
titleLength = [title length];
|
||||||
if(!titleLength)
|
if (!titleLength)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cells = [matrix cells];
|
cells = [matrix cells];
|
||||||
numberOfCells = [cells count];
|
numberOfCells = [cells count];
|
||||||
|
|
||||||
for(i = 0; i < numberOfCells; i++)
|
for (i = 0; i < numberOfCells; i++)
|
||||||
{
|
{
|
||||||
cellString = [[matrix cellAtRow:i column:0] stringValue];
|
cellString = [[matrix cellAtRow:i column:0] stringValue];
|
||||||
|
|
||||||
cellLength = [cellString length];
|
cellLength = [cellString length];
|
||||||
if(cellLength != titleLength)
|
if (cellLength != titleLength)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
result = [self _compareFilename:cellString with:title];
|
result = [self _compareFilename:cellString with:title];
|
||||||
|
|
||||||
if(result == NSOrderedSame)
|
if (result == NSOrderedSame)
|
||||||
{
|
{
|
||||||
[matrix selectCellAtRow:i column:0];
|
[matrix selectCellAtRow:i column:0];
|
||||||
[matrix scrollCellToVisibleAtRow:i column:0];
|
[matrix scrollCellToVisibleAtRow:i column:0];
|
||||||
[_okButton setEnabled:YES];
|
[_okButton setEnabled:YES];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(result == NSOrderedDescending)
|
else if (result == NSOrderedDescending)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -939,6 +1005,7 @@ selectCellWithString: (NSString*)title
|
||||||
NSMatrix *matrix;
|
NSMatrix *matrix;
|
||||||
NSBrowserCell *selectedCell;
|
NSBrowserCell *selectedCell;
|
||||||
NSString *filename;
|
NSString *filename;
|
||||||
|
BOOL isDir = NO;
|
||||||
|
|
||||||
matrix = [_browser matrixInColumn: [_browser lastColumn]];
|
matrix = [_browser matrixInColumn: [_browser lastColumn]];
|
||||||
selectedCell = [matrix selectedCell];
|
selectedCell = [matrix selectedCell];
|
||||||
|
@ -976,9 +1043,50 @@ selectCellWithString: (NSString*)title
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIGN (_directory, [_browser pathToColumn:[_browser lastColumn]]);
|
ASSIGN (_directory, [_browser pathToColumn:[_browser lastColumn]]);
|
||||||
ASSIGN (_fullFileName, [_directory stringByAppendingPathComponent:
|
filename = [[_form cellAtIndex: 0] stringValue];
|
||||||
[[_form cellAtIndex: 0] stringValue]]);
|
if ([filename isAbsolutePath] == YES)
|
||||||
|
{
|
||||||
|
ASSIGN (_fullFileName, filename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ASSIGN (_fullFileName, [_directory stringByAppendingPathComponent:
|
||||||
|
filename]);
|
||||||
|
}
|
||||||
|
|
||||||
|
filename = [_fullFileName stringByDeletingLastPathComponent];
|
||||||
|
if ([_fm fileExistsAtPath: filename isDirectory: &isDir] == NO)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
result = NSRunAlertPanel(_(@"Save"),
|
||||||
|
_(@"The directory '%@' does not exist, do you want to create it?"),
|
||||||
|
_(@"Yes"), _(@"No"), nil,
|
||||||
|
filename
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result == NSAlertDefaultReturn)
|
||||||
|
{
|
||||||
|
if ([_fm createDirectoryAtPath: filename attributes: nil] == NO)
|
||||||
|
{
|
||||||
|
NSRunAlertPanel(_(@"Save"),
|
||||||
|
_(@"The directory '%@' could not be created."),
|
||||||
|
_(@"Dismiss"), nil, nil,
|
||||||
|
filename
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (isDir == NO)
|
||||||
|
{
|
||||||
|
NSRunAlertPanel(_(@"Save"),
|
||||||
|
_(@"The path '%@' is not a directory."),
|
||||||
|
_(@"Dismiss"), nil, nil,
|
||||||
|
filename
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ([_fm fileExistsAtPath: [self filename] isDirectory: NULL])
|
if ([_fm fileExistsAtPath: [self filename] isDirectory: NULL])
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
@ -1433,14 +1541,22 @@ createRowsForColumn: (int)column
|
||||||
NSComparisonResult result;
|
NSComparisonResult result;
|
||||||
NSRange range;
|
NSRange range;
|
||||||
|
|
||||||
matrix = [_browser matrixInColumn:[_browser lastColumn]];
|
|
||||||
s = [[[aNotification userInfo] objectForKey:@"NSFieldEditor"] string];
|
s = [[[aNotification userInfo] objectForKey:@"NSFieldEditor"] string];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the user typed in an absolute path, display it.
|
||||||
|
*/
|
||||||
|
if ([s isAbsolutePath] == YES)
|
||||||
|
{
|
||||||
|
[self setDirectory: s];
|
||||||
|
}
|
||||||
|
|
||||||
sLength = [s length];
|
sLength = [s length];
|
||||||
range.location = 0;
|
range.location = 0;
|
||||||
range.length = sLength;
|
range.length = sLength;
|
||||||
|
|
||||||
if(sLength == 0)
|
matrix = [_browser matrixInColumn:[_browser lastColumn]];
|
||||||
|
if (sLength == 0)
|
||||||
{
|
{
|
||||||
[matrix deselectAllCells];
|
[matrix deselectAllCells];
|
||||||
[_okButton setEnabled:NO];
|
[_okButton setEnabled:NO];
|
||||||
|
@ -1452,31 +1568,31 @@ createRowsForColumn: (int)column
|
||||||
selectedRow = [matrix selectedRow];
|
selectedRow = [matrix selectedRow];
|
||||||
cells = [matrix cells];
|
cells = [matrix cells];
|
||||||
|
|
||||||
if(selectedString)
|
if (selectedString)
|
||||||
{
|
{
|
||||||
result = [s compare:selectedString options:0 range:range];
|
result = [s compare:selectedString options:0 range:range];
|
||||||
|
|
||||||
if(result == NSOrderedSame)
|
if (result == NSOrderedSame)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
result = NSOrderedDescending;
|
result = NSOrderedDescending;
|
||||||
|
|
||||||
if(result == NSOrderedDescending)
|
if (result == NSOrderedDescending)
|
||||||
{
|
{
|
||||||
int numberOfCells = [cells count];
|
int numberOfCells = [cells count];
|
||||||
|
|
||||||
for(i = selectedRow+1; i < numberOfCells; i++)
|
for (i = selectedRow+1; i < numberOfCells; i++)
|
||||||
{
|
{
|
||||||
selectedString = [[matrix cellAtRow:i column:0] stringValue];
|
selectedString = [[matrix cellAtRow:i column:0] stringValue];
|
||||||
|
|
||||||
cellLength = [selectedString length];
|
cellLength = [selectedString length];
|
||||||
if(cellLength != sLength)
|
if (cellLength != sLength)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
result = [selectedString compare:s options:0 range:range];
|
result = [selectedString compare:s options:0 range:range];
|
||||||
|
|
||||||
if(result == NSOrderedSame)
|
if (result == NSOrderedSame)
|
||||||
{
|
{
|
||||||
[matrix deselectAllCells];
|
[matrix deselectAllCells];
|
||||||
[matrix selectCellAtRow:i column:0];
|
[matrix selectCellAtRow:i column:0];
|
||||||
|
@ -1488,17 +1604,17 @@ createRowsForColumn: (int)column
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(i = selectedRow; i >= 0; --i)
|
for (i = selectedRow; i >= 0; --i)
|
||||||
{
|
{
|
||||||
selectedString = [[matrix cellAtRow:i column:0] stringValue];
|
selectedString = [[matrix cellAtRow:i column:0] stringValue];
|
||||||
|
|
||||||
cellLength = [selectedString length];
|
cellLength = [selectedString length];
|
||||||
if(cellLength != sLength)
|
if (cellLength != sLength)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
result = [selectedString compare:s options:0 range:range];
|
result = [selectedString compare:s options:0 range:range];
|
||||||
|
|
||||||
if(result == NSOrderedSame)
|
if (result == NSOrderedSame)
|
||||||
{
|
{
|
||||||
[matrix deselectAllCells];
|
[matrix deselectAllCells];
|
||||||
[matrix selectCellAtRow:i column:0];
|
[matrix selectCellAtRow:i column:0];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue