From 461a55ee8b1e66f36fe725a62a18cfe30e982824 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Tue, 12 Mar 2013 11:23:23 +0000 Subject: [PATCH] Impressão na versão baseada em gtk2 estava cortando caracteres na margem esquerda --- src/pw3270/print.c | 23 +++++++++++++++++------ src/pw3270/window.c | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/pw3270/print.c b/src/pw3270/print.c index ae2387a..8f1bee0 100644 --- a/src/pw3270/print.c +++ b/src/pw3270/print.c @@ -94,7 +94,11 @@ #ifdef AUTO_FONT_SIZE { double width = gtk_print_context_get_width(context); - double cols = (double)info->cols; +#if GTK_CHECK_VERSION(3,0,0) + double cols = (double) info->cols; +#else + double cols = (double) (info->cols+5); +#endif // GTK(3,0,0) double current = width / cols; double valid = current; cairo_font_extents_t extents; @@ -105,12 +109,12 @@ current = valid +1.0; cairo_set_font_size(cr,current); cairo_font_extents(cr,&extents); - } while( (cols * extents.max_x_advance) < width ); + } + while( (cols * extents.max_x_advance) < width ); trace("Font size: %d",(int) valid); cairo_set_font_size(cr,valid); - } #endif // AUTO_FONT_SIZE @@ -344,8 +348,9 @@ static gchar * enum_to_string(GType type, guint enum_value) static void font_set(GtkFontButton *widget, PRINT_INFO *info) { + trace("%s font=%p",__FUNCTION__,info->font); if(info->font) - g_free(info->font) + g_free(info->font); info->font = g_strdup(gtk_font_button_get_font_name(widget)); } @@ -410,6 +415,11 @@ static gchar * enum_to_string(GType type, guint enum_value) g_free(info->font); info->font = get_string_from_config("print",FONT_CONFIG,DEFAULT_FONT); + if(!*info->font) + { + g_free(info->font); + info->font = g_strdup(DEFAULT_FONT); + } // Font selection button #ifdef AUTO_FONT_SIZE @@ -446,11 +456,12 @@ static gchar * enum_to_string(GType type, guint enum_value) } #else { + trace("Font=%s",info->font); widget = gtk_font_button_new_with_font(info->font); - gtk_font_button_set_show_size((GtkFontButton *) widget,FALSE); + gtk_font_button_set_show_size((GtkFontButton *) widget,TRUE); gtk_font_button_set_use_font((GtkFontButton *) widget,TRUE); gtk_label_set_mnemonic_widget(GTK_LABEL(label[0]),widget); - g_free(font); + g_free(info->font); #if GTK_CHECK_VERSION(3,2,0) gtk_font_chooser_set_filter_func((GtkFontChooser *) widget,filter_monospaced,NULL,NULL); diff --git a/src/pw3270/window.c b/src/pw3270/window.c index 66dfdcb..149d586 100644 --- a/src/pw3270/window.c +++ b/src/pw3270/window.c @@ -459,7 +459,7 @@ static void print_all(GtkWidget *widget, GtkWidget *window) { - pw3270_print(widget,G_OBJECT(widget), GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, PW3270_SRC_ALL); + pw3270_print(widget, NULL, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, PW3270_SRC_ALL); } static void toggle_changed(GtkWidget *widget, LIB3270_TOGGLE id, gboolean toggled, const gchar *name, GtkWindow *toplevel) -- libgit2 0.21.2