1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /** @file
3  * @brief Print dialog
4  */
5 /* Authors:
6  *   Kees Cook <kees@outflux.net>
7  *
8  * Copyright (C) 2007 Kees Cook
9  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
10  */
11 
12 #ifndef INKSCAPE_UI_DIALOG_PRINT_H
13 #define INKSCAPE_UI_DIALOG_PRINT_H
14 
15 #include "ui/widget/rendering-options.h"
16 #include <gtkmm/printoperation.h> // GtkMM
17 
18 class SPItem;
19 class SPDocument;
20 
21 
22 /*
23  * gtk 2.12.0 has a bug (http://bugzilla.gnome.org/show_bug.cgi?id=482089)
24  * where it fails to correctly deal with gtkmm signal management.  As a result
25  * we have call gtk directly instead of doing a much cleaner version of
26  * this printing dialog, using full gtkmmification.  (The bug was fixed
27  * in 2.12.1, so when the Inkscape gtk minimum version is bumped there,
28  * we can revert Inkscape commit 16865.
29  */
30 struct workaround_gtkmm
31 {
32     SPDocument *_doc;
33     SPItem     *_base;
34     Inkscape::UI::Widget::RenderingOptions *_tab;
35 };
36 
37 namespace Inkscape {
38 namespace UI {
39 namespace Dialog {
40 
41 struct PrinterSettings {
42     Glib::RefPtr<Gtk::PrintSettings> _gtk_print_settings;
43 };
44 
45 class Print {
46 public:
47     Print(SPDocument *doc, SPItem *base);
48     Gtk::PrintOperationResult run(Gtk::PrintOperationAction, Gtk::Window &parent_window);
49 
50 protected:
51 
52 private:
53     Glib::RefPtr<Gtk::PrintOperation> _printop;
54     SPDocument *_doc;
55     SPItem     *_base;
56     Inkscape::UI::Widget::RenderingOptions _tab;
57 
58     struct workaround_gtkmm _workaround;
59 
60     void draw_page(const Glib::RefPtr<Gtk::PrintContext>& context, int /*page_nr*/);
61     Gtk::Widget *create_custom_widget();
62     void begin_print(const Glib::RefPtr<Gtk::PrintContext>&);
63 };
64 
65 } // namespace Dialog
66 } // namespace UI
67 } // namespace Inkscape
68 
69 #endif // INKSCAPE_UI_DIALOG_PRINT_H
70 
71 /*
72   Local Variables:
73   mode:c++
74   c-file-style:"stroustrup"
75   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
76   indent-tabs-mode:nil
77   fill-column:99
78   End:
79 */
80 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
81