Debian Codegraph @

gtk/src/printoperation.ccg

raw
1 /* Copyright (C) 2006 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include <gtk/gtk.h>
18
19 // This Signal Proxy allows the C++ coder to specify a sigc::slot instead of a static function.
20
21 static void
22 SignalProxy_PrintSetupDone_gtk_callback(GtkPageSetup* page_setup, gpointer data)
23 {
24 const auto the_slot = static_cast<Gtk::SlotPrintSetupDone*>(data);
25
26 try
27 {
28 auto ps = Glib::wrap(page_setup);
29 (*the_slot)(ps);
30 }
31 catch (...)
32 {
33 Glib::exception_handlers_invoke();
34 }
35
36 delete the_slot;
37 }
38
39 namespace Gtk
40 {
41
42 PrintOperationResult
43 PrintOperation::run(PrintOperationAction action)
44 {
45 GError* gerror = nullptr;
46 PrintOperationResult res =
47 (PrintOperationResult)gtk_print_operation_run(this->gobj(), (GtkPrintOperationAction)action, nullptr, &gerror);
48
49 if (res == PRINT_OPERATION_RESULT_ERROR)
50 {
51 gtk_print_operation_get_error(this->gobj(), &gerror);
52 ::Glib::Error::throw_exception(gerror);
53 }
54
55 return res;
56 }
57
58 Glib::RefPtr<PageSetup>
59 run_page_setup_dialog(Window& parent,
60 const Glib::RefPtr<const PageSetup>& page_setup,
61 const Glib::RefPtr<const PrintSettings>& print_settings)
62 {
63 // Specify the exact type with template specialization, to avoid possible
64 // ambiguities between the const and non-const versions of unwrap() reported
65 // by Sun's compiler (specifying unwrap<const Object> was reported
66 // not to work):
67 return Glib::wrap(
68 gtk_print_run_page_setup_dialog(
69 parent.gobj(),
70 const_cast<GtkPageSetup*>(Glib::unwrap<PageSetup>(page_setup)),
71 const_cast<GtkPrintSettings*>(Glib::unwrap<PrintSettings>(print_settings))));
72
73 }
74
75 Glib::RefPtr<PageSetup>
76 run_page_setup_dialog(Window& parent,
77 const Glib::RefPtr<const PrintSettings>& print_settings)
78 {
79 // Specify the exact type with template specialization, to avoid possible
80 // ambiguities between the const and non-const versions of unwrap() reported
81 // by Sun's compiler (specifying unwrap<const Object> was reported
82 // not to work):
83 return Glib::wrap(
84 gtk_print_run_page_setup_dialog(
85 parent.gobj(),
86 nullptr,
87 const_cast<GtkPrintSettings*>(Glib::unwrap<PrintSettings>(print_settings))));
88
89 }
90
91 void
92 run_page_setup_dialog_async(Window& parent,
93 const Glib::RefPtr<const PageSetup>& page_setup,
94 const Glib::RefPtr<const PrintSettings>& print_settings,
95 const SlotPrintSetupDone& slot)
96 {
97 auto slot_copy = new SlotPrintSetupDone(slot);
98
99 // Specify the exact type with template specialization, to avoid possible
100 // ambiguities between the const and non-const versions of unwrap() reported
101 // by Sun's compiler (specifying unwrap<const Object> was reported
102 // not to work):
103 gtk_print_run_page_setup_dialog_async(
104 parent.gobj(),
105 const_cast<GtkPageSetup*>(Glib::unwrap<PageSetup>(page_setup)),
106 const_cast<GtkPrintSettings*>(Glib::unwrap<PrintSettings>(print_settings)),
107 &SignalProxy_PrintSetupDone_gtk_callback,
108 slot_copy);
109 }
110
111 void
112 run_page_setup_dialog_async(Window& parent,
113 const Glib::RefPtr<const PrintSettings>& print_settings,
114 const SlotPrintSetupDone& slot)
115 {
116 auto slot_copy = new SlotPrintSetupDone(slot);
117
118 // Specify the exact type with template specialization, to avoid possible
119 // ambiguities between the const and non-const versions of unwrap() reported
120 // by Sun's compiler (specifying unwrap<const Object> was reported
121 // not to work):
122 gtk_print_run_page_setup_dialog_async(
123 parent.gobj(),
124 nullptr,
125 const_cast<GtkPrintSettings*>(Glib::unwrap<PrintSettings>(print_settings)),
126 &SignalProxy_PrintSetupDone_gtk_callback,
127 slot_copy);
128 }
129
130 } // namespace Gtk