diff --git a/.gitignore b/.gitignore index 4716d11..43cab1b 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ doxygen/doxyfile glade/v3270.xml *test.glade* ValgrindOut.xml +*.crl diff --git a/Makefile.in b/Makefile.in index 67c6a2d..873f08c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -38,7 +38,8 @@ SOURCES= \ $(wildcard src/trace/*.c) \ $(wildcard src/dialogs/*.c) \ $(wildcard src/dialogs/@OSNAME@/*.c) \ - $(wildcard src/dialogs/print/*.c) + $(wildcard src/dialogs/print/*.c) \ + $(wildcard src/dialogs/save/*.c) TEST_SOURCES= \ $(wildcard src/testprogram/*.c) diff --git a/src/dialogs/print/print.c b/src/dialogs/print/print.c index c72614b..3bc1218 100644 --- a/src/dialogs/print/print.c +++ b/src/dialogs/print/print.c @@ -210,7 +210,7 @@ // Setup defaults - widget->mode = LIB3270_PRINT_ALL; + widget->mode = LIB3270_CONTENT_ALL; widget->show_selection = FALSE; widget->font.name = NULL; // g_strdup(v3270_default_font); widget->contents.width = 80; @@ -219,7 +219,7 @@ } -V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT_MODE mode) +V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode) { g_return_val_if_fail(GTK_IS_V3270(widget),NULL); @@ -237,7 +237,7 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT /*--[ Convenience ]----------------------------------------------------------------------------------*/ - int v3270_print(GtkWidget *widget, LIB3270_PRINT_MODE mode, GError **error) + int v3270_print(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, GError **error) { if(*error) { @@ -262,26 +262,26 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT int v3270_print_all(GtkWidget *widget, GError **error) { - return v3270_print(widget,LIB3270_PRINT_ALL,error); + return v3270_print(widget,LIB3270_CONTENT_ALL,error); } int v3270_print_selected(GtkWidget *widget, GError **error) { - return v3270_print(widget,LIB3270_PRINT_SELECTED,error); + return v3270_print(widget,LIB3270_CONTENT_SELECTED,error); } int v3270_print_copy(GtkWidget *widget, GError **error) { - return v3270_print(widget,LIB3270_PRINT_COPY,error); + return v3270_print(widget,LIB3270_CONTENT_COPY,error); } - void V3270PrintOperation_set_text_by_mode(V3270PrintOperation * operation, LIB3270_PRINT_MODE mode) + void V3270PrintOperation_set_text_by_mode(V3270PrintOperation * operation, LIB3270_CONTENT_OPTION mode) { operation->mode = mode; switch(mode) { - case LIB3270_PRINT_ALL: + case LIB3270_CONTENT_ALL: { size_t row, col; int baddr = 0; @@ -304,7 +304,7 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT } break; - case LIB3270_PRINT_SELECTED: + case LIB3270_CONTENT_SELECTED: { unsigned int row, col; unsigned int baddr = 0; @@ -361,7 +361,7 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT } break; - case LIB3270_PRINT_COPY: + case LIB3270_CONTENT_COPY: { lib3270_autoptr(char) copy = v3270_get_copy(GTK_WIDGET(operation->widget)); if(copy) diff --git a/src/dialogs/print/private.h b/src/dialogs/print/private.h index 8c82ab6..052bdd0 100644 --- a/src/dialogs/print/private.h +++ b/src/dialogs/print/private.h @@ -48,21 +48,21 @@ struct _V3270PrintOperation { - GtkPrintOperation parent; - GdkRGBA colors[V3270_COLOR_COUNT]; - LIB3270_PRINT_MODE mode; - v3270 * widget; - H3270 * session; + GtkPrintOperation parent; + GdkRGBA colors[V3270_COLOR_COUNT]; + LIB3270_CONTENT_OPTION mode; + v3270 * widget; + H3270 * session; - size_t lpp; ///< @brief Lines per page (in rows). - size_t pages; ///< @brief Number of pages. - gboolean show_selection; ///< @brief Print selection box? + size_t lpp; ///< @brief Lines per page (in rows). + size_t pages; ///< @brief Number of pages. + gboolean show_selection; ///< @brief Print selection box? struct { - size_t width; ///< @brief Width of the contents (in columns); - size_t height; ///< @brief Height of the contents (in rows); - column **text; ///< @brief Report contents. + size_t width; ///< @brief Width of the contents (in columns); + size_t height; ///< @brief Height of the contents (in rows); + column **text; ///< @brief Report contents. } contents; struct diff --git a/src/dialogs/private.h b/src/dialogs/private.h index e5bb9da..9a9fd2a 100644 --- a/src/dialogs/private.h +++ b/src/dialogs/private.h @@ -37,3 +37,5 @@ #include #include + + diff --git a/src/dialogs/save/convenience.c b/src/dialogs/save/convenience.c new file mode 100644 index 0000000..2c73997 --- /dev/null +++ b/src/dialogs/save/convenience.c @@ -0,0 +1,68 @@ +/* + * "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 + #include "private.h" + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + + LIB3270_EXPORT int v3270_save(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, const gchar *filename, GError **error) + { + if(*error) + { + return -1; + } + + if(!v3270_is_connected(widget)) + { + *error = g_error_new(g_quark_from_static_string(PACKAGE_NAME),ENOTCONN,"%s",strerror(ENOTCONN)); + return -1; + } + + lib3270_trace_event(v3270_get_session(widget),"save action activated (type=%d)",(int) mode); + return lib3270_save(v3270_get_session(widget),mode,filename); + } + + int v3270_save_all(GtkWidget *widget, const gchar *filename, GError **error) + { + return v3270_save(widget,LIB3270_CONTENT_ALL,filename,error); + } + + int v3270_save_selected(GtkWidget *widget, const gchar *filename, GError **error) + { + return v3270_save(widget,LIB3270_CONTENT_SELECTED,filename,error); + } + + int v3270_save_copy(GtkWidget *widget, const gchar *filename, GError **error) + { + return v3270_save(widget,LIB3270_CONTENT_COPY,filename,error); + } + diff --git a/src/dialogs/save/private.h b/src/dialogs/save/private.h new file mode 100644 index 0000000..052bdd0 --- /dev/null +++ b/src/dialogs/save/private.h @@ -0,0 +1,81 @@ +/* + * "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 + #include + +/*--[ Widget definition ]----------------------------------------------------------------------------*/ + + struct _V3270PrintOperationClass + { + GtkPrintOperationClass parent_class; + + }; + + typedef struct _column + { + unsigned char c; + unsigned short attr; + } column; + + struct _V3270PrintOperation + { + GtkPrintOperation parent; + GdkRGBA colors[V3270_COLOR_COUNT]; + LIB3270_CONTENT_OPTION mode; + v3270 * widget; + H3270 * session; + + size_t lpp; ///< @brief Lines per page (in rows). + size_t pages; ///< @brief Number of pages. + gboolean show_selection; ///< @brief Print selection box? + + struct + { + size_t width; ///< @brief Width of the contents (in columns); + size_t height; ///< @brief Height of the contents (in rows); + column **text; ///< @brief Report contents. + } contents; + + struct + { + gchar * name; + v3270FontInfo info; + } font; + + }; + +/*--[ Prototypes ]-----------------------------------------------------------------------------------*/ + + G_GNUC_INTERNAL void V3270PrintOperation_begin_print(GtkPrintOperation *prt, GtkPrintContext *context); + G_GNUC_INTERNAL void V3270PrintOperation_draw_page(GtkPrintOperation *prt, GtkPrintContext *context, gint page); + + diff --git a/src/dialogs/save/save.c b/src/dialogs/save/save.c new file mode 100644 index 0000000..102773c --- /dev/null +++ b/src/dialogs/save/save.c @@ -0,0 +1,35 @@ +/* + * "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 "private.h" + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + + + diff --git a/src/include/v3270.h b/src/include/v3270.h index bcdab08..2d07d8d 100644 --- a/src/include/v3270.h +++ b/src/include/v3270.h @@ -265,12 +265,18 @@ LIB3270_EXPORT void v3270_select_host(GtkWidget *widget); // Print - LIB3270_EXPORT int v3270_print(GtkWidget *widget, LIB3270_PRINT_MODE mode, GError **error); - + LIB3270_EXPORT int v3270_print(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, GError **error); LIB3270_EXPORT int v3270_print_all(GtkWidget *widget, GError **error); LIB3270_EXPORT int v3270_print_selected(GtkWidget *widget, GError **error); LIB3270_EXPORT int v3270_print_copy(GtkWidget *widget, GError **error); + // Save + LIB3270_EXPORT int v3270_save(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, const gchar *filename, GError **error); + LIB3270_EXPORT int v3270_save_all(GtkWidget *widget, const gchar *filename, GError **error); + LIB3270_EXPORT int v3270_save_selected(GtkWidget *widget, const gchar *filename, GError **error); + LIB3270_EXPORT int v3270_save_copy(GtkWidget *widget, const gchar *filename, GError **error); + + // Misc LIB3270_EXPORT int v3270_exec_command(GtkWidget *widget, const gchar *cmdline); LIB3270_EXPORT GtkWidget * v3270_dialog_new(GtkWidget *widget, const gchar *title, const gchar *apply); diff --git a/src/include/v3270/print.h b/src/include/v3270/print.h index 0070e3c..f068ff4 100644 --- a/src/include/v3270/print.h +++ b/src/include/v3270/print.h @@ -51,8 +51,8 @@ /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ - LIB3270_EXPORT V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT_MODE mode); - LIB3270_EXPORT void V3270PrintOperation_set_text_by_mode(V3270PrintOperation * operation, LIB3270_PRINT_MODE mode); + LIB3270_EXPORT V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode); + LIB3270_EXPORT void V3270PrintOperation_set_text_by_mode(V3270PrintOperation * operation, LIB3270_CONTENT_OPTION mode); LIB3270_EXPORT GtkTreeModel * v3270_font_family_model_new(GtkWidget *widget, const gchar *selected, GtkTreeIter * active); LIB3270_EXPORT GtkWidget * v3270_font_selection_new(const gchar *fontname); diff --git a/src/terminal/callbacks.c b/src/terminal/callbacks.c index 7e579f2..3984514 100644 --- a/src/terminal/callbacks.c +++ b/src/terminal/callbacks.c @@ -326,7 +326,7 @@ static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const } -static int print(H3270 *session, LIB3270_PRINT_MODE mode) +static int print(H3270 *session, LIB3270_CONTENT_OPTION mode) { GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session)); GError * error = NULL; diff --git a/src/testprogram/toolbar.c b/src/testprogram/toolbar.c index 2e56cf5..235fa66 100644 --- a/src/testprogram/toolbar.c +++ b/src/testprogram/toolbar.c @@ -58,6 +58,11 @@ lib3270_disconnect(v3270_get_session(terminal)); } +static void save_all_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) + { + lib3270_save_all(v3270_get_session(terminal),NULL); + } + static void ft_clicked(GtkButton *button, GtkWidget *terminal) { /* @@ -175,7 +180,8 @@ { "gtk-print", G_CALLBACK(print_clicked), "Print screen contents" }, { "gtk-harddisk", G_CALLBACK(ft_clicked), "Open file transfer dialog" }, { "gtk-copy", G_CALLBACK(copy_clicked), "Copy data" }, - { "gtk-paste", G_CALLBACK(paste_clicked), "Paste data" } + { "gtk-paste", G_CALLBACK(paste_clicked), "Paste data" }, + { "gtk-save", G_CALLBACK(save_all_clicked), "Save screen" } }; GtkWidget * toolbar = gtk_toolbar_new(); diff --git a/v3270.cbp b/v3270.cbp index ecc6023..be9b89d 100644 --- a/v3270.cbp +++ b/v3270.cbp @@ -71,6 +71,13 @@ + + + + + -- libgit2 0.21.2