 Chromium Code Reviews
 Chromium Code Reviews Issue 2165083002:
  Linux: Refactor X11DesktopHandler  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 2165083002:
  Linux: Refactor X11DesktopHandler  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/libgtk2ui/print_dialog_gtk2.h" | 5 #include "chrome/browser/ui/libgtk2ui/print_dialog_gtk2.h" | 
| 6 | 6 | 
| 7 #include <gtk/gtkunixprint.h> | 7 #include <gtk/gtkunixprint.h> | 
| 8 | 8 | 
| 9 #include <algorithm> | 9 #include <algorithm> | 
| 10 #include <cmath> | 10 #include <cmath> | 
| 11 #include <string> | 11 #include <string> | 
| 12 #include <vector> | 12 #include <vector> | 
| 13 | 13 | 
| 14 #include "base/bind.h" | 14 #include "base/bind.h" | 
| 15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" | 
| 16 #include "base/files/file_util_proxy.h" | 16 #include "base/files/file_util_proxy.h" | 
| 17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" | 
| 18 #include "base/logging.h" | 18 #include "base/logging.h" | 
| 19 #include "base/macros.h" | 19 #include "base/macros.h" | 
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" | 
| 21 #include "base/values.h" | 21 #include "base/values.h" | 
| 22 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" | 22 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" | 
| 23 #include "chrome/browser/ui/libgtk2ui/printing_gtk2_util.h" | 23 #include "chrome/browser/ui/libgtk2ui/printing_gtk2_util.h" | 
| 24 #include "printing/metafile.h" | 24 #include "printing/metafile.h" | 
| 25 #include "printing/print_job_constants.h" | 25 #include "printing/print_job_constants.h" | 
| 26 #include "printing/print_settings.h" | 26 #include "printing/print_settings.h" | 
| 27 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" | 
| 28 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" | |
| 29 | 28 | 
| 30 using content::BrowserThread; | 29 using content::BrowserThread; | 
| 31 using printing::PageRanges; | 30 using printing::PageRanges; | 
| 32 using printing::PrintSettings; | 31 using printing::PrintSettings; | 
| 33 | 32 | 
| 34 namespace { | 33 namespace { | 
| 35 | 34 | 
| 36 #if defined(USE_CUPS) | 35 #if defined(USE_CUPS) | 
| 37 // CUPS Duplex attribute and values. | 36 // CUPS Duplex attribute and values. | 
| 38 const char kCUPSDuplex[] = "cups-Duplex"; | 37 const char kCUPSDuplex[] = "cups-Duplex"; | 
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 TRUE); | 358 TRUE); | 
| 360 gtk_print_unix_dialog_set_has_selection(GTK_PRINT_UNIX_DIALOG(dialog_), | 359 gtk_print_unix_dialog_set_has_selection(GTK_PRINT_UNIX_DIALOG(dialog_), | 
| 361 has_selection); | 360 has_selection); | 
| 362 gtk_print_unix_dialog_set_settings(GTK_PRINT_UNIX_DIALOG(dialog_), | 361 gtk_print_unix_dialog_set_settings(GTK_PRINT_UNIX_DIALOG(dialog_), | 
| 363 gtk_settings_); | 362 gtk_settings_); | 
| 364 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); | 363 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); | 
| 365 gtk_widget_show(dialog_); | 364 gtk_widget_show(dialog_); | 
| 366 | 365 | 
| 367 // We need to call gtk_window_present after making the widgets visible to make | 366 // We need to call gtk_window_present after making the widgets visible to make | 
| 368 // sure window gets correctly raised and gets focus. | 367 // sure window gets correctly raised and gets focus. | 
| 369 int time = views::X11DesktopHandler::get()->wm_user_time_ms(); | 368 gtk_window_present(GTK_WINDOW(dialog_)); | 
| 
danakj
2016/08/11 21:48:19
Using a time is better if we can. Not being famili
 
Tom (Use chromium acct)
2016/08/15 18:42:45
:(
../../chrome/browser/ui/libgtk2ui/print_dialog
 
Tom (Use chromium acct)
2016/08/19 00:26:31
Turns out the necessary dependency was added in th
 | |
| 370 gtk_window_present_with_time(GTK_WINDOW(dialog_), time); | |
| 371 } | 369 } | 
| 372 | 370 | 
| 373 void PrintDialogGtk2::PrintDocument(const printing::MetafilePlayer& metafile, | 371 void PrintDialogGtk2::PrintDocument(const printing::MetafilePlayer& metafile, | 
| 374 const base::string16& document_name) { | 372 const base::string16& document_name) { | 
| 375 // This runs on the print worker thread, does not block the UI thread. | 373 // This runs on the print worker thread, does not block the UI thread. | 
| 376 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 374 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
| 377 | 375 | 
| 378 // The document printing tasks can outlive the PrintingContext that created | 376 // The document printing tasks can outlive the PrintingContext that created | 
| 379 // this dialog. | 377 // this dialog. | 
| 380 AddRef(); | 378 AddRef(); | 
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 void PrintDialogGtk2::OnWindowDestroying(aura::Window* window) { | 547 void PrintDialogGtk2::OnWindowDestroying(aura::Window* window) { | 
| 550 DCHECK_EQ(libgtk2ui::GetAuraTransientParent(dialog_), window); | 548 DCHECK_EQ(libgtk2ui::GetAuraTransientParent(dialog_), window); | 
| 551 | 549 | 
| 552 libgtk2ui::ClearAuraTransientParent(dialog_); | 550 libgtk2ui::ClearAuraTransientParent(dialog_); | 
| 553 window->RemoveObserver(this); | 551 window->RemoveObserver(this); | 
| 554 if (!callback_.is_null()) { | 552 if (!callback_.is_null()) { | 
| 555 callback_.Run(PrintingContextLinux::CANCEL); | 553 callback_.Run(PrintingContextLinux::CANCEL); | 
| 556 callback_.Reset(); | 554 callback_.Reset(); | 
| 557 } | 555 } | 
| 558 } | 556 } | 
| OLD | NEW |