2014-07-10 17:41:30 +02:00
|
|
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#ifndef CEF_TESTS_CEFCLIENT_BROWSER_PRINT_HANDLER_GTK_H_
|
|
|
|
#define CEF_TESTS_CEFCLIENT_BROWSER_PRINT_HANDLER_GTK_H_
|
2014-07-10 17:41:30 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gtk/gtkunixprint.h>
|
|
|
|
|
|
|
|
#include "include/cef_print_handler.h"
|
|
|
|
|
2015-01-23 20:23:54 +01:00
|
|
|
namespace client {
|
|
|
|
|
2014-07-10 17:41:30 +02:00
|
|
|
class ClientPrintHandlerGtk : public CefPrintHandler {
|
|
|
|
public:
|
|
|
|
ClientPrintHandlerGtk();
|
|
|
|
|
2015-01-23 21:03:47 +01:00
|
|
|
// CefPrintHandler methods.
|
|
|
|
void OnPrintSettings(CefRefPtr<CefPrintSettings> settings,
|
|
|
|
bool get_defaults) OVERRIDE;
|
|
|
|
bool OnPrintDialog(
|
2014-07-10 17:41:30 +02:00
|
|
|
bool has_selection,
|
|
|
|
CefRefPtr<CefPrintDialogCallback> callback) OVERRIDE;
|
2015-01-23 21:03:47 +01:00
|
|
|
bool OnPrintJob(const CefString& document_name,
|
|
|
|
const CefString& pdf_file_path,
|
|
|
|
CefRefPtr<CefPrintJobCallback> callback) OVERRIDE;
|
|
|
|
void OnPrintReset() OVERRIDE;
|
2014-07-10 17:41:30 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void OnDialogResponse(GtkDialog *dialog,
|
|
|
|
gint response_id);
|
|
|
|
void OnJobCompleted(GtkPrintJob* print_job,
|
|
|
|
GError* error);
|
|
|
|
|
|
|
|
static void OnDialogResponseThunk(GtkDialog *dialog,
|
|
|
|
gint response_id,
|
|
|
|
ClientPrintHandlerGtk* handler) {
|
|
|
|
handler->OnDialogResponse(dialog, response_id);
|
|
|
|
}
|
|
|
|
static void OnJobCompletedThunk(GtkPrintJob* print_job,
|
|
|
|
void* handler,
|
|
|
|
GError* error) {
|
|
|
|
static_cast<ClientPrintHandlerGtk*>(handler)->
|
|
|
|
OnJobCompleted(print_job, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print dialog settings. ClientPrintHandlerGtk owns |dialog_| and holds
|
|
|
|
// references to the other objects.
|
|
|
|
GtkWidget* dialog_;
|
|
|
|
GtkPrintSettings* gtk_settings_;
|
|
|
|
GtkPageSetup* page_setup_;
|
|
|
|
GtkPrinter* printer_;
|
|
|
|
|
|
|
|
CefRefPtr<CefPrintDialogCallback> dialog_callback_;
|
|
|
|
CefRefPtr<CefPrintJobCallback> job_callback_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(ClientPrintHandlerGtk);
|
2015-01-23 21:03:47 +01:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(ClientPrintHandlerGtk);
|
2014-07-10 17:41:30 +02:00
|
|
|
};
|
|
|
|
|
2015-01-23 20:23:54 +01:00
|
|
|
} // namespace client
|
2014-07-10 17:41:30 +02:00
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#endif // CEF_TESTS_CEFCLIENT_BROWSER_PRINT_HANDLER_GTK_H_
|