Commit 6d5ebe31d5025ee40aec7136e087a4c29db35804
1 parent
5ac56691
Exists in
master
and in
5 other branches
Corrigindo dialogo de impressão em gtk3
Showing
4 changed files
with
36 additions
and
23 deletions
Show diff stats
pw3270.cbp
... | ... | @@ -46,6 +46,9 @@ |
46 | 46 | <Unit filename="src/gtk/actions.c"> |
47 | 47 | <Option compilerVar="CC" /> |
48 | 48 | </Unit> |
49 | + <Unit filename="src/gtk/colors.c"> | |
50 | + <Option compilerVar="CC" /> | |
51 | + </Unit> | |
49 | 52 | <Unit filename="src/gtk/common/common.h" /> |
50 | 53 | <Unit filename="src/gtk/common/config.c"> |
51 | 54 | <Option compilerVar="CC" /> | ... | ... |
src/gtk/colors.c
... | ... | @@ -44,9 +44,9 @@ |
44 | 44 | else |
45 | 45 | { |
46 | 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 | 51 | #if !GTK_CHECK_VERSION(3,0,0) |
52 | 52 | GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_STRING); |
... | ... | @@ -76,10 +76,16 @@ |
76 | 76 | #if GTK_CHECK_VERSION(3,0,0) |
77 | 77 | |
78 | 78 | gtk_combo_box_text_insert( GTK_COMBO_BOX_TEXT(widget), |
79 | - 0, | |
79 | + f, | |
80 | 80 | str, |
81 | 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 | 89 | #else |
84 | 90 | |
85 | 91 | gtk_list_store_append((GtkListStore *) model,&iter); |
... | ... | @@ -110,6 +116,7 @@ |
110 | 116 | 0, |
111 | 117 | active, |
112 | 118 | _( "Custom colors") ); |
119 | + gtk_combo_box_set_active(GTK_COMBO_BOX(widget),0); | |
113 | 120 | |
114 | 121 | #else |
115 | 122 | ... | ... |
src/gtk/print.c
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple |
19 | 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 | 23 | * Contatos: |
24 | 24 | * |
... | ... | @@ -42,10 +42,12 @@ |
42 | 42 | guint fontsize; |
43 | 43 | cairo_font_weight_t fontweight; |
44 | 44 | gchar * colorname; |
45 | + int baddr; | |
45 | 46 | int rows; |
46 | 47 | int cols; |
47 | 48 | int pages; |
48 | 49 | cairo_font_extents_t extents; |
50 | + double left; | |
49 | 51 | double width; |
50 | 52 | double height; |
51 | 53 | cairo_scaled_font_t * font_scaled; |
... | ... | @@ -54,8 +56,10 @@ |
54 | 56 | |
55 | 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 | 63 | cairo_select_font_face(cr, info->font, CAIRO_FONT_SLANT_NORMAL, info->fontweight); |
60 | 64 | |
61 | 65 | info->font_scaled = cairo_get_scaled_font(cr); |
... | ... | @@ -65,15 +69,18 @@ |
65 | 69 | info->width = ((double) info->cols) * info->extents.max_x_advance; |
66 | 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 | 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 | 82 | lib3270_get_screen_size(info->session,&info->rows,&info->cols); |
75 | - setup_font(cr,info); | |
76 | - | |
83 | + setup_font(context,info); | |
77 | 84 | gtk_print_operation_set_n_pages(prt,1); |
78 | 85 | } |
79 | 86 | |
... | ... | @@ -82,31 +89,27 @@ |
82 | 89 | int row; |
83 | 90 | int col; |
84 | 91 | cairo_t * cr = gtk_print_context_get_cairo_context(context); |
85 | - int baddr = 0; | |
92 | + int baddr = info->baddr; | |
86 | 93 | GdkRectangle rect; |
87 | 94 | |
88 | 95 | cairo_set_scaled_font(cr,info->font_scaled); |
89 | 96 | |
90 | 97 | memset(&rect,0,sizeof(rect)); |
91 | - | |
92 | - rect.x = 0; | |
93 | - rect.y = 0; | |
98 | + rect.y = 2; | |
94 | 99 | rect.height = (info->extents.height + info->extents.descent); |
95 | 100 | rect.width = info->extents.max_x_advance; |
96 | 101 | |
97 | -/* | |
98 | 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 | 104 | cairo_fill(cr); |
101 | 105 | cairo_stroke(cr); |
102 | -*/ | |
103 | 106 | |
104 | 107 | rect.width++; |
105 | 108 | rect.height++; |
106 | 109 | |
107 | 110 | for(row = 0; row < info->rows; row++) |
108 | 111 | { |
109 | - rect.x = 0; | |
112 | + rect.x = info->left; | |
110 | 113 | for(col = 0; col < info->cols; col++) |
111 | 114 | { |
112 | 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 | 105 | } |
106 | 106 | else |
107 | 107 | { |
108 | - fg = color+((attr & 0x00F0) >> 4); | |
108 | + bg = color+((attr & 0x00F0) >> 4); | |
109 | 109 | |
110 | 110 | if(attr & LIB3270_ATTR_FIELD) |
111 | - bg = color+(attr & 0x0003)+V3270_COLOR_FIELD; | |
111 | + fg = color+(attr & 0x0003)+V3270_COLOR_FIELD; | |
112 | 112 | else |
113 | - bg = color+(attr & 0x000F); | |
113 | + fg = color+(attr & 0x000F); | |
114 | 114 | } |
115 | 115 | |
116 | 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 | 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 | 121 | // Clear element area |
122 | - gdk_cairo_set_source_color(cr,fg); | |
122 | + gdk_cairo_set_source_color(cr,bg); | |
123 | 123 | cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height); |
124 | 124 | cairo_fill(cr); |
125 | 125 | |
126 | 126 | // Set foreground color |
127 | - gdk_cairo_set_source_color(cr,bg); | |
127 | + gdk_cairo_set_source_color(cr,fg); | |
128 | 128 | |
129 | 129 | // Draw char |
130 | 130 | if(attr & LIB3270_ATTR_CG) | ... | ... |