Commit 037efc3173c18869741e6f6c36d293266da2db81
1 parent
db107654
Exists in
master
and in
1 other branch
Fixing reference count on printer dialog.
Showing
3 changed files
with
48 additions
and
43 deletions
Show diff stats
src/dialogs/print/convenience.c
@@ -39,7 +39,7 @@ | @@ -39,7 +39,7 @@ | ||
39 | 39 | ||
40 | int v3270_print_dialog(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, GError **error) | 40 | int v3270_print_dialog(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, GError **error) |
41 | { | 41 | { |
42 | - int rc; | 42 | + int rc = 0; |
43 | 43 | ||
44 | if(!(widget && GTK_IS_V3270(widget))) | 44 | if(!(widget && GTK_IS_V3270(widget))) |
45 | return errno = EINVAL; | 45 | return errno = EINVAL; |
@@ -69,7 +69,17 @@ | @@ -69,7 +69,17 @@ | ||
69 | error | 69 | error |
70 | ); | 70 | ); |
71 | 71 | ||
72 | - rc = (*error == NULL ? 0 : -1); | 72 | + if(*error) |
73 | + { | ||
74 | + rc = (*error)->code ? (*error)->code : -1; | ||
75 | + g_warning("Print operation has failed with errror\"%s\" (rc=%d)",(*error)->message,rc); | ||
76 | + | ||
77 | + } | ||
78 | + else | ||
79 | + { | ||
80 | + rc = 0; | ||
81 | + } | ||
82 | + | ||
73 | 83 | ||
74 | } | 84 | } |
75 | else | 85 | else |
@@ -102,31 +112,27 @@ | @@ -102,31 +112,27 @@ | ||
102 | switch(result) | 112 | switch(result) |
103 | { | 113 | { |
104 | case GTK_PRINT_OPERATION_RESULT_ERROR: | 114 | case GTK_PRINT_OPERATION_RESULT_ERROR: |
105 | - debug("%s: Error on print operation",__FUNCTION__); | ||
106 | - lib3270_trace_event(v3270_get_session(widget),"%s\n",_("Error on print operation")); | ||
107 | - rc = -1; | 115 | + debug("%s: Error on print operation\n",__FUNCTION__); |
116 | + g_warning("Error on print operation"); | ||
117 | + if(!rc) | ||
118 | + rc = -1; | ||
108 | break; | 119 | break; |
109 | 120 | ||
110 | case GTK_PRINT_OPERATION_RESULT_APPLY: | 121 | case GTK_PRINT_OPERATION_RESULT_APPLY: |
111 | debug("%s: The print settings should be stored.",__FUNCTION__); | 122 | debug("%s: The print settings should be stored.",__FUNCTION__); |
112 | - lib3270_trace_event(v3270_get_session(widget),"%s\n",_("The print settings should be stored.")); | ||
113 | rc = 0; | 123 | rc = 0; |
114 | break; | 124 | break; |
115 | 125 | ||
116 | case GTK_PRINT_OPERATION_RESULT_CANCEL: | 126 | case GTK_PRINT_OPERATION_RESULT_CANCEL: |
117 | debug("%s: The print operation has been canceled, the print settings should not be stored.", __FUNCTION__); | 127 | debug("%s: The print operation has been canceled, the print settings should not be stored.", __FUNCTION__); |
118 | - lib3270_trace_event(v3270_get_session(widget),"%s\n",_("The print operation has been canceled, the print settings should not be stored.")); | ||
119 | - rc = 0; | ||
120 | break; | 128 | break; |
121 | 129 | ||
122 | case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: | 130 | case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: |
123 | debug("%s: The print operation is running",__FUNCTION__); | 131 | debug("%s: The print operation is running",__FUNCTION__); |
124 | - lib3270_trace_event(v3270_get_session(widget),"%s\n",_("The print operation is running")); | ||
125 | - rc = 0; | ||
126 | break; | 132 | break; |
127 | 133 | ||
128 | default: | 134 | default: |
129 | - g_message("Unexpected status %d in print operation",(int) result); | 135 | + g_warning("Unexpected status %d in print operation",(int) result); |
130 | 136 | ||
131 | } | 137 | } |
132 | 138 |
src/dialogs/print/print.c
@@ -89,7 +89,7 @@ | @@ -89,7 +89,7 @@ | ||
89 | 89 | ||
90 | default: | 90 | default: |
91 | debug("Unexpected status %d in print operation",(int) result); | 91 | debug("Unexpected status %d in print operation",(int) result); |
92 | - lib3270_trace_event(operation->widget->host,"%s\n",_("Unexpected status %d in print operation"),(int) result); | 92 | + lib3270_trace_event(operation->widget->host,_("Unexpected status %d in print operation"),(int) result); |
93 | 93 | ||
94 | } | 94 | } |
95 | 95 | ||
@@ -102,6 +102,12 @@ | @@ -102,6 +102,12 @@ | ||
102 | { | 102 | { |
103 | V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(object); | 103 | V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(object); |
104 | 104 | ||
105 | + if(operation->widget) | ||
106 | + { | ||
107 | + g_object_unref(G_OBJECT(operation->widget)); | ||
108 | + operation->widget = NULL; | ||
109 | + } | ||
110 | + | ||
105 | operation->contents.selection = NULL; | 111 | operation->contents.selection = NULL; |
106 | 112 | ||
107 | if(operation->font.info.scaled) | 113 | if(operation->font.info.scaled) |
@@ -218,40 +224,30 @@ | @@ -218,40 +224,30 @@ | ||
218 | return GTK_WIDGET(GTK_V3270_PRINT_OPERATION(operation)->widget); | 224 | return GTK_WIDGET(GTK_V3270_PRINT_OPERATION(operation)->widget); |
219 | } | 225 | } |
220 | 226 | ||
221 | -/* | ||
222 | -static GList * get_selection(GList *list, H3270 *hSession, int all) | ||
223 | -{ | ||
224 | - lib3270_selection * selection = lib3270_get_selection(hSession,0,all); | ||
225 | - | ||
226 | - if(selection) | ||
227 | - { | ||
228 | - size_t sz = sizeof(lib3270_selection) + (sizeof(lib3270_selection_element) * ((selection->bounds.width * selection->bounds.height)+1)); | ||
229 | - | ||
230 | - debug( | ||
231 | - "width=%u height=%u length=%u (sz=%u, szHeader=%u, szElement=%u)", | ||
232 | - selection->bounds.width, | ||
233 | - selection->bounds.height, | ||
234 | - (selection->bounds.width * selection->bounds.height), | ||
235 | - sz, | ||
236 | - sizeof(lib3270_selection), | ||
237 | - sizeof(lib3270_selection_element) | ||
238 | - ); | 227 | + void v3270_print_operation_set_terminal(GtkPrintOperation * operation, GtkWidget *widget) |
228 | + { | ||
229 | + g_return_if_fail(GTK_IS_V3270_PRINT_OPERATION(operation) && GTK_IS_V3270(widget)); | ||
239 | 230 | ||
240 | - gpointer data = g_malloc0(sz); | ||
241 | - memcpy(data,selection,sz); | 231 | + V3270PrintOperation * opr = GTK_V3270_PRINT_OPERATION(operation); |
242 | 232 | ||
243 | - lib3270_free(selection); | 233 | + if(opr->widget) |
234 | + { | ||
235 | + g_object_unref(G_OBJECT(opr->widget)); | ||
236 | + opr->widget = NULL; | ||
237 | + opr->session = NULL; | ||
238 | + } | ||
244 | 239 | ||
245 | - return g_list_append(list,data); | 240 | + if(widget && GTK_IS_V3270(widget)) |
241 | + { | ||
242 | + opr->widget = GTK_V3270(widget); | ||
243 | + opr->session = v3270_get_session(widget); | ||
244 | + g_object_ref(G_OBJECT(opr->widget)); | ||
246 | } | 245 | } |
247 | 246 | ||
248 | - g_warning("Error getting selection"); | ||
249 | - return NULL; | ||
250 | -} | ||
251 | -*/ | 247 | + } |
252 | 248 | ||
253 | -GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode) | ||
254 | -{ | 249 | + GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode) |
250 | + { | ||
255 | g_return_val_if_fail(GTK_IS_V3270(widget),NULL); | 251 | g_return_val_if_fail(GTK_IS_V3270(widget),NULL); |
256 | 252 | ||
257 | H3270 *hSession = v3270_get_session(widget); | 253 | H3270 *hSession = v3270_get_session(widget); |
@@ -266,9 +262,10 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT | @@ -266,9 +262,10 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT | ||
266 | V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(g_object_new(GTK_TYPE_V3270_PRINT_OPERATION, NULL)); | 262 | V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(g_object_new(GTK_TYPE_V3270_PRINT_OPERATION, NULL)); |
267 | 263 | ||
268 | operation->mode = mode; | 264 | operation->mode = mode; |
269 | - operation->widget = GTK_V3270(widget); | ||
270 | - operation->session = hSession; | 265 | + operation->widget = NULL; |
266 | + operation->session = NULL; | ||
271 | 267 | ||
268 | + v3270_print_operation_set_terminal(GTK_PRINT_OPERATION(operation),GTK_WIDGET(widget)); | ||
272 | v3270_set_mono_color_table(operation->settings.colors,"#000000","#FFFFFF"); | 269 | v3270_set_mono_color_table(operation->settings.colors,"#000000","#FFFFFF"); |
273 | 270 | ||
274 | // Get contents. | 271 | // Get contents. |
@@ -308,7 +305,7 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT | @@ -308,7 +305,7 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT | ||
308 | } | 305 | } |
309 | 306 | ||
310 | return GTK_PRINT_OPERATION(operation); | 307 | return GTK_PRINT_OPERATION(operation); |
311 | -} | 308 | + } |
312 | 309 | ||
313 | gboolean v3270_print_operation_set_font_family(GtkPrintOperation *operation, const gchar *fontname) | 310 | gboolean v3270_print_operation_set_font_family(GtkPrintOperation *operation, const gchar *fontname) |
314 | { | 311 | { |
src/include/v3270/print.h
@@ -64,8 +64,10 @@ | @@ -64,8 +64,10 @@ | ||
64 | 64 | ||
65 | LIB3270_EXPORT GType V3270PrintOperation_get_type(void); | 65 | LIB3270_EXPORT GType V3270PrintOperation_get_type(void); |
66 | LIB3270_EXPORT GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode); | 66 | LIB3270_EXPORT GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode); |
67 | + | ||
67 | LIB3270_EXPORT void v3270_print_operation_apply_settings(GtkPrintOperation *operation, GtkWidget *settings); | 68 | LIB3270_EXPORT void v3270_print_operation_apply_settings(GtkPrintOperation *operation, GtkWidget *settings); |
68 | 69 | ||
70 | + LIB3270_EXPORT void v3270_print_operation_set_terminal(GtkPrintOperation * operation, GtkWidget *terminal); | ||
69 | LIB3270_EXPORT GtkWidget * v3270_print_operation_get_terminal(GtkPrintOperation *operation); | 71 | LIB3270_EXPORT GtkWidget * v3270_print_operation_get_terminal(GtkPrintOperation *operation); |
70 | 72 | ||
71 | LIB3270_EXPORT gboolean v3270_print_operation_set_font_family(GtkPrintOperation *operation, const gchar *fontname); | 73 | LIB3270_EXPORT gboolean v3270_print_operation_set_font_family(GtkPrintOperation *operation, const gchar *fontname); |