Commit e51354ffa376419f78c7ee8d027f289427b4b5d0
1 parent
fd944146
Exists in
master
and in
1 other branch
Updating color selection dialog.
Showing
3 changed files
with
112 additions
and
13 deletions
Show diff stats
src/dialogs/colors.c
@@ -31,6 +31,8 @@ | @@ -31,6 +31,8 @@ | ||
31 | #include <v3270/colorscheme.h> | 31 | #include <v3270/colorscheme.h> |
32 | #include <lib3270/log.h> | 32 | #include <lib3270/log.h> |
33 | 33 | ||
34 | + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | ||
35 | + | ||
34 | /*--[ Widget definition ]----------------------------------------------------------------------------*/ | 36 | /*--[ Widget definition ]----------------------------------------------------------------------------*/ |
35 | 37 | ||
36 | struct _V3270ColorSelectionClass | 38 | struct _V3270ColorSelectionClass |
@@ -43,7 +45,8 @@ | @@ -43,7 +45,8 @@ | ||
43 | { | 45 | { |
44 | GtkGrid parent; | 46 | GtkGrid parent; |
45 | 47 | ||
46 | - GtkWidget * terminal; | 48 | + GtkWidget * terminal; |
49 | + int selected; | ||
47 | 50 | ||
48 | struct { | 51 | struct { |
49 | GtkWidget * view; | 52 | GtkWidget * view; |
@@ -71,7 +74,46 @@ | @@ -71,7 +74,46 @@ | ||
71 | 74 | ||
72 | } | 75 | } |
73 | 76 | ||
74 | -static void color_scheme_changed(GtkWidget G_GNUC_UNUSED(*dunno), const GdkRGBA *colors, V3270ColorSelection *widget) { | 77 | + static void update_color_chooser(V3270ColorSelection *widget, int id) |
78 | + { | ||
79 | + widget->selected = id; | ||
80 | + | ||
81 | + if(id < 0 || id >= V3270_COLOR_COUNT) | ||
82 | + { | ||
83 | +#if USE_GTK_COLOR_CHOOSER | ||
84 | + gtk_widget_set_sensitive(widget->colors.chooser,FALSE); | ||
85 | +#else | ||
86 | + gtk_widget_set_sensitive(widget->colors.editor,FALSE); | ||
87 | +#endif // USE_GTK_COLOR_CHOOSER | ||
88 | + return; | ||
89 | + } | ||
90 | + | ||
91 | + GdkRGBA * clr = v3270_get_color(widget->terminal,id); | ||
92 | + | ||
93 | +#if USE_GTK_COLOR_CHOOSER | ||
94 | + { | ||
95 | + GValue value; | ||
96 | + | ||
97 | + gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(widget->colors.chooser),clr); | ||
98 | + | ||
99 | + g_value_init(&value, G_TYPE_BOOLEAN); | ||
100 | + g_value_set_boolean(&value,FALSE); | ||
101 | + g_object_set_property(G_OBJECT(widget->colors.chooser),"show-editor",&value); | ||
102 | + | ||
103 | + gtk_widget_set_sensitive(widget->colors.chooser,TRUE); | ||
104 | + | ||
105 | + } | ||
106 | +#else | ||
107 | + | ||
108 | + gtk_color_selection_set_previous_rgba(GTK_COLOR_SELECTION(widget->colors.editor),widget->saved+id); | ||
109 | + gtk_color_selection_set_current_rgba(GTK_COLOR_SELECTION(widget->colors.editor),clr); | ||
110 | + | ||
111 | + gtk_widget_set_sensitive(widget->colors.editor,TRUE); | ||
112 | +#endif // GTK_CHECK_VERSION | ||
113 | + | ||
114 | + } | ||
115 | + | ||
116 | + static void color_scheme_changed(GtkWidget G_GNUC_UNUSED(*dunno), const GdkRGBA *colors, V3270ColorSelection *widget) { | ||
75 | 117 | ||
76 | debug("%s=%p",__FUNCTION__,colors); | 118 | debug("%s=%p",__FUNCTION__,colors); |
77 | 119 | ||
@@ -79,10 +121,60 @@ static void color_scheme_changed(GtkWidget G_GNUC_UNUSED(*dunno), const GdkRGBA | @@ -79,10 +121,60 @@ static void color_scheme_changed(GtkWidget G_GNUC_UNUSED(*dunno), const GdkRGBA | ||
79 | for(f=0;f<V3270_COLOR_COUNT;f++) | 121 | for(f=0;f<V3270_COLOR_COUNT;f++) |
80 | v3270_set_color(widget->terminal,f,colors+f); | 122 | v3270_set_color(widget->terminal,f,colors+f); |
81 | 123 | ||
124 | + update_color_chooser(widget,widget->selected); | ||
125 | + | ||
82 | v3270_reload(widget->terminal); | 126 | v3270_reload(widget->terminal); |
83 | gtk_widget_queue_draw(widget->terminal); | 127 | gtk_widget_queue_draw(widget->terminal); |
84 | 128 | ||
85 | -} | 129 | + } |
130 | + | ||
131 | +#if USE_GTK_COLOR_CHOOSER | ||
132 | + static void color_activated(GtkColorChooser *chooser, GdkRGBA *clr, V3270ColorSelection *widget) | ||
133 | + { | ||
134 | + if(widget->selected < 0 || widget->selected >= V3270_COLOR_COUNT) | ||
135 | + return; | ||
136 | + | ||
137 | + trace("Updating color %d",widget->selected); | ||
138 | + | ||
139 | + v3270_set_color(widget->terminal,widget->selected,clr); | ||
140 | + v3270_reload(widget->terminal); | ||
141 | + v3270_color_scheme_set_rgba(widget->colors.scheme,v3270_get_color_table(widget->terminal)); | ||
142 | + gtk_widget_queue_draw(widget->terminal); | ||
143 | + | ||
144 | + } | ||
145 | +#else | ||
146 | + static void color_changed(GtkWidget *colorselection, V3270ColorSelection *widget) | ||
147 | + { | ||
148 | + GdkRGBA clr; | ||
149 | + | ||
150 | + if(widget->selected < 0 || widget->selected >= V3270_COLOR_COUNT) | ||
151 | + return; | ||
152 | + | ||
153 | + gtk_color_selection_get_current_rgba(GTK_COLOR_SELECTION(colorselection),&clr); | ||
154 | + | ||
155 | + v3270_set_color(widget->terminal,widget->selected,&clr); | ||
156 | + v3270_reload(widget->terminal); | ||
157 | + v3270_color_scheme_set_rgba(widget->colors.scheme,v3270_get_color_table(widget->terminal)); | ||
158 | + gtk_widget_queue_draw(widget->terminal); | ||
159 | + | ||
160 | + } | ||
161 | +#endif // GTK_CHECK_VERSION | ||
162 | + | ||
163 | + static void color_selected(GtkTreeSelection *selection, V3270ColorSelection *widget) | ||
164 | + { | ||
165 | + GValue value = { 0, }; | ||
166 | + GtkTreeModel * model; | ||
167 | + GtkTreeIter iter; | ||
168 | + | ||
169 | + if(!gtk_tree_selection_get_selected(selection,&model,&iter)) | ||
170 | + return; | ||
171 | + | ||
172 | + gtk_tree_model_get_value(model,&iter,1,&value); | ||
173 | + | ||
174 | + update_color_chooser(widget,g_value_get_int(&value)); | ||
175 | + | ||
176 | + } | ||
177 | + | ||
86 | 178 | ||
87 | static void V3270ColorSelection_init(V3270ColorSelection *widget) | 179 | static void V3270ColorSelection_init(V3270ColorSelection *widget) |
88 | { | 180 | { |
@@ -105,7 +197,7 @@ static void color_scheme_changed(GtkWidget G_GNUC_UNUSED(*dunno), const GdkRGBA | @@ -105,7 +197,7 @@ static void color_scheme_changed(GtkWidget G_GNUC_UNUSED(*dunno), const GdkRGBA | ||
105 | // Setup selection mode. | 197 | // Setup selection mode. |
106 | GtkTreeSelection * select = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget->colors.view)); | 198 | GtkTreeSelection * select = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget->colors.view)); |
107 | gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE); | 199 | gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE); |
108 | - // g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(color_selected),widget); | 200 | + g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(color_selected),widget); |
109 | 201 | ||
110 | // Put the view inside a scrolled window. | 202 | // Put the view inside a scrolled window. |
111 | GtkWidget * box = gtk_scrolled_window_new(NULL,NULL); | 203 | GtkWidget * box = gtk_scrolled_window_new(NULL,NULL); |
@@ -123,18 +215,20 @@ static void color_scheme_changed(GtkWidget G_GNUC_UNUSED(*dunno), const GdkRGBA | @@ -123,18 +215,20 @@ static void color_scheme_changed(GtkWidget G_GNUC_UNUSED(*dunno), const GdkRGBA | ||
123 | { | 215 | { |
124 | // Create color chooser widget | 216 | // Create color chooser widget |
125 | widget->colors.chooser = gtk_color_chooser_widget_new(); | 217 | widget->colors.chooser = gtk_color_chooser_widget_new(); |
126 | - // gtk_widget_set_sensitive(widget->colors.chooser,0); | ||
127 | - // g_signal_connect(G_OBJECT(widget->colors.chooser),"color-activated",G_CALLBACK(color_activated),widget); | 218 | + |
219 | + gtk_widget_set_sensitive(widget->colors.chooser,0); | ||
220 | + g_signal_connect(G_OBJECT(widget->colors.chooser),"color-activated",G_CALLBACK(color_activated),widget); | ||
128 | 221 | ||
129 | gtk_grid_attach(GTK_GRID(widget),widget->colors.chooser,1,0,5,5); | 222 | gtk_grid_attach(GTK_GRID(widget),widget->colors.chooser,1,0,5,5); |
130 | } | 223 | } |
131 | #else | 224 | #else |
132 | { | 225 | { |
133 | widget->colors.editor = gtk_color_selection_new(); | 226 | widget->colors.editor = gtk_color_selection_new(); |
134 | - gtk_widget_set_sensitive(widget->colors.editor,0); | ||
135 | gtk_color_selection_set_has_opacity_control(GTK_COLOR_SELECTION(widget->colors.editor),FALSE); | 227 | gtk_color_selection_set_has_opacity_control(GTK_COLOR_SELECTION(widget->colors.editor),FALSE); |
136 | gtk_color_selection_set_has_palette(GTK_COLOR_SELECTION(widget->colors.editor),TRUE); | 228 | gtk_color_selection_set_has_palette(GTK_COLOR_SELECTION(widget->colors.editor),TRUE); |
137 | - // g_signal_connect(G_OBJECT(widget->colors.editor),"color-changed",G_CALLBACK(color_changed),widget); | 229 | + |
230 | + gtk_widget_set_sensitive(widget->colors.editor,0); | ||
231 | + g_signal_connect(G_OBJECT(widget->colors.editor),"color-changed",G_CALLBACK(color_changed),widget); | ||
138 | 232 | ||
139 | gtk_grid_attach(GTK_GRID(widget),widget->colors.editor,1,0,5,5); | 233 | gtk_grid_attach(GTK_GRID(widget),widget->colors.editor,1,0,5,5); |
140 | } | 234 | } |
src/dialogs/colorscheme.c
@@ -288,12 +288,13 @@ | @@ -288,12 +288,13 @@ | ||
288 | else | 288 | else |
289 | { | 289 | { |
290 | gchar **group = g_key_file_get_groups(conf,&len); | 290 | gchar **group = g_key_file_get_groups(conf,&len); |
291 | + GtkTreeIter iter; | ||
292 | + | ||
291 | GTK_V3270_COLOR_SCHEME(widget)->schemes = g_new0(GdkRGBA,(len*V3270_COLOR_COUNT)); | 293 | GTK_V3270_COLOR_SCHEME(widget)->schemes = g_new0(GdkRGBA,(len*V3270_COLOR_COUNT)); |
292 | 294 | ||
293 | for(g=0;g<len;g++) | 295 | for(g=0;g<len;g++) |
294 | { | 296 | { |
295 | // Setup colors for current entry | 297 | // Setup colors for current entry |
296 | - GtkTreeIter iter; | ||
297 | GdkRGBA * clr = GTK_V3270_COLOR_SCHEME(widget)->schemes+index; | 298 | GdkRGBA * clr = GTK_V3270_COLOR_SCHEME(widget)->schemes+index; |
298 | const gchar * label = g_key_file_get_locale_string(conf,group[g],"label",NULL,NULL); | 299 | const gchar * label = g_key_file_get_locale_string(conf,group[g],"label",NULL,NULL); |
299 | 300 | ||
@@ -327,6 +328,7 @@ | @@ -327,6 +328,7 @@ | ||
327 | { | 328 | { |
328 | if(!gdk_rgba_equal(colora+f,colorb+f)) | 329 | if(!gdk_rgba_equal(colora+f,colorb+f)) |
329 | { | 330 | { |
331 | +/* | ||
330 | #ifdef DEBUG | 332 | #ifdef DEBUG |
331 | v3270_autofree gchar * cla = gdk_rgba_to_string(colora+f); | 333 | v3270_autofree gchar * cla = gdk_rgba_to_string(colora+f); |
332 | v3270_autofree gchar * clb = gdk_rgba_to_string(colorb+f); | 334 | v3270_autofree gchar * clb = gdk_rgba_to_string(colorb+f); |
@@ -339,6 +341,7 @@ | @@ -339,6 +341,7 @@ | ||
339 | clb | 341 | clb |
340 | ); | 342 | ); |
341 | #endif // DEBUG | 343 | #endif // DEBUG |
344 | +*/ | ||
342 | return FALSE; | 345 | return FALSE; |
343 | } | 346 | } |
344 | } | 347 | } |
@@ -358,6 +361,8 @@ | @@ -358,6 +361,8 @@ | ||
358 | 361 | ||
359 | gtk_tree_model_get_value(gtk_combo_box_get_model(GTK_COMBO_BOX(widget)),&iter,1,&value); | 362 | gtk_tree_model_get_value(gtk_combo_box_get_model(GTK_COMBO_BOX(widget)),&iter,1,&value); |
360 | clr = g_value_get_pointer(&value); | 363 | clr = g_value_get_pointer(&value); |
364 | + if(!clr) | ||
365 | + return g_strdup(""); | ||
361 | 366 | ||
362 | GString *str = g_string_new(""); | 367 | GString *str = g_string_new(""); |
363 | for(f=0;f<V3270_COLOR_COUNT;f++) | 368 | for(f=0;f<V3270_COLOR_COUNT;f++) |
@@ -388,17 +393,17 @@ | @@ -388,17 +393,17 @@ | ||
388 | gtk_tree_model_get_value(model,&iter,1,&value); | 393 | gtk_tree_model_get_value(model,&iter,1,&value); |
389 | clr = g_value_get_pointer(&value); | 394 | clr = g_value_get_pointer(&value); |
390 | 395 | ||
391 | -// debug("%p",clr); | ||
392 | - | ||
393 | if(clr && compare_colors(clr,colors)) | 396 | if(clr && compare_colors(clr,colors)) |
394 | { | 397 | { |
395 | gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widget),&iter); | 398 | gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widget),&iter); |
396 | - break; | 399 | + return; |
397 | } | 400 | } |
398 | 401 | ||
399 | } while(gtk_tree_model_iter_next(model,&iter)); | 402 | } while(gtk_tree_model_iter_next(model,&iter)); |
400 | } | 403 | } |
401 | 404 | ||
405 | + debug("%s: Can't identify color scheme", __FUNCTION__); | ||
406 | + gtk_combo_box_set_active(GTK_COMBO_BOX(widget),-1); | ||
402 | 407 | ||
403 | } | 408 | } |
404 | 409 |
src/trace/trace.c
@@ -43,7 +43,7 @@ | @@ -43,7 +43,7 @@ | ||
43 | #include <syslog.h> | 43 | #include <syslog.h> |
44 | #endif // HAVE_SYSLOG | 44 | #endif // HAVE_SYSLOG |
45 | 45 | ||
46 | -//#pragma GCC diagnostic ignored "-Wdeprecated-declarations" | 46 | +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
47 | 47 | ||
48 | /*--[ Widget definition ]----------------------------------------------------------------------------*/ | 48 | /*--[ Widget definition ]----------------------------------------------------------------------------*/ |
49 | 49 |