Commit 817d865ec0a10aee39cba5f475aeb015122e46a3

Authored by Perry Werneck
1 parent 5e7ea614
Exists in master and in 1 other branch develop

Addint "save" methods.

.gitignore
... ... @@ -52,3 +52,4 @@ doxygen/doxyfile
52 52 glade/v3270.xml
53 53 *test.glade*
54 54 ValgrindOut.xml
  55 +*.crl
... ...
Makefile.in
... ... @@ -38,7 +38,8 @@ SOURCES= \
38 38 $(wildcard src/trace/*.c) \
39 39 $(wildcard src/dialogs/*.c) \
40 40 $(wildcard src/dialogs/@OSNAME@/*.c) \
41   - $(wildcard src/dialogs/print/*.c)
  41 + $(wildcard src/dialogs/print/*.c) \
  42 + $(wildcard src/dialogs/save/*.c)
42 43  
43 44 TEST_SOURCES= \
44 45 $(wildcard src/testprogram/*.c)
... ...
src/dialogs/print/print.c
... ... @@ -210,7 +210,7 @@
210 210  
211 211  
212 212 // Setup defaults
213   - widget->mode = LIB3270_PRINT_ALL;
  213 + widget->mode = LIB3270_CONTENT_ALL;
214 214 widget->show_selection = FALSE;
215 215 widget->font.name = NULL; // g_strdup(v3270_default_font);
216 216 widget->contents.width = 80;
... ... @@ -219,7 +219,7 @@
219 219  
220 220 }
221 221  
222   -V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT_MODE mode)
  222 +V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode)
223 223 {
224 224 g_return_val_if_fail(GTK_IS_V3270(widget),NULL);
225 225  
... ... @@ -237,7 +237,7 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT
237 237  
238 238 /*--[ Convenience ]----------------------------------------------------------------------------------*/
239 239  
240   - int v3270_print(GtkWidget *widget, LIB3270_PRINT_MODE mode, GError **error)
  240 + int v3270_print(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, GError **error)
241 241 {
242 242 if(*error)
243 243 {
... ... @@ -262,26 +262,26 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT
262 262  
263 263 int v3270_print_all(GtkWidget *widget, GError **error)
264 264 {
265   - return v3270_print(widget,LIB3270_PRINT_ALL,error);
  265 + return v3270_print(widget,LIB3270_CONTENT_ALL,error);
266 266 }
267 267  
268 268 int v3270_print_selected(GtkWidget *widget, GError **error)
269 269 {
270   - return v3270_print(widget,LIB3270_PRINT_SELECTED,error);
  270 + return v3270_print(widget,LIB3270_CONTENT_SELECTED,error);
271 271 }
272 272  
273 273 int v3270_print_copy(GtkWidget *widget, GError **error)
274 274 {
275   - return v3270_print(widget,LIB3270_PRINT_COPY,error);
  275 + return v3270_print(widget,LIB3270_CONTENT_COPY,error);
276 276 }
277 277  
278   - void V3270PrintOperation_set_text_by_mode(V3270PrintOperation * operation, LIB3270_PRINT_MODE mode)
  278 + void V3270PrintOperation_set_text_by_mode(V3270PrintOperation * operation, LIB3270_CONTENT_OPTION mode)
279 279 {
280 280 operation->mode = mode;
281 281  
282 282 switch(mode)
283 283 {
284   - case LIB3270_PRINT_ALL:
  284 + case LIB3270_CONTENT_ALL:
285 285 {
286 286 size_t row, col;
287 287 int baddr = 0;
... ... @@ -304,7 +304,7 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT
304 304 }
305 305 break;
306 306  
307   - case LIB3270_PRINT_SELECTED:
  307 + case LIB3270_CONTENT_SELECTED:
308 308 {
309 309 unsigned int row, col;
310 310 unsigned int baddr = 0;
... ... @@ -361,7 +361,7 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT
361 361 }
362 362 break;
363 363  
364   - case LIB3270_PRINT_COPY:
  364 + case LIB3270_CONTENT_COPY:
365 365 {
366 366 lib3270_autoptr(char) copy = v3270_get_copy(GTK_WIDGET(operation->widget));
367 367 if(copy)
... ...
src/dialogs/print/private.h
... ... @@ -48,21 +48,21 @@
48 48  
49 49 struct _V3270PrintOperation
50 50 {
51   - GtkPrintOperation parent;
52   - GdkRGBA colors[V3270_COLOR_COUNT];
53   - LIB3270_PRINT_MODE mode;
54   - v3270 * widget;
55   - H3270 * session;
  51 + GtkPrintOperation parent;
  52 + GdkRGBA colors[V3270_COLOR_COUNT];
  53 + LIB3270_CONTENT_OPTION mode;
  54 + v3270 * widget;
  55 + H3270 * session;
56 56  
57   - size_t lpp; ///< @brief Lines per page (in rows).
58   - size_t pages; ///< @brief Number of pages.
59   - gboolean show_selection; ///< @brief Print selection box?
  57 + size_t lpp; ///< @brief Lines per page (in rows).
  58 + size_t pages; ///< @brief Number of pages.
  59 + gboolean show_selection; ///< @brief Print selection box?
60 60  
61 61 struct
62 62 {
63   - size_t width; ///< @brief Width of the contents (in columns);
64   - size_t height; ///< @brief Height of the contents (in rows);
65   - column **text; ///< @brief Report contents.
  63 + size_t width; ///< @brief Width of the contents (in columns);
  64 + size_t height; ///< @brief Height of the contents (in rows);
  65 + column **text; ///< @brief Report contents.
66 66 } contents;
67 67  
68 68 struct
... ...
src/dialogs/private.h
... ... @@ -37,3 +37,5 @@
37 37  
38 38 #include <gtk/gtk.h>
39 39 #include <v3270.h>
  40 +
  41 +
... ...
src/dialogs/save/convenience.c 0 → 100644
... ... @@ -0,0 +1,68 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como - e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include <config.h>
  31 + #include <errno.h>
  32 + #include <string.h>
  33 + #include "private.h"
  34 +
  35 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  36 +
  37 + LIB3270_EXPORT int v3270_save(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, const gchar *filename, GError **error)
  38 + {
  39 + if(*error)
  40 + {
  41 + return -1;
  42 + }
  43 +
  44 + if(!v3270_is_connected(widget))
  45 + {
  46 + *error = g_error_new(g_quark_from_static_string(PACKAGE_NAME),ENOTCONN,"%s",strerror(ENOTCONN));
  47 + return -1;
  48 + }
  49 +
  50 + lib3270_trace_event(v3270_get_session(widget),"save action activated (type=%d)",(int) mode);
  51 + return lib3270_save(v3270_get_session(widget),mode,filename);
  52 + }
  53 +
  54 + int v3270_save_all(GtkWidget *widget, const gchar *filename, GError **error)
  55 + {
  56 + return v3270_save(widget,LIB3270_CONTENT_ALL,filename,error);
  57 + }
  58 +
  59 + int v3270_save_selected(GtkWidget *widget, const gchar *filename, GError **error)
  60 + {
  61 + return v3270_save(widget,LIB3270_CONTENT_SELECTED,filename,error);
  62 + }
  63 +
  64 + int v3270_save_copy(GtkWidget *widget, const gchar *filename, GError **error)
  65 + {
  66 + return v3270_save(widget,LIB3270_CONTENT_COPY,filename,error);
  67 + }
  68 +
... ...
src/dialogs/save/private.h 0 → 100644
... ... @@ -0,0 +1,81 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como - e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include <v3270.h>
  31 + #include <v3270/print.h>
  32 + #include <lib3270/log.h>
  33 + #include <lib3270/trace.h>
  34 +
  35 +/*--[ Widget definition ]----------------------------------------------------------------------------*/
  36 +
  37 + struct _V3270PrintOperationClass
  38 + {
  39 + GtkPrintOperationClass parent_class;
  40 +
  41 + };
  42 +
  43 + typedef struct _column
  44 + {
  45 + unsigned char c;
  46 + unsigned short attr;
  47 + } column;
  48 +
  49 + struct _V3270PrintOperation
  50 + {
  51 + GtkPrintOperation parent;
  52 + GdkRGBA colors[V3270_COLOR_COUNT];
  53 + LIB3270_CONTENT_OPTION mode;
  54 + v3270 * widget;
  55 + H3270 * session;
  56 +
  57 + size_t lpp; ///< @brief Lines per page (in rows).
  58 + size_t pages; ///< @brief Number of pages.
  59 + gboolean show_selection; ///< @brief Print selection box?
  60 +
  61 + struct
  62 + {
  63 + size_t width; ///< @brief Width of the contents (in columns);
  64 + size_t height; ///< @brief Height of the contents (in rows);
  65 + column **text; ///< @brief Report contents.
  66 + } contents;
  67 +
  68 + struct
  69 + {
  70 + gchar * name;
  71 + v3270FontInfo info;
  72 + } font;
  73 +
  74 + };
  75 +
  76 +/*--[ Prototypes ]-----------------------------------------------------------------------------------*/
  77 +
  78 + G_GNUC_INTERNAL void V3270PrintOperation_begin_print(GtkPrintOperation *prt, GtkPrintContext *context);
  79 + G_GNUC_INTERNAL void V3270PrintOperation_draw_page(GtkPrintOperation *prt, GtkPrintContext *context, gint page);
  80 +
  81 +
... ...
src/dialogs/save/save.c 0 → 100644
... ... @@ -0,0 +1,35 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como - e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include "private.h"
  31 +
  32 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  33 +
  34 +
  35 +
... ...
src/include/v3270.h
... ... @@ -265,12 +265,18 @@
265 265 LIB3270_EXPORT void v3270_select_host(GtkWidget *widget);
266 266  
267 267 // Print
268   - LIB3270_EXPORT int v3270_print(GtkWidget *widget, LIB3270_PRINT_MODE mode, GError **error);
269   -
  268 + LIB3270_EXPORT int v3270_print(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, GError **error);
270 269 LIB3270_EXPORT int v3270_print_all(GtkWidget *widget, GError **error);
271 270 LIB3270_EXPORT int v3270_print_selected(GtkWidget *widget, GError **error);
272 271 LIB3270_EXPORT int v3270_print_copy(GtkWidget *widget, GError **error);
273 272  
  273 + // Save
  274 + LIB3270_EXPORT int v3270_save(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, const gchar *filename, GError **error);
  275 + LIB3270_EXPORT int v3270_save_all(GtkWidget *widget, const gchar *filename, GError **error);
  276 + LIB3270_EXPORT int v3270_save_selected(GtkWidget *widget, const gchar *filename, GError **error);
  277 + LIB3270_EXPORT int v3270_save_copy(GtkWidget *widget, const gchar *filename, GError **error);
  278 +
  279 + // Misc
274 280 LIB3270_EXPORT int v3270_exec_command(GtkWidget *widget, const gchar *cmdline);
275 281  
276 282 LIB3270_EXPORT GtkWidget * v3270_dialog_new(GtkWidget *widget, const gchar *title, const gchar *apply);
... ...
src/include/v3270/print.h
... ... @@ -51,8 +51,8 @@
51 51  
52 52 /*--[ Prototipes ]-----------------------------------------------------------------------------------*/
53 53  
54   - LIB3270_EXPORT V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT_MODE mode);
55   - LIB3270_EXPORT void V3270PrintOperation_set_text_by_mode(V3270PrintOperation * operation, LIB3270_PRINT_MODE mode);
  54 + LIB3270_EXPORT V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode);
  55 + LIB3270_EXPORT void V3270PrintOperation_set_text_by_mode(V3270PrintOperation * operation, LIB3270_CONTENT_OPTION mode);
56 56  
57 57 LIB3270_EXPORT GtkTreeModel * v3270_font_family_model_new(GtkWidget *widget, const gchar *selected, GtkTreeIter * active);
58 58 LIB3270_EXPORT GtkWidget * v3270_font_selection_new(const gchar *fontname);
... ...
src/terminal/callbacks.c
... ... @@ -326,7 +326,7 @@ static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const
326 326 }
327 327  
328 328  
329   -static int print(H3270 *session, LIB3270_PRINT_MODE mode)
  329 +static int print(H3270 *session, LIB3270_CONTENT_OPTION mode)
330 330 {
331 331 GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session));
332 332 GError * error = NULL;
... ...
src/testprogram/toolbar.c
... ... @@ -58,6 +58,11 @@
58 58 lib3270_disconnect(v3270_get_session(terminal));
59 59 }
60 60  
  61 +static void save_all_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal)
  62 + {
  63 + lib3270_save_all(v3270_get_session(terminal),NULL);
  64 + }
  65 +
61 66 static void ft_clicked(GtkButton *button, GtkWidget *terminal)
62 67 {
63 68 /*
... ... @@ -175,7 +180,8 @@
175 180 { "gtk-print", G_CALLBACK(print_clicked), "Print screen contents" },
176 181 { "gtk-harddisk", G_CALLBACK(ft_clicked), "Open file transfer dialog" },
177 182 { "gtk-copy", G_CALLBACK(copy_clicked), "Copy data" },
178   - { "gtk-paste", G_CALLBACK(paste_clicked), "Paste data" }
  183 + { "gtk-paste", G_CALLBACK(paste_clicked), "Paste data" },
  184 + { "gtk-save", G_CALLBACK(save_all_clicked), "Save screen" }
179 185 };
180 186  
181 187 GtkWidget * toolbar = gtk_toolbar_new();
... ...
v3270.cbp
... ... @@ -71,6 +71,13 @@
71 71 </Unit>
72 72 <Unit filename="src/dialogs/print/private.h" />
73 73 <Unit filename="src/dialogs/private.h" />
  74 + <Unit filename="src/dialogs/save/convenience.c">
  75 + <Option compilerVar="CC" />
  76 + </Unit>
  77 + <Unit filename="src/dialogs/save/private.h" />
  78 + <Unit filename="src/dialogs/save/save.c">
  79 + <Option compilerVar="CC" />
  80 + </Unit>
74 81 <Unit filename="src/dialogs/security.c">
75 82 <Option compilerVar="CC" />
76 83 </Unit>
... ...