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

Side by Side Diff: chrome/browser/printing/print_dialog_gtk.cc

Issue 8549031: base::Bind: Convert PrintingContext::PrintSettingsCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win fix. Created 9 years, 1 month 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
« no previous file with comments | « chrome/browser/printing/print_dialog_gtk.h ('k') | chrome/browser/printing/print_job_worker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/printing/print_dialog_gtk.h" 5 #include "chrome/browser/printing/print_dialog_gtk.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <gtk/gtkpagesetupunixdialog.h> 8 #include <gtk/gtkpagesetupunixdialog.h>
9 #include <gtk/gtkprintjob.h> 9 #include <gtk/gtkprintjob.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } // namespace 93 } // namespace
94 94
95 // static 95 // static
96 printing::PrintDialogGtkInterface* PrintDialogGtk::CreatePrintDialog( 96 printing::PrintDialogGtkInterface* PrintDialogGtk::CreatePrintDialog(
97 PrintingContextGtk* context) { 97 PrintingContextGtk* context) {
98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
99 return new PrintDialogGtk(context); 99 return new PrintDialogGtk(context);
100 } 100 }
101 101
102 PrintDialogGtk::PrintDialogGtk(PrintingContextGtk* context) 102 PrintDialogGtk::PrintDialogGtk(PrintingContextGtk* context)
103 : callback_(NULL), 103 : context_(context),
104 context_(context),
105 dialog_(NULL), 104 dialog_(NULL),
106 gtk_settings_(NULL), 105 gtk_settings_(NULL),
107 page_setup_(NULL), 106 page_setup_(NULL),
108 printer_(NULL) { 107 printer_(NULL) {
109 } 108 }
110 109
111 PrintDialogGtk::~PrintDialogGtk() { 110 PrintDialogGtk::~PrintDialogGtk() {
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 111 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
113 112
114 if (dialog_) { 113 if (dialog_) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 gtk_print_settings_set_orientation( 224 gtk_print_settings_set_orientation(
226 gtk_settings_, 225 gtk_settings_,
227 landscape ? GTK_PAGE_ORIENTATION_LANDSCAPE : 226 landscape ? GTK_PAGE_ORIENTATION_LANDSCAPE :
228 GTK_PAGE_ORIENTATION_PORTRAIT); 227 GTK_PAGE_ORIENTATION_PORTRAIT);
229 228
230 InitPrintSettings(ranges, settings); 229 InitPrintSettings(ranges, settings);
231 return true; 230 return true;
232 } 231 }
233 232
234 void PrintDialogGtk::ShowDialog( 233 void PrintDialogGtk::ShowDialog(
235 PrintingContextGtk::PrintSettingsCallback* callback) { 234 const PrintingContextGtk::PrintSettingsCallback& callback) {
236 callback_ = callback; 235 callback_ = callback;
237 236
238 GtkWindow* parent = BrowserList::GetLastActive()->window()->GetNativeHandle(); 237 GtkWindow* parent = BrowserList::GetLastActive()->window()->GetNativeHandle();
239 // TODO(estade): We need a window title here. 238 // TODO(estade): We need a window title here.
240 dialog_ = gtk_print_unix_dialog_new(NULL, parent); 239 dialog_ = gtk_print_unix_dialog_new(NULL, parent);
241 g_signal_connect(dialog_, "delete-event", 240 g_signal_connect(dialog_, "delete-event",
242 G_CALLBACK(gtk_widget_hide_on_delete), NULL); 241 G_CALLBACK(gtk_widget_hide_on_delete), NULL);
243 242
244 243
245 // Set modal so user cannot focus the same tab and press print again. 244 // Set modal so user cannot focus the same tab and press print again.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 range.to = gtk_range[i].end; 335 range.to = gtk_range[i].end;
337 ranges_vector.push_back(range); 336 ranges_vector.push_back(range);
338 } 337 }
339 g_free(gtk_range); 338 g_free(gtk_range);
340 } 339 }
341 340
342 PrintSettings settings; 341 PrintSettings settings;
343 printing::PrintSettingsInitializerGtk::InitPrintSettings( 342 printing::PrintSettingsInitializerGtk::InitPrintSettings(
344 gtk_settings_, page_setup_, ranges_vector, false, &settings); 343 gtk_settings_, page_setup_, ranges_vector, false, &settings);
345 context_->InitWithSettings(settings); 344 context_->InitWithSettings(settings);
346 callback_->Run(PrintingContextGtk::OK); 345 callback_.Run(PrintingContextGtk::OK);
347 callback_ = NULL; 346 callback_.Reset();
348 return; 347 return;
349 } 348 }
350 case GTK_RESPONSE_DELETE_EVENT: // Fall through. 349 case GTK_RESPONSE_DELETE_EVENT: // Fall through.
351 case GTK_RESPONSE_CANCEL: { 350 case GTK_RESPONSE_CANCEL: {
352 callback_->Run(PrintingContextGtk::CANCEL); 351 callback_.Run(PrintingContextGtk::CANCEL);
353 callback_ = NULL; 352 callback_.Reset();
354 return; 353 return;
355 } 354 }
356 case GTK_RESPONSE_APPLY: 355 case GTK_RESPONSE_APPLY:
357 default: { 356 default: {
358 NOTREACHED(); 357 NOTREACHED();
359 } 358 }
360 } 359 }
361 } 360 }
362 361
363 void PrintDialogGtk::SendDocumentToPrinter(const string16& document_name) { 362 void PrintDialogGtk::SendDocumentToPrinter(const string16& document_name) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 // Printing finished. Matches AddRef() in PrintDocument(); 397 // Printing finished. Matches AddRef() in PrintDocument();
399 Release(); 398 Release();
400 } 399 }
401 400
402 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges, 401 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges,
403 PrintSettings* settings) { 402 PrintSettings* settings) {
404 printing::PrintSettingsInitializerGtk::InitPrintSettings( 403 printing::PrintSettingsInitializerGtk::InitPrintSettings(
405 gtk_settings_, page_setup_, page_ranges, false, settings); 404 gtk_settings_, page_setup_, page_ranges, false, settings);
406 context_->InitWithSettings(*settings); 405 context_->InitWithSettings(*settings);
407 } 406 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_dialog_gtk.h ('k') | chrome/browser/printing/print_job_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698