annotate src/print.c @ 1641:c8252313dcfa

make sure that a directory exists on saving desktop files
author nadvornik
date Wed, 10 Jun 2009 20:45:24 +0000
parents 25bed5b179be
children 672ee190869e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /*
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 138
diff changeset
2 * Geeqie
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2004 John Ellis
1284
8b89e3ff286b Add year 2009 to copyright info everywhere.
zas_
parents: 1237
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 266
diff changeset
13 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 #include "print.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 512
diff changeset
16 #include "filedata.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include "image.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include "image-load.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "pixbuf_util.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "thumb.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "utilops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "ui_menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include "ui_utildlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 #include "ui_spinner.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 #include "ui_tabcomp.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 #include <locale.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 #include <signal.h>
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
32 #include <glib/gprintf.h>
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 #define PRINT_LPR_COMMAND "lpr"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 #define PRINT_LPR_CUSTOM "lpr -P %s"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 #define PRINT_LPR_QUERY "lpstat -p"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 #define PRINT_DLG_WIDTH 600
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 #define PRINT_DLG_HEIGHT 400
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 #define PRINT_DLG_PREVIEW_WIDTH 270
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 #define PRINT_DLG_PREVIEW_HEIGHT -1
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 /* these are in point units */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 #define PRINT_MIN_WIDTH 100
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 #define PRINT_MIN_HEIGHT 100
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 #define PRINT_MAX_WIDTH 4000
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 #define PRINT_MAX_HEIGHT 4000
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 #define PRINT_MARGIN_DEFAULT 36
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 #define PRINT_PROOF_MIN_SIZE 8
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 #define PRINT_PROOF_MAX_SIZE 720
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 #define PRINT_PROOF_DEFAULT_SIZE 144
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 #define PRINT_PROOF_MARGIN 5
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 /* default page size */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 #define PAGE_LAYOUT_WIDTH 850
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 #define PAGE_LAYOUT_HEIGHT 1100
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 /* preview uses 1 pixel = PRINT_PREVIEW_SCALE points */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 #define PRINT_PREVIEW_SCALE 4
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 /* default dpi to use for printing ps image data */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 #define PRINT_PS_DPI_DEFAULT 300.0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 #define PRINT_PS_DPI_MIN 150.0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 /* method to use when scaling down image data */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 #define PRINT_PS_MAX_INTERP GDK_INTERP_BILINEAR
121
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
69 /* color to use as mask when printing transparent images */
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
70 #define PRINT_PS_MASK_R 255
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
71 #define PRINT_PS_MASK_G 255
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
72 #define PRINT_PS_MASK_B 255
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 /* padding between objects */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 #define PRINT_TEXT_PADDING 3.0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 /* locale for postscript portability */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 #define POSTSCRIPT_LOCALE "C"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 /* group and keys for saving prefs */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 #define PRINT_PREF_GROUP "print_settings"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 #define PRINT_PREF_SAVE "save_settings"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 #define PRINT_PREF_OUTPUT "output"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 #define PRINT_PREF_FORMAT "format"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 #define PRINT_PREF_DPI "dpi"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 #define PRINT_PREF_UNITS "units"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 #define PRINT_PREF_SIZE "size"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 #define PRINT_PREF_ORIENTATION "orientation"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 #define PRINT_PREF_CUSTOM_WIDTH "custom_width"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 #define PRINT_PREF_CUSTOM_HEIGHT "custom_height"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 #define PRINT_PREF_MARGIN_LEFT "margin_left"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 #define PRINT_PREF_MARGIN_RIGHT "margin_right"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 #define PRINT_PREF_MARGIN_TOP "margin_top"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 #define PRINT_PREF_MARGIN_BOTTOM "margin_bottom"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 #define PRINT_PREF_PROOF_WIDTH "proof_width"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 #define PRINT_PREF_PROOF_HEIGHT "proof_height"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 #define PRINT_PREF_PRINTERC "custom_printer"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103
1237
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
104 #define PRINT_PREF_TEXT "text"
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
105 #define PRINT_PREF_TEXTSIZE "textsize"
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
106 #define PRINT_PREF_TEXTCOLOR_R "textcolor_r"
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
107 #define PRINT_PREF_TEXTCOLOR_G "textcolor_g"
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
108 #define PRINT_PREF_TEXTCOLOR_B "textcolor_b"
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
109
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
110 #define PRINT_PREF_SOURCE "source"
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
111 #define PRINT_PREF_LAYOUT "layout"
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
112
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
113 #define PRINT_PREF_IMAGE_SCALE "image_scale"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 typedef enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 PRINT_SOURCE_IMAGE = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 PRINT_SOURCE_SELECTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 PRINT_SOURCE_ALL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 PRINT_SOURCE_COUNT
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 } PrintSource;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 const gchar *print_source_text[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 N_("Image"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 N_("Selection"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 N_("All"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 NULL
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 typedef enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 PRINT_LAYOUT_IMAGE = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 PRINT_LAYOUT_PROOF,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 PRINT_LAYOUT_COUNT
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 } PrintLayout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 const gchar *print_layout_text[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 N_("One image per page"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 N_("Proof sheet"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 NULL
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 typedef enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 PRINT_OUTPUT_PS_LPR = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 PRINT_OUTPUT_PS_CUSTOM,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 PRINT_OUTPUT_PS_FILE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 PRINT_OUTPUT_RGB_FILE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 PRINT_OUTPUT_COUNT
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 } PrintOutput;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 const gchar *print_output_text[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 N_("Default printer"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 N_("Custom printer"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 N_("PostScript file"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 N_("Image file"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 NULL
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 typedef enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 PRINT_FILE_JPG_LOW = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 PRINT_FILE_JPG_NORMAL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 PRINT_FILE_JPG_HIGH,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 PRINT_FILE_PNG,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 PRINT_FILE_COUNT
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 } PrintFileFormat;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 const gchar *print_file_format_text[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 N_("jpeg, low quality"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 N_("jpeg, normal quality"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169 N_("jpeg, high quality"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 "png",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 NULL
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 typedef enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 RENDER_FORMAT_PREVIEW,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 RENDER_FORMAT_RGB,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 RENDER_FORMAT_PS
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 } RenderFormat;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 typedef enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 TEXT_INFO_FILENAME = 1 << 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 TEXT_INFO_FILEDATE = 1 << 1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 TEXT_INFO_FILESIZE = 1 << 2,
266
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
184 TEXT_INFO_DIMENSIONS = 1 << 3,
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
185 TEXT_INFO_FILEPATH = 1 << 4
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 } TextInfo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
188 typedef enum {
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
189 PAPER_UNIT_POINTS = 0,
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
190 PAPER_UNIT_MM,
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
191 PAPER_UNIT_CM,
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
192 PAPER_UNIT_INCH,
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
193 PAPER_UNIT_PICAS,
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
194 PAPER_UNIT_COUNT
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
195 } PaperUnits;
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
196
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
197 typedef enum {
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
198 PAPER_ORIENTATION_PORTRAIT = 0,
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
199 PAPER_ORIENTATION_LANDSCAPE,
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
200 PAPER_ORIENTATION_COUNT
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
201 } PaperOrientation;
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
202
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
203
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 typedef struct _PrintWindow PrintWindow;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 struct _PrintWindow
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 GenericDialog *dialog;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
209 FileData *source_fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 GList *source_selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 GList *source_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 PrintSource source;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 PrintLayout layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 PrintOutput output;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 gchar *output_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 gchar *output_custom;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 PrintFileFormat output_format;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 gdouble max_dpi;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 GtkWidget *notebook;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 GtkWidget *path_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 GtkWidget *custom_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 GtkWidget *path_format_menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 GtkWidget *max_dpi_menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 ImageWindow *layout_image;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 gdouble layout_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 gdouble layout_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1443
diff changeset
235 guint layout_idle_id; /* event source id */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236
1237
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
237 gdouble image_scale;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 GtkWidget *image_scale_spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 gdouble proof_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 gdouble proof_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 gint proof_columns;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 gint proof_rows;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 GList *proof_point;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 gint proof_position;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 gint proof_page;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 GtkWidget *proof_group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 GtkWidget *proof_width_spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 GtkWidget *proof_height_spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 GtkWidget *paper_menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 GtkWidget *paper_width_spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 GtkWidget *paper_height_spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 GtkWidget *paper_units_menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 GtkWidget *paper_orientation_menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 GtkWidget *margin_left_spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 GtkWidget *margin_right_spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 GtkWidget *margin_top_spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 GtkWidget *margin_bottom_spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
264 PaperUnits paper_units;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 gint paper_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 gdouble paper_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 gdouble paper_height;
736
a7289f9e8d29 Fix signed vs unsigned warnings.
zas_
parents: 675
diff changeset
268 PaperOrientation paper_orientation;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 gdouble margin_left;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 gdouble margin_right;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 gdouble margin_top;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 gdouble margin_bottom;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 GtkWidget *button_back;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 GtkWidget *button_next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 GtkWidget *page_label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 GtkWidget *print_button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 gdouble single_scale;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 gdouble single_x;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 gdouble single_y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 GtkWidget *single_scale_spin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 TextInfo text_fields;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 gint text_points;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 guint8 text_r;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 guint8 text_g;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 guint8 text_b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 gint save_settings;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 /* job printing */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 GenericDialog *job_dialog;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 GtkWidget *job_progress;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 GtkWidget *job_progress_label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 RenderFormat job_format;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 PrintOutput job_output;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 FILE *job_file;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 FILE *job_pipe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 gchar *job_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 GdkPixbuf *job_pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 gint job_page;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 ImageLoader *job_loader;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 static void print_job_throw_error(PrintWindow *pw, const gchar *message);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 static gint print_job_start(PrintWindow *pw, RenderFormat format, PrintOutput output);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 static void print_job_close(PrintWindow *pw, gint error);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 static void print_window_close(PrintWindow *pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 /* misc utils */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
322 static gboolean clip_region(gdouble x1, gdouble y1, gdouble w1, gdouble h1,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
323 gdouble x2, gdouble y2, gdouble w2, gdouble h2,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
324 gdouble *rx, gdouble *ry, gdouble *rw, gdouble *rh)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 if (x2 + w2 <= x1 || x2 >= x1 + w1 ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 y2 + h2 <= y1 || y2 >= y1 + h1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 *rx = MAX(x1, x2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 *rw = MIN((x1 + w1), (x2 + w2)) - *rx;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 *ry = MAX(y1, y2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 *rh = MIN((y1 + h1), (y2 + h2)) - *ry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 static const gchar *print_output_name(PrintOutput output)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 {
1177
5a20c47e7a14 Fix up unsigned expression always true/false warnings.
zas_
parents: 1174
diff changeset
343 if (output >= PRINT_OUTPUT_COUNT) return "";
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 return _(print_output_text[output]);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 * data
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 typedef struct _PaperSize PaperSize;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 struct _PaperSize {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 gchar *description;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 gint width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 gint height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 PaperOrientation orientation;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 const gchar *print_paper_units[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 N_("points"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 N_("millimeters"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 N_("centimeters"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 N_("inches"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 N_("picas"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 NULL
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 const gchar *print_paper_orientation[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 N_("Portrait"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 N_("Landscape"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 NULL
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 PaperSize print_paper_sizes[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 { N_("Custom"), 360, 720, PAPER_ORIENTATION_PORTRAIT },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 { N_("Letter"), 612, 792, PAPER_ORIENTATION_PORTRAIT }, /* in 8.5 x 11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382 { N_("Legal"), 612, 1008, PAPER_ORIENTATION_PORTRAIT }, /* in 8.5 x 14 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 { N_("Executive"), 522, 756, PAPER_ORIENTATION_PORTRAIT }, /* in 7.25x 10.5 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 { "A0", 2384, 3370, PAPER_ORIENTATION_PORTRAIT }, /* mm 841 x 1189 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 { "A1", 1684, 2384, PAPER_ORIENTATION_PORTRAIT }, /* mm 594 x 841 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 { "A2", 1191, 1684, PAPER_ORIENTATION_PORTRAIT }, /* mm 420 x 594 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 { "A3", 842, 1191, PAPER_ORIENTATION_PORTRAIT }, /* mm 297 x 420 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 { "A4", 595, 842, PAPER_ORIENTATION_PORTRAIT }, /* mm 210 x 297 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 { "A5", 420, 595, PAPER_ORIENTATION_PORTRAIT }, /* mm 148 x 210 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 { "A6", 298, 420, PAPER_ORIENTATION_PORTRAIT }, /* mm 105 x 148 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 { "B3", 1001, 1417, PAPER_ORIENTATION_PORTRAIT }, /* mm 353 x 500 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 { "B4", 709, 1001, PAPER_ORIENTATION_PORTRAIT }, /* mm 250 x 353 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 { "B5", 499, 709, PAPER_ORIENTATION_PORTRAIT }, /* mm 176 x 250 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 { "B6", 354, 499, PAPER_ORIENTATION_PORTRAIT }, /* mm 125 x 176 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 { N_("Envelope #10"), 297, 684, PAPER_ORIENTATION_LANDSCAPE }, /* in 4.125 x 9.5 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 { N_("Envelope #9"), 279, 639, PAPER_ORIENTATION_LANDSCAPE }, /* in 3.875 x 8.875 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 { N_("Envelope C4"), 649, 918, PAPER_ORIENTATION_LANDSCAPE }, /* mm 229 x 324 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 { N_("Envelope C5"), 459, 649, PAPER_ORIENTATION_LANDSCAPE }, /* mm 162 x 229 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 { N_("Envelope C6"), 323, 459, PAPER_ORIENTATION_LANDSCAPE }, /* mm 114 x 162 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 { N_("Photo 6x4"), 432, 288, PAPER_ORIENTATION_PORTRAIT }, /* in 6 x 4 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 { N_("Photo 8x10"), 576, 720, PAPER_ORIENTATION_PORTRAIT }, /* in 8 x 10 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 { N_("Postcard"), 284, 419, PAPER_ORIENTATION_LANDSCAPE }, /* mm 100 x 148 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 { N_("Tabloid"), 792, 1224, PAPER_ORIENTATION_PORTRAIT }, /* in 11 x 17 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 { NULL, 0, 0, 0 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 static PaperSize *print_paper_size_nth(gint n)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 PaperSize *ps = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 gint i = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 while (i <= n && print_paper_sizes[i].description)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 ps = &print_paper_sizes[i];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 i++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 return ps;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 static gint print_paper_size_lookup(gint n, gdouble *width, gdouble *height)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 PaperSize *ps;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 gdouble w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 ps = print_paper_size_nth(n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428 if (!ps) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 if (ps->orientation == PAPER_ORIENTATION_PORTRAIT)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 w = ps->width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433 h = ps->height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 h = ps->width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 w = ps->height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 if (width) *width = w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 if (height) *height = h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 static gdouble print_paper_size_convert_units(gdouble value, PaperUnits src, PaperUnits dst)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 gdouble ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 if (src == dst) return value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 switch (src)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 case PAPER_UNIT_MM:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 ret = value / 25.4 * 72.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 case PAPER_UNIT_CM:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 ret = value / 2.54 * 72.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 case PAPER_UNIT_INCH:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 ret = value * 72.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 case PAPER_UNIT_PICAS:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 ret = value * 12.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467 case PAPER_UNIT_POINTS:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 ret = value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 switch (dst)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 case PAPER_UNIT_MM:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 ret = ret / 72.0 * 25.4;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 case PAPER_UNIT_CM:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 ret = ret / 72.0 * 2.54;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 case PAPER_UNIT_INCH:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 ret = ret / 72.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 case PAPER_UNIT_PICAS:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 ret = ret / 12.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 case PAPER_UNIT_POINTS:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 static PaperUnits paper_unit_default(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 {
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 736
diff changeset
497 const gchar *result;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 /* this is not used because it is not even slightly portable */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 #include <langinfo.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 result = nl_langinfo(_NL_MEASUREMENT_MEASUREMENT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 if (result[0] == '2') return PAPER_UNIT_INCH;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 #ifdef LC_MEASUREMENT
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 result = setlocale(LC_MEASUREMENT, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 #else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 result = setlocale(LC_ALL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 if (result &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 (strstr(result, "_US") || strstr(result, "_PR")) )
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 return PAPER_UNIT_INCH;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 return PAPER_UNIT_CM;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 * the layout window
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 static gint print_layout_page_count(PrintWindow *pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 static gint print_preview_unit(gdouble points)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 {
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 736
diff changeset
531 return (gint)(points / PRINT_PREVIEW_SCALE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 static void print_proof_size(PrintWindow *pw, gdouble *width, gdouble *height)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 if (width) *width = pw->proof_width + PRINT_PROOF_MARGIN * 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 if (height)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 gdouble h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 h = pw->proof_height + PRINT_PROOF_MARGIN * 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 if (pw->text_fields != 0) h += PRINT_TEXT_PADDING;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 if (pw->text_fields & TEXT_INFO_FILENAME) h+= (gdouble)pw->text_points * 1.25;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 if (pw->text_fields & TEXT_INFO_DIMENSIONS) h+= (gdouble)pw->text_points * 1.25;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 if (pw->text_fields & TEXT_INFO_FILEDATE) h+= (gdouble)pw->text_points * 1.25;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 if (pw->text_fields & TEXT_INFO_FILESIZE) h+= (gdouble)pw->text_points * 1.25;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 *height = h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 static void print_window_layout_status(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 gint total;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 total = print_layout_page_count(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 pw->proof_page = CLAMP(pw->proof_page, 0, total - 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 buf = g_strdup_printf(_("page %d of %d"), pw->proof_page + 1, (total > 0) ? total : 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 gtk_label_set_text(GTK_LABEL(pw->page_label), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 gtk_widget_set_sensitive(pw->page_label, (total > 0));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 gtk_widget_set_sensitive(pw->button_back, (pw->proof_page > 0));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 gtk_widget_set_sensitive(pw->button_next, (pw->proof_page < total - 1));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 gtk_widget_set_sensitive(pw->print_button, total > 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 static void print_window_layout_render_stop(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 {
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1443
diff changeset
573 if (pw->layout_idle_id)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 g_source_remove(pw->layout_idle_id);
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1443
diff changeset
576 pw->layout_idle_id = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 static gboolean print_window_layout_render_idle(gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 print_job_close(pw, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 print_job_start(pw, RENDER_FORMAT_PREVIEW, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1443
diff changeset
587 pw->layout_idle_id = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 static void print_window_layout_render(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 gdouble proof_w, proof_h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 print_proof_size(pw, &proof_w, &proof_h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 pw->proof_columns = (pw->layout_width - pw->margin_left - pw->margin_right) / proof_w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 pw->proof_rows = (pw->layout_height - pw->margin_top - pw->margin_bottom) / proof_h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 print_window_layout_status(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1443
diff changeset
601 if (!pw->layout_idle_id)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 pw->layout_idle_id = g_idle_add(print_window_layout_render_idle, pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 static void print_window_layout_size(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 gdouble width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 gdouble height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 gint sw, sh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 if (!pw->layout_image) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 if (pw->paper_orientation == PAPER_ORIENTATION_LANDSCAPE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 width = pw->paper_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 height = pw->paper_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 width = pw->paper_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 height = pw->paper_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 pw->layout_width = width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 pw->layout_height = height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 sw = print_preview_unit(width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 sh = print_preview_unit(height);
23
17acca639a86 ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
632 pixbuf = image_get_pixbuf(pw->layout_image);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 if (!pixbuf ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 gdk_pixbuf_get_width(pixbuf) != sw ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 gdk_pixbuf_get_height(pixbuf) != sh)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, sw, sh);
1045
0ab0deb0cfcc added possibility to redraw only the parts of image that are already
nadvornik
parents: 1029
diff changeset
638 image_change_pixbuf(pw->layout_image, pixbuf, 0.0, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 g_object_unref(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 print_window_layout_render(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 print_window_layout_status(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 static gint print_layout_page_count(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 gint images;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 gint images_per_page;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 gint pages;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652 if (pw->layout_width - pw->margin_left - pw->margin_right <= 0.0 ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 pw->layout_height - pw->margin_top - pw->margin_bottom <= 0.0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 switch (pw->source)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 case PRINT_SOURCE_ALL:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 images = g_list_length(pw->source_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 case PRINT_SOURCE_SELECTION:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 images = g_list_length(pw->source_selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 case PRINT_SOURCE_IMAGE:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667 default:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
668 images = (pw->source_fd) ? 1 : 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 switch (pw->layout)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674 case PRINT_LAYOUT_PROOF:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675 images_per_page = pw->proof_columns * pw->proof_rows;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 case PRINT_LAYOUT_IMAGE:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 images_per_page = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 if (images < 1 || images_per_page < 1) return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 pages = images / images_per_page;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 if (pages * images_per_page < images) pages++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 return pages;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691 static void print_layout_page_step(PrintWindow *pw, gint step)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 gint max;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 gint page;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 max = print_layout_page_count(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 page = pw->proof_page + step;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 if (page >= max) page = max - 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 if (page < 0) page = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 if (page == pw->proof_page) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 pw->proof_page = page;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 print_window_layout_size(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708 static void print_layout_page_back_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 print_layout_page_step(pw, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 static void print_layout_page_next_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 print_layout_page_step(pw, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 static void print_layout_zoom_in_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 image_zoom_adjust(pw->layout_image, 0.25);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 static void print_layout_zoom_out_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 image_zoom_adjust(pw->layout_image, -0.25);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 static void print_layout_zoom_original_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 gdouble zoom;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 zoom = image_zoom_get(pw->layout_image);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 image_zoom_set(pw->layout_image, (zoom == 1.0) ? 0.0 : 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 static GtkWidget *print_window_layout_setup(PrintWindow *pw, GtkWidget *box)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 GtkWidget *group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 vbox = pref_box_new(box, TRUE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 group = pref_frame_new(vbox, TRUE, _("Preview"), GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1443
diff changeset
753 pw->layout_idle_id = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 pw->layout_image = image_new(FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 gtk_widget_set_size_request(pw->layout_image->widget, PRINT_DLG_PREVIEW_WIDTH, PRINT_DLG_PREVIEW_HEIGHT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 gtk_box_pack_start(GTK_BOX(group), pw->layout_image->widget, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 gtk_widget_show(pw->layout_image->widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 pw->button_back = pref_button_new(hbox, GTK_STOCK_GO_BACK, NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 G_CALLBACK(print_layout_page_back_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 pw->button_next = pref_button_new(hbox, GTK_STOCK_GO_FORWARD, NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 G_CALLBACK(print_layout_page_next_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 pw->page_label = pref_label_new(hbox, "");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 button = pref_button_new(NULL, GTK_STOCK_ZOOM_OUT, NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 G_CALLBACK(print_layout_zoom_out_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 button = pref_button_new(NULL, GTK_STOCK_ZOOM_IN, NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 G_CALLBACK(print_layout_zoom_in_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 button = pref_button_new(NULL, GTK_STOCK_ZOOM_100, NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777 G_CALLBACK(print_layout_zoom_original_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 print_window_layout_size(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 return vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 static void print_window_spin_set(GtkSpinButton *spin, gpointer block_data,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787 gdouble value, gdouble min, gdouble max,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 gdouble step, gdouble page, gint digits)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 if (block_data) g_signal_handlers_block_matched(G_OBJECT(spin), G_SIGNAL_MATCH_DATA,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 0, 0, NULL, NULL, block_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 gtk_spin_button_set_digits(spin, digits);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 gtk_spin_button_set_increments(spin, step, page);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 gtk_spin_button_set_range(spin, min, max);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 gtk_spin_button_set_value(spin, value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 if (block_data) g_signal_handlers_unblock_matched(G_OBJECT(spin), G_SIGNAL_MATCH_DATA,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 0, 0, NULL, NULL, block_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 static void print_window_layout_sync_layout(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 gtk_widget_set_sensitive(pw->image_scale_spin, (pw->layout == PRINT_LAYOUT_IMAGE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 gtk_widget_set_sensitive(pw->proof_group, (pw->layout == PRINT_LAYOUT_PROOF));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807 static void print_window_layout_sync_paper(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809 gdouble width, height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810 gint digits;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811 gdouble step;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 gdouble page;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 gtk_widget_set_sensitive(pw->paper_width_spin, (pw->paper_size == 0));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815 gtk_widget_set_sensitive(pw->paper_height_spin, (pw->paper_size == 0));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 width = print_paper_size_convert_units((gdouble)pw->paper_width, PAPER_UNIT_POINTS, pw->paper_units);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818 height = print_paper_size_convert_units((gdouble)pw->paper_height, PAPER_UNIT_POINTS, pw->paper_units);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 switch (pw->paper_units)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 case PAPER_UNIT_MM:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 digits = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 step = 1.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 page = 10.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 case PAPER_UNIT_CM:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 digits = 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829 step = 0.5;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 page = 1.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 case PAPER_UNIT_INCH:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 digits = 3;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 step = 0.25;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 page = 1.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 case PAPER_UNIT_PICAS:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 digits = 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839 step = 1.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 page = 6.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 case PAPER_UNIT_POINTS:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844 digits = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 step = 1.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 page = 10.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 print_window_spin_set(GTK_SPIN_BUTTON(pw->paper_width_spin), pw, width,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 print_paper_size_convert_units(PRINT_MIN_WIDTH, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 print_paper_size_convert_units(PRINT_MAX_WIDTH, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853 step, page, digits);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 print_window_spin_set(GTK_SPIN_BUTTON(pw->paper_height_spin), pw, height,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856 print_paper_size_convert_units(PRINT_MIN_HEIGHT, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 print_paper_size_convert_units(PRINT_MAX_HEIGHT, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 step, page, digits);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 print_window_spin_set(GTK_SPIN_BUTTON(pw->margin_left_spin), pw,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 print_paper_size_convert_units(pw->margin_left, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 0.0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863 print_paper_size_convert_units(PRINT_MAX_WIDTH, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 step, page, digits);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866 print_window_spin_set(GTK_SPIN_BUTTON(pw->margin_right_spin), pw,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 print_paper_size_convert_units(pw->margin_right, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 0.0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 print_paper_size_convert_units(PRINT_MAX_WIDTH, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 step, page, digits);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872 print_window_spin_set(GTK_SPIN_BUTTON(pw->margin_top_spin), pw,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 print_paper_size_convert_units(pw->margin_top, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 0.0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 print_paper_size_convert_units(PRINT_MAX_HEIGHT, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 step, page, digits);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 print_window_spin_set(GTK_SPIN_BUTTON(pw->margin_bottom_spin), pw,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879 print_paper_size_convert_units(pw->margin_bottom, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 0.0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881 print_paper_size_convert_units(PRINT_MAX_HEIGHT, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 step, page, digits);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884 print_window_spin_set(GTK_SPIN_BUTTON(pw->proof_width_spin), pw,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 print_paper_size_convert_units(pw->proof_width, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 print_paper_size_convert_units(PRINT_PROOF_MIN_SIZE, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 print_paper_size_convert_units(PRINT_PROOF_MAX_SIZE, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 step, page, digits);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890 print_window_spin_set(GTK_SPIN_BUTTON(pw->proof_height_spin), pw,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 print_paper_size_convert_units(pw->proof_height, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 print_paper_size_convert_units(PRINT_PROOF_MIN_SIZE, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 print_paper_size_convert_units(PRINT_PROOF_MAX_SIZE, PAPER_UNIT_POINTS, pw->paper_units),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 step, page, digits);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 static void print_window_layout_set_size(PrintWindow *pw, gdouble width, gdouble height)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 pw->paper_width = width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900 pw->paper_height = height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 print_window_layout_sync_paper(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 print_window_layout_size(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 static void print_window_layout_set_orientation(PrintWindow *pw, PaperOrientation o)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 if (pw->paper_orientation == o) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 pw->paper_orientation = o;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 print_window_layout_size(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
918 * list printers
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922 static GList *print_window_list_printers(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924 FILE *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 gchar buffer[2048];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 p = popen(PRINT_LPR_QUERY, "r");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929 if (!p) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 while (fgets(buffer, sizeof(buffer), p) != NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 gchar *ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 gchar *end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 ptr = buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 if (strncmp(ptr, "printer ", 8) != 0) continue;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 if (strstr(ptr, "enabled") == NULL) continue;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939 ptr += 8;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940 end = ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941 while (*end != '\0' && *end != '\n' && *end != ' ' && *end != '\t') end++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 *end = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 list = g_list_append(list, g_strdup(ptr));
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
944 DEBUG_1("adding printer: %s", ptr);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947 pclose(p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954 * print ps
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 typedef struct _PipeError PipeError;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 struct _PipeError {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 struct sigaction old_action;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 sig_atomic_t *error;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 static sig_atomic_t pipe_handler_error = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 static PipeError *pipe_handler_data = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
966
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 736
diff changeset
967 static void pipe_handler_sigpipe_cb(gint fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 pipe_handler_error = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 static PipeError *pipe_handler_new(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974 struct sigaction new_action;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 PipeError *pe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 if (pipe_handler_data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
979 log_printf("warning SIGPIPE handler already in use\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 pe = g_new0(PipeError, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 pipe_handler_error = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 pe->error = &pipe_handler_error;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 new_action.sa_handler = pipe_handler_sigpipe_cb;
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 507
diff changeset
989 sigemptyset(&new_action.sa_mask);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 new_action.sa_flags = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
991
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992 /* setup our signal handler */
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 507
diff changeset
993 sigaction(SIGPIPE, &new_action, &pe->old_action);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 pipe_handler_data = pe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 return pe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 static void pipe_handler_free(PipeError *pe)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 if (!pe) return;
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
1002 if (pe != pipe_handler_data) log_printf("warning SIGPIPE handler not closing same data\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 /* restore the original signal handler */
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 507
diff changeset
1005 sigaction(SIGPIPE, &pe->old_action, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007 pipe_handler_data = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 g_free(pe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1011 static gboolean pipe_handler_check(PipeError *pe)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013 if (!pe) return FALSE;
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1014 return !!(*pe->error);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 static FILE *print_job_ps_fd(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 if (pw->job_file) return pw->job_file;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020 if (pw->job_pipe) return pw->job_pipe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1024 static gboolean print_job_ps_init(PrintWindow *pw)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 PipeError *pe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028 const gchar *cmd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 const gchar *path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030 gchar *lc_pointer;
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1031 gboolean ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 if (pw->job_file != NULL || pw->job_pipe != NULL) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035 switch (pw->job_output)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037 case PRINT_OUTPUT_PS_LPR:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038 cmd = PRINT_LPR_COMMAND;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040 case PRINT_OUTPUT_PS_CUSTOM:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 cmd = pw->output_custom;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 case PRINT_OUTPUT_PS_FILE:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 path = pw->output_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051 if (cmd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053 pw->job_pipe = popen(cmd, "w");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 if (!pw->job_pipe)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 buf = g_strdup_printf(_("Unable to open pipe for writing.\n\"%s\""), cmd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 print_job_throw_error(pw, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 else if (path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 if (isfile(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074 buf = g_strdup_printf(_("A file with name %s already exists."), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 print_job_throw_error(pw, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081 pathl = path_from_utf8(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1082 pw->job_file = fopen(pathl, "w");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085 if (!pw->job_file)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1087 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089 buf = g_strdup_printf(_("Failure writing to file %s"), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 print_job_throw_error(pw, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1094 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096 g_free(pw->job_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1097 pw->job_path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100 f = print_job_ps_fd(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101 if (!f) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 lc_pointer = g_strdup(setlocale(LC_NUMERIC, NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104 setlocale(LC_NUMERIC, POSTSCRIPT_LOCALE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 pe = pipe_handler_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 /* comments, etc. */
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1109 g_fprintf(f, "%%!PS-Adobe-3.0\n");
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1110 g_fprintf(f, "%%%%Creator: %s Version %s\n", GQ_APPNAME, VERSION);
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1111 g_fprintf(f, "%%%%CreationDate: \n");
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1112 g_fprintf(f, "%%%%LanguageLevel 2\n");
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1113 g_fprintf(f, "%%%%DocumentMedia: \n");
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1114 g_fprintf(f, "%%%%Orientation: %s\n",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115 (pw->paper_orientation == PAPER_ORIENTATION_PORTRAIT) ? "Portrait" : "Landscape");
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1116 g_fprintf(f, "%%%%BoundingBox: %f %f %f %f\n",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117 0.0, 0.0, pw->paper_width, pw->paper_height);
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1118 g_fprintf(f, "%%%%Pages: %d\n", print_layout_page_count(pw));
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1119 g_fprintf(f, "%%%%PageOrder: Ascend\n");
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1120 g_fprintf(f, "%%%%Title:\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1121
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122 /* setup page size, coordinates (do we really need this?) */
1614
25bed5b179be enabled PageSize code
nadvornik
parents: 1523
diff changeset
1123 /* enabled for 1.0beta2 https://bugzilla.redhat.com/222639 */
25bed5b179be enabled PageSize code
nadvornik
parents: 1523
diff changeset
1124 #if 1
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1125 g_fprintf(f, "<<\n");
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1126 g_fprintf(f, "/PageSize [%f %f]\n", pw->layout_width, pw->layout_height);
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1127 g_fprintf(f, "/ImagingBBox [%f %f %f %f]\n", /* l b r t */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 pw->margin_left, pw->margin_bottom,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 pw->layout_width - pw->margin_right, pw->layout_height - pw->margin_top);
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1130 g_fprintf(f, "/Orientation %d\n",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 (pw->paper_orientation == PAPER_ORIENTATION_PORTRAIT) ? 0 : 1);
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1132 g_fprintf(f, ">> setpagedevice\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1135 ret = !pipe_handler_check(pe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1136 pipe_handler_free(pe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 if (lc_pointer)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 setlocale(LC_NUMERIC, lc_pointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141 g_free(lc_pointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1144 if (!ret) print_job_throw_error(pw, _("SIGPIPE error writing to printer."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1149 static gboolean print_job_ps_page_new(PrintWindow *pw, gint page)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1151 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152 PipeError *pe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153 gchar *lc_pointer;
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1154 gboolean ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156 f= print_job_ps_fd(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157 if (!f) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 lc_pointer = g_strdup(setlocale(LC_NUMERIC, NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 setlocale(LC_NUMERIC, POSTSCRIPT_LOCALE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 pe = pipe_handler_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1164 g_fprintf(f, "%%%% page %d\n", page + 1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 if (pw->paper_orientation == PAPER_ORIENTATION_LANDSCAPE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167 {
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1168 g_fprintf(f, "/pagelevel save def\n");
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1169 g_fprintf(f, "%d 0 translate 90 rotate\n", (gint)pw->layout_height);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172 ret = !pipe_handler_check(pe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173 pipe_handler_free(pe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175 if (lc_pointer)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177 setlocale(LC_NUMERIC, lc_pointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 g_free(lc_pointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181 if (!ret) print_job_throw_error(pw, _("SIGPIPE error writing to printer."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1186 static gboolean print_job_ps_page_done(PrintWindow *pw)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 PipeError *pe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190 gchar *lc_pointer;
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1191 gboolean ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 f = print_job_ps_fd(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 if (!f) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 lc_pointer = g_strdup(setlocale(LC_NUMERIC, NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197 setlocale(LC_NUMERIC, POSTSCRIPT_LOCALE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199 pe = pipe_handler_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 if (pw->paper_orientation == PAPER_ORIENTATION_LANDSCAPE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 {
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1203 g_fprintf(f, "pagelevel restore\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1206 g_fprintf(f, "showpage\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 ret = !pipe_handler_check(pe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209 pipe_handler_free(pe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211 if (lc_pointer)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213 setlocale(LC_NUMERIC, lc_pointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 g_free(lc_pointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 if (!ret) print_job_throw_error(pw, _("SIGPIPE error writing to printer."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 static void print_job_ps_page_image_pixel(FILE *f, guchar *pix)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224 static gchar hex_digits[] = "0123456789abcdef";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225 gchar text[8];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 gint i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228 for (i = 0; i < 3; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 text[i*2] = hex_digits[pix[i] >> 4];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231 text[i*2+1] = hex_digits[pix[i] & 0xf];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233 text[6] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1235 g_fprintf(f, "%s", text);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
1236 }
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1237 static gboolean print_job_ps_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1238 gdouble x, gdouble y, gdouble w, gdouble h,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1239 gdouble offx, gdouble offy)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1242 PipeError *pe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243 gchar *lc_pointer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1244 gint sw, sh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245 gint bps;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246 gint rowstride;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247 guchar *pix;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248 gint i, j;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1249 gint c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1250 guchar *p;
121
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
1251 guchar bps_buf[3];
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1252 gboolean ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1254 if (!pixbuf) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256 f = print_job_ps_fd(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257 if (!f) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1259 sw = gdk_pixbuf_get_width(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1260 sh = gdk_pixbuf_get_height(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1261
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1262 if (pw->max_dpi >= PRINT_PS_DPI_MIN &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1263 sw / pw->max_dpi > w / 72.0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1265 pixbuf = gdk_pixbuf_scale_simple(pixbuf,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266 (gint)(w / 72.0 * pw->max_dpi),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267 (gint)(h / 72.0 * pw->max_dpi),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268 PRINT_PS_MAX_INTERP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269 sw = gdk_pixbuf_get_width(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270 sh = gdk_pixbuf_get_height(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274 g_object_ref(G_OBJECT(pixbuf));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1275 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1276
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277 bps = (gdk_pixbuf_get_has_alpha(pixbuf)) ? 4 : 3;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278 rowstride = gdk_pixbuf_get_rowstride(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 pix = gdk_pixbuf_get_pixels(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281 lc_pointer = g_strdup(setlocale(LC_NUMERIC, NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282 setlocale(LC_NUMERIC, POSTSCRIPT_LOCALE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1283
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284 pe = pipe_handler_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1285
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1286 g_fprintf(f, "gsave\n");
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1287 g_fprintf(f, "[%f 0 0 %f %f %f] concat\n", w, h, x, pw->layout_height - h - y);
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1288 g_fprintf(f, "/buf %d string def\n", sw * 3);
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1289 g_fprintf(f, "%d %d %d\n", sw, sh, 8);
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1290 g_fprintf(f, "[%d 0 0 -%d 0 %d]\n", sw, sh, sh);
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1291 g_fprintf(f, "{ currentfile buf readhexstring pop }\n");
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1292 g_fprintf(f, "false %d colorimage\n", 3);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1294 c = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 for (j = 0; j < sh; j++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1297 p = pix + j * rowstride;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1298 for (i = 0; i < sw; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1299 {
121
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
1300 if (bps == 3)
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
1301 {
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
1302 print_job_ps_page_image_pixel(f, p);
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
1303 }
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
1304 else
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
1305 {
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
1306 bps_buf[0] = (p[0] * p[3] + PRINT_PS_MASK_R * (256 - p[3])) >> 8;
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
1307 bps_buf[1] = (p[1] * p[3] + PRINT_PS_MASK_G * (256 - p[3])) >> 8;
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
1308 bps_buf[2] = (p[2] * p[3] + PRINT_PS_MASK_B * (256 - p[3])) >> 8;
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
1309 print_job_ps_page_image_pixel(f, bps_buf);
045ac4c27e62 Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net>
gqview
parents: 23
diff changeset
1310 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1311 p+=bps;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1312 c++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1313 if (c > 11)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1314 {
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1315 g_fprintf(f, "\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1316 c = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1317 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1318 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1319 }
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1320 if (c > 0) g_fprintf(f, "\n");
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1321 g_fprintf(f, "grestore\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1322
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1323 ret = !pipe_handler_check(pe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1324 pipe_handler_free(pe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1325
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1326 if (lc_pointer)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1327 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1328 setlocale(LC_NUMERIC, lc_pointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1329 g_free(lc_pointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1330 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1331
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1332 g_object_unref(G_OBJECT(pixbuf));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1333
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1334 if (!ret) print_job_throw_error(pw, _("SIGPIPE error writing to printer."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1335
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1336 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1337 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1338
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1339 static const gchar *ps_text_to_hex_array(FILE *f, const gchar *text, gdouble x, gdouble y)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1340 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1341 static gchar hex_digits[] = "0123456789abcdef";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1342 const gchar *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1343
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1344 if (!text) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1345
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1346 g_fprintf(f, "%f %f moveto\n", x, y);
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1347 g_fprintf(f, "<");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1348
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1349 /* fixme: convert utf8 to ascii or proper locale string.. */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1350
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1351 p = text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1352 while (*p != '\0' && *p != '\n')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1353 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1354 gchar text[3];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1355
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1356 text[0] = hex_digits[*p >> 4];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1357 text[1] = hex_digits[*p & 0xf];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1358 text[2] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1359
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1360 g_fprintf(f, "%s", text);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1361
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1362 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1363 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1364
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1365 g_fprintf(f, ">\n");
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1366 g_fprintf(f, "dup stringwidth pop 2 div neg 0 rmoveto show\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1367
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1368 return p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1369 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1370
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1371 static void ps_text_parse(FILE *f, const gchar *text, gdouble x, gdouble y, gdouble point_size)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1372 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1373 const gchar *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1374
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1375 if (!text) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1376
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1377 g_fprintf(f, "newpath\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1378
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1379 p = text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1380 while (p && *p != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1381 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1382 p = ps_text_to_hex_array(f, p, x, y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1383 if (p && *p == '\n') p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1384 y -= point_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1385 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1386
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1387 g_fprintf(f, "closepath\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1388 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1389
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1390 static gboolean print_job_ps_page_text(PrintWindow *pw, const gchar *text, gdouble point_size,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1391 gdouble x, gdouble y, gdouble width,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1392 guint8 r, guint8 g, guint8 b)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1393 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1394 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1395 PipeError *pe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1396 gchar *lc_pointer;
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1397 gboolean ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1398
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1399 if (!text) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1400
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1401 f = print_job_ps_fd(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1402 if (!f) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1403
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1404 lc_pointer = g_strdup(setlocale(LC_NUMERIC, NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1405 setlocale(LC_NUMERIC, POSTSCRIPT_LOCALE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1406
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1407 pe = pipe_handler_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1408
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1409 g_fprintf(f, "/Sans findfont\n");
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1410 g_fprintf(f, "%f scalefont\n", point_size);
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1411 g_fprintf(f, "setfont\n");
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1412
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1413 g_fprintf(f, "%f %f %f setrgbcolor\n", (gdouble)r / 255.0, (gdouble)g / 255.0, (gdouble)b / 255.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1414 ps_text_parse(f, text, x, pw->layout_height - y - point_size, point_size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1415
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1416 ret = !pipe_handler_check(pe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1417 pipe_handler_free(pe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1418
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1419 if (lc_pointer)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1420 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1421 setlocale(LC_NUMERIC, lc_pointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1422 g_free(lc_pointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1423 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1424
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1425 if (!ret) print_job_throw_error(pw, _("SIGPIPE error writing to printer."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1426
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1427 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1428 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1429
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1430 static gboolean print_job_ps_end(PrintWindow *pw)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1431 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1432 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1433 PipeError *pe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1434 gchar *lc_pointer;
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1435 gboolean ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1436
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1437 f = print_job_ps_fd(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1438 if (!f) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1439
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1440 lc_pointer = g_strdup(setlocale(LC_NUMERIC, NULL));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1441 setlocale(LC_NUMERIC, POSTSCRIPT_LOCALE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1442
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1443 pe = pipe_handler_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1444
1305
2abdd6e50120 Glibification.
zas_
parents: 1284
diff changeset
1445 g_fprintf(f, "%%%%EOF\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1446
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1447 ret = !pipe_handler_check(pe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1448 pipe_handler_free(pe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1449
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1450 if (lc_pointer)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1451 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1452 setlocale(LC_NUMERIC, lc_pointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1453 g_free(lc_pointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1454 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1455
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1456 if (!ret) print_job_throw_error(pw, _("SIGPIPE error writing to printer."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1457
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1458 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1459 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1460
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1461 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1462 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1463 * print rgb
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1464 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1465 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1466
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1467 static gboolean print_job_rgb_page_new(PrintWindow *pw, gint page)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1468 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1469 gint total;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1470
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1471 if (pw->job_pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1472 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1473 pixbuf_set_rect_fill(pw->job_pixbuf, 0, 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1474 gdk_pixbuf_get_width(pw->job_pixbuf),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1475 gdk_pixbuf_get_height(pw->job_pixbuf),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1476 255, 255, 255, 255);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1477 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1478
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1479 g_free(pw->job_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1480 pw->job_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1481
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1482 total = print_layout_page_count(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1483
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1484 if (!pw->output_path ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1485 page < 0 || page >= total) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1486
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1487 if (total > 1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1488 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1489 const gchar *ext;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1490 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1491
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1492 ext = extension_from_path(pw->output_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1493
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1494 if (ext)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1495 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1496 base = g_strndup(pw->output_path, ext - pw->output_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1497 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1498 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1499 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1500 base = g_strdup(pw->output_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1501 ext = "";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1502 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1503 pw->job_path = g_strdup_printf("%s_%03d%s", base, page + 1, ext);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1504 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1505 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1506 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1507 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1508 pw->job_path = g_strdup(pw->output_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1509 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1510
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1511 if (isfile(pw->job_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1512 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1513 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1514
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1515 buf = g_strdup_printf(_("A file with name %s already exists."), pw->job_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1516 print_job_throw_error(pw, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1517 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1518
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1519 g_free(pw->job_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1520 pw->job_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1521 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1522
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1523 return (pw->job_path != NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1524 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1525
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1526 static gboolean print_job_rgb_page_done(PrintWindow *pw)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1527 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1528 gchar *pathl;
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1347
diff changeset
1529 gboolean ret = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1530
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1531 if (!pw->job_pixbuf) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1532
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1533 pathl = path_from_utf8(pw->job_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1534
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1535 if (pw->output_format == PRINT_FILE_PNG)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1536 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1537 ret = pixbuf_to_file_as_png(pw->job_pixbuf, pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1538 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1539 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1540 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1541 gint quality = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1542
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1543 switch (pw->output_format)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1544 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1545 case PRINT_FILE_JPG_LOW:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1546 quality = 65;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1547 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1548 case PRINT_FILE_JPG_NORMAL:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1549 quality = 80;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1550 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1551 case PRINT_FILE_JPG_HIGH:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1552 quality = 95;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1553 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1554 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1555 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1556 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1557
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1558 if (quality > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1559 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1560 ret = pixbuf_to_file_as_jpg(pw->job_pixbuf, pathl, quality);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1561 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1562 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1563
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1564 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1565
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1566 if (!ret)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1567 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1568 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1569
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1570 buf = g_strdup_printf(_("Failure writing to file %s"), pw->job_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1571 print_job_throw_error(pw, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1572 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1573 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1574
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1575 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1576 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1577
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1578 static gboolean print_job_rgb_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1579 gdouble x, gdouble y, gdouble w, gdouble h,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1580 gdouble offx, gdouble offy)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1581 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1582 gdouble sw, sh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1583 gdouble dw, dh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1584 gdouble rx, ry, rw, rh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1585
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1586 if (!pw->job_pixbuf) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1587 if (!pixbuf) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1588
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1589 sw = (gdouble)gdk_pixbuf_get_width(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1590 sh = (gdouble)gdk_pixbuf_get_height(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1591
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1592 dw = (gdouble)gdk_pixbuf_get_width(pw->job_pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1593 dh = (gdouble)gdk_pixbuf_get_height(pw->job_pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1594
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
1595 if (clip_region(x, y, w, h,
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
1596 0.0, 0.0, dw, dh,
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
1597 &rx, &ry, &rw, &rh))
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
1598 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1599 gdk_pixbuf_composite(pixbuf, pw->job_pixbuf, rx, ry, rw, rh,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1600 x + offx, y + offy,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1601 w / sw, h / sh,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1602 (w / sw < 0.01 || h / sh < 0.01) ? GDK_INTERP_NEAREST : GDK_INTERP_BILINEAR, 255);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1603 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1604
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1605 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1606 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1607
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1608 static gdouble convert_pango_dpi(gdouble points)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1609 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1610 static gdouble dpi = 0.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1611
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1612 if (dpi == 0.0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1613 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1614 GtkSettings *settings;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1615 GObjectClass *klass;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1616
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1617 settings = gtk_settings_get_default();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1618 klass = G_OBJECT_CLASS(GTK_SETTINGS_GET_CLASS(settings));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1619 if (g_object_class_find_property(klass, "gtk-xft-dpi"))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1620 {
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 736
diff changeset
1621 gint int_dpi;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1622 g_object_get(settings, "gtk-xft-dpi", &int_dpi, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1623 dpi = (gdouble)int_dpi / PANGO_SCALE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1624 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1625
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1626 if (dpi < 25.0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1627 {
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1347
diff changeset
1628 static gboolean warned = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1629 gdouble fallback_dpi = 96.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1630
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1631 if (!warned)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1632 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1633 if (dpi == 0.0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1634 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
1635 log_printf("pango dpi unknown, assuming %.0f\n", fallback_dpi);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1636 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1637 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1638 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
1639 log_printf("pango dpi reported as %.0f ignored, assuming %.0f\n", dpi, fallback_dpi);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1640 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1641 warned = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1642 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1643
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1644 dpi = fallback_dpi;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1645 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1646 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1647
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1648 if (dpi == 0) return points;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1649 return points * 72.0 / dpi;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1650 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1651
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1652 static gboolean print_job_rgb_page_text(PrintWindow *pw, const gchar *text, gdouble point_size,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1653 gdouble x, gdouble y, gdouble width,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1654 guint8 r, guint8 g, guint8 b)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1655 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1656 PangoLayout *layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1657 PangoFontDescription *desc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1658 gint lw, lh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1659
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1660 if (!pw->job_pixbuf) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1661
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1662 layout = gtk_widget_create_pango_layout(pw->dialog->dialog, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1663
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1664 desc = pango_font_description_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1665 pango_font_description_set_size(desc, convert_pango_dpi(point_size) * PANGO_SCALE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1666 pango_layout_set_font_description(layout, desc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1667 pango_font_description_free(desc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1668
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1669 pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1670 pango_layout_set_text(layout, text, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1671
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1672 pango_layout_get_pixel_size(layout, &lw, &lh);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1673 x = x - (gdouble)lw / 2.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1674
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1675 pixbuf_draw_layout(pw->job_pixbuf, layout, pw->dialog->dialog, x, y, r, g, b, 255);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1676 g_object_unref(G_OBJECT(layout));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1677
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1678 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1679 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1680
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1681 static gboolean print_job_rgb_init(PrintWindow *pw)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1682 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1683 if (pw->job_pixbuf) g_object_unref(pw->job_pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1684 pw->job_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1685 (gint)pw->layout_width, (gint)pw->layout_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1686
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1687 return print_job_rgb_page_new(pw, pw->job_page);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1688 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1689
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1690 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1691 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1692 * print preview
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1693 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1694 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1695
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1696 static gboolean print_job_preview_page_new(PrintWindow *pw, gint page)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1697 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1698 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1699 gint w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1700 gint l, r, t, b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1701
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1702 pixbuf = pw->job_pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1703 if (!pixbuf) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1704
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1705 w = print_preview_unit(pw->layout_width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1706 h = print_preview_unit(pw->layout_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1707 l = print_preview_unit(pw->margin_left);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1708 r = print_preview_unit(pw->margin_right);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1709 t = print_preview_unit(pw->margin_top);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1710 b = print_preview_unit(pw->margin_bottom);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1711
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1712 /* fill background */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1713 pixbuf_set_rect_fill(pixbuf, 0, 0, w, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1714 255, 255, 255, 255);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1715
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1716 /* draw cm or inch grid */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1717 if (TRUE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1718 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1719 gdouble i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1720 gdouble grid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1721 PaperUnits units;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1722
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1723 units = (pw->paper_units == PAPER_UNIT_MM ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1724 pw->paper_units == PAPER_UNIT_CM) ? PAPER_UNIT_CM : PAPER_UNIT_INCH;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1725
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1726 grid = print_paper_size_convert_units(1.0, units, PAPER_UNIT_POINTS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1727 for (i = grid ; i < pw->layout_width; i += grid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1728 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1729 pixbuf_draw_rect_fill(pixbuf, print_preview_unit(i), 0, 1, h, 0, 0, 0, 16);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1730 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1731 for (i = grid; i < pw->layout_height; i += grid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1732 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1733 pixbuf_draw_rect_fill(pixbuf, 0, print_preview_unit(i), w, 1, 0, 0, 0, 16);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1734 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1735 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1736
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1737 /* proof sheet grid */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1738 if (pw->layout == PRINT_LAYOUT_PROOF)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1739 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1740 gdouble i, j;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1741 gdouble proof_w, proof_h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1742 gint uw, uh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1743
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1744 print_proof_size(pw, &proof_w, &proof_h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1745 uw = print_preview_unit(proof_w + PRINT_PREVIEW_SCALE - 0.1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1746 uh = print_preview_unit(proof_h + PRINT_PREVIEW_SCALE - 0.1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1747
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1748 for (i = 0; i < pw->proof_columns; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1749 for (j = 0; j < pw->proof_rows; j++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1750 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1751 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1752
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1753 x = pw->margin_left + (pw->layout_width - pw->margin_left - pw->margin_right - (pw->proof_columns * proof_w)) / 2 + i * proof_w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1754 y = pw->margin_top + j * proof_h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1755
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1756 pixbuf_draw_rect(pixbuf, print_preview_unit(x), print_preview_unit(y), uw, uh,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1757 255, 0, 0, 64, 1, 1, 1, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1758 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1759 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1760
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1761 /* non-printable region (margins) */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1762 pixbuf_draw_rect(pixbuf, 0, 0, w, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1763 0, 0, 0, 16,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1764 l, r, t, b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1765
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1766 /* margin lines */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1767 pixbuf_draw_rect(pixbuf, l, 0, w - l - r, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1768 0, 0, 255, 128,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1769 1, 1, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1770 pixbuf_draw_rect(pixbuf, 0, t, w, h - t - b,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1771 0, 0, 255, 128,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1772 0, 0, 1, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1773
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1774 /* border */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1775 pixbuf_draw_rect(pixbuf, 0, 0, w, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1776 0, 0, 0, 255,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1777 1, 1, 1, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1778
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1779 image_area_changed(pw->layout_image, 0, 0, w, h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1780
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1781 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1782 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1783
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1784 static gboolean print_job_preview_page_done(PrintWindow *pw)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1785 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1786 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1787 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1788
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1789 static gboolean print_job_preview_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1790 gdouble x, gdouble y, gdouble w, gdouble h,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1791 gdouble offx, gdouble offy)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1792 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1793 gdouble sw, sh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1794 gdouble dw, dh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1795 gdouble rx, ry, rw, rh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1796
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1797 if (!pw->job_pixbuf) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1798 if (!pixbuf) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1799
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1800 sw = (gdouble)gdk_pixbuf_get_width(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1801 sh = (gdouble)gdk_pixbuf_get_height(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1802
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1803 dw = (gdouble)gdk_pixbuf_get_width(pw->job_pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1804 dh = (gdouble)gdk_pixbuf_get_height(pw->job_pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1805
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1806 x = print_preview_unit(x);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1807 y = print_preview_unit(y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1808 w = print_preview_unit(w);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1809 h = print_preview_unit(h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1810 offx = print_preview_unit(offx);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1811 offy = print_preview_unit(offy);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1812
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1813 if (clip_region(x, y, w, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1814 0.0, 0.0, dw, dh,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1815 &rx, &ry, &rw, &rh))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1816 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1817 gdk_pixbuf_composite(pixbuf, pw->job_pixbuf, rx, ry, rw, rh,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1818 x + offx, y + offy,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1819 w / sw, h / sh,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1820 (w / sw < 0.01 || h / sh < 0.01) ? GDK_INTERP_NEAREST : GDK_INTERP_BILINEAR, 255);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1821
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1822 image_area_changed(pw->layout_image, rx, ry, rw, rh);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1823 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1824
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1825 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1826 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1827
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1828 static gboolean print_job_preview_page_text(PrintWindow *pw, const gchar *text, gdouble point_size,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1829 gdouble x, gdouble y, gdouble width,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1830 guint8 r, guint8 g, guint8 b)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1831 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1832 PangoLayout *layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1833 PangoFontDescription *desc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1834 gint lw, lh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1835 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1836
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1837 if (!pw->job_pixbuf) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1838
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1839 layout = gtk_widget_create_pango_layout(pw->dialog->dialog, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1840
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1841 desc = pango_font_description_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1842 pango_font_description_set_size(desc, convert_pango_dpi(point_size) * PANGO_SCALE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1843 pango_layout_set_font_description(layout, desc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1844 pango_font_description_free(desc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1845
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1846 pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1847 pango_layout_set_text(layout, text, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1848
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1849 pango_layout_get_pixel_size(layout, &lw, &lh);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1850 x = x - (gdouble)lw / 2.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1851
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1852 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, lw, lh);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1853 pixbuf_set_rect_fill(pixbuf, 0, 0, lw, lh, 0, 0, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1854 pixbuf_draw_layout(pixbuf, layout, pw->dialog->dialog, 0, 0, r, g, b, 255);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1855 g_object_unref(G_OBJECT(layout));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1856
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1857 print_job_preview_page_image(pw, pixbuf, x, y, (gdouble)lw, (gdouble)lh, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1858 g_object_unref(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1859
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1860 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1861 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1862
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1863 static gboolean print_job_preview_init(PrintWindow *pw)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1864 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1865 if (pw->job_pixbuf) g_object_unref(pw->job_pixbuf);
23
17acca639a86 ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
1866 pw->job_pixbuf = image_get_pixbuf(pw->layout_image);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1867 g_object_ref(pw->job_pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1868
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1869 return print_job_preview_page_new(pw, pw->job_page);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1870 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1871
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1872
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1873 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1874 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1875 * wrappers
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1876 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1877 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1878
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1879 static gboolean print_job_page_new(PrintWindow *pw)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1880 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1881 switch (pw->job_format)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1882 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1883 case RENDER_FORMAT_RGB:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1884 return print_job_rgb_page_new(pw, pw->job_page);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1885 case RENDER_FORMAT_PS:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1886 return print_job_ps_page_new(pw, pw->job_page);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1887 case RENDER_FORMAT_PREVIEW:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1888 return print_job_preview_page_new(pw, pw->job_page);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1889 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1890
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1891 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1892 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1893
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1894 static gboolean print_job_page_done(PrintWindow *pw)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1895 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1896 switch (pw->job_format)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1897 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1898 case RENDER_FORMAT_RGB:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1899 return print_job_rgb_page_done(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1900 case RENDER_FORMAT_PS:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1901 return print_job_ps_page_done(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1902 case RENDER_FORMAT_PREVIEW:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1903 return print_job_preview_page_done(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1904 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1905
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1906 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1907 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1908
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1909 static gboolean print_job_page_image(PrintWindow *pw, GdkPixbuf *pixbuf,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1910 gdouble x, gdouble y, gdouble w, gdouble h,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1911 gdouble offx, gdouble offy)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1912 {
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1347
diff changeset
1913 gboolean success = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1914
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1915 if (w <= 0.0 || h <= 0.0) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1916
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1917 switch (pw->job_format)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1918 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1919 case RENDER_FORMAT_RGB:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1920 success = print_job_rgb_page_image(pw, pixbuf, x, y, w, h, offx, offy);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1921 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1922 case RENDER_FORMAT_PS:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1923 success = print_job_ps_page_image(pw, pixbuf, x, y, w, h, offx, offy);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1924 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1925 case RENDER_FORMAT_PREVIEW:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1926 success = print_job_preview_page_image(pw, pixbuf, x, y, w, h, offx, offy);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1927 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1928 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1929
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1930 return success;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1931 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1932
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1933 static gboolean print_job_page_text(PrintWindow *pw, const gchar *text, gdouble point_size,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1934 gdouble x, gdouble y, gdouble width,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1935 guint8 r, guint8 g, guint8 b)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1936 {
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1347
diff changeset
1937 gboolean success = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1938
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1939 if (!text) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1940
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1941 switch (pw->job_format)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1942 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1943 case RENDER_FORMAT_RGB:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1944 success = print_job_rgb_page_text(pw, text, point_size, x, y, width, r, g, b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1945 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1946 case RENDER_FORMAT_PS:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1947 success = print_job_ps_page_text(pw, text, point_size, x, y, width, r, g, b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1948 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1949 case RENDER_FORMAT_PREVIEW:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1950 success = print_job_preview_page_text(pw, text, point_size, x, y, width, r, g, b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1951 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1952 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1953
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1954 return success;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1955 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1956
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1957 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1958 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1959 * print ?
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1960 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1961 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1962
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1963 static gboolean print_job_render_image(PrintWindow *pw);
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
1964 static gboolean print_job_render_proof(PrintWindow *pw);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1965
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1966
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1967 static void print_job_status(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1968 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1969 gdouble value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1970 gint page;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1971 gint total;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1972 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1973
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1974 if (!pw->job_progress) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1975
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1976 page = pw->job_page;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1977 total = print_layout_page_count(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1978
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1979 if (pw->layout == PRINT_LAYOUT_PROOF && pw->proof_point)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1980 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1981 GList *start;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1982
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1983 start = g_list_first(pw->proof_point);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1984 value = (gdouble)g_list_position(start, pw->proof_point) / g_list_length(start);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1985 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1986 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1987 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1988 value = (total > 0) ? (gdouble)page / total : 0.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1989 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1990
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1991 buf = g_strdup_printf(_("Page %d"), page + 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1992 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pw->job_progress), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1993 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1994
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1995 if (pw->job_path && pw->job_progress_label)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1996 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1997 gtk_label_set_text(GTK_LABEL(pw->job_progress_label), pw->job_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1998 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1999
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2000 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pw->job_progress), value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2001 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2002
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2003 static void print_job_throw_error(PrintWindow *pw, const gchar *message)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2004 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2005 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2006 GtkWidget *parent = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2007 GtkWidget *group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2008 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2009 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2010
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2011 if (GTK_WIDGET_VISIBLE(pw->dialog->dialog)) parent = pw->dialog->dialog;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2012
1174
0bea79d87065 Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents: 1164
diff changeset
2013 gd = generic_dialog_new(_("Printing error"), "print_warning",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2014 parent, TRUE, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2015 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, NULL, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2016
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2017 buf = g_strdup_printf(_("An error occured printing to %s."), print_output_name(pw->output));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2018 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_ERROR, _("Printing error"), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2019 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2020
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2021 group = pref_group_new(gd->vbox, FALSE, _("Details"), GTK_ORIENTATION_VERTICAL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2022 label = pref_label_new(group, message);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2023 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2024
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2025 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2026 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2027
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2028 static void print_job_done(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2029 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2030 print_job_close(pw, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2031 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2032
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
2033 static gboolean print_job_text_image(PrintWindow *pw, const gchar *path,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
2034 gdouble x, gdouble y, gdouble width,
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
2035 gint sw, gint sh, gint proof)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2036 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2037 GString *string;
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1347
diff changeset
2038 gboolean space = FALSE;
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1347
diff changeset
2039 gboolean newline = FALSE;
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
2040 gboolean ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2041
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2042 if (pw->text_fields == 0) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2043
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2044 string = g_string_new("");
1011
616b14da08c2 do not access image_loader directly
nadvornik
parents: 1000
diff changeset
2045 path = image_loader_get_fd(pw->job_loader)->path;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2046
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2047 if (pw->text_fields & TEXT_INFO_FILENAME)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2048 {
266
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
2049 if (pw->text_fields & TEXT_INFO_FILEPATH)
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
2050 g_string_append(string, path);
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
2051 else
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
2052 g_string_append(string, filename_from_path(path));
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
2053 newline = TRUE;
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
2054 }
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
2055 else if (pw->text_fields & TEXT_INFO_FILEPATH)
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
2056 {
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
2057 gchar *dirname = g_path_get_dirname(path);
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
2058
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
2059 g_string_append_printf(string, "%s%s", dirname, G_DIR_SEPARATOR_S);
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
2060 g_free(dirname);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2061 newline = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2062 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2063 if (pw->text_fields & TEXT_INFO_DIMENSIONS)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2064 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2065 if (newline) g_string_append(string, "\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2066 g_string_append_printf(string, "%d x %d", (gint)sw, (gint)sh);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2067 newline = proof;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2068 space = !proof;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2069 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2070 if (pw->text_fields & TEXT_INFO_FILEDATE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2071 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2072 if (newline) g_string_append(string, "\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2073 if (space) g_string_append(string, " - ");
1011
616b14da08c2 do not access image_loader directly
nadvornik
parents: 1000
diff changeset
2074 g_string_append(string, text_from_time(filetime(image_loader_get_fd(pw->job_loader)->path)));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2075 newline = proof;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2076 space = !proof;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2077 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2078 if (pw->text_fields & TEXT_INFO_FILESIZE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2079 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2080 gchar *size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2081
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2082 if (newline) g_string_append(string, "\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2083 if (space) g_string_append(string, " - ");
1011
616b14da08c2 do not access image_loader directly
nadvornik
parents: 1000
diff changeset
2084 size = text_from_size_abrev(filesize(image_loader_get_fd(pw->job_loader)->path));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2085 g_string_append(string, size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2086 g_free(size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2087 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2088
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2089 ret = print_job_page_text(pw, string->str, pw->text_points, x, y, width,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2090 pw->text_r, pw->text_g, pw->text_b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2091
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2092 g_string_free(string, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2093
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2094 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2095 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2096
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2097 static void print_job_render_image_loader_done(ImageLoader *il, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2098 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2099 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2100 GdkPixbuf *pixbuf;
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1347
diff changeset
2101 gboolean success = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2102
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2103 pixbuf = image_loader_get_pixbuf(il);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2104 if (pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2105 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2106 gdouble sw, sh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2107 gdouble dw, dh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2108 gdouble x, y, w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2109 gdouble scale;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2110 gdouble offx, offy;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2111
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2112 sw = (gdouble)gdk_pixbuf_get_width(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2113 sh = (gdouble)gdk_pixbuf_get_height(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2114
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2115 dw = pw->layout_width - pw->margin_left - pw->margin_right;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2116 dh = pw->layout_height - pw->margin_top - pw->margin_bottom;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2117
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2118 if (dw / sw < dh / sh)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2119 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2120 w = dw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2121 h = dw / sw * sh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2122 scale = w / sw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2123 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2124 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2125 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2126 h = dh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2127 w = dh / sh *sw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2128 scale = h / sh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2129 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2130
1237
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2131 if (pw->image_scale >= 5.0)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2132 {
1237
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2133 w = w * pw->image_scale / 100.0;
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2134 h = h * pw->image_scale / 100.0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2135 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2136
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2137 x = pw->margin_left + (dw / 2) - (w / 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2138 y = pw->margin_top + (dh / 2) - (h / 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2139
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2140 offx = offy = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2141
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2142 if (x < 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2143 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2144 w += x;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2145 offx = x;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2146 x = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2147 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2148 if (x + w >= pw->layout_width) w = pw->layout_width - x;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2149
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2150 if (y < 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2151 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2152 h += y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2153 offy = y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2154 y = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2155 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2156 if (y + h >= pw->layout_height) h = pw->layout_height - y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2157
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2158 success = (success &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2159 print_job_page_image(pw, pixbuf, x, y, w, h, offx, offy));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2160
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2161 x = x + w / 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2162 y = y + h + PRINT_TEXT_PADDING;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2163
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2164 success = (success &&
1011
616b14da08c2 do not access image_loader directly
nadvornik
parents: 1000
diff changeset
2165 print_job_text_image(pw, image_loader_get_fd(pw->job_loader)->path, x, y, dw, sw, sh, FALSE));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2166 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2167
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2168 image_loader_free(pw->job_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2169 pw->job_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2170
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2171 if (pw->job_format == RENDER_FORMAT_PREVIEW)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2172 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2173 print_job_done(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2174 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2175 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2176
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2177 success = (success && print_job_page_done(pw));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2178 if (!success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2179 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2180 print_job_close(pw, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2181 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2182 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2183
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2184 pw->job_page++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2185 print_job_status(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2186
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2187 if (print_job_render_image(pw))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2188 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2189 if (!print_job_page_new(pw)) print_job_close(pw, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2190 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2191 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2192 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2193 print_job_done(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2194 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2195 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2196
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
2197 static gboolean print_job_render_image(PrintWindow *pw)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2198 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
2199 FileData *fd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2201 switch (pw->source)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2202 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2203 case PRINT_SOURCE_SELECTION:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
2204 fd = g_list_nth_data(pw->source_selection, pw->job_page);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2205 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2206 case PRINT_SOURCE_ALL:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
2207 fd = g_list_nth_data(pw->source_list, pw->job_page);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2208 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2209 case PRINT_SOURCE_IMAGE:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2210 default:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
2211 if (pw->job_page == 0) fd = pw->source_fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2212 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2213 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2214
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2215 image_loader_free(pw->job_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2216 pw->job_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2217
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
2218 if (!fd) return FALSE;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
2219
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
2220 pw->job_loader = image_loader_new(fd);
1346
c9949c19a6d0 No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents: 1305
diff changeset
2221 g_signal_connect(G_OBJECT(pw->job_loader), "done", (GCallback)print_job_render_image_loader_done, pw);
1012
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
2222 if (!image_loader_start(pw->job_loader))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2223 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2224 image_loader_free(pw->job_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2225 pw->job_loader= NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2226 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2227
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2228 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2229 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2230
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2231 static void print_job_render_proof_loader_done(ImageLoader *il, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2232 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2233 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2234 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2235 gdouble x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2236 gdouble w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2237 gdouble proof_w, proof_h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2238 gdouble icon_w, icon_h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2239 gdouble scale;
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1347
diff changeset
2240 gboolean success = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2241
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2242 if (pw->proof_columns < 1 || pw->proof_rows < 1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2243 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2244 image_loader_free(pw->job_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2245 pw->job_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2246
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2247 print_job_done(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2248
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2249 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2250 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2251
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2252 pixbuf = image_loader_get_pixbuf(il);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2253
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2254 w = gdk_pixbuf_get_width(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2255 h = gdk_pixbuf_get_height(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2256
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2257 if (pw->proof_width / w < pw->proof_height / h)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2258 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2259 icon_w = pw->proof_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2260 icon_h = pw->proof_width / w * h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2261 scale = icon_w / w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2262 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2263 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2264 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2265 icon_h = pw->proof_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2266 icon_w = pw->proof_height / h * w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2267 scale = icon_h / h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2268 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2269
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2270 y = pw->proof_position / pw->proof_columns;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2271 x = pw->proof_position - (y * pw->proof_columns);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2272
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2273 print_proof_size(pw, &proof_w, &proof_h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2274
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2275 x *= proof_w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2276 y *= proof_h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2277 x += pw->margin_left + (pw->layout_width - pw->margin_left - pw->margin_right - (pw->proof_columns * proof_w)) / 2 + (proof_w - icon_w) / 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2278 y += pw->margin_top + PRINT_PROOF_MARGIN + (pw->proof_height - icon_h) / 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2279
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2280 success = (success &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2281 print_job_page_image(pw, pixbuf, x, y, icon_w, icon_h, 0, 0));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2282
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2283 x = x + icon_w / 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2284 y = y + icon_h + (pw->proof_height - icon_h) / 2 + PRINT_TEXT_PADDING;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2285
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
2286 success = (success &&
1011
616b14da08c2 do not access image_loader directly
nadvornik
parents: 1000
diff changeset
2287 print_job_text_image(pw, image_loader_get_fd(pw->job_loader)->path, x, y, icon_w + PRINT_PROOF_MARGIN * 2, w, h, TRUE));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2288
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2289 if (!success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2290 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2291 print_job_close(pw, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2292 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2293 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2294
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2295 if (pw->proof_point) pw->proof_point = pw->proof_point->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2296
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2297 pw->proof_position++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2298 if (pw->proof_position >= pw->proof_columns * pw->proof_rows)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2299 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2300 if (pw->job_format == RENDER_FORMAT_PREVIEW)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2301 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2302 print_job_done(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2303 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2304 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2305
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2306 if (!print_job_page_done(pw))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2307 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2308 print_job_close(pw, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2309 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2310 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2311
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2312 pw->proof_position = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2313 pw->job_page++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2314 if (print_job_render_proof(pw))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2315 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2316 if (!print_job_page_new(pw))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2317 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2318 print_job_close(pw, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2319 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2320 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2321 print_job_status(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2322 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2323 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2324 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2325 print_job_done(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2326 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2327 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2328 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2329 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2330 if (print_job_render_proof(pw))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2331 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2332 print_job_status(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2333 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2334 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2335 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2336 if (print_job_page_done(pw))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2337 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2338 print_job_done(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2339 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2340 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2341 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2342 print_job_close(pw, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2343 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2344 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2345 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2346 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2347
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
2348 static gboolean print_job_render_proof(PrintWindow *pw)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2349 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
2350 FileData *fd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2351
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2352 if (pw->proof_columns < 1 || pw->proof_rows < 1) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2353
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2354 if (!pw->proof_point && pw->proof_position == 0 && pw->source == PRINT_SOURCE_IMAGE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2355 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
2356 fd = pw->source_fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2357 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2358 else if (pw->proof_point &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2359 pw->proof_position < pw->proof_columns * pw->proof_rows)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2360 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
2361 fd = pw->proof_point->data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2362 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2363
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
2364 if (!fd) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2365
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2366 image_loader_free(pw->job_loader);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
2367 pw->job_loader = image_loader_new(fd);
1346
c9949c19a6d0 No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents: 1305
diff changeset
2368 g_signal_connect(G_OBJECT(pw->job_loader), "done", (GCallback)print_job_render_proof_loader_done, pw);
1012
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
2369 if (!image_loader_start(pw->job_loader))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2370 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2371 image_loader_free(pw->job_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2372 pw->job_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2373 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2374
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2375 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2376 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2377
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2378 static void print_job_render(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2379 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2380 gdouble proof_w, proof_h;
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
2381 gboolean finished;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2382
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2383 pw->proof_position = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2384
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2385 switch (pw->source)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2386 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2387 case PRINT_SOURCE_SELECTION:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2388 pw->proof_point = pw->source_selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2389 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2390 case PRINT_SOURCE_ALL:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2391 pw->proof_point = pw->source_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2392 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2393 case PRINT_SOURCE_IMAGE:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2394 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2395 pw->proof_point = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2396 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2397 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2398
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2399 print_proof_size(pw, &proof_w, &proof_h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2400 pw->proof_columns = (pw->layout_width - pw->margin_left - pw->margin_right) / proof_w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2401 pw->proof_rows = (pw->layout_height - pw->margin_top - pw->margin_bottom) / proof_h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2402
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2403 if (pw->job_format == RENDER_FORMAT_PREVIEW)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2404 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2405 gint total;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2406
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2407 total = print_layout_page_count(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2408 if (pw->job_page < 0 || pw->job_page >= total)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2409 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2410 print_job_done(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2411 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2412 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2413
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2414 if (pw->proof_point && pw->job_page > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2415 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2416 pw->proof_point = g_list_nth(pw->proof_point, pw->job_page * pw->proof_columns * pw->proof_rows);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2417 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2418 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2419
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2420 if (!print_job_page_new(pw))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2421 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2422 print_job_close(pw, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2423 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2424 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2425
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2426 if (pw->layout == PRINT_LAYOUT_IMAGE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2427 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2428 finished = !print_job_render_image(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2429 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2430 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2431 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2432 finished = !print_job_render_proof(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2433 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2434
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2435 if (finished) print_job_done(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2436 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2437
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
2438 static gboolean print_job_init(PrintWindow *pw)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2439 {
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1347
diff changeset
2440 gboolean success = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2441
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2442 pw->job_page = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2443
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2444 switch (pw->job_format)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2445 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2446 case RENDER_FORMAT_RGB:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2447 success = print_job_rgb_init(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2448 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2449 case RENDER_FORMAT_PS:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2450 success = print_job_ps_init(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2451 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2452 case RENDER_FORMAT_PREVIEW:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2453 pw->job_page = pw->proof_page;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2454 success = print_job_preview_init(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2455 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2456 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2457
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2458 return success;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2459 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2460
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
2461 static gboolean print_job_finish(PrintWindow *pw)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2462 {
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1347
diff changeset
2463 gboolean success = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2464
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2465 switch (pw->job_format)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2466 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2467 case RENDER_FORMAT_RGB:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2468 success = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2469 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2470 case RENDER_FORMAT_PS:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2471 print_job_ps_end(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2472 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2473 case RENDER_FORMAT_PREVIEW:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2474 success = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2475 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2476 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2477
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2478 return success;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2479 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2480
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2481 static void print_job_close_file(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2482 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2483 if (pw->job_file)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2484 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2485 fclose(pw->job_file);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2486 pw->job_file = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2487 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2488
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2489 if (pw->job_pipe)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2490 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2491 PipeError *pe;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2492
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2493 pe = pipe_handler_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2494 pclose(pw->job_pipe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2495 pipe_handler_free(pe);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2496
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2497 pw->job_pipe = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2498 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2499 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2500
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2501 static gboolean print_job_close_finish_cb(gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2502 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2503 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2504
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2505 print_window_close(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2506 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2507 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2508
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2509 static void print_job_close(PrintWindow *pw, gint error)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2510 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2511 if (!error) print_job_finish(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2512
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2513 print_job_close_file(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2514 g_free(pw->job_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2515 pw->job_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2516
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2517 if (pw->job_dialog)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2518 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2519 generic_dialog_close(pw->job_dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2520 pw->job_dialog = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2521 pw->job_progress = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2522 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2523
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2524 image_loader_free(pw->job_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2525 pw->job_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2526
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2527 if (pw->job_pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2528 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2529 g_object_unref(pw->job_pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2530 pw->job_pixbuf = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2531 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2532
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2533 if (pw->dialog && !GTK_WIDGET_VISIBLE(pw->dialog->dialog))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2534 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2535 g_idle_add_full(G_PRIORITY_HIGH_IDLE, print_job_close_finish_cb, pw, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2536 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2537 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2538
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2539 static void print_job_cancel_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2540 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2541 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2542
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2543 print_job_close(pw, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2544 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2545
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2546 static void print_pref_store(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2547 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2548
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2549 pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_SAVE, pw->save_settings);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2550
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2551 if (!pw->save_settings) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2552
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2553 /* only store values that are actually used in this print job, hence the if()s */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2554
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2555 pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_OUTPUT, pw->output);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2556
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2557 if (pw->output == PRINT_OUTPUT_RGB_FILE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2558 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2559 pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_FORMAT, pw->output_format);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2560 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2561
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2562 if (pw->job_format == RENDER_FORMAT_PS)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2563 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2564 pref_list_double_set(PRINT_PREF_GROUP, PRINT_PREF_DPI, pw->max_dpi);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2565 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2566
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2567 pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_UNITS, pw->paper_units);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2568 pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_SIZE, pw->paper_size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2569 pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_ORIENTATION, pw->paper_orientation);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2570
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2571 if (pw->paper_size == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2572 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2573 pref_list_double_set(PRINT_PREF_GROUP, PRINT_PREF_CUSTOM_WIDTH, pw->paper_width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2574 pref_list_double_set(PRINT_PREF_GROUP, PRINT_PREF_CUSTOM_HEIGHT, pw->paper_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2575 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2576
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2577 pref_list_double_set(PRINT_PREF_GROUP, PRINT_PREF_MARGIN_LEFT, pw->margin_left);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2578 pref_list_double_set(PRINT_PREF_GROUP, PRINT_PREF_MARGIN_RIGHT, pw->margin_right);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2579 pref_list_double_set(PRINT_PREF_GROUP, PRINT_PREF_MARGIN_TOP, pw->margin_top);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2580 pref_list_double_set(PRINT_PREF_GROUP, PRINT_PREF_MARGIN_BOTTOM, pw->margin_bottom);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2581
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2582 if (pw->layout == PRINT_LAYOUT_PROOF)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2583 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2584 pref_list_double_set(PRINT_PREF_GROUP, PRINT_PREF_PROOF_WIDTH, pw->proof_width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2585 pref_list_double_set(PRINT_PREF_GROUP, PRINT_PREF_PROOF_HEIGHT, pw->proof_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2586 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2587
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2588 if (pw->output == PRINT_OUTPUT_PS_CUSTOM)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2589 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2590 pref_list_string_set(PRINT_PREF_GROUP, PRINT_PREF_PRINTERC, pw->output_custom);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2591 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2592
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2593 if (pw->output == PRINT_OUTPUT_RGB_FILE ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2594 pw->output == PRINT_OUTPUT_PS_FILE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2595 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2596 tab_completion_append_to_history(pw->path_entry, pw->output_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2597 }
1237
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2598
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2599 pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_TEXT, pw->text_fields);
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2600 pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_TEXTSIZE, pw->text_points);
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2601 pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_TEXTCOLOR_R, pw->text_r);
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2602 pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_TEXTCOLOR_G, pw->text_g);
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2603 pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_TEXTCOLOR_B, pw->text_b);
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2604
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2605 pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_SOURCE, pw->source);
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2606 pref_list_int_set(PRINT_PREF_GROUP, PRINT_PREF_LAYOUT, pw->layout);
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2607
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2608 pref_list_double_set(PRINT_PREF_GROUP, PRINT_PREF_IMAGE_SCALE, pw->image_scale);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2609 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2610
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
2611 static gboolean print_job_start(PrintWindow *pw, RenderFormat format, PrintOutput output)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2612 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2613 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2614 GtkWidget *spinner;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2615 gchar *msg;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2616
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2617 if (pw->job_dialog) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2618
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2619 pw->job_format = format;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2620 pw->job_output = output;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2621
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2622 if (!print_job_init(pw))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2623 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2624 print_job_close(pw, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2625 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2626 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2627
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2628 if (format == RENDER_FORMAT_PREVIEW)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2629 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2630 print_job_render(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2631 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2632 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2633
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2634 print_pref_store(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2635
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2636 gtk_widget_hide(pw->dialog->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2637
1174
0bea79d87065 Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents: 1164
diff changeset
2638 pw->job_dialog = file_util_gen_dlg(_("Print"), "print_job_dialog",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2639 (GtkWidget *)gtk_window_get_transient_for(GTK_WINDOW(pw->dialog->dialog)), FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2640 print_job_cancel_cb, pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2641
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2642 msg = g_strdup_printf(_("Printing %d pages to %s."), print_layout_page_count(pw), print_output_name(pw->output));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2643 generic_dialog_add_message(pw->job_dialog, NULL, msg, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2644 g_free(msg);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2645
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2646 if (pw->job_output == PRINT_OUTPUT_PS_FILE ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2647 pw->job_output == PRINT_OUTPUT_RGB_FILE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2648 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2649 hbox = pref_box_new(pw->job_dialog->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2650 pref_label_new(hbox, _("Filename:"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2651
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2652 pw->job_progress_label = pref_label_new(hbox, "");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2653 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2654 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2655 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2656 pw->job_progress_label = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2657 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2658
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2659 pref_spacer(pw->job_dialog->vbox, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2660
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2661 hbox = pref_box_new(pw->job_dialog->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2662
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2663 pw->job_progress = gtk_progress_bar_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2664 gtk_box_pack_start(GTK_BOX(hbox), pw->job_progress, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2665 gtk_widget_show(pw->job_progress);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2666
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2667 spinner = spinner_new(NULL, SPINNER_SPEED);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2668 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2669 gtk_widget_show(spinner);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2670
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2671 gtk_widget_show(pw->job_dialog->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2672
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2673 print_job_render(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2674 print_job_status(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2675
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2676 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2677 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2678
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2679 static void print_window_print_start(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2680 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2681 RenderFormat format;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2682
1347
79937bc55f3a Add missing space between switch and first parenthesis.
zas_
parents: 1346
diff changeset
2683 switch (pw->output)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2684 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2685 case PRINT_OUTPUT_RGB_FILE:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2686 format = RENDER_FORMAT_RGB;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2687 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2688 case PRINT_OUTPUT_PS_FILE:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2689 case PRINT_OUTPUT_PS_CUSTOM:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2690 case PRINT_OUTPUT_PS_LPR:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2691 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2692 format = RENDER_FORMAT_PS;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2693 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2694 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2695
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2696 print_job_start(pw, format, pw->output);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2697 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2698
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2699
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2700 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2701 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2702 * combo box util
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2703 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2704 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2705
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2706 static GtkWidget *print_combo_menu(const gchar *text[], gint count, gint preferred,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2707 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2708 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2709 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2710 gint i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2711
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2712 combo = gtk_combo_box_new_text();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2713
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2714 for (i = 0 ; i < count; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2715 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2716 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _(text[i]));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2717 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2718
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2719 if (preferred >= 0 && preferred < count)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2720 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2721 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), preferred);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2722 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2723
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2724 if (func) g_signal_connect(G_OBJECT(combo), "changed", func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2725
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2726 return combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2727 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2728
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2729
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2730 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2731 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2732 * paper selection
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2733 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2734 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2735
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2736 static GtkWidget *print_paper_menu(GtkWidget *table, gint column, gint row,
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
2737 PaperOrientation preferred, GCallback func, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2738 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2739 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2740 gint i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2741
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2742 pref_table_label(table, column, row, (_("Format:")), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2743
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2744 combo = gtk_combo_box_new_text();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2745
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2746 i = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2747 while (print_paper_sizes[i].description)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2748 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2749 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _(print_paper_sizes[i].description));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2750 i++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2751 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2752
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2753 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), preferred);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2754 if (func) g_signal_connect(G_OBJECT(combo), "changed", func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2755
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2756 gtk_table_attach(GTK_TABLE(table), combo, column + 1, column + 2, row, row + 1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2757 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2758 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2759
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2760 return combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2761 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2762
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2763 static void print_paper_select_cb(GtkWidget *combo, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2764 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2765 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2766 PaperSize *ps;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2767 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2768
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2769 n = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2770 ps = print_paper_size_nth(n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2771
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2772 if (!ps) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2773
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2774 pw->paper_size = n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2775
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2776 if (pw->paper_size == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2777 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2778 print_window_layout_sync_paper(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2779 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2780 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2781
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2782 if (ps->orientation == PAPER_ORIENTATION_PORTRAIT)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2783 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2784 print_window_layout_set_size(pw, ps->width, ps->height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2785 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2786 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2787 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2788 print_window_layout_set_size(pw, ps->height, ps->width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2789 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2790 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2791
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2792 static void print_paper_size_cb(GtkWidget *spin, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2793 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2794 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2795 gdouble value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2796
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2797 value = print_paper_size_convert_units(gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin)),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2798 pw->paper_units, PAPER_UNIT_POINTS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2799
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2800 if (spin == pw->paper_width_spin)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2801 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2802 pw->paper_width = value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2803 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2804 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2805 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2806 pw->paper_height = value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2807 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2808
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2809 print_window_layout_set_size(pw, pw->paper_width, pw->paper_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2810 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2811
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2812 static GtkWidget *print_paper_units_menu(GtkWidget *table, gint column, gint row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2813 PaperUnits units, GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2814 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2815 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2816
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2817 pref_table_label(table, column, row, (_("Units:")), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2818
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2819 combo = print_combo_menu(print_paper_units, PAPER_UNIT_COUNT, units, func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2820
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2821 gtk_table_attach(GTK_TABLE(table), combo, column + 1, column + 2, row, row + 1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2822 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2823 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2824
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2825 return combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2826 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2827
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2828 static void print_paper_units_set(PrintWindow *pw, PaperUnits units)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2829 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2830 PaperUnits old_units;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2831
1177
5a20c47e7a14 Fix up unsigned expression always true/false warnings.
zas_
parents: 1174
diff changeset
2832 if (units >= PAPER_UNIT_COUNT) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2833
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2834 old_units = pw->paper_units;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2835 pw->paper_units = units;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2836 print_window_layout_sync_paper(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2837
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2838 if ((units == PAPER_UNIT_MM || units == PAPER_UNIT_CM) !=
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2839 (old_units == PAPER_UNIT_MM || old_units == PAPER_UNIT_CM))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2840 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2841 print_window_layout_render(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2842 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2843 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2844
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2845 static void print_paper_units_cb(GtkWidget *combo, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2846 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2847 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2848 PaperUnits units;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2849
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2850 units = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2851
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2852 print_paper_units_set(pw, units);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2853 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2854
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2855 static GtkWidget *print_paper_orientation_menu(GtkWidget *table, gint column, gint row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2856 PaperOrientation preferred,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2857 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2858 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2859 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2860
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2861 pref_table_label(table, column, row, (_("Orientation:")), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2862
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2863 combo = print_combo_menu(print_paper_orientation, PAPER_ORIENTATION_COUNT, preferred, func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2864
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2865 gtk_table_attach(GTK_TABLE(table), combo, column + 1, column + 2, row, row + 1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2866 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2867 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2868
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2869 return combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2870 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2871
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2872 static void print_paper_orientation_cb(GtkWidget *combo, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2873 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2874 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2875 PaperOrientation o;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2876
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2877 o = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2878
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2879 print_window_layout_set_orientation(pw, o);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2880 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2881
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2882 static void print_paper_margin_cb(GtkWidget *spin, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2883 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2884 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2885 gdouble value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2886
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2887 value = print_paper_size_convert_units(gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin)),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2888 pw->paper_units, PAPER_UNIT_POINTS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2889
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2890 if (spin == pw->margin_left_spin)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2891 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2892 pw->margin_left = CLAMP(value, 0.0, pw->paper_width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2893 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2894 else if (spin == pw->margin_right_spin)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2895 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2896 pw->margin_right = CLAMP(value, 0.0, pw->paper_width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2897 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2898 else if (spin == pw->margin_top_spin)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2899 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2900 pw->margin_top = CLAMP(value, 0.0, pw->paper_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2901 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2902 else if (spin == pw->margin_bottom_spin)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2903 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2904 pw->margin_bottom = CLAMP(value, 0.0, pw->paper_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2905 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2906
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2907 print_window_layout_set_size(pw, pw->paper_width, pw->paper_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2908 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2909
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2910 static GtkWidget *print_misc_menu(GtkWidget *parent_box, gint preferred,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2911 const gchar *title, const gchar *key,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2912 gint count, const gchar **text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2913 GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2914 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2915 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2916 GtkWidget *button = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2917 gint i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2918
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2919 box = pref_group_new(parent_box, FALSE, title, GTK_ORIENTATION_VERTICAL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2920
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2921 for (i = 0; i < count; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2922 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2923 button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _(text[i]));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2924 if (i == preferred)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2925 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2926 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2927 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2928 g_object_set_data(G_OBJECT(button), key, GINT_TO_POINTER(i));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2929 if (func) g_signal_connect(G_OBJECT(button), "clicked", func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2930 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2931 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2932 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2933
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2934 return box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2935 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2936
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2937 static void print_source_select_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2938 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2939 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2940
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2941 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2942
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2943 pw->source = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "print_source"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2944 print_window_layout_size(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2945 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2946
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2947 static void print_layout_select_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2948 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2949 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2950
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2951 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2952
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2953 pw->layout = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "print_layout"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2954
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2955 print_window_layout_sync_layout(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2956 print_window_layout_size(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2957 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2958
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2959 static void print_image_scale_cb(GtkWidget *spin, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2960 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2961 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2962
1237
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
2963 pw->image_scale = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2964
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2965 print_window_layout_set_size(pw, pw->paper_width, pw->paper_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2966 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2967
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2968 static void print_proof_size_cb(GtkWidget *spin, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2969 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2970 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2971 gdouble value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2972
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2973 value = print_paper_size_convert_units(gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin)),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2974 pw->paper_units, PAPER_UNIT_POINTS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2975
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2976 if (spin == pw->proof_width_spin)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2977 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2978 pw->proof_width = value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2979 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2980 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2981 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2982 pw->proof_height = value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2983 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2984
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2985 print_window_layout_render(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2986 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2987
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2988 static GtkWidget *print_output_menu(GtkWidget *table, gint column, gint row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2989 PrintOutput preferred, GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2990 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2991 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2992
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2993 pref_table_label(table, column, row, (_("Destination:")), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2994
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2995 combo = print_combo_menu(print_output_text, PRINT_OUTPUT_COUNT, preferred, func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2996
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2997 gtk_table_attach(GTK_TABLE(table), combo, column + 1, column + 2, row, row + 1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2998 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2999 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3000
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3001 return combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3002 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3003
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3004 static void print_custom_entry_set(PrintWindow *pw, GtkWidget *combo)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3005 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3006 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3007 const gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3008 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3009 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3010
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3011 store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3012 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3013
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3014 list = print_window_list_printers();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3015 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3016 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3017 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3018 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3019 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3020
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3021 name = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3022 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3023
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3024 buf = g_strdup_printf(PRINT_LPR_CUSTOM, name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3025 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3026 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3027 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
3028 string_list_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3029
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3030 if (pref_list_string_get(PRINT_PREF_GROUP, PRINT_PREF_PRINTERC, &text))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3031 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3032 gtk_entry_set_text(GTK_ENTRY(pw->custom_entry), text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3033 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3034 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3035 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3036 text = gtk_entry_get_text(GTK_ENTRY(pw->custom_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3037 if (!text || strlen(text) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3038 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3039 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3040
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3041 buf = g_strdup_printf(PRINT_LPR_CUSTOM, _("<printer name>"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3042 gtk_entry_set_text(GTK_ENTRY(pw->custom_entry), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3043 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3044 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3045 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3046 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3047
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3048 static void print_output_set(PrintWindow *pw, PrintOutput output)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3049 {
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1347
diff changeset
3050 gboolean use_file = FALSE;
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1347
diff changeset
3051 gboolean use_custom = FALSE;
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1347
diff changeset
3052 gboolean use_format = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3053
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3054 pw->output = output;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3055
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3056 switch (pw->output)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3057 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3058 case PRINT_OUTPUT_RGB_FILE:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3059 use_file = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3060 use_format = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3061 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3062 case PRINT_OUTPUT_PS_FILE:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3063 use_file = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3064 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3065 case PRINT_OUTPUT_PS_CUSTOM:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3066 use_custom = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3067 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3068 case PRINT_OUTPUT_PS_LPR:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3069 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3070 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3071 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3072
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3073 gtk_widget_set_sensitive(gtk_widget_get_parent(pw->path_entry), use_file);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3074 gtk_widget_set_sensitive(gtk_widget_get_parent(pw->custom_entry), use_custom);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3075 gtk_widget_set_sensitive(pw->path_format_menu, use_format);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3076 gtk_widget_set_sensitive(pw->max_dpi_menu, !use_format);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3077 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3078
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3079 static void print_output_cb(GtkWidget *combo, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3080 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3081 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3082 PrintOutput output;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3083
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3084 output = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3085
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3086 print_output_set(pw, output);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3087 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3088
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3089 static GtkWidget *print_output_format_menu(GtkWidget * table, gint column, gint row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3090 PrintFileFormat preferred, GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3091 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3092 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3093
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3094 combo = print_combo_menu(print_file_format_text, PRINT_FILE_COUNT, preferred, func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3095
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3096 gtk_table_attach(GTK_TABLE(table), combo, column, column + 1, row, row + 1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3097 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3098 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3099
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3100 return combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3101 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3102
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3103 static void print_output_format_cb(GtkWidget *combo, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3104 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3105 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3106
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3107 pw->output_format = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3108 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3109
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3110 static GtkWidget *print_output_dpi_menu(GtkWidget * table, gint column, gint row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3111 gdouble dpi, GCallback func, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3112 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3113 static gint dpilist[] = { 150, 300, 600, 1200, 0, -1};
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3114 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3115 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3116 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3117 gint current = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3118 gint i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3119
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3120 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3121
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3122 i = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3123 while (dpilist[i] != -1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3124 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3125 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3126 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3127
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3128 if (dpilist[i] == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3129 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3130 text = g_strdup(_("Unlimited"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3131 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3132 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3133 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3134 text = g_strdup_printf("%d", dpilist[i]);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3135 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3136
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3137 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3138 gtk_list_store_set(store, &iter, 0, text, 1, dpilist[i], -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3139 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3140
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3141 if (dpi == (gdouble)dpilist[i]) current = i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3142
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3143 i++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3144 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3145
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3146 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3147 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3148
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3149 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), current);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3150 if (func) g_signal_connect(G_OBJECT(combo), "changed", func, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3151
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3152 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3153 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3154 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", 0, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3155
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3156 gtk_table_attach(GTK_TABLE(table), combo, column, column + 1, row, row + 1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3157 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3158 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3159
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3160 return combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3161 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3162
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3163 static void print_output_dpi_cb(GtkWidget *combo, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3164 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3165 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3166 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3167 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3168 gint n = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3170 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3171 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3172 gtk_tree_model_get(store, &iter, 1, &n, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3173
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3174 pw->max_dpi = (gdouble)n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3175 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3176
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
3177 static void print_text_field_set(PrintWindow *pw, TextInfo field, gboolean active)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3178 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3179 if (active)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3180 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3181 pw->text_fields |= field;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3182 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3183 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3184 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3185 pw->text_fields &= ~field;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3186 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3187
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3188 print_window_layout_render(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3189 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3190
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3191 static void print_text_cb_name(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3192 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3193 PrintWindow *pw = data;
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
3194 gboolean active;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3195
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3196 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3197 print_text_field_set(pw, TEXT_INFO_FILENAME, active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3198 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3199
266
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
3200 static void print_text_cb_path(GtkWidget *widget, gpointer data)
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
3201 {
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
3202 PrintWindow *pw = data;
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
3203 gboolean active;
266
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
3204
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
3205 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
3206 print_text_field_set(pw, TEXT_INFO_FILEPATH, active);
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
3207 }
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
3208
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3209 static void print_text_cb_date(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3210 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3211 PrintWindow *pw = data;
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
3212 gboolean active;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3213
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3214 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3215 print_text_field_set(pw, TEXT_INFO_FILEDATE, active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3216 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3217
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3218 static void print_text_cb_size(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3219 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3220 PrintWindow *pw = data;
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
3221 gboolean active;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3222
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3223 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3224 print_text_field_set(pw, TEXT_INFO_FILESIZE, active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3225 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3226
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3227 static void print_text_cb_dims(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3228 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3229 PrintWindow *pw = data;
1443
f879e7d94c6d gint -> gboolean.
zas_
parents: 1437
diff changeset
3230 gboolean active;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3231
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3232 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3233 print_text_field_set(pw, TEXT_INFO_DIMENSIONS, active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3234 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3235
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3236 static void print_text_cb_points(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3237 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3238 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3239
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3240 pw->text_points = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3241 print_window_layout_render(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3242 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3243
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3244 static void print_text_menu(GtkWidget *box, PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3245 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3246 GtkWidget *group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3247
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3248 group = pref_group_new(box, FALSE, _("Show"), GTK_ORIENTATION_VERTICAL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3249
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3250 pref_checkbox_new(group, _("Name"), (pw->text_fields & TEXT_INFO_FILENAME),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3251 G_CALLBACK(print_text_cb_name), pw);
266
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
3252 pref_checkbox_new(group, _("Path"), (pw->text_fields & TEXT_INFO_FILEPATH),
65187a2309d3 Add the possibility to print file names with path.
zas_
parents: 254
diff changeset
3253 G_CALLBACK(print_text_cb_path), pw);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3254 pref_checkbox_new(group, _("Date"), (pw->text_fields & TEXT_INFO_FILEDATE),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3255 G_CALLBACK(print_text_cb_date), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3256 pref_checkbox_new(group, _("Size"), (pw->text_fields & TEXT_INFO_FILESIZE),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3257 G_CALLBACK(print_text_cb_size), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3258 pref_checkbox_new(group, _("Dimensions"), (pw->text_fields & TEXT_INFO_DIMENSIONS),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3259 G_CALLBACK(print_text_cb_dims), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3260
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3261 group = pref_group_new(box, FALSE, _("Font"), GTK_ORIENTATION_VERTICAL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3262
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3263 pref_spin_new(group, _("Size:"), _("points"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3264 8.0, 100.0, 1.0, 0, pw->text_points,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3265 G_CALLBACK(print_text_cb_points), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3266
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3267 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3268 button = color_selection_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3269 gtk_box_pack_start(GTK_BOX(group), button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3270 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3271 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3272 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3273
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3274 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3275 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3276 * print window
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3277 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3278 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3279
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3280 static void print_window_close(PrintWindow *pw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3281 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3282 print_window_layout_render_stop(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3283
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3284 generic_dialog_close(pw->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3285 pw->dialog = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3286
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3287 print_job_close(pw, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3288
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
3289 file_data_unref(pw->source_fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
3290 filelist_free(pw->source_selection);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
3291 filelist_free(pw->source_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3292
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3293 g_free(pw->output_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3294 g_free(pw->output_custom);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3295
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3296 g_free(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3297 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3298
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3299 static void print_window_print_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3300 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3301 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3302
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3303 switch (pw->output)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3304 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3305 case PRINT_OUTPUT_RGB_FILE:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3306 case PRINT_OUTPUT_PS_FILE:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3307 g_free(pw->output_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3308 pw->output_path = g_strdup(gtk_entry_get_text(GTK_ENTRY(pw->path_entry)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3309 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3310 case PRINT_OUTPUT_PS_CUSTOM:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3311 g_free(pw->output_custom);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3312 pw->output_custom = g_strdup(gtk_entry_get_text(GTK_ENTRY(pw->custom_entry)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3313 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3314 case PRINT_OUTPUT_PS_LPR:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3315 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3316 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3317 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3318
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3319 print_window_print_start(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3320 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3321
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3322 static void print_window_cancel_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3323 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3324 PrintWindow *pw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3325
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3326 print_window_close(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3327 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3328
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3329 static gint print_pref_int(const gchar *key, gint fallback)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3330 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3331 gint value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3332
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3333 if (pref_list_int_get(PRINT_PREF_GROUP, key, &value)) return value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3334 return fallback;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3335 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3336
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3337 static gdouble print_pref_double(const gchar *key, gdouble fallback)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3338 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3339 gdouble value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3340
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3341 if (pref_list_double_get(PRINT_PREF_GROUP, key, &value)) return value;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3342 return fallback;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3343 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3344
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
3345 void print_window_new(FileData *fd, GList *selection, GList *list, GtkWidget *parent)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3346 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3347 PrintWindow *pw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3348 GdkGeometry geometry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3349 GtkWidget *main_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3350 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3351 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3352 GtkWidget *combo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3353 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3354 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3355
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3356 pw = g_new0(PrintWindow, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3357
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 121
diff changeset
3358 pw->source_fd = file_data_ref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3359 pw->source_selection = selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3360 pw->source_list = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3361
1237
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
3362 pw->source = print_pref_int(PRINT_PREF_SOURCE, PRINT_SOURCE_SELECTION);
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
3363 pw->layout = print_pref_int(PRINT_PREF_LAYOUT, PRINT_LAYOUT_IMAGE);
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
3364
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
3365 pw->image_scale = print_pref_double(PRINT_PREF_IMAGE_SCALE, 100.0);
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
3366
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3367 pw->output = print_pref_int(PRINT_PREF_OUTPUT, PRINT_OUTPUT_PS_LPR);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3368 pw->output_format = print_pref_int(PRINT_PREF_FORMAT, PRINT_FILE_JPG_NORMAL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3369
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3370 pw->max_dpi = print_pref_double(PRINT_PREF_DPI, PRINT_PS_DPI_DEFAULT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3371
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3372 pw->paper_units = print_pref_int(PRINT_PREF_UNITS, paper_unit_default());
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3373 pw->paper_size = print_pref_int(PRINT_PREF_SIZE, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3374 if (pw->paper_size == 0 ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3375 !print_paper_size_lookup(pw->paper_size, &pw->paper_width, &pw->paper_height))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3376 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3377 pw->paper_width = print_pref_double(PRINT_PREF_CUSTOM_WIDTH, 360.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3378 pw->paper_height = print_pref_double(PRINT_PREF_CUSTOM_HEIGHT, 720.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3379 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3380 pw->paper_orientation = print_pref_int(PRINT_PREF_ORIENTATION, PAPER_ORIENTATION_PORTRAIT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3381
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3382 pw->margin_left = print_pref_double(PRINT_PREF_MARGIN_LEFT, PRINT_MARGIN_DEFAULT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3383 pw->margin_right = print_pref_double(PRINT_PREF_MARGIN_RIGHT, PRINT_MARGIN_DEFAULT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3384 pw->margin_top = print_pref_double(PRINT_PREF_MARGIN_TOP, PRINT_MARGIN_DEFAULT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3385 pw->margin_bottom = print_pref_double(PRINT_PREF_MARGIN_BOTTOM, PRINT_MARGIN_DEFAULT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3386
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3387 pw->proof_width = print_pref_double(PRINT_PREF_PROOF_WIDTH, PRINT_PROOF_DEFAULT_SIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3388 pw->proof_height = print_pref_double(PRINT_PREF_PROOF_HEIGHT, PRINT_PROOF_DEFAULT_SIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3389
1237
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
3390 pw->text_fields = print_pref_int(PRINT_PREF_TEXT, TEXT_INFO_FILENAME);
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
3391 pw->text_points = print_pref_int(PRINT_PREF_TEXTSIZE, 10);
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
3392 pw->text_r = print_pref_int(PRINT_PREF_TEXTCOLOR_R, 0);
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
3393 pw->text_g = print_pref_int(PRINT_PREF_TEXTCOLOR_G, 0);
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
3394 pw->text_b = print_pref_int(PRINT_PREF_TEXTCOLOR_B, 0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3395
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3396 pw->save_settings = print_pref_int(PRINT_PREF_SAVE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3397
1174
0bea79d87065 Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents: 1164
diff changeset
3398 pw->dialog = file_util_gen_dlg(_("Print"), "print_dialog",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3399 parent, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3400 print_window_cancel_cb, pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3401
1029
1a4b18c58556 Use a constant for minimal window size. Set it to 32 for all dialogs.
zas_
parents: 1012
diff changeset
3402 geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE;
1a4b18c58556 Use a constant for minimal window size. Set it to 32 for all dialogs.
zas_
parents: 1012
diff changeset
3403 geometry.min_height = DEFAULT_MINIMAL_WINDOW_SIZE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3404 geometry.base_width = PRINT_DLG_WIDTH;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3405 geometry.base_height = PRINT_DLG_HEIGHT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3406 gtk_window_set_geometry_hints(GTK_WINDOW(pw->dialog->dialog), NULL, &geometry,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3407 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3408
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3409 pw->print_button = generic_dialog_add_button(pw->dialog, GTK_STOCK_PRINT, NULL, print_window_print_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3410
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3411 main_box = pref_box_new(pw->dialog->vbox, TRUE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3412
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3413 pw->notebook = gtk_notebook_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3414 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(pw->notebook), GTK_POS_TOP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3415 gtk_box_pack_start(GTK_BOX(main_box), pw->notebook, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3416
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3417 /* layout tab */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3418
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3419 vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3420 gtk_container_set_border_width(GTK_CONTAINER(vbox), PREF_PAD_BORDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3421 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3422 label = gtk_label_new(_("Layout"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3423 gtk_notebook_append_page(GTK_NOTEBOOK(pw->notebook), vbox, label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3424
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3425 print_misc_menu(vbox, pw->source, _("Source"), "print_source",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3426 PRINT_SOURCE_COUNT, print_source_text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3427 G_CALLBACK(print_source_select_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3428
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3429 box = print_misc_menu(vbox, pw->layout, _("Layout"), "print_layout",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3430 PRINT_LAYOUT_COUNT, print_layout_text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3431 G_CALLBACK(print_layout_select_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3432
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3433 pref_spacer(box, PREF_PAD_GROUP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3434
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3435 table = pref_table_new(box, 2, 2, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3436
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3437 pw->image_scale_spin = pref_table_spin(table, 0, 0, _("Image size:"), "%",
1237
824a1e1775b8 When "Remember print settings" is checked, save _all_ settings. Before this patch, text fields, text size, source, layout and image scale properties were not saved.
zas_
parents: 1177
diff changeset
3438 5.0, 100.0, 1.0, 0, pw->image_scale,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3439 G_CALLBACK(print_image_scale_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3440
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3441 label = pref_table_label(table, 0, 1, _("Proof size:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3442 pw->proof_group = pref_table_box(table, 1, 1, GTK_ORIENTATION_HORIZONTAL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3443 pref_link_sensitivity(label, pw->proof_group);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
3444
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3445 pw->proof_width_spin = pref_spin_new(pw->proof_group, NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3446 0.0, 50.0, 0.1, 3, 0.0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3447 G_CALLBACK(print_proof_size_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3448 pw->proof_height_spin = pref_spin_new(pw->proof_group, "x", NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3449 0.0, 50.0, 0.1, 3, 0.0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3450 G_CALLBACK(print_proof_size_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3451
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3452 /* text tab */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3453
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3454 vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3455 gtk_container_set_border_width(GTK_CONTAINER(vbox), PREF_PAD_BORDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3456 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3457 label = gtk_label_new(_("Text"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3458 gtk_notebook_append_page(GTK_NOTEBOOK(pw->notebook), vbox, label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3459
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3460 print_text_menu(vbox, pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3461
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3462 /* paper tab */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3463
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3464 vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3465 gtk_container_set_border_width(GTK_CONTAINER(vbox), PREF_PAD_BORDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3466 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3467 label = gtk_label_new(_("Paper"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3468 gtk_notebook_append_page(GTK_NOTEBOOK(pw->notebook), vbox, label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3469
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3470 table = pref_table_new(vbox, 2, 4, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3471
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3472 print_paper_menu(table, 0, 0, pw->paper_size, G_CALLBACK(print_paper_select_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3473
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3474 label = pref_table_label(table, 0, 1, (_("Size:")), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3475 box = pref_table_box(table, 1, 1, GTK_ORIENTATION_HORIZONTAL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3476 pw->paper_width_spin = pref_spin_new(box, NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3477 1.0, 10000.0, 1.0, 2, 66,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3478 G_CALLBACK(print_paper_size_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3479 pw->paper_height_spin = pref_spin_new(box, "x", NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3480 1.0, 10000.0, 1.0, 2, 66,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3481 G_CALLBACK(print_paper_size_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3482 pref_link_sensitivity(label, pw->paper_width_spin);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3483
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3484 pw->paper_units_menu = print_paper_units_menu(table, 0, 2, pw->paper_units,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3485 G_CALLBACK(print_paper_units_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3486
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3487 print_paper_orientation_menu(table, 0, 3, pw->paper_orientation,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3488 G_CALLBACK(print_paper_orientation_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3489
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3490 box = pref_group_new(vbox, FALSE, _("Margins"), GTK_ORIENTATION_VERTICAL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3491 table = pref_table_new(box, 4, 2, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3492 pw->margin_left_spin = pref_table_spin(table, 0, 0, _("Left:"), NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3493 0.0, 50.0, 0.1, 3, 0.0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3494 G_CALLBACK(print_paper_margin_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3495 pw->margin_right_spin = pref_table_spin(table, 2, 0, _("Right:"), NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3496 0.0, 50.0, 0.1, 3, 0.0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3497 G_CALLBACK(print_paper_margin_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3498 pw->margin_top_spin = pref_table_spin(table, 0, 1, _("Top:"), NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3499 0.0, 50.0, 0.1, 3, 0.0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3500 G_CALLBACK(print_paper_margin_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3501 pw->margin_bottom_spin = pref_table_spin(table, 2, 1, _("Bottom:"), NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3502 0.0, 50.0, 0.1, 3, 0.0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3503 G_CALLBACK(print_paper_margin_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3504
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3505 /* printer tab */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3506
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3507 vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3508 gtk_container_set_border_width(GTK_CONTAINER(vbox), PREF_PAD_BORDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3509 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3510 label = gtk_label_new(_("Printer"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3511 gtk_notebook_append_page(GTK_NOTEBOOK(pw->notebook), vbox, label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3512
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3513 table = pref_table_new(vbox, 2, 5, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3514 print_output_menu(table, 0, 0, pw->output, G_CALLBACK(print_output_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3515
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3516 label = pref_table_label(table, 0, 1, _("Custom printer:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3517 combo = history_combo_new(&pw->custom_entry, NULL, "print_custom", -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3518 print_custom_entry_set(pw, combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3519 gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 1, 2,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3520 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3521 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3522
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3523 pref_link_sensitivity(label, combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3524
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3525 label = pref_table_label(table, 0, 2, _("File:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3526 combo = tab_completion_new_with_history(&pw->path_entry, NULL, "print_path", -1, NULL, pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3527 tab_completion_add_select_button(pw->path_entry, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3528 gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 2, 3,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3529 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3530 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3531
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3532 pref_link_sensitivity(label, combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3533
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3534 label = pref_table_label(table, 0, 3, _("File format:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3535 pw->path_format_menu = print_output_format_menu(table, 1, 3, pw->output_format,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3536 G_CALLBACK(print_output_format_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3537 pref_link_sensitivity(label, pw->path_format_menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3538
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3539 label = pref_table_label(table, 0, 4, _("DPI:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3540 pw->max_dpi_menu = print_output_dpi_menu(table, 1, 4, pw->max_dpi,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3541 G_CALLBACK(print_output_dpi_cb), pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3542 pref_link_sensitivity(label, pw->max_dpi_menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3543
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3544 print_output_set(pw, pw->output);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3545
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3546 vbox = print_window_layout_setup(pw, main_box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3547 pref_checkbox_new_int(vbox, _("Remember print settings"), pw->save_settings, &pw->save_settings);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3548
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3549 print_window_layout_sync_layout(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3550 print_window_layout_sync_paper(pw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3551
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3552 gtk_widget_show(pw->notebook);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3553 gtk_widget_show(pw->dialog->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3554 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1045
diff changeset
3555 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */