Commit b3926a49b21900b25f087bf2bf1f248570571069
1 parent
f4743ff8
Exists in
master
and in
5 other branches
Linux custom print widget is now managed by libv3270.
Showing
4 changed files
with
77 additions
and
20 deletions
Show diff stats
src/pw3270/linux/print.c
| ... | ... | @@ -37,6 +37,7 @@ |
| 37 | 37 | |
| 38 | 38 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 39 | 39 | |
| 40 | +/* | |
| 40 | 41 | static GtkWidget * create_custom_widget(GtkPrintOperation *prt, gpointer G_GNUC_UNUSED(dunno)) |
| 41 | 42 | { |
| 42 | 43 | GtkWidget * widget = gtk_frame_new(""); |
| ... | ... | @@ -70,31 +71,24 @@ |
| 70 | 71 | |
| 71 | 72 | return widget; |
| 72 | 73 | } |
| 74 | +*/ | |
| 73 | 75 | |
| 76 | +/* | |
| 74 | 77 | static void custom_widget_apply(GtkPrintOperation *prt, GtkWidget *widget, gpointer G_GNUC_UNUSED(dunno)) |
| 75 | 78 | { |
| 76 | 79 | GtkWidget * settings = gtk_bin_get_child(GTK_BIN(widget)); |
| 77 | - | |
| 78 | 80 | 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 | 81 | } |
| 82 | +*/ | |
| 89 | 83 | |
| 90 | - void setup_print_dialog(GtkPrintOperation * operation) | |
| 84 | + void load_print_operation_settings(GtkPrintOperation * operation) | |
| 91 | 85 | { |
| 92 | 86 | GtkPrintSettings * settings = gtk_print_settings_new(); |
| 93 | 87 | GtkPageSetup * setup = gtk_page_setup_new(); |
| 94 | 88 | GtkPaperSize * papersize = NULL; |
| 95 | 89 | |
| 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); | |
| 90 | +// g_signal_connect(operation,"create-custom-widget",G_CALLBACK(create_custom_widget),NULL); | |
| 91 | +// g_signal_connect(operation,"custom-widget-apply",G_CALLBACK(custom_widget_apply), NULL); | |
| 98 | 92 | |
| 99 | 93 | // Load page and print settings |
| 100 | 94 | GKeyFile * conf = get_application_keyfile(); |
| ... | ... | @@ -138,5 +132,36 @@ |
| 138 | 132 | gtk_page_setup_set_paper_size_and_default_margins(setup,papersize); |
| 139 | 133 | gtk_print_operation_set_default_page_setup(operation,setup); |
| 140 | 134 | |
| 135 | + // Load font and colors | |
| 136 | + g_autofree gchar * font_family = get_string_from_config("print",FONT_CONFIG,DEFAULT_FONT); | |
| 137 | + if(font_family && *font_family) | |
| 138 | + v3270_print_operation_set_font_family(operation,font_family); | |
| 139 | + | |
| 140 | + g_autofree gchar * color_scheme = get_string_from_config("print","colors",""); | |
| 141 | + if(color_scheme && *color_scheme) | |
| 142 | + v3270_print_operation_set_color_scheme(operation,color_scheme); | |
| 143 | + | |
| 141 | 144 | } |
| 142 | 145 | |
| 146 | + void save_print_operation_settings(GtkPrintOperation * operation) | |
| 147 | + { | |
| 148 | + GtkPrintSettings * settings = gtk_print_operation_get_print_settings(operation); | |
| 149 | + GtkPageSetup * pgsetup = gtk_print_operation_get_default_page_setup(operation); | |
| 150 | + GtkPaperSize * papersize = gtk_page_setup_get_paper_size(pgsetup); | |
| 151 | + | |
| 152 | + g_message("Saving print settings"); | |
| 153 | + | |
| 154 | + GKeyFile * conf = get_application_keyfile(); | |
| 155 | + gtk_print_settings_to_key_file(settings,conf,"print_settings"); | |
| 156 | + gtk_page_setup_to_key_file(pgsetup,conf,"page_setup"); | |
| 157 | + gtk_paper_size_to_key_file(papersize,conf,"paper_size"); | |
| 158 | + | |
| 159 | + // Store font family | |
| 160 | + g_autofree gchar * font_family = v3270_print_operation_get_font_family(operation); | |
| 161 | + set_string_to_config("print",FONT_CONFIG,font_family); | |
| 162 | + | |
| 163 | + // Store save color settings | |
| 164 | + g_autofree gchar * colors = v3270_print_operation_get_color_scheme(operation); | |
| 165 | + set_string_to_config("print","colors","%s",colors); | |
| 166 | + | |
| 167 | + } | ... | ... |
src/pw3270/print.c
| ... | ... | @@ -24,8 +24,6 @@ |
| 24 | 24 | * |
| 25 | 25 | * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) |
| 26 | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) |
| 27 | - * licinio@bb.com.br (Licínio Luis Branco) | |
| 28 | - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
| 29 | 27 | * |
| 30 | 28 | */ |
| 31 | 29 | |
| ... | ... | @@ -183,18 +181,19 @@ |
| 183 | 181 | |
| 184 | 182 | gtk_print_operation_set_allow_async(operation,get_boolean_from_config("print","allow_async",TRUE)); |
| 185 | 183 | |
| 186 | - setup_print_dialog(operation); | |
| 184 | + load_print_operation_settings(operation); | |
| 187 | 185 | |
| 188 | 186 | // |
| 189 | 187 | // Run print dialog |
| 190 | 188 | // |
| 191 | 189 | GError *err = NULL; |
| 192 | - gtk_print_operation_run( | |
| 190 | + GtkPrintOperationResult result = | |
| 191 | + gtk_print_operation_run( | |
| 193 | 192 | operation, |
| 194 | 193 | GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, |
| 195 | 194 | GTK_WINDOW(gtk_widget_get_toplevel(widget)), |
| 196 | 195 | &err |
| 197 | - ); | |
| 196 | + ); | |
| 198 | 197 | |
| 199 | 198 | if(err) |
| 200 | 199 | { |
| ... | ... | @@ -216,6 +215,33 @@ |
| 216 | 215 | |
| 217 | 216 | rc = -1; |
| 218 | 217 | } |
| 218 | + else | |
| 219 | + { | |
| 220 | + switch(result) | |
| 221 | + { | |
| 222 | + case GTK_PRINT_OPERATION_RESULT_ERROR: // An error has occurred. | |
| 223 | + g_message("Print operation has failed"); | |
| 224 | + break; | |
| 225 | + | |
| 226 | + case GTK_PRINT_OPERATION_RESULT_APPLY: // The print settings should be stored. | |
| 227 | + save_print_operation_settings(operation); | |
| 228 | + break; | |
| 229 | + | |
| 230 | + case GTK_PRINT_OPERATION_RESULT_CANCEL: // The print operation has been canceled, the print settings should not be stored. | |
| 231 | + g_message("Print operation was cancelled"); | |
| 232 | + break; | |
| 233 | + | |
| 234 | + case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: // The print operation is not complete yet. This value will only be returned when running asynchronously. | |
| 235 | + g_message("Print operation is in progress"); | |
| 236 | + break; | |
| 237 | + | |
| 238 | + default: | |
| 239 | + g_warning("Unexpected print operation result: %d",(int) result); | |
| 240 | + | |
| 241 | + } | |
| 242 | + } | |
| 243 | + | |
| 244 | + g_object_unref(operation); | |
| 219 | 245 | |
| 220 | 246 | return rc; |
| 221 | 247 | ... | ... |
src/pw3270/private.h
| ... | ... | @@ -77,7 +77,8 @@ |
| 77 | 77 | G_GNUC_INTERNAL void run_security_dialog(GtkWidget *widget); |
| 78 | 78 | |
| 79 | 79 | // Tools |
| 80 | - G_GNUC_INTERNAL void setup_print_dialog(GtkPrintOperation * operation); | |
| 80 | + G_GNUC_INTERNAL void load_print_operation_settings(GtkPrintOperation * operation); | |
| 81 | + G_GNUC_INTERNAL void save_print_operation_settings(GtkPrintOperation * operation); | |
| 81 | 82 | |
| 82 | 83 | // actions |
| 83 | 84 | G_GNUC_INTERNAL void paste_file_action(GtkAction *action, GtkWidget *widget); | ... | ... |
src/pw3270/windows/print.c
| ... | ... | @@ -100,7 +100,7 @@ static gchar * enum_to_string(GType type, guint enum_value) |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - void setup_print_dialog(GtkPrintOperation * operation) | |
| 103 | + void load_print_operation_settings(GtkPrintOperation * operation) | |
| 104 | 104 | { |
| 105 | 105 | GtkPrintSettings * settings = gtk_print_settings_new(); |
| 106 | 106 | GtkPageSetup * setup = gtk_page_setup_new(); |
| ... | ... | @@ -222,3 +222,8 @@ static gchar * enum_to_string(GType type, guint enum_value) |
| 222 | 222 | |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | + void save_print_operation_settings(GtkPrintOperation * operation) | |
| 226 | + { | |
| 227 | + | |
| 228 | + | |
| 229 | + } | ... | ... |