Commit 6d5ebe31d5025ee40aec7136e087a4c29db35804

Authored by perry.werneck@gmail.com
1 parent 5ac56691

Corrigindo dialogo de impressão em gtk3

@@ -46,6 +46,9 @@ @@ -46,6 +46,9 @@
46 <Unit filename="src/gtk/actions.c"> 46 <Unit filename="src/gtk/actions.c">
47 <Option compilerVar="CC" /> 47 <Option compilerVar="CC" />
48 </Unit> 48 </Unit>
  49 + <Unit filename="src/gtk/colors.c">
  50 + <Option compilerVar="CC" />
  51 + </Unit>
49 <Unit filename="src/gtk/common/common.h" /> 52 <Unit filename="src/gtk/common/common.h" />
50 <Unit filename="src/gtk/common/config.c"> 53 <Unit filename="src/gtk/common/config.c">
51 <Option compilerVar="CC" /> 54 <Option compilerVar="CC" />
src/gtk/colors.c
@@ -44,9 +44,9 @@ @@ -44,9 +44,9 @@
44 else 44 else
45 { 45 {
46 gchar ** group; 46 gchar ** group;
47 - GKeyFile * conf = g_key_file_new();  
48 - int f;  
49 - gboolean found = FALSE; 47 + GKeyFile * conf = g_key_file_new();
  48 + int f = 0;
  49 + gboolean found = FALSE;
50 50
51 #if !GTK_CHECK_VERSION(3,0,0) 51 #if !GTK_CHECK_VERSION(3,0,0)
52 GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_STRING); 52 GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_STRING);
@@ -76,10 +76,16 @@ @@ -76,10 +76,16 @@
76 #if GTK_CHECK_VERSION(3,0,0) 76 #if GTK_CHECK_VERSION(3,0,0)
77 77
78 gtk_combo_box_text_insert( GTK_COMBO_BOX_TEXT(widget), 78 gtk_combo_box_text_insert( GTK_COMBO_BOX_TEXT(widget),
79 - 0, 79 + f,
80 str, 80 str,
81 g_key_file_get_locale_string(conf,group[f],"Label",NULL,NULL)); 81 g_key_file_get_locale_string(conf,group[f],"Label",NULL,NULL));
82 82
  83 +
  84 + if(active && !g_strcasecmp(active,str))
  85 + {
  86 + found = TRUE;
  87 + gtk_combo_box_set_active(GTK_COMBO_BOX(widget),f);
  88 + }
83 #else 89 #else
84 90
85 gtk_list_store_append((GtkListStore *) model,&iter); 91 gtk_list_store_append((GtkListStore *) model,&iter);
@@ -110,6 +116,7 @@ @@ -110,6 +116,7 @@
110 0, 116 0,
111 active, 117 active,
112 _( "Custom colors") ); 118 _( "Custom colors") );
  119 + gtk_combo_box_set_active(GTK_COMBO_BOX(widget),0);
113 120
114 #else 121 #else
115 122
src/gtk/print.c
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple 18 * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
19 * Place, Suite 330, Boston, MA, 02111-1307, USA 19 * Place, Suite 330, Boston, MA, 02111-1307, USA
20 * 20 *
21 - * Este programa está nomeado como dialog.c e possui - linhas de código. 21 + * Este programa está nomeado como print.c e possui - linhas de código.
22 * 22 *
23 * Contatos: 23 * Contatos:
24 * 24 *
@@ -42,10 +42,12 @@ @@ -42,10 +42,12 @@
42 guint fontsize; 42 guint fontsize;
43 cairo_font_weight_t fontweight; 43 cairo_font_weight_t fontweight;
44 gchar * colorname; 44 gchar * colorname;
  45 + int baddr;
45 int rows; 46 int rows;
46 int cols; 47 int cols;
47 int pages; 48 int pages;
48 cairo_font_extents_t extents; 49 cairo_font_extents_t extents;
  50 + double left;
49 double width; 51 double width;
50 double height; 52 double height;
51 cairo_scaled_font_t * font_scaled; 53 cairo_scaled_font_t * font_scaled;
@@ -54,8 +56,10 @@ @@ -54,8 +56,10 @@
54 56
55 /*--[ Implement ]------------------------------------------------------------------------------------*/ 57 /*--[ Implement ]------------------------------------------------------------------------------------*/
56 58
57 - static void setup_font(cairo_t *cr, PRINT_INFO *info) 59 + static void setup_font(GtkPrintContext * context, PRINT_INFO *info)
58 { 60 {
  61 + cairo_t *cr = gtk_print_context_get_cairo_context(context);
  62 +
59 cairo_select_font_face(cr, info->font, CAIRO_FONT_SLANT_NORMAL, info->fontweight); 63 cairo_select_font_face(cr, info->font, CAIRO_FONT_SLANT_NORMAL, info->fontweight);
60 64
61 info->font_scaled = cairo_get_scaled_font(cr); 65 info->font_scaled = cairo_get_scaled_font(cr);
@@ -65,15 +69,18 @@ @@ -65,15 +69,18 @@
65 info->width = ((double) info->cols) * info->extents.max_x_advance; 69 info->width = ((double) info->cols) * info->extents.max_x_advance;
66 info->height = ((double) info->rows) * (info->extents.height + info->extents.descent); 70 info->height = ((double) info->rows) * (info->extents.height + info->extents.descent);
67 71
  72 + // Center image
  73 + info->left = (gtk_print_context_get_width(context)-info->width)/2;
  74 + if(info->left < 2)
  75 + info->left = 2;
  76 +
  77 +
68 } 78 }
69 79
70 static void begin_print_all(GtkPrintOperation *prt, GtkPrintContext *context, PRINT_INFO *info) 80 static void begin_print_all(GtkPrintOperation *prt, GtkPrintContext *context, PRINT_INFO *info)
71 { 81 {
72 - cairo_t *cr = gtk_print_context_get_cairo_context(context);  
73 -  
74 lib3270_get_screen_size(info->session,&info->rows,&info->cols); 82 lib3270_get_screen_size(info->session,&info->rows,&info->cols);
75 - setup_font(cr,info);  
76 - 83 + setup_font(context,info);
77 gtk_print_operation_set_n_pages(prt,1); 84 gtk_print_operation_set_n_pages(prt,1);
78 } 85 }
79 86
@@ -82,31 +89,27 @@ @@ -82,31 +89,27 @@
82 int row; 89 int row;
83 int col; 90 int col;
84 cairo_t * cr = gtk_print_context_get_cairo_context(context); 91 cairo_t * cr = gtk_print_context_get_cairo_context(context);
85 - int baddr = 0; 92 + int baddr = info->baddr;
86 GdkRectangle rect; 93 GdkRectangle rect;
87 94
88 cairo_set_scaled_font(cr,info->font_scaled); 95 cairo_set_scaled_font(cr,info->font_scaled);
89 96
90 memset(&rect,0,sizeof(rect)); 97 memset(&rect,0,sizeof(rect));
91 -  
92 - rect.x = 0;  
93 - rect.y = 0; 98 + rect.y = 2;
94 rect.height = (info->extents.height + info->extents.descent); 99 rect.height = (info->extents.height + info->extents.descent);
95 rect.width = info->extents.max_x_advance; 100 rect.width = info->extents.max_x_advance;
96 101
97 -/*  
98 gdk_cairo_set_source_color(cr,info->color+V3270_COLOR_BACKGROUND); 102 gdk_cairo_set_source_color(cr,info->color+V3270_COLOR_BACKGROUND);
99 - cairo_rectangle(cr, 0, 0, rect.width*info->cols, rect.height*info->rows); 103 + cairo_rectangle(cr, info->left-2, 0, (rect.width*info->cols)+4, (rect.height*info->rows)+4);
100 cairo_fill(cr); 104 cairo_fill(cr);
101 cairo_stroke(cr); 105 cairo_stroke(cr);
102 -*/  
103 106
104 rect.width++; 107 rect.width++;
105 rect.height++; 108 rect.height++;
106 109
107 for(row = 0; row < info->rows; row++) 110 for(row = 0; row < info->rows; row++)
108 { 111 {
109 - rect.x = 0; 112 + rect.x = info->left;
110 for(col = 0; col < info->cols; col++) 113 for(col = 0; col < info->cols; col++)
111 { 114 {
112 unsigned char c; 115 unsigned char c;
src/gtk/v3270/draw.c
@@ -105,12 +105,12 @@ void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H32 @@ -105,12 +105,12 @@ void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H32
105 } 105 }
106 else 106 else
107 { 107 {
108 - fg = color+((attr & 0x00F0) >> 4); 108 + bg = color+((attr & 0x00F0) >> 4);
109 109
110 if(attr & LIB3270_ATTR_FIELD) 110 if(attr & LIB3270_ATTR_FIELD)
111 - bg = color+(attr & 0x0003)+V3270_COLOR_FIELD; 111 + fg = color+(attr & 0x0003)+V3270_COLOR_FIELD;
112 else 112 else
113 - bg = color+(attr & 0x000F); 113 + fg = color+(attr & 0x000F);
114 } 114 }
115 115
116 v3270_draw_char(cr,chr,attr,session,height,rect,fg,bg); 116 v3270_draw_char(cr,chr,attr,session,height,rect,fg,bg);
@@ -119,12 +119,12 @@ void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H32 @@ -119,12 +119,12 @@ void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H32
119 void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, guint height, GdkRectangle *rect, GdkColor *fg, GdkColor *bg) 119 void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, guint height, GdkRectangle *rect, GdkColor *fg, GdkColor *bg)
120 { 120 {
121 // Clear element area 121 // Clear element area
122 - gdk_cairo_set_source_color(cr,fg); 122 + gdk_cairo_set_source_color(cr,bg);
123 cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height); 123 cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height);
124 cairo_fill(cr); 124 cairo_fill(cr);
125 125
126 // Set foreground color 126 // Set foreground color
127 - gdk_cairo_set_source_color(cr,bg); 127 + gdk_cairo_set_source_color(cr,fg);
128 128
129 // Draw char 129 // Draw char
130 if(attr & LIB3270_ATTR_CG) 130 if(attr & LIB3270_ATTR_CG)