Commit dce5d5c2 authored by Marshall Greenblatt's avatar Marshall Greenblatt

Linux: Pass CefBrowser to CefPrintHandler callbacks (issue #2196)

parent 5918d426
......@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=e8f6bdc822cf4f5c32b22ba8b5cacb25823d8971$
// $hash=ed78ca41d62dfc0cdb52828dcf795617c4e231a7$
//
#ifndef CEF_INCLUDE_CAPI_CEF_PRINT_HANDLER_CAPI_H_
......@@ -85,8 +85,9 @@ typedef struct _cef_print_job_callback_t {
} cef_print_job_callback_t;
///
// Implement this structure to handle printing on Linux. The functions of this
// structure will be called on the browser process UI thread.
// Implement this structure to handle printing on Linux. Each browser will have
// only one print job in progress at a time. The functions of this structure
// will be called on the browser process UI thread.
///
typedef struct _cef_print_handler_t {
///
......@@ -109,6 +110,7 @@ typedef struct _cef_print_handler_t {
// reference to |settings| outside of this callback.
///
void(CEF_CALLBACK* on_print_settings)(struct _cef_print_handler_t* self,
struct _cef_browser_t* browser,
struct _cef_print_settings_t* settings,
int get_defaults);
......@@ -119,6 +121,7 @@ typedef struct _cef_print_handler_t {
///
int(CEF_CALLBACK* on_print_dialog)(
struct _cef_print_handler_t* self,
struct _cef_browser_t* browser,
int has_selection,
struct _cef_print_dialog_callback_t* callback);
......@@ -128,6 +131,7 @@ typedef struct _cef_print_handler_t {
// the job immediately.
///
int(CEF_CALLBACK* on_print_job)(struct _cef_print_handler_t* self,
struct _cef_browser_t* browser,
const cef_string_t* document_name,
const cef_string_t* pdf_file_path,
struct _cef_print_job_callback_t* callback);
......@@ -135,7 +139,8 @@ typedef struct _cef_print_handler_t {
///
// Reset client state related to printing.
///
void(CEF_CALLBACK* on_print_reset)(struct _cef_print_handler_t* self);
void(CEF_CALLBACK* on_print_reset)(struct _cef_print_handler_t* self,
struct _cef_browser_t* browser);
///
// Return the PDF paper size in device units. Used in combination with
......@@ -143,6 +148,7 @@ typedef struct _cef_print_handler_t {
///
cef_size_t(CEF_CALLBACK* get_pdf_paper_size)(
struct _cef_print_handler_t* self,
struct _cef_browser_t* browser,
int device_units_per_inch);
} cef_print_handler_t;
......
......@@ -75,8 +75,9 @@ class CefPrintJobCallback : public virtual CefBaseRefCounted {
};
///
// Implement this interface to handle printing on Linux. The methods of this
// class will be called on the browser process UI thread.
// Implement this interface to handle printing on Linux. Each browser will have
// only one print job in progress at a time. The methods of this class will be
// called on the browser process UI thread.
///
/*--cef(source=client)--*/
class CefPrintHandler : public virtual CefBaseRefCounted {
......@@ -96,7 +97,8 @@ class CefPrintHandler : public virtual CefBaseRefCounted {
// reference to |settings| outside of this callback.
///
/*--cef()--*/
virtual void OnPrintSettings(CefRefPtr<CefPrintSettings> settings,
virtual void OnPrintSettings(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefPrintSettings> settings,
bool get_defaults) = 0;
///
......@@ -105,7 +107,8 @@ class CefPrintHandler : public virtual CefBaseRefCounted {
// printing immediately.
///
/*--cef()--*/
virtual bool OnPrintDialog(bool has_selection,
virtual bool OnPrintDialog(CefRefPtr<CefBrowser> browser,
bool has_selection,
CefRefPtr<CefPrintDialogCallback> callback) = 0;
///
......@@ -114,7 +117,8 @@ class CefPrintHandler : public virtual CefBaseRefCounted {
// immediately.
///
/*--cef()--*/
virtual bool OnPrintJob(const CefString& document_name,
virtual bool OnPrintJob(CefRefPtr<CefBrowser> browser,
const CefString& document_name,
const CefString& pdf_file_path,
CefRefPtr<CefPrintJobCallback> callback) = 0;
......@@ -122,14 +126,15 @@ class CefPrintHandler : public virtual CefBaseRefCounted {
// Reset client state related to printing.
///
/*--cef()--*/
virtual void OnPrintReset() = 0;
virtual void OnPrintReset(CefRefPtr<CefBrowser> browser) = 0;
///
// Return the PDF paper size in device units. Used in combination with
// CefBrowserHost::PrintToPDF().
///
/*--cef()--*/
virtual CefSize GetPdfPaperSize(int device_units_per_inch) {
virtual CefSize GetPdfPaperSize(CefRefPtr<CefBrowser> browser,
int device_units_per_inch) {
return CefSize();
}
};
......
......@@ -113,9 +113,12 @@ gfx::Size CefPrintDialogLinux::GetPdfPaperSize(
if (browser_handler.get()) {
CefRefPtr<CefPrintHandler> handler = browser_handler->GetPrintHandler();
if (handler.get()) {
CefRefPtr<CefBrowserHostImpl> browser =
extensions::GetOwnerBrowserForFrame(
context->render_process_id(), context->render_frame_id(), NULL);
const printing::PrintSettings& settings = context->settings();
CefSize cef_size =
handler->GetPdfPaperSize(settings.device_units_per_inch());
CefSize cef_size = handler->GetPdfPaperSize(
browser.get(), settings.device_units_per_inch());
size.SetSize(cef_size.width, cef_size.height);
}
}
......@@ -187,10 +190,14 @@ void CefPrintDialogLinux::ShowDialog(
callback_ = callback;
CefRefPtr<CefBrowserHostImpl> browser = extensions::GetOwnerBrowserForFrame(
context_->render_process_id(), context_->render_frame_id(), NULL);
CefRefPtr<CefPrintDialogCallbackImpl> callback_impl(
new CefPrintDialogCallbackImpl(this));
if (!handler_->OnPrintDialog(has_selection, callback_impl.get())) {
if (!handler_->OnPrintDialog(browser.get(), has_selection,
callback_impl.get())) {
callback_impl->Disconnect();
OnPrintCancel();
}
......@@ -253,7 +260,10 @@ void CefPrintDialogLinux::SetHandler() {
void CefPrintDialogLinux::ReleaseHandler() {
if (handler_.get()) {
handler_->OnPrintReset();
CefRefPtr<CefBrowserHostImpl> browser = extensions::GetOwnerBrowserForFrame(
context_->render_process_id(), context_->render_frame_id(), NULL);
handler_->OnPrintReset(browser.get());
handler_ = NULL;
}
}
......@@ -266,9 +276,12 @@ bool CefPrintDialogLinux::UpdateSettings(printing::PrintSettings* settings,
if (!handler_.get())
return false;
CefRefPtr<CefBrowserHostImpl> browser = extensions::GetOwnerBrowserForFrame(
context_->render_process_id(), context_->render_frame_id(), NULL);
CefRefPtr<CefPrintSettingsImpl> settings_impl(
new CefPrintSettingsImpl(settings, false, false));
handler_->OnPrintSettings(settings_impl.get(), get_defaults);
handler_->OnPrintSettings(browser.get(), settings_impl.get(), get_defaults);
settings_impl->Detach(NULL);
context_->InitWithSettings(*settings);
......@@ -284,10 +297,13 @@ void CefPrintDialogLinux::SendDocumentToPrinter(
return;
}
CefRefPtr<CefBrowserHostImpl> browser = extensions::GetOwnerBrowserForFrame(
context_->render_process_id(), context_->render_frame_id(), NULL);
CefRefPtr<CefPrintJobCallbackImpl> callback_impl(
new CefPrintJobCallbackImpl(this));
if (!handler_->OnPrintJob(document_name, path_to_pdf_.value(),
if (!handler_->OnPrintJob(browser.get(), document_name, path_to_pdf_.value(),
callback_impl.get())) {
callback_impl->Disconnect();
OnJobCompleted();
......
......@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=e2a9910119dcf81b74624588d222c7781e3fdc9a$
// $hash=80fc869800987a74f4c6e4eb202f0f5201126a76$
//
#include "libcef_dll/cpptoc/print_handler_cpptoc.h"
......@@ -42,6 +42,7 @@ print_handler_on_print_start(struct _cef_print_handler_t* self,
void CEF_CALLBACK
print_handler_on_print_settings(struct _cef_print_handler_t* self,
cef_browser_t* browser,
struct _cef_print_settings_t* settings,
int get_defaults) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
......@@ -49,6 +50,10 @@ print_handler_on_print_settings(struct _cef_print_handler_t* self,
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Verify param: settings; type: refptr_diff
DCHECK(settings);
if (!settings)
......@@ -56,11 +61,13 @@ print_handler_on_print_settings(struct _cef_print_handler_t* self,
// Execute
CefPrintHandlerCppToC::Get(self)->OnPrintSettings(
CefPrintSettingsCToCpp::Wrap(settings), get_defaults ? true : false);
CefBrowserCToCpp::Wrap(browser), CefPrintSettingsCToCpp::Wrap(settings),
get_defaults ? true : false);
}
int CEF_CALLBACK
print_handler_on_print_dialog(struct _cef_print_handler_t* self,
cef_browser_t* browser,
int has_selection,
cef_print_dialog_callback_t* callback) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
......@@ -68,6 +75,10 @@ print_handler_on_print_dialog(struct _cef_print_handler_t* self,
DCHECK(self);
if (!self)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: callback; type: refptr_diff
DCHECK(callback);
if (!callback)
......@@ -75,7 +86,7 @@ print_handler_on_print_dialog(struct _cef_print_handler_t* self,
// Execute
bool _retval = CefPrintHandlerCppToC::Get(self)->OnPrintDialog(
has_selection ? true : false,
CefBrowserCToCpp::Wrap(browser), has_selection ? true : false,
CefPrintDialogCallbackCToCpp::Wrap(callback));
// Return type: bool
......@@ -84,6 +95,7 @@ print_handler_on_print_dialog(struct _cef_print_handler_t* self,
int CEF_CALLBACK
print_handler_on_print_job(struct _cef_print_handler_t* self,
cef_browser_t* browser,
const cef_string_t* document_name,
const cef_string_t* pdf_file_path,
cef_print_job_callback_t* callback) {
......@@ -92,6 +104,10 @@ print_handler_on_print_job(struct _cef_print_handler_t* self,
DCHECK(self);
if (!self)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: document_name; type: string_byref_const
DCHECK(document_name);
if (!document_name)
......@@ -107,37 +123,48 @@ print_handler_on_print_job(struct _cef_print_handler_t* self,
// Execute
bool _retval = CefPrintHandlerCppToC::Get(self)->OnPrintJob(
CefString(document_name), CefString(pdf_file_path),
CefPrintJobCallbackCToCpp::Wrap(callback));
CefBrowserCToCpp::Wrap(browser), CefString(document_name),
CefString(pdf_file_path), CefPrintJobCallbackCToCpp::Wrap(callback));
// Return type: bool
return _retval;
}
void CEF_CALLBACK
print_handler_on_print_reset(struct _cef_print_handler_t* self) {
print_handler_on_print_reset(struct _cef_print_handler_t* self,
cef_browser_t* browser) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Execute
CefPrintHandlerCppToC::Get(self)->OnPrintReset();
CefPrintHandlerCppToC::Get(self)->OnPrintReset(
CefBrowserCToCpp::Wrap(browser));
}
cef_size_t CEF_CALLBACK
print_handler_get_pdf_paper_size(struct _cef_print_handler_t* self,
cef_browser_t* browser,
int device_units_per_inch) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return CefSize();
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return CefSize();
// Execute
cef_size_t _retval =
CefPrintHandlerCppToC::Get(self)->GetPdfPaperSize(device_units_per_inch);
cef_size_t _retval = CefPrintHandlerCppToC::Get(self)->GetPdfPaperSize(
CefBrowserCToCpp::Wrap(browser), device_units_per_inch);
// Return type: simple
return _retval;
......
......@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=0749b78aaf8f69cd706962477d4d0241c93cf333$
// $hash=80679bfc067e7564eadb691876081c4176b04c4f$
//
#include "libcef_dll/ctocpp/print_handler_ctocpp.h"
......@@ -37,6 +37,7 @@ void CefPrintHandlerCToCpp::OnPrintStart(CefRefPtr<CefBrowser> browser) {
}
void CefPrintHandlerCToCpp::OnPrintSettings(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefPrintSettings> settings,
bool get_defaults) {
cef_print_handler_t* _struct = GetStruct();
......@@ -45,17 +46,23 @@ void CefPrintHandlerCToCpp::OnPrintSettings(
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return;
// Verify param: settings; type: refptr_diff
DCHECK(settings.get());
if (!settings.get())
return;
// Execute
_struct->on_print_settings(_struct, CefPrintSettingsCppToC::Wrap(settings),
_struct->on_print_settings(_struct, CefBrowserCppToC::Wrap(browser),
CefPrintSettingsCppToC::Wrap(settings),
get_defaults);
}
bool CefPrintHandlerCToCpp::OnPrintDialog(
CefRefPtr<CefBrowser> browser,
bool has_selection,
CefRefPtr<CefPrintDialogCallback> callback) {
cef_print_handler_t* _struct = GetStruct();
......@@ -64,6 +71,10 @@ bool CefPrintHandlerCToCpp::OnPrintDialog(
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return false;
// Verify param: callback; type: refptr_diff
DCHECK(callback.get());
if (!callback.get())
......@@ -71,13 +82,15 @@ bool CefPrintHandlerCToCpp::OnPrintDialog(
// Execute
int _retval = _struct->on_print_dialog(
_struct, has_selection, CefPrintDialogCallbackCppToC::Wrap(callback));
_struct, CefBrowserCppToC::Wrap(browser), has_selection,
CefPrintDialogCallbackCppToC::Wrap(callback));
// Return type: bool
return _retval ? true : false;
}
bool CefPrintHandlerCToCpp::OnPrintJob(
CefRefPtr<CefBrowser> browser,
const CefString& document_name,
const CefString& pdf_file_path,
CefRefPtr<CefPrintJobCallback> callback) {
......@@ -87,6 +100,10 @@ bool CefPrintHandlerCToCpp::OnPrintJob(
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return false;
// Verify param: document_name; type: string_byref_const
DCHECK(!document_name.empty());
if (document_name.empty())
......@@ -102,34 +119,45 @@ bool CefPrintHandlerCToCpp::OnPrintJob(
// Execute
int _retval = _struct->on_print_job(
_struct, document_name.GetStruct(), pdf_file_path.GetStruct(),
CefPrintJobCallbackCppToC::Wrap(callback));
_struct, CefBrowserCppToC::Wrap(browser), document_name.GetStruct(),
pdf_file_path.GetStruct(), CefPrintJobCallbackCppToC::Wrap(callback));
// Return type: bool
return _retval ? true : false;
}
void CefPrintHandlerCToCpp::OnPrintReset() {
void CefPrintHandlerCToCpp::OnPrintReset(CefRefPtr<CefBrowser> browser) {
cef_print_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_print_reset))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return;
// Execute
_struct->on_print_reset(_struct);
_struct->on_print_reset(_struct, CefBrowserCppToC::Wrap(browser));
}
CefSize CefPrintHandlerCToCpp::GetPdfPaperSize(int device_units_per_inch) {
CefSize CefPrintHandlerCToCpp::GetPdfPaperSize(CefRefPtr<CefBrowser> browser,
int device_units_per_inch) {
cef_print_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_pdf_paper_size))
return CefSize();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return CefSize();
// Execute
cef_size_t _retval =
_struct->get_pdf_paper_size(_struct, device_units_per_inch);
cef_size_t _retval = _struct->get_pdf_paper_size(
_struct, CefBrowserCppToC::Wrap(browser), device_units_per_inch);
// Return type: simple
return _retval;
......
......@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=104e754c5019270e7bd700c6b979891f1275f9a7$
// $hash=1a2adb6e9cbbe96253cc997312e60ca330dc4de6$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_PRINT_HANDLER_CTOCPP_H_
......@@ -34,15 +34,19 @@ class CefPrintHandlerCToCpp : public CefCToCppRefCounted<CefPrintHandlerCToCpp,
// CefPrintHandler methods.
void OnPrintStart(CefRefPtr<CefBrowser> browser) override;
void OnPrintSettings(CefRefPtr<CefPrintSettings> settings,
void OnPrintSettings(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefPrintSettings> settings,
bool get_defaults) override;
bool OnPrintDialog(bool has_selection,
bool OnPrintDialog(CefRefPtr<CefBrowser> browser,
bool has_selection,
CefRefPtr<CefPrintDialogCallback> callback) override;
bool OnPrintJob(const CefString& document_name,
bool OnPrintJob(CefRefPtr<CefBrowser> browser,
const CefString& document_name,
const CefString& pdf_file_path,
CefRefPtr<CefPrintJobCallback> callback) override;
void OnPrintReset() override;
CefSize GetPdfPaperSize(int device_units_per_inch) override;
void OnPrintReset(CefRefPtr<CefBrowser> browser) override;
CefSize GetPdfPaperSize(CefRefPtr<CefBrowser> browser,
int device_units_per_inch) override;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_PRINT_HANDLER_CTOCPP_H_
......@@ -303,4 +303,9 @@ patches = [
# https://bugs.chromium.org/p/chromium/issues/detail?id=721461
'name': 'network_change_721461',
},
{
# Linux: Attach routing IDs to PrintingContext.
# https://bitbucket.org/chromiumembedded/cef/issues/2196
'name': 'printing_context_2196',
},
]
diff --git chrome/browser/printing/print_job_worker.cc chrome/browser/printing/print_job_worker.cc
index d06b61a..f41f848 100644
--- chrome/browser/printing/print_job_worker.cc
+++ chrome/browser/printing/print_job_worker.cc
@@ -121,6 +121,7 @@ PrintJobWorker::PrintJobWorker(int render_process_id,
printing_context_delegate_ = base::MakeUnique<PrintingContextDelegate>(
render_process_id, render_frame_id);
printing_context_ = PrintingContext::Create(printing_context_delegate_.get());
+ printing_context_->set_render_ids(render_process_id, render_frame_id);
}
PrintJobWorker::~PrintJobWorker() {
diff --git printing/printing_context.h printing/printing_context.h
index 7054654..ed5b664 100644
--- printing/printing_context.h
+++ printing/printing_context.h
@@ -127,6 +127,13 @@ class PRINTING_EXPORT PrintingContext {
int job_id() const { return job_id_; }
+ void set_render_ids(int render_process_id, int render_frame_id) {
+ render_process_id_ = render_process_id;
+ render_frame_id_ = render_frame_id;
+ }
+ int render_process_id() const { return render_process_id_; }
+ int render_frame_id() const { return render_frame_id_; }
+
protected:
explicit PrintingContext(Delegate* delegate);
@@ -151,6 +158,10 @@ class PRINTING_EXPORT PrintingContext {
// The job id for the current job. The value is 0 if no jobs are active.
int job_id_;
+ // Routing IDs for the frame that owns this object.
+ int render_process_id_ = 0;
+ int render_frame_id_ = 0;
+
private:
DISALLOW_COPY_AND_ASSIGN(PrintingContext);
};
......@@ -7,10 +7,15 @@
#include <vector>
#include <gtk/gtk.h>
#include <gtk/gtkunixprint.h>
#include "include/base/cef_logging.h"
#include "include/base/cef_macros.h"
#include "include/wrapper/cef_helpers.h"
#include "tests/cefclient/browser/root_window.h"
namespace client {
namespace {
......@@ -267,161 +272,328 @@ void InitPrintSettings(GtkPrintSettings* settings,
} // namespace
ClientPrintHandlerGtk::ClientPrintHandlerGtk()
: dialog_(NULL), gtk_settings_(NULL), page_setup_(NULL), printer_(NULL) {}
struct ClientPrintHandlerGtk::PrintHandler {
PrintHandler(CefRefPtr<CefBrowser> browser)
: browser_(browser),
dialog_(NULL),
gtk_settings_(NULL),
page_setup_(NULL),
printer_(NULL) {}
~PrintHandler() {
if (dialog_) {
gtk_widget_destroy(dialog_);
dialog_ = NULL;
}
if (gtk_settings_) {
g_object_unref(gtk_settings_);
gtk_settings_ = NULL;
}
if (page_setup_) {
g_object_unref(page_setup_);
page_setup_ = NULL;
}
if (printer_) {
g_object_unref(printer_);
printer_ = NULL;
}
}
void ClientPrintHandlerGtk::OnPrintStart(CefRefPtr<CefBrowser> browser) {}
void OnPrintSettings(CefRefPtr<CefPrintSettings> settings,
bool get_defaults) {
if (get_defaults) {
DCHECK(!page_setup_);
DCHECK(!printer_);
void ClientPrintHandlerGtk::OnPrintSettings(
CefRefPtr<CefPrintSettings> settings,
bool get_defaults) {
if (get_defaults) {
DCHECK(!page_setup_);
DCHECK(!printer_);
// |gtk_settings_| is a new copy.
gtk_settings_ = gtk_print_settings_copy(GetLastUsedSettings()->settings());
page_setup_ = gtk_page_setup_new();
} else {
if (!gtk_settings_) {
// |gtk_settings_| is a new copy.
gtk_settings_ =
gtk_print_settings_copy(GetLastUsedSettings()->settings());
}
page_setup_ = gtk_page_setup_new();
} else {
if (!gtk_settings_) {
gtk_settings_ =
gtk_print_settings_copy(GetLastUsedSettings()->settings());
}
GtkPrinterList* printer_list = new GtkPrinterList;
printer_ = printer_list->GetPrinterWithName(settings->GetDeviceName());
if (printer_) {
g_object_ref(printer_);
gtk_print_settings_set_printer(gtk_settings_,
gtk_printer_get_name(printer_));
if (!page_setup_) {
page_setup_ = gtk_printer_get_default_page_size(printer_);
GtkPrinterList* printer_list = new GtkPrinterList;
printer_ = printer_list->GetPrinterWithName(settings->GetDeviceName());
if (printer_) {
g_object_ref(printer_);
gtk_print_settings_set_printer(gtk_settings_,
gtk_printer_get_name(printer_));
if (!page_setup_) {
page_setup_ = gtk_printer_get_default_page_size(printer_);
}
}
gtk_print_settings_set_n_copies(gtk_settings_, settings->GetCopies());
gtk_print_settings_set_collate(gtk_settings_, settings->WillCollate());
std::string color_value;
std::string color_setting_name;
GetColorModelForMode(settings->GetColorModel(), &color_setting_name,
&color_value);
gtk_print_settings_set(gtk_settings_, color_setting_name.c_str(),
color_value.c_str());