Document print patch by Wolfgang Lux.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24800 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2007-03-07 14:38:51 +00:00
parent 58edc1e5db
commit a0c83e671f
5 changed files with 62 additions and 16 deletions

View file

@ -1,4 +1,27 @@
2007-03-08 Richard Frith-Macdonald <rfm@gnu.org>
2007-03-07 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSPrintPanel.m: The modal loop which displays the print
panel is now left with either NSOKButton or NSCancelButton
(cf. the documentation of NSPrintPanel's -runModal: and
-beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:).
* Source/NSPrintOperation.m: The callback passed to the print
panel's beginSheet... method had a wrong signature (and also was
misspelled). In addition, the code of the callback did retrieve
its own callback from the print dictionary in a wrong way (was
asking for a pointer to a selector while a selector was saved).
* Source/NSDocument.m: The callback of
-runModalPrintOperation:delegate:didRunSelector:contextInfo:
method has a different signature than the one passed to the print
operation's
-runOperationModalForWindow:delegate:didRunSelector:contextInfo:
method. This means NSDocument needs some adapter code and also has
to save the delegate and selector passed to runModalPrintOperation...
in some place.
* Headers/AppKit/NSDocument.h: Since there can be at most one print dialog for a
document, add two private instance variables to NSDocument for that purpose.
Patch by Wolfgang Lux <wolfgang.lux@gmail.com>.
2007-03-07 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSPasteboard.m: Launch gpbs with --auto option so that
it shuts down again when all connections are closed.

View file

@ -96,6 +96,8 @@ typedef enum _NSSaveOperationType {
NSString *_last_component_file_name; // file name last component
NSURL *_autosaved_file_url; // Autosave location as URL
NSPrintInfo *_print_info; // print info record
id _printOp_delegate; // delegate and selector called
SEL _printOp_didRunSelector;// after modal print operation
NSView *_save_panel_accessory; // outlet for the accessory save-panel view
NSPopUpButton *_spa_button; // outlet for "the File Format:" button in the save panel.
NSString *_save_type; // the currently selected extension.

View file

@ -196,6 +196,7 @@ withContentsOfURL: (NSURL *)url
RELEASE(_window_controllers);
RELEASE(_window);
RELEASE(_print_info);
RELEASE(_printOp_delegate);
RELEASE(_save_panel_accessory);
RELEASE(_spa_button);
RELEASE(_save_type);
@ -1253,12 +1254,30 @@ originalContentsURL: (NSURL *)orig
didRunSelector: (SEL)sel
contextInfo: (void *)context
{
ASSIGN(_printOp_delegate, delegate);
_printOp_didRunSelector = sel;
[op runOperationModalForWindow: [self windowForSheet]
delegate: delegate
didRunSelector: sel
delegate: self
didRunSelector: @selector(_runModalPrintOperationDidSucceed:contextInfo:)
contextInfo: context];
}
- (void)_runModalPrintOperationDidSucceed: (BOOL)success
contextInfo: (void *)context
{
id delegate = _printOp_delegate;
SEL didRunSelector = _printOp_didRunSelector;
void (*didRun)(id, SEL, NSDocument *, BOOL, id);
if (delegate && [delegate respondsToSelector:didRunSelector])
{
didRun = (void (*)(id, SEL, NSDocument *, BOOL, id))
[delegate methodForSelector:didRunSelector];
didRun(delegate, didRunSelector, self, success, context);
}
DESTROY(_printOp_delegate);
}
- (BOOL)validateMenuItem: (NSMenuItem *)anItem
{
BOOL result = YES;

View file

@ -86,7 +86,7 @@ typedef struct _page_info_t {
- (BOOL) _runOperation;
- (void) _setupPrintInfo;
- (void)_printOperationDidRun:(NSPrintOperation *)printOperation
success:(BOOL)success
returnCode:(int)returnCode
contextInfo:(void *)contextInfo;
- (void) _printPaginateWithInfo: (page_info_t *)info
knowsRange: (BOOL)knowsRange;
@ -532,9 +532,9 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
[panel updateFromPrintInfo];
[panel beginSheetWithPrintInfo: _print_info
modalForWindow: docWindow
delegate: delegate
delegate: self
didEndSelector:
@selector(_printOperationDidRun:sucess:contextInfo:)
@selector(_printOperationDidRun:returnCode:contextInfo:)
contextInfo: contextInfo];
[panel setAccessoryView: nil];
}
@ -683,29 +683,29 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
}
- (void)_printOperationDidRun:(NSPrintOperation *)printOperation
success:(BOOL)success
returnCode:(int)returnCode
contextInfo:(void *)contextInfo
{
id delegate;
SEL *didRunSelector;
SEL didRunSelector;
BOOL success = NO;
NSMutableDictionary *dict;
void (*didRun)(id, SEL, BOOL, id);
if (success == YES)
if (returnCode == NSOKButton)
{
NSPrintPanel *panel = [self printPanel];
[panel finalWritePrintInfo];
success = NO;
if ([self _runOperation])
success = [self deliverResult];
}
[self cleanUpOperation];
dict = [_print_info dictionary];
didRunSelector = [[dict objectForKey: @"GSModalRunSelector"] pointerValue];
[[dict objectForKey: @"GSModalRunSelector"] getValue:&didRunSelector];
delegate = [dict objectForKey: @"GSModalRunDelegate"];
didRun = (void (*)(id, SEL, BOOL, id))[delegate methodForSelector:
*didRunSelector];
didRun (delegate, *didRunSelector, success, contextInfo);
didRunSelector];
didRun (delegate, didRunSelector, success, contextInfo);
}

View file

@ -218,11 +218,13 @@ static NSPrintPanel *shared_instance;
*/
- (int)runModal
{
int ret;
_picked = NSOKButton;
[NSApp runModalForWindow: self];
ret = [NSApp runModalForWindow: self];
[_optionPanel orderOut: self];
/* Don't order ourselves out, let the NSPrintOperation do that */
return (_picked == NSCancelButton) ? NSCancelButton : NSOKButton;
return ret;
}
- (void) beginSheetWithPrintInfo: (NSPrintInfo *)printInfo
@ -308,7 +310,7 @@ static NSPrintPanel *shared_instance;
{
NSLog(@"Print panel buttonAction: from unknown sender - x%p\n", sender);
}
[NSApp stopModalWithCode: _picked];
[NSApp stopModalWithCode: (_picked == NSCancelButton) ? NSCancelButton : NSOKButton];
}
- (void) _pickedPage: (id)sender