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

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

Issue 8372030: Get printing working in Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix gyp issues with tests 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
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 86
87 std::vector<GtkPrinter*> printers_; 87 std::vector<GtkPrinter*> printers_;
88 GtkPrinter* default_printer_; 88 GtkPrinter* default_printer_;
89 }; 89 };
90 90
91 } // namespace 91 } // namespace
92 92
93 // static 93 // static
94 printing::PrintDialogGtkInterface* PrintDialogGtk::CreatePrintDialog( 94 printing::PrintDialogGtkInterface* PrintDialogGtk::CreatePrintDialog(
95 PrintingContextCairo* context) { 95 PrintingContextGtk* context) {
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
97 return new PrintDialogGtk(context); 97 return new PrintDialogGtk(context);
98 } 98 }
99 99
100 PrintDialogGtk::PrintDialogGtk(PrintingContextCairo* context) 100 PrintDialogGtk::PrintDialogGtk(PrintingContextGtk* context)
101 : callback_(NULL), 101 : callback_(NULL),
102 context_(context), 102 context_(context),
103 dialog_(NULL), 103 dialog_(NULL),
104 gtk_settings_(NULL), 104 gtk_settings_(NULL),
105 page_setup_(NULL), 105 page_setup_(NULL),
106 printer_(NULL) { 106 printer_(NULL) {
107 } 107 }
108 108
109 PrintDialogGtk::~PrintDialogGtk() { 109 PrintDialogGtk::~PrintDialogGtk() {
110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 gtk_print_settings_set_orientation( 221 gtk_print_settings_set_orientation(
222 gtk_settings_, 222 gtk_settings_,
223 landscape ? GTK_PAGE_ORIENTATION_LANDSCAPE : 223 landscape ? GTK_PAGE_ORIENTATION_LANDSCAPE :
224 GTK_PAGE_ORIENTATION_PORTRAIT); 224 GTK_PAGE_ORIENTATION_PORTRAIT);
225 225
226 InitPrintSettings(ranges, settings); 226 InitPrintSettings(ranges, settings);
227 return true; 227 return true;
228 } 228 }
229 229
230 void PrintDialogGtk::ShowDialog( 230 void PrintDialogGtk::ShowDialog(
231 PrintingContextCairo::PrintSettingsCallback* callback) { 231 PrintingContextGtk::PrintSettingsCallback* callback) {
232 callback_ = callback; 232 callback_ = callback;
233 233
234 GtkWindow* parent = BrowserList::GetLastActive()->window()->GetNativeHandle(); 234 GtkWindow* parent = BrowserList::GetLastActive()->window()->GetNativeHandle();
235 // TODO(estade): We need a window title here. 235 // TODO(estade): We need a window title here.
236 dialog_ = gtk_print_unix_dialog_new(NULL, parent); 236 dialog_ = gtk_print_unix_dialog_new(NULL, parent);
237 g_signal_connect(dialog_, "delete-event", 237 g_signal_connect(dialog_, "delete-event",
238 G_CALLBACK(gtk_widget_hide_on_delete), NULL); 238 G_CALLBACK(gtk_widget_hide_on_delete), NULL);
239 239
240 240
241 // Set modal so user cannot focus the same tab and press print again. 241 // Set modal so user cannot focus the same tab and press print again.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 range.to = gtk_range[i].end; 333 range.to = gtk_range[i].end;
334 ranges_vector.push_back(range); 334 ranges_vector.push_back(range);
335 } 335 }
336 g_free(gtk_range); 336 g_free(gtk_range);
337 } 337 }
338 338
339 PrintSettings settings; 339 PrintSettings settings;
340 printing::PrintSettingsInitializerGtk::InitPrintSettings( 340 printing::PrintSettingsInitializerGtk::InitPrintSettings(
341 gtk_settings_, page_setup_, ranges_vector, false, &settings); 341 gtk_settings_, page_setup_, ranges_vector, false, &settings);
342 context_->InitWithSettings(settings); 342 context_->InitWithSettings(settings);
343 callback_->Run(PrintingContextCairo::OK); 343 callback_->Run(PrintingContextGtk::OK);
344 callback_ = NULL; 344 callback_ = NULL;
345 return; 345 return;
346 } 346 }
347 case GTK_RESPONSE_DELETE_EVENT: // Fall through. 347 case GTK_RESPONSE_DELETE_EVENT: // Fall through.
348 case GTK_RESPONSE_CANCEL: { 348 case GTK_RESPONSE_CANCEL: {
349 callback_->Run(PrintingContextCairo::CANCEL); 349 callback_->Run(PrintingContextGtk::CANCEL);
350 callback_ = NULL; 350 callback_ = NULL;
351 return; 351 return;
352 } 352 }
353 case GTK_RESPONSE_APPLY: 353 case GTK_RESPONSE_APPLY:
354 default: { 354 default: {
355 NOTREACHED(); 355 NOTREACHED();
356 } 356 }
357 } 357 }
358 } 358 }
359 359
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 // Printing finished. Matches AddRef() in PrintDocument(); 395 // Printing finished. Matches AddRef() in PrintDocument();
396 Release(); 396 Release();
397 } 397 }
398 398
399 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges, 399 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges,
400 PrintSettings* settings) { 400 PrintSettings* settings) {
401 printing::PrintSettingsInitializerGtk::InitPrintSettings( 401 printing::PrintSettingsInitializerGtk::InitPrintSettings(
402 gtk_settings_, page_setup_, page_ranges, false, settings); 402 gtk_settings_, page_setup_, page_ranges, false, settings);
403 context_->InitWithSettings(*settings); 403 context_->InitWithSettings(*settings);
404 } 404 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698