Bug Summary

File:tests/print-editor.c
Warning:line 1009, column 8
This statement is never executed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name print-editor.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/tests -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -I .. -I ../cdk -I ../cdk -D G_ENABLE_DEBUG -D G_ENABLE_CONSISTENCY_CHECKS -D GLIB_MIN_REQUIRED_VERSION=GLIB_VERSION_2_66 -D GLIB_MAX_ALLOWED_VERSION=GLIB_VERSION_2_66 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/atk-1.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/gio-unix-2.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/pango-1.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/tests -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-09-19-172619-43637-1 -x c print-editor.c
1#include <math.h>
2#include <pango/pangocairo.h>
3#include <ctk/ctk.h>
4
5static CtkWidget *main_window;
6static char *filename = NULL((void*)0);
7static CtkPageSetup *page_setup = NULL((void*)0);
8static CtkPrintSettings *settings = NULL((void*)0);
9static gboolean file_changed = FALSE(0);
10static CtkTextBuffer *buffer;
11static CtkWidget *statusbar;
12static GList *active_prints = NULL((void*)0);
13
14static void
15update_title (CtkWindow *window)
16{
17 char *basename;
18 char *title;
19
20 if (filename == NULL((void*)0))
21 basename = g_strdup ("Untitled")g_strdup_inline ("Untitled");
22 else
23 basename = g_path_get_basename (filename);
24
25 title = g_strdup_printf ("Simple Editor with printing - %s", basename);
26 g_free (basename);
27
28 ctk_window_set_title (window, title);
29 g_free (title);
30}
31
32static void
33update_statusbar (void)
34{
35 gchar *msg;
36 gint row, col;
37 CtkTextIter iter;
38 const char *print_str;
39
40 ctk_statusbar_pop (CTK_STATUSBAR (statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((statusbar)), ((ctk_statusbar_get_type ()))))))
, 0);
41
42 ctk_text_buffer_get_iter_at_mark (buffer,
43 &iter,
44 ctk_text_buffer_get_insert (buffer));
45
46 row = ctk_text_iter_get_line (&iter);
47 col = ctk_text_iter_get_line_offset (&iter);
48
49 print_str = "";
50 if (active_prints)
51 {
52 CtkPrintOperation *op = active_prints->data;
53 print_str = ctk_print_operation_get_status_string (op);
54 }
55
56 msg = g_strdup_printf ("%d, %d%s %s",
57 row, col,
58 file_changed?" - Modified":"",
59 print_str);
60
61 ctk_statusbar_push (CTK_STATUSBAR (statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((statusbar)), ((ctk_statusbar_get_type ()))))))
, 0, msg);
62
63 g_free (msg);
64}
65
66static void
67update_ui (void)
68{
69 update_title (CTK_WINDOW (main_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_window_get_type ()))))))
);
70 update_statusbar ();
71}
72
73static char *
74get_text (void)
75{
76 CtkTextIter start, end;
77
78 ctk_text_buffer_get_start_iter (buffer, &start);
79 ctk_text_buffer_get_end_iter (buffer, &end);
80 return ctk_text_buffer_get_text (buffer, &start, &end, FALSE(0));
81}
82
83static void
84set_text (const char *text, gsize len)
85{
86 ctk_text_buffer_set_text (buffer, text, len);
87 file_changed = FALSE(0);
88 update_ui ();
89}
90
91static void
92load_file (const char *open_filename)
93{
94 CtkWidget *error_dialog;
95 char *contents;
96 GError *error;
97 gsize len;
98
99 error_dialog = NULL((void*)0);
100 error = NULL((void*)0);
101 if (g_file_get_contents (open_filename, &contents, &len, &error))
102 {
103 if (g_utf8_validate (contents, len, NULL((void*)0)))
104 {
105 filename = g_strdup (open_filename)g_strdup_inline (open_filename);
106 set_text (contents, len);
107 g_free (contents);
108 }
109 else
110 {
111 error_dialog = ctk_message_dialog_new (CTK_WINDOW (main_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_window_get_type ()))))))
,
112 CTK_DIALOG_DESTROY_WITH_PARENT,
113 CTK_MESSAGE_ERROR,
114 CTK_BUTTONS_CLOSE,
115 "Error loading file %s:\n%s",
116 open_filename,
117 "Not valid utf8");
118 }
119 }
120 else
121 {
122 error_dialog = ctk_message_dialog_new (CTK_WINDOW (main_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_window_get_type ()))))))
,
123 CTK_DIALOG_DESTROY_WITH_PARENT,
124 CTK_MESSAGE_ERROR,
125 CTK_BUTTONS_CLOSE,
126 "Error loading file %s:\n%s",
127 open_filename,
128 error->message);
129
130 g_error_free (error);
131 }
132 if (error_dialog)
133 {
134 g_signal_connect (error_dialog, "response", G_CALLBACK (ctk_widget_destroy), NULL)g_signal_connect_data ((error_dialog), ("response"), (((GCallback
) (ctk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
135 ctk_widget_show (error_dialog);
136 }
137}
138
139
140static void
141save_file (const char *save_filename)
142{
143 char *text = get_text ();
144 GError *error;
145
146 error = NULL((void*)0);
147 if (g_file_set_contents (save_filename,
148 text, -1, &error))
149 {
150 if (save_filename != filename)
151 {
152 g_free (filename);
153 filename = g_strdup (save_filename)g_strdup_inline (save_filename);
154 }
155 file_changed = FALSE(0);
156 update_ui ();
157 }
158 else
159 {
160 CtkWidget *error_dialog;
161
162 error_dialog = ctk_message_dialog_new (CTK_WINDOW (main_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_window_get_type ()))))))
,
163 CTK_DIALOG_DESTROY_WITH_PARENT,
164 CTK_MESSAGE_ERROR,
165 CTK_BUTTONS_CLOSE,
166 "Error saving to file %s:\n%s",
167 filename,
168 error->message);
169
170 g_signal_connect (error_dialog, "response", G_CALLBACK (ctk_widget_destroy), NULL)g_signal_connect_data ((error_dialog), ("response"), (((GCallback
) (ctk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
171 ctk_widget_show (error_dialog);
172
173 g_error_free (error);
174 }
175}
176
177
178typedef struct {
179 char *text;
180 PangoLayout *layout;
181 GList *page_breaks;
182 CtkWidget *font_button;
183 char *font;
184} PrintData;
185
186static void
187begin_print (CtkPrintOperation *operation,
188 CtkPrintContext *context,
189 PrintData *print_data)
190{
191 PangoFontDescription *desc;
192 double width, height;
193 double page_height;
194 GList *page_breaks;
195 int num_lines;
196 int line;
197
198 width = ctk_print_context_get_width (context);
199 height = ctk_print_context_get_height (context);
200
201 print_data->layout = ctk_print_context_create_pango_layout (context);
202
203 desc = pango_font_description_from_string (print_data->font);
204 pango_layout_set_font_description (print_data->layout, desc);
205 pango_font_description_free (desc);
206
207 pango_layout_set_width (print_data->layout, width * PANGO_SCALE1024);
208
209 pango_layout_set_text (print_data->layout, print_data->text, -1);
210
211 num_lines = pango_layout_get_line_count (print_data->layout);
212
213 page_breaks = NULL((void*)0);
214 page_height = 0;
215
216 for (line = 0; line < num_lines; line++)
217 {
218 PangoLayoutLine *layout_line;
219 PangoRectangle ink_rect, logical_rect;
220 double line_height;
221
222 layout_line = pango_layout_get_line (print_data->layout, line);
223 pango_layout_line_get_extents (layout_line, &ink_rect, &logical_rect);
224
225 line_height = logical_rect.height / 1024.0;
226
227 if (page_height + line_height > height)
228 {
229 page_breaks = g_list_prepend (page_breaks, GINT_TO_POINTER (line)((gpointer) (glong) (line)));
230 page_height = 0;
231 }
232
233 page_height += line_height;
234 }
235
236 page_breaks = g_list_reverse (page_breaks);
237 ctk_print_operation_set_n_pages (operation, g_list_length (page_breaks) + 1);
238
239 print_data->page_breaks = page_breaks;
240}
241
242static void
243draw_page (CtkPrintOperation *operation,
244 CtkPrintContext *context,
245 int page_nr,
246 PrintData *print_data)
247{
248 cairo_t *cr;
249 GList *pagebreak;
250 int start, end, i;
251 PangoLayoutIter *iter;
252 double start_pos;
253
254 if (page_nr == 0)
255 start = 0;
256 else
257 {
258 pagebreak = g_list_nth (print_data->page_breaks, page_nr - 1);
259 start = GPOINTER_TO_INT (pagebreak->data)((gint) (glong) (pagebreak->data));
260 }
261
262 pagebreak = g_list_nth (print_data->page_breaks, page_nr);
263 if (pagebreak == NULL((void*)0))
264 end = pango_layout_get_line_count (print_data->layout);
265 else
266 end = GPOINTER_TO_INT (pagebreak->data)((gint) (glong) (pagebreak->data));
267
268 cr = ctk_print_context_get_cairo_context (context);
269
270 cairo_set_source_rgb (cr, 0, 0, 0);
271
272 i = 0;
273 start_pos = 0;
274 iter = pango_layout_get_iter (print_data->layout);
275 do
276 {
277 PangoRectangle logical_rect;
278
279 if (i >= start)
280 {
281 PangoLayoutLine *line;
282 int baseline;
283
284 line = pango_layout_iter_get_line (iter);
285
286 pango_layout_iter_get_line_extents (iter, NULL((void*)0), &logical_rect);
287 baseline = pango_layout_iter_get_baseline (iter);
288
289 if (i == start)
290 start_pos = logical_rect.y / 1024.0;
291
292 cairo_move_to (cr, logical_rect.x / 1024.0, baseline / 1024.0 - start_pos);
293
294 pango_cairo_show_layout_line (cr, line);
295 }
296 i++;
297 }
298 while (i < end &&
299 pango_layout_iter_next_line (iter));
300
301 pango_layout_iter_free (iter);
302}
303
304static void
305status_changed_cb (CtkPrintOperation *op,
306 gpointer user_data)
307{
308 if (ctk_print_operation_is_finished (op))
309 {
310 active_prints = g_list_remove (active_prints, op);
311 g_object_unref (op);
312 }
313 update_statusbar ();
314}
315
316static CtkWidget *
317create_custom_widget (CtkPrintOperation *operation,
318 PrintData *data)
319{
320 CtkWidget *vbox, *hbox, *font, *label;
321
322 ctk_print_operation_set_custom_tab_label (operation, "Other");
323 vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0);
324 ctk_container_set_border_width (CTK_CONTAINER (vbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((ctk_container_get_type ()))))))
, 12);
325
326 hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 8);
327 ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((ctk_box_get_type ()))))))
, hbox, FALSE(0), FALSE(0), 0);
328 ctk_widget_show (hbox);
329
330 label = ctk_label_new ("Font:");
331 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);
332 ctk_widget_show (label);
333
334 font = ctk_font_button_new_with_font (data->font);
335 ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((ctk_box_get_type ()))))))
, font, FALSE(0), FALSE(0), 0);
336 ctk_widget_show (font);
337 data->font_button = font;
338
339 return vbox;
340}
341
342static void
343custom_widget_apply (CtkPrintOperation *operation,
344 CtkWidget *widget,
345 PrintData *data)
346{
347 const char *selected_font;
348 selected_font = ctk_font_chooser_get_font (CTK_FONT_CHOOSER (data->font_button)((((CtkFontChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->font_button)), ((ctk_font_chooser_get_type ()))
))))
);
349
350 g_free (data->font);
351 data->font = g_strdup (selected_font)g_strdup_inline (selected_font);
352}
353
354typedef struct
355{
356 CtkPrintOperation *op;
357 CtkPrintOperationPreview *preview;
358 CtkPrintContext *context;
359 CtkWidget *spin;
360 CtkWidget *area;
361 gint page;
362 PrintData *data;
363 gdouble dpi_x, dpi_y;
364} PreviewOp;
365
366static gboolean
367preview_draw (CtkWidget *widget,
368 cairo_t *cr,
369 gpointer data)
370{
371 PreviewOp *pop = data;
372 cairo_t *prev_cr;
373 double dpi_x, dpi_y;
374
375 prev_cr = ctk_print_context_get_cairo_context (pop->context);
376 cairo_reference (prev_cr);
377 dpi_x = ctk_print_context_get_dpi_x (pop->context);
378 dpi_y = ctk_print_context_get_dpi_y (pop->context);
379
380 ctk_print_context_set_cairo_context (pop->context,
381 cr, dpi_x, dpi_y);
382 ctk_print_operation_preview_render_page (pop->preview,
383 pop->page - 1);
384 ctk_print_context_set_cairo_context (pop->context,
385 prev_cr, dpi_x, dpi_y);
386 cairo_destroy (prev_cr);
387
388 return TRUE(!(0));
389}
390
391static void
392preview_ready (CtkPrintOperationPreview *preview,
393 CtkPrintContext *context,
394 gpointer data)
395{
396 PreviewOp *pop = data;
397 gint n_pages;
398
399 g_object_get (pop->op, "n-pages", &n_pages, NULL((void*)0));
400
401 ctk_spin_button_set_range (CTK_SPIN_BUTTON (pop->spin)((((CtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop->spin)), ((ctk_spin_button_get_type ()))))))
,
402 1.0, n_pages);
403
404 g_signal_connect (pop->area, "draw",g_signal_connect_data ((pop->area), ("draw"), (((GCallback
) (preview_draw))), (pop), ((void*)0), (GConnectFlags) 0)
405 G_CALLBACK (preview_draw),g_signal_connect_data ((pop->area), ("draw"), (((GCallback
) (preview_draw))), (pop), ((void*)0), (GConnectFlags) 0)
406 pop)g_signal_connect_data ((pop->area), ("draw"), (((GCallback
) (preview_draw))), (pop), ((void*)0), (GConnectFlags) 0)
;
407
408 ctk_widget_queue_draw (pop->area);
409}
410
411static void
412preview_got_page_size (CtkPrintOperationPreview *preview,
413 CtkPrintContext *context,
414 CtkPageSetup *page_setup,
415 gpointer data)
416{
417 PreviewOp *pop = data;
418 CtkAllocation allocation;
419 CtkPaperSize *paper_size;
420 double w, h;
421 cairo_t *cr;
422 gdouble dpi_x, dpi_y;
423
424 paper_size = ctk_page_setup_get_paper_size (page_setup);
425
426 w = ctk_paper_size_get_width (paper_size, CTK_UNIT_INCH);
427 h = ctk_paper_size_get_height (paper_size, CTK_UNIT_INCH);
428
429 cr = cdk_cairo_create (ctk_widget_get_window (pop->area));
430
431 ctk_widget_get_allocation (pop->area, &allocation);
432 dpi_x = allocation.width/w;
433 dpi_y = allocation.height/h;
434
435 if (fabs (dpi_x - pop->dpi_x) > 0.001 ||
436 fabs (dpi_y - pop->dpi_y) > 0.001)
437 {
438 ctk_print_context_set_cairo_context (context, cr, dpi_x, dpi_y);
439 pop->dpi_x = dpi_x;
440 pop->dpi_y = dpi_y;
441 }
442
443 pango_cairo_update_layout (cr, pop->data->layout);
444 cairo_destroy (cr);
445}
446
447static void
448update_page (CtkSpinButton *widget,
449 gpointer data)
450{
451 PreviewOp *pop = data;
452
453 pop->page = ctk_spin_button_get_value_as_int (widget);
454 ctk_widget_queue_draw (pop->area);
455}
456
457static void
458preview_destroy (CtkWindow *window,
459 PreviewOp *pop)
460{
461 ctk_print_operation_preview_end_preview (pop->preview);
462 g_object_unref (pop->op);
463
464 g_free (pop);
465}
466
467static gboolean
468preview_cb (CtkPrintOperation *op,
469 CtkPrintOperationPreview *preview,
470 CtkPrintContext *context,
471 CtkWindow *parent,
472 gpointer data)
473{
474 CtkWidget *window, *close, *page, *hbox, *vbox, *da;
475 gdouble width, height;
476 cairo_t *cr;
477 PreviewOp *pop;
478 PrintData *print_data = data;
479
480 pop = g_new0 (PreviewOp, 1)((PreviewOp *) g_malloc0_n ((1), sizeof (PreviewOp)));
481
482 pop->data = print_data;
483
484 width = 200;
485 height = 300;
486 window = ctk_window_new (CTK_WINDOW_TOPLEVEL);
487 ctk_window_set_transient_for (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
488 CTK_WINDOW (main_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_window_get_type ()))))))
);
489 vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0);
490 ctk_container_add (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_container_get_type ()))))))
, vbox);
491 hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 0);
492 ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((ctk_box_get_type ()))))))
, hbox,
493 FALSE(0), FALSE(0), 0);
494 page = ctk_spin_button_new_with_range (1, 100, 1);
495 ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((ctk_box_get_type ()))))))
, page, FALSE(0), FALSE(0), 0);
496
497 close = ctk_button_new_with_label ("Close");
498 ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((ctk_box_get_type ()))))))
, close, FALSE(0), FALSE(0), 0);
499
500 da = ctk_drawing_area_new ();
501 ctk_widget_set_size_request (CTK_WIDGET (da)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((da)), ((ctk_widget_get_type ()))))))
, width, height);
502 ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((ctk_box_get_type ()))))))
, da, TRUE(!(0)), TRUE(!(0)), 0);
503
504 ctk_widget_realize (da);
505
506 cr = cdk_cairo_create (ctk_widget_get_window (da));
507
508 /* TODO: What dpi to use here? This will be used for pagination.. */
509 ctk_print_context_set_cairo_context (context, cr, 72, 72);
510 cairo_destroy (cr);
511
512 pop->op = g_object_ref (op)((__typeof__ (op)) (g_object_ref) (op));
513 pop->preview = preview;
514 pop->context = context;
515 pop->spin = page;
516 pop->area = da;
517 pop->page = 1;
518
519 g_signal_connect (page, "value-changed",g_signal_connect_data ((page), ("value-changed"), (((GCallback
) (update_page))), (pop), ((void*)0), (GConnectFlags) 0)
520 G_CALLBACK (update_page), pop)g_signal_connect_data ((page), ("value-changed"), (((GCallback
) (update_page))), (pop), ((void*)0), (GConnectFlags) 0)
;
521 g_signal_connect_swapped (close, "clicked",g_signal_connect_data ((close), ("clicked"), (((GCallback) (ctk_widget_destroy
))), (window), ((void*)0), G_CONNECT_SWAPPED)
522 G_CALLBACK (ctk_widget_destroy), window)g_signal_connect_data ((close), ("clicked"), (((GCallback) (ctk_widget_destroy
))), (window), ((void*)0), G_CONNECT_SWAPPED)
;
523
524 g_signal_connect (preview, "ready",g_signal_connect_data ((preview), ("ready"), (((GCallback) (preview_ready
))), (pop), ((void*)0), (GConnectFlags) 0)
525 G_CALLBACK (preview_ready), pop)g_signal_connect_data ((preview), ("ready"), (((GCallback) (preview_ready
))), (pop), ((void*)0), (GConnectFlags) 0)
;
526 g_signal_connect (preview, "got-page-size",g_signal_connect_data ((preview), ("got-page-size"), (((GCallback
) (preview_got_page_size))), (pop), ((void*)0), (GConnectFlags
) 0)
527 G_CALLBACK (preview_got_page_size), pop)g_signal_connect_data ((preview), ("got-page-size"), (((GCallback
) (preview_got_page_size))), (pop), ((void*)0), (GConnectFlags
) 0)
;
528
529 g_signal_connect (window, "destroy",g_signal_connect_data ((window), ("destroy"), (((GCallback) (
preview_destroy))), (pop), ((void*)0), (GConnectFlags) 0)
530 G_CALLBACK (preview_destroy), pop)g_signal_connect_data ((window), ("destroy"), (((GCallback) (
preview_destroy))), (pop), ((void*)0), (GConnectFlags) 0)
;
531
532 ctk_widget_show_all (window);
533
534 return TRUE(!(0));
535}
536
537static void
538print_done (CtkPrintOperation *op,
539 CtkPrintOperationResult res,
540 PrintData *print_data)
541{
542 GError *error = NULL((void*)0);
543
544 if (res == CTK_PRINT_OPERATION_RESULT_ERROR)
545 {
546
547 CtkWidget *error_dialog;
548
549 ctk_print_operation_get_error (op, &error);
550
551 error_dialog = ctk_message_dialog_new (CTK_WINDOW (main_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_window_get_type ()))))))
,
552 CTK_DIALOG_DESTROY_WITH_PARENT,
553 CTK_MESSAGE_ERROR,
554 CTK_BUTTONS_CLOSE,
555 "Error printing file:\n%s",
556 error ? error->message : "no details");
557 g_signal_connect (error_dialog, "response", G_CALLBACK (ctk_widget_destroy), NULL)g_signal_connect_data ((error_dialog), ("response"), (((GCallback
) (ctk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
558 ctk_widget_show (error_dialog);
559 }
560 else if (res == CTK_PRINT_OPERATION_RESULT_APPLY)
561 {
562 if (settings != NULL((void*)0))
563 g_object_unref (settings);
564 settings = g_object_ref (ctk_print_operation_get_print_settings (op))((__typeof__ (ctk_print_operation_get_print_settings (op))) (
g_object_ref) (ctk_print_operation_get_print_settings (op)))
;
565 }
566
567 g_free (print_data->text);
568 g_free (print_data->font);
569 g_free (print_data);
570
571 if (!ctk_print_operation_is_finished (op))
572 {
573 g_object_ref (op)((__typeof__ (op)) (g_object_ref) (op));
574 active_prints = g_list_append (active_prints, op);
575 update_statusbar ();
576
577 /* This ref is unref:ed when we get the final state change */
578 g_signal_connect (op, "status_changed",g_signal_connect_data ((op), ("status_changed"), (((GCallback
) (status_changed_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
579 G_CALLBACK (status_changed_cb), NULL)g_signal_connect_data ((op), ("status_changed"), (((GCallback
) (status_changed_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
580 }
581}
582
583static void
584end_print (CtkPrintOperation *op, CtkPrintContext *context, PrintData *print_data)
585{
586 g_list_free (print_data->page_breaks);
587 print_data->page_breaks = NULL((void*)0);
588 g_object_unref (print_data->layout);
589 print_data->layout = NULL((void*)0);
590}
591
592static void
593print_or_preview (GSimpleAction *action, CtkPrintOperationAction print_action)
594{
595 CtkPrintOperation *print;
596 PrintData *print_data;
597
598 print_data = g_new0 (PrintData, 1)((PrintData *) g_malloc0_n ((1), sizeof (PrintData)));
599
600 print_data->text = get_text ();
601 print_data->font = g_strdup ("Sans 12")g_strdup_inline ("Sans 12");
602
603 print = ctk_print_operation_new ();
604
605 ctk_print_operation_set_track_print_status (print, TRUE(!(0)));
606
607 if (settings != NULL((void*)0))
608 ctk_print_operation_set_print_settings (print, settings);
609
610 if (page_setup != NULL((void*)0))
611 ctk_print_operation_set_default_page_setup (print, page_setup);
612
613 g_signal_connect (print, "begin_print", G_CALLBACK (begin_print), print_data)g_signal_connect_data ((print), ("begin_print"), (((GCallback
) (begin_print))), (print_data), ((void*)0), (GConnectFlags) 0
)
;
614 g_signal_connect (print, "end-print", G_CALLBACK (end_print), print_data)g_signal_connect_data ((print), ("end-print"), (((GCallback) (
end_print))), (print_data), ((void*)0), (GConnectFlags) 0)
;
615 g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), print_data)g_signal_connect_data ((print), ("draw_page"), (((GCallback) (
draw_page))), (print_data), ((void*)0), (GConnectFlags) 0)
;
616 g_signal_connect (print, "create_custom_widget", G_CALLBACK (create_custom_widget), print_data)g_signal_connect_data ((print), ("create_custom_widget"), (((
GCallback) (create_custom_widget))), (print_data), ((void*)0)
, (GConnectFlags) 0)
;
617 g_signal_connect (print, "custom_widget_apply", G_CALLBACK (custom_widget_apply), print_data)g_signal_connect_data ((print), ("custom_widget_apply"), (((GCallback
) (custom_widget_apply))), (print_data), ((void*)0), (GConnectFlags
) 0)
;
618 g_signal_connect (print, "preview", G_CALLBACK (preview_cb), print_data)g_signal_connect_data ((print), ("preview"), (((GCallback) (preview_cb
))), (print_data), ((void*)0), (GConnectFlags) 0)
;
619
620 g_signal_connect (print, "done", G_CALLBACK (print_done), print_data)g_signal_connect_data ((print), ("done"), (((GCallback) (print_done
))), (print_data), ((void*)0), (GConnectFlags) 0)
;
621
622 ctk_print_operation_set_export_filename (print, "test.pdf");
623
624#if 0
625 ctk_print_operation_set_allow_async (print, TRUE(!(0)));
626#endif
627 ctk_print_operation_run (print, print_action, CTK_WINDOW (main_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_window_get_type ()))))))
, NULL((void*)0));
628
629 g_object_unref (print);
630}
631
632static void
633activate_page_setup (GSimpleAction *action,
634 GVariant *parameter,
635 gpointer user_data)
636{
637 CtkPageSetup *new_page_setup;
638
639 new_page_setup = ctk_print_run_page_setup_dialog (CTK_WINDOW (main_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_window_get_type ()))))))
,
640 page_setup, settings);
641
642 if (page_setup)
643 g_object_unref (page_setup);
644
645 page_setup = new_page_setup;
646}
647
648static void
649activate_print (GSimpleAction *action,
650 GVariant *parameter,
651 gpointer user_data)
652{
653 print_or_preview (action, CTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
654}
655
656static void
657activate_preview (GSimpleAction *action,
658 GVariant *parameter,
659 gpointer user_data)
660{
661 print_or_preview (action, CTK_PRINT_OPERATION_ACTION_PREVIEW);
662}
663
664static void
665activate_save_as (GSimpleAction *action,
666 GVariant *parameter,
667 gpointer user_data)
668{
669 CtkWidget *dialog;
670 gint response;
671
672 dialog = ctk_file_chooser_dialog_new ("Select file",
673 CTK_WINDOW (main_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_window_get_type ()))))))
,
674 CTK_FILE_CHOOSER_ACTION_SAVE,
675 "_Cancel", CTK_RESPONSE_CANCEL,
676 "_Save", CTK_RESPONSE_OK,
677 NULL((void*)0));
678 ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
, CTK_RESPONSE_OK);
679 response = ctk_dialog_run (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
);
680
681 if (response == CTK_RESPONSE_OK)
682 {
683 char *save_filename;
684
685 save_filename = ctk_file_chooser_get_filename (CTK_FILE_CHOOSER (dialog)((((CtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_file_chooser_get_type ()))))))
);
686 save_file (save_filename);
687 g_free (save_filename);
688 }
689
690 ctk_widget_destroy (dialog);
691}
692
693static void
694activate_save (GSimpleAction *action,
695 GVariant *parameter,
696 gpointer user_data)
697{
698 if (filename == NULL((void*)0))
699 activate_save_as (action, NULL((void*)0), NULL((void*)0));
700 else
701 save_file (filename);
702}
703
704static void
705activate_open (GSimpleAction *action,
706 GVariant *parameter,
707 gpointer user_data)
708{
709 CtkWidget *dialog;
710 gint response;
711
712 dialog = ctk_file_chooser_dialog_new ("Select file",
713 CTK_WINDOW (main_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_window_get_type ()))))))
,
714 CTK_FILE_CHOOSER_ACTION_OPEN,
715 "_Cancel", CTK_RESPONSE_CANCEL,
716 "_Open", CTK_RESPONSE_OK,
717 NULL((void*)0));
718 ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
, CTK_RESPONSE_OK);
719 response = ctk_dialog_run (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
);
720
721 if (response == CTK_RESPONSE_OK)
722 {
723 char *open_filename;
724
725 open_filename = ctk_file_chooser_get_filename (CTK_FILE_CHOOSER (dialog)((((CtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_file_chooser_get_type ()))))))
);
726 load_file (open_filename);
727 g_free (open_filename);
728 }
729
730 ctk_widget_destroy (dialog);
731}
732
733static void
734activate_new (GSimpleAction *action,
735 GVariant *parameter,
736 gpointer user_data)
737{
738 g_free (filename);
739 filename = NULL((void*)0);
740 set_text ("", 0);
741}
742
743static void
744activate_about (GSimpleAction *action,
745 GVariant *parameter,
746 gpointer user_data)
747{
748 const gchar *authors[] = {
749 "Alexander Larsson",
750 NULL((void*)0)
751 };
752 ctk_show_about_dialog (CTK_WINDOW (main_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_window_get_type ()))))))
,
753 "name", "Print Test Editor",
754 "logo-icon-name", "text-editor",
755 "version", "0.1",
756 "copyright", "(C) Red Hat, Inc",
757 "comments", "Program to demonstrate CTK+ printing.",
758 "authors", authors,
759 NULL((void*)0));
760}
761
762static void
763activate_quit (GSimpleAction *action,
764 GVariant *parameter,
765 gpointer user_data)
766{
767 CtkApplication *app = user_data;
768 GList *list, *next;
769
770 list = ctk_application_get_windows (app);
771 while (list)
772 {
773 CtkWidget *win;
774
775 win = list->data;
776 next = list->next;
777
778 ctk_widget_destroy (CTK_WIDGET (win)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((win)), ((ctk_widget_get_type ()))))))
);
779
780 list = next;
781 }
782}
783
784static GActionEntry app_entries[] = {
785 { .name = "new", .activate = activate_new },
786 { .name = "open", .activate = activate_open },
787 { .name = "save", .activate = activate_save },
788 { .name = "save-as", .activate = activate_save_as },
789 { .name = "quit", .activate = activate_quit },
790 { .name = "about", .activate = activate_about },
791 { .name = "page-setup", .activate = activate_page_setup },
792 { .name = "preview", .activate = activate_preview },
793 { .name = "print", .activate = activate_print }
794};
795
796static const gchar ui_info[] =
797 "<interface>"
798 " <menu id='appmenu'>"
799 " <section>"
800 " <item>"
801 " <attribute name='label'>_About</attribute>"
802 " <attribute name='action'>app.about</attribute>"
803 " <attribute name='accel'>&lt;Primary&gt;a</attribute>"
804 " </item>"
805 " </section>"
806 " <section>"
807 " <item>"
808 " <attribute name='label'>_Quit</attribute>"
809 " <attribute name='action'>app.quit</attribute>"
810 " <attribute name='accel'>&lt;Primary&gt;q</attribute>"
811 " </item>"
812 " </section>"
813 " </menu>"
814 " <menu id='menubar'>"
815 " <submenu>"
816 " <attribute name='label'>_File</attribute>"
817 " <section>"
818 " <item>"
819 " <attribute name='label'>_New</attribute>"
820 " <attribute name='action'>app.new</attribute>"
821 " <attribute name='accel'>&lt;Primary&gt;n</attribute>"
822 " </item>"
823 " <item>"
824 " <attribute name='label'>_Open</attribute>"
825 " <attribute name='action'>app.open</attribute>"
826 " </item>"
827 " <item>"
828 " <attribute name='label'>_Save</attribute>"
829 " <attribute name='action'>app.save</attribute>"
830 " <attribute name='accel'>&lt;Primary&gt;s</attribute>"
831 " </item>"
832 " <item>"
833 " <attribute name='label'>Save _As...</attribute>"
834 " <attribute name='action'>app.save-as</attribute>"
835 " <attribute name='accel'>&lt;Primary&gt;s</attribute>"
836 " </item>"
837 " </section>"
838 " <section>"
839 " <item>"
840 " <attribute name='label'>Page Setup</attribute>"
841 " <attribute name='action'>app.page-setup</attribute>"
842 " </item>"
843 " <item>"
844 " <attribute name='label'>Preview</attribute>"
845 " <attribute name='action'>app.preview</attribute>"
846 " </item>"
847 " <item>"
848 " <attribute name='label'>Print</attribute>"
849 " <attribute name='action'>app.print</attribute>"
850 " </item>"
851 " </section>"
852 " </submenu>"
853 " </menu>"
854 "</interface>";
855
856static void
857buffer_changed_callback (CtkTextBuffer *buffer)
858{
859 file_changed = TRUE(!(0));
860 update_statusbar ();
861}
862
863static void
864mark_set_callback (CtkTextBuffer *buffer,
865 const CtkTextIter *new_location,
866 CtkTextMark *mark,
867 gpointer data)
868{
869 update_statusbar ();
870}
871
872static gint
873command_line (GApplication *application,
874 GApplicationCommandLine *command_line)
875{
876 int argc;
877 char **argv;
878
879 argv = g_application_command_line_get_arguments (command_line, &argc);
880
881 if (argc == 2)
882 load_file (argv[1]);
883
884 return 0;
885}
886
887static void
888startup (GApplication *app)
889{
890 CtkBuilder *builder;
891 GMenuModel *appmenu;
892 GMenuModel *menubar;
893
894 builder = ctk_builder_new ();
895 ctk_builder_add_from_string (builder, ui_info, -1, NULL((void*)0));
896
897 appmenu = (GMenuModel *)ctk_builder_get_object (builder, "appmenu");
898 menubar = (GMenuModel *)ctk_builder_get_object (builder, "menubar");
899
900 ctk_application_set_app_menu (CTK_APPLICATION (app)((((CtkApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app)), ((ctk_application_get_type ()))))))
, appmenu);
901 ctk_application_set_menubar (CTK_APPLICATION (app)((((CtkApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app)), ((ctk_application_get_type ()))))))
, menubar);
902
903 g_object_unref (builder);
904}
905
906static void
907activate (GApplication *app)
908{
909 CtkWidget *box;
910 CtkWidget *bar;
911 CtkWidget *sw;
912 CtkWidget *contents;
913
914 main_window = ctk_application_window_new (CTK_APPLICATION (app)((((CtkApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app)), ((ctk_application_get_type ()))))))
);
915 ctk_window_set_icon_name (CTK_WINDOW (main_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_window_get_type ()))))))
, "text-editor");
916 ctk_window_set_default_size (CTK_WINDOW (main_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_window_get_type ()))))))
, 400, 600);
917 update_title (CTK_WINDOW (main_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_window_get_type ()))))))
);
918
919 box = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0);
920 ctk_container_add (CTK_CONTAINER (main_window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((main_window)), ((ctk_container_get_type ()))))))
, box);
921
922 bar = ctk_menu_bar_new ();
923 ctk_widget_show (bar);
924 ctk_container_add (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_container_get_type ()))))))
, bar);
925
926 /* Create document */
927 sw = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0));
928
929 ctk_scrolled_window_set_policy (CTK_SCROLLED_WINDOW (sw)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((sw)), ((ctk_scrolled_window_get_type ())))
)))
,
930 CTK_POLICY_AUTOMATIC,
931 CTK_POLICY_AUTOMATIC);
932
933 ctk_scrolled_window_set_shadow_type (CTK_SCROLLED_WINDOW (sw)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((sw)), ((ctk_scrolled_window_get_type ())))
)))
,
934 CTK_SHADOW_IN);
935
936 ctk_widget_set_vexpand (sw, TRUE(!(0)));
937 ctk_container_add (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_container_get_type ()))))))
, sw);
938
939 contents = ctk_text_view_new ();
940 ctk_widget_grab_focus (contents);
941
942 ctk_container_add (CTK_CONTAINER (sw)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sw)), ((ctk_container_get_type ()))))))
,
943 contents);
944
945 /* Create statusbar */
946 statusbar = ctk_statusbar_new ();
947 ctk_container_add (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_container_get_type ()))))))
, statusbar);
948
949 /* Show text widget info in the statusbar */
950 buffer = ctk_text_view_get_buffer (CTK_TEXT_VIEW (contents)((((CtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((contents)), ((ctk_text_view_get_type ()))))))
);
951
952 g_signal_connect_object (buffer,
953 "changed",
954 G_CALLBACK (buffer_changed_callback)((GCallback) (buffer_changed_callback)),
955 NULL((void*)0),
956 0);
957
958 g_signal_connect_object (buffer,
959 "mark_set", /* cursor moved */
960 G_CALLBACK (mark_set_callback)((GCallback) (mark_set_callback)),
961 NULL((void*)0),
962 0);
963
964 update_ui ();
965
966 ctk_widget_show_all (main_window);
967}
968
969int
970main (int argc, char **argv)
971{
972 CtkApplication *app;
973 GError *error = NULL((void*)0);
974
975 ctk_init (NULL((void*)0), NULL((void*)0));
976
977 settings = ctk_print_settings_new_from_file ("print-settings.ini", &error);
978 if (error) {
979 g_print ("Failed to load print settings: %s\n", error->message);
980 g_clear_error (&error);
981
982 settings = ctk_print_settings_new ();
983 }
984 g_assert (settings != NULL)do { if (settings != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "print-editor.c", 984, ((const char*) (__func__
)), "settings != NULL"); } while (0)
;
985
986 page_setup = ctk_page_setup_new_from_file ("page-setup.ini", &error);
987 if (error) {
988 g_print ("Failed to load page setup: %s\n", error->message);
989 g_clear_error (&error);
990 }
991
992 app = ctk_application_new ("org.ctk.PrintEditor", 0);
993
994 g_action_map_add_action_entries (G_ACTION_MAP (app)((((GActionMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app)), ((g_action_map_get_type ()))))))
,
995 app_entries, G_N_ELEMENTS (app_entries)(sizeof (app_entries) / sizeof ((app_entries)[0])),
996 app);
997
998 g_signal_connect (app, "startup", G_CALLBACK (startup), NULL)g_signal_connect_data ((app), ("startup"), (((GCallback) (startup
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
999 g_signal_connect (app, "activate", G_CALLBACK (activate), NULL)g_signal_connect_data ((app), ("activate"), (((GCallback) (activate
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
1000 g_signal_connect (app, "command-line", G_CALLBACK (command_line), NULL)g_signal_connect_data ((app), ("command-line"), (((GCallback)
(command_line))), (((void*)0)), ((void*)0), (GConnectFlags) 0
)
;
1001
1002 g_application_run (G_APPLICATION (app)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app)), ((g_application_get_type ()))))))
, argc, argv);
1003
1004 if (!ctk_print_settings_to_file (settings, "print-settings.ini", &error)) {
1005 g_print ("Failed to save print settings: %s\n", error->message);
1006 g_clear_error (&error);
1007 }
1008 if (page_setup &&
1009 !ctk_page_setup_to_file (page_setup, "page-setup.ini", &error)) {
This statement is never executed
1010 g_print ("Failed to save page setup: %s\n", error->message);
1011 g_clear_error (&error);
1012 }
1013
1014 return 0;
1015}