Do better job on validating the OK button of the Open panel. Replaces

the previous "fix" for bug #25471, which made it impossible to use the
open panel for choosing directories (except by entering a fake file
name into the panel) and actually did not fix that bug other than by
coincidence.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29129 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
wlux 2009-12-15 23:56:51 +00:00
parent 44c81fa9a7
commit 42a97f5908
2 changed files with 15 additions and 30 deletions

View file

@ -1,5 +1,11 @@
2009-12-16 Wolfgang Lux <wolfgang.lux@gmail.com> 2009-12-16 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSOpenPanel.m (-_selectTextInColumn:, _selectCellName:,
-controlTextDidChange:): Do better job on validating the OK
button. Replaces the previous fix for bug #25471, which made it
impossible to use the open panel for choosing directories (except
by entering a fake file name into the panel).
* Source/NSBrowser.m (-doClick:): Fix NSBrowser so that branch * Source/NSBrowser.m (-doClick:): Fix NSBrowser so that branch
cells are really deselected when multiple selection is enabled and cells are really deselected when multiple selection is enabled and
allowsBranchSelection is set to NO. Also replace the workaround allowsBranchSelection is set to NO. Also replace the workaround

View file

@ -91,7 +91,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
[self setCanChooseFiles: YES]; [self setCanChooseFiles: YES];
[self setCanChooseDirectories: YES]; [self setCanChooseDirectories: YES];
[self setAllowsMultipleSelection: NO]; [self setAllowsMultipleSelection: NO];
[_okButton setEnabled: YES]; [_okButton setEnabled: NO];
} }
- (BOOL) _shouldShowExtension: (NSString *)extension - (BOOL) _shouldShowExtension: (NSString *)extension
@ -124,12 +124,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
[[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]];
[_okButton setEnabled:
[self _shouldShowExtension:
[[_browser path] pathExtension]]];
}
} }
else else
{ {
@ -144,17 +139,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
if (_canChooseDirectories == NO || [[matrix selectedCell] isLeaf] == YES) if (_canChooseDirectories == NO || [[matrix selectedCell] isLeaf] == YES)
[super _selectTextInColumn: column]; [super _selectTextInColumn: column];
else else
{ [self _selectCellName: [[_form cellAtIndex: 0] stringValue]];
if ([[[_form cellAtIndex: 0] stringValue] length] > 0)
{
[self _selectCellName: [[_form cellAtIndex: 0] stringValue]];
[_form setNeedsDisplay: YES];
}
[_okButton setEnabled:
[self _shouldShowExtension:
[[_browser path] pathExtension]]];
}
} }
} }
@ -174,7 +159,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
titleLength = [title length]; titleLength = [title length];
if (!titleLength) if (!titleLength)
{ {
[_okButton setEnabled: NO]; [_okButton setEnabled: _canChooseDirectories];
return; return;
} }
@ -205,6 +190,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
else if (result == NSOrderedDescending) else if (result == NSOrderedDescending)
break; break;
} }
[_okButton setEnabled: NO];
} }
- (void) _setupForDirectory: (NSString *)path file: (NSString *)filename - (void) _setupForDirectory: (NSString *)path file: (NSString *)filename
@ -516,12 +502,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
} }
else else
{ {
if (_canChooseDirectories == NO) if (selectedColumn == lastColumn)
{
if (selectedColumn == lastColumn)
selectedCell = [matrix selectedCell];
}
else if (selectedColumn == lastColumn)
selectedCell = [matrix selectedCell]; selectedCell = [matrix selectedCell];
} }
} }
@ -539,8 +520,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
} }
} }
else if (_canChooseDirectories == NO else if (_canChooseDirectories == NO
&& (![_browser allowsMultipleSelection] || !selectedCells && (selectedColumn != lastColumn || ![selectedCells count]))
|| selectedColumn != lastColumn || ![selectedCells count]))
{ {
[_form selectTextAtIndex: 0]; [_form selectTextAtIndex: 0];
[_form setNeedsDisplay: YES]; [_form setNeedsDisplay: YES];
@ -653,8 +633,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
if (sLength == 0) if (sLength == 0)
{ {
[matrix deselectAllCells]; [matrix deselectAllCells];
if (_canChooseDirectories == NO) [_okButton setEnabled: _canChooseDirectories];
[_okButton setEnabled: NO];
return; return;
} }
@ -732,7 +711,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
} }
[matrix deselectAllCells]; [matrix deselectAllCells];
[_okButton setEnabled: YES]; [_okButton setEnabled: NO];
} }
@end /* NSOpenPanel */ @end /* NSOpenPanel */