Implemented accessory view.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23006 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2006-05-30 04:54:12 +00:00
parent 46be8e4caf
commit aa206849b2
2 changed files with 45 additions and 8 deletions

View file

@ -1,3 +1,8 @@
2006-05-30 00:53 Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSDocument.m: Implemented accessory view logic when
the document can save more than one filetype.
2006-05-29 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSApplication.m: Revert last change which broke menu

View file

@ -36,6 +36,7 @@
#include "AppKit/NSView.h"
#include "AppKit/NSPopUpButton.h"
#include "AppKit/NSDocumentFrameworkPrivate.h"
#include "AppKit/NSBox.h"
#include "GSGuiPrivate.h"
@ -456,7 +457,7 @@
- (IBAction)changeSaveType: (id)sender
{
//FIXME if we have accessory -- store the desired save type somewhere.
[self setFileType: [sender titleOfSelectedItem]];
}
- (int)runModalSavePanel: (NSSavePanel *)savePanel
@ -471,13 +472,45 @@
return YES;
}
- (void) _loadPanelAccessoryNib
- (void) _createPanelAccessory
{
// FIXME. We need to load the pop-up button
if(savePanelAccessory == nil)
{
NSRect accessoryFrame = NSMakeRect(0,0,380,70);
NSRect spaFrame = NSMakeRect(115,14,150,22);
savePanelAccessory = [[NSBox alloc] initWithFrame: accessoryFrame];
[(NSBox *)savePanelAccessory setTitle: @"File Type"];
[savePanelAccessory setAutoresizingMask:
NSViewWidthSizable | NSViewHeightSizable];
spaButton = [[NSPopUpButton alloc] initWithFrame: spaFrame];
[spaButton setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable | NSViewMinYMargin |
NSViewMaxYMargin | NSViewMinXMargin | NSViewMaxXMargin];
[spaButton setTarget: self];
[spaButton setAction: @selector(changeSaveType:)];
[savePanelAccessory addSubview: spaButton];
}
}
- (void) _addItemsToSpaButtonFromArray: (NSArray *)types
{
// FIXME. Add types to popup.
NSEnumerator *en = [types objectEnumerator];
NSString *title = nil;
int i = 0;
while((title = [en nextObject]) != nil)
{
[spaButton addItemWithTitle: title];
i++;
}
// if it's more than one, then
[spaButton setEnabled: (i > 0)];
// if we have some items, select the current filetype.
if(i > 0)
{
[spaButton selectItemWithTitle: [self fileType]];
}
}
- (NSString *)fileNameFromRunningSavePanelForSaveOperation: (NSSaveOperationType)saveOperation
@ -495,7 +528,7 @@
if ([self shouldRunSavePanelWithAccessoryView])
{
if (savePanelAccessory == nil)
[self _loadPanelAccessoryNib];
[self _createPanelAccessory];
[self _addItemsToSpaButtonFromArray: extensions];
@ -645,9 +678,8 @@
- (NSString *)fileTypeFromLastRunSavePanel
{
// FIXME this should return type picked on save accessory
// return [spaPopupButton title];
return [self fileType];
// return [self fileType];
return [spaButton title];
}
- (NSDictionary *)fileAttributesToWriteToFile: (NSString *)fullDocumentPath