make save and open panels usable on mswindows

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26520 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2008-05-13 15:04:01 +00:00
parent 7fe697acb2
commit 285dddf250
5 changed files with 90 additions and 14 deletions

View file

@ -1,3 +1,10 @@
2008-05-13 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSOpenPanel.m:
* Source/NSSavepanel.m:
Add code to handle the fact of ms-windows disk drives (multiple roots)
by creating a pseudo-root directory with all the disk drives inside it.
2008-05-08 21:04-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSWindow.m: (-(void)miniaturize: (id)sender):

View file

@ -52,6 +52,19 @@
#include "AppKit/NSMatrix.h"
#include "AppKit/NSOpenPanel.h"
static NSString *
pathToColumn(NSBrowser *browser, int column)
{
#if defined(__MINGW32__)
if (column == 0)
return @"/";
else
return [[browser pathToColumn: column] substringFromIndex: 1];
#else
return [browser pathToColumn: column];
#endif
}
static NSOpenPanel *_gs_gui_open_panel = nil;
// Pacify the compiler
@ -413,7 +426,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
while ((filename = [enumerator nextObject]) != nil)
{
[ret addObject: [NSURL fileURLWithPath: filename]];
[ret addObject: [NSURL fileURLWithPath: filename]];
}
return AUTORELEASE(ret);
@ -533,7 +546,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
return;
}
ASSIGN (_directory, [_browser pathToColumn: [_browser lastColumn]]);
ASSIGN (_directory, pathToColumn(_browser, [_browser lastColumn]));
if (selectedCell)
tmp = [selectedCell stringValue];

View file

@ -66,6 +66,32 @@ static NSFileManager *_fm = nil;
static BOOL _gs_display_reading_progress = NO;
static NSString *
pathToColumn(NSBrowser *browser, int column)
{
#if defined(__MINGW32__)
if (column == 0)
return @"/";
else if (column == 1)
return [[[browser pathToColumn: column] substringFromIndex: 1]
stringByAppendingString: @"/"];
else
return [[browser pathToColumn: column] substringFromIndex: 1];
#else
return [browser pathToColumn: column];
#endif
}
static void
setPath(NSBrowser *browser, NSString *path)
{
#if defined(__MINGW32__)
[browser setPath: [@"/" stringByAppendingString: path]];
#else
[browser setPath: path];
#endif
}
//
// SavePanel filename compare
//
@ -436,7 +462,8 @@ static BOOL _gs_display_reading_progress = NO;
{
if (_delegateHasDirectoryDidChange)
{
[_delegate panel: self directoryDidChange: [_browser pathToColumn: column]];
[_delegate panel: self
directoryDidChange: pathToColumn(_browser, column)];
}
if ([[[_form cellAtIndex: 0] stringValue] length] > 0)
@ -506,7 +533,7 @@ selectCellWithString: (NSString*)title
m = [sender matrixInColumn: column];
isLeaf = [[m selectedCell] isLeaf];
path = [sender pathToColumn: column];
path = pathToColumn(sender, column);
if (isLeaf)
{
@ -537,7 +564,7 @@ selectCellWithString: (NSString*)title
if (filename == nil)
filename = @"";
ASSIGN(_fullFileName, [_directory stringByAppendingPathComponent: filename]);
[_browser setPath: _fullFileName];
setPath(_browser, _fullFileName);
[self _selectCellName: filename];
[[_form cellAtIndex: 0] setStringValue: filename];
@ -679,7 +706,6 @@ selectCellWithString: (NSString*)title
_delegateHasDirectoryDidChange = NO;
_delegateHasSelectionDidChange = NO;
*/
[self _getOriginalSize];
return self;
}
@ -884,7 +910,7 @@ selectCellWithString: (NSString*)title
&& isDir)
{
ASSIGN (_directory, standardizedPath);
[_browser setPath: _directory];
setPath(_browser, _directory);
}
}
@ -1067,7 +1093,7 @@ selectCellWithString: (NSString*)title
*/
- (void) cancel: (id)sender
{
ASSIGN(_directory, [_browser pathToColumn:[_browser lastColumn]]);
ASSIGN(_directory, pathToColumn(_browser, [_browser lastColumn]));
[NSApp stopModalWithCode: NSCancelButton];
[_okButton setEnabled: NO];
[self close];
@ -1096,7 +1122,7 @@ selectCellWithString: (NSString*)title
return;
}
ASSIGN (_directory, [_browser pathToColumn:[_browser lastColumn]]);
ASSIGN (_directory, pathToColumn(_browser, [_browser lastColumn]));
filename = [[_form cellAtIndex: 0] stringValue];
if ([filename isAbsolutePath] == YES)
{
@ -1119,7 +1145,7 @@ selectCellWithString: (NSString*)title
{
ASSIGN (_directory, [filename stringByDeletingLastPathComponent]);
ASSIGN (_fullFileName, filename);
[_browser setPath: _fullFileName];
setPath(_browser, _fullFileName);
filename = [_fullFileName lastPathComponent];
@ -1427,8 +1453,35 @@ createRowsForColumn: (int)column
pool = [NSAutoreleasePool new];
path = [_browser pathToColumn: column];
path = pathToColumn(_browser, column);
#if defined(__MINGW32__)
if (column == 0)
{
NSMutableArray *m;
unsigned i;
files = [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths];
m = [files mutableCopy];
i = [m count];
while (i-- > 0)
{
NSString *file = [m objectAtIndex: i];
/* Strip the backslash from the drive name so we don't
* get it confusing the path we have.
*/
file = [file substringToIndex: [file length] - 1];
[m replaceObjectAtIndex: i withObject: file];
}
files = [m autorelease];
}
else
{
files = [[NSFileManager defaultManager] directoryContentsAtPath: path];
}
#else
files = [[NSFileManager defaultManager] directoryContentsAtPath: path];
#endif
/* Remove hidden files. */
{
@ -1593,7 +1646,7 @@ createRowsForColumn: (int)column
{
NSArray *cells = [[sender matrixInColumn: column] cells];
unsigned count = [cells count], i;
NSString *path = [sender pathToColumn: column];
NSString *path = pathToColumn(sender, column);
// iterate through the cells asking the delegate if each filename is valid
// if it says no for any filename, the column is not valid

View file

@ -2635,6 +2635,9 @@ resetCursorRectsForView(NSView *theView)
- (void) _didDeminiaturize: sender
{
_f.is_miniaturized = NO;
/* May need to redraw on deminiaturisation ...
*/
[_wv setNeedsDisplay: YES];
[nc postNotificationName: NSWindowDidDeminiaturizeNotification object: self];
}

View file

@ -503,7 +503,7 @@ static NSDictionary *applications = nil;
static NSString *extPrefPath = nil;
static NSDictionary *extPreferences = nil;
// FIXME: Won't work for MINGW
// FIXME: Won't work for MINGW32
static NSString *_rootPath = @"/";
/*
@ -1571,7 +1571,7 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
{
NSMutableArray *names;
NSFileManager *mgr = [NSFileManager defaultManager];
#ifdef __MINGW__
#if defined(__MINGW32__)
unsigned max = BUFSIZ;
unichar buf[max];
unichar *base = buf;