Commit 5ecd10c2b5f83f0a7ce630eb78d6c6df45129b34
1 parent
7ec37943
Exists in
master
and in
5 other branches
Updating print dialog.
Showing
9 changed files
with
320 additions
and
278 deletions
Show diff stats
configure.ac
... | ... | @@ -87,6 +87,7 @@ fi |
87 | 87 | case "$host" in |
88 | 88 | *-mingw32|*-pc-msys) |
89 | 89 | |
90 | + app_cv_osname="windows" | |
90 | 91 | EXEEXT=".exe" |
91 | 92 | DLLPREFIX="" |
92 | 93 | DLLEXT=".dll" |
... | ... | @@ -111,7 +112,7 @@ case "$host" in |
111 | 112 | AC_CONFIG_FILES(win/makeruntime.sh) |
112 | 113 | AC_CONFIG_FILES(win/copydeps.sh) |
113 | 114 | AC_CONFIG_FILES(win/$PACKAGE_TARNAME.nsi) |
114 | - AC_CONFIG_FILES(src/pw3270/resources.rc) | |
115 | + AC_CONFIG_FILES(src/pw3270/windows/resources.rc) | |
115 | 116 | |
116 | 117 | if test "$host_cpu" = "x86_64"; then |
117 | 118 | app_cv_programfiles="PROGRAMFILES64" |
... | ... | @@ -138,6 +139,7 @@ case "$host" in |
138 | 139 | ;; |
139 | 140 | |
140 | 141 | *) |
142 | + app_cv_osname="linux" | |
141 | 143 | EXEEXT="" |
142 | 144 | DLLPREFIX="lib" |
143 | 145 | DLLEXT=".so" |
... | ... | @@ -150,6 +152,7 @@ case "$host" in |
150 | 152 | |
151 | 153 | esac |
152 | 154 | |
155 | +AC_SUBST(OSNAME,$app_cv_osname) | |
153 | 156 | AC_SUBST(DBG_CFLAGS) |
154 | 157 | AC_SUBST(RLS_CFLAGS) |
155 | 158 | AC_SUBST(EXEEXT) | ... | ... |
pw3270.cbp
... | ... | @@ -153,6 +153,9 @@ |
153 | 153 | </Unit> |
154 | 154 | <Unit filename="src/pw3270/include/v3270.h" /> |
155 | 155 | <Unit filename="src/pw3270/include/v3270ft.h" /> |
156 | + <Unit filename="src/pw3270/linux/print.c"> | |
157 | + <Option compilerVar="CC" /> | |
158 | + </Unit> | |
156 | 159 | <Unit filename="src/pw3270/main.c"> |
157 | 160 | <Option compilerVar="CC" /> |
158 | 161 | </Unit> |
... | ... | @@ -229,6 +232,10 @@ |
229 | 232 | <Unit filename="src/pw3270/window.c"> |
230 | 233 | <Option compilerVar="CC" /> |
231 | 234 | </Unit> |
235 | + <Unit filename="src/pw3270/windows/print.c"> | |
236 | + <Option compilerVar="CC" /> | |
237 | + </Unit> | |
238 | + <Unit filename="src/pw3270/windows/resources.rc.in" /> | |
232 | 239 | <Unit filename="src/sample/Makefile.in" /> |
233 | 240 | <Unit filename="src/sample/connect.c"> |
234 | 241 | <Option compilerVar="CC" /> | ... | ... |
src/pw3270/Makefile.in
... | ... | @@ -0,0 +1,142 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como - e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | + #include "../private.h" | |
31 | + #include <v3270.h> | |
32 | + #include <v3270/print.h> | |
33 | + #include <lib3270/selection.h> | |
34 | + | |
35 | + #define FONT_CONFIG "font-family" | |
36 | + #define DEFAULT_FONT "Courier New" | |
37 | + | |
38 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
39 | + | |
40 | + static GtkWidget * create_custom_widget(GtkPrintOperation *prt, gpointer G_GNUC_UNUSED(dunno)) | |
41 | + { | |
42 | + GtkWidget * widget = gtk_frame_new(""); | |
43 | + GtkWidget * settings = V3270_print_settings_new(v3270_print_operation_get_terminal(prt)); | |
44 | + | |
45 | + // Load values from configuration | |
46 | + g_autofree gchar * font_family = get_string_from_config("print",FONT_CONFIG,DEFAULT_FONT); | |
47 | + if(font_family && *font_family) | |
48 | + v3270_print_settings_set_font_family(settings,font_family); | |
49 | + | |
50 | + g_autofree gchar * color_scheme = get_string_from_config("print","colors",""); | |
51 | + if(color_scheme && *color_scheme) | |
52 | + v3270_print_settings_set_color_scheme(settings,color_scheme); | |
53 | + | |
54 | + // Create frame | |
55 | + GtkWidget *label = gtk_label_new(NULL); | |
56 | + gtk_label_set_markup(GTK_LABEL(label),_("<b>Text options</b>")); | |
57 | + gtk_frame_set_label_widget(GTK_FRAME(widget),label); | |
58 | + | |
59 | + gtk_container_set_border_width(GTK_CONTAINER(widget),12); | |
60 | + | |
61 | + // The print dialog doesn't follow the guidelines from https://developer.gnome.org/hig/stable/visual-layout.html.en )-: | |
62 | + gtk_frame_set_shadow_type(GTK_FRAME(widget),GTK_SHADOW_NONE); | |
63 | + | |
64 | + gtk_container_set_border_width(GTK_CONTAINER(settings),6); | |
65 | + g_object_set(G_OBJECT(settings),"margin-start",8,NULL); | |
66 | + | |
67 | + gtk_container_add(GTK_CONTAINER(widget),settings); | |
68 | + | |
69 | + gtk_widget_show_all(widget); | |
70 | + | |
71 | + return widget; | |
72 | + } | |
73 | + | |
74 | + static void custom_widget_apply(GtkPrintOperation *prt, GtkWidget *widget, gpointer G_GNUC_UNUSED(dunno)) | |
75 | + { | |
76 | + GtkWidget * settings = gtk_bin_get_child(GTK_BIN(widget)); | |
77 | + | |
78 | + v3270_print_operation_apply_settings(prt,settings); | |
79 | + | |
80 | + // Store font family | |
81 | + g_autofree gchar * font_family = v3270_print_settings_get_font_family(settings); | |
82 | + set_string_to_config("print",FONT_CONFIG,font_family); | |
83 | + | |
84 | + // Store save color settings | |
85 | + g_autofree gchar * colors = v3270_print_settings_get_color_scheme(settings); | |
86 | + set_string_to_config("print","colors","%s",colors); | |
87 | + | |
88 | + } | |
89 | + | |
90 | +void setup_print_dialog(GtkPrintOperation * operation) | |
91 | +{ | |
92 | + GtkPrintSettings * settings = gtk_print_settings_new(); | |
93 | + GtkPageSetup * setup = gtk_page_setup_new(); | |
94 | + GtkPaperSize * papersize = NULL; | |
95 | + | |
96 | + g_signal_connect(operation,"create-custom-widget",G_CALLBACK(create_custom_widget),NULL); | |
97 | + g_signal_connect(operation,"custom-widget-apply",G_CALLBACK(custom_widget_apply), NULL); | |
98 | + | |
99 | + // Load page and print settings | |
100 | + GKeyFile * conf = get_application_keyfile(); | |
101 | + GError * err = NULL; | |
102 | + | |
103 | + if(!gtk_print_settings_load_key_file(settings,conf,"print_settings",&err)) | |
104 | + { | |
105 | + g_warning("Error getting print settings: %s",err->message); | |
106 | + g_error_free(err); | |
107 | + err = NULL; | |
108 | + } | |
109 | + | |
110 | + if(!gtk_page_setup_load_key_file(setup,conf,"page_setup",&err)) | |
111 | + { | |
112 | + g_warning("Error getting page setup: %s",err->message); | |
113 | + g_error_free(err); | |
114 | + err = NULL; | |
115 | + } | |
116 | + | |
117 | + if(g_key_file_has_group(conf,"paper_size")) | |
118 | + { | |
119 | + // Use saved paper size | |
120 | + GError *err = NULL; | |
121 | + | |
122 | + papersize = gtk_paper_size_new_from_key_file(conf,"paper_size",&err); | |
123 | + if(err) | |
124 | + { | |
125 | + g_warning("Error loading paper size: %s",err->message); | |
126 | + g_error_free(err); | |
127 | + } | |
128 | + | |
129 | + trace("Papersize: %p",papersize); | |
130 | + } | |
131 | + else | |
132 | + { | |
133 | + // Create default | |
134 | + papersize = gtk_paper_size_new(NULL); | |
135 | + } | |
136 | + | |
137 | + gtk_print_operation_set_print_settings(operation,settings); | |
138 | + gtk_page_setup_set_paper_size_and_default_margins(setup,papersize); | |
139 | + gtk_print_operation_set_default_page_setup(operation,setup); | |
140 | + | |
141 | +} | |
142 | + | ... | ... |
src/pw3270/print.c
... | ... | @@ -38,151 +38,8 @@ |
38 | 38 | #define FONT_CONFIG "font-family" |
39 | 39 | #define DEFAULT_FONT "Courier New" |
40 | 40 | |
41 | -/*--[ Structs ]--------------------------------------------------------------------------------------*/ | |
42 | - | |
43 | - typedef struct _print_info | |
44 | - { | |
45 | - GdkRGBA color[V3270_COLOR_COUNT]; | |
46 | - int show_selection : 1; | |
47 | - LIB3270_CONTENT_OPTION src; | |
48 | - | |
49 | - GtkWidget * widget; | |
50 | - H3270 * session; | |
51 | - | |
52 | - int baddr; | |
53 | - int rows; | |
54 | - int cols; /**< Max line width */ | |
55 | - int pages; | |
56 | - int lpp; /**< Lines per page */ | |
57 | - | |
58 | - v3270FontInfo font; | |
59 | - | |
60 | - double left; | |
61 | - double width; /**< Report width */ | |
62 | - double height; /**< Report height (all pages) */ | |
63 | - | |
64 | - gchar **text; | |
65 | - | |
66 | - } PRINT_INFO; | |
67 | - | |
68 | - | |
69 | 41 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
70 | 42 | |
71 | - static void begin_print(GtkPrintOperation *prt, GtkPrintContext *context, PRINT_INFO *info) | |
72 | - { | |
73 | - cairo_font_extents_t extents; | |
74 | - | |
75 | - cairo_t * cr = gtk_print_context_get_cairo_context(context); | |
76 | - gchar * font = get_string_from_config("print",FONT_CONFIG,DEFAULT_FONT); | |
77 | - | |
78 | - trace("%s: operation=%p context=%p font=\"%s\"",__FUNCTION__,prt,context,font); | |
79 | - | |
80 | - // Setup font | |
81 | - if(*font) | |
82 | - { | |
83 | - PangoFontDescription * descr = pango_font_description_from_string(font); | |
84 | - if(descr) | |
85 | - { | |
86 | - cairo_select_font_face(cr, pango_font_description_get_family(descr), | |
87 | - CAIRO_FONT_SLANT_NORMAL, | |
88 | - pango_font_description_get_weight(descr) == PANGO_WEIGHT_BOLD ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL); | |
89 | - | |
90 | - { | |
91 | - double width = gtk_print_context_get_width(context); | |
92 | - double cols = (double) info->cols; | |
93 | - double current = width / cols; | |
94 | - double valid = current; | |
95 | - | |
96 | - do | |
97 | - { | |
98 | - valid = current; | |
99 | - current = valid +1.0; | |
100 | - cairo_set_font_size(cr,current); | |
101 | - cairo_font_extents(cr,&extents); | |
102 | - } | |
103 | - while( (cols * extents.max_x_advance) < width ); | |
104 | - | |
105 | - trace("Font size: %d",(int) valid); | |
106 | - cairo_set_font_size(cr,valid); | |
107 | - | |
108 | - } | |
109 | - | |
110 | - pango_font_description_free(descr); | |
111 | - } | |
112 | - } | |
113 | - g_free(font); | |
114 | - | |
115 | - info->font.scaled = cairo_get_scaled_font(cr); | |
116 | - cairo_scaled_font_reference(info->font.scaled); | |
117 | - cairo_scaled_font_extents(info->font.scaled,&extents); | |
118 | - | |
119 | - info->font.height = extents.height; | |
120 | - info->font.descent = extents.descent; | |
121 | - info->font.width = extents.max_x_advance; | |
122 | - | |
123 | - info->width = ((double) info->cols) * extents.max_x_advance; | |
124 | - info->height = ((double) info->rows) * (extents.height + extents.descent); | |
125 | - | |
126 | - // Center image | |
127 | - info->left = (gtk_print_context_get_width(context)-info->width)/2; | |
128 | - if(info->left < 2) | |
129 | - info->left = 2; | |
130 | - | |
131 | - // Setup page size | |
132 | - info->lpp = (gtk_print_context_get_height(context) / (extents.height + extents.descent)); | |
133 | - info->pages = (info->rows / info->lpp)+1; | |
134 | - | |
135 | - trace("%d lines per page, %d pages to print",info->lpp,info->pages); | |
136 | - | |
137 | - gtk_print_operation_set_n_pages(prt,info->pages); | |
138 | - } | |
139 | - | |
140 | - static void draw_screen(GtkPrintOperation *prt, GtkPrintContext *context, gint pg, PRINT_INFO *info) | |
141 | - { | |
142 | - int row; | |
143 | - int col; | |
144 | - cairo_t * cr = gtk_print_context_get_cairo_context(context); | |
145 | - int baddr = info->baddr; | |
146 | - GdkRectangle rect; | |
147 | - | |
148 | - cairo_set_scaled_font(cr,info->font.scaled); | |
149 | - | |
150 | - memset(&rect,0,sizeof(rect)); | |
151 | - rect.y = 2; | |
152 | - rect.height = (info->font.height + info->font.descent); | |
153 | - rect.width = info->font.width; | |
154 | - | |
155 | - // Clear page | |
156 | - gdk_cairo_set_source_rgba(cr,info->color+V3270_COLOR_BACKGROUND); | |
157 | - cairo_rectangle(cr, info->left-2, 0, (rect.width*info->cols)+4, (rect.height*info->rows)+4); | |
158 | - cairo_fill(cr); | |
159 | - cairo_stroke(cr); | |
160 | - | |
161 | - rect.width++; | |
162 | - rect.height++; | |
163 | - | |
164 | - for(row = 0; row < info->rows; row++) | |
165 | - { | |
166 | - rect.x = info->left; | |
167 | - for(col = 0; col < info->cols; col++) | |
168 | - { | |
169 | - unsigned char c; | |
170 | - unsigned short attr; | |
171 | - | |
172 | - if(!lib3270_get_element(info->session,baddr++,&c,&attr) && (info->src == LIB3270_CONTENT_ALL || (attr & LIB3270_ATTR_SELECTED))) | |
173 | - { | |
174 | - if(!info->show_selection) | |
175 | - attr &= ~LIB3270_ATTR_SELECTED; | |
176 | - v3270_draw_element(cr,c,attr,info->session,&info->font,&rect,info->color); | |
177 | - } | |
178 | - | |
179 | - rect.x += (rect.width-1); | |
180 | - } | |
181 | - rect.y += (rect.height-1); | |
182 | - | |
183 | - } | |
184 | - } | |
185 | - | |
186 | 43 | #ifdef _WIN32 |
187 | 44 | |
188 | 45 | #define save_string(h,k,v) save_settings(k,v,h) |
... | ... | @@ -236,6 +93,7 @@ static gchar * enum_to_string(GType type, guint enum_value) |
236 | 93 | gtk_widget_destroy(dialog); |
237 | 94 | } |
238 | 95 | |
96 | + /* | |
239 | 97 | static void done(GtkPrintOperation *prt, GtkPrintOperationResult result, PRINT_INFO *info) |
240 | 98 | { |
241 | 99 | if(result == GTK_PRINT_OPERATION_RESULT_ERROR) |
... | ... | @@ -327,77 +185,8 @@ static gchar * enum_to_string(GType type, guint enum_value) |
327 | 185 | |
328 | 186 | } |
329 | 187 | |
330 | - if(info->font.scaled) | |
331 | - cairo_scaled_font_destroy(info->font.scaled); | |
332 | - | |
333 | - if(info->text) | |
334 | - g_strfreev(info->text); | |
335 | - | |
336 | - if(info->font.family) | |
337 | - g_free(info->font.family); | |
338 | - | |
339 | - g_free(info); | |
340 | - } | |
341 | - | |
342 | - static void toggle_show_selection(GtkToggleButton *togglebutton,PRINT_INFO *info) | |
343 | - { | |
344 | - gboolean active = gtk_toggle_button_get_active(togglebutton); | |
345 | - info->show_selection = active ? 1 : 0; | |
346 | - set_boolean_to_config("print","selection",active); | |
347 | - } | |
348 | - | |
349 | - static GtkWidget * create_custom_widget(GtkPrintOperation *prt, PRINT_INFO *info) | |
350 | - { | |
351 | - GtkWidget * widget = gtk_frame_new(""); | |
352 | - GtkWidget * settings = V3270_print_settings_new(info->widget); | |
353 | - | |
354 | - // Load values from configuration | |
355 | - g_autofree gchar * font_family = get_string_from_config("print",FONT_CONFIG,DEFAULT_FONT); | |
356 | - if(font_family && *font_family) | |
357 | - v3270_print_settings_set_font_family(settings,font_family); | |
358 | - | |
359 | - g_autofree gchar * color_scheme = get_string_from_config("print","colors",""); | |
360 | - if(color_scheme && *color_scheme) | |
361 | - v3270_print_settings_set_color_scheme(settings,color_scheme); | |
362 | - | |
363 | - // Create frame | |
364 | - GtkWidget *label = gtk_label_new(NULL); | |
365 | - gtk_label_set_markup(GTK_LABEL(label),_("<b>Text options</b>")); | |
366 | - gtk_frame_set_label_widget(GTK_FRAME(widget),label); | |
367 | - | |
368 | - gtk_container_set_border_width(GTK_CONTAINER(widget),12); | |
369 | - | |
370 | - // The print dialog doesn't follow the guidelines from https://developer.gnome.org/hig/stable/visual-layout.html.en )-: | |
371 | - gtk_frame_set_shadow_type(GTK_FRAME(widget),GTK_SHADOW_NONE); | |
372 | - | |
373 | - gtk_container_set_border_width(GTK_CONTAINER(settings),6); | |
374 | - g_object_set(G_OBJECT(settings),"margin-start",8,NULL); | |
375 | - | |
376 | - gtk_container_add(GTK_CONTAINER(widget),settings); | |
377 | - | |
378 | - gtk_widget_show_all(widget); | |
379 | - | |
380 | - return widget; | |
381 | - } | |
382 | - | |
383 | - static void custom_widget_apply(GtkPrintOperation *prt, GtkWidget *widget, PRINT_INFO *info) | |
384 | - { | |
385 | - GtkWidget * settings = gtk_bin_get_child(GTK_BIN(widget)); | |
386 | - | |
387 | - info->show_selection = v3270_print_settings_get_show_selection(settings) ? 1 : 0; | |
388 | - | |
389 | - // Setup font family | |
390 | - if(info->font.family) | |
391 | - g_free(info->font.family); | |
392 | - info->font.family = v3270_print_settings_get_font_family(settings); | |
393 | - set_string_to_config("print",FONT_CONFIG,info->font.family); | |
394 | - | |
395 | - // Setup print settings | |
396 | - v3270_print_settings_get_rgba(settings, info->color, V3270_COLOR_COUNT); | |
397 | - g_autofree gchar * colors = v3270_print_settings_get_color_scheme(settings); | |
398 | - set_string_to_config("print","colors","%s",colors); | |
399 | - | |
400 | 188 | } |
189 | + */ | |
401 | 190 | |
402 | 191 | #ifdef _WIN32 |
403 | 192 | void update_settings(const gchar *key, const gchar *val, gpointer *settings) |
... | ... | @@ -432,6 +221,12 @@ static gchar * enum_to_string(GType type, guint enum_value) |
432 | 221 | |
433 | 222 | #endif // _WIN32 |
434 | 223 | |
224 | +#if GTK_CHECK_VERSION(3,0,0) && !defined(WIN32) | |
225 | +/* | |
226 | +*/ | |
227 | +#endif // !WIN32 | |
228 | + | |
229 | +/* | |
435 | 230 | static GtkPrintOperation * begin_print_operation(GObject *obj, GtkWidget *widget, PRINT_INFO **info) |
436 | 231 | { |
437 | 232 | GtkPrintOperation * print = gtk_print_operation_new(); |
... | ... | @@ -467,16 +262,13 @@ static gchar * enum_to_string(GType type, guint enum_value) |
467 | 262 | { |
468 | 263 | g_autofree gchar *color_scheme = get_string_from_config("print","colors",""); |
469 | 264 | |
470 | - trace("info->color=%p",info->color); | |
471 | - trace("colorlist=%p",ptr); | |
472 | - | |
473 | 265 | if(color_scheme && *color_scheme) |
474 | - v3270_set_color_table(info->color,color_scheme); | |
266 | + v3270_set_color_table((*info)->color,color_scheme); | |
475 | 267 | else |
476 | - v3270_set_mono_color_table(info->color,"black","white"); | |
268 | + v3270_set_mono_color_table((*info)->color,"black","white"); | |
477 | 269 | |
478 | 270 | } |
479 | -#endif // _WIN32 | |
271 | +#endif // !_WIN32 | |
480 | 272 | |
481 | 273 | // Load page and print settings |
482 | 274 | { |
... | ... | @@ -650,6 +442,7 @@ static gchar * enum_to_string(GType type, guint enum_value) |
650 | 442 | trace("%s ends",__FUNCTION__); |
651 | 443 | return print; |
652 | 444 | } |
445 | + */ | |
653 | 446 | |
654 | 447 | void print_all_action(GtkAction *action, GtkWidget *widget) |
655 | 448 | { |
... | ... | @@ -661,36 +454,66 @@ static gchar * enum_to_string(GType type, guint enum_value) |
661 | 454 | pw3270_print(widget,G_OBJECT(action),GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, LIB3270_CONTENT_SELECTED); |
662 | 455 | } |
663 | 456 | |
664 | - static void draw_text(GtkPrintOperation *prt, GtkPrintContext *context, gint pg, PRINT_INFO *info) | |
457 | + void print_copy_action(GtkAction *action, GtkWidget *widget) | |
665 | 458 | { |
666 | - cairo_t * cr = gtk_print_context_get_cairo_context(context); | |
667 | - GdkRectangle rect; | |
668 | - int row = pg*info->lpp; | |
669 | - int l; | |
459 | + pw3270_print(widget,G_OBJECT(action),GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, LIB3270_CONTENT_COPY); | |
460 | + } | |
461 | + | |
462 | + LIB3270_EXPORT int pw3270_print(GtkWidget *widget, GObject *action, GtkPrintOperationAction oper, LIB3270_CONTENT_OPTION src) | |
463 | + { | |
464 | + int rc = 0; | |
465 | + | |
466 | + g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL); | |
467 | + | |
468 | + if(action) | |
469 | + lib3270_trace_event(v3270_get_session(widget),"Action %s activated on widget %p\n",gtk_action_get_name(GTK_ACTION(action)),widget); | |
670 | 470 | |
671 | - cairo_set_scaled_font(cr,info->font.scaled); | |
471 | + // | |
472 | + // Create and setup dialog | |
473 | + // | |
474 | + GtkPrintOperation * operation = v3270_print_operation_new(widget,src); | |
672 | 475 | |
673 | - memset(&rect,0,sizeof(rect)); | |
674 | - rect.y = 2; | |
675 | - rect.height = (info->font.height + info->font.descent)+1; | |
676 | - rect.width = info->font.width+1; | |
476 | + gtk_print_operation_set_allow_async(operation,get_boolean_from_config("print","allow_async",TRUE)); | |
677 | 477 | |
678 | - for(l=0;l<info->lpp && row < info->rows;l++) | |
478 | + setup_print_dialog(operation); | |
479 | + | |
480 | + // | |
481 | + // Run print dialog | |
482 | + // | |
483 | + GError *err = NULL; | |
484 | + gtk_print_operation_run( | |
485 | + operation, | |
486 | + GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, | |
487 | + GTK_WINDOW(gtk_widget_get_toplevel(widget)), | |
488 | + &err | |
489 | + ); | |
490 | + | |
491 | + if(err) | |
679 | 492 | { |
680 | - cairo_move_to(cr,2,rect.y+rect.height); | |
681 | - cairo_show_text(cr, info->text[row]); | |
682 | - cairo_stroke(cr); | |
683 | - row++; | |
684 | - rect.y += (rect.height-1); | |
493 | + GtkWidget *popup = gtk_message_dialog_new_with_markup( | |
494 | + GTK_WINDOW(gtk_widget_get_toplevel(widget)), | |
495 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
496 | + GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE, | |
497 | + _("Can't print") | |
498 | + ); | |
499 | + | |
500 | + gtk_window_set_title(GTK_WINDOW(popup),_("Operation has failed")); | |
501 | + | |
502 | + gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(popup),"%s",err->message); | |
503 | + | |
504 | + gtk_dialog_run(GTK_DIALOG(popup)); | |
505 | + gtk_widget_destroy(popup); | |
506 | + | |
507 | + g_error_free(err); | |
508 | + | |
509 | + rc = -1; | |
685 | 510 | } |
686 | 511 | |
687 | - } | |
512 | + return rc; | |
688 | 513 | |
689 | - void print_copy_action(GtkAction *action, GtkWidget *widget) | |
690 | - { | |
691 | - pw3270_print(widget,G_OBJECT(action),GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, LIB3270_CONTENT_COPY); | |
692 | 514 | } |
693 | 515 | |
516 | + /* | |
694 | 517 | LIB3270_EXPORT int pw3270_print(GtkWidget *widget, GObject *action, GtkPrintOperationAction oper, LIB3270_CONTENT_OPTION src) |
695 | 518 | { |
696 | 519 | PRINT_INFO * info = NULL; |
... | ... | @@ -760,11 +583,11 @@ static gchar * enum_to_string(GType type, guint enum_value) |
760 | 583 | |
761 | 584 | return 0; |
762 | 585 | } |
586 | + */ | |
763 | 587 | |
764 | 588 | void print_settings_action(GtkAction *action, GtkWidget *terminal) |
765 | 589 | { |
766 | 590 | const gchar * title = g_object_get_data(G_OBJECT(action),"title"); |
767 | - PRINT_INFO info; | |
768 | 591 | GtkWidget * widget; |
769 | 592 | GtkWidget * dialog = gtk_dialog_new_with_buttons ( gettext(title ? title : N_( "Print settings") ), |
770 | 593 | GTK_WINDOW(gtk_widget_get_toplevel(terminal)), |
... | ... | @@ -773,8 +596,6 @@ void print_settings_action(GtkAction *action, GtkWidget *terminal) |
773 | 596 | GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
774 | 597 | NULL ); |
775 | 598 | |
776 | - memset(&info,0,sizeof(info)); | |
777 | - | |
778 | 599 | gtk_window_set_deletable(GTK_WINDOW(dialog),FALSE); |
779 | 600 | |
780 | 601 | // https://developer.gnome.org/hig/stable/visual-layout.html.en |
... | ... | @@ -788,14 +609,33 @@ void print_settings_action(GtkAction *action, GtkWidget *terminal) |
788 | 609 | 18 |
789 | 610 | ); |
790 | 611 | |
791 | - widget = GTK_WIDGET(create_custom_widget(NULL,&info)); | |
612 | + // Create settings widget & load values from configuration. | |
613 | + GtkWidget * settings = V3270_print_settings_new(terminal); | |
792 | 614 | |
793 | - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(widget),TRUE,TRUE,2); | |
615 | + // Load settings. | |
616 | + { | |
617 | + g_autofree gchar * font_family = get_string_from_config("print",FONT_CONFIG,DEFAULT_FONT); | |
618 | + if(font_family && *font_family) | |
619 | + v3270_print_settings_set_font_family(settings,font_family); | |
620 | + | |
621 | + g_autofree gchar * color_scheme = get_string_from_config("print","colors",""); | |
622 | + if(color_scheme && *color_scheme) | |
623 | + v3270_print_settings_set_color_scheme(settings,color_scheme); | |
624 | + } | |
625 | + | |
626 | + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),settings,TRUE,TRUE,2); | |
794 | 627 | |
795 | 628 | if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
796 | 629 | { |
797 | 630 | // Accepted, save settings |
798 | - custom_widget_apply(NULL,widget,&info); | |
631 | + | |
632 | + // Save font family | |
633 | + g_autofree gchar * font_family = v3270_print_settings_get_font_family(settings); | |
634 | + set_string_to_config("print",FONT_CONFIG,font_family); | |
635 | + | |
636 | + // Save colors | |
637 | + g_autofree gchar * colors = v3270_print_settings_get_color_scheme(settings); | |
638 | + set_string_to_config("print","colors","%s",colors); | |
799 | 639 | } |
800 | 640 | |
801 | 641 | gtk_widget_destroy(dialog); | ... | ... |
src/pw3270/private.h
... | ... | @@ -76,6 +76,9 @@ |
76 | 76 | G_GNUC_INTERNAL GtkWidget * color_scheme_new(const GdkRGBA *current); |
77 | 77 | G_GNUC_INTERNAL void run_security_dialog(GtkWidget *widget); |
78 | 78 | |
79 | + // Tools | |
80 | + G_GNUC_INTERNAL void setup_print_dialog(GtkPrintOperation * operation); | |
81 | + | |
79 | 82 | // actions |
80 | 83 | G_GNUC_INTERNAL void paste_file_action(GtkAction *action, GtkWidget *widget); |
81 | 84 | G_GNUC_INTERNAL void hostname_action(GtkAction *action, GtkWidget *widget); | ... | ... |
src/pw3270/resources.rc.in
... | ... | @@ -1,31 +0,0 @@ |
1 | -#include <windows.h> | |
2 | - | |
3 | -1 ICON @PACKAGE_TARNAME@.ico | |
4 | - | |
5 | -VS_VERSION_INFO VERSIONINFO | |
6 | -FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 | |
7 | -PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 | |
8 | - | |
9 | -BEGIN | |
10 | - | |
11 | - BLOCK "StringFileInfo" | |
12 | - BEGIN | |
13 | - BLOCK "080904E4" | |
14 | - BEGIN | |
15 | - VALUE "FileDescription", "@PACKAGE_DESCRIPTION@\0" | |
16 | - VALUE "CompanyName", "Banco do Brasil S/A.\0" | |
17 | - VALUE "FileVersion", "@WIN32_VERSION@\0" | |
18 | - VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0" | |
19 | - VALUE "OriginalFilename", "@PACKAGE_TARNAME@.exe\0" | |
20 | - VALUE "ProductName", "@PACKAGE_NAME@\0" | |
21 | - VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.0\0" | |
22 | - END | |
23 | - END | |
24 | - | |
25 | - BLOCK "VarFileInfo" | |
26 | - BEGIN | |
27 | - VALUE "Translation", 0x809, 0x04E4 | |
28 | - END | |
29 | - | |
30 | -END | |
31 | - |
... | ... | @@ -0,0 +1,44 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como - e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | + #include "private.h" | |
31 | + #include <v3270.h> | |
32 | + #include <v3270/print.h> | |
33 | + #include <lib3270/selection.h> | |
34 | + #include <lib3270/trace.h> | |
35 | + | |
36 | + | |
37 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
38 | + | |
39 | + | |
40 | +void setup_print_dialog(GtkPrintOperation * operation) | |
41 | +{ | |
42 | + | |
43 | +} | |
44 | + | ... | ... |
... | ... | @@ -0,0 +1,31 @@ |
1 | +#include <windows.h> | |
2 | + | |
3 | +1 ICON @PACKAGE_TARNAME@.ico | |
4 | + | |
5 | +VS_VERSION_INFO VERSIONINFO | |
6 | +FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 | |
7 | +PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0 | |
8 | + | |
9 | +BEGIN | |
10 | + | |
11 | + BLOCK "StringFileInfo" | |
12 | + BEGIN | |
13 | + BLOCK "080904E4" | |
14 | + BEGIN | |
15 | + VALUE "FileDescription", "@PACKAGE_DESCRIPTION@\0" | |
16 | + VALUE "CompanyName", "Banco do Brasil S/A.\0" | |
17 | + VALUE "FileVersion", "@WIN32_VERSION@\0" | |
18 | + VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0" | |
19 | + VALUE "OriginalFilename", "@PACKAGE_TARNAME@.exe\0" | |
20 | + VALUE "ProductName", "@PACKAGE_NAME@\0" | |
21 | + VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.0\0" | |
22 | + END | |
23 | + END | |
24 | + | |
25 | + BLOCK "VarFileInfo" | |
26 | + BEGIN | |
27 | + VALUE "Translation", 0x809, 0x04E4 | |
28 | + END | |
29 | + | |
30 | +END | |
31 | + | ... | ... |