Commit 0054c1c31cca45424ce6f3afec83a961c3b58014
1 parent
f1894934
Exists in
master
and in
1 other branch
Rewriting color scheme selection widget
Showing
8 changed files
with
376 additions
and
11 deletions
Show diff stats
Makefile.in
@@ -313,6 +313,13 @@ install-shared: \ | @@ -313,6 +313,13 @@ install-shared: \ | ||
313 | $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ | 313 | $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ |
314 | 314 | ||
315 | 315 | ||
316 | + # Install default configs | ||
317 | + @mkdir -p $(datarootdir)/pw3270 | ||
318 | + | ||
319 | + @$(INSTALL_DATA) \ | ||
320 | + colors.conf \ | ||
321 | + $(datarootdir)/pw3270 | ||
322 | + | ||
316 | install-static: \ | 323 | install-static: \ |
317 | $(BINRLS)/static/$(LIBNAME).a | 324 | $(BINRLS)/static/$(LIBNAME).a |
318 | 325 |
@@ -0,0 +1,103 @@ | @@ -0,0 +1,103 @@ | ||
1 | +# | ||
2 | +# Software pw3270; desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
3 | +# (Paul Mattes Paul.Mattes@usa.net); de emulação de terminal 3270 para acesso a | ||
4 | +# aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
5 | +# | ||
6 | +# Copyright (C) <2008> <Banco do Brasil S.A.> | ||
7 | +# | ||
8 | +# Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
9 | +# os termos da GPL v.2 - Licença Pública Geral GNU; conforme publicado pela | ||
10 | +# Free Software Foundation. | ||
11 | +# | ||
12 | +# Este programa é distribuído na expectativa de ser útil; mas SEM QUALQUER | ||
13 | +# GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
14 | +# A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
15 | +# obter mais detalhes. | ||
16 | +# | ||
17 | +# Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
18 | +# programa; se não; escreva para a Free Software Foundation; Inc.; 51 Franklin | ||
19 | +# St; Fifth Floor; Boston; MA 02110-1301 USA | ||
20 | +# | ||
21 | +# | ||
22 | +# Contatos: | ||
23 | +# | ||
24 | +# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
25 | +# erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
26 | +# | ||
27 | + | ||
28 | +[default] | ||
29 | +label=PW3270 default | ||
30 | + | ||
31 | +base=#000000;#7890F0;#FF0000;#FF00FF;#00FF00;#00FFFF;#FFFF00;#FFFFFF;#000000;#000080;#FFA200;#800080;#008000;#008080;#A0A000;#C0C0C0 | ||
32 | +field=#00FF00;#FF0000;#00FFFF;#FFFFFF | ||
33 | +selection=#404040;#ffffff | ||
34 | +OIA=#000000;#00FF00;#7890F0;#FFFFFF;#FF0000 | ||
35 | + | ||
36 | +cross-hair=#00FF00 | ||
37 | + | ||
38 | +[X3270] | ||
39 | +label=X3270 | ||
40 | + | ||
41 | +base=black;deepSkyBlue;red;pink;green;turquoise;yellow;white;black;blue3;orange;purple;paleGreen;paleTurquoise2;grey;white | ||
42 | +field=green;red;deepSkyBlue;white | ||
43 | +selection=dimGrey;black | ||
44 | +OIA=black;turquoise;turquoise;white;red | ||
45 | + | ||
46 | +cross-hair=white | ||
47 | + | ||
48 | +[Reverse] | ||
49 | +label=Reverse | ||
50 | +label[pt_BR]=Invertido | ||
51 | + | ||
52 | +base=white;blue;firebrick;pink;green4;cadetBlue;goldenrod;black;white;blue3;orange;purple;paleGreen;darkTurquoise;grey;black | ||
53 | +selection=dimGrey;black | ||
54 | +OIA=white;blue;blue;black;black | ||
55 | + | ||
56 | +cross-hair=black | ||
57 | + | ||
58 | +[Bright] | ||
59 | +label=Bright | ||
60 | +label[pt_BR]=Cores fortes | ||
61 | + | ||
62 | +base=black;blue;red;magenta;green;turquoise;yellow;white;black;blue3;orange;purple;paleGreen;cyan;grey;white | ||
63 | +selection=dimGrey;black | ||
64 | +OIA=black;blue;blue;white;red | ||
65 | + | ||
66 | +cross-hair=white | ||
67 | + | ||
68 | +[CPE] | ||
69 | +label=CPE | ||
70 | +base=black;LightBlue1;PaleVioletRed1;pink;green;turquoise;yellow;white;black;LightBlue3;orange;MediumPurple1;paleGreen;paleTurquoise2;grey80;white | ||
71 | +selection=dimGrey;black | ||
72 | +OIA=black;turquoise;turquoise;white;red | ||
73 | + | ||
74 | +cross-hair=white | ||
75 | + | ||
76 | +[Green] | ||
77 | +label=Green | ||
78 | +label[pt_BR]=Verde | ||
79 | + | ||
80 | +base=black;green | ||
81 | + | ||
82 | +[WB] | ||
83 | +label=White on Black | ||
84 | +label[pt_BR]=Branco com fundo preto | ||
85 | + | ||
86 | +base=black;white | ||
87 | + | ||
88 | +[BW] | ||
89 | +label=Black on White | ||
90 | +label[pt_BR]=Preto com fundo branco | ||
91 | +base=white;black | ||
92 | + | ||
93 | +[selenized] | ||
94 | + | ||
95 | +# https://github.com/jan-warchol/selenized | ||
96 | +label=Selenized color palette by Jan Warchoł | ||
97 | + | ||
98 | +base=rgb(24,24,24);rgb(79,156,254);rgb(237,74,70);rgb(235,110,183);rgb(131,199,70);rgb(86,216,201);rgb(239,197,65);rgb(222,222,222);rgb(59,59,59);rgb(54,142,171);rgb(250,145,83);rgb(165,128,226);rgb(112,180,51);rgb(65,199,185);rgb(219,179,45);rgb(119,119,119) | ||
99 | +field=rgb(131,199,70);rgb(237,74,70);rgb(65,199,185);rgb(250,145,83) | ||
100 | +selection=rgb(37,37,37);rgb(222,222,222) | ||
101 | +OIA=rgb(24,24,24);rgb(222,222,222);rgb(79,156,254);rgb(131,199,70);rgb(239,197,65) | ||
102 | +cross-hair=rgb(222,222,222) | ||
103 | + |
src/dialogs/colorscheme.c
@@ -38,7 +38,9 @@ | @@ -38,7 +38,9 @@ | ||
38 | #include <glib/gi18n.h> | 38 | #include <glib/gi18n.h> |
39 | 39 | ||
40 | #include <v3270.h> | 40 | #include <v3270.h> |
41 | + #include <lib3270/log.h> | ||
41 | #include <v3270/colorscheme.h> | 42 | #include <v3270/colorscheme.h> |
43 | + #include "../v3270/marshal.h" | ||
42 | 44 | ||
43 | #define V3270_COLOR_BASE V3270_COLOR_GRAY+1 | 45 | #define V3270_COLOR_BASE V3270_COLOR_GRAY+1 |
44 | 46 | ||
@@ -48,33 +50,260 @@ | @@ -48,33 +50,260 @@ | ||
48 | { | 50 | { |
49 | GtkComboBoxClass parent_class; | 51 | GtkComboBoxClass parent_class; |
50 | 52 | ||
51 | - | ||
52 | }; | 53 | }; |
53 | 54 | ||
54 | struct _V3270ColorScheme | 55 | struct _V3270ColorScheme |
55 | { | 56 | { |
56 | - GtkComboBox parent; | 57 | + GtkComboBox parent; |
58 | + GdkRGBA * schemes; | ||
59 | + | ||
60 | + | ||
61 | + }; | ||
57 | 62 | ||
63 | + enum | ||
64 | + { | ||
65 | + CHANGED, | ||
66 | + LAST_SIGNAL | ||
58 | }; | 67 | }; |
59 | 68 | ||
69 | + static guint color_signal[LAST_SIGNAL] = { 0 }; | ||
70 | + | ||
60 | G_DEFINE_TYPE(V3270ColorScheme, V3270ColorScheme, GTK_TYPE_COMBO_BOX); | 71 | G_DEFINE_TYPE(V3270ColorScheme, V3270ColorScheme, GTK_TYPE_COMBO_BOX); |
61 | 72 | ||
62 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 73 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
63 | 74 | ||
75 | + static void changed(GtkComboBox *widget) | ||
76 | + { | ||
77 | + GdkRGBA * clr = NULL; | ||
78 | + GValue value = { 0, }; | ||
79 | + GtkTreeIter iter; | ||
80 | + | ||
81 | + if(!gtk_combo_box_get_active_iter(widget,&iter)) | ||
82 | + return; | ||
83 | + | ||
84 | + gtk_tree_model_get_value(gtk_combo_box_get_model(widget),&iter,1,&value); | ||
85 | + clr = g_value_get_pointer(&value); | ||
86 | + | ||
87 | + debug("%s=%p",__FUNCTION__,clr); | ||
88 | + g_signal_emit(widget, color_signal[CHANGED], 0, clr); | ||
89 | + | ||
90 | + } | ||
91 | + | ||
64 | static void V3270ColorScheme_class_init(G_GNUC_UNUSED V3270ColorSchemeClass *klass) | 92 | static void V3270ColorScheme_class_init(G_GNUC_UNUSED V3270ColorSchemeClass *klass) |
65 | { | 93 | { |
94 | + GObjectClass * gobject_class = G_OBJECT_CLASS(klass); | ||
95 | + | ||
96 | + klass->parent_class.changed = changed; | ||
97 | + | ||
98 | + color_signal[CHANGED] = | ||
99 | + g_signal_new( | ||
100 | + "update-colors", | ||
101 | + G_OBJECT_CLASS_TYPE (gobject_class), | ||
102 | + G_SIGNAL_RUN_FIRST, | ||
103 | + 0, | ||
104 | + NULL, NULL, | ||
105 | + v3270_VOID__VOID_POINTER, | ||
106 | + G_TYPE_NONE, 1, G_TYPE_POINTER, 0 | ||
107 | + ); | ||
108 | + | ||
109 | + debug("changed_signal=%d",(int) color_signal[CHANGED]); | ||
66 | 110 | ||
67 | } | 111 | } |
68 | 112 | ||
69 | static void V3270ColorScheme_init(V3270ColorScheme *widget) | 113 | static void V3270ColorScheme_init(V3270ColorScheme *widget) |
70 | { | 114 | { |
71 | 115 | ||
116 | + GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_POINTER); | ||
117 | + GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); | ||
118 | + | ||
119 | + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE); | ||
120 | + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), renderer, "text", 0, NULL); | ||
121 | + | ||
122 | + gtk_combo_box_set_model(GTK_COMBO_BOX(widget), model); | ||
123 | + | ||
72 | } | 124 | } |
73 | 125 | ||
74 | - LIB3270_EXPORT GtkWidget * v3270_color_scheme_new(GdkRGBA *colors) | 126 | + static void load_color_scheme(GKeyFile *conf, const gchar *group, GdkRGBA *clr) |
75 | { | 127 | { |
76 | - GtkWidget *widget = GTK_WIDGET(g_object_new(GTK_TYPE_V3270_COLOR_SCHEME, NULL)); | 128 | + const gchar * val; |
129 | + size_t f; | ||
130 | + | ||
131 | + // Load base colors | ||
132 | + val = g_key_file_get_string(conf,group,"base",NULL); | ||
133 | + if(val) | ||
134 | + { | ||
135 | + // Process base colors | ||
136 | + gchar **str = g_strsplit(val,";",V3270_COLOR_BASE); | ||
137 | + | ||
138 | + switch(g_strv_length(str)) | ||
139 | + { | ||
140 | + case 2: // Only 2 colors, create monocromatic table | ||
141 | + v3270_set_mono_color_table(clr,str[1],str[0]); | ||
142 | + break; | ||
143 | + | ||
144 | + case V3270_COLOR_BASE: // All colors, update it | ||
145 | + for(f=0;f<V3270_COLOR_BASE;f++) | ||
146 | + gdk_rgba_parse(clr+f,str[f]); | ||
147 | + break; | ||
148 | + | ||
149 | + default: | ||
150 | + | ||
151 | + // Unexpected size, load new colors over the defaults | ||
152 | + g_warning("base color list in %s has %d elements, should have %d",group,g_strv_length(str),V3270_COLOR_GRAY); | ||
153 | + | ||
154 | + gdk_rgba_parse(clr,str[0]); | ||
155 | + gdk_rgba_parse(clr+1,str[1]); | ||
156 | + | ||
157 | + for(f=2;f<V3270_COLOR_BASE;f++) | ||
158 | + clr[f] = clr[1]; | ||
159 | + | ||
160 | + clr[V3270_COLOR_BLACK] = *clr; | ||
161 | + | ||
162 | + for(f=2;f<MIN(g_strv_length(str),V3270_COLOR_BASE-1);f++) | ||
163 | + gdk_rgba_parse(clr+f,str[f]); | ||
164 | + | ||
165 | + } | ||
166 | + g_strfreev(str); | ||
167 | + | ||
168 | + } | ||
169 | + else | ||
170 | + { | ||
171 | + g_warning("Color scheme [%s] has no \"base\" entry, using green on black",group); | ||
172 | + | ||
173 | + gdk_rgba_parse(clr,"black"); | ||
174 | + gdk_rgba_parse(clr+1,"green"); | ||
175 | + | ||
176 | + for(f=2;f<V3270_COLOR_BASE;f++) | ||
177 | + clr[f] = clr[1]; | ||
178 | + clr[V3270_COLOR_BLACK] = *clr; | ||
179 | + } | ||
180 | + | ||
181 | + // Load field colors | ||
182 | + clr[V3270_COLOR_FIELD] = clr[V3270_COLOR_GREEN]; | ||
183 | + clr[V3270_COLOR_FIELD_INTENSIFIED] = clr[V3270_COLOR_RED]; | ||
184 | + clr[V3270_COLOR_FIELD_PROTECTED] = clr[V3270_COLOR_BLUE]; | ||
185 | + clr[V3270_COLOR_FIELD_PROTECTED_INTENSIFIED] = clr[V3270_COLOR_WHITE]; | ||
186 | + | ||
187 | + val = g_key_file_get_string(conf,group,"field",NULL); | ||
188 | + if(val) | ||
189 | + { | ||
190 | + gchar **str = g_strsplit(val,";",5); | ||
191 | + | ||
192 | + for(f=0;f< MIN(g_strv_length(str),4); f++) | ||
193 | + gdk_rgba_parse(clr+V3270_COLOR_FIELD+f,str[f]); | ||
194 | + | ||
195 | + g_strfreev(str); | ||
196 | + } | ||
197 | + | ||
198 | + // Load selection colors | ||
199 | + clr[V3270_COLOR_SELECTED_BG] = clr[V3270_COLOR_WHITE]; | ||
200 | + clr[V3270_COLOR_SELECTED_FG] = clr[V3270_COLOR_BLACK]; | ||
201 | + val = g_key_file_get_string(conf,group,"selection",NULL); | ||
202 | + if(val) | ||
203 | + { | ||
204 | + gchar **str = g_strsplit(val,";",3); | ||
205 | + | ||
206 | + for(f=0;f< MIN(g_strv_length(str),2); f++) | ||
207 | + gdk_rgba_parse(clr+V3270_COLOR_SELECTED_BG+f,str[f]); | ||
208 | + | ||
209 | + g_strfreev(str); | ||
210 | + } | ||
211 | + | ||
212 | + // Load OIA colors | ||
213 | + clr[V3270_COLOR_OIA_BACKGROUND] = clr[V3270_COLOR_BACKGROUND]; | ||
214 | + clr[V3270_COLOR_OIA_FOREGROUND] = clr[V3270_COLOR_GREEN]; | ||
215 | + clr[V3270_COLOR_OIA_SEPARATOR] = clr[V3270_COLOR_GREEN]; | ||
216 | + clr[V3270_COLOR_OIA_STATUS_OK] = clr[V3270_COLOR_GREEN]; | ||
217 | + clr[V3270_COLOR_OIA_STATUS_INVALID] = clr[V3270_COLOR_RED]; | ||
218 | + clr[V3270_COLOR_OIA_STATUS_WARNING] = clr[V3270_COLOR_YELLOW]; | ||
219 | + | ||
220 | + val = g_key_file_get_string(conf,group,"OIA",NULL); | ||
221 | + if(val) | ||
222 | + { | ||
223 | + gchar **str = g_strsplit(val,";",6); | ||
224 | + | ||
225 | + // 0 = V3270_COLOR_OIA_BACKGROUND, | ||
226 | + // 1 = V3270_COLOR_OIA_FOREGROUND, | ||
227 | + // 2 = V3270_COLOR_OIA_SEPARATOR, | ||
228 | + // 3 = V3270_COLOR_OIA_STATUS_OK, | ||
229 | + // 4 = V3270_COLOR_OIA_STATUS_WARNING, | ||
230 | + // 5 = V3270_COLOR_OIA_STATUS_INVALID, | ||
231 | + | ||
232 | + if(g_strv_length(str) == 5) | ||
233 | + { | ||
234 | + for(f=0;f < 5; f++) | ||
235 | + gdk_rgba_parse(clr+V3270_COLOR_OIA_BACKGROUND+f,str[f]); | ||
236 | + clr[V3270_COLOR_OIA_STATUS_INVALID] = clr[V3270_COLOR_OIA_STATUS_WARNING]; | ||
237 | + } | ||
238 | + else | ||
239 | + { | ||
240 | + for(f=0;f< MIN(g_strv_length(str),6); f++) | ||
241 | + gdk_rgba_parse(clr+V3270_COLOR_OIA_BACKGROUND+f,str[f]); | ||
242 | + } | ||
243 | + | ||
244 | + g_strfreev(str); | ||
245 | + } | ||
246 | + | ||
247 | + // Setup extended elements | ||
248 | + clr[V3270_COLOR_CROSS_HAIR] = clr[V3270_COLOR_GREEN]; | ||
249 | + | ||
250 | + val = g_key_file_get_string(conf,group,"cross-hair",NULL); | ||
251 | + if(val) | ||
252 | + gdk_rgba_parse(clr+V3270_COLOR_CROSS_HAIR,val); | ||
253 | + | ||
254 | + } | ||
255 | + | ||
256 | + LIB3270_EXPORT GtkWidget * v3270_color_scheme_new() | ||
257 | + { | ||
258 | + GtkWidget * widget = GTK_WIDGET(g_object_new(GTK_TYPE_V3270_COLOR_SCHEME, NULL)); | ||
259 | + GtkTreeModel * model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget)); | ||
260 | + | ||
261 | +#ifdef DEBUG | ||
262 | + lib3270_autoptr(char) filename = lib3270_strdup_printf("%s/%s",".","colors.conf"); | ||
263 | +#else | ||
264 | + lib3270_autoptr(char) filename = lib3270_build_data_filename("colors.conf"); | ||
265 | +#endif // DEBUG | ||
266 | + | ||
267 | + if(!g_file_test(filename,G_FILE_TEST_IS_REGULAR)) | ||
268 | + { | ||
269 | + g_warning("Unable to load color schemes in \"%s\"",filename); | ||
270 | + gtk_widget_set_sensitive(widget,FALSE); | ||
271 | + return widget; | ||
272 | + } | ||
273 | + | ||
274 | + // Load color schemes. | ||
275 | + g_autoptr(GKeyFile) conf = g_key_file_new(); | ||
276 | + g_autoptr(GError) err = NULL; | ||
277 | + int index = 0; | ||
278 | + gsize len; | ||
279 | + gsize g; | ||
280 | + | ||
281 | + g_key_file_load_from_file(conf,filename,G_KEY_FILE_NONE,&err); | ||
282 | + | ||
283 | + gchar **group = g_key_file_get_groups(conf,&len); | ||
284 | + GTK_V3270_COLOR_SCHEME(widget)->schemes = g_new0(GdkRGBA,(len*V3270_COLOR_COUNT)); | ||
285 | + | ||
286 | + for(g=0;g<len;g++) | ||
287 | + { | ||
288 | + // Setup colors for current entry | ||
289 | + GtkTreeIter iter; | ||
290 | + GdkRGBA * clr = GTK_V3270_COLOR_SCHEME(widget)->schemes+index; | ||
291 | + const gchar * label = g_key_file_get_locale_string(conf,group[g],"label",NULL,NULL); | ||
292 | + | ||
293 | + load_color_scheme(conf,group[g],clr); | ||
294 | + | ||
295 | + // Set it in the combobox | ||
296 | + gtk_list_store_append((GtkListStore *) model,&iter); | ||
297 | + gtk_list_store_set((GtkListStore *) model, &iter, | ||
298 | + 0, label ? label : group[g], | ||
299 | + 1, clr, | ||
300 | + -1); | ||
301 | + | ||
302 | + // move to next color list | ||
303 | + index += V3270_COLOR_COUNT; | ||
304 | + } | ||
77 | 305 | ||
306 | + g_strfreev(group); | ||
78 | 307 | ||
79 | return widget; | 308 | return widget; |
80 | } | 309 | } |
src/include/v3270.h
@@ -215,7 +215,7 @@ | @@ -215,7 +215,7 @@ | ||
215 | LIB3270_EXPORT const GdkRGBA * v3270_get_color_table(GtkWidget *widget); | 215 | LIB3270_EXPORT const GdkRGBA * v3270_get_color_table(GtkWidget *widget); |
216 | LIB3270_EXPORT void v3270_set_mono_color_table(GdkRGBA *table, const gchar *fg, const gchar *bg); | 216 | LIB3270_EXPORT void v3270_set_mono_color_table(GdkRGBA *table, const gchar *fg, const gchar *bg); |
217 | LIB3270_EXPORT void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, v3270FontInfo *font, GdkRectangle *rect, GdkRGBA *color); | 217 | LIB3270_EXPORT void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, v3270FontInfo *font, GdkRectangle *rect, GdkRGBA *color); |
218 | - LIB3270_EXPORT void v3270_set_color(GtkWidget *widget, enum V3270_COLOR id, GdkRGBA *color); | 218 | + LIB3270_EXPORT void v3270_set_color(GtkWidget *widget, enum V3270_COLOR id, const GdkRGBA *color); |
219 | LIB3270_EXPORT GdkRGBA * v3270_get_color(GtkWidget *widget, enum V3270_COLOR id); | 219 | LIB3270_EXPORT GdkRGBA * v3270_get_color(GtkWidget *widget, enum V3270_COLOR id); |
220 | 220 | ||
221 | // Misc | 221 | // Misc |
src/include/v3270/colorscheme.h
@@ -47,7 +47,7 @@ | @@ -47,7 +47,7 @@ | ||
47 | 47 | ||
48 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ | 48 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ |
49 | 49 | ||
50 | - LIB3270_EXPORT GtkWidget * v3270_color_scheme_new(GdkRGBA *colors); | 50 | + LIB3270_EXPORT GtkWidget * v3270_color_scheme_new(); |
51 | 51 | ||
52 | G_END_DECLS | 52 | G_END_DECLS |
53 | 53 |
src/testprogram/testprogram.c
@@ -36,6 +36,8 @@ | @@ -36,6 +36,8 @@ | ||
36 | #include <v3270.h> | 36 | #include <v3270.h> |
37 | #include <v3270/filetransfer.h> | 37 | #include <v3270/filetransfer.h> |
38 | #include <v3270/ftprogress.h> | 38 | #include <v3270/ftprogress.h> |
39 | + #include <v3270/colorscheme.h> | ||
40 | + #include <lib3270/log.h> | ||
39 | #include <stdlib.h> | 41 | #include <stdlib.h> |
40 | 42 | ||
41 | /*---[ Implement ]----------------------------------------------------------------------------------*/ | 43 | /*---[ Implement ]----------------------------------------------------------------------------------*/ |
@@ -88,6 +90,19 @@ static void trace_window_destroy(G_GNUC_UNUSED GtkWidget *widget, H3270 *hSessio | @@ -88,6 +90,19 @@ static void trace_window_destroy(G_GNUC_UNUSED GtkWidget *widget, H3270 *hSessio | ||
88 | lib3270_set_toggle(hSession,LIB3270_TOGGLE_NETWORK_TRACE,0); | 90 | lib3270_set_toggle(hSession,LIB3270_TOGGLE_NETWORK_TRACE,0); |
89 | } | 91 | } |
90 | 92 | ||
93 | +static void color_scheme_changed(GtkWidget *widget, const GdkRGBA *colors, GtkWidget *terminal) { | ||
94 | + | ||
95 | + debug("%s=%p",__FUNCTION__,colors); | ||
96 | + | ||
97 | + int f; | ||
98 | + for(f=0;f<V3270_COLOR_COUNT;f++) | ||
99 | + v3270_set_color(terminal,f,colors+f); | ||
100 | + | ||
101 | + v3270_reload(terminal); | ||
102 | + gtk_widget_queue_draw(terminal); | ||
103 | + | ||
104 | +} | ||
105 | + | ||
91 | static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { | 106 | static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { |
92 | 107 | ||
93 | /* | 108 | /* |
@@ -153,17 +168,29 @@ static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { | @@ -153,17 +168,29 @@ static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { | ||
153 | 168 | ||
154 | g_signal_connect(terminal,"popup",G_CALLBACK(popup_menu),NULL); | 169 | g_signal_connect(terminal,"popup",G_CALLBACK(popup_menu),NULL); |
155 | 170 | ||
171 | + // Create box | ||
172 | + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL,2); | ||
173 | + GtkWidget *grid = gtk_grid_new(); | ||
174 | + GtkWidget *color = v3270_color_scheme_new(); | ||
175 | + | ||
176 | + g_signal_connect(G_OBJECT(color),"update-colors",G_CALLBACK(color_scheme_changed),terminal); | ||
177 | + | ||
178 | + gtk_grid_attach(GTK_GRID(grid),color,0,0,1,1); | ||
179 | + | ||
180 | + gtk_box_pack_start(GTK_BOX(box),grid,FALSE,TRUE,0); | ||
181 | + gtk_box_pack_start(GTK_BOX(box),terminal,TRUE,TRUE,0); | ||
182 | + | ||
156 | // Setup and show window | 183 | // Setup and show window |
157 | gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); | 184 | gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); |
158 | gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); | 185 | gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); |
159 | - gtk_container_add(GTK_CONTAINER(window),terminal); | 186 | + gtk_container_add(GTK_CONTAINER(window),box); |
160 | gtk_widget_show_all (window); | 187 | gtk_widget_show_all (window); |
161 | 188 | ||
162 | - v3270_set_toggle(terminal,LIB3270_TOGGLE_RECONNECT,1); | 189 | + // v3270_set_toggle(terminal,LIB3270_TOGGLE_RECONNECT,1); |
163 | 190 | ||
164 | // v3270_set_script(terminal,'R'); | 191 | // v3270_set_script(terminal,'R'); |
165 | 192 | ||
166 | - v3270_print_all(terminal); | 193 | + // v3270_print_all(terminal); |
167 | 194 | ||
168 | 195 | ||
169 | } | 196 | } |
src/v3270/colors.c
@@ -90,7 +90,7 @@ LIB3270_EXPORT void v3270_set_colors(GtkWidget *widget, const gchar *colors) | @@ -90,7 +90,7 @@ LIB3270_EXPORT void v3270_set_colors(GtkWidget *widget, const gchar *colors) | ||
90 | 90 | ||
91 | } | 91 | } |
92 | 92 | ||
93 | -LIB3270_EXPORT void v3270_set_color(GtkWidget *widget, enum V3270_COLOR id, GdkRGBA *color) | 93 | +LIB3270_EXPORT void v3270_set_color(GtkWidget *widget, enum V3270_COLOR id, const GdkRGBA *color) |
94 | { | 94 | { |
95 | g_return_if_fail(GTK_IS_V3270(widget)); | 95 | g_return_if_fail(GTK_IS_V3270(widget)); |
96 | 96 |
src/v3270/print.c
@@ -210,7 +210,6 @@ | @@ -210,7 +210,6 @@ | ||
210 | debug("%s(%p)",__FUNCTION__,info->widget); | 210 | debug("%s(%p)",__FUNCTION__,info->widget); |
211 | g_signal_emit(info->widget, v3270_widget_signal[SIGNAL_PRINT_DONE], 0, prt, (guint) result); | 211 | g_signal_emit(info->widget, v3270_widget_signal[SIGNAL_PRINT_DONE], 0, prt, (guint) result); |
212 | 212 | ||
213 | - | ||
214 | debug("%s",__FUNCTION__); | 213 | debug("%s",__FUNCTION__); |
215 | if(info->font.scaled) | 214 | if(info->font.scaled) |
216 | cairo_scaled_font_destroy(info->font.scaled); | 215 | cairo_scaled_font_destroy(info->font.scaled); |