Commit 58ae34b3af6021196954e6f2290e301f3ec92976
1 parent
96a6a74a
Exists in
master
and in
1 other branch
Adding key-file save & load on print operation object.
Adding signal for keyfile load on terminal widget.
Showing
6 changed files
with
126 additions
and
1 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,107 @@ |
| 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 | + | |
| 32 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 33 | + | |
| 34 | + void v3270_print_operation_to_key_file(GtkPrintOperation *operation, GKeyFile *key_file) { | |
| 35 | + | |
| 36 | + GtkPrintSettings * settings = gtk_print_operation_get_print_settings(operation); | |
| 37 | + GtkPageSetup * pgsetup = gtk_print_operation_get_default_page_setup(operation); | |
| 38 | + GtkPaperSize * papersize = gtk_page_setup_get_paper_size(pgsetup); | |
| 39 | + | |
| 40 | + trace("%s(%p)",__FUNCTION__,operation); | |
| 41 | + g_message("Saving print settings"); | |
| 42 | + | |
| 43 | + gtk_print_settings_to_key_file(settings,key_file,"print_settings"); | |
| 44 | + gtk_page_setup_to_key_file(pgsetup,key_file,"page_setup"); | |
| 45 | + gtk_paper_size_to_key_file(papersize,key_file,"paper_size"); | |
| 46 | + | |
| 47 | + // Store font family | |
| 48 | + g_autofree gchar * font_family = v3270_print_operation_get_font_family(operation); | |
| 49 | + g_key_file_set_string(key_file,"print","font-family",font_family); | |
| 50 | + | |
| 51 | + // Store color settings | |
| 52 | + g_autofree gchar * colors = v3270_print_operation_get_color_scheme(operation); | |
| 53 | + g_key_file_set_string(key_file,"print","colors",colors); | |
| 54 | + | |
| 55 | + } | |
| 56 | + | |
| 57 | + void v3270_print_operation_load_key_file(GtkPrintOperation *operation, GKeyFile *key_file) { | |
| 58 | + | |
| 59 | + GtkPrintSettings * settings = gtk_print_settings_new(); | |
| 60 | + GtkPageSetup * setup = gtk_page_setup_new(); | |
| 61 | + GtkPaperSize * papersize = NULL; | |
| 62 | + GError * error = NULL; | |
| 63 | + | |
| 64 | + // Load page and print settings | |
| 65 | + | |
| 66 | + if(g_key_file_has_group(key_file,"print_settings") && !gtk_print_settings_load_key_file(settings,key_file,"print_settings",&error)) { | |
| 67 | + g_warning("Error getting print settings: %s",error->message); | |
| 68 | + g_error_free(error); | |
| 69 | + error = NULL; | |
| 70 | + } | |
| 71 | + | |
| 72 | + if(g_key_file_has_group(key_file,"page_setup") && !gtk_page_setup_load_key_file(setup,key_file,"page_setup",&error)) { | |
| 73 | + g_warning("Error getting page setup: %s",error->message); | |
| 74 | + g_error_free(error); | |
| 75 | + error = NULL; | |
| 76 | + } | |
| 77 | + | |
| 78 | + if(g_key_file_has_group(key_file,"paper_size")) { | |
| 79 | + // Use saved paper size | |
| 80 | + | |
| 81 | + papersize = gtk_paper_size_new_from_key_file(key_file,"paper_size",&error); | |
| 82 | + if(error) | |
| 83 | + { | |
| 84 | + g_warning("Error loading paper size: %s",error->message); | |
| 85 | + g_error_free(error); | |
| 86 | + error = NULL; | |
| 87 | + } | |
| 88 | + | |
| 89 | + } else { | |
| 90 | + // Create default | |
| 91 | + papersize = gtk_paper_size_new(NULL); | |
| 92 | + } | |
| 93 | + | |
| 94 | + gtk_print_operation_set_print_settings(operation,settings); | |
| 95 | + gtk_page_setup_set_paper_size_and_default_margins(setup,papersize); | |
| 96 | + gtk_print_operation_set_default_page_setup(operation,setup); | |
| 97 | + | |
| 98 | + // Load font and colors | |
| 99 | + g_autofree gchar * font_family = g_key_file_get_string(key_file,"print","font-family",NULL); | |
| 100 | + if(font_family && *font_family) | |
| 101 | + v3270_print_operation_set_font_family(operation,font_family); | |
| 102 | + | |
| 103 | + g_autofree gchar * color_scheme = g_key_file_get_string(key_file,"print","colors",NULL); | |
| 104 | + if(color_scheme && *color_scheme) | |
| 105 | + v3270_print_operation_set_color_scheme(operation,color_scheme); | |
| 106 | + | |
| 107 | + } | ... | ... |
src/dialogs/print/print.c
| ... | ... | @@ -244,6 +244,8 @@ |
| 244 | 244 | g_object_ref(G_OBJECT(opr->widget)); |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | + g_signal_emit(GTK_WIDGET(opr->widget), v3270_widget_signal[V3270_SIGNAL_PRINT_SETUP], 0, operation); | |
| 248 | + | |
| 247 | 249 | } |
| 248 | 250 | |
| 249 | 251 | GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode) |
| ... | ... | @@ -265,8 +267,8 @@ |
| 265 | 267 | operation->widget = NULL; |
| 266 | 268 | operation->session = NULL; |
| 267 | 269 | |
| 268 | - v3270_print_operation_set_terminal(GTK_PRINT_OPERATION(operation),GTK_WIDGET(widget)); | |
| 269 | 270 | v3270_set_mono_color_table(operation->settings.colors,"#000000","#FFFFFF"); |
| 271 | + v3270_print_operation_set_terminal(GTK_PRINT_OPERATION(operation),GTK_WIDGET(widget)); | |
| 270 | 272 | |
| 271 | 273 | // Get contents. |
| 272 | 274 | switch(operation->mode) | ... | ... |
src/include/internals.h
src/include/v3270/print.h
| ... | ... | @@ -67,6 +67,9 @@ |
| 67 | 67 | |
| 68 | 68 | LIB3270_EXPORT void v3270_print_operation_apply_settings(GtkPrintOperation *operation, GtkWidget *settings); |
| 69 | 69 | |
| 70 | + LIB3270_EXPORT void v3270_print_operation_to_key_file(GtkPrintOperation *operation, GKeyFile *key_file); | |
| 71 | + LIB3270_EXPORT void v3270_print_operation_load_key_file(GtkPrintOperation *operation, GKeyFile *key_file); | |
| 72 | + | |
| 70 | 73 | LIB3270_EXPORT void v3270_print_operation_set_terminal(GtkPrintOperation * operation, GtkWidget *terminal); |
| 71 | 74 | LIB3270_EXPORT GtkWidget * v3270_print_operation_get_terminal(GtkPrintOperation *operation); |
| 72 | 75 | ... | ... |
src/terminal/widget.c
| ... | ... | @@ -435,6 +435,15 @@ static void v3270_class_init(v3270Class *klass) |
| 435 | 435 | v3270_VOID__VOID_POINTER_UINT, |
| 436 | 436 | G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT, 0); |
| 437 | 437 | |
| 438 | + v3270_widget_signal[V3270_SIGNAL_PRINT_SETUP] = | |
| 439 | + g_signal_new( I_("print-setup"), | |
| 440 | + G_OBJECT_CLASS_TYPE (gobject_class), | |
| 441 | + G_SIGNAL_RUN_FIRST, | |
| 442 | + 0, | |
| 443 | + NULL, NULL, | |
| 444 | + v3270_VOID__VOID_POINTER, | |
| 445 | + G_TYPE_NONE, 2, G_TYPE_POINTER, 0); | |
| 446 | + | |
| 438 | 447 | v3270_widget_signal[V3270_SIGNAL_SAVE_SETTINGS] = |
| 439 | 448 | g_signal_new( I_("save-settings"), |
| 440 | 449 | G_OBJECT_CLASS_TYPE (gobject_class), | ... | ... |
v3270.cbp
| ... | ... | @@ -75,6 +75,9 @@ |
| 75 | 75 | <Unit filename="src/dialogs/print/draw.c"> |
| 76 | 76 | <Option compilerVar="CC" /> |
| 77 | 77 | </Unit> |
| 78 | + <Unit filename="src/dialogs/print/keyfile.c"> | |
| 79 | + <Option compilerVar="CC" /> | |
| 80 | + </Unit> | |
| 78 | 81 | <Unit filename="src/dialogs/print/print.c"> |
| 79 | 82 | <Option compilerVar="CC" /> |
| 80 | 83 | </Unit> | ... | ... |