discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: custom options during save in a document app


From: Dr. H. Nikolaus Schaller
Subject: Re: custom options during save in a document app
Date: Fri, 5 Oct 2012 14:56:17 +0200

Am 05.10.2012 um 14:37 schrieb Riccardo Mottola:

> Hi Wolfgang,
> 
> Wolfgang Lux wrote:
>> Hi Riccardo,
>> I think you are on a completely wrong track here. If you want to add a JPEG 
>> file type to PRICE, you should declare that in the NSTypes (or 
>> CFBundleDocumentTypes) section of the Info.plist file as a separate type, 
>> but using the same NSDocumentClass as for TIFF files. Then, the NSDocument 
>> framework will automatically handle the file type and file extension for you 
>> and you shouldn't override saveDocumentAs: (it will not work in the way 
>> you'd expect on OS X anyway thanks to document modal sheets anyway).
>> 
>> To add options for the JPEG type you must add an accessory view to the save 
>> panel in -prepareSavePanel:, as Fred and Nikolaus suggested. Make sure you 
>> save the values selected by the user in attributes of your document class, 
>> so you have them available in -dataRepresentationOfType:
>> 
> Exactly, I added an accessory view, however as far as I understand, the 
> document types are now my burden. I do not want to override saveDocumentAs 
> anymore, at least not for this need. I can read back what was selected with 
> fileTypeFromLastRunSavePanel, however in the "standard" view which these the 
> type selection generated by the NSDocumentClass are handled automatically. In 
> the standard panel, selection them does change the extension of the file 
> directly (and perhaps does other things too and I want to emulate this).
> 
> Your suggestion would be then to populate the popup dynamically by the 
> supported NSDocumentClass types? That would be a further plus that adds some 
> burden, since some have certain options other others, but could be cool.

Maybe you can try to give the SavePanel a delegate and implement the 
NSOpenSavePanelDelegate protocol?

So it should become possible to check the file extension as it is typed in. And 
you could then be possible to add or remove the accessory view dynamically.

Nikolaus




reply via email to

[Prev in Thread] Current Thread [Next in Thread]