File: | ctk/ctkprintunixdialog.c |
Warning: | line 2365, column 18 Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* CtkPrintUnixDialog |
2 | * Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com> |
3 | * Copyright (C) 2006 Alexander Larsson <alexl@redhat.com> |
4 | * Copyright © 2006, 2007 Christian Persch |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Lesser General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2 of the License, or (at your option) any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Lesser General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Lesser General Public |
17 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
18 | */ |
19 | |
20 | #include "config.h" |
21 | |
22 | #include <stdlib.h> |
23 | #include <string.h> |
24 | #include <ctype.h> |
25 | #include <stdio.h> |
26 | #include <math.h> |
27 | |
28 | #include "ctkprintunixdialog.h" |
29 | |
30 | #include "ctkcustompaperunixdialog.h" |
31 | #include "ctkprintbackend.h" |
32 | #include "ctkprinter-private.h" |
33 | #include "ctkprinteroptionwidget.h" |
34 | #include "ctkprintutils.h" |
35 | |
36 | #include "ctkspinbutton.h" |
37 | #include "ctkcellrendererpixbuf.h" |
38 | #include "ctkcellrenderertext.h" |
39 | #include "ctkimage.h" |
40 | #include "ctktreeselection.h" |
41 | #include "ctknotebook.h" |
42 | #include "ctkscrolledwindow.h" |
43 | #include "ctkcombobox.h" |
44 | #include "ctktogglebutton.h" |
45 | #include "ctkradiobutton.h" |
46 | #include "ctkdrawingarea.h" |
47 | #include "ctkbox.h" |
48 | #include "ctkgrid.h" |
49 | #include "ctkframe.h" |
50 | #include "ctklabel.h" |
51 | #include "ctkeventbox.h" |
52 | #include "ctkbuildable.h" |
53 | #include "ctkmessagedialog.h" |
54 | #include "ctkbutton.h" |
55 | #include "ctkintl.h" |
56 | #include "ctkprivate.h" |
57 | #include "ctktypebuiltins.h" |
58 | #include "ctkdialogprivate.h" |
59 | #include "ctkstylecontextprivate.h" |
60 | #include "ctkwidgetprivate.h" |
61 | |
62 | |
63 | /** |
64 | * SECTION:ctkprintunixdialog |
65 | * @Short_description: A print dialog |
66 | * @Title: CtkPrintUnixDialog |
67 | * @Include: ctk/ctkunixprint.h |
68 | * @See_also: #CtkPageSetupUnixDialog, #CtkPrinter, #CtkPrintJob |
69 | * |
70 | * CtkPrintUnixDialog implements a print dialog for platforms |
71 | * which don’t provide a native print dialog, like Unix. It can |
72 | * be used very much like any other CTK+ dialog, at the cost of |
73 | * the portability offered by the |
74 | * [high-level printing API][ctk3-High-level-Printing-API] |
75 | * |
76 | * In order to print something with #CtkPrintUnixDialog, you need |
77 | * to use ctk_print_unix_dialog_get_selected_printer() to obtain |
78 | * a #CtkPrinter object and use it to construct a #CtkPrintJob using |
79 | * ctk_print_job_new(). |
80 | * |
81 | * #CtkPrintUnixDialog uses the following response values: |
82 | * - %CTK_RESPONSE_OK: for the “Print” button |
83 | * - %CTK_RESPONSE_APPLY: for the “Preview” button |
84 | * - %CTK_RESPONSE_CANCEL: for the “Cancel” button |
85 | * |
86 | * Printing support was added in CTK+ 2.10. |
87 | * |
88 | * # CtkPrintUnixDialog as CtkBuildable |
89 | * |
90 | * The CtkPrintUnixDialog implementation of the CtkBuildable interface exposes its |
91 | * @notebook internal children with the name “notebook”. |
92 | * |
93 | * An example of a #CtkPrintUnixDialog UI definition fragment: |
94 | * |[ |
95 | * <object class="CtkPrintUnixDialog" id="dialog1"> |
96 | * <child internal-child="notebook"> |
97 | * <object class="CtkNotebook" id="notebook"> |
98 | * <child> |
99 | * <object class="CtkLabel" id="tabcontent"> |
100 | * <property name="label">Content on notebook tab</property> |
101 | * </object> |
102 | * </child> |
103 | * <child type="tab"> |
104 | * <object class="CtkLabel" id="tablabel"> |
105 | * <property name="label">Tab label</property> |
106 | * </object> |
107 | * <packing> |
108 | * <property name="tab_expand">False</property> |
109 | * <property name="tab_fill">False</property> |
110 | * </packing> |
111 | * </child> |
112 | * </object> |
113 | * </child> |
114 | * </object> |
115 | * ]| |
116 | * |
117 | * # CSS nodes |
118 | * |
119 | * CtkPrintUnixDialog has a single CSS node with name printdialog. |
120 | */ |
121 | |
122 | |
123 | #define EXAMPLE_PAGE_AREA_SIZE110 110 |
124 | #define RULER_DISTANCE7.5 7.5 |
125 | #define RULER_RADIUS2 2 |
126 | |
127 | |
128 | static void ctk_print_unix_dialog_constructed (GObject *object); |
129 | static void ctk_print_unix_dialog_destroy (CtkWidget *widget); |
130 | static void ctk_print_unix_dialog_finalize (GObject *object); |
131 | static void ctk_print_unix_dialog_set_property (GObject *object, |
132 | guint prop_id, |
133 | const GValue *value, |
134 | GParamSpec *pspec); |
135 | static void ctk_print_unix_dialog_get_property (GObject *object, |
136 | guint prop_id, |
137 | GValue *value, |
138 | GParamSpec *pspec); |
139 | static void ctk_print_unix_dialog_style_updated (CtkWidget *widget); |
140 | static void unschedule_idle_mark_conflicts (CtkPrintUnixDialog *dialog); |
141 | static void selected_printer_changed (CtkTreeSelection *selection, |
142 | CtkPrintUnixDialog *dialog); |
143 | static void clear_per_printer_ui (CtkPrintUnixDialog *dialog); |
144 | static void printer_added_cb (CtkPrintBackend *backend, |
145 | CtkPrinter *printer, |
146 | CtkPrintUnixDialog *dialog); |
147 | static void printer_removed_cb (CtkPrintBackend *backend, |
148 | CtkPrinter *printer, |
149 | CtkPrintUnixDialog *dialog); |
150 | static void printer_status_cb (CtkPrintBackend *backend, |
151 | CtkPrinter *printer, |
152 | CtkPrintUnixDialog *dialog); |
153 | static void update_collate_icon (CtkToggleButton *toggle_button, |
154 | CtkPrintUnixDialog *dialog); |
155 | static gboolean error_dialogs (CtkPrintUnixDialog *print_dialog, |
156 | gint print_dialog_response_id, |
157 | gpointer data); |
158 | static void emit_ok_response (CtkTreeView *tree_view, |
159 | CtkTreePath *path, |
160 | CtkTreeViewColumn *column, |
161 | gpointer *user_data); |
162 | static void update_page_range_entry_sensitivity(CtkWidget *button, |
163 | CtkPrintUnixDialog *dialog); |
164 | static void update_print_at_entry_sensitivity (CtkWidget *button, |
165 | CtkPrintUnixDialog *dialog); |
166 | static void update_print_at_option (CtkPrintUnixDialog *dialog); |
167 | static void update_dialog_from_capabilities (CtkPrintUnixDialog *dialog); |
168 | static gboolean draw_collate_cb (CtkWidget *widget, |
169 | cairo_t *cr, |
170 | CtkPrintUnixDialog *dialog); |
171 | static gboolean is_printer_active (CtkTreeModel *model, |
172 | CtkTreeIter *iter, |
173 | CtkPrintUnixDialog *dialog); |
174 | static gint default_printer_list_sort_func (CtkTreeModel *model, |
175 | CtkTreeIter *a, |
176 | CtkTreeIter *b, |
177 | gpointer user_data); |
178 | static gboolean paper_size_row_is_separator (CtkTreeModel *model, |
179 | CtkTreeIter *iter, |
180 | gpointer data); |
181 | static void page_name_func (CtkCellLayout *cell_layout, |
182 | CtkCellRenderer *cell, |
183 | CtkTreeModel *tree_model, |
184 | CtkTreeIter *iter, |
185 | gpointer data); |
186 | static void update_number_up_layout (CtkPrintUnixDialog *dialog); |
187 | static gboolean draw_page_cb (CtkWidget *widget, |
188 | cairo_t *cr, |
189 | CtkPrintUnixDialog *dialog); |
190 | |
191 | |
192 | static gboolean dialog_get_collate (CtkPrintUnixDialog *dialog); |
193 | static gboolean dialog_get_reverse (CtkPrintUnixDialog *dialog); |
194 | static gint dialog_get_n_copies (CtkPrintUnixDialog *dialog); |
195 | |
196 | static void set_cell_sensitivity_func (CtkTreeViewColumn *tree_column, |
197 | CtkCellRenderer *cell, |
198 | CtkTreeModel *model, |
199 | CtkTreeIter *iter, |
200 | gpointer data); |
201 | static gboolean set_active_printer (CtkPrintUnixDialog *dialog, |
202 | const gchar *printer_name); |
203 | static void redraw_page_layout_preview (CtkPrintUnixDialog *dialog); |
204 | static void load_print_backends (CtkPrintUnixDialog *dialog); |
205 | static gboolean printer_compare (CtkTreeModel *model, |
206 | gint column, |
207 | const gchar *key, |
208 | CtkTreeIter *iter, |
209 | gpointer search_data); |
210 | |
211 | /* CtkBuildable */ |
212 | static void ctk_print_unix_dialog_buildable_init (CtkBuildableIface *iface); |
213 | static GObject *ctk_print_unix_dialog_buildable_get_internal_child (CtkBuildable *buildable, |
214 | CtkBuilder *builder, |
215 | const gchar *childname); |
216 | |
217 | static const gchar common_paper_sizes[][16] = { |
218 | "na_letter", |
219 | "na_legal", |
220 | "iso_a4", |
221 | "iso_a5", |
222 | "roc_16k", |
223 | "iso_b5", |
224 | "jis_b5", |
225 | "na_number-10", |
226 | "iso_dl", |
227 | "jpn_chou3", |
228 | "na_ledger", |
229 | "iso_a3", |
230 | }; |
231 | |
232 | /* Keep in line with liststore defined in ctkprintunixdialog.ui */ |
233 | enum { |
234 | PAGE_SETUP_LIST_COL_PAGE_SETUP, |
235 | PAGE_SETUP_LIST_COL_IS_SEPARATOR, |
236 | PAGE_SETUP_LIST_N_COLS |
237 | }; |
238 | |
239 | /* Keep in line with liststore defined in ctkprintunixdialog.ui */ |
240 | enum { |
241 | PRINTER_LIST_COL_ICON, |
242 | PRINTER_LIST_COL_NAME, |
243 | PRINTER_LIST_COL_STATE, |
244 | PRINTER_LIST_COL_JOBS, |
245 | PRINTER_LIST_COL_LOCATION, |
246 | PRINTER_LIST_COL_PRINTER_OBJ, |
247 | PRINTER_LIST_N_COLS |
248 | }; |
249 | |
250 | enum { |
251 | PROP_0, |
252 | PROP_PAGE_SETUP, |
253 | PROP_CURRENT_PAGE, |
254 | PROP_PRINT_SETTINGS, |
255 | PROP_SELECTED_PRINTER, |
256 | PROP_MANUAL_CAPABILITIES, |
257 | PROP_SUPPORT_SELECTION, |
258 | PROP_HAS_SELECTION, |
259 | PROP_EMBED_PAGE_SETUP |
260 | }; |
261 | |
262 | struct CtkPrintUnixDialogPrivate |
263 | { |
264 | CtkWidget *notebook; |
265 | |
266 | CtkWidget *printer_treeview; |
267 | CtkTreeViewColumn *printer_icon_column; |
268 | CtkTreeViewColumn *printer_name_column; |
269 | CtkTreeViewColumn *printer_location_column; |
270 | CtkTreeViewColumn *printer_status_column; |
271 | CtkCellRenderer *printer_icon_renderer; |
272 | CtkCellRenderer *printer_name_renderer; |
273 | CtkCellRenderer *printer_location_renderer; |
274 | CtkCellRenderer *printer_status_renderer; |
275 | |
276 | CtkPrintCapabilities manual_capabilities; |
277 | CtkPrintCapabilities printer_capabilities; |
278 | |
279 | CtkTreeModel *printer_list; |
280 | CtkTreeModelFilter *printer_list_filter; |
281 | |
282 | CtkPageSetup *page_setup; |
283 | gboolean page_setup_set; |
284 | gboolean embed_page_setup; |
285 | CtkListStore *page_setup_list; |
286 | CtkListStore *custom_paper_list; |
287 | |
288 | gboolean support_selection; |
289 | gboolean has_selection; |
290 | |
291 | CtkWidget *all_pages_radio; |
292 | CtkWidget *current_page_radio; |
293 | CtkWidget *selection_radio; |
294 | CtkWidget *range_table; |
295 | CtkWidget *page_range_radio; |
296 | CtkWidget *page_range_entry; |
297 | |
298 | CtkWidget *copies_spin; |
299 | CtkWidget *collate_check; |
300 | CtkWidget *reverse_check; |
301 | CtkWidget *collate_image; |
302 | CtkWidget *page_layout_preview; |
303 | CtkWidget *scale_spin; |
304 | CtkWidget *page_set_combo; |
305 | CtkWidget *print_now_radio; |
306 | CtkWidget *print_at_radio; |
307 | CtkWidget *print_at_entry; |
308 | CtkWidget *print_hold_radio; |
309 | CtkWidget *paper_size_combo; |
310 | CtkWidget *paper_size_combo_label; |
311 | CtkCellRenderer *paper_size_renderer; |
312 | CtkWidget *orientation_combo; |
313 | CtkWidget *orientation_combo_label; |
314 | gboolean internal_page_setup_change; |
315 | gboolean updating_print_at; |
316 | CtkPrinterOptionWidget *pages_per_sheet; |
317 | CtkPrinterOptionWidget *duplex; |
318 | CtkPrinterOptionWidget *paper_type; |
319 | CtkPrinterOptionWidget *paper_source; |
320 | CtkPrinterOptionWidget *output_tray; |
321 | CtkPrinterOptionWidget *job_prio; |
322 | CtkPrinterOptionWidget *billing_info; |
323 | CtkPrinterOptionWidget *cover_before; |
324 | CtkPrinterOptionWidget *cover_after; |
325 | CtkPrinterOptionWidget *number_up_layout; |
326 | |
327 | CtkWidget *conflicts_widget; |
328 | |
329 | CtkWidget *job_page; |
330 | CtkWidget *finishing_table; |
331 | CtkWidget *finishing_page; |
332 | CtkWidget *image_quality_table; |
333 | CtkWidget *image_quality_page; |
334 | CtkWidget *color_table; |
335 | CtkWidget *color_page; |
336 | |
337 | CtkWidget *advanced_vbox; |
338 | CtkWidget *advanced_page; |
339 | |
340 | CtkWidget *extension_point; |
341 | |
342 | /* These are set initially on selected printer (either default printer, |
343 | * printer taken from set settings, or user-selected), but when any |
344 | * setting is changed by the user it is cleared. |
345 | */ |
346 | CtkPrintSettings *initial_settings; |
347 | |
348 | CtkPrinterOption *number_up_layout_n_option; |
349 | CtkPrinterOption *number_up_layout_2_option; |
350 | |
351 | /* This is the initial printer set by set_settings. We look for it in |
352 | * the added printers. We clear this whenever the user manually changes |
353 | * to another printer, when the user changes a setting or when we find |
354 | * this printer. |
355 | */ |
356 | char *waiting_for_printer; |
357 | gboolean internal_printer_change; |
358 | |
359 | GList *print_backends; |
360 | |
361 | CtkPrinter *current_printer; |
362 | CtkPrinter *request_details_printer; |
363 | gulong request_details_tag; |
364 | CtkPrinterOptionSet *options; |
365 | gulong options_changed_handler; |
366 | gulong mark_conflicts_id; |
367 | |
368 | gchar *format_for_printer; |
369 | |
370 | gint current_page; |
371 | }; |
372 | |
373 | G_DEFINE_TYPE_WITH_CODE (CtkPrintUnixDialog, ctk_print_unix_dialog, CTK_TYPE_DIALOG,static void ctk_print_unix_dialog_init (CtkPrintUnixDialog *self ); static void ctk_print_unix_dialog_class_init (CtkPrintUnixDialogClass *klass); static GType ctk_print_unix_dialog_get_type_once (void ); static gpointer ctk_print_unix_dialog_parent_class = ((void *)0); static gint CtkPrintUnixDialog_private_offset; static void ctk_print_unix_dialog_class_intern_init (gpointer klass) { ctk_print_unix_dialog_parent_class = g_type_class_peek_parent (klass); if (CtkPrintUnixDialog_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkPrintUnixDialog_private_offset ); ctk_print_unix_dialog_class_init ((CtkPrintUnixDialogClass *) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_print_unix_dialog_get_instance_private (CtkPrintUnixDialog *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkPrintUnixDialog_private_offset )))); } GType ctk_print_unix_dialog_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); (void) (0 ? (gpointer) * ( &static_g_define_type_id) : ((void*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_print_unix_dialog_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_print_unix_dialog_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_dialog_get_type ()), g_intern_static_string ("CtkPrintUnixDialog" ), sizeof (CtkPrintUnixDialogClass), (GClassInitFunc)(void (* )(void)) ctk_print_unix_dialog_class_intern_init, sizeof (CtkPrintUnixDialog ), (GInstanceInitFunc)(void (*)(void)) ctk_print_unix_dialog_init , (GTypeFlags) 0); { {{ CtkPrintUnixDialog_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkPrintUnixDialogPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_print_unix_dialog_buildable_init, ((void *)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_buildable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } |
374 | G_ADD_PRIVATE (CtkPrintUnixDialog)static void ctk_print_unix_dialog_init (CtkPrintUnixDialog *self ); static void ctk_print_unix_dialog_class_init (CtkPrintUnixDialogClass *klass); static GType ctk_print_unix_dialog_get_type_once (void ); static gpointer ctk_print_unix_dialog_parent_class = ((void *)0); static gint CtkPrintUnixDialog_private_offset; static void ctk_print_unix_dialog_class_intern_init (gpointer klass) { ctk_print_unix_dialog_parent_class = g_type_class_peek_parent (klass); if (CtkPrintUnixDialog_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkPrintUnixDialog_private_offset ); ctk_print_unix_dialog_class_init ((CtkPrintUnixDialogClass *) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_print_unix_dialog_get_instance_private (CtkPrintUnixDialog *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkPrintUnixDialog_private_offset )))); } GType ctk_print_unix_dialog_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); (void) (0 ? (gpointer) * ( &static_g_define_type_id) : ((void*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_print_unix_dialog_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_print_unix_dialog_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_dialog_get_type ()), g_intern_static_string ("CtkPrintUnixDialog" ), sizeof (CtkPrintUnixDialogClass), (GClassInitFunc)(void (* )(void)) ctk_print_unix_dialog_class_intern_init, sizeof (CtkPrintUnixDialog ), (GInstanceInitFunc)(void (*)(void)) ctk_print_unix_dialog_init , (GTypeFlags) 0); { {{ CtkPrintUnixDialog_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkPrintUnixDialogPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_print_unix_dialog_buildable_init, ((void *)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_buildable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } |
375 | G_IMPLEMENT_INTERFACE (CTK_TYPE_BUILDABLE,static void ctk_print_unix_dialog_init (CtkPrintUnixDialog *self ); static void ctk_print_unix_dialog_class_init (CtkPrintUnixDialogClass *klass); static GType ctk_print_unix_dialog_get_type_once (void ); static gpointer ctk_print_unix_dialog_parent_class = ((void *)0); static gint CtkPrintUnixDialog_private_offset; static void ctk_print_unix_dialog_class_intern_init (gpointer klass) { ctk_print_unix_dialog_parent_class = g_type_class_peek_parent (klass); if (CtkPrintUnixDialog_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkPrintUnixDialog_private_offset ); ctk_print_unix_dialog_class_init ((CtkPrintUnixDialogClass *) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_print_unix_dialog_get_instance_private (CtkPrintUnixDialog *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkPrintUnixDialog_private_offset )))); } GType ctk_print_unix_dialog_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); (void) (0 ? (gpointer) * ( &static_g_define_type_id) : ((void*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_print_unix_dialog_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_print_unix_dialog_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_dialog_get_type ()), g_intern_static_string ("CtkPrintUnixDialog" ), sizeof (CtkPrintUnixDialogClass), (GClassInitFunc)(void (* )(void)) ctk_print_unix_dialog_class_intern_init, sizeof (CtkPrintUnixDialog ), (GInstanceInitFunc)(void (*)(void)) ctk_print_unix_dialog_init , (GTypeFlags) 0); { {{ CtkPrintUnixDialog_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkPrintUnixDialogPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_print_unix_dialog_buildable_init, ((void *)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_buildable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } |
376 | ctk_print_unix_dialog_buildable_init))static void ctk_print_unix_dialog_init (CtkPrintUnixDialog *self ); static void ctk_print_unix_dialog_class_init (CtkPrintUnixDialogClass *klass); static GType ctk_print_unix_dialog_get_type_once (void ); static gpointer ctk_print_unix_dialog_parent_class = ((void *)0); static gint CtkPrintUnixDialog_private_offset; static void ctk_print_unix_dialog_class_intern_init (gpointer klass) { ctk_print_unix_dialog_parent_class = g_type_class_peek_parent (klass); if (CtkPrintUnixDialog_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkPrintUnixDialog_private_offset ); ctk_print_unix_dialog_class_init ((CtkPrintUnixDialogClass *) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_print_unix_dialog_get_instance_private (CtkPrintUnixDialog *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkPrintUnixDialog_private_offset )))); } GType ctk_print_unix_dialog_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); (void) (0 ? (gpointer) * ( &static_g_define_type_id) : ((void*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_print_unix_dialog_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_print_unix_dialog_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_dialog_get_type ()), g_intern_static_string ("CtkPrintUnixDialog" ), sizeof (CtkPrintUnixDialogClass), (GClassInitFunc)(void (* )(void)) ctk_print_unix_dialog_class_intern_init, sizeof (CtkPrintUnixDialog ), (GInstanceInitFunc)(void (*)(void)) ctk_print_unix_dialog_init , (GTypeFlags) 0); { {{ CtkPrintUnixDialog_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkPrintUnixDialogPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_print_unix_dialog_buildable_init, ((void *)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_buildable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } |
377 | |
378 | static CtkBuildableIface *parent_buildable_iface; |
379 | |
380 | static gboolean |
381 | is_default_printer (CtkPrintUnixDialog *dialog, |
382 | CtkPrinter *printer) |
383 | { |
384 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
385 | |
386 | if (priv->format_for_printer) |
387 | return strcmp (priv->format_for_printer, |
388 | ctk_printer_get_name (printer)) == 0; |
389 | else |
390 | return ctk_printer_is_default (printer); |
391 | } |
392 | |
393 | static void |
394 | ctk_print_unix_dialog_class_init (CtkPrintUnixDialogClass *class) |
395 | { |
396 | GObjectClass *object_class; |
397 | CtkWidgetClass *widget_class; |
398 | |
399 | object_class = (GObjectClass *) class; |
400 | widget_class = (CtkWidgetClass *) class; |
401 | |
402 | object_class->constructed = ctk_print_unix_dialog_constructed; |
403 | object_class->finalize = ctk_print_unix_dialog_finalize; |
404 | object_class->set_property = ctk_print_unix_dialog_set_property; |
405 | object_class->get_property = ctk_print_unix_dialog_get_property; |
406 | |
407 | widget_class->style_updated = ctk_print_unix_dialog_style_updated; |
408 | widget_class->destroy = ctk_print_unix_dialog_destroy; |
409 | |
410 | g_object_class_install_property (object_class, |
411 | PROP_PAGE_SETUP, |
412 | g_param_spec_object ("page-setup", |
413 | P_("Page Setup")g_dgettext("ctk30" "-properties","Page Setup"), |
414 | P_("The CtkPageSetup to use")g_dgettext("ctk30" "-properties","The CtkPageSetup to use"), |
415 | CTK_TYPE_PAGE_SETUP(ctk_page_setup_get_type ()), |
416 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
417 | |
418 | g_object_class_install_property (object_class, |
419 | PROP_CURRENT_PAGE, |
420 | g_param_spec_int ("current-page", |
421 | P_("Current Page")g_dgettext("ctk30" "-properties","Current Page"), |
422 | P_("The current page in the document")g_dgettext("ctk30" "-properties","The current page in the document" ), |
423 | -1, |
424 | G_MAXINT2147483647, |
425 | -1, |
426 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
427 | |
428 | g_object_class_install_property (object_class, |
429 | PROP_PRINT_SETTINGS, |
430 | g_param_spec_object ("print-settings", |
431 | P_("Print Settings")g_dgettext("ctk30" "-properties","Print Settings"), |
432 | P_("The CtkPrintSettings used for initializing the dialog")g_dgettext("ctk30" "-properties","The CtkPrintSettings used for initializing the dialog" ), |
433 | CTK_TYPE_PRINT_SETTINGS(ctk_print_settings_get_type ()), |
434 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
435 | |
436 | g_object_class_install_property (object_class, |
437 | PROP_SELECTED_PRINTER, |
438 | g_param_spec_object ("selected-printer", |
439 | P_("Selected Printer")g_dgettext("ctk30" "-properties","Selected Printer"), |
440 | P_("The CtkPrinter which is selected")g_dgettext("ctk30" "-properties","The CtkPrinter which is selected" ), |
441 | CTK_TYPE_PRINTER(ctk_printer_get_type ()), |
442 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
443 | |
444 | g_object_class_install_property (object_class, |
445 | PROP_MANUAL_CAPABILITIES, |
446 | g_param_spec_flags ("manual-capabilities", |
447 | P_("Manual Capabilities")g_dgettext("ctk30" "-properties","Manual Capabilities"), |
448 | P_("Capabilities the application can handle")g_dgettext("ctk30" "-properties","Capabilities the application can handle" ), |
449 | CTK_TYPE_PRINT_CAPABILITIES(ctk_print_capabilities_get_type ()), |
450 | 0, |
451 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
452 | |
453 | g_object_class_install_property (object_class, |
454 | PROP_SUPPORT_SELECTION, |
455 | g_param_spec_boolean ("support-selection", |
456 | P_("Support Selection")g_dgettext("ctk30" "-properties","Support Selection"), |
457 | P_("Whether the dialog supports selection")g_dgettext("ctk30" "-properties","Whether the dialog supports selection" ), |
458 | FALSE(0), |
459 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
460 | |
461 | g_object_class_install_property (object_class, |
462 | PROP_HAS_SELECTION, |
463 | g_param_spec_boolean ("has-selection", |
464 | P_("Has Selection")g_dgettext("ctk30" "-properties","Has Selection"), |
465 | P_("Whether the application has a selection")g_dgettext("ctk30" "-properties","Whether the application has a selection" ), |
466 | FALSE(0), |
467 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
468 | |
469 | g_object_class_install_property (object_class, |
470 | PROP_EMBED_PAGE_SETUP, |
471 | g_param_spec_boolean ("embed-page-setup", |
472 | P_("Embed Page Setup")g_dgettext("ctk30" "-properties","Embed Page Setup"), |
473 | P_("TRUE if page setup combos are embedded in CtkPrintUnixDialog")g_dgettext("ctk30" "-properties","TRUE if page setup combos are embedded in CtkPrintUnixDialog" ), |
474 | FALSE(0), |
475 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
476 | |
477 | /* Bind class to template |
478 | */ |
479 | ctk_widget_class_set_template_from_resource (widget_class, |
480 | "/org/ctk/libctk/ui/ctkprintunixdialog.ui"); |
481 | |
482 | /* CtkTreeView / CtkTreeModel */ |
483 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, printer_treeview)ctk_widget_class_bind_template_child_full (widget_class, "printer_treeview" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, printer_treeview))))); |
484 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, printer_list)ctk_widget_class_bind_template_child_full (widget_class, "printer_list" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, printer_list))))); |
485 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, printer_list_filter)ctk_widget_class_bind_template_child_full (widget_class, "printer_list_filter" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, printer_list_filter))))); |
486 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, page_setup_list)ctk_widget_class_bind_template_child_full (widget_class, "page_setup_list" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, page_setup_list))))); |
487 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, custom_paper_list)ctk_widget_class_bind_template_child_full (widget_class, "custom_paper_list" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, custom_paper_list))))); |
488 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, printer_icon_column)ctk_widget_class_bind_template_child_full (widget_class, "printer_icon_column" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, printer_icon_column))))); |
489 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, printer_name_column)ctk_widget_class_bind_template_child_full (widget_class, "printer_name_column" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, printer_name_column))))); |
490 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, printer_location_column)ctk_widget_class_bind_template_child_full (widget_class, "printer_location_column" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, printer_location_column))))); |
491 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, printer_status_column)ctk_widget_class_bind_template_child_full (widget_class, "printer_status_column" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, printer_status_column))))); |
492 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, printer_icon_renderer)ctk_widget_class_bind_template_child_full (widget_class, "printer_icon_renderer" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, printer_icon_renderer))))); |
493 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, printer_name_renderer)ctk_widget_class_bind_template_child_full (widget_class, "printer_name_renderer" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, printer_name_renderer))))); |
494 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, printer_location_renderer)ctk_widget_class_bind_template_child_full (widget_class, "printer_location_renderer" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, printer_location_renderer))))); |
495 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, printer_status_renderer)ctk_widget_class_bind_template_child_full (widget_class, "printer_status_renderer" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, printer_status_renderer))))); |
496 | |
497 | /* General Widgetry */ |
498 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, notebook)ctk_widget_class_bind_template_child_full (widget_class, "notebook" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, notebook))))); |
499 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, all_pages_radio)ctk_widget_class_bind_template_child_full (widget_class, "all_pages_radio" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, all_pages_radio))))); |
500 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, all_pages_radio)ctk_widget_class_bind_template_child_full (widget_class, "all_pages_radio" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, all_pages_radio))))); |
501 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, current_page_radio)ctk_widget_class_bind_template_child_full (widget_class, "current_page_radio" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, current_page_radio))))); |
502 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, selection_radio)ctk_widget_class_bind_template_child_full (widget_class, "selection_radio" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, selection_radio))))); |
503 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, range_table)ctk_widget_class_bind_template_child_full (widget_class, "range_table" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, range_table))))); |
504 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, page_range_radio)ctk_widget_class_bind_template_child_full (widget_class, "page_range_radio" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, page_range_radio))))); |
505 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, page_range_entry)ctk_widget_class_bind_template_child_full (widget_class, "page_range_entry" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, page_range_entry))))); |
506 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, copies_spin)ctk_widget_class_bind_template_child_full (widget_class, "copies_spin" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, copies_spin))))); |
507 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, collate_check)ctk_widget_class_bind_template_child_full (widget_class, "collate_check" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, collate_check))))); |
508 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, reverse_check)ctk_widget_class_bind_template_child_full (widget_class, "reverse_check" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, reverse_check))))); |
509 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, collate_image)ctk_widget_class_bind_template_child_full (widget_class, "collate_image" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, collate_image))))); |
510 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, page_layout_preview)ctk_widget_class_bind_template_child_full (widget_class, "page_layout_preview" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, page_layout_preview))))); |
511 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, scale_spin)ctk_widget_class_bind_template_child_full (widget_class, "scale_spin" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, scale_spin))))); |
512 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, page_set_combo)ctk_widget_class_bind_template_child_full (widget_class, "page_set_combo" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, page_set_combo))))); |
513 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, print_now_radio)ctk_widget_class_bind_template_child_full (widget_class, "print_now_radio" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, print_now_radio))))); |
514 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, print_at_radio)ctk_widget_class_bind_template_child_full (widget_class, "print_at_radio" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, print_at_radio))))); |
515 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, print_at_entry)ctk_widget_class_bind_template_child_full (widget_class, "print_at_entry" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, print_at_entry))))); |
516 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, print_hold_radio)ctk_widget_class_bind_template_child_full (widget_class, "print_hold_radio" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, print_hold_radio))))); |
517 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, paper_size_combo)ctk_widget_class_bind_template_child_full (widget_class, "paper_size_combo" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, paper_size_combo))))); |
518 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, paper_size_combo_label)ctk_widget_class_bind_template_child_full (widget_class, "paper_size_combo_label" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, paper_size_combo_label))))); |
519 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, paper_size_renderer)ctk_widget_class_bind_template_child_full (widget_class, "paper_size_renderer" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, paper_size_renderer))))); |
520 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, orientation_combo)ctk_widget_class_bind_template_child_full (widget_class, "orientation_combo" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, orientation_combo))))); |
521 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, orientation_combo_label)ctk_widget_class_bind_template_child_full (widget_class, "orientation_combo_label" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, orientation_combo_label))))); |
522 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, conflicts_widget)ctk_widget_class_bind_template_child_full (widget_class, "conflicts_widget" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, conflicts_widget))))); |
523 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, job_page)ctk_widget_class_bind_template_child_full (widget_class, "job_page" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, job_page))))); |
524 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, finishing_table)ctk_widget_class_bind_template_child_full (widget_class, "finishing_table" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, finishing_table))))); |
525 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, finishing_page)ctk_widget_class_bind_template_child_full (widget_class, "finishing_page" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, finishing_page))))); |
526 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, image_quality_table)ctk_widget_class_bind_template_child_full (widget_class, "image_quality_table" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, image_quality_table))))); |
527 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, image_quality_page)ctk_widget_class_bind_template_child_full (widget_class, "image_quality_page" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, image_quality_page))))); |
528 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, color_table)ctk_widget_class_bind_template_child_full (widget_class, "color_table" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, color_table))))); |
529 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, color_page)ctk_widget_class_bind_template_child_full (widget_class, "color_page" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, color_page))))); |
530 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, advanced_vbox)ctk_widget_class_bind_template_child_full (widget_class, "advanced_vbox" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, advanced_vbox))))); |
531 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, advanced_page)ctk_widget_class_bind_template_child_full (widget_class, "advanced_page" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, advanced_page))))); |
532 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, extension_point)ctk_widget_class_bind_template_child_full (widget_class, "extension_point" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, extension_point))))); |
533 | |
534 | /* CtkPrinterOptionWidgets... */ |
535 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, pages_per_sheet)ctk_widget_class_bind_template_child_full (widget_class, "pages_per_sheet" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, pages_per_sheet))))); |
536 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, duplex)ctk_widget_class_bind_template_child_full (widget_class, "duplex" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, duplex))))); |
537 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, paper_type)ctk_widget_class_bind_template_child_full (widget_class, "paper_type" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, paper_type))))); |
538 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, paper_source)ctk_widget_class_bind_template_child_full (widget_class, "paper_source" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, paper_source))))); |
539 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, output_tray)ctk_widget_class_bind_template_child_full (widget_class, "output_tray" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, output_tray))))); |
540 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, job_prio)ctk_widget_class_bind_template_child_full (widget_class, "job_prio" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, job_prio))))); |
541 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, billing_info)ctk_widget_class_bind_template_child_full (widget_class, "billing_info" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, billing_info))))); |
542 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, cover_before)ctk_widget_class_bind_template_child_full (widget_class, "cover_before" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, cover_before))))); |
543 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, cover_after)ctk_widget_class_bind_template_child_full (widget_class, "cover_after" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, cover_after))))); |
544 | ctk_widget_class_bind_template_child_private (widget_class, CtkPrintUnixDialog, number_up_layout)ctk_widget_class_bind_template_child_full (widget_class, "number_up_layout" , (0), (CtkPrintUnixDialog_private_offset + (((glong) __builtin_offsetof (CtkPrintUnixDialogPrivate, number_up_layout))))); |
545 | |
546 | /* Callbacks handled in the UI */ |
547 | ctk_widget_class_bind_template_callback (widget_class, redraw_page_layout_preview)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "redraw_page_layout_preview" , ((GCallback) (redraw_page_layout_preview))); |
548 | ctk_widget_class_bind_template_callback (widget_class, error_dialogs)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "error_dialogs", ((GCallback ) (error_dialogs))); |
549 | ctk_widget_class_bind_template_callback (widget_class, emit_ok_response)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "emit_ok_response", ((GCallback ) (emit_ok_response))); |
550 | ctk_widget_class_bind_template_callback (widget_class, selected_printer_changed)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "selected_printer_changed" , ((GCallback) (selected_printer_changed))); |
551 | ctk_widget_class_bind_template_callback (widget_class, update_page_range_entry_sensitivity)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "update_page_range_entry_sensitivity" , ((GCallback) (update_page_range_entry_sensitivity))); |
552 | ctk_widget_class_bind_template_callback (widget_class, update_print_at_entry_sensitivity)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "update_print_at_entry_sensitivity" , ((GCallback) (update_print_at_entry_sensitivity))); |
553 | ctk_widget_class_bind_template_callback (widget_class, update_print_at_option)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "update_print_at_option", ((GCallback) (update_print_at_option))); |
554 | ctk_widget_class_bind_template_callback (widget_class, update_dialog_from_capabilities)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "update_dialog_from_capabilities" , ((GCallback) (update_dialog_from_capabilities))); |
555 | ctk_widget_class_bind_template_callback (widget_class, update_collate_icon)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "update_collate_icon", (( GCallback) (update_collate_icon))); |
556 | ctk_widget_class_bind_template_callback (widget_class, draw_collate_cb)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "draw_collate_cb", ((GCallback ) (draw_collate_cb))); |
557 | ctk_widget_class_bind_template_callback (widget_class, redraw_page_layout_preview)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "redraw_page_layout_preview" , ((GCallback) (redraw_page_layout_preview))); |
558 | ctk_widget_class_bind_template_callback (widget_class, update_number_up_layout)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "update_number_up_layout" , ((GCallback) (update_number_up_layout))); |
559 | ctk_widget_class_bind_template_callback (widget_class, redraw_page_layout_preview)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "redraw_page_layout_preview" , ((GCallback) (redraw_page_layout_preview))); |
560 | ctk_widget_class_bind_template_callback (widget_class, draw_page_cb)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "draw_page_cb", ((GCallback ) (draw_page_cb))); |
561 | |
562 | ctk_widget_class_set_css_name (widget_class, "printdialog"); |
563 | } |
564 | |
565 | /* Returns a toplevel CtkWindow, or NULL if none */ |
566 | static CtkWindow * |
567 | get_toplevel (CtkWidget *widget) |
568 | { |
569 | CtkWidget *toplevel = NULL((void*)0); |
570 | |
571 | toplevel = ctk_widget_get_toplevel (widget); |
572 | if (!ctk_widget_is_toplevel (toplevel)) |
573 | return NULL((void*)0); |
574 | else |
575 | return CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toplevel)), ((ctk_window_get_type ())))))); |
576 | } |
577 | |
578 | static void |
579 | set_busy_cursor (CtkPrintUnixDialog *dialog, |
580 | gboolean busy) |
581 | { |
582 | CtkWidget *widget; |
583 | CtkWindow *toplevel; |
584 | CdkDisplay *display; |
585 | CdkCursor *cursor; |
586 | |
587 | toplevel = get_toplevel (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); |
588 | widget = CTK_WIDGET (toplevel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toplevel)), ((ctk_widget_get_type ())))))); |
589 | |
590 | if (!toplevel || !ctk_widget_get_realized (widget)) |
591 | return; |
592 | |
593 | display = ctk_widget_get_display (widget); |
594 | |
595 | if (busy) |
596 | cursor = cdk_cursor_new_from_name (display, "progress"); |
597 | else |
598 | cursor = NULL((void*)0); |
599 | |
600 | cdk_window_set_cursor (ctk_widget_get_window (widget), cursor); |
601 | cdk_display_flush (display); |
602 | |
603 | if (cursor) |
604 | g_object_unref (cursor); |
605 | } |
606 | |
607 | /* This function handles error messages before printing. |
608 | */ |
609 | static gboolean |
610 | error_dialogs (CtkPrintUnixDialog *print_dialog, |
611 | gint print_dialog_response_id, |
612 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
613 | { |
614 | CtkPrintUnixDialogPrivate *priv = print_dialog->priv; |
615 | CtkPrinterOption *option = NULL((void*)0); |
616 | CtkPrinter *printer = NULL((void*)0); |
617 | CtkWindow *toplevel = NULL((void*)0); |
618 | CtkWidget *dialog = NULL((void*)0); |
619 | GFile *file = NULL((void*)0); |
620 | gchar *basename = NULL((void*)0); |
621 | gchar *dirname = NULL((void*)0); |
622 | int response; |
623 | |
624 | if (print_dialog != NULL((void*)0) && print_dialog_response_id == CTK_RESPONSE_OK) |
625 | { |
626 | printer = ctk_print_unix_dialog_get_selected_printer (print_dialog); |
627 | |
628 | if (printer != NULL((void*)0)) |
629 | { |
630 | if (priv->request_details_tag || !ctk_printer_is_accepting_jobs (printer)) |
631 | { |
632 | g_signal_stop_emission_by_name (print_dialog, "response"); |
633 | return TRUE(!(0)); |
634 | } |
635 | |
636 | /* Shows overwrite confirmation dialog in the case of printing |
637 | * to file which already exists. |
638 | */ |
639 | if (ctk_printer_is_virtual (printer)) |
640 | { |
641 | option = ctk_printer_option_set_lookup (priv->options, |
642 | "ctk-main-page-custom-input"); |
643 | |
644 | if (option != NULL((void*)0) && |
645 | option->type == CTK_PRINTER_OPTION_TYPE_FILESAVE) |
646 | { |
647 | file = g_file_new_for_uri (option->value); |
648 | |
649 | if (g_file_query_exists (file, NULL((void*)0))) |
650 | { |
651 | GFile *parent; |
652 | |
653 | toplevel = get_toplevel (CTK_WIDGET (print_dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((print_dialog)), ((ctk_widget_get_type ()))))))); |
654 | |
655 | basename = g_file_get_basename (file); |
656 | parent = g_file_get_parent (file); |
657 | dirname = g_file_get_parse_name (parent); |
658 | g_object_unref (parent); |
659 | |
660 | dialog = ctk_message_dialog_new (toplevel, |
661 | CTK_DIALOG_MODAL | |
662 | CTK_DIALOG_DESTROY_WITH_PARENT, |
663 | CTK_MESSAGE_QUESTION, |
664 | CTK_BUTTONS_NONE, |
665 | _("A file named “%s” already exists. Do you want to replace it?")((char *) g_dgettext ("ctk30", "A file named “%s” already exists. Do you want to replace it?" )), |
666 | basename); |
667 | |
668 | ctk_message_dialog_format_secondary_text (CTK_MESSAGE_DIALOG (dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((dialog)), ((ctk_message_dialog_get_type ()) ))))), |
669 | _("The file already exists in “%s”. Replacing it will "((char *) g_dgettext ("ctk30", "The file already exists in “%s”. Replacing it will " "overwrite its contents.")) |
670 | "overwrite its contents.")((char *) g_dgettext ("ctk30", "The file already exists in “%s”. Replacing it will " "overwrite its contents.")), |
671 | dirname); |
672 | |
673 | ctk_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
674 | _("_Cancel")((char *) g_dgettext ("ctk30", "_Cancel")), |
675 | CTK_RESPONSE_CANCEL); |
676 | ctk_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
677 | _("_Replace")((char *) g_dgettext ("ctk30", "_Replace")), |
678 | CTK_RESPONSE_ACCEPT); |
679 | G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push
clang diagnostic ignored "-Wdeprecated-declarations" |
680 | ctk_dialog_set_alternative_button_order (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
681 | CTK_RESPONSE_ACCEPT, |
682 | CTK_RESPONSE_CANCEL, |
683 | -1); |
684 | G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop |
685 | ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
686 | CTK_RESPONSE_ACCEPT); |
687 | |
688 | if (ctk_window_has_group (toplevel)) |
689 | ctk_window_group_add_window (ctk_window_get_group (toplevel), |
690 | CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ()))))))); |
691 | |
692 | response = ctk_dialog_run (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ()))))))); |
693 | |
694 | ctk_widget_destroy (dialog); |
695 | |
696 | g_free (dirname); |
697 | g_free (basename); |
698 | |
699 | if (response != CTK_RESPONSE_ACCEPT) |
700 | { |
701 | g_signal_stop_emission_by_name (print_dialog, "response"); |
702 | g_object_unref (file); |
703 | return TRUE(!(0)); |
704 | } |
705 | } |
706 | |
707 | g_object_unref (file); |
708 | } |
709 | } |
710 | } |
711 | } |
712 | return FALSE(0); |
713 | } |
714 | |
715 | static void |
716 | ctk_print_unix_dialog_init (CtkPrintUnixDialog *dialog) |
717 | { |
718 | CtkPrintUnixDialogPrivate *priv; |
719 | CtkTreeSortable *sort; |
720 | CtkWidget *widget; |
721 | |
722 | dialog->priv = ctk_print_unix_dialog_get_instance_private (dialog); |
723 | priv = dialog->priv; |
724 | |
725 | priv->print_backends = NULL((void*)0); |
726 | priv->current_page = -1; |
727 | priv->number_up_layout_n_option = NULL((void*)0); |
728 | priv->number_up_layout_2_option = NULL((void*)0); |
729 | |
730 | priv->page_setup = ctk_page_setup_new (); |
731 | priv->page_setup_set = FALSE(0); |
732 | priv->embed_page_setup = FALSE(0); |
733 | priv->internal_page_setup_change = FALSE(0); |
734 | |
735 | priv->support_selection = FALSE(0); |
736 | priv->has_selection = FALSE(0); |
737 | |
738 | g_type_ensure (CTK_TYPE_PRINTER(ctk_printer_get_type ())); |
739 | g_type_ensure (CTK_TYPE_PRINTER_OPTION(ctk_printer_option_get_type ())); |
740 | g_type_ensure (CTK_TYPE_PRINTER_OPTION_SET(ctk_printer_option_set_get_type ())); |
741 | g_type_ensure (CTK_TYPE_PRINTER_OPTION_WIDGET(ctk_printer_option_widget_get_type ())); |
742 | |
743 | ctk_widget_init_template (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); |
744 | ctk_dialog_set_use_header_bar_from_setting (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ()))))))); |
745 | ctk_dialog_add_buttons (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
746 | _("Pre_view")((char *) g_dgettext ("ctk30", "Pre_view")), CTK_RESPONSE_APPLY, |
747 | _("_Cancel")((char *) g_dgettext ("ctk30", "_Cancel")), CTK_RESPONSE_CANCEL, |
748 | _("_Print")((char *) g_dgettext ("ctk30", "_Print")), CTK_RESPONSE_OK, |
749 | NULL((void*)0)); |
750 | ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK); |
751 | widget = ctk_dialog_get_widget_for_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK); |
752 | ctk_widget_set_sensitive (widget, FALSE(0)); |
753 | |
754 | /* Treeview auxiliary functions need to be setup here */ |
755 | ctk_tree_model_filter_set_visible_func (priv->printer_list_filter, |
756 | (CtkTreeModelFilterVisibleFunc) is_printer_active, |
757 | dialog, |
758 | NULL((void*)0)); |
759 | |
760 | sort = CTK_TREE_SORTABLE (priv->printer_list)((((CtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_list)), ((ctk_tree_sortable_get_type () )))))); |
761 | ctk_tree_sortable_set_default_sort_func (sort, |
762 | default_printer_list_sort_func, |
763 | NULL((void*)0), |
764 | NULL((void*)0)); |
765 | |
766 | ctk_tree_sortable_set_sort_column_id (sort, |
767 | CTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID(-1), |
768 | CTK_SORT_ASCENDING); |
769 | |
770 | ctk_tree_view_set_search_equal_func (CTK_TREE_VIEW (priv->printer_treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_treeview)), ((ctk_tree_view_get_type () )))))), |
771 | printer_compare, NULL((void*)0), NULL((void*)0)); |
772 | |
773 | ctk_tree_view_column_set_cell_data_func (priv->printer_icon_column, |
774 | priv->printer_icon_renderer, |
775 | set_cell_sensitivity_func, NULL((void*)0), NULL((void*)0)); |
776 | |
777 | ctk_tree_view_column_set_cell_data_func (priv->printer_name_column, |
778 | priv->printer_name_renderer, |
779 | set_cell_sensitivity_func, NULL((void*)0), NULL((void*)0)); |
780 | |
781 | ctk_tree_view_column_set_cell_data_func (priv->printer_location_column, |
782 | priv->printer_location_renderer, |
783 | set_cell_sensitivity_func, NULL((void*)0), NULL((void*)0)); |
784 | |
785 | ctk_tree_view_column_set_cell_data_func (priv->printer_status_column, |
786 | priv->printer_status_renderer, |
787 | set_cell_sensitivity_func, NULL((void*)0), NULL((void*)0)); |
788 | |
789 | |
790 | /* Paper size combo auxilary funcs */ |
791 | ctk_combo_box_set_row_separator_func (CTK_COMBO_BOX (priv->paper_size_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->paper_size_combo)), ((ctk_combo_box_get_type () )))))), |
792 | paper_size_row_is_separator, NULL((void*)0), NULL((void*)0)); |
793 | ctk_cell_layout_set_cell_data_func (CTK_CELL_LAYOUT (priv->paper_size_combo)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->paper_size_combo)), ((ctk_cell_layout_get_type ( ))))))), |
794 | priv->paper_size_renderer, |
795 | page_name_func, NULL((void*)0), NULL((void*)0)); |
796 | |
797 | /* Preview drawing area has no window */ |
798 | ctk_widget_set_has_window (priv->page_layout_preview, FALSE(0)); |
799 | |
800 | /* Load backends */ |
801 | load_print_backends (dialog); |
802 | |
803 | /* Load custom papers */ |
804 | _ctk_print_load_custom_papers (priv->custom_paper_list); |
805 | |
806 | ctk_css_node_set_name (ctk_widget_get_css_node (priv->collate_image), I_("paper")g_intern_static_string ("paper")); |
807 | ctk_css_node_set_name (ctk_widget_get_css_node (priv->page_layout_preview), I_("paper")g_intern_static_string ("paper")); |
808 | } |
809 | |
810 | static void |
811 | ctk_print_unix_dialog_constructed (GObject *object) |
812 | { |
813 | gboolean use_header; |
814 | |
815 | G_OBJECT_CLASS (ctk_print_unix_dialog_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_print_unix_dialog_parent_class)), (((GType) ((20) << (2))))))))->constructed (object); |
816 | |
817 | g_object_get (object, "use-header-bar", &use_header, NULL((void*)0)); |
818 | if (use_header) |
819 | { |
820 | /* Reorder the preview button */ |
821 | CtkWidget *button, *parent; |
822 | button = ctk_dialog_get_widget_for_response (CTK_DIALOG (object)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_APPLY); |
823 | g_object_ref (button)((__typeof__ (button)) (g_object_ref) (button)); |
824 | parent = ctk_widget_get_parent (button); |
825 | ctk_container_remove (CTK_CONTAINER (parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_container_get_type ())))))), button); |
826 | ctk_header_bar_pack_end (CTK_HEADER_BAR (parent)((((CtkHeaderBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_header_bar_get_type ())))))), button); |
827 | g_object_unref (button); |
828 | } |
829 | |
830 | update_dialog_from_capabilities (CTK_PRINT_UNIX_DIALOG (object)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((object)), ((ctk_print_unix_dialog_get_type ()))))))); |
831 | } |
832 | |
833 | static void |
834 | ctk_print_unix_dialog_destroy (CtkWidget *widget) |
835 | { |
836 | CtkPrintUnixDialog *dialog = CTK_PRINT_UNIX_DIALOG (widget)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((widget)), ((ctk_print_unix_dialog_get_type ())))))); |
837 | |
838 | /* Make sure we don't destroy custom widgets owned by the backends */ |
839 | clear_per_printer_ui (dialog); |
840 | |
841 | CTK_WIDGET_CLASS (ctk_print_unix_dialog_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_print_unix_dialog_parent_class)), ((ctk_widget_get_type ()))))))->destroy (widget); |
842 | } |
843 | |
844 | static void |
845 | disconnect_printer_details_request (CtkPrintUnixDialog *dialog, |
846 | gboolean details_failed) |
847 | { |
848 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
849 | |
850 | if (priv->request_details_tag) |
851 | { |
852 | g_signal_handler_disconnect (priv->request_details_printer, |
853 | priv->request_details_tag); |
854 | priv->request_details_tag = 0; |
855 | set_busy_cursor (dialog, FALSE(0)); |
856 | if (details_failed) |
857 | ctk_list_store_set (CTK_LIST_STORE (priv->printer_list)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_list)), ((ctk_list_store_get_type ()))) ))), |
858 | g_object_get_data (G_OBJECT (priv->request_details_printer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->request_details_printer)), (((GType) ((20) << (2)))))))), |
859 | "ctk-print-tree-iter"), |
860 | PRINTER_LIST_COL_STATE, |
861 | _("Getting printer information failed")((char *) g_dgettext ("ctk30", "Getting printer information failed" )), |
862 | -1); |
863 | else |
864 | ctk_list_store_set (CTK_LIST_STORE (priv->printer_list)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_list)), ((ctk_list_store_get_type ()))) ))), |
865 | g_object_get_data (G_OBJECT (priv->request_details_printer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->request_details_printer)), (((GType) ((20) << (2)))))))), |
866 | "ctk-print-tree-iter"), |
867 | PRINTER_LIST_COL_STATE, |
868 | ctk_printer_get_state_message (priv->request_details_printer), |
869 | -1); |
870 | g_object_unref (priv->request_details_printer); |
871 | priv->request_details_printer = NULL((void*)0); |
872 | } |
873 | } |
874 | |
875 | static void |
876 | ctk_print_unix_dialog_finalize (GObject *object) |
877 | { |
878 | CtkPrintUnixDialog *dialog = CTK_PRINT_UNIX_DIALOG (object)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((object)), ((ctk_print_unix_dialog_get_type ())))))); |
879 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
880 | CtkPrintBackend *backend; |
881 | GList *node; |
882 | |
883 | unschedule_idle_mark_conflicts (dialog); |
884 | disconnect_printer_details_request (dialog, FALSE(0)); |
885 | |
886 | g_clear_object (&priv->current_printer)do { _Static_assert (sizeof *((&priv->current_printer) ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&priv->current_printer))) _pp = ((&priv->current_printer )); __typeof__ (*((&priv->current_printer))) _ptr = *_pp ; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
887 | g_clear_object (&priv->options)do { _Static_assert (sizeof *((&priv->options)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ ((( &priv->options))) _pp = ((&priv->options)); __typeof__ (*((&priv->options))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
888 | |
889 | if (priv->number_up_layout_2_option) |
890 | { |
891 | priv->number_up_layout_2_option->choices[0] = NULL((void*)0); |
892 | priv->number_up_layout_2_option->choices[1] = NULL((void*)0); |
893 | g_free (priv->number_up_layout_2_option->choices_display[0]); |
894 | g_free (priv->number_up_layout_2_option->choices_display[1]); |
895 | priv->number_up_layout_2_option->choices_display[0] = NULL((void*)0); |
896 | priv->number_up_layout_2_option->choices_display[1] = NULL((void*)0); |
897 | g_object_unref (priv->number_up_layout_2_option); |
898 | priv->number_up_layout_2_option = NULL((void*)0); |
899 | } |
900 | |
901 | g_clear_object (&priv->number_up_layout_n_option)do { _Static_assert (sizeof *((&priv->number_up_layout_n_option )) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&priv->number_up_layout_n_option))) _pp = ((&priv ->number_up_layout_n_option)); __typeof__ (*((&priv-> number_up_layout_n_option))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
902 | g_clear_object (&priv->page_setup)do { _Static_assert (sizeof *((&priv->page_setup)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ ((( &priv->page_setup))) _pp = ((&priv->page_setup) ); __typeof__ (*((&priv->page_setup))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
903 | g_clear_object (&priv->initial_settings)do { _Static_assert (sizeof *((&priv->initial_settings )) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&priv->initial_settings))) _pp = ((&priv->initial_settings )); __typeof__ (*((&priv->initial_settings))) _ptr = * _pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
904 | g_clear_pointer (&priv->waiting_for_printer, (GDestroyNotify)g_free)do { _Static_assert (sizeof *(&priv->waiting_for_printer ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ ((&priv->waiting_for_printer)) _pp = (&priv->waiting_for_printer ); __typeof__ (*(&priv->waiting_for_printer)) _ptr = * _pp; *_pp = ((void*)0); if (_ptr) ((GDestroyNotify)g_free) (_ptr ); } while (0); |
905 | g_clear_pointer (&priv->format_for_printer, (GDestroyNotify)g_free)do { _Static_assert (sizeof *(&priv->format_for_printer ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ ((&priv->format_for_printer)) _pp = (&priv->format_for_printer ); __typeof__ (*(&priv->format_for_printer)) _ptr = *_pp ; *_pp = ((void*)0); if (_ptr) ((GDestroyNotify)g_free) (_ptr ); } while (0); |
906 | |
907 | for (node = priv->print_backends; node != NULL((void*)0); node = node->next) |
908 | { |
909 | backend = CTK_PRINT_BACKEND (node->data)((((CtkPrintBackend*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((node->data)), ((ctk_print_backend_get_type ())))))); |
910 | |
911 | g_signal_handlers_disconnect_by_func (backend, printer_added_cb, dialog)g_signal_handlers_disconnect_matched ((backend), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (printer_added_cb), (dialog)); |
912 | g_signal_handlers_disconnect_by_func (backend, printer_removed_cb, dialog)g_signal_handlers_disconnect_matched ((backend), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (printer_removed_cb), (dialog)); |
913 | g_signal_handlers_disconnect_by_func (backend, printer_status_cb, dialog)g_signal_handlers_disconnect_matched ((backend), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (printer_status_cb), (dialog)); |
914 | |
915 | ctk_print_backend_destroy (backend); |
916 | g_object_unref (backend); |
917 | } |
918 | |
919 | g_list_free (priv->print_backends); |
920 | priv->print_backends = NULL((void*)0); |
921 | |
922 | g_clear_object (&priv->page_setup_list)do { _Static_assert (sizeof *((&priv->page_setup_list) ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&priv->page_setup_list))) _pp = ((&priv->page_setup_list )); __typeof__ (*((&priv->page_setup_list))) _ptr = *_pp ; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
923 | |
924 | G_OBJECT_CLASS (ctk_print_unix_dialog_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_print_unix_dialog_parent_class)), (((GType) ((20) << (2))))))))->finalize (object); |
925 | } |
926 | |
927 | static void |
928 | printer_removed_cb (CtkPrintBackend *backend G_GNUC_UNUSED__attribute__ ((__unused__)), |
929 | CtkPrinter *printer, |
930 | CtkPrintUnixDialog *dialog) |
931 | { |
932 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
933 | CtkTreeIter *iter; |
934 | |
935 | iter = g_object_get_data (G_OBJECT (printer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((printer)), (((GType) ((20) << (2)))))))), "ctk-print-tree-iter"); |
936 | ctk_list_store_remove (CTK_LIST_STORE (priv->printer_list)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_list)), ((ctk_list_store_get_type ()))) ))), iter); |
937 | } |
938 | |
939 | static void |
940 | ctk_print_unix_dialog_buildable_init (CtkBuildableIface *iface) |
941 | { |
942 | parent_buildable_iface = g_type_interface_peek_parent (iface); |
943 | |
944 | iface->get_internal_child = ctk_print_unix_dialog_buildable_get_internal_child; |
945 | } |
946 | |
947 | static GObject * |
948 | ctk_print_unix_dialog_buildable_get_internal_child (CtkBuildable *buildable, |
949 | CtkBuilder *builder, |
950 | const gchar *childname) |
951 | { |
952 | if (strcmp (childname, "notebook") == 0) |
953 | return G_OBJECT (CTK_PRINT_UNIX_DIALOG (buildable)->priv->notebook)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((buildable)), ((ctk_print_unix_dialog_get_type ()))))))->priv->notebook)), (((GType) ((20) << ( 2)))))))); |
954 | |
955 | return parent_buildable_iface->get_internal_child (buildable, builder, childname); |
956 | } |
957 | |
958 | /* This function controls "sensitive" property of CtkCellRenderer |
959 | * based on pause state of printers. |
960 | */ |
961 | void set_cell_sensitivity_func (CtkTreeViewColumn *tree_column G_GNUC_UNUSED__attribute__ ((__unused__)), |
962 | CtkCellRenderer *cell, |
963 | CtkTreeModel *tree_model, |
964 | CtkTreeIter *iter, |
965 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
966 | { |
967 | CtkPrinter *printer; |
968 | |
969 | ctk_tree_model_get (tree_model, iter, |
970 | PRINTER_LIST_COL_PRINTER_OBJ, &printer, |
971 | -1); |
972 | |
973 | if (printer != NULL((void*)0) && !ctk_printer_is_accepting_jobs (printer)) |
974 | g_object_set (cell, "sensitive", FALSE(0), NULL((void*)0)); |
975 | else |
976 | g_object_set (cell, "sensitive", TRUE(!(0)), NULL((void*)0)); |
977 | |
978 | g_clear_object (&printer)do { _Static_assert (sizeof *((&printer)) == sizeof (gpointer ), "Expression evaluates to false"); __typeof__ (((&printer ))) _pp = ((&printer)); __typeof__ (*((&printer))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr) ; } while (0); |
979 | } |
980 | |
981 | static void |
982 | printer_status_cb (CtkPrintBackend *backend, |
983 | CtkPrinter *printer, |
984 | CtkPrintUnixDialog *dialog) |
985 | { |
986 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
987 | CtkTreeIter *iter; |
988 | CtkTreeSelection *selection; |
989 | GIcon *icon; |
990 | |
991 | iter = g_object_get_data (G_OBJECT (printer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((printer)), (((GType) ((20) << (2)))))))), "ctk-print-tree-iter"); |
992 | |
993 | icon = g_themed_icon_new ("printer"); |
994 | g_themed_icon_prepend_name (G_THEMED_ICON (icon)((((GThemedIcon*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon)), ((g_themed_icon_get_type ())))))), ctk_printer_get_icon_name (printer)); |
995 | ctk_list_store_set (CTK_LIST_STORE (priv->printer_list)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_list)), ((ctk_list_store_get_type ()))) ))), iter, |
996 | PRINTER_LIST_COL_ICON, icon, |
997 | PRINTER_LIST_COL_STATE, ctk_printer_get_state_message (printer), |
998 | PRINTER_LIST_COL_JOBS, ctk_printer_get_job_count (printer), |
999 | PRINTER_LIST_COL_LOCATION, ctk_printer_get_location (printer), |
1000 | -1); |
1001 | g_object_unref (icon); |
1002 | |
1003 | /* When the pause state change then we need to update sensitive property |
1004 | * of CTK_RESPONSE_OK button inside of selected_printer_changed function. |
1005 | */ |
1006 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (priv->printer_treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_treeview)), ((ctk_tree_view_get_type () ))))))); |
1007 | priv->internal_printer_change = TRUE(!(0)); |
1008 | selected_printer_changed (selection, dialog); |
1009 | priv->internal_printer_change = FALSE(0); |
1010 | |
1011 | if (ctk_print_backend_printer_list_is_done (backend) && |
1012 | ctk_printer_is_default (printer) && |
1013 | (ctk_tree_selection_count_selected_rows (selection) == 0)) |
1014 | set_active_printer (dialog, ctk_printer_get_name (printer)); |
1015 | } |
1016 | |
1017 | static void |
1018 | printer_added_cb (CtkPrintBackend *backend G_GNUC_UNUSED__attribute__ ((__unused__)), |
1019 | CtkPrinter *printer, |
1020 | CtkPrintUnixDialog *dialog) |
1021 | { |
1022 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1023 | CtkTreeIter iter, filter_iter; |
1024 | CtkTreeSelection *selection; |
1025 | CtkTreePath *path; |
1026 | GIcon *icon; |
1027 | |
1028 | ctk_list_store_append (CTK_LIST_STORE (priv->printer_list)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_list)), ((ctk_list_store_get_type ()))) ))), &iter); |
1029 | |
1030 | g_object_set_data_full (G_OBJECT (printer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((printer)), (((GType) ((20) << (2)))))))), |
1031 | "ctk-print-tree-iter", |
1032 | ctk_tree_iter_copy (&iter), |
1033 | (GDestroyNotify) ctk_tree_iter_free); |
1034 | |
1035 | icon = g_themed_icon_new ("printer"); |
1036 | g_themed_icon_prepend_name (G_THEMED_ICON (icon)((((GThemedIcon*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon)), ((g_themed_icon_get_type ())))))), ctk_printer_get_icon_name (printer)); |
1037 | ctk_list_store_set (CTK_LIST_STORE (priv->printer_list)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_list)), ((ctk_list_store_get_type ()))) ))), &iter, |
1038 | PRINTER_LIST_COL_ICON, icon, |
1039 | PRINTER_LIST_COL_NAME, ctk_printer_get_name (printer), |
1040 | PRINTER_LIST_COL_STATE, ctk_printer_get_state_message (printer), |
1041 | PRINTER_LIST_COL_JOBS, ctk_printer_get_job_count (printer), |
1042 | PRINTER_LIST_COL_LOCATION, ctk_printer_get_location (printer), |
1043 | PRINTER_LIST_COL_PRINTER_OBJ, printer, |
1044 | -1); |
1045 | g_object_unref (icon); |
1046 | |
1047 | ctk_tree_model_filter_convert_child_iter_to_iter (priv->printer_list_filter, |
1048 | &filter_iter, &iter); |
1049 | path = ctk_tree_model_get_path (CTK_TREE_MODEL (priv->printer_list_filter)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_list_filter)), ((ctk_tree_model_get_type ())))))), &filter_iter); |
1050 | |
1051 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (priv->printer_treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_treeview)), ((ctk_tree_view_get_type () ))))))); |
1052 | |
1053 | if (priv->waiting_for_printer != NULL((void*)0) && |
1054 | strcmp (ctk_printer_get_name (printer), priv->waiting_for_printer) == 0) |
1055 | { |
1056 | priv->internal_printer_change = TRUE(!(0)); |
1057 | ctk_tree_selection_select_iter (selection, &filter_iter); |
1058 | ctk_tree_view_scroll_to_cell (CTK_TREE_VIEW (priv->printer_treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_treeview)), ((ctk_tree_view_get_type () )))))), |
1059 | path, NULL((void*)0), TRUE(!(0)), 0.5, 0.0); |
1060 | priv->internal_printer_change = FALSE(0); |
1061 | g_free (priv->waiting_for_printer); |
1062 | priv->waiting_for_printer = NULL((void*)0); |
1063 | } |
1064 | else if (is_default_printer (dialog, printer) && |
1065 | ctk_tree_selection_count_selected_rows (selection) == 0) |
1066 | { |
1067 | priv->internal_printer_change = TRUE(!(0)); |
1068 | ctk_tree_selection_select_iter (selection, &filter_iter); |
1069 | ctk_tree_view_scroll_to_cell (CTK_TREE_VIEW (priv->printer_treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_treeview)), ((ctk_tree_view_get_type () )))))), |
1070 | path, NULL((void*)0), TRUE(!(0)), 0.5, 0.0); |
1071 | priv->internal_printer_change = FALSE(0); |
1072 | } |
1073 | |
1074 | ctk_tree_path_free (path); |
1075 | } |
1076 | |
1077 | static void |
1078 | printer_list_initialize (CtkPrintUnixDialog *dialog, |
1079 | CtkPrintBackend *print_backend) |
1080 | { |
1081 | GList *list; |
1082 | GList *node; |
1083 | |
1084 | g_return_if_fail (print_backend != NULL)do { if ((print_backend != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "print_backend != NULL") ; return; } } while (0); |
1085 | |
1086 | g_signal_connect_object (print_backend, "printer-added", |
1087 | (GCallback) printer_added_cb, G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), 0); |
1088 | |
1089 | g_signal_connect_object (print_backend, "printer-removed", |
1090 | (GCallback) printer_removed_cb, G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), 0); |
1091 | |
1092 | g_signal_connect_object (print_backend, "printer-status-changed", |
1093 | (GCallback) printer_status_cb, G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), 0); |
1094 | |
1095 | list = ctk_print_backend_get_printer_list (print_backend); |
1096 | |
1097 | node = list; |
1098 | while (node != NULL((void*)0)) |
1099 | { |
1100 | printer_added_cb (print_backend, node->data, dialog); |
1101 | node = node->next; |
1102 | } |
1103 | |
1104 | g_list_free (list); |
1105 | } |
1106 | |
1107 | static void |
1108 | load_print_backends (CtkPrintUnixDialog *dialog) |
1109 | { |
1110 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1111 | GList *node; |
1112 | |
1113 | if (g_module_supported ()) |
1114 | priv->print_backends = ctk_print_backend_load_modules (); |
1115 | |
1116 | for (node = priv->print_backends; node != NULL((void*)0); node = node->next) |
1117 | { |
1118 | CtkPrintBackend *backend = node->data; |
1119 | printer_list_initialize (dialog, backend); |
1120 | } |
1121 | } |
1122 | |
1123 | static void |
1124 | ctk_print_unix_dialog_set_property (GObject *object, |
1125 | guint prop_id, |
1126 | const GValue *value, |
1127 | GParamSpec *pspec) |
1128 | |
1129 | { |
1130 | CtkPrintUnixDialog *dialog = CTK_PRINT_UNIX_DIALOG (object)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((object)), ((ctk_print_unix_dialog_get_type ())))))); |
1131 | |
1132 | switch (prop_id) |
1133 | { |
1134 | case PROP_PAGE_SETUP: |
1135 | ctk_print_unix_dialog_set_page_setup (dialog, g_value_get_object (value)); |
1136 | break; |
1137 | case PROP_CURRENT_PAGE: |
1138 | ctk_print_unix_dialog_set_current_page (dialog, g_value_get_int (value)); |
1139 | break; |
1140 | case PROP_PRINT_SETTINGS: |
1141 | ctk_print_unix_dialog_set_settings (dialog, g_value_get_object (value)); |
1142 | break; |
1143 | case PROP_MANUAL_CAPABILITIES: |
1144 | ctk_print_unix_dialog_set_manual_capabilities (dialog, g_value_get_flags (value)); |
1145 | break; |
1146 | case PROP_SUPPORT_SELECTION: |
1147 | ctk_print_unix_dialog_set_support_selection (dialog, g_value_get_boolean (value)); |
1148 | break; |
1149 | case PROP_HAS_SELECTION: |
1150 | ctk_print_unix_dialog_set_has_selection (dialog, g_value_get_boolean (value)); |
1151 | break; |
1152 | case PROP_EMBED_PAGE_SETUP: |
1153 | ctk_print_unix_dialog_set_embed_page_setup (dialog, g_value_get_boolean (value)); |
1154 | break; |
1155 | default: |
1156 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctkprintunixdialog.c", 1156, ("property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
1157 | break; |
1158 | } |
1159 | } |
1160 | |
1161 | static void |
1162 | ctk_print_unix_dialog_get_property (GObject *object, |
1163 | guint prop_id, |
1164 | GValue *value, |
1165 | GParamSpec *pspec) |
1166 | { |
1167 | CtkPrintUnixDialog *dialog = CTK_PRINT_UNIX_DIALOG (object)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((object)), ((ctk_print_unix_dialog_get_type ())))))); |
1168 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1169 | |
1170 | switch (prop_id) |
1171 | { |
1172 | case PROP_PAGE_SETUP: |
1173 | g_value_set_object (value, priv->page_setup); |
1174 | break; |
1175 | case PROP_CURRENT_PAGE: |
1176 | g_value_set_int (value, priv->current_page); |
1177 | break; |
1178 | case PROP_PRINT_SETTINGS: |
1179 | g_value_take_object (value, ctk_print_unix_dialog_get_settings (dialog)); |
1180 | break; |
1181 | case PROP_SELECTED_PRINTER: |
1182 | g_value_set_object (value, priv->current_printer); |
1183 | break; |
1184 | case PROP_MANUAL_CAPABILITIES: |
1185 | g_value_set_flags (value, priv->manual_capabilities); |
1186 | break; |
1187 | case PROP_SUPPORT_SELECTION: |
1188 | g_value_set_boolean (value, priv->support_selection); |
1189 | break; |
1190 | case PROP_HAS_SELECTION: |
1191 | g_value_set_boolean (value, priv->has_selection); |
1192 | break; |
1193 | case PROP_EMBED_PAGE_SETUP: |
1194 | g_value_set_boolean (value, priv->embed_page_setup); |
1195 | break; |
1196 | default: |
1197 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctkprintunixdialog.c", 1197, ("property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
1198 | break; |
1199 | } |
1200 | } |
1201 | |
1202 | static gboolean |
1203 | is_printer_active (CtkTreeModel *model, |
1204 | CtkTreeIter *iter, |
1205 | CtkPrintUnixDialog *dialog) |
1206 | { |
1207 | gboolean result; |
1208 | CtkPrinter *printer; |
1209 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1210 | |
1211 | ctk_tree_model_get (model, iter, |
1212 | PRINTER_LIST_COL_PRINTER_OBJ, &printer, |
1213 | -1); |
1214 | |
1215 | if (printer == NULL((void*)0)) |
1216 | return FALSE(0); |
1217 | |
1218 | result = ctk_printer_is_active (printer); |
1219 | |
1220 | if (result && |
1221 | priv->manual_capabilities & (CTK_PRINT_CAPABILITY_GENERATE_PDF | |
1222 | CTK_PRINT_CAPABILITY_GENERATE_PS)) |
1223 | { |
1224 | /* Check that the printer can handle at least one of the data |
1225 | * formats that the application supports. |
1226 | */ |
1227 | result = ((priv->manual_capabilities & CTK_PRINT_CAPABILITY_GENERATE_PDF) && |
1228 | ctk_printer_accepts_pdf (printer)) || |
1229 | ((priv->manual_capabilities & CTK_PRINT_CAPABILITY_GENERATE_PS) && |
1230 | ctk_printer_accepts_ps (printer)); |
1231 | } |
1232 | |
1233 | g_object_unref (printer); |
1234 | |
1235 | return result; |
1236 | } |
1237 | |
1238 | static gint |
1239 | default_printer_list_sort_func (CtkTreeModel *model, |
1240 | CtkTreeIter *a, |
1241 | CtkTreeIter *b, |
1242 | gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
1243 | { |
1244 | gchar *a_name; |
1245 | gchar *b_name; |
1246 | CtkPrinter *a_printer; |
1247 | CtkPrinter *b_printer; |
1248 | gint result; |
1249 | |
1250 | ctk_tree_model_get (model, a, |
1251 | PRINTER_LIST_COL_NAME, &a_name, |
1252 | PRINTER_LIST_COL_PRINTER_OBJ, &a_printer, |
1253 | -1); |
1254 | ctk_tree_model_get (model, b, |
1255 | PRINTER_LIST_COL_NAME, &b_name, |
1256 | PRINTER_LIST_COL_PRINTER_OBJ, &b_printer, |
1257 | -1); |
1258 | |
1259 | if (a_printer == NULL((void*)0) && b_printer == NULL((void*)0)) |
1260 | result = 0; |
1261 | else if (a_printer == NULL((void*)0)) |
1262 | result = G_MAXINT2147483647; |
1263 | else if (b_printer == NULL((void*)0)) |
1264 | result = G_MININT(-2147483647 -1); |
1265 | else if (ctk_printer_is_virtual (a_printer) && ctk_printer_is_virtual (b_printer)) |
1266 | result = 0; |
1267 | else if (ctk_printer_is_virtual (a_printer) && !ctk_printer_is_virtual (b_printer)) |
1268 | result = G_MININT(-2147483647 -1); |
1269 | else if (!ctk_printer_is_virtual (a_printer) && ctk_printer_is_virtual (b_printer)) |
1270 | result = G_MAXINT2147483647; |
1271 | else if (a_name == NULL((void*)0) && b_name == NULL((void*)0)) |
1272 | result = 0; |
1273 | else if (a_name == NULL((void*)0) && b_name != NULL((void*)0)) |
1274 | result = 1; |
1275 | else if (a_name != NULL((void*)0) && b_name == NULL((void*)0)) |
1276 | result = -1; |
1277 | else |
1278 | result = g_ascii_strcasecmp (a_name, b_name); |
1279 | |
1280 | g_free (a_name); |
1281 | g_free (b_name); |
1282 | if (a_printer) |
1283 | g_object_unref (a_printer); |
1284 | if (b_printer) |
1285 | g_object_unref (b_printer); |
1286 | |
1287 | return result; |
1288 | } |
1289 | |
1290 | static CtkWidget * |
1291 | wrap_in_frame (const gchar *label, |
1292 | CtkWidget *child) |
1293 | { |
1294 | CtkWidget *frame, *label_widget; |
1295 | gchar *bold_text; |
1296 | |
1297 | label_widget = ctk_label_new (NULL((void*)0)); |
1298 | ctk_widget_set_halign (label_widget, CTK_ALIGN_START); |
1299 | ctk_widget_set_valign (label_widget, CTK_ALIGN_CENTER); |
1300 | ctk_widget_show (label_widget); |
1301 | |
1302 | bold_text = g_markup_printf_escaped ("<b>%s</b>", label); |
1303 | ctk_label_set_markup (CTK_LABEL (label_widget)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label_widget)), ((ctk_label_get_type ())))))), bold_text); |
1304 | g_free (bold_text); |
1305 | |
1306 | frame = ctk_box_new (CTK_ORIENTATION_VERTICAL, 6); |
1307 | ctk_box_pack_start (CTK_BOX (frame)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((frame)), ((ctk_box_get_type ())))))), label_widget, FALSE(0), FALSE(0), 0); |
1308 | |
1309 | ctk_widget_set_margin_start (child, 12); |
1310 | ctk_widget_set_halign (child, CTK_ALIGN_FILL); |
1311 | ctk_widget_set_valign (child, CTK_ALIGN_FILL); |
1312 | |
1313 | ctk_box_pack_start (CTK_BOX (frame)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((frame)), ((ctk_box_get_type ())))))), child, FALSE(0), FALSE(0), 0); |
1314 | |
1315 | ctk_widget_show (frame); |
1316 | |
1317 | return frame; |
1318 | } |
1319 | |
1320 | static gboolean |
1321 | setup_option (CtkPrintUnixDialog *dialog, |
1322 | const gchar *option_name, |
1323 | CtkPrinterOptionWidget *widget) |
1324 | { |
1325 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1326 | CtkPrinterOption *option; |
1327 | |
1328 | option = ctk_printer_option_set_lookup (priv->options, option_name); |
1329 | ctk_printer_option_widget_set_source (widget, option); |
1330 | |
1331 | return option != NULL((void*)0); |
1332 | } |
1333 | |
1334 | static void |
1335 | add_option_to_extension_point (CtkPrinterOption *option, |
1336 | gpointer data) |
1337 | { |
1338 | CtkWidget *extension_point = data; |
1339 | CtkWidget *widget; |
1340 | |
1341 | widget = ctk_printer_option_widget_new (option); |
1342 | ctk_widget_show (widget); |
1343 | |
1344 | if (ctk_printer_option_widget_has_external_label (CTK_PRINTER_OPTION_WIDGET (widget)((((CtkPrinterOptionWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((widget)), ((ctk_printer_option_widget_get_type ())))))))) |
1345 | { |
1346 | CtkWidget *label, *hbox; |
1347 | |
1348 | ctk_widget_set_valign (widget, CTK_ALIGN_BASELINE); |
1349 | |
1350 | label = ctk_printer_option_widget_get_external_label (CTK_PRINTER_OPTION_WIDGET (widget)((((CtkPrinterOptionWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((widget)), ((ctk_printer_option_widget_get_type ()))))))); |
1351 | ctk_widget_show (label); |
1352 | ctk_widget_set_halign (label, CTK_ALIGN_START); |
1353 | ctk_widget_set_valign (label, CTK_ALIGN_BASELINE); |
1354 | ctk_label_set_mnemonic_widget (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), widget); |
1355 | |
1356 | hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 12); |
1357 | ctk_widget_set_valign (hbox, CTK_ALIGN_BASELINE); |
1358 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), label, FALSE(0), FALSE(0), 0); |
1359 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), widget, FALSE(0), FALSE(0), 0); |
1360 | ctk_widget_show (hbox); |
1361 | |
1362 | ctk_box_pack_start (CTK_BOX (extension_point)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((extension_point)), ((ctk_box_get_type ())))))), hbox, TRUE(!(0)), TRUE(!(0)), 0); |
1363 | } |
1364 | else |
1365 | ctk_box_pack_start (CTK_BOX (extension_point)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((extension_point)), ((ctk_box_get_type ())))))), widget, TRUE(!(0)), TRUE(!(0)), 0); |
1366 | } |
1367 | |
1368 | static gint |
1369 | grid_rows (CtkGrid *table) |
1370 | { |
1371 | gint t0, t1, t, h; |
1372 | GList *children, *c; |
1373 | |
1374 | children = ctk_container_get_children (CTK_CONTAINER (table)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_container_get_type ()))))))); |
1375 | t0 = t1 = 0; |
1376 | for (c = children; c; c = c->next) |
1377 | { |
1378 | ctk_container_child_get (CTK_CONTAINER (table)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_container_get_type ())))))), c->data, |
1379 | "top-attach", &t, |
1380 | "height", &h, |
1381 | NULL((void*)0)); |
1382 | if (c == children) |
1383 | { |
1384 | t0 = t; |
1385 | t1 = t + h; |
1386 | } |
1387 | else |
1388 | { |
1389 | if (t < t0) |
1390 | t0 = t; |
1391 | if (t + h > t1) |
1392 | t1 = t + h; |
1393 | } |
1394 | } |
1395 | g_list_free (children); |
1396 | |
1397 | return t1 - t0; |
1398 | } |
1399 | |
1400 | static void |
1401 | add_option_to_table (CtkPrinterOption *option, |
1402 | gpointer user_data) |
1403 | { |
1404 | CtkGrid *table; |
1405 | CtkWidget *label, *widget; |
1406 | guint row; |
1407 | |
1408 | table = CTK_GRID (user_data)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), ((ctk_grid_get_type ())))))); |
1409 | |
1410 | if (g_str_has_prefix (option->name, "ctk-")(__builtin_constant_p ("ctk-")? __extension__ ({ const char * const __str = (option->name); const char * const __prefix = ("ctk-"); gboolean __result = (0); if (__str == ((void*)0) || __prefix == ((void*)0)) __result = (g_str_has_prefix) (__str , __prefix); else { const size_t __str_len = strlen (((__str) + !(__str))); const size_t __prefix_len = strlen (((__prefix ) + !(__prefix))); if (__str_len >= __prefix_len) __result = memcmp (((__str) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len ) == 0; } __result; }) : (g_str_has_prefix) (option->name, "ctk-") )) |
1411 | return; |
1412 | |
1413 | row = grid_rows (table); |
1414 | |
1415 | widget = ctk_printer_option_widget_new (option); |
1416 | ctk_widget_show (widget); |
1417 | |
1418 | if (ctk_printer_option_widget_has_external_label (CTK_PRINTER_OPTION_WIDGET (widget)((((CtkPrinterOptionWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((widget)), ((ctk_printer_option_widget_get_type ())))))))) |
1419 | { |
1420 | label = ctk_printer_option_widget_get_external_label (CTK_PRINTER_OPTION_WIDGET (widget)((((CtkPrinterOptionWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((widget)), ((ctk_printer_option_widget_get_type ()))))))); |
1421 | ctk_widget_show (label); |
1422 | |
1423 | ctk_widget_set_halign (label, CTK_ALIGN_START); |
1424 | ctk_widget_set_valign (label, CTK_ALIGN_CENTER); |
1425 | ctk_label_set_mnemonic_widget (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), widget); |
1426 | |
1427 | ctk_grid_attach (table, label, 0, row - 1, 1, 1); |
1428 | ctk_grid_attach (table, widget, 1, row - 1, 1, 1); |
1429 | } |
1430 | else |
1431 | ctk_grid_attach (table, widget, 0, row - 1, 2, 1); |
1432 | } |
1433 | |
1434 | static void |
1435 | setup_page_table (CtkPrinterOptionSet *options, |
1436 | const gchar *group, |
1437 | CtkWidget *table, |
1438 | CtkWidget *page) |
1439 | { |
1440 | gint nrows; |
1441 | |
1442 | ctk_printer_option_set_foreach_in_group (options, group, |
1443 | add_option_to_table, |
1444 | table); |
1445 | |
1446 | nrows = grid_rows (CTK_GRID (table)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_grid_get_type ()))))))); |
1447 | if (nrows == 0) |
1448 | ctk_widget_hide (page); |
1449 | else |
1450 | ctk_widget_show (page); |
1451 | } |
1452 | |
1453 | static void |
1454 | update_print_at_option (CtkPrintUnixDialog *dialog) |
1455 | { |
1456 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1457 | CtkPrinterOption *option; |
1458 | |
1459 | option = ctk_printer_option_set_lookup (priv->options, "ctk-print-time"); |
1460 | |
1461 | if (option == NULL((void*)0)) |
1462 | return; |
1463 | |
1464 | if (priv->updating_print_at) |
1465 | return; |
1466 | |
1467 | if (ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (priv->print_at_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->print_at_radio)), ((ctk_toggle_button_get_type ( ))))))))) |
1468 | ctk_printer_option_set (option, "at"); |
1469 | else if (ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (priv->print_hold_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->print_hold_radio)), ((ctk_toggle_button_get_type ())))))))) |
1470 | ctk_printer_option_set (option, "on-hold"); |
1471 | else |
1472 | ctk_printer_option_set (option, "now"); |
1473 | |
1474 | option = ctk_printer_option_set_lookup (priv->options, "ctk-print-time-text"); |
1475 | if (option != NULL((void*)0)) |
1476 | { |
1477 | const gchar *text; |
1478 | |
1479 | text = ctk_entry_get_text (CTK_ENTRY (priv->print_at_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->print_at_entry)), ((ctk_entry_get_type ()))))))); |
1480 | ctk_printer_option_set (option, text); |
1481 | } |
1482 | } |
1483 | |
1484 | |
1485 | static gboolean |
1486 | setup_print_at (CtkPrintUnixDialog *dialog) |
1487 | { |
1488 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1489 | CtkPrinterOption *option; |
1490 | |
1491 | option = ctk_printer_option_set_lookup (priv->options, "ctk-print-time"); |
1492 | |
1493 | if (option == NULL((void*)0)) |
1494 | { |
1495 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (priv->print_now_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->print_now_radio)), ((ctk_toggle_button_get_type ())))))), |
1496 | TRUE(!(0))); |
1497 | ctk_widget_set_sensitive (priv->print_at_radio, FALSE(0)); |
1498 | ctk_widget_set_sensitive (priv->print_at_entry, FALSE(0)); |
1499 | ctk_widget_set_sensitive (priv->print_hold_radio, FALSE(0)); |
1500 | ctk_entry_set_text (CTK_ENTRY (priv->print_at_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->print_at_entry)), ((ctk_entry_get_type ())))))), ""); |
1501 | return FALSE(0); |
1502 | } |
1503 | |
1504 | priv->updating_print_at = TRUE(!(0)); |
1505 | |
1506 | ctk_widget_set_sensitive (priv->print_at_entry, FALSE(0)); |
1507 | ctk_widget_set_sensitive (priv->print_at_radio, |
1508 | ctk_printer_option_has_choice (option, "at")); |
1509 | |
1510 | ctk_widget_set_sensitive (priv->print_hold_radio, |
1511 | ctk_printer_option_has_choice (option, "on-hold")); |
1512 | |
1513 | update_print_at_option (dialog); |
1514 | |
1515 | if (strcmp (option->value, "at") == 0) |
1516 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (priv->print_at_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->print_at_radio)), ((ctk_toggle_button_get_type ( ))))))), |
1517 | TRUE(!(0))); |
1518 | else if (strcmp (option->value, "on-hold") == 0) |
1519 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (priv->print_hold_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->print_hold_radio)), ((ctk_toggle_button_get_type ())))))), |
1520 | TRUE(!(0))); |
1521 | else |
1522 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (priv->print_now_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->print_now_radio)), ((ctk_toggle_button_get_type ())))))), |
1523 | TRUE(!(0))); |
1524 | |
1525 | option = ctk_printer_option_set_lookup (priv->options, "ctk-print-time-text"); |
1526 | if (option != NULL((void*)0)) |
1527 | ctk_entry_set_text (CTK_ENTRY (priv->print_at_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->print_at_entry)), ((ctk_entry_get_type ())))))), option->value); |
1528 | |
1529 | priv->updating_print_at = FALSE(0); |
1530 | |
1531 | return TRUE(!(0)); |
1532 | } |
1533 | |
1534 | static void |
1535 | update_dialog_from_settings (CtkPrintUnixDialog *dialog) |
1536 | { |
1537 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1538 | GList *groups, *l; |
1539 | gchar *group; |
1540 | CtkWidget *table, *frame; |
1541 | gboolean has_advanced, has_job; |
1542 | guint nrows; |
1543 | GList *children; |
1544 | |
1545 | if (priv->current_printer == NULL((void*)0)) |
1546 | { |
1547 | clear_per_printer_ui (dialog); |
1548 | ctk_widget_hide (priv->job_page); |
1549 | ctk_widget_hide (priv->advanced_page); |
1550 | ctk_widget_hide (priv->image_quality_page); |
1551 | ctk_widget_hide (priv->finishing_page); |
1552 | ctk_widget_hide (priv->color_page); |
1553 | ctk_dialog_set_response_sensitive (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK, FALSE(0)); |
1554 | |
1555 | return; |
1556 | } |
1557 | |
1558 | setup_option (dialog, "ctk-n-up", priv->pages_per_sheet); |
1559 | setup_option (dialog, "ctk-n-up-layout", priv->number_up_layout); |
1560 | setup_option (dialog, "ctk-duplex", priv->duplex); |
1561 | setup_option (dialog, "ctk-paper-type", priv->paper_type); |
1562 | setup_option (dialog, "ctk-paper-source", priv->paper_source); |
1563 | setup_option (dialog, "ctk-output-tray", priv->output_tray); |
1564 | |
1565 | has_job = FALSE(0); |
1566 | has_job |= setup_option (dialog, "ctk-job-prio", priv->job_prio); |
1567 | has_job |= setup_option (dialog, "ctk-billing-info", priv->billing_info); |
1568 | has_job |= setup_option (dialog, "ctk-cover-before", priv->cover_before); |
1569 | has_job |= setup_option (dialog, "ctk-cover-after", priv->cover_after); |
1570 | has_job |= setup_print_at (dialog); |
1571 | |
1572 | if (has_job) |
1573 | ctk_widget_show (priv->job_page); |
1574 | else |
1575 | ctk_widget_hide (priv->job_page); |
1576 | |
1577 | setup_page_table (priv->options, |
1578 | "ImageQualityPage", |
1579 | priv->image_quality_table, |
1580 | priv->image_quality_page); |
1581 | |
1582 | setup_page_table (priv->options, |
1583 | "FinishingPage", |
1584 | priv->finishing_table, |
1585 | priv->finishing_page); |
1586 | |
1587 | setup_page_table (priv->options, |
1588 | "ColorPage", |
1589 | priv->color_table, |
1590 | priv->color_page); |
1591 | |
1592 | ctk_printer_option_set_foreach_in_group (priv->options, |
1593 | "CtkPrintDialogExtension", |
1594 | add_option_to_extension_point, |
1595 | priv->extension_point); |
1596 | |
1597 | /* A bit of a hack, keep the last option flush right. |
1598 | * This keeps the file format radios from moving as the |
1599 | * filename changes. |
1600 | */ |
1601 | children = ctk_container_get_children (CTK_CONTAINER (priv->extension_point)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->extension_point)), ((ctk_container_get_type ()) )))))); |
1602 | l = g_list_last (children); |
1603 | if (l && l != children) |
1604 | ctk_widget_set_halign (CTK_WIDGET (l->data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), ((ctk_widget_get_type ())))))), CTK_ALIGN_END); |
1605 | g_list_free (children); |
1606 | |
1607 | /* Put the rest of the groups in the advanced page */ |
1608 | groups = ctk_printer_option_set_get_groups (priv->options); |
1609 | |
1610 | has_advanced = FALSE(0); |
1611 | for (l = groups; l != NULL((void*)0); l = l->next) |
1612 | { |
1613 | group = l->data; |
1614 | |
1615 | if (group == NULL((void*)0)) |
1616 | continue; |
1617 | |
1618 | if (strcmp (group, "ImageQualityPage") == 0 || |
1619 | strcmp (group, "ColorPage") == 0 || |
1620 | strcmp (group, "FinishingPage") == 0 || |
1621 | strcmp (group, "CtkPrintDialogExtension") == 0) |
1622 | continue; |
1623 | |
1624 | table = ctk_grid_new (); |
1625 | ctk_grid_set_row_spacing (CTK_GRID (table)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_grid_get_type ())))))), 6); |
1626 | ctk_grid_set_column_spacing (CTK_GRID (table)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_grid_get_type ())))))), 12); |
1627 | |
1628 | ctk_printer_option_set_foreach_in_group (priv->options, |
1629 | group, |
1630 | add_option_to_table, |
1631 | table); |
1632 | |
1633 | nrows = grid_rows (CTK_GRID (table)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_grid_get_type ()))))))); |
1634 | if (nrows == 0) |
1635 | ctk_widget_destroy (table); |
1636 | else |
1637 | { |
1638 | has_advanced = TRUE(!(0)); |
1639 | frame = wrap_in_frame (group, table); |
1640 | ctk_widget_show (table); |
1641 | ctk_widget_show (frame); |
1642 | |
1643 | ctk_box_pack_start (CTK_BOX (priv->advanced_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->advanced_vbox)), ((ctk_box_get_type ())))))), |
1644 | frame, FALSE(0), FALSE(0), 0); |
1645 | } |
1646 | } |
1647 | |
1648 | if (has_advanced) |
1649 | ctk_widget_show (priv->advanced_page); |
1650 | else |
1651 | ctk_widget_hide (priv->advanced_page); |
1652 | |
1653 | g_list_free_full (groups, g_free); |
1654 | } |
1655 | |
1656 | static void |
1657 | update_dialog_from_capabilities (CtkPrintUnixDialog *dialog) |
1658 | { |
1659 | CtkPrintCapabilities caps; |
1660 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1661 | gboolean can_collate; |
1662 | const gchar *copies; |
1663 | CtkWidget *button; |
1664 | |
1665 | copies = ctk_entry_get_text (CTK_ENTRY (priv->copies_spin)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->copies_spin)), ((ctk_entry_get_type ()))))))); |
1666 | can_collate = (*copies != '\0' && atoi (copies) > 1); |
1667 | |
1668 | caps = priv->manual_capabilities | priv->printer_capabilities; |
1669 | |
1670 | ctk_widget_set_sensitive (priv->page_set_combo, |
1671 | caps & CTK_PRINT_CAPABILITY_PAGE_SET); |
1672 | ctk_widget_set_sensitive (priv->copies_spin, |
1673 | caps & CTK_PRINT_CAPABILITY_COPIES); |
1674 | ctk_widget_set_sensitive (priv->collate_check, |
1675 | can_collate && |
1676 | (caps & CTK_PRINT_CAPABILITY_COLLATE)); |
1677 | ctk_widget_set_sensitive (priv->reverse_check, |
1678 | caps & CTK_PRINT_CAPABILITY_REVERSE); |
1679 | ctk_widget_set_sensitive (priv->scale_spin, |
1680 | caps & CTK_PRINT_CAPABILITY_SCALE); |
1681 | ctk_widget_set_sensitive (CTK_WIDGET (priv->pages_per_sheet)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->pages_per_sheet)), ((ctk_widget_get_type ())))) )), |
1682 | caps & CTK_PRINT_CAPABILITY_NUMBER_UP); |
1683 | |
1684 | button = ctk_dialog_get_widget_for_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_APPLY); |
1685 | ctk_widget_set_visible (button, (caps & CTK_PRINT_CAPABILITY_PREVIEW) != 0); |
1686 | |
1687 | update_collate_icon (NULL((void*)0), dialog); |
1688 | |
1689 | ctk_tree_model_filter_refilter (priv->printer_list_filter); |
1690 | } |
1691 | |
1692 | static gboolean |
1693 | page_setup_is_equal (CtkPageSetup *a, |
1694 | CtkPageSetup *b) |
1695 | { |
1696 | return |
1697 | ctk_paper_size_is_equal (ctk_page_setup_get_paper_size (a), |
1698 | ctk_page_setup_get_paper_size (b)) && |
1699 | ctk_page_setup_get_top_margin (a, CTK_UNIT_MM) == ctk_page_setup_get_top_margin (b, CTK_UNIT_MM) && |
1700 | ctk_page_setup_get_bottom_margin (a, CTK_UNIT_MM) == ctk_page_setup_get_bottom_margin (b, CTK_UNIT_MM) && |
1701 | ctk_page_setup_get_left_margin (a, CTK_UNIT_MM) == ctk_page_setup_get_left_margin (b, CTK_UNIT_MM) && |
1702 | ctk_page_setup_get_right_margin (a, CTK_UNIT_MM) == ctk_page_setup_get_right_margin (b, CTK_UNIT_MM); |
1703 | } |
1704 | |
1705 | static gboolean |
1706 | page_setup_is_same_size (CtkPageSetup *a, |
1707 | CtkPageSetup *b) |
1708 | { |
1709 | return ctk_paper_size_is_equal (ctk_page_setup_get_paper_size (a), |
1710 | ctk_page_setup_get_paper_size (b)); |
1711 | } |
1712 | |
1713 | static gboolean |
1714 | set_paper_size (CtkPrintUnixDialog *dialog, |
1715 | CtkPageSetup *page_setup, |
1716 | gboolean size_only, |
1717 | gboolean add_item) |
1718 | { |
1719 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1720 | CtkTreeModel *model; |
1721 | CtkTreeIter iter; |
1722 | CtkPageSetup *list_page_setup; |
1723 | |
1724 | if (!priv->internal_page_setup_change) |
1725 | return TRUE(!(0)); |
1726 | |
1727 | if (page_setup == NULL((void*)0)) |
1728 | return FALSE(0); |
1729 | |
1730 | model = CTK_TREE_MODEL (priv->page_setup_list)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->page_setup_list)), ((ctk_tree_model_get_type () )))))); |
1731 | |
1732 | if (ctk_tree_model_get_iter_first (model, &iter)) |
1733 | { |
1734 | do |
1735 | { |
1736 | ctk_tree_model_get (CTK_TREE_MODEL (priv->page_setup_list)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->page_setup_list)), ((ctk_tree_model_get_type () )))))), &iter, |
1737 | PAGE_SETUP_LIST_COL_PAGE_SETUP, &list_page_setup, |
1738 | -1); |
1739 | if (list_page_setup == NULL((void*)0)) |
1740 | continue; |
1741 | |
1742 | if ((size_only && page_setup_is_same_size (page_setup, list_page_setup)) || |
1743 | (!size_only && page_setup_is_equal (page_setup, list_page_setup))) |
1744 | { |
1745 | ctk_combo_box_set_active_iter (CTK_COMBO_BOX (priv->paper_size_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->paper_size_combo)), ((ctk_combo_box_get_type () )))))), |
1746 | &iter); |
1747 | ctk_combo_box_set_active (CTK_COMBO_BOX (priv->orientation_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->orientation_combo)), ((ctk_combo_box_get_type ( ))))))), |
1748 | ctk_page_setup_get_orientation (page_setup)); |
1749 | g_object_unref (list_page_setup); |
1750 | return TRUE(!(0)); |
1751 | } |
1752 | |
1753 | g_object_unref (list_page_setup); |
1754 | |
1755 | } while (ctk_tree_model_iter_next (model, &iter)); |
1756 | } |
1757 | |
1758 | if (add_item) |
1759 | { |
1760 | ctk_list_store_append (priv->page_setup_list, &iter); |
1761 | ctk_list_store_set (priv->page_setup_list, &iter, |
1762 | PAGE_SETUP_LIST_COL_IS_SEPARATOR, TRUE(!(0)), |
1763 | -1); |
1764 | ctk_list_store_append (priv->page_setup_list, &iter); |
1765 | ctk_list_store_set (priv->page_setup_list, &iter, |
1766 | PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup, |
1767 | -1); |
1768 | ctk_combo_box_set_active_iter (CTK_COMBO_BOX (priv->paper_size_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->paper_size_combo)), ((ctk_combo_box_get_type () )))))), |
1769 | &iter); |
1770 | ctk_combo_box_set_active (CTK_COMBO_BOX (priv->orientation_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->orientation_combo)), ((ctk_combo_box_get_type ( ))))))), |
1771 | ctk_page_setup_get_orientation (page_setup)); |
1772 | return TRUE(!(0)); |
1773 | } |
1774 | |
1775 | return FALSE(0); |
1776 | } |
1777 | |
1778 | static void |
1779 | fill_custom_paper_sizes (CtkPrintUnixDialog *dialog) |
1780 | { |
1781 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1782 | CtkTreeIter iter, paper_iter; |
1783 | CtkTreeModel *model; |
1784 | |
1785 | model = CTK_TREE_MODEL (priv->custom_paper_list)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->custom_paper_list)), ((ctk_tree_model_get_type ( ))))))); |
1786 | if (ctk_tree_model_get_iter_first (model, &iter)) |
1787 | { |
1788 | ctk_list_store_append (priv->page_setup_list, &paper_iter); |
1789 | ctk_list_store_set (priv->page_setup_list, &paper_iter, |
1790 | PAGE_SETUP_LIST_COL_IS_SEPARATOR, TRUE(!(0)), |
1791 | -1); |
1792 | do |
1793 | { |
1794 | CtkPageSetup *page_setup; |
1795 | ctk_tree_model_get (model, &iter, 0, &page_setup, -1); |
1796 | |
1797 | ctk_list_store_append (priv->page_setup_list, &paper_iter); |
1798 | ctk_list_store_set (priv->page_setup_list, &paper_iter, |
1799 | PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup, |
1800 | -1); |
1801 | |
1802 | g_object_unref (page_setup); |
1803 | } while (ctk_tree_model_iter_next (model, &iter)); |
1804 | } |
1805 | |
1806 | ctk_list_store_append (priv->page_setup_list, &paper_iter); |
1807 | ctk_list_store_set (priv->page_setup_list, &paper_iter, |
1808 | PAGE_SETUP_LIST_COL_IS_SEPARATOR, TRUE(!(0)), |
1809 | -1); |
1810 | ctk_list_store_append (priv->page_setup_list, &paper_iter); |
1811 | ctk_list_store_set (priv->page_setup_list, &paper_iter, |
1812 | PAGE_SETUP_LIST_COL_PAGE_SETUP, NULL((void*)0), |
1813 | -1); |
1814 | } |
1815 | |
1816 | static void |
1817 | fill_paper_sizes (CtkPrintUnixDialog *dialog, |
1818 | CtkPrinter *printer) |
1819 | { |
1820 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1821 | GList *list, *l; |
1822 | CtkPageSetup *page_setup; |
1823 | CtkPaperSize *paper_size; |
1824 | CtkTreeIter iter; |
1825 | gint i; |
1826 | |
1827 | ctk_list_store_clear (priv->page_setup_list); |
1828 | |
1829 | if (printer == NULL((void*)0) || (list = ctk_printer_list_papers (printer)) == NULL((void*)0)) |
1830 | { |
1831 | for (i = 0; i < G_N_ELEMENTS (common_paper_sizes)(sizeof (common_paper_sizes) / sizeof ((common_paper_sizes)[0 ])); i++) |
1832 | { |
1833 | page_setup = ctk_page_setup_new (); |
1834 | paper_size = ctk_paper_size_new (common_paper_sizes[i]); |
1835 | ctk_page_setup_set_paper_size_and_default_margins (page_setup, paper_size); |
1836 | ctk_paper_size_free (paper_size); |
1837 | |
1838 | ctk_list_store_append (priv->page_setup_list, &iter); |
1839 | ctk_list_store_set (priv->page_setup_list, &iter, |
1840 | PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup, |
1841 | -1); |
1842 | g_object_unref (page_setup); |
1843 | } |
1844 | } |
1845 | else |
1846 | { |
1847 | for (l = list; l != NULL((void*)0); l = l->next) |
1848 | { |
1849 | page_setup = l->data; |
1850 | ctk_list_store_append (priv->page_setup_list, &iter); |
1851 | ctk_list_store_set (priv->page_setup_list, &iter, |
1852 | PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup, |
1853 | -1); |
1854 | g_object_unref (page_setup); |
1855 | } |
1856 | g_list_free (list); |
1857 | } |
1858 | |
1859 | fill_custom_paper_sizes (dialog); |
1860 | } |
1861 | |
1862 | static void |
1863 | update_paper_sizes (CtkPrintUnixDialog *dialog) |
1864 | { |
1865 | CtkPageSetup *current_page_setup = NULL((void*)0); |
1866 | CtkPrinter *printer; |
1867 | |
1868 | printer = ctk_print_unix_dialog_get_selected_printer (dialog); |
1869 | |
1870 | fill_paper_sizes (dialog, printer); |
1871 | |
1872 | current_page_setup = ctk_page_setup_copy (ctk_print_unix_dialog_get_page_setup (dialog)); |
1873 | |
1874 | if (current_page_setup) |
1875 | { |
1876 | if (!set_paper_size (dialog, current_page_setup, FALSE(0), FALSE(0))) |
1877 | set_paper_size (dialog, current_page_setup, TRUE(!(0)), TRUE(!(0))); |
1878 | |
1879 | g_object_unref (current_page_setup); |
1880 | } |
1881 | } |
1882 | |
1883 | static void |
1884 | mark_conflicts (CtkPrintUnixDialog *dialog) |
1885 | { |
1886 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1887 | CtkPrinter *printer; |
1888 | gboolean have_conflict; |
1889 | |
1890 | have_conflict = FALSE(0); |
1891 | |
1892 | printer = priv->current_printer; |
1893 | |
1894 | if (printer) |
1895 | { |
1896 | |
1897 | g_signal_handler_block (priv->options, |
1898 | priv->options_changed_handler); |
1899 | |
1900 | ctk_printer_option_set_clear_conflicts (priv->options); |
1901 | |
1902 | have_conflict = _ctk_printer_mark_conflicts (printer, |
1903 | priv->options); |
1904 | |
1905 | g_signal_handler_unblock (priv->options, |
1906 | priv->options_changed_handler); |
1907 | } |
1908 | |
1909 | if (have_conflict) |
1910 | ctk_widget_show (priv->conflicts_widget); |
1911 | else |
1912 | ctk_widget_hide (priv->conflicts_widget); |
1913 | } |
1914 | |
1915 | static gboolean |
1916 | mark_conflicts_callback (gpointer data) |
1917 | { |
1918 | CtkPrintUnixDialog *dialog = data; |
1919 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1920 | |
1921 | priv->mark_conflicts_id = 0; |
1922 | |
1923 | mark_conflicts (dialog); |
1924 | |
1925 | return FALSE(0); |
1926 | } |
1927 | |
1928 | static void |
1929 | unschedule_idle_mark_conflicts (CtkPrintUnixDialog *dialog) |
1930 | { |
1931 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1932 | |
1933 | if (priv->mark_conflicts_id != 0) |
1934 | { |
1935 | g_source_remove (priv->mark_conflicts_id); |
1936 | priv->mark_conflicts_id = 0; |
1937 | } |
1938 | } |
1939 | |
1940 | static void |
1941 | schedule_idle_mark_conflicts (CtkPrintUnixDialog *dialog) |
1942 | { |
1943 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1944 | |
1945 | if (priv->mark_conflicts_id != 0) |
1946 | return; |
1947 | |
1948 | priv->mark_conflicts_id = cdk_threads_add_idle (mark_conflicts_callback, |
1949 | dialog); |
1950 | g_source_set_name_by_id (priv->mark_conflicts_id, "[ctk+] mark_conflicts_callback"); |
1951 | } |
1952 | |
1953 | static void |
1954 | options_changed_cb (CtkPrintUnixDialog *dialog) |
1955 | { |
1956 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1957 | |
1958 | schedule_idle_mark_conflicts (dialog); |
1959 | |
1960 | g_free (priv->waiting_for_printer); |
1961 | priv->waiting_for_printer = NULL((void*)0); |
1962 | } |
1963 | |
1964 | static void |
1965 | remove_custom_widget (CtkWidget *widget, |
1966 | CtkContainer *container) |
1967 | { |
1968 | ctk_container_remove (container, widget); |
1969 | } |
1970 | |
1971 | static void |
1972 | extension_point_clear_children (CtkContainer *container) |
1973 | { |
1974 | ctk_container_foreach (container, |
1975 | (CtkCallback)remove_custom_widget, |
1976 | container); |
1977 | } |
1978 | |
1979 | static void |
1980 | clear_per_printer_ui (CtkPrintUnixDialog *dialog) |
1981 | { |
1982 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
1983 | |
1984 | if (priv->finishing_table == NULL((void*)0)) |
1985 | return; |
1986 | |
1987 | ctk_container_foreach (CTK_CONTAINER (priv->finishing_table)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->finishing_table)), ((ctk_container_get_type ()) ))))), |
1988 | (CtkCallback)ctk_widget_destroy, NULL((void*)0)); |
1989 | ctk_container_foreach (CTK_CONTAINER (priv->image_quality_table)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->image_quality_table)), ((ctk_container_get_type ())))))), |
1990 | (CtkCallback)ctk_widget_destroy, NULL((void*)0)); |
1991 | ctk_container_foreach (CTK_CONTAINER (priv->color_table)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->color_table)), ((ctk_container_get_type ()))))) ), |
1992 | (CtkCallback)ctk_widget_destroy, NULL((void*)0)); |
1993 | ctk_container_foreach (CTK_CONTAINER (priv->advanced_vbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->advanced_vbox)), ((ctk_container_get_type ()))) ))), |
1994 | (CtkCallback)ctk_widget_destroy, NULL((void*)0)); |
1995 | extension_point_clear_children (CTK_CONTAINER (priv->extension_point)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->extension_point)), ((ctk_container_get_type ()) )))))); |
1996 | } |
1997 | |
1998 | static void |
1999 | printer_details_acquired (CtkPrinter *printer G_GNUC_UNUSED__attribute__ ((__unused__)), |
2000 | gboolean success, |
2001 | CtkPrintUnixDialog *dialog) |
2002 | { |
2003 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
2004 | |
2005 | disconnect_printer_details_request (dialog, !success); |
2006 | |
2007 | if (success) |
2008 | { |
2009 | CtkTreeSelection *selection; |
2010 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (priv->printer_treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_treeview)), ((ctk_tree_view_get_type () ))))))); |
2011 | |
2012 | selected_printer_changed (selection, dialog); |
2013 | } |
2014 | } |
2015 | |
2016 | static void |
2017 | selected_printer_changed (CtkTreeSelection *selection, |
2018 | CtkPrintUnixDialog *dialog) |
2019 | { |
2020 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
2021 | CtkPrinter *printer; |
2022 | CtkTreeIter iter, filter_iter; |
2023 | |
2024 | /* Whenever the user selects a printer we stop looking for |
2025 | * the printer specified in the initial settings |
2026 | */ |
2027 | if (priv->waiting_for_printer && |
2028 | !priv->internal_printer_change) |
2029 | { |
2030 | g_free (priv->waiting_for_printer); |
2031 | priv->waiting_for_printer = NULL((void*)0); |
2032 | } |
2033 | |
2034 | disconnect_printer_details_request (dialog, FALSE(0)); |
2035 | |
2036 | printer = NULL((void*)0); |
2037 | if (ctk_tree_selection_get_selected (selection, NULL((void*)0), &filter_iter)) |
2038 | { |
2039 | ctk_tree_model_filter_convert_iter_to_child_iter (priv->printer_list_filter, |
2040 | &iter, |
2041 | &filter_iter); |
2042 | |
2043 | ctk_tree_model_get (priv->printer_list, &iter, |
2044 | PRINTER_LIST_COL_PRINTER_OBJ, &printer, |
2045 | -1); |
2046 | } |
2047 | |
2048 | /* sets CTK_RESPONSE_OK button sensitivity depending on whether the printer |
2049 | * accepts/rejects jobs |
2050 | */ |
2051 | if (printer != NULL((void*)0)) |
2052 | { |
2053 | if (!ctk_printer_is_accepting_jobs (printer)) |
2054 | ctk_dialog_set_response_sensitive (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK, FALSE(0)); |
2055 | else if (priv->current_printer == printer && ctk_printer_has_details (printer)) |
2056 | |
2057 | ctk_dialog_set_response_sensitive (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK, TRUE(!(0))); |
2058 | } |
2059 | |
2060 | if (printer != NULL((void*)0) && !ctk_printer_has_details (printer)) |
2061 | { |
2062 | ctk_dialog_set_response_sensitive (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK, FALSE(0)); |
2063 | priv->request_details_tag = |
2064 | g_signal_connect (printer, "details-acquired",g_signal_connect_data ((printer), ("details-acquired"), (((GCallback ) (printer_details_acquired))), (dialog), ((void*)0), (GConnectFlags ) 0) |
2065 | G_CALLBACK (printer_details_acquired), dialog)g_signal_connect_data ((printer), ("details-acquired"), (((GCallback ) (printer_details_acquired))), (dialog), ((void*)0), (GConnectFlags ) 0); |
2066 | /* take the reference */ |
2067 | priv->request_details_printer = printer; |
2068 | set_busy_cursor (dialog, TRUE(!(0))); |
2069 | ctk_list_store_set (CTK_LIST_STORE (priv->printer_list)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_list)), ((ctk_list_store_get_type ()))) ))), |
2070 | g_object_get_data (G_OBJECT (printer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((printer)), (((GType) ((20) << (2)))))))), "ctk-print-tree-iter"), |
2071 | PRINTER_LIST_COL_STATE, _("Getting printer information…")((char *) g_dgettext ("ctk30", "Getting printer information…" )), |
2072 | -1); |
2073 | ctk_printer_request_details (printer); |
2074 | return; |
2075 | } |
2076 | |
2077 | if (printer == priv->current_printer) |
2078 | { |
2079 | if (printer) |
2080 | g_object_unref (printer); |
2081 | return; |
2082 | } |
2083 | |
2084 | if (priv->options) |
2085 | { |
2086 | g_clear_object (&priv->options)do { _Static_assert (sizeof *((&priv->options)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ ((( &priv->options))) _pp = ((&priv->options)); __typeof__ (*((&priv->options))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
2087 | clear_per_printer_ui (dialog); |
2088 | } |
2089 | |
2090 | g_clear_object (&priv->current_printer)do { _Static_assert (sizeof *((&priv->current_printer) ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&priv->current_printer))) _pp = ((&priv->current_printer )); __typeof__ (*((&priv->current_printer))) _ptr = *_pp ; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
2091 | priv->printer_capabilities = 0; |
2092 | |
2093 | if (printer != NULL((void*)0) && ctk_printer_is_accepting_jobs (printer)) |
2094 | ctk_dialog_set_response_sensitive (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK, TRUE(!(0))); |
2095 | priv->current_printer = printer; |
2096 | |
2097 | if (printer != NULL((void*)0)) |
2098 | { |
2099 | if (!priv->page_setup_set) |
2100 | { |
2101 | /* if no explicit page setup has been set, use the printer default */ |
2102 | CtkPageSetup *page_setup; |
2103 | |
2104 | page_setup = ctk_printer_get_default_page_size (printer); |
2105 | |
2106 | if (!page_setup) |
2107 | page_setup = ctk_page_setup_new (); |
2108 | |
2109 | if (page_setup && priv->page_setup) |
2110 | ctk_page_setup_set_orientation (page_setup, ctk_page_setup_get_orientation (priv->page_setup)); |
2111 | |
2112 | g_clear_object (&priv->page_setup)do { _Static_assert (sizeof *((&priv->page_setup)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ ((( &priv->page_setup))) _pp = ((&priv->page_setup) ); __typeof__ (*((&priv->page_setup))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
2113 | priv->page_setup = page_setup; /* transfer ownership */ |
2114 | } |
2115 | |
2116 | priv->printer_capabilities = ctk_printer_get_capabilities (printer); |
2117 | priv->options = _ctk_printer_get_options (printer, |
2118 | priv->initial_settings, |
2119 | priv->page_setup, |
2120 | priv->manual_capabilities); |
2121 | |
2122 | priv->options_changed_handler = |
2123 | g_signal_connect_swapped (priv->options, "changed", G_CALLBACK (options_changed_cb), dialog)g_signal_connect_data ((priv->options), ("changed"), (((GCallback ) (options_changed_cb))), (dialog), ((void*)0), G_CONNECT_SWAPPED ); |
2124 | schedule_idle_mark_conflicts (dialog); |
2125 | } |
2126 | |
2127 | update_dialog_from_settings (dialog); |
2128 | update_dialog_from_capabilities (dialog); |
2129 | |
2130 | priv->internal_page_setup_change = TRUE(!(0)); |
2131 | update_paper_sizes (dialog); |
2132 | priv->internal_page_setup_change = FALSE(0); |
2133 | |
2134 | g_object_notify ( G_OBJECT(dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "selected-printer"); |
2135 | } |
2136 | |
2137 | static gboolean |
2138 | printer_compare (CtkTreeModel *model, |
2139 | gint column G_GNUC_UNUSED__attribute__ ((__unused__)), |
2140 | const gchar *key, |
2141 | CtkTreeIter *iter, |
2142 | gpointer search_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
2143 | { |
2144 | gboolean matches = FALSE(0); |
2145 | |
2146 | if (key != NULL((void*)0)) |
2147 | { |
2148 | gchar *name = NULL((void*)0); |
2149 | gchar *location = NULL((void*)0); |
2150 | gchar *casefold_key = NULL((void*)0); |
2151 | gchar *casefold_name = NULL((void*)0); |
2152 | gchar *casefold_location = NULL((void*)0); |
2153 | gchar **keys; |
2154 | gchar *tmp1, *tmp2; |
2155 | gint i; |
2156 | |
2157 | ctk_tree_model_get (model, iter, |
2158 | PRINTER_LIST_COL_NAME, &name, |
2159 | PRINTER_LIST_COL_LOCATION, &location, |
2160 | -1); |
2161 | |
2162 | casefold_key = g_utf8_casefold (key, -1); |
2163 | |
2164 | if (name != NULL((void*)0)) |
2165 | { |
2166 | casefold_name = g_utf8_casefold (name, -1); |
2167 | g_free (name); |
2168 | } |
2169 | |
2170 | if (location != NULL((void*)0)) |
2171 | { |
2172 | casefold_location = g_utf8_casefold (location, -1); |
2173 | g_free (location); |
2174 | } |
2175 | |
2176 | if (casefold_name != NULL((void*)0) || |
2177 | casefold_location != NULL((void*)0)) |
2178 | { |
2179 | keys = g_strsplit_set (casefold_key, " \t", 0); |
2180 | if (keys != NULL((void*)0)) |
2181 | { |
2182 | matches = TRUE(!(0)); |
2183 | |
2184 | for (i = 0; keys[i] != NULL((void*)0); i++) |
2185 | { |
2186 | if (keys[i][0] != '\0') |
2187 | { |
2188 | tmp1 = tmp2 = NULL((void*)0); |
2189 | |
2190 | if (casefold_name != NULL((void*)0)) |
2191 | tmp1 = g_strstr_len (casefold_name, -1, keys[i]); |
2192 | |
2193 | if (casefold_location != NULL((void*)0)) |
2194 | tmp2 = g_strstr_len (casefold_location, -1, keys[i]); |
2195 | |
2196 | if (tmp1 == NULL((void*)0) && tmp2 == NULL((void*)0)) |
2197 | { |
2198 | matches = FALSE(0); |
2199 | break; |
2200 | } |
2201 | } |
2202 | } |
2203 | |
2204 | g_strfreev (keys); |
2205 | } |
2206 | } |
2207 | |
2208 | g_free (casefold_location); |
2209 | g_free (casefold_name); |
2210 | g_free (casefold_key); |
2211 | } |
2212 | |
2213 | return !matches; |
2214 | } |
2215 | |
2216 | static void |
2217 | update_collate_icon (CtkToggleButton *toggle_button G_GNUC_UNUSED__attribute__ ((__unused__)), |
2218 | CtkPrintUnixDialog *dialog) |
2219 | { |
2220 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
2221 | |
2222 | ctk_widget_queue_draw (priv->collate_image); |
2223 | } |
2224 | |
2225 | static void |
2226 | paint_page (CtkWidget *widget, |
2227 | cairo_t *cr, |
2228 | gint x, |
2229 | gint y, |
2230 | gchar *text, |
2231 | gint text_x) |
2232 | { |
2233 | CtkStyleContext *context; |
2234 | gint width, height; |
2235 | gint text_y; |
2236 | |
2237 | width = 20; |
2238 | height = 26; |
2239 | text_y = 21; |
2240 | |
2241 | context = ctk_widget_get_style_context (widget); |
2242 | |
2243 | ctk_render_background (context, cr, x, y, width, height); |
2244 | ctk_render_frame (context, cr, x, y, width, height); |
2245 | |
2246 | cairo_select_font_face (cr, "Sans", |
2247 | CAIRO_FONT_SLANT_NORMAL, |
2248 | CAIRO_FONT_WEIGHT_NORMAL); |
2249 | cairo_set_font_size (cr, 9); |
2250 | cairo_move_to (cr, x + text_x, y + text_y); |
2251 | cairo_show_text (cr, text); |
2252 | } |
2253 | |
2254 | static gboolean |
2255 | draw_collate_cb (CtkWidget *widget, |
2256 | cairo_t *cr, |
2257 | CtkPrintUnixDialog *dialog) |
2258 | { |
2259 | gboolean collate, reverse, rtl; |
2260 | gint copies; |
2261 | gint text_x; |
2262 | gint x, y, x1, x2, p1, p2; |
2263 | |
2264 | collate = dialog_get_collate (dialog); |
2265 | reverse = dialog_get_reverse (dialog); |
2266 | copies = dialog_get_n_copies (dialog); |
2267 | |
2268 | rtl = (ctk_widget_get_direction (CTK_WIDGET (widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_widget_get_type ()))))))) == CTK_TEXT_DIR_RTL); |
2269 | |
2270 | x = (ctk_widget_get_allocated_width (widget) - 30) / 2; |
2271 | y = (ctk_widget_get_allocated_height (widget) - 36) / 2; |
2272 | if (rtl) |
2273 | { |
2274 | x1 = x; |
2275 | x2 = x - 36; |
2276 | p1 = 0; |
2277 | p2 = 10; |
2278 | text_x = 4; |
2279 | } |
2280 | else |
2281 | { |
2282 | x1 = x; |
2283 | x2 = x + 36; |
2284 | p1 = 10; |
2285 | p2 = 0; |
2286 | text_x = 11; |
2287 | } |
2288 | |
2289 | if (copies == 1) |
2290 | { |
2291 | paint_page (widget, cr, x1 + p1, y, reverse ? "1" : "2", text_x); |
2292 | paint_page (widget, cr, x1 + p2, y + 10, reverse ? "2" : "1", text_x); |
2293 | } |
2294 | else |
2295 | { |
2296 | paint_page (widget, cr, x1 + p1, y, collate == reverse ? "1" : "2", text_x); |
2297 | paint_page (widget, cr, x1 + p2, y + 10, reverse ? "2" : "1", text_x); |
2298 | |
2299 | paint_page (widget, cr, x2 + p1, y, reverse ? "1" : "2", text_x); |
2300 | paint_page (widget, cr, x2 + p2, y + 10, collate == reverse ? "2" : "1", text_x); |
2301 | } |
2302 | |
2303 | return TRUE(!(0)); |
2304 | } |
2305 | |
2306 | static void |
2307 | ctk_print_unix_dialog_style_updated (CtkWidget *widget) |
2308 | { |
2309 | CTK_WIDGET_CLASS (ctk_print_unix_dialog_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_print_unix_dialog_parent_class)), ((ctk_widget_get_type ()))))))->style_updated (widget); |
2310 | |
2311 | if (ctk_widget_has_screen (widget)) |
2312 | { |
2313 | CtkPrintUnixDialog *dialog = (CtkPrintUnixDialog *)widget; |
2314 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
2315 | gint size; |
2316 | gfloat scale; |
2317 | |
2318 | ctk_icon_size_lookup (CTK_ICON_SIZE_DIALOG, &size, NULL((void*)0)); |
2319 | scale = size / 48.0; |
2320 | |
2321 | ctk_widget_set_size_request (priv->collate_image, |
2322 | (50 + 20) * scale, |
2323 | (15 + 26) * scale); |
2324 | } |
2325 | } |
2326 | |
2327 | static void |
2328 | update_page_range_entry_sensitivity (CtkWidget *button, |
2329 | CtkPrintUnixDialog *dialog) |
2330 | { |
2331 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
2332 | gboolean active; |
2333 | |
2334 | active = ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (button)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_toggle_button_get_type ()))))))); |
2335 | |
2336 | ctk_widget_set_sensitive (priv->page_range_entry, active); |
2337 | |
2338 | if (active) |
2339 | ctk_widget_grab_focus (priv->page_range_entry); |
2340 | } |
2341 | |
2342 | static void |
2343 | update_print_at_entry_sensitivity (CtkWidget *button, |
2344 | CtkPrintUnixDialog *dialog) |
2345 | { |
2346 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
2347 | gboolean active; |
2348 | |
2349 | active = ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (button)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_toggle_button_get_type ()))))))); |
2350 | |
2351 | ctk_widget_set_sensitive (priv->print_at_entry, active); |
2352 | |
2353 | if (active) |
2354 | ctk_widget_grab_focus (priv->print_at_entry); |
2355 | } |
2356 | |
2357 | static void |
2358 | emit_ok_response (CtkTreeView *tree_view G_GNUC_UNUSED__attribute__ ((__unused__)), |
2359 | CtkTreePath *path G_GNUC_UNUSED__attribute__ ((__unused__)), |
2360 | CtkTreeViewColumn *column G_GNUC_UNUSED__attribute__ ((__unused__)), |
2361 | gpointer *user_data) |
2362 | { |
2363 | CtkPrintUnixDialog *print_dialog; |
2364 | |
2365 | print_dialog = (CtkPrintUnixDialog *) user_data; |
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption | |
2366 | |
2367 | ctk_dialog_response (CTK_DIALOG (print_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((print_dialog)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK); |
2368 | } |
2369 | |
2370 | static gboolean |
2371 | is_range_separator (gchar c) |
2372 | { |
2373 | return (c == ',' || c == ';' || c == ':'); |
2374 | } |
2375 | |
2376 | static CtkPageRange * |
2377 | dialog_get_page_ranges (CtkPrintUnixDialog *dialog, |
2378 | gint *n_ranges_out) |
2379 | { |
2380 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
2381 | gint i, n_ranges; |
2382 | const gchar *text, *p; |
2383 | gchar *next; |
2384 | CtkPageRange *ranges; |
2385 | gint start, end; |
2386 | |
2387 | text = ctk_entry_get_text (CTK_ENTRY (priv->page_range_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->page_range_entry)), ((ctk_entry_get_type ())))) ))); |
2388 | |
2389 | if (*text == 0) |
2390 | { |
2391 | *n_ranges_out = 0; |
2392 | return NULL((void*)0); |
2393 | } |
2394 | |
2395 | n_ranges = 1; |
2396 | p = text; |
2397 | while (*p) |
2398 | { |
2399 | if (is_range_separator (*p)) |
2400 | n_ranges++; |
2401 | p++; |
2402 | } |
2403 | |
2404 | ranges = g_new0 (CtkPageRange, n_ranges)((CtkPageRange *) g_malloc0_n ((n_ranges), sizeof (CtkPageRange ))); |
2405 | |
2406 | i = 0; |
2407 | p = text; |
2408 | while (*p) |
2409 | { |
2410 | while (isspace (*p)((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short int) _ISspace)) p++; |
2411 | |
2412 | if (*p == '-') |
2413 | { |
2414 | /* a half-open range like -2 */ |
2415 | start = 1; |
2416 | } |
2417 | else |
2418 | { |
2419 | start = (int)strtol (p, &next, 10); |
2420 | if (start < 1) |
2421 | start = 1; |
2422 | p = next; |
2423 | } |
2424 | |
2425 | end = start; |
2426 | |
2427 | while (isspace (*p)((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short int) _ISspace)) p++; |
2428 | |
2429 | if (*p == '-') |
2430 | { |
2431 | p++; |
2432 | end = (int)strtol (p, &next, 10); |
2433 | if (next == p) /* a half-open range like 2- */ |
2434 | end = 0; |
2435 | else if (end < start) |
2436 | end = start; |
2437 | } |
2438 | |
2439 | ranges[i].start = start - 1; |
2440 | ranges[i].end = end - 1; |
2441 | i++; |
2442 | |
2443 | /* Skip until end or separator */ |
2444 | while (*p && !is_range_separator (*p)) |
2445 | p++; |
2446 | |
2447 | /* if not at end, skip separator */ |
2448 | if (*p) |
2449 | p++; |
2450 | } |
2451 | |
2452 | *n_ranges_out = i; |
2453 | |
2454 | return ranges; |
2455 | } |
2456 | |
2457 | static void |
2458 | dialog_set_page_ranges (CtkPrintUnixDialog *dialog, |
2459 | CtkPageRange *ranges, |
2460 | gint n_ranges) |
2461 | { |
2462 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
2463 | gint i; |
2464 | GString *s = g_string_new (NULL((void*)0)); |
2465 | |
2466 | for (i = 0; i < n_ranges; i++) |
2467 | { |
2468 | g_string_append_printf (s, "%d", ranges[i].start + 1); |
2469 | if (ranges[i].end > ranges[i].start) |
2470 | g_string_append_printf (s, "-%d", ranges[i].end + 1); |
2471 | else if (ranges[i].end == -1) |
2472 | g_string_append (s, "-")(__builtin_constant_p ("-") ? __extension__ ({ const char * const __val = ("-"); g_string_append_len_inline (s, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val))) : (gssize ) -1); }) : g_string_append_len_inline (s, "-", (gssize) -1)); |
2473 | |
2474 | if (i != n_ranges - 1) |
2475 | g_string_append (s, ",")(__builtin_constant_p (",") ? __extension__ ({ const char * const __val = (","); g_string_append_len_inline (s, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val))) : (gssize ) -1); }) : g_string_append_len_inline (s, ",", (gssize) -1)); |
2476 | } |
2477 | |
2478 | ctk_entry_set_text (CTK_ENTRY (priv->page_range_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->page_range_entry)), ((ctk_entry_get_type ())))) )), s->str); |
2479 | |
2480 | g_string_free (s, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) ( (s), ((!(0)))) : g_string_free_and_steal (s)) : (g_string_free ) ((s), ((!(0))))); |
2481 | } |
2482 | |
2483 | static CtkPrintPages |
2484 | dialog_get_print_pages (CtkPrintUnixDialog *dialog) |
2485 | { |
2486 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
2487 | |
2488 | if (ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (priv->all_pages_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->all_pages_radio)), ((ctk_toggle_button_get_type ())))))))) |
2489 | return CTK_PRINT_PAGES_ALL; |
2490 | else if (ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (priv->current_page_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->current_page_radio)), ((ctk_toggle_button_get_type ())))))))) |
2491 | return CTK_PRINT_PAGES_CURRENT; |
2492 | else if (ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (priv->selection_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->selection_radio)), ((ctk_toggle_button_get_type ())))))))) |
2493 | return CTK_PRINT_PAGES_SELECTION; |
2494 | else |
2495 | return CTK_PRINT_PAGES_RANGES; |
2496 | } |
2497 | |
2498 | static void |
2499 | dialog_set_print_pages (CtkPrintUnixDialog *dialog, |
2500 | CtkPrintPages pages) |
2501 | { |
2502 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
2503 | |
2504 | if (pages == CTK_PRINT_PAGES_RANGES) |
2505 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (priv->page_range_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->page_range_radio)), ((ctk_toggle_button_get_type ())))))), TRUE(!(0))); |
2506 | else if (pages == CTK_PRINT_PAGES_CURRENT) |
2507 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (priv->current_page_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->current_page_radio)), ((ctk_toggle_button_get_type ())))))), TRUE(!(0))); |
2508 | else if (pages == CTK_PRINT_PAGES_SELECTION) |
2509 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (priv->selection_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->selection_radio)), ((ctk_toggle_button_get_type ())))))), TRUE(!(0))); |
2510 | else |
2511 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (priv->all_pages_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->all_pages_radio)), ((ctk_toggle_button_get_type ())))))), TRUE(!(0))); |
2512 | } |
2513 | |
2514 | static gdouble |
2515 | dialog_get_scale (CtkPrintUnixDialog *dialog) |
2516 | { |
2517 | if (ctk_widget_is_sensitive (dialog->priv->scale_spin)) |
2518 | return ctk_spin_button_get_value (CTK_SPIN_BUTTON (dialog->priv->scale_spin)((((CtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->priv->scale_spin)), ((ctk_spin_button_get_type ()))))))); |
2519 | else |
2520 | return 100.0; |
2521 | } |
2522 | |
2523 | static void |
2524 | dialog_set_scale (CtkPrintUnixDialog *dialog, |
2525 | gdouble val) |
2526 | { |
2527 | ctk_spin_button_set_value (CTK_SPIN_BUTTON (dialog->priv->scale_spin)((((CtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->priv->scale_spin)), ((ctk_spin_button_get_type ())))))), val); |
2528 | } |
2529 | |
2530 | static CtkPageSet |
2531 | dialog_get_page_set (CtkPrintUnixDialog *dialog) |
2532 | { |
2533 | if (ctk_widget_is_sensitive (dialog->priv->page_set_combo)) |
2534 | return (CtkPageSet)ctk_combo_box_get_active (CTK_COMBO_BOX (dialog->priv->page_set_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->priv->page_set_combo)), ((ctk_combo_box_get_type ()))))))); |
2535 | else |
2536 | return CTK_PAGE_SET_ALL; |
2537 | } |
2538 | |
2539 | static void |
2540 | dialog_set_page_set (CtkPrintUnixDialog *dialog, |
2541 | CtkPageSet val) |
2542 | { |
2543 | ctk_combo_box_set_active (CTK_COMBO_BOX (dialog->priv->page_set_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->priv->page_set_combo)), ((ctk_combo_box_get_type ())))))), |
2544 | (int)val); |
2545 | } |
2546 | |
2547 | static gint |
2548 | dialog_get_n_copies (CtkPrintUnixDialog *dialog) |
2549 | { |
2550 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
2551 | CtkAdjustment *adjustment; |
2552 | const gchar *text; |
2553 | gchar *endptr = NULL((void*)0); |
2554 | gint n_copies; |
2555 | |
2556 | adjustment = ctk_spin_button_get_adjustment (CTK_SPIN_BUTTON (priv->copies_spin)((((CtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->copies_spin)), ((ctk_spin_button_get_type ()))) )))); |
2557 | |
2558 | text = ctk_entry_get_text (CTK_ENTRY (priv->copies_spin)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->copies_spin)), ((ctk_entry_get_type ()))))))); |
2559 | n_copies = g_ascii_strtoull (text, &endptr, 0); |
2560 | |
2561 | if (ctk_widget_is_sensitive (dialog->priv->copies_spin)) |
2562 | { |
2563 | if (n_copies != 0 && endptr != text && (endptr != NULL((void*)0) && endptr[0] == '\0') && |
2564 | n_copies >= ctk_adjustment_get_lower (adjustment) && |
2565 | n_copies <= ctk_adjustment_get_upper (adjustment)) |
2566 | { |
2567 | return n_copies; |
2568 | } |
2569 | |
2570 | return ctk_spin_button_get_value_as_int (CTK_SPIN_BUTTON (priv->copies_spin)((((CtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->copies_spin)), ((ctk_spin_button_get_type ()))) )))); |
2571 | } |
2572 | |
2573 | return 1; |
2574 | } |
2575 | |
2576 | static void |
2577 | dialog_set_n_copies (CtkPrintUnixDialog *dialog, |
2578 | gint n_copies) |
2579 | { |
2580 | ctk_spin_button_set_value (CTK_SPIN_BUTTON (dialog->priv->copies_spin)((((CtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->priv->copies_spin)), ((ctk_spin_button_get_type ())))))), |
2581 | n_copies); |
2582 | } |
2583 | |
2584 | static gboolean |
2585 | dialog_get_collate (CtkPrintUnixDialog *dialog) |
2586 | { |
2587 | if (ctk_widget_is_sensitive (dialog->priv->collate_check)) |
2588 | return ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (dialog->priv->collate_check)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->priv->collate_check)), ((ctk_toggle_button_get_type ()))))))); |
2589 | return FALSE(0); |
2590 | } |
2591 | |
2592 | static void |
2593 | dialog_set_collate (CtkPrintUnixDialog *dialog, |
2594 | gboolean collate) |
2595 | { |
2596 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (dialog->priv->collate_check)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->priv->collate_check)), ((ctk_toggle_button_get_type ())))))), |
2597 | collate); |
2598 | } |
2599 | |
2600 | static gboolean |
2601 | dialog_get_reverse (CtkPrintUnixDialog *dialog) |
2602 | { |
2603 | if (ctk_widget_is_sensitive (dialog->priv->reverse_check)) |
2604 | return ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (dialog->priv->reverse_check)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->priv->reverse_check)), ((ctk_toggle_button_get_type ()))))))); |
2605 | return FALSE(0); |
2606 | } |
2607 | |
2608 | static void |
2609 | dialog_set_reverse (CtkPrintUnixDialog *dialog, |
2610 | gboolean reverse) |
2611 | { |
2612 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (dialog->priv->reverse_check)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->priv->reverse_check)), ((ctk_toggle_button_get_type ())))))), |
2613 | reverse); |
2614 | } |
2615 | |
2616 | static gint |
2617 | dialog_get_pages_per_sheet (CtkPrintUnixDialog *dialog) |
2618 | { |
2619 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
2620 | const gchar *val; |
2621 | gint num; |
2622 | |
2623 | val = ctk_printer_option_widget_get_value (priv->pages_per_sheet); |
2624 | |
2625 | num = 1; |
2626 | |
2627 | if (val) |
2628 | { |
2629 | num = atoi(val); |
2630 | if (num < 1) |
2631 | num = 1; |
2632 | } |
2633 | |
2634 | return num; |
2635 | } |
2636 | |
2637 | static CtkNumberUpLayout |
2638 | dialog_get_number_up_layout (CtkPrintUnixDialog *dialog) |
2639 | { |
2640 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
2641 | CtkPrintCapabilities caps; |
2642 | CtkNumberUpLayout layout; |
2643 | const gchar *val; |
2644 | GEnumClass *enum_class; |
2645 | GEnumValue *enum_value; |
2646 | |
2647 | val = ctk_printer_option_widget_get_value (priv->number_up_layout); |
2648 | |
2649 | caps = priv->manual_capabilities | priv->printer_capabilities; |
2650 | |
2651 | if ((caps & CTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT) == 0) |
2652 | return CTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM; |
2653 | |
2654 | if (ctk_widget_get_direction (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))) == CTK_TEXT_DIR_LTR) |
2655 | layout = CTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM; |
2656 | else |
2657 | layout = CTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TO_BOTTOM; |
2658 | |
2659 | if (val == NULL((void*)0)) |
2660 | return layout; |
2661 | |
2662 | if (val[0] == '\0' && priv->options) |
2663 | { |
2664 | CtkPrinterOption *option = ctk_printer_option_set_lookup (priv->options, "ctk-n-up-layout"); |
2665 | if (option) |
2666 | val = option->value; |
2667 | } |
2668 | |
2669 | enum_class = g_type_class_ref (CTK_TYPE_NUMBER_UP_LAYOUT(ctk_number_up_layout_get_type ())); |
2670 | enum_value = g_enum_get_value_by_nick (enum_class, val); |
2671 | if (enum_value) |
2672 | layout = enum_value->value; |
2673 | g_type_class_unref (enum_class); |
2674 | |
2675 | return layout; |
2676 | } |
2677 | |
2678 | static gboolean |
2679 | draw_page_cb (CtkWidget *widget, |
2680 | cairo_t *cr, |
2681 | CtkPrintUnixDialog *dialog) |
2682 | { |
2683 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
2684 | CtkStyleContext *context; |
2685 | gdouble ratio; |
2686 | gint w, h, tmp, shadow_offset; |
2687 | gint pages_x, pages_y, i, x, y, layout_w, layout_h; |
2688 | gdouble page_width, page_height; |
2689 | CtkPageOrientation orientation; |
2690 | gboolean landscape; |
2691 | PangoLayout *layout; |
2692 | PangoFontDescription *font; |
2693 | gchar *text; |
2694 | CdkRGBA color; |
2695 | CtkNumberUpLayout number_up_layout; |
2696 | gint start_x, end_x, start_y, end_y; |
2697 | gint dx, dy; |
2698 | gint width, height; |
2699 | gboolean horizontal; |
2700 | CtkPageSetup *page_setup; |
2701 | gdouble paper_width, paper_height; |
2702 | gdouble pos_x, pos_y; |
2703 | gint pages_per_sheet; |
2704 | gboolean ltr = TRUE(!(0)); |
2705 | |
2706 | orientation = ctk_page_setup_get_orientation (priv->page_setup); |
2707 | landscape = |
2708 | (orientation == CTK_PAGE_ORIENTATION_LANDSCAPE) || |
2709 | (orientation == CTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE); |
2710 | |
2711 | number_up_layout = dialog_get_number_up_layout (dialog); |
2712 | width = ctk_widget_get_allocated_width (widget); |
2713 | height = ctk_widget_get_allocated_height (widget); |
2714 | |
2715 | cairo_save (cr); |
2716 | |
2717 | page_setup = ctk_print_unix_dialog_get_page_setup (dialog); |
2718 | |
2719 | if (page_setup != NULL((void*)0)) |
2720 | { |
2721 | if (!landscape) |
2722 | { |
2723 | paper_width = ctk_page_setup_get_paper_width (page_setup, CTK_UNIT_MM); |
2724 | paper_height = ctk_page_setup_get_paper_height (page_setup, CTK_UNIT_MM); |
2725 | } |
2726 | else |
2727 | { |
2728 | paper_width = ctk_page_setup_get_paper_height (page_setup, CTK_UNIT_MM); |
2729 | paper_height = ctk_page_setup_get_paper_width (page_setup, CTK_UNIT_MM); |
2730 | } |
2731 | |
2732 | if (paper_width < paper_height) |
2733 | { |
2734 | h = EXAMPLE_PAGE_AREA_SIZE110 - 3; |
2735 | w = (paper_height != 0) ? h * paper_width / paper_height : 0; |
2736 | } |
2737 | else |
2738 | { |
2739 | w = EXAMPLE_PAGE_AREA_SIZE110 - 3; |
2740 | h = (paper_width != 0) ? w * paper_height / paper_width : 0; |
2741 | } |
2742 | |
2743 | if (paper_width == 0) |
2744 | w = 0; |
2745 | |
2746 | if (paper_height == 0) |
2747 | h = 0; |
2748 | } |
2749 | else |
2750 | { |
2751 | ratio = G_SQRT21.4142135623730950488016887242096980785696718753769; |
2752 | w = (EXAMPLE_PAGE_AREA_SIZE110 - 3) / ratio; |
2753 | h = EXAMPLE_PAGE_AREA_SIZE110 - 3; |
2754 | } |
2755 | |
2756 | pages_per_sheet = dialog_get_pages_per_sheet (dialog); |
2757 | switch (pages_per_sheet) |
2758 | { |
2759 | default: |
2760 | case 1: |
2761 | pages_x = 1; pages_y = 1; |
2762 | break; |
2763 | case 2: |
2764 | landscape = !landscape; |
2765 | pages_x = 1; pages_y = 2; |
2766 | break; |
2767 | case 4: |
2768 | pages_x = 2; pages_y = 2; |
2769 | break; |
2770 | case 6: |
2771 | landscape = !landscape; |
2772 | pages_x = 2; pages_y = 3; |
2773 | break; |
2774 | case 9: |
2775 | pages_x = 3; pages_y = 3; |
2776 | break; |
2777 | case 16: |
2778 | pages_x = 4; pages_y = 4; |
2779 | break; |
2780 | } |
2781 | |
2782 | if (landscape) |
2783 | { |
2784 | tmp = w; |
2785 | w = h; |
2786 | h = tmp; |
2787 | |
2788 | tmp = pages_x; |
2789 | pages_x = pages_y; |
2790 | pages_y = tmp; |
2791 | } |
2792 | |
2793 | context = ctk_widget_get_style_context (widget); |
2794 | ctk_style_context_get_color (context, ctk_style_context_get_state (context), &color); |
2795 | |
2796 | pos_x = (width - w) / 2; |
2797 | pos_y = (height - h) / 2 - 10; |
2798 | cairo_translate (cr, pos_x, pos_y); |
2799 | |
2800 | shadow_offset = 3; |
2801 | |
2802 | cairo_set_source_rgba (cr, color.red, color.green, color.blue, 0.5); |
2803 | cairo_rectangle (cr, shadow_offset + 1, shadow_offset + 1, w, h); |
2804 | cairo_fill (cr); |
2805 | |
2806 | ctk_render_background (context, cr, 1, 1, w, h); |
2807 | |
2808 | cairo_set_line_width (cr, 1.0); |
2809 | cairo_rectangle (cr, 0.5, 0.5, w + 1, h + 1); |
2810 | cdk_cairo_set_source_rgba (cr, &color); |
2811 | cairo_stroke (cr); |
2812 | |
2813 | i = 1; |
2814 | |
2815 | page_width = (gdouble)w / pages_x; |
2816 | page_height = (gdouble)h / pages_y; |
2817 | |
2818 | layout = pango_cairo_create_layout (cr); |
2819 | |
2820 | font = pango_font_description_new (); |
2821 | pango_font_description_set_family (font, "sans"); |
2822 | |
2823 | if (page_height > 0) |
2824 | pango_font_description_set_absolute_size (font, page_height * 0.4 * PANGO_SCALE1024); |
2825 | else |
2826 | pango_font_description_set_absolute_size (font, 1); |
2827 | |
2828 | pango_layout_set_font_description (layout, font); |
2829 | pango_font_description_free (font); |
2830 | |
2831 | pango_layout_set_width (layout, page_width * PANGO_SCALE1024); |
2832 | pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER); |
2833 | |
2834 | switch (number_up_layout) |
2835 | { |
2836 | default: |
2837 | case CTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM: |
2838 | start_x = 0; |
2839 | end_x = pages_x - 1; |
2840 | start_y = 0; |
2841 | end_y = pages_y - 1; |
2842 | dx = 1; |
2843 | dy = 1; |
2844 | horizontal = TRUE(!(0)); |
2845 | break; |
2846 | case CTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_BOTTOM_TO_TOP: |
2847 | start_x = 0; |
2848 | end_x = pages_x - 1; |
2849 | start_y = pages_y - 1; |
2850 | end_y = 0; |
2851 | dx = 1; |
2852 | dy = - 1; |
2853 | horizontal = TRUE(!(0)); |
2854 | break; |
2855 | case CTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TO_BOTTOM: |
2856 | start_x = pages_x - 1; |
2857 | end_x = 0; |
2858 | start_y = 0; |
2859 | end_y = pages_y - 1; |
2860 | dx = - 1; |
2861 | dy = 1; |
2862 | horizontal = TRUE(!(0)); |
2863 | break; |
2864 | case CTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_BOTTOM_TO_TOP: |
2865 | start_x = pages_x - 1; |
2866 | end_x = 0; |
2867 | start_y = pages_y - 1; |
2868 | end_y = 0; |
2869 | dx = - 1; |
2870 | dy = - 1; |
2871 | horizontal = TRUE(!(0)); |
2872 | break; |
2873 | case CTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_LEFT_TO_RIGHT: |
2874 | start_x = 0; |
2875 | end_x = pages_x - 1; |
2876 | start_y = 0; |
2877 | end_y = pages_y - 1; |
2878 | dx = 1; |
2879 | dy = 1; |
2880 | horizontal = FALSE(0); |
2881 | break; |
2882 | case CTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_RIGHT_TO_LEFT: |
2883 | start_x = pages_x - 1; |
2884 | end_x = 0; |
2885 | start_y = 0; |
2886 | end_y = pages_y - 1; |
2887 | dx = - 1; |
2888 | dy = 1; |
2889 | horizontal = FALSE(0); |
2890 | break; |
2891 | case CTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_LEFT_TO_RIGHT: |
2892 | start_x = 0; |
2893 | end_x = pages_x - 1; |
2894 | start_y = pages_y - 1; |
2895 | end_y = 0; |
2896 | dx = 1; |
2897 | dy = - 1; |
2898 | horizontal = FALSE(0); |
2899 | break; |
2900 | case CTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_RIGHT_TO_LEFT: |
2901 | start_x = pages_x - 1; |
2902 | end_x = 0; |
2903 | start_y = pages_y - 1; |
2904 | end_y = 0; |
2905 | dx = - 1; |
2906 | dy = - 1; |
2907 | horizontal = FALSE(0); |
2908 | break; |
2909 | } |
2910 | |
2911 | if (horizontal) |
2912 | for (y = start_y; y != end_y + dy; y += dy) |
2913 | { |
2914 | for (x = start_x; x != end_x + dx; x += dx) |
2915 | { |
2916 | text = g_strdup_printf ("%d", i++); |
2917 | pango_layout_set_text (layout, text, -1); |
2918 | g_free (text); |
2919 | pango_layout_get_size (layout, &layout_w, &layout_h); |
2920 | cairo_save (cr); |
2921 | cairo_translate (cr, |
2922 | x * page_width, |
2923 | y * page_height + (page_height - layout_h / 1024.0) / 2); |
2924 | |
2925 | pango_cairo_show_layout (cr, layout); |
2926 | cairo_restore (cr); |
2927 | } |
2928 | } |
2929 | else |
2930 | for (x = start_x; x != end_x + dx; x += dx) |
2931 | { |
2932 | for (y = start_y; y != end_y + dy; y += dy) |
2933 | { |
2934 | text = g_strdup_printf ("%d", i++); |
2935 | pango_layout_set_text (layout, text, -1); |
2936 | g_free (text); |
2937 | pango_layout_get_size (layout, &layout_w, &layout_h); |
2938 | cairo_save (cr); |
2939 | cairo_translate (cr, |
2940 | x * page_width, |
2941 | y * page_height + (page_height - layout_h / 1024.0) / 2); |
2942 | |
2943 | pango_cairo_show_layout (cr, layout); |
2944 | cairo_restore (cr); |
2945 | } |
2946 | } |
2947 | |
2948 | g_object_unref (layout); |
2949 | |
2950 | if (page_setup != NULL((void*)0)) |
2951 | { |
2952 | PangoContext *pango_c = NULL((void*)0); |
2953 | PangoFontDescription *pango_f = NULL((void*)0); |
2954 | gint font_size = 12 * PANGO_SCALE1024; |
2955 | |
2956 | pos_x += 1; |
2957 | pos_y += 1; |
2958 | |
2959 | if (pages_per_sheet == 2 || pages_per_sheet == 6) |
2960 | { |
2961 | paper_width = ctk_page_setup_get_paper_height (page_setup, _ctk_print_get_default_user_units ()); |
2962 | paper_height = ctk_page_setup_get_paper_width (page_setup, _ctk_print_get_default_user_units ()); |
2963 | } |
2964 | else |
2965 | { |
2966 | paper_width = ctk_page_setup_get_paper_width (page_setup, _ctk_print_get_default_user_units ()); |
2967 | paper_height = ctk_page_setup_get_paper_height (page_setup, _ctk_print_get_default_user_units ()); |
2968 | } |
2969 | |
2970 | cairo_restore (cr); |
2971 | cairo_save (cr); |
2972 | |
2973 | layout = pango_cairo_create_layout (cr); |
2974 | |
2975 | font = pango_font_description_new (); |
2976 | pango_font_description_set_family (font, "sans"); |
2977 | |
2978 | pango_c = ctk_widget_get_pango_context (widget); |
2979 | if (pango_c != NULL((void*)0)) |
2980 | { |
2981 | pango_f = pango_context_get_font_description (pango_c); |
2982 | if (pango_f != NULL((void*)0)) |
2983 | font_size = pango_font_description_get_size (pango_f); |
2984 | } |
2985 | |
2986 | pango_font_description_set_size (font, font_size); |
2987 | pango_layout_set_font_description (layout, font); |
2988 | pango_font_description_free (font); |
2989 | |
2990 | pango_layout_set_width (layout, -1); |
2991 | pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER); |
2992 | |
2993 | if (_ctk_print_get_default_user_units () == CTK_UNIT_MM) |
2994 | text = g_strdup_printf ("%.1f mm", paper_height); |
2995 | else |
2996 | text = g_strdup_printf ("%.2f inch", paper_height); |
2997 | |
2998 | pango_layout_set_text (layout, text, -1); |
2999 | g_free (text); |
3000 | pango_layout_get_size (layout, &layout_w, &layout_h); |
3001 | |
3002 | ltr = ctk_widget_get_direction (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))) == CTK_TEXT_DIR_LTR; |
3003 | |
3004 | if (ltr) |
3005 | cairo_translate (cr, pos_x - layout_w / PANGO_SCALE1024 - 2 * RULER_DISTANCE7.5, |
3006 | (height - layout_h / PANGO_SCALE1024) / 2); |
3007 | else |
3008 | cairo_translate (cr, pos_x + w + shadow_offset + 2 * RULER_DISTANCE7.5, |
3009 | (height - layout_h / PANGO_SCALE1024) / 2); |
3010 | |
3011 | cdk_cairo_set_source_rgba (cr, &color); |
3012 | pango_cairo_show_layout (cr, layout); |
3013 | |
3014 | cairo_restore (cr); |
3015 | cairo_save (cr); |
3016 | |
3017 | if (_ctk_print_get_default_user_units () == CTK_UNIT_MM) |
3018 | text = g_strdup_printf ("%.1f mm", paper_width); |
3019 | else |
3020 | text = g_strdup_printf ("%.2f inch", paper_width); |
3021 | |
3022 | pango_layout_set_text (layout, text, -1); |
3023 | g_free (text); |
3024 | pango_layout_get_size (layout, &layout_w, &layout_h); |
3025 | |
3026 | cairo_translate (cr, (width - layout_w / PANGO_SCALE1024) / 2, |
3027 | pos_y + h + shadow_offset + 2 * RULER_DISTANCE7.5); |
3028 | |
3029 | cdk_cairo_set_source_rgba (cr, &color); |
3030 | pango_cairo_show_layout (cr, layout); |
3031 | |
3032 | g_object_unref (layout); |
3033 | |
3034 | cairo_restore (cr); |
3035 | |
3036 | cairo_set_line_width (cr, 1); |
3037 | |
3038 | cdk_cairo_set_source_rgba (cr, &color); |
3039 | |
3040 | if (ltr) |
3041 | { |
3042 | cairo_move_to (cr, pos_x - RULER_DISTANCE7.5, pos_y); |
3043 | cairo_line_to (cr, pos_x - RULER_DISTANCE7.5, pos_y + h); |
3044 | cairo_stroke (cr); |
3045 | |
3046 | cairo_move_to (cr, pos_x - RULER_DISTANCE7.5 - RULER_RADIUS2, pos_y - 0.5); |
3047 | cairo_line_to (cr, pos_x - RULER_DISTANCE7.5 + RULER_RADIUS2, pos_y - 0.5); |
3048 | cairo_stroke (cr); |
3049 | |
3050 | cairo_move_to (cr, pos_x - RULER_DISTANCE7.5 - RULER_RADIUS2, pos_y + h + 0.5); |
3051 | cairo_line_to (cr, pos_x - RULER_DISTANCE7.5 + RULER_RADIUS2, pos_y + h + 0.5); |
3052 | cairo_stroke (cr); |
3053 | } |
3054 | else |
3055 | { |
3056 | cairo_move_to (cr, pos_x + w + shadow_offset + RULER_DISTANCE7.5, pos_y); |
3057 | cairo_line_to (cr, pos_x + w + shadow_offset + RULER_DISTANCE7.5, pos_y + h); |
3058 | cairo_stroke (cr); |
3059 | |
3060 | cairo_move_to (cr, pos_x + w + shadow_offset + RULER_DISTANCE7.5 - RULER_RADIUS2, pos_y - 0.5); |
3061 | cairo_line_to (cr, pos_x + w + shadow_offset + RULER_DISTANCE7.5 + RULER_RADIUS2, pos_y - 0.5); |
3062 | cairo_stroke (cr); |
3063 | |
3064 | cairo_move_to (cr, pos_x + w + shadow_offset + RULER_DISTANCE7.5 - RULER_RADIUS2, pos_y + h + 0.5); |
3065 | cairo_line_to (cr, pos_x + w + shadow_offset + RULER_DISTANCE7.5 + RULER_RADIUS2, pos_y + h + 0.5); |
3066 | cairo_stroke (cr); |
3067 | } |
3068 | |
3069 | cairo_move_to (cr, pos_x, pos_y + h + shadow_offset + RULER_DISTANCE7.5); |
3070 | cairo_line_to (cr, pos_x + w, pos_y + h + shadow_offset + RULER_DISTANCE7.5); |
3071 | cairo_stroke (cr); |
3072 | |
3073 | cairo_move_to (cr, pos_x - 0.5, pos_y + h + shadow_offset + RULER_DISTANCE7.5 - RULER_RADIUS2); |
3074 | cairo_line_to (cr, pos_x - 0.5, pos_y + h + shadow_offset + RULER_DISTANCE7.5 + RULER_RADIUS2); |
3075 | cairo_stroke (cr); |
3076 | |
3077 | cairo_move_to (cr, pos_x + w + 0.5, pos_y + h + shadow_offset + RULER_DISTANCE7.5 - RULER_RADIUS2); |
3078 | cairo_line_to (cr, pos_x + w + 0.5, pos_y + h + shadow_offset + RULER_DISTANCE7.5 + RULER_RADIUS2); |
3079 | cairo_stroke (cr); |
3080 | } |
3081 | |
3082 | return TRUE(!(0)); |
3083 | } |
3084 | |
3085 | static void |
3086 | redraw_page_layout_preview (CtkPrintUnixDialog *dialog) |
3087 | { |
3088 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
3089 | |
3090 | if (priv->page_layout_preview) |
3091 | ctk_widget_queue_draw (priv->page_layout_preview); |
3092 | } |
3093 | |
3094 | static void |
3095 | update_number_up_layout (CtkPrintUnixDialog *dialog) |
3096 | { |
3097 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
3098 | CtkPrintCapabilities caps; |
3099 | CtkPrinterOptionSet *set; |
3100 | CtkNumberUpLayout layout; |
3101 | CtkPrinterOption *option; |
3102 | CtkPrinterOption *old_option; |
3103 | CtkPageOrientation page_orientation; |
3104 | |
3105 | set = priv->options; |
3106 | |
3107 | caps = priv->manual_capabilities | priv->printer_capabilities; |
3108 | |
3109 | if (caps & CTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT) |
3110 | { |
3111 | if (priv->number_up_layout_n_option == NULL((void*)0)) |
3112 | { |
3113 | priv->number_up_layout_n_option = ctk_printer_option_set_lookup (set, "ctk-n-up-layout"); |
3114 | if (priv->number_up_layout_n_option == NULL((void*)0)) |
3115 | { |
3116 | char *n_up_layout[] = { "lrtb", "lrbt", "rltb", "rlbt", "tblr", "tbrl", "btlr", "btrl" }; |
3117 | /* Translators: These strings name the possible arrangements of |
3118 | * multiple pages on a sheet when printing (same as in ctkprintbackendcups.c) |
3119 | */ |
3120 | char *n_up_layout_display[] = { N_("Left to right, top to bottom")("Left to right, top to bottom"), N_("Left to right, bottom to top")("Left to right, bottom to top"), |
3121 | N_("Right to left, top to bottom")("Right to left, top to bottom"), N_("Right to left, bottom to top")("Right to left, bottom to top"), |
3122 | N_("Top to bottom, left to right")("Top to bottom, left to right"), N_("Top to bottom, right to left")("Top to bottom, right to left"), |
3123 | N_("Bottom to top, left to right")("Bottom to top, left to right"), N_("Bottom to top, right to left")("Bottom to top, right to left") }; |
3124 | int i; |
3125 | |
3126 | priv->number_up_layout_n_option = ctk_printer_option_new ("ctk-n-up-layout", |
3127 | _("Page Ordering")((char *) g_dgettext ("ctk30", "Page Ordering")), |
3128 | CTK_PRINTER_OPTION_TYPE_PICKONE); |
3129 | ctk_printer_option_allocate_choices (priv->number_up_layout_n_option, 8); |
3130 | |
3131 | for (i = 0; i < G_N_ELEMENTS (n_up_layout_display)(sizeof (n_up_layout_display) / sizeof ((n_up_layout_display) [0])); i++) |
3132 | { |
3133 | priv->number_up_layout_n_option->choices[i] = g_strdup (n_up_layout[i])g_strdup_inline (n_up_layout[i]); |
3134 | priv->number_up_layout_n_option->choices_display[i] = g_strdup (_(n_up_layout_display[i]))g_strdup_inline (((char *) g_dgettext ("ctk30", n_up_layout_display [i]))); |
3135 | } |
3136 | } |
3137 | g_object_ref (priv->number_up_layout_n_option)((__typeof__ (priv->number_up_layout_n_option)) (g_object_ref ) (priv->number_up_layout_n_option)); |
3138 | |
3139 | priv->number_up_layout_2_option = ctk_printer_option_new ("ctk-n-up-layout", |
3140 | _("Page Ordering")((char *) g_dgettext ("ctk30", "Page Ordering")), |
3141 | CTK_PRINTER_OPTION_TYPE_PICKONE); |
3142 | ctk_printer_option_allocate_choices (priv->number_up_layout_2_option, 2); |
3143 | } |
3144 | |
3145 | page_orientation = ctk_page_setup_get_orientation (priv->page_setup); |
3146 | if (page_orientation == CTK_PAGE_ORIENTATION_PORTRAIT || |
3147 | page_orientation == CTK_PAGE_ORIENTATION_REVERSE_PORTRAIT) |
3148 | { |
3149 | if (! (priv->number_up_layout_2_option->choices[0] == priv->number_up_layout_n_option->choices[0] && |
3150 | priv->number_up_layout_2_option->choices[1] == priv->number_up_layout_n_option->choices[2])) |
3151 | { |
3152 | g_free (priv->number_up_layout_2_option->choices_display[0]); |
3153 | g_free (priv->number_up_layout_2_option->choices_display[1]); |
3154 | priv->number_up_layout_2_option->choices[0] = priv->number_up_layout_n_option->choices[0]; |
3155 | priv->number_up_layout_2_option->choices[1] = priv->number_up_layout_n_option->choices[2]; |
3156 | priv->number_up_layout_2_option->choices_display[0] = g_strdup ( _("Left to right"))g_strdup_inline (((char *) g_dgettext ("ctk30", "Left to right" ))); |
3157 | priv->number_up_layout_2_option->choices_display[1] = g_strdup ( _("Right to left"))g_strdup_inline (((char *) g_dgettext ("ctk30", "Right to left" ))); |
3158 | } |
3159 | } |
3160 | else |
3161 | { |
3162 | if (! (priv->number_up_layout_2_option->choices[0] == priv->number_up_layout_n_option->choices[0] && |
3163 | priv->number_up_layout_2_option->choices[1] == priv->number_up_layout_n_option->choices[1])) |
3164 | { |
3165 | g_free (priv->number_up_layout_2_option->choices_display[0]); |
3166 | g_free (priv->number_up_layout_2_option->choices_display[1]); |
3167 | priv->number_up_layout_2_option->choices[0] = priv->number_up_layout_n_option->choices[0]; |
3168 | priv->number_up_layout_2_option->choices[1] = priv->number_up_layout_n_option->choices[1]; |
3169 | priv->number_up_layout_2_option->choices_display[0] = g_strdup ( _("Top to bottom"))g_strdup_inline (((char *) g_dgettext ("ctk30", "Top to bottom" ))); |
3170 | priv->number_up_layout_2_option->choices_display[1] = g_strdup ( _("Bottom to top"))g_strdup_inline (((char *) g_dgettext ("ctk30", "Bottom to top" ))); |
3171 | } |
3172 | } |
3173 | |
3174 | layout = dialog_get_number_up_layout (dialog); |
3175 | |
3176 | old_option = ctk_printer_option_set_lookup (set, "ctk-n-up-layout"); |
3177 | if (old_option != NULL((void*)0)) |
3178 | ctk_printer_option_set_remove (set, old_option); |
3179 | |
3180 | if (dialog_get_pages_per_sheet (dialog) != 1) |
3181 | { |
3182 | GEnumClass *enum_class; |
3183 | GEnumValue *enum_value; |
3184 | enum_class = g_type_class_ref (CTK_TYPE_NUMBER_UP_LAYOUT(ctk_number_up_layout_get_type ())); |
3185 | |
3186 | if (dialog_get_pages_per_sheet (dialog) == 2) |
3187 | { |
3188 | option = priv->number_up_layout_2_option; |
3189 | |
3190 | switch (layout) |
3191 | { |
3192 | case CTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM: |
3193 | case CTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_LEFT_TO_RIGHT: |
3194 | enum_value = g_enum_get_value (enum_class, CTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM); |
3195 | break; |
3196 | |
3197 | case CTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_BOTTOM_TO_TOP: |
3198 | case CTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_LEFT_TO_RIGHT: |
3199 | enum_value = g_enum_get_value (enum_class, CTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_BOTTOM_TO_TOP); |
3200 | break; |
3201 | |
3202 | case CTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TO_BOTTOM: |
3203 | case CTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_RIGHT_TO_LEFT: |
3204 | enum_value = g_enum_get_value (enum_class, CTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TO_BOTTOM); |
3205 | break; |
3206 | |
3207 | case CTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_BOTTOM_TO_TOP: |
3208 | case CTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_RIGHT_TO_LEFT: |
3209 | enum_value = g_enum_get_value (enum_class, CTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_BOTTOM_TO_TOP); |
3210 | break; |
3211 | |
3212 | default: |
3213 | g_assert_not_reached()do { g_assertion_message_expr ("Ctk", "ctkprintunixdialog.c", 3213, ((const char*) (__func__)), ((void*)0)); } while (0); |
3214 | enum_value = NULL((void*)0); |
3215 | } |
3216 | } |
3217 | else |
3218 | { |
3219 | option = priv->number_up_layout_n_option; |
3220 | |
3221 | enum_value = g_enum_get_value (enum_class, layout); |
3222 | } |
3223 | |
3224 | g_assert (enum_value != NULL)do { if (enum_value != ((void*)0)) ; else g_assertion_message_expr ("Ctk", "ctkprintunixdialog.c", 3224, ((const char*) (__func__ )), "enum_value != NULL"); } while (0); |
3225 | ctk_printer_option_set (option, enum_value->value_nick); |
3226 | g_type_class_unref (enum_class); |
3227 | |
3228 | ctk_printer_option_set_add (set, option); |
3229 | } |
3230 | } |
3231 | |
3232 | setup_option (dialog, "ctk-n-up-layout", priv->number_up_layout); |
3233 | |
3234 | if (priv->number_up_layout != NULL((void*)0)) |
3235 | ctk_widget_set_sensitive (CTK_WIDGET (priv->number_up_layout)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->number_up_layout)), ((ctk_widget_get_type ()))) ))), |
3236 | (caps & CTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT) && |
3237 | (dialog_get_pages_per_sheet (dialog) > 1)); |
3238 | } |
3239 | |
3240 | static void |
3241 | custom_paper_dialog_response_cb (CtkDialog *custom_paper_dialog, |
3242 | gint response_id G_GNUC_UNUSED__attribute__ ((__unused__)), |
3243 | gpointer user_data) |
3244 | { |
3245 | CtkPrintUnixDialog *print_dialog = CTK_PRINT_UNIX_DIALOG (user_data)((((CtkPrintUnixDialog*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((user_data)), ((ctk_print_unix_dialog_get_type ())))))); |
3246 | CtkPrintUnixDialogPrivate *priv = print_dialog->priv; |
3247 | CtkTreeModel *model; |
3248 | CtkTreeIter iter; |
3249 | |
3250 | _ctk_print_load_custom_papers (priv->custom_paper_list); |
3251 | |
3252 | priv->internal_page_setup_change = TRUE(!(0)); |
3253 | update_paper_sizes (print_dialog); |
3254 | priv->internal_page_setup_change = FALSE(0); |
3255 | |
3256 | if (priv->page_setup_set) |
3257 | { |
3258 | model = CTK_TREE_MODEL (priv->custom_paper_list)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->custom_paper_list)), ((ctk_tree_model_get_type ( ))))))); |
3259 | if (ctk_tree_model_get_iter_first (model, &iter)) |
3260 | { |
3261 | do |
3262 | { |
3263 | CtkPageSetup *page_setup; |
3264 | ctk_tree_model_get (model, &iter, 0, &page_setup, -1); |
3265 | |
3266 | if (page_setup && |
3267 | g_strcmp0 (ctk_paper_size_get_display_name (ctk_page_setup_get_paper_size (page_setup)), |
3268 | ctk_paper_size_get_display_name (ctk_page_setup_get_paper_size (priv->page_setup))) == 0) |
3269 | ctk_print_unix_dialog_set_page_setup (print_dialog, page_setup); |
3270 | |
3271 | g_clear_object (&page_setup)do { _Static_assert (sizeof *((&page_setup)) == sizeof (gpointer ), "Expression evaluates to false"); __typeof__ (((&page_setup ))) _pp = ((&page_setup)); __typeof__ (*((&page_setup ))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref ) (_ptr); } while (0); |
3272 | } while (ctk_tree_model_iter_next (model, &iter)); |
3273 | } |
3274 | } |
3275 | |
3276 | ctk_widget_destroy (CTK_WIDGET (custom_paper_dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((custom_paper_dialog)), ((ctk_widget_get_type ()))))))); |
3277 | } |
3278 | |
3279 | static void |
3280 | orientation_changed (CtkComboBox *combo_box G_GNUC_UNUSED__attribute__ ((__unused__)), |
3281 | CtkPrintUnixDialog *dialog) |
3282 | { |
3283 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
3284 | CtkPageOrientation orientation; |
3285 | CtkPageSetup *page_setup; |
3286 | |
3287 | if (priv->internal_page_setup_change) |
3288 | return; |
3289 | |
3290 | orientation = (CtkPageOrientation) ctk_combo_box_get_active (CTK_COMBO_BOX (priv->orientation_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->orientation_combo)), ((ctk_combo_box_get_type ( )))))))); |
3291 | |
3292 | if (priv->page_setup) |
3293 | { |
3294 | page_setup = ctk_page_setup_copy (priv->page_setup); |
3295 | if (page_setup) |
3296 | ctk_page_setup_set_orientation (page_setup, orientation); |
3297 | |
3298 | ctk_print_unix_dialog_set_page_setup (dialog, page_setup); |
3299 | } |
3300 | |
3301 | redraw_page_layout_preview (dialog); |
3302 | } |
3303 | |
3304 | static void |
3305 | paper_size_changed (CtkComboBox *combo_box, |
3306 | CtkPrintUnixDialog *dialog) |
3307 | { |
3308 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
3309 | CtkTreeIter iter; |
3310 | CtkPageSetup *page_setup, *last_page_setup; |
3311 | CtkPageOrientation orientation; |
3312 | |
3313 | if (priv->internal_page_setup_change) |
3314 | return; |
3315 | |
3316 | if (ctk_combo_box_get_active_iter (combo_box, &iter)) |
3317 | { |
3318 | ctk_tree_model_get (ctk_combo_box_get_model (combo_box), |
3319 | &iter, PAGE_SETUP_LIST_COL_PAGE_SETUP, &page_setup, |
3320 | -1); |
3321 | |
3322 | if (page_setup == NULL((void*)0)) |
3323 | { |
3324 | CtkWidget *custom_paper_dialog; |
3325 | |
3326 | /* Change from "manage" menu item to last value */ |
3327 | if (priv->page_setup) |
3328 | last_page_setup = g_object_ref (priv->page_setup)((__typeof__ (priv->page_setup)) (g_object_ref) (priv-> page_setup)); |
3329 | else |
3330 | last_page_setup = ctk_page_setup_new (); /* "good" default */ |
3331 | |
3332 | if (!set_paper_size (dialog, last_page_setup, FALSE(0), FALSE(0))) |
3333 | set_paper_size (dialog, last_page_setup, TRUE(!(0)), TRUE(!(0))); |
3334 | g_object_unref (last_page_setup); |
3335 | |
3336 | /* And show the custom paper dialog */ |
3337 | custom_paper_dialog = _ctk_custom_paper_unix_dialog_new (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), _("Manage Custom Sizes")((char *) g_dgettext ("ctk30", "Manage Custom Sizes"))); |
3338 | g_signal_connect (custom_paper_dialog, "response", G_CALLBACK (custom_paper_dialog_response_cb), dialog)g_signal_connect_data ((custom_paper_dialog), ("response"), ( ((GCallback) (custom_paper_dialog_response_cb))), (dialog), ( (void*)0), (GConnectFlags) 0); |
3339 | ctk_window_present (CTK_WINDOW (custom_paper_dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((custom_paper_dialog)), ((ctk_window_get_type ()))))))); |
3340 | |
3341 | return; |
3342 | } |
3343 | |
3344 | if (priv->page_setup) |
3345 | orientation = ctk_page_setup_get_orientation (priv->page_setup); |
3346 | else |
3347 | orientation = CTK_PAGE_ORIENTATION_PORTRAIT; |
3348 | |
3349 | ctk_page_setup_set_orientation (page_setup, orientation); |
3350 | ctk_print_unix_dialog_set_page_setup (dialog, page_setup); |
3351 | |
3352 | g_object_unref (page_setup); |
3353 | } |
3354 | |
3355 | redraw_page_layout_preview (dialog); |
3356 | } |
3357 | |
3358 | static gboolean |
3359 | paper_size_row_is_separator (CtkTreeModel *model, |
3360 | CtkTreeIter *iter, |
3361 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
3362 | { |
3363 | gboolean separator; |
3364 | |
3365 | ctk_tree_model_get (model, iter, |
3366 | PAGE_SETUP_LIST_COL_IS_SEPARATOR, &separator, |
3367 | -1); |
3368 | return separator; |
3369 | } |
3370 | |
3371 | static void |
3372 | page_name_func (CtkCellLayout *cell_layout G_GNUC_UNUSED__attribute__ ((__unused__)), |
3373 | CtkCellRenderer *cell, |
3374 | CtkTreeModel *tree_model, |
3375 | CtkTreeIter *iter, |
3376 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
3377 | { |
3378 | CtkPageSetup *page_setup; |
3379 | CtkPaperSize *paper_size; |
3380 | |
3381 | ctk_tree_model_get (tree_model, iter, |
3382 | PAGE_SETUP_LIST_COL_PAGE_SETUP, &page_setup, |
3383 | -1); |
3384 | if (page_setup) |
3385 | { |
3386 | paper_size = ctk_page_setup_get_paper_size (page_setup); |
3387 | g_object_set (cell, "text", ctk_paper_size_get_display_name (paper_size), NULL((void*)0)); |
3388 | g_object_unref (page_setup); |
3389 | } |
3390 | else |
3391 | g_object_set (cell, "text", _("Manage Custom Sizes…")((char *) g_dgettext ("ctk30", "Manage Custom Sizes…")), NULL((void*)0)); |
3392 | } |
3393 | |
3394 | /** |
3395 | * ctk_print_unix_dialog_new: |
3396 | * @title: (allow-none): Title of the dialog, or %NULL |
3397 | * @parent: (allow-none): Transient parent of the dialog, or %NULL |
3398 | * |
3399 | * Creates a new #CtkPrintUnixDialog. |
3400 | * |
3401 | * Returns: a new #CtkPrintUnixDialog |
3402 | * |
3403 | * Since: 2.10 |
3404 | */ |
3405 | CtkWidget * |
3406 | ctk_print_unix_dialog_new (const gchar *title, |
3407 | CtkWindow *parent) |
3408 | { |
3409 | CtkWidget *result; |
3410 | |
3411 | result = g_object_new (CTK_TYPE_PRINT_UNIX_DIALOG(ctk_print_unix_dialog_get_type ()), |
3412 | "transient-for", parent, |
3413 | "title", title ? title : _("Print")((char *) g_dgettext ("ctk30", "Print")), |
3414 | NULL((void*)0)); |
3415 | |
3416 | return result; |
3417 | } |
3418 | |
3419 | /** |
3420 | * ctk_print_unix_dialog_get_selected_printer: |
3421 | * @dialog: a #CtkPrintUnixDialog |
3422 | * |
3423 | * Gets the currently selected printer. |
3424 | * |
3425 | * Returns: (transfer none): the currently selected printer |
3426 | * |
3427 | * Since: 2.10 |
3428 | */ |
3429 | CtkPrinter * |
3430 | ctk_print_unix_dialog_get_selected_printer (CtkPrintUnixDialog *dialog) |
3431 | { |
3432 | g_return_val_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return (((void*)0)); } } while (0); |
3433 | |
3434 | return dialog->priv->current_printer; |
3435 | } |
3436 | |
3437 | /** |
3438 | * ctk_print_unix_dialog_set_page_setup: |
3439 | * @dialog: a #CtkPrintUnixDialog |
3440 | * @page_setup: a #CtkPageSetup |
3441 | * |
3442 | * Sets the page setup of the #CtkPrintUnixDialog. |
3443 | * |
3444 | * Since: 2.10 |
3445 | */ |
3446 | void |
3447 | ctk_print_unix_dialog_set_page_setup (CtkPrintUnixDialog *dialog, |
3448 | CtkPageSetup *page_setup) |
3449 | { |
3450 | CtkPrintUnixDialogPrivate *priv; |
3451 | |
3452 | g_return_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return ; } } while (0); |
3453 | g_return_if_fail (CTK_IS_PAGE_SETUP (page_setup))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((page_setup)); GType __t = ((ctk_page_setup_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_PAGE_SETUP (page_setup)"); return; } } while (0); |
3454 | |
3455 | priv = dialog->priv; |
3456 | |
3457 | if (priv->page_setup != page_setup) |
3458 | { |
3459 | g_clear_object (&priv->page_setup)do { _Static_assert (sizeof *((&priv->page_setup)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ ((( &priv->page_setup))) _pp = ((&priv->page_setup) ); __typeof__ (*((&priv->page_setup))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
3460 | priv->page_setup = g_object_ref (page_setup)((__typeof__ (page_setup)) (g_object_ref) (page_setup)); |
3461 | |
3462 | priv->page_setup_set = TRUE(!(0)); |
3463 | |
3464 | g_object_notify (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "page-setup"); |
3465 | } |
3466 | } |
3467 | |
3468 | /** |
3469 | * ctk_print_unix_dialog_get_page_setup: |
3470 | * @dialog: a #CtkPrintUnixDialog |
3471 | * |
3472 | * Gets the page setup that is used by the #CtkPrintUnixDialog. |
3473 | * |
3474 | * Returns: (transfer none): the page setup of @dialog. |
3475 | * |
3476 | * Since: 2.10 |
3477 | */ |
3478 | CtkPageSetup * |
3479 | ctk_print_unix_dialog_get_page_setup (CtkPrintUnixDialog *dialog) |
3480 | { |
3481 | g_return_val_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return (((void*)0)); } } while (0); |
3482 | |
3483 | return dialog->priv->page_setup; |
3484 | } |
3485 | |
3486 | /** |
3487 | * ctk_print_unix_dialog_get_page_setup_set: |
3488 | * @dialog: a #CtkPrintUnixDialog |
3489 | * |
3490 | * Gets the page setup that is used by the #CtkPrintUnixDialog. |
3491 | * |
3492 | * Returns: whether a page setup was set by user. |
3493 | * |
3494 | * Since: 2.18 |
3495 | */ |
3496 | gboolean |
3497 | ctk_print_unix_dialog_get_page_setup_set (CtkPrintUnixDialog *dialog) |
3498 | { |
3499 | g_return_val_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return ((0)); } } while (0); |
3500 | |
3501 | return dialog->priv->page_setup_set; |
3502 | } |
3503 | |
3504 | /** |
3505 | * ctk_print_unix_dialog_set_current_page: |
3506 | * @dialog: a #CtkPrintUnixDialog |
3507 | * @current_page: the current page number. |
3508 | * |
3509 | * Sets the current page number. If @current_page is not -1, this enables |
3510 | * the current page choice for the range of pages to print. |
3511 | * |
3512 | * Since: 2.10 |
3513 | */ |
3514 | void |
3515 | ctk_print_unix_dialog_set_current_page (CtkPrintUnixDialog *dialog, |
3516 | gint current_page) |
3517 | { |
3518 | CtkPrintUnixDialogPrivate *priv; |
3519 | |
3520 | g_return_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return ; } } while (0); |
3521 | |
3522 | priv = dialog->priv; |
3523 | |
3524 | if (priv->current_page != current_page) |
3525 | { |
3526 | priv->current_page = current_page; |
3527 | |
3528 | if (priv->current_page_radio) |
3529 | ctk_widget_set_sensitive (priv->current_page_radio, current_page != -1); |
3530 | |
3531 | g_object_notify (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "current-page"); |
3532 | } |
3533 | } |
3534 | |
3535 | /** |
3536 | * ctk_print_unix_dialog_get_current_page: |
3537 | * @dialog: a #CtkPrintUnixDialog |
3538 | * |
3539 | * Gets the current page of the #CtkPrintUnixDialog. |
3540 | * |
3541 | * Returns: the current page of @dialog |
3542 | * |
3543 | * Since: 2.10 |
3544 | */ |
3545 | gint |
3546 | ctk_print_unix_dialog_get_current_page (CtkPrintUnixDialog *dialog) |
3547 | { |
3548 | g_return_val_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return (-1); } } while (0); |
3549 | |
3550 | return dialog->priv->current_page; |
3551 | } |
3552 | |
3553 | static gboolean |
3554 | set_active_printer (CtkPrintUnixDialog *dialog, |
3555 | const gchar *printer_name) |
3556 | { |
3557 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
3558 | CtkTreeModel *model; |
3559 | CtkTreeIter iter, filter_iter; |
3560 | CtkTreeSelection *selection; |
3561 | CtkPrinter *printer; |
3562 | |
3563 | model = CTK_TREE_MODEL (priv->printer_list)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_list)), ((ctk_tree_model_get_type ()))) ))); |
3564 | |
3565 | if (ctk_tree_model_get_iter_first (model, &iter)) |
3566 | { |
3567 | do |
3568 | { |
3569 | ctk_tree_model_get (CTK_TREE_MODEL (priv->printer_list)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_list)), ((ctk_tree_model_get_type ()))) ))), &iter, |
3570 | PRINTER_LIST_COL_PRINTER_OBJ, &printer, |
3571 | -1); |
3572 | if (printer == NULL((void*)0)) |
3573 | continue; |
3574 | |
3575 | if (strcmp (ctk_printer_get_name (printer), printer_name) == 0) |
3576 | { |
3577 | ctk_tree_model_filter_convert_child_iter_to_iter (priv->printer_list_filter, |
3578 | &filter_iter, &iter); |
3579 | |
3580 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (priv->printer_treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_treeview)), ((ctk_tree_view_get_type () ))))))); |
3581 | priv->internal_printer_change = TRUE(!(0)); |
3582 | ctk_tree_selection_select_iter (selection, &filter_iter); |
3583 | priv->internal_printer_change = FALSE(0); |
3584 | g_free (priv->waiting_for_printer); |
3585 | priv->waiting_for_printer = NULL((void*)0); |
3586 | |
3587 | g_object_unref (printer); |
3588 | return TRUE(!(0)); |
3589 | } |
3590 | |
3591 | g_object_unref (printer); |
3592 | |
3593 | } while (ctk_tree_model_iter_next (model, &iter)); |
3594 | } |
3595 | |
3596 | return FALSE(0); |
3597 | } |
3598 | |
3599 | /** |
3600 | * ctk_print_unix_dialog_set_settings: |
3601 | * @dialog: a #CtkPrintUnixDialog |
3602 | * @settings: (allow-none): a #CtkPrintSettings, or %NULL |
3603 | * |
3604 | * Sets the #CtkPrintSettings for the #CtkPrintUnixDialog. Typically, |
3605 | * this is used to restore saved print settings from a previous print |
3606 | * operation before the print dialog is shown. |
3607 | * |
3608 | * Since: 2.10 |
3609 | **/ |
3610 | void |
3611 | ctk_print_unix_dialog_set_settings (CtkPrintUnixDialog *dialog, |
3612 | CtkPrintSettings *settings) |
3613 | { |
3614 | CtkPrintUnixDialogPrivate *priv; |
3615 | const gchar *printer; |
3616 | CtkPageRange *ranges; |
3617 | gint num_ranges; |
3618 | |
3619 | g_return_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return ; } } while (0); |
3620 | g_return_if_fail (settings == NULL || CTK_IS_PRINT_SETTINGS (settings))do { if ((settings == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((settings)); GType __t = ((ctk_print_settings_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "settings == NULL || CTK_IS_PRINT_SETTINGS (settings)" ); return; } } while (0); |
3621 | |
3622 | priv = dialog->priv; |
3623 | |
3624 | if (settings != NULL((void*)0)) |
3625 | { |
3626 | dialog_set_collate (dialog, ctk_print_settings_get_collate (settings)); |
3627 | dialog_set_reverse (dialog, ctk_print_settings_get_reverse (settings)); |
3628 | dialog_set_n_copies (dialog, ctk_print_settings_get_n_copies (settings)); |
3629 | dialog_set_scale (dialog, ctk_print_settings_get_scale (settings)); |
3630 | dialog_set_page_set (dialog, ctk_print_settings_get_page_set (settings)); |
3631 | dialog_set_print_pages (dialog, ctk_print_settings_get_print_pages (settings)); |
3632 | ranges = ctk_print_settings_get_page_ranges (settings, &num_ranges); |
3633 | if (ranges) |
3634 | { |
3635 | dialog_set_page_ranges (dialog, ranges, num_ranges); |
3636 | g_free (ranges); |
3637 | } |
3638 | |
3639 | priv->format_for_printer = |
3640 | g_strdup (ctk_print_settings_get (settings, "format-for-printer"))g_strdup_inline (ctk_print_settings_get (settings, "format-for-printer" )); |
3641 | } |
3642 | |
3643 | if (priv->initial_settings) |
3644 | g_object_unref (priv->initial_settings); |
3645 | |
3646 | priv->initial_settings = settings; |
3647 | |
3648 | g_free (priv->waiting_for_printer); |
3649 | priv->waiting_for_printer = NULL((void*)0); |
3650 | |
3651 | if (settings) |
3652 | { |
3653 | g_object_ref (settings)((__typeof__ (settings)) (g_object_ref) (settings)); |
3654 | |
3655 | printer = ctk_print_settings_get_printer (settings); |
3656 | |
3657 | if (printer && !set_active_printer (dialog, printer)) |
3658 | priv->waiting_for_printer = g_strdup (printer)g_strdup_inline (printer); |
3659 | } |
3660 | |
3661 | g_object_notify (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "print-settings"); |
3662 | } |
3663 | |
3664 | /** |
3665 | * ctk_print_unix_dialog_get_settings: |
3666 | * @dialog: a #CtkPrintUnixDialog |
3667 | * |
3668 | * Gets a new #CtkPrintSettings object that represents the |
3669 | * current values in the print dialog. Note that this creates a |
3670 | * new object, and you need to unref it |
3671 | * if don’t want to keep it. |
3672 | * |
3673 | * Returns: a new #CtkPrintSettings object with the values from @dialog |
3674 | * |
3675 | * Since: 2.10 |
3676 | */ |
3677 | CtkPrintSettings * |
3678 | ctk_print_unix_dialog_get_settings (CtkPrintUnixDialog *dialog) |
3679 | { |
3680 | CtkPrintUnixDialogPrivate *priv; |
3681 | CtkPrintSettings *settings; |
3682 | CtkPrintPages print_pages; |
3683 | CtkPageRange *ranges; |
3684 | gint n_ranges; |
3685 | |
3686 | g_return_val_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return (((void*)0)); } } while (0); |
3687 | |
3688 | priv = dialog->priv; |
3689 | settings = ctk_print_settings_new (); |
3690 | |
3691 | if (priv->current_printer) |
3692 | ctk_print_settings_set_printer (settings, |
3693 | ctk_printer_get_name (priv->current_printer)); |
3694 | else |
3695 | ctk_print_settings_set_printer (settings, "default"); |
3696 | |
3697 | ctk_print_settings_set (settings, "format-for-printer", |
3698 | priv->format_for_printer); |
3699 | |
3700 | ctk_print_settings_set_collate (settings, |
3701 | dialog_get_collate (dialog)); |
3702 | |
3703 | ctk_print_settings_set_reverse (settings, |
3704 | dialog_get_reverse (dialog)); |
3705 | |
3706 | ctk_print_settings_set_n_copies (settings, |
3707 | dialog_get_n_copies (dialog)); |
3708 | |
3709 | ctk_print_settings_set_scale (settings, |
3710 | dialog_get_scale (dialog)); |
3711 | |
3712 | ctk_print_settings_set_page_set (settings, |
3713 | dialog_get_page_set (dialog)); |
3714 | |
3715 | print_pages = dialog_get_print_pages (dialog); |
3716 | ctk_print_settings_set_print_pages (settings, print_pages); |
3717 | |
3718 | ranges = dialog_get_page_ranges (dialog, &n_ranges); |
3719 | if (ranges) |
3720 | { |
3721 | ctk_print_settings_set_page_ranges (settings, ranges, n_ranges); |
3722 | g_free (ranges); |
3723 | } |
3724 | |
3725 | /* TODO: print when. How to handle? */ |
3726 | |
3727 | if (priv->current_printer) |
3728 | _ctk_printer_get_settings_from_options (priv->current_printer, |
3729 | priv->options, |
3730 | settings); |
3731 | |
3732 | return settings; |
3733 | } |
3734 | |
3735 | /** |
3736 | * ctk_print_unix_dialog_add_custom_tab: |
3737 | * @dialog: a #CtkPrintUnixDialog |
3738 | * @child: the widget to put in the custom tab |
3739 | * @tab_label: the widget to use as tab label |
3740 | * |
3741 | * Adds a custom tab to the print dialog. |
3742 | * |
3743 | * Since: 2.10 |
3744 | */ |
3745 | void |
3746 | ctk_print_unix_dialog_add_custom_tab (CtkPrintUnixDialog *dialog, |
3747 | CtkWidget *child, |
3748 | CtkWidget *tab_label) |
3749 | { |
3750 | ctk_notebook_insert_page (CTK_NOTEBOOK (dialog->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->priv->notebook)), ((ctk_notebook_get_type ( ))))))), |
3751 | child, tab_label, 2); |
3752 | ctk_widget_show (child); |
3753 | ctk_widget_show (tab_label); |
3754 | } |
3755 | |
3756 | /** |
3757 | * ctk_print_unix_dialog_set_manual_capabilities: |
3758 | * @dialog: a #CtkPrintUnixDialog |
3759 | * @capabilities: the printing capabilities of your application |
3760 | * |
3761 | * This lets you specify the printing capabilities your application |
3762 | * supports. For instance, if you can handle scaling the output then |
3763 | * you pass #CTK_PRINT_CAPABILITY_SCALE. If you don’t pass that, then |
3764 | * the dialog will only let you select the scale if the printing |
3765 | * system automatically handles scaling. |
3766 | * |
3767 | * Since: 2.10 |
3768 | */ |
3769 | void |
3770 | ctk_print_unix_dialog_set_manual_capabilities (CtkPrintUnixDialog *dialog, |
3771 | CtkPrintCapabilities capabilities) |
3772 | { |
3773 | CtkPrintUnixDialogPrivate *priv = dialog->priv; |
3774 | |
3775 | if (priv->manual_capabilities != capabilities) |
3776 | { |
3777 | priv->manual_capabilities = capabilities; |
3778 | update_dialog_from_capabilities (dialog); |
3779 | |
3780 | if (priv->current_printer) |
3781 | { |
3782 | CtkTreeSelection *selection; |
3783 | |
3784 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (priv->printer_treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->printer_treeview)), ((ctk_tree_view_get_type () ))))))); |
3785 | g_clear_object (&priv->current_printer)do { _Static_assert (sizeof *((&priv->current_printer) ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&priv->current_printer))) _pp = ((&priv->current_printer )); __typeof__ (*((&priv->current_printer))) _ptr = *_pp ; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
3786 | priv->internal_printer_change = TRUE(!(0)); |
3787 | selected_printer_changed (selection, dialog); |
3788 | priv->internal_printer_change = FALSE(0); |
3789 | } |
3790 | |
3791 | g_object_notify (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "manual-capabilities"); |
3792 | } |
3793 | } |
3794 | |
3795 | /** |
3796 | * ctk_print_unix_dialog_get_manual_capabilities: |
3797 | * @dialog: a #CtkPrintUnixDialog |
3798 | * |
3799 | * Gets the value of #CtkPrintUnixDialog:manual-capabilities property. |
3800 | * |
3801 | * Returns: the printing capabilities |
3802 | * |
3803 | * Since: 2.18 |
3804 | */ |
3805 | CtkPrintCapabilities |
3806 | ctk_print_unix_dialog_get_manual_capabilities (CtkPrintUnixDialog *dialog) |
3807 | { |
3808 | g_return_val_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return ((0)); } } while (0); |
3809 | |
3810 | return dialog->priv->manual_capabilities; |
3811 | } |
3812 | |
3813 | /** |
3814 | * ctk_print_unix_dialog_set_support_selection: |
3815 | * @dialog: a #CtkPrintUnixDialog |
3816 | * @support_selection: %TRUE to allow print selection |
3817 | * |
3818 | * Sets whether the print dialog allows user to print a selection. |
3819 | * |
3820 | * Since: 2.18 |
3821 | */ |
3822 | void |
3823 | ctk_print_unix_dialog_set_support_selection (CtkPrintUnixDialog *dialog, |
3824 | gboolean support_selection) |
3825 | { |
3826 | CtkPrintUnixDialogPrivate *priv; |
3827 | |
3828 | g_return_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return ; } } while (0); |
3829 | |
3830 | priv = dialog->priv; |
3831 | |
3832 | support_selection = support_selection != FALSE(0); |
3833 | if (priv->support_selection != support_selection) |
3834 | { |
3835 | priv->support_selection = support_selection; |
3836 | |
3837 | if (priv->selection_radio) |
3838 | { |
3839 | if (support_selection) |
3840 | { |
3841 | ctk_widget_set_sensitive (priv->selection_radio, priv->has_selection); |
3842 | ctk_widget_show (priv->selection_radio); |
3843 | } |
3844 | else |
3845 | { |
3846 | ctk_widget_set_sensitive (priv->selection_radio, FALSE(0)); |
3847 | ctk_widget_hide (priv->selection_radio); |
3848 | } |
3849 | } |
3850 | |
3851 | g_object_notify (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "support-selection"); |
3852 | } |
3853 | } |
3854 | |
3855 | /** |
3856 | * ctk_print_unix_dialog_get_support_selection: |
3857 | * @dialog: a #CtkPrintUnixDialog |
3858 | * |
3859 | * Gets the value of #CtkPrintUnixDialog:support-selection property. |
3860 | * |
3861 | * Returns: whether the application supports print of selection |
3862 | * |
3863 | * Since: 2.18 |
3864 | */ |
3865 | gboolean |
3866 | ctk_print_unix_dialog_get_support_selection (CtkPrintUnixDialog *dialog) |
3867 | { |
3868 | g_return_val_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return ((0)); } } while (0); |
3869 | |
3870 | return dialog->priv->support_selection; |
3871 | } |
3872 | |
3873 | /** |
3874 | * ctk_print_unix_dialog_set_has_selection: |
3875 | * @dialog: a #CtkPrintUnixDialog |
3876 | * @has_selection: %TRUE indicates that a selection exists |
3877 | * |
3878 | * Sets whether a selection exists. |
3879 | * |
3880 | * Since: 2.18 |
3881 | */ |
3882 | void |
3883 | ctk_print_unix_dialog_set_has_selection (CtkPrintUnixDialog *dialog, |
3884 | gboolean has_selection) |
3885 | { |
3886 | CtkPrintUnixDialogPrivate *priv; |
3887 | |
3888 | g_return_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return ; } } while (0); |
3889 | |
3890 | priv = dialog->priv; |
3891 | |
3892 | has_selection = has_selection != FALSE(0); |
3893 | if (priv->has_selection != has_selection) |
3894 | { |
3895 | priv->has_selection = has_selection; |
3896 | |
3897 | if (priv->selection_radio) |
3898 | { |
3899 | if (priv->support_selection) |
3900 | ctk_widget_set_sensitive (priv->selection_radio, has_selection); |
3901 | else |
3902 | ctk_widget_set_sensitive (priv->selection_radio, FALSE(0)); |
3903 | } |
3904 | |
3905 | g_object_notify (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "has-selection"); |
3906 | } |
3907 | } |
3908 | |
3909 | /** |
3910 | * ctk_print_unix_dialog_get_has_selection: |
3911 | * @dialog: a #CtkPrintUnixDialog |
3912 | * |
3913 | * Gets the value of #CtkPrintUnixDialog:has-selection property. |
3914 | * |
3915 | * Returns: whether there is a selection |
3916 | * |
3917 | * Since: 2.18 |
3918 | */ |
3919 | gboolean |
3920 | ctk_print_unix_dialog_get_has_selection (CtkPrintUnixDialog *dialog) |
3921 | { |
3922 | g_return_val_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return ((0)); } } while (0); |
3923 | |
3924 | return dialog->priv->has_selection; |
3925 | } |
3926 | |
3927 | /** |
3928 | * ctk_print_unix_dialog_set_embed_page_setup |
3929 | * @dialog: a #CtkPrintUnixDialog |
3930 | * @embed: embed page setup selection |
3931 | * |
3932 | * Embed page size combo box and orientation combo box into page setup page. |
3933 | * |
3934 | * Since: 2.18 |
3935 | */ |
3936 | void |
3937 | ctk_print_unix_dialog_set_embed_page_setup (CtkPrintUnixDialog *dialog, |
3938 | gboolean embed) |
3939 | { |
3940 | CtkPrintUnixDialogPrivate *priv; |
3941 | |
3942 | g_return_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return ; } } while (0); |
3943 | |
3944 | priv = dialog->priv; |
3945 | |
3946 | embed = embed != FALSE(0); |
3947 | if (priv->embed_page_setup != embed) |
3948 | { |
3949 | priv->embed_page_setup = embed; |
3950 | |
3951 | ctk_widget_set_sensitive (priv->paper_size_combo, priv->embed_page_setup); |
3952 | ctk_widget_set_sensitive (priv->orientation_combo, priv->embed_page_setup); |
3953 | |
3954 | if (priv->embed_page_setup) |
3955 | { |
3956 | if (priv->paper_size_combo != NULL((void*)0)) |
3957 | g_signal_connect (priv->paper_size_combo, "changed", G_CALLBACK (paper_size_changed), dialog)g_signal_connect_data ((priv->paper_size_combo), ("changed" ), (((GCallback) (paper_size_changed))), (dialog), ((void*)0) , (GConnectFlags) 0); |
3958 | |
3959 | if (priv->orientation_combo) |
3960 | g_signal_connect (priv->orientation_combo, "changed", G_CALLBACK (orientation_changed), dialog)g_signal_connect_data ((priv->orientation_combo), ("changed" ), (((GCallback) (orientation_changed))), (dialog), ((void*)0 ), (GConnectFlags) 0); |
3961 | } |
3962 | else |
3963 | { |
3964 | if (priv->paper_size_combo != NULL((void*)0)) |
3965 | g_signal_handlers_disconnect_by_func (priv->paper_size_combo, G_CALLBACK (paper_size_changed), dialog)g_signal_handlers_disconnect_matched ((priv->paper_size_combo ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (((GCallback) (paper_size_changed))), (dialog )); |
3966 | |
3967 | if (priv->orientation_combo) |
3968 | g_signal_handlers_disconnect_by_func (priv->orientation_combo, G_CALLBACK (orientation_changed), dialog)g_signal_handlers_disconnect_matched ((priv->orientation_combo ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (((GCallback) (orientation_changed))), ( dialog)); |
3969 | } |
3970 | |
3971 | priv->internal_page_setup_change = TRUE(!(0)); |
3972 | update_paper_sizes (dialog); |
3973 | priv->internal_page_setup_change = FALSE(0); |
3974 | } |
3975 | } |
3976 | |
3977 | /** |
3978 | * ctk_print_unix_dialog_get_embed_page_setup: |
3979 | * @dialog: a #CtkPrintUnixDialog |
3980 | * |
3981 | * Gets the value of #CtkPrintUnixDialog:embed-page-setup property. |
3982 | * |
3983 | * Returns: whether there is a selection |
3984 | * |
3985 | * Since: 2.18 |
3986 | */ |
3987 | gboolean |
3988 | ctk_print_unix_dialog_get_embed_page_setup (CtkPrintUnixDialog *dialog) |
3989 | { |
3990 | g_return_val_if_fail (CTK_IS_PRINT_UNIX_DIALOG (dialog), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((dialog)); GType __t = ((ctk_print_unix_dialog_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_PRINT_UNIX_DIALOG (dialog)"); return ((0)); } } while (0); |
3991 | |
3992 | return dialog->priv->embed_page_setup; |
3993 | } |