diff --git a/src/dialogs/print/convenience.c b/src/dialogs/print/convenience.c index d1337ee..32b1681 100644 --- a/src/dialogs/print/convenience.c +++ b/src/dialogs/print/convenience.c @@ -39,7 +39,7 @@ int v3270_print_dialog(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, GError **error) { - int rc; + int rc = 0; if(!(widget && GTK_IS_V3270(widget))) return errno = EINVAL; @@ -69,7 +69,17 @@ error ); - rc = (*error == NULL ? 0 : -1); + if(*error) + { + rc = (*error)->code ? (*error)->code : -1; + g_warning("Print operation has failed with errror\"%s\" (rc=%d)",(*error)->message,rc); + + } + else + { + rc = 0; + } + } else @@ -102,31 +112,27 @@ switch(result) { case GTK_PRINT_OPERATION_RESULT_ERROR: - debug("%s: Error on print operation",__FUNCTION__); - lib3270_trace_event(v3270_get_session(widget),"%s\n",_("Error on print operation")); - rc = -1; + debug("%s: Error on print operation\n",__FUNCTION__); + g_warning("Error on print operation"); + if(!rc) + rc = -1; break; case GTK_PRINT_OPERATION_RESULT_APPLY: debug("%s: The print settings should be stored.",__FUNCTION__); - lib3270_trace_event(v3270_get_session(widget),"%s\n",_("The print settings should be stored.")); rc = 0; break; case GTK_PRINT_OPERATION_RESULT_CANCEL: debug("%s: The print operation has been canceled, the print settings should not be stored.", __FUNCTION__); - lib3270_trace_event(v3270_get_session(widget),"%s\n",_("The print operation has been canceled, the print settings should not be stored.")); - rc = 0; break; case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: debug("%s: The print operation is running",__FUNCTION__); - lib3270_trace_event(v3270_get_session(widget),"%s\n",_("The print operation is running")); - rc = 0; break; default: - g_message("Unexpected status %d in print operation",(int) result); + g_warning("Unexpected status %d in print operation",(int) result); } diff --git a/src/dialogs/print/print.c b/src/dialogs/print/print.c index 03661b2..2e81b20 100644 --- a/src/dialogs/print/print.c +++ b/src/dialogs/print/print.c @@ -89,7 +89,7 @@ default: debug("Unexpected status %d in print operation",(int) result); - lib3270_trace_event(operation->widget->host,"%s\n",_("Unexpected status %d in print operation"),(int) result); + lib3270_trace_event(operation->widget->host,_("Unexpected status %d in print operation"),(int) result); } @@ -102,6 +102,12 @@ { V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(object); + if(operation->widget) + { + g_object_unref(G_OBJECT(operation->widget)); + operation->widget = NULL; + } + operation->contents.selection = NULL; if(operation->font.info.scaled) @@ -218,40 +224,30 @@ return GTK_WIDGET(GTK_V3270_PRINT_OPERATION(operation)->widget); } -/* -static GList * get_selection(GList *list, H3270 *hSession, int all) -{ - lib3270_selection * selection = lib3270_get_selection(hSession,0,all); - - if(selection) - { - size_t sz = sizeof(lib3270_selection) + (sizeof(lib3270_selection_element) * ((selection->bounds.width * selection->bounds.height)+1)); - - debug( - "width=%u height=%u length=%u (sz=%u, szHeader=%u, szElement=%u)", - selection->bounds.width, - selection->bounds.height, - (selection->bounds.width * selection->bounds.height), - sz, - sizeof(lib3270_selection), - sizeof(lib3270_selection_element) - ); + void v3270_print_operation_set_terminal(GtkPrintOperation * operation, GtkWidget *widget) + { + g_return_if_fail(GTK_IS_V3270_PRINT_OPERATION(operation) && GTK_IS_V3270(widget)); - gpointer data = g_malloc0(sz); - memcpy(data,selection,sz); + V3270PrintOperation * opr = GTK_V3270_PRINT_OPERATION(operation); - lib3270_free(selection); + if(opr->widget) + { + g_object_unref(G_OBJECT(opr->widget)); + opr->widget = NULL; + opr->session = NULL; + } - return g_list_append(list,data); + if(widget && GTK_IS_V3270(widget)) + { + opr->widget = GTK_V3270(widget); + opr->session = v3270_get_session(widget); + g_object_ref(G_OBJECT(opr->widget)); } - g_warning("Error getting selection"); - return NULL; -} -*/ + } -GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode) -{ + GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode) + { g_return_val_if_fail(GTK_IS_V3270(widget),NULL); H3270 *hSession = v3270_get_session(widget); @@ -266,9 +262,10 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(g_object_new(GTK_TYPE_V3270_PRINT_OPERATION, NULL)); operation->mode = mode; - operation->widget = GTK_V3270(widget); - operation->session = hSession; + operation->widget = NULL; + operation->session = NULL; + v3270_print_operation_set_terminal(GTK_PRINT_OPERATION(operation),GTK_WIDGET(widget)); v3270_set_mono_color_table(operation->settings.colors,"#000000","#FFFFFF"); // Get contents. @@ -308,7 +305,7 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT } return GTK_PRINT_OPERATION(operation); -} + } gboolean v3270_print_operation_set_font_family(GtkPrintOperation *operation, const gchar *fontname) { diff --git a/src/include/v3270/print.h b/src/include/v3270/print.h index 9a69e51..d893101 100644 --- a/src/include/v3270/print.h +++ b/src/include/v3270/print.h @@ -64,8 +64,10 @@ LIB3270_EXPORT GType V3270PrintOperation_get_type(void); LIB3270_EXPORT GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode); + LIB3270_EXPORT void v3270_print_operation_apply_settings(GtkPrintOperation *operation, GtkWidget *settings); + LIB3270_EXPORT void v3270_print_operation_set_terminal(GtkPrintOperation * operation, GtkWidget *terminal); LIB3270_EXPORT GtkWidget * v3270_print_operation_get_terminal(GtkPrintOperation *operation); LIB3270_EXPORT gboolean v3270_print_operation_set_font_family(GtkPrintOperation *operation, const gchar *fontname); -- libgit2 0.21.2