Commit de623e2209a90e37ba7c6e922008d3829ad8fec4

Authored by perry.werneck@gmail.com
1 parent 83388820

Incluindo dropdown específico quando a lista de cores atual é personalizada

Showing 1 changed file with 28 additions and 2 deletions   Show diff stats
src/pw3270/colors.c
... ... @@ -240,6 +240,7 @@ static void load_color_scheme(GKeyFile *conf, const gchar *group, GdkColor *clr)
240 240 GdkColor * table = g_new0(GdkColor,(len*V3270_COLOR_COUNT));
241 241 int pos = 0;
242 242 int g;
  243 + gboolean found = FALSE;
243 244  
244 245 g_signal_connect(G_OBJECT(widget),"changed",G_CALLBACK(color_scheme_changed),0);
245 246  
... ... @@ -265,15 +266,40 @@ static void load_color_scheme(GKeyFile *conf, const gchar *group, GdkColor *clr)
265 266 // It's the same color, select iter
266 267 trace("Current color scheme is \"%s\"",group[g]);
267 268 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widget),&iter);
  269 + found = TRUE;
268 270 }
269 271  
270 272 // move to next color list
271 273 pos += V3270_COLOR_COUNT;
272 274 }
273 275  
274   -
275 276 g_strfreev(group);
276 277  
  278 + if(!found)
  279 + {
  280 + // Custom color table, save it as a new dropdown entry.
  281 +
  282 + GdkColor * clr = g_new0(GdkColor,V3270_COLOR_COUNT);
  283 + int f;
  284 +
  285 + for(f=0;f<V3270_COLOR_COUNT;f++)
  286 + clr[f] = current[f];
  287 +
  288 + trace("Current color scheme is \"%s\"","custom");
  289 +
  290 + g_object_set_data_full(G_OBJECT(widget),"customcolortable",clr,g_free);
  291 +
  292 + gtk_list_store_append((GtkListStore *) model,&iter);
  293 + gtk_list_store_set((GtkListStore *) model, &iter,
  294 + 0, _( "Custom colors" ),
  295 + 1, clr,
  296 + -1);
  297 +
  298 + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widget),&iter);
  299 +
  300 + }
  301 +
  302 +
277 303 gtk_widget_set_sensitive(widget,TRUE);
278 304 }
279 305  
... ... @@ -395,8 +421,8 @@ static void load_color_scheme(GKeyFile *conf, const gchar *group, GdkColor *clr)
395 421 GtkWidget * color;
396 422 GdkColor saved[V3270_COLOR_COUNT];
397 423  
  424 + // Color dialog setup
398 425 {
399   - // Color dialog setup
400 426 color = gtk_color_selection_new();
401 427 gtk_widget_set_sensitive(color,0);
402 428 gtk_color_selection_set_has_opacity_control(GTK_COLOR_SELECTION(color),FALSE);
... ...