From db1076542ff133001a60c85fede549dfc0a949aa Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Thu, 21 Nov 2019 16:59:38 -0300 Subject: [PATCH] Save screen action has the same bug of the print dialog, fixing it. --- src/dialogs/print/print.c | 7 ++++--- src/dialogs/save/save.c | 8 ++------ src/include/internals.h | 2 ++ src/selection/get.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/terminal/properties/get.c | 1 - v3270.cbp | 3 +++ 6 files changed, 77 insertions(+), 10 deletions(-) create mode 100644 src/selection/get.c diff --git a/src/dialogs/print/print.c b/src/dialogs/print/print.c index df42c89..03661b2 100644 --- a/src/dialogs/print/print.c +++ b/src/dialogs/print/print.c @@ -218,7 +218,7 @@ 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); @@ -248,6 +248,7 @@ static GList * get_selection(GList *list, H3270 *hSession, int all) g_warning("Error getting selection"); return NULL; } +*/ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode) { @@ -275,7 +276,7 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT { case LIB3270_CONTENT_ALL: debug("%s","LIB3270_CONTENT_ALL"); - operation->contents.dynamic = get_selection(operation->contents.dynamic, operation->session,1); + operation->contents.dynamic = g_list_append_lib3270_selection(operation->contents.dynamic, operation->session,TRUE); operation->contents.selection = operation->contents.dynamic; break; @@ -286,7 +287,7 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT case LIB3270_CONTENT_SELECTED: debug("%s","LIB3270_CONTENT_SELECTED"); - operation->contents.dynamic = get_selection(operation->contents.dynamic, operation->session,0); + operation->contents.dynamic = g_list_append_lib3270_selection(operation->contents.dynamic, operation->session,FALSE); operation->contents.selection = operation->contents.dynamic; break; } diff --git a/src/dialogs/save/save.c b/src/dialogs/save/save.c index e1d3402..d916769 100644 --- a/src/dialogs/save/save.c +++ b/src/dialogs/save/save.c @@ -346,9 +346,7 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_ { case LIB3270_CONTENT_ALL: debug("%s","LIB3270_CONTENT_ALL"); - dynamic = g_new0(GList,1); - dynamic->data = (gpointer) lib3270_get_selection(v3270_get_session(dialog->terminal),0,1); - selection = dynamic; + selection = dynamic = g_list_append_lib3270_selection(dynamic, v3270_get_session(dialog->terminal),TRUE); break; case LIB3270_CONTENT_COPY: @@ -358,9 +356,7 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_ case LIB3270_CONTENT_SELECTED: debug("%s","LIB3270_CONTENT_SELECTED"); - dynamic = g_new0(GList,1); - dynamic->data = (gpointer) lib3270_get_selection(v3270_get_session(dialog->terminal),0,0); - selection = dynamic; + selection = dynamic = g_list_append_lib3270_selection(dynamic, v3270_get_session(dialog->terminal),FALSE); break; default: diff --git a/src/include/internals.h b/src/include/internals.h index 429995c..c58a427 100644 --- a/src/include/internals.h +++ b/src/include/internals.h @@ -139,6 +139,8 @@ G_GNUC_INTERNAL gchar * v3270_convert_to_3270_charset(GtkWidget *widget, const gchar *text, const gchar *encoding, GError **error); + /// @brief Add current lib3270 selection to a list + G_GNUC_INTERNAL GList * g_list_append_lib3270_selection(GList *list, H3270 *hSession, gboolean all); /*--[ Internal Widgets & Tools ]---------------------------------------------------------------------*/ diff --git a/src/selection/get.c b/src/selection/get.c new file mode 100644 index 0000000..dad00e3 --- /dev/null +++ b/src/selection/get.c @@ -0,0 +1,66 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como - e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + #include + #include + #include + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + + GList * g_list_append_lib3270_selection(GList *list, H3270 *hSession, gboolean 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) + ); + + gpointer data = g_malloc0(sz); + memcpy(data,selection,sz); + + lib3270_free(selection); + + return g_list_append(list,data); + } + + g_warning("Can't get TN3270 active selection"); + + return NULL; + + } diff --git a/src/terminal/properties/get.c b/src/terminal/properties/get.c index e8d2057..d33e65d 100644 --- a/src/terminal/properties/get.c +++ b/src/terminal/properties/get.c @@ -28,7 +28,6 @@ */ #include "private.h" - #include /*--[ Implement ]------------------------------------------------------------------------------------*/ diff --git a/v3270.cbp b/v3270.cbp index 147af83..fe9be99 100644 --- a/v3270.cbp +++ b/v3270.cbp @@ -188,6 +188,9 @@ + + -- libgit2 0.21.2