Commit 461a55ee8b1e66f36fe725a62a18cfe30e982824

Authored by perry.werneck@gmail.com
1 parent dee1ba19

Impressão na versão baseada em gtk2 estava cortando caracteres na margem esquerda

Showing 2 changed files with 18 additions and 7 deletions   Show diff stats
src/pw3270/print.c
@@ -94,7 +94,11 @@ @@ -94,7 +94,11 @@
94 #ifdef AUTO_FONT_SIZE 94 #ifdef AUTO_FONT_SIZE
95 { 95 {
96 double width = gtk_print_context_get_width(context); 96 double width = gtk_print_context_get_width(context);
97 - double cols = (double)info->cols; 97 +#if GTK_CHECK_VERSION(3,0,0)
  98 + double cols = (double) info->cols;
  99 +#else
  100 + double cols = (double) (info->cols+5);
  101 +#endif // GTK(3,0,0)
98 double current = width / cols; 102 double current = width / cols;
99 double valid = current; 103 double valid = current;
100 cairo_font_extents_t extents; 104 cairo_font_extents_t extents;
@@ -105,12 +109,12 @@ @@ -105,12 +109,12 @@
105 current = valid +1.0; 109 current = valid +1.0;
106 cairo_set_font_size(cr,current); 110 cairo_set_font_size(cr,current);
107 cairo_font_extents(cr,&extents); 111 cairo_font_extents(cr,&extents);
108 - } while( (cols * extents.max_x_advance) < width ); 112 + }
  113 + while( (cols * extents.max_x_advance) < width );
109 114
110 trace("Font size: %d",(int) valid); 115 trace("Font size: %d",(int) valid);
111 cairo_set_font_size(cr,valid); 116 cairo_set_font_size(cr,valid);
112 117
113 -  
114 } 118 }
115 #endif // AUTO_FONT_SIZE 119 #endif // AUTO_FONT_SIZE
116 120
@@ -344,8 +348,9 @@ static gchar * enum_to_string(GType type, guint enum_value) @@ -344,8 +348,9 @@ static gchar * enum_to_string(GType type, guint enum_value)
344 348
345 static void font_set(GtkFontButton *widget, PRINT_INFO *info) 349 static void font_set(GtkFontButton *widget, PRINT_INFO *info)
346 { 350 {
  351 + trace("%s font=%p",__FUNCTION__,info->font);
347 if(info->font) 352 if(info->font)
348 - g_free(info->font) 353 + g_free(info->font);
349 info->font = g_strdup(gtk_font_button_get_font_name(widget)); 354 info->font = g_strdup(gtk_font_button_get_font_name(widget));
350 } 355 }
351 356
@@ -410,6 +415,11 @@ static gchar * enum_to_string(GType type, guint enum_value) @@ -410,6 +415,11 @@ static gchar * enum_to_string(GType type, guint enum_value)
410 g_free(info->font); 415 g_free(info->font);
411 416
412 info->font = get_string_from_config("print",FONT_CONFIG,DEFAULT_FONT); 417 info->font = get_string_from_config("print",FONT_CONFIG,DEFAULT_FONT);
  418 + if(!*info->font)
  419 + {
  420 + g_free(info->font);
  421 + info->font = g_strdup(DEFAULT_FONT);
  422 + }
413 423
414 // Font selection button 424 // Font selection button
415 #ifdef AUTO_FONT_SIZE 425 #ifdef AUTO_FONT_SIZE
@@ -446,11 +456,12 @@ static gchar * enum_to_string(GType type, guint enum_value) @@ -446,11 +456,12 @@ static gchar * enum_to_string(GType type, guint enum_value)
446 } 456 }
447 #else 457 #else
448 { 458 {
  459 + trace("Font=%s",info->font);
449 widget = gtk_font_button_new_with_font(info->font); 460 widget = gtk_font_button_new_with_font(info->font);
450 - gtk_font_button_set_show_size((GtkFontButton *) widget,FALSE); 461 + gtk_font_button_set_show_size((GtkFontButton *) widget,TRUE);
451 gtk_font_button_set_use_font((GtkFontButton *) widget,TRUE); 462 gtk_font_button_set_use_font((GtkFontButton *) widget,TRUE);
452 gtk_label_set_mnemonic_widget(GTK_LABEL(label[0]),widget); 463 gtk_label_set_mnemonic_widget(GTK_LABEL(label[0]),widget);
453 - g_free(font); 464 + g_free(info->font);
454 465
455 #if GTK_CHECK_VERSION(3,2,0) 466 #if GTK_CHECK_VERSION(3,2,0)
456 gtk_font_chooser_set_filter_func((GtkFontChooser *) widget,filter_monospaced,NULL,NULL); 467 gtk_font_chooser_set_filter_func((GtkFontChooser *) widget,filter_monospaced,NULL,NULL);
src/pw3270/window.c
@@ -459,7 +459,7 @@ @@ -459,7 +459,7 @@
459 459
460 static void print_all(GtkWidget *widget, GtkWidget *window) 460 static void print_all(GtkWidget *widget, GtkWidget *window)
461 { 461 {
462 - pw3270_print(widget,G_OBJECT(widget), GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, PW3270_SRC_ALL); 462 + pw3270_print(widget, NULL, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, PW3270_SRC_ALL);
463 } 463 }
464 464
465 static void toggle_changed(GtkWidget *widget, LIB3270_TOGGLE id, gboolean toggled, const gchar *name, GtkWindow *toplevel) 465 static void toggle_changed(GtkWidget *widget, LIB3270_TOGGLE id, gboolean toggled, const gchar *name, GtkWindow *toplevel)