Commit 14e4ac2001f6ce1f56693eae6157f6fe9f58d360
1 parent
111e4359
Exists in
v5.2
Fixing print settings.
Showing
1 changed file
with
58 additions
and
48 deletions
Show diff stats
src/pw3270/print.c
| ... | ... | @@ -33,6 +33,7 @@ |
| 33 | 33 | #include <v3270/dialogs.h> |
| 34 | 34 | #include <lib3270/selection.h> |
| 35 | 35 | #include <lib3270/trace.h> |
| 36 | + #include <lib3270/log.h> | |
| 36 | 37 | |
| 37 | 38 | #define FONT_CONFIG "font-family" |
| 38 | 39 | #define DEFAULT_FONT "Courier New" |
| ... | ... | @@ -54,6 +55,54 @@ |
| 54 | 55 | pw3270_print(widget,G_OBJECT(action),GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, LIB3270_CONTENT_COPY); |
| 55 | 56 | } |
| 56 | 57 | |
| 58 | + static void done(GtkPrintOperation *operation, GtkPrintOperationResult result, GtkWidget *terminal) | |
| 59 | + { | |
| 60 | + debug("%s(%u)",__FUNCTION__,(unsigned int) result); | |
| 61 | + | |
| 62 | + switch(result) | |
| 63 | + { | |
| 64 | + case GTK_PRINT_OPERATION_RESULT_ERROR: // An error has occurred. | |
| 65 | + { | |
| 66 | + // Get error code | |
| 67 | + GError * err = NULL; | |
| 68 | + | |
| 69 | + gtk_print_operation_get_error(operation,&err); | |
| 70 | + | |
| 71 | + v3270_error_popup( | |
| 72 | + terminal, | |
| 73 | + _("Operation has failed"), | |
| 74 | + _( "Unable to complete print job" ), | |
| 75 | + err->message | |
| 76 | + ); | |
| 77 | + | |
| 78 | + g_error_free(err); | |
| 79 | + | |
| 80 | + } | |
| 81 | + break; | |
| 82 | + | |
| 83 | + case GTK_PRINT_OPERATION_RESULT_APPLY: // The print settings should be stored. | |
| 84 | + trace("%s","GTK_PRINT_OPERATION_RESULT_APPLY"); | |
| 85 | + save_print_operation_settings(operation); | |
| 86 | + break; | |
| 87 | + | |
| 88 | + case GTK_PRINT_OPERATION_RESULT_CANCEL: // The print operation has been canceled, the print settings should not be stored. | |
| 89 | + trace("%s","GTK_PRINT_OPERATION_RESULT_CANCEL"); | |
| 90 | + g_message("Print operation was cancelled"); | |
| 91 | + break; | |
| 92 | + | |
| 93 | + case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: // The print operation is not complete yet. This value will only be returned when running asynchronously. | |
| 94 | + trace("%s","GTK_PRINT_OPERATION_RESULT_IN_PROGRESS"); | |
| 95 | + g_message("Print operation is in progress"); | |
| 96 | + break; | |
| 97 | + | |
| 98 | + default: | |
| 99 | + trace("%s","Unexpected"); | |
| 100 | + g_warning("Unexpected print operation result: %d",(int) result); | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + } | |
| 105 | + | |
| 57 | 106 | LIB3270_EXPORT int pw3270_print(GtkWidget *widget, GObject *action, GtkPrintOperationAction oper, LIB3270_CONTENT_OPTION src) |
| 58 | 107 | { |
| 59 | 108 | int rc = 0; |
| ... | ... | @@ -67,9 +116,17 @@ |
| 67 | 116 | // Create and setup dialog |
| 68 | 117 | // |
| 69 | 118 | GtkPrintOperation * operation = v3270_print_operation_new(widget,src); |
| 119 | + if(!operation) | |
| 120 | + { | |
| 121 | + g_message("Can't create print operation"); | |
| 122 | + return -1; | |
| 123 | + } | |
| 124 | + | |
| 125 | + g_signal_connect(operation,"done",G_CALLBACK(done),widget); | |
| 126 | + | |
| 70 | 127 | { |
| 71 | 128 | // Setup async mode |
| 72 | - gboolean async = get_boolean_from_config("terminal","allow_async_print",FALSE); | |
| 129 | + gboolean async = get_boolean_from_config("terminal","allow_async_print",TRUE); | |
| 73 | 130 | gtk_print_operation_set_allow_async(operation,async); |
| 74 | 131 | } |
| 75 | 132 | |
| ... | ... | @@ -99,53 +156,6 @@ |
| 99 | 156 | g_error_free(err); |
| 100 | 157 | rc = -1; |
| 101 | 158 | } |
| 102 | - else | |
| 103 | - { | |
| 104 | - trace("Print operation result was %u",(unsigned int) result); | |
| 105 | - | |
| 106 | - switch(result) | |
| 107 | - { | |
| 108 | - case GTK_PRINT_OPERATION_RESULT_ERROR: // An error has occurred. | |
| 109 | - { | |
| 110 | - // Get error code | |
| 111 | - GError * err = NULL; | |
| 112 | - | |
| 113 | - gtk_print_operation_get_error(operation,&err); | |
| 114 | - | |
| 115 | - v3270_error_popup( | |
| 116 | - widget, | |
| 117 | - _("Operation has failed"), | |
| 118 | - _( "Unable to complete print job" ), | |
| 119 | - err->message | |
| 120 | - ); | |
| 121 | - | |
| 122 | - g_error_free(err); | |
| 123 | - rc = -1; | |
| 124 | - | |
| 125 | - } | |
| 126 | - break; | |
| 127 | - | |
| 128 | - case GTK_PRINT_OPERATION_RESULT_APPLY: // The print settings should be stored. | |
| 129 | - trace("%s","GTK_PRINT_OPERATION_RESULT_APPLY"); | |
| 130 | - save_print_operation_settings(operation); | |
| 131 | - break; | |
| 132 | - | |
| 133 | - case GTK_PRINT_OPERATION_RESULT_CANCEL: // The print operation has been canceled, the print settings should not be stored. | |
| 134 | - trace("%s","GTK_PRINT_OPERATION_RESULT_CANCEL"); | |
| 135 | - g_message("Print operation was cancelled"); | |
| 136 | - break; | |
| 137 | - | |
| 138 | - case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: // The print operation is not complete yet. This value will only be returned when running asynchronously. | |
| 139 | - trace("%s","GTK_PRINT_OPERATION_RESULT_IN_PROGRESS"); | |
| 140 | - g_message("Print operation is in progress"); | |
| 141 | - break; | |
| 142 | - | |
| 143 | - default: | |
| 144 | - trace("%s","Unexpected"); | |
| 145 | - g_warning("Unexpected print operation result: %d",(int) result); | |
| 146 | - | |
| 147 | - } | |
| 148 | - } | |
| 149 | 159 | |
| 150 | 160 | g_object_unref(operation); |
| 151 | 161 | ... | ... |