Commit 8146018343c017ebca23210b98ac6a7d565c1937

Authored by Perry Werneck
1 parent 2eb92892
Exists in master and in 1 other branch develop

Fixing print dialog cleanup.

src/dialogs/print/convenience.c
@@ -40,14 +40,17 @@ @@ -40,14 +40,17 @@
40 int rc; 40 int rc;
41 41
42 if(!(widget && GTK_IS_V3270(widget))) 42 if(!(widget && GTK_IS_V3270(widget)))
43 - {  
44 return errno = EINVAL; 43 return errno = EINVAL;
45 - }  
46 44
47 lib3270_trace_event(v3270_get_session(widget),"print action activated (type=%d)",(int) mode); 45 lib3270_trace_event(v3270_get_session(widget),"print action activated (type=%d)",(int) mode);
48 46
  47 + if(!v3270_is_connected(widget))
  48 + return errno = ENOTCONN;
  49 +
49 // Print operation. 50 // Print operation.
50 GtkPrintOperation * operation = v3270_print_operation_new(widget, mode); 51 GtkPrintOperation * operation = v3270_print_operation_new(widget, mode);
  52 + if(!operation)
  53 + return errno = EPERM;
51 54
52 gtk_print_operation_set_show_progress(operation,TRUE); 55 gtk_print_operation_set_show_progress(operation,TRUE);
53 56
src/dialogs/print/print.c
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
42 { 42 {
43 V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(prt); 43 V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(prt);
44 44
45 - debug("%s",__FUNCTION__); 45 + debug("%s rc=%u",__FUNCTION__,(unsigned int) result);
46 46
47 if(result == GTK_PRINT_OPERATION_RESULT_ERROR) 47 if(result == GTK_PRINT_OPERATION_RESULT_ERROR)
48 { 48 {
@@ -62,7 +62,10 @@ @@ -62,7 +62,10 @@
62 } 62 }
63 63
64 if(operation->widget) 64 if(operation->widget)
  65 + {
  66 + debug("%s: Emiting signal PRINT_DONE",__FUNCTION__);
65 g_signal_emit(GTK_WIDGET(operation->widget), v3270_widget_signal[V3270_SIGNAL_PRINT_DONE], 0, prt, (guint) result); 67 g_signal_emit(GTK_WIDGET(operation->widget), v3270_widget_signal[V3270_SIGNAL_PRINT_DONE], 0, prt, (guint) result);
  68 + }
66 69
67 } 70 }
68 71
@@ -77,12 +80,18 @@ @@ -77,12 +80,18 @@
77 debug("%s.operation->font.info.scaled=%p",__FUNCTION__,operation->font.info.scaled); 80 debug("%s.operation->font.info.scaled=%p",__FUNCTION__,operation->font.info.scaled);
78 g_message("%s.operation->font.info.scaled=%p",__FUNCTION__,operation->font.info.scaled); 81 g_message("%s.operation->font.info.scaled=%p",__FUNCTION__,operation->font.info.scaled);
79 if(operation->font.info.scaled) 82 if(operation->font.info.scaled)
  83 + {
80 cairo_scaled_font_destroy(operation->font.info.scaled); 84 cairo_scaled_font_destroy(operation->font.info.scaled);
  85 + operation->font.info.scaled = NULL;
  86 + }
81 87
82 debug("%s.operation->font.name=%p",__FUNCTION__,operation->font.name); 88 debug("%s.operation->font.name=%p",__FUNCTION__,operation->font.name);
83 g_message("%s.operation->font.name=%p",__FUNCTION__,operation->font.name); 89 g_message("%s.operation->font.name=%p",__FUNCTION__,operation->font.name);
84 if(operation->font.name) 90 if(operation->font.name)
  91 + {
85 g_free(operation->font.name); 92 g_free(operation->font.name);
  93 + operation->font.name = NULL;
  94 + }
86 95
87 debug("%s.operation->contents.dynamic=%p",__FUNCTION__,operation->font.name); 96 debug("%s.operation->contents.dynamic=%p",__FUNCTION__,operation->font.name);
88 g_message("%s.operation->contents.dynamic=%p",__FUNCTION__,operation->font.name); 97 g_message("%s.operation->contents.dynamic=%p",__FUNCTION__,operation->font.name);
@@ -230,11 +239,20 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT @@ -230,11 +239,20 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT
230 { 239 {
231 g_return_val_if_fail(GTK_IS_V3270(widget),NULL); 240 g_return_val_if_fail(GTK_IS_V3270(widget),NULL);
232 241
  242 + H3270 *hSession = v3270_get_session(widget);
  243 +
  244 + if(!lib3270_is_connected(hSession))
  245 + {
  246 + errno = ENOTCONN;
  247 + g_warning("Can't print from offline session");
  248 + return NULL;
  249 + }
  250 +
233 V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(g_object_new(GTK_TYPE_V3270_PRINT_OPERATION, NULL)); 251 V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(g_object_new(GTK_TYPE_V3270_PRINT_OPERATION, NULL));
234 252
235 operation->mode = mode; 253 operation->mode = mode;
236 operation->widget = GTK_V3270(widget); 254 operation->widget = GTK_V3270(widget);
237 - operation->session = v3270_get_session(widget); 255 + operation->session = hSession;
238 256
239 v3270_set_mono_color_table(operation->settings.colors,"#000000","#FFFFFF"); 257 v3270_set_mono_color_table(operation->settings.colors,"#000000","#FFFFFF");
240 258