diff --git a/src/dialogs/save/save.c b/src/dialogs/save/save.c index 679bf1e..5ad3e8f 100644 --- a/src/dialogs/save/save.c +++ b/src/dialogs/save/save.c @@ -446,7 +446,46 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_ { debug("%s",__FUNCTION__); - GdkPixbuf * pixbuf = v3270_get_as_pixbuf(dialog->terminal); + GdkPixbuf * pixbuf = NULL; + + switch(dialog->mode) + { + case LIB3270_CONTENT_ALL: + debug("%s","LIB3270_CONTENT_ALL"); +#ifdef DEBUG + { + debug("%s","LIB3270_CONTENT_SELECTED"); + GList * selection = g_list_append_lib3270_selection(NULL, v3270_get_session(dialog->terminal),TRUE); + pixbuf = v3270_get_selection_as_pixbuf(GTK_V3270(dialog->terminal), selection, TRUE); + g_list_free_full(selection,(GDestroyNotify) lib3270_free); + } +#else + pixbuf = v3270_get_as_pixbuf(dialog->terminal); +#endif // DEBUG + + break; + + case LIB3270_CONTENT_COPY: + { + debug("%s","LIB3270_CONTENT_COPY"); + const GList * selection = v3270_get_selection_blocks(dialog->terminal); + pixbuf = v3270_get_selection_as_pixbuf(GTK_V3270(dialog->terminal), selection, FALSE); + } + break; + + case LIB3270_CONTENT_SELECTED: + { + debug("%s","LIB3270_CONTENT_SELECTED"); + GList * selection = g_list_append_lib3270_selection(NULL, v3270_get_session(dialog->terminal),FALSE); + pixbuf = v3270_get_selection_as_pixbuf(GTK_V3270(dialog->terminal), selection, FALSE); + g_list_free_full(selection,(GDestroyNotify) lib3270_free); + } + break; + + default: + *error = g_error_new(g_quark_from_static_string(PACKAGE_NAME),ENOTCONN,_( "Unexpected mode %d" ),(int) dialog->mode); + return; + } if(pixbuf) { diff --git a/src/include/clipboard.h b/src/include/clipboard.h index 55e54c0..e742e29 100644 --- a/src/include/clipboard.h +++ b/src/include/clipboard.h @@ -91,6 +91,7 @@ /// @brief Get contents. G_GNUC_INTERNAL gchar * v3270_get_selection_as_text(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all); + G_GNUC_INTERNAL GdkPixbuf * v3270_get_selection_as_pixbuf(v3270 * terminal, const GList *selection, gboolean all); G_GNUC_INTERNAL gchar * v3270_get_selection_as_table(v3270 * terminal, const GList *selection, const gchar *delimiter, const gchar *encoding, gboolean all); G_GNUC_INTERNAL gchar * v3270_get_selection_as_html_div(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all, const V3270SelectionOption options); G_GNUC_INTERNAL gchar * v3270_get_selection_as_html_table(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all, const V3270SelectionOption options); diff --git a/src/selection/pixbuf.c b/src/selection/pixbuf.c new file mode 100644 index 0000000..051be35 --- /dev/null +++ b/src/selection/pixbuf.c @@ -0,0 +1,141 @@ +/* + * "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 ]------------------------------------------------------------------------------------*/ + +GdkPixbuf * v3270_get_selection_as_pixbuf(v3270 * terminal, const GList *selections, gboolean all) +{ + const GList *selection; + + // Get image size + size_t rows = 0, cols = 0; + + for(selection = selections; selection; selection = g_list_next(selection)) + { + lib3270_selection * block = ((lib3270_selection *) selection->data); + unsigned int row, col, src = 0; + + for(row=0; row < block->bounds.height; row++) + { + size_t hasSelection = FALSE; + + for(col=0; colbounds.width; col++) + { + if( (block->contents[src].attribute.visual & LIB3270_ATTR_SELECTED) || all ) + { + hasSelection = TRUE; + if(col > cols) + cols = col; + } + } + + if(hasSelection) + { + rows++; + } + + } + + } + + if(!rows) + return NULL; + + debug("Selection rows=%u cols=%u",(unsigned int) rows, (unsigned int) cols); + + gint width = (cols+1) * terminal->font.width; + gint height = (rows+1) * terminal->font.spacing.value; + + cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); + + cairo_t *cr = cairo_create(surface); + gdk_cairo_set_source_rgba(cr,terminal->color+V3270_COLOR_BACKGROUND); + cairo_rectangle(cr, 0, 0, width, height); + cairo_fill(cr); + cairo_stroke(cr); + + // Draw contents + GdkRectangle rect; + memset(&rect,0,sizeof(rect)); + rect.width = terminal->font.width; + rect.height = terminal->font.spacing.value; + + cairo_set_scaled_font(cr,terminal->font.scaled); + + for(selection = selections; selection; selection = g_list_next(selection)) + { + lib3270_selection * block = ((lib3270_selection *) selection->data); + unsigned int row, col, src = 0; + + for(row=0; row < block->bounds.height; row++) + { + size_t hasSelection = FALSE; + rect.x = 0; + + for(col=0; colbounds.width; col++) + { + if( (block->contents[src].attribute.visual & LIB3270_ATTR_SELECTED) || all ) + { + hasSelection = TRUE; + + v3270_draw_element( + cr, + block->contents[src].chr, + block->contents[src].attribute.visual, + terminal->host, + &terminal->font, + &rect, + terminal->color + ); + + } + rect.x += rect.width; + } + + if(hasSelection) + { + rect.y += terminal->font.spacing.value; + } + + } + } + + cairo_destroy (cr); + + GdkPixbuf * pixbuf = gdk_pixbuf_get_from_surface(surface,0,0,width,height); + + cairo_surface_destroy (surface); + + return pixbuf; + +} diff --git a/v3270.cbp b/v3270.cbp index 094166a..74b5af2 100644 --- a/v3270.cbp +++ b/v3270.cbp @@ -219,6 +219,9 @@ + + -- libgit2 0.21.2