Commit e51354ffa376419f78c7ee8d027f289427b4b5d0

Authored by Perry Werneck
1 parent fd944146
Exists in master and in 1 other branch develop

Updating color selection dialog.

src/dialogs/colors.c
... ... @@ -31,6 +31,8 @@
31 31 #include <v3270/colorscheme.h>
32 32 #include <lib3270/log.h>
33 33  
  34 + #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  35 +
34 36 /*--[ Widget definition ]----------------------------------------------------------------------------*/
35 37  
36 38 struct _V3270ColorSelectionClass
... ... @@ -43,7 +45,8 @@
43 45 {
44 46 GtkGrid parent;
45 47  
46   - GtkWidget * terminal;
  48 + GtkWidget * terminal;
  49 + int selected;
47 50  
48 51 struct {
49 52 GtkWidget * view;
... ... @@ -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 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 121 for(f=0;f<V3270_COLOR_COUNT;f++)
80 122 v3270_set_color(widget->terminal,f,colors+f);
81 123  
  124 + update_color_chooser(widget,widget->selected);
  125 +
82 126 v3270_reload(widget->terminal);
83 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 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 197 // Setup selection mode.
106 198 GtkTreeSelection * select = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget->colors.view));
107 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 202 // Put the view inside a scrolled window.
111 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 215 {
124 216 // Create color chooser widget
125 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 222 gtk_grid_attach(GTK_GRID(widget),widget->colors.chooser,1,0,5,5);
130 223 }
131 224 #else
132 225 {
133 226 widget->colors.editor = gtk_color_selection_new();
134   - gtk_widget_set_sensitive(widget->colors.editor,0);
135 227 gtk_color_selection_set_has_opacity_control(GTK_COLOR_SELECTION(widget->colors.editor),FALSE);
136 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 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 288 else
289 289 {
290 290 gchar **group = g_key_file_get_groups(conf,&len);
  291 + GtkTreeIter iter;
  292 +
291 293 GTK_V3270_COLOR_SCHEME(widget)->schemes = g_new0(GdkRGBA,(len*V3270_COLOR_COUNT));
292 294  
293 295 for(g=0;g<len;g++)
294 296 {
295 297 // Setup colors for current entry
296   - GtkTreeIter iter;
297 298 GdkRGBA * clr = GTK_V3270_COLOR_SCHEME(widget)->schemes+index;
298 299 const gchar * label = g_key_file_get_locale_string(conf,group[g],"label",NULL,NULL);
299 300  
... ... @@ -327,6 +328,7 @@
327 328 {
328 329 if(!gdk_rgba_equal(colora+f,colorb+f))
329 330 {
  331 +/*
330 332 #ifdef DEBUG
331 333 v3270_autofree gchar * cla = gdk_rgba_to_string(colora+f);
332 334 v3270_autofree gchar * clb = gdk_rgba_to_string(colorb+f);
... ... @@ -339,6 +341,7 @@
339 341 clb
340 342 );
341 343 #endif // DEBUG
  344 +*/
342 345 return FALSE;
343 346 }
344 347 }
... ... @@ -358,6 +361,8 @@
358 361  
359 362 gtk_tree_model_get_value(gtk_combo_box_get_model(GTK_COMBO_BOX(widget)),&iter,1,&value);
360 363 clr = g_value_get_pointer(&value);
  364 + if(!clr)
  365 + return g_strdup("");
361 366  
362 367 GString *str = g_string_new("");
363 368 for(f=0;f<V3270_COLOR_COUNT;f++)
... ... @@ -388,17 +393,17 @@
388 393 gtk_tree_model_get_value(model,&iter,1,&value);
389 394 clr = g_value_get_pointer(&value);
390 395  
391   -// debug("%p",clr);
392   -
393 396 if(clr && compare_colors(clr,colors))
394 397 {
395 398 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widget),&iter);
396   - break;
  399 + return;
397 400 }
398 401  
399 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 43 #include <syslog.h>
44 44 #endif // HAVE_SYSLOG
45 45  
46   -//#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  46 +#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
47 47  
48 48 /*--[ Widget definition ]----------------------------------------------------------------------------*/
49 49  
... ...