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: Wolfgang Lux
Subject: Re: custom options during save in a document app
Date: Sun, 7 Oct 2012 14:02:37 +0200

Riccardo Mottola wrote:

>> Not sure what your problem is here. There is nothing you need to initialize. 
>> NSDocument automatically selects the current document type (as returned by 
>> the -fileType method) for you.
> I need to initialize my option controls, specifically I send an action to the 
> compression ration slider, so it reads its value and sends it to the text 
> field. I do this if" "JPEG" is selected, but not if "TIFF" since it is not 
> needed.
> 
> At startup, the document type gets selected automatically, but it does not 
> "perform" the action. So if it selects TIFF it is fine, but if it is already 
> JPEG, the fields are uninitialized.
> Perhaps I should check duing the file panel creation, but there I don't have 
> the "sener", that is the popupbutton, to explicitely check for the type.

You don't need the pop up button. I told you above that the pop up button is 
set to the current type of the document  and this is what NSDocument's 
-fileType method returns!

>> At least under GNUstep the pop up button is created just once and retained 
>> by the NSDocument class. The next time you use the save panel the pop up 
>> button will be reused and set as accessory view of the save panel before 
>> -prepareSavePanel is called. If that doesn't work for you, you seem to have 
>> a major bug in your code.
> I don't doubt there are bugs lurking around.
> 
> On mac, if I do "save as" and "save as again" I get twice this log:
> 
> 2012-10-07 11:13:37.651 PRICE[1316] prepareSavePanel, original accessory view 
> class: NSBox
> 2012-10-07 11:13:37.666 PRICE[1316] original content view: <NSView: 0x4692f0>
> 2012-10-07 11:13:37.669 PRICE[1316] new options view: <NSBox: 0x4d6840>
> 
> <...>
> 
> 2012-10-07 11:13:48.188 PRICE[1316] prepareSavePanel, original accessory view 
> class: NSBox
> 2012-10-07 11:13:48.188 PRICE[1316] original content view: <NSView: 0x5828d70>
> 2012-10-07 11:13:48.188 PRICE[1316] new options view: <NSBox: 0x4d6840>
> 
> this means that the options view loaded from the nib is the same, but he view 
> of the savepanel is different.

Which doesn't surprise me much, as the save panel on OS X on the second call 
should be different as well :-)
Contrary to what the documentation says, you get a new panel for each call of 
NSSavePanel -savePanel. But then, this shouldn't matter much for your code.

> On GNUstep I ca't get anything to work at the moment, I expect I need some 
> slight different reparent code, because the accessory view is not a Box, 
> however right now I get "null" for the original content view. Does it work 
> for  you?

Just checked and it indeed doesn't work on GNUstep. Turns out this is because 
GNUstep is still using a long deprecated API 
(-runModalSavePanel:withAccessoryView:) to present the save panel. However, 
this gives you a different option to modify the accessory: Override that 
NSDocument method and change the accessoryView passed to that method before 
calling the super class implementation.

Wolfgang




reply via email to

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