Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: printing/printing_context_mac.mm

Issue 1997016: Set the job name for the print job on the Mac.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "printing/printing_context.h" 5 #include "printing/printing_context.h"
6 6
7 #import <ApplicationServices/ApplicationServices.h> 7 #import <ApplicationServices/ApplicationServices.h>
8 #import <AppKit/AppKit.h> 8 #import <AppKit/AppKit.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 11 matching lines...) Expand all
22 in_print_job_(false), 22 in_print_job_(false),
23 abort_printing_(false) { 23 abort_printing_(false) {
24 } 24 }
25 25
26 PrintingContext::~PrintingContext() { 26 PrintingContext::~PrintingContext() {
27 ResetSettings(); 27 ResetSettings();
28 } 28 }
29 29
30 30
31 PrintingContext::Result PrintingContext::AskUserForSettings( 31 PrintingContext::Result PrintingContext::AskUserForSettings(
32 gfx::NativeWindow window, int max_pages, bool has_selection) { 32 gfx::NativeView parent_view, int max_pages, bool has_selection) {
33 DCHECK([NSThread isMainThread]); 33 DCHECK([NSThread isMainThread]);
34 34
35 // We deliberately don't feed max_pages into the dialog, because setting 35 // We deliberately don't feed max_pages into the dialog, because setting
36 // NSPrintLastPage makes the print dialog pre-select the option to only print 36 // NSPrintLastPage makes the print dialog pre-select the option to only print
37 // a range. 37 // a range.
38 38
39 // TODO(stuartmorgan): implement 'print selection only' (probably requires 39 // TODO(stuartmorgan): implement 'print selection only' (probably requires
40 // adding a new custom view to the panel on 10.5; 10.6 has 40 // adding a new custom view to the panel on 10.5; 10.6 has
41 // NSPrintPanelShowsPrintSelection). 41 // NSPrintPanelShowsPrintSelection).
42 NSPrintPanel* panel = [NSPrintPanel printPanel]; 42 NSPrintPanel* panel = [NSPrintPanel printPanel];
43 NSPrintInfo* printInfo = [NSPrintInfo sharedPrintInfo];
43 44
44 NSPrintPanelOptions options = [panel options]; 45 NSPrintPanelOptions options = [panel options];
45 options |= NSPrintPanelShowsPaperSize; 46 options |= NSPrintPanelShowsPaperSize;
46 options |= NSPrintPanelShowsOrientation; 47 options |= NSPrintPanelShowsOrientation;
47 options |= NSPrintPanelShowsScaling; 48 options |= NSPrintPanelShowsScaling;
48 [panel setOptions:options]; 49 [panel setOptions:options];
49 50
51 NSString* job_title = [[parent_view window] title];
52 PMPrintSettings printSettings = (PMPrintSettings)[printInfo PMPrintSettings];
53 PMPrintSettingsSetJobName(printSettings, (CFStringRef)job_title);
stuartmorgan 2010/05/12 18:54:43 Do you need to nil-check job_title before calling
54 [printInfo updateFromPMPrintSettings];
55
50 // TODO(stuartmorgan): We really want a tab sheet here, not a modal window. 56 // TODO(stuartmorgan): We really want a tab sheet here, not a modal window.
51 // Will require restructuring the PrintingContext API to use a callback. 57 // Will require restructuring the PrintingContext API to use a callback.
52 NSInteger selection = 58 NSInteger selection =
53 [panel runModalWithPrintInfo:[NSPrintInfo sharedPrintInfo]]; 59 [panel runModalWithPrintInfo:printInfo];
54 if (selection != NSOKButton) { 60 if (selection != NSOKButton) {
55 return CANCEL; 61 return CANCEL;
56 } 62 }
57 63
58 ParsePrintInfo([panel printInfo]); 64 ParsePrintInfo([panel printInfo]);
59 return OK; 65 return OK;
60 } 66 }
61 67
62 PrintingContext::Result PrintingContext::UseDefaultSettings() { 68 PrintingContext::Result PrintingContext::UseDefaultSettings() {
63 DCHECK(!in_print_job_); 69 DCHECK(!in_print_job_);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 void PrintingContext::DismissDialog() { 216 void PrintingContext::DismissDialog() {
211 NOTIMPLEMENTED(); 217 NOTIMPLEMENTED();
212 } 218 }
213 219
214 PrintingContext::Result PrintingContext::OnError() { 220 PrintingContext::Result PrintingContext::OnError() {
215 ResetSettings(); 221 ResetSettings();
216 return abort_printing_ ? CANCEL : FAILED; 222 return abort_printing_ ? CANCEL : FAILED;
217 } 223 }
218 224
219 } // namespace printing 225 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698