Re: [PATCHES] Implement monitor labeling in the RANDR code



On Tue, 2008-08-19 at 11:45 -0400, Matthias Clasen wrote:
> On Tue, Aug 19, 2008 at 11:32 AM, Federico Mena Quintero
> > In GTK+ 2.10 we got the wonderfully obscure and underused
> > gtk_style_lookup_color() and color expressions in gtkrc files (e.g. so
> > you can do gtk_style_lookup_color (style, "spellcheck_squiggle")), but
> > so far these have been useless for color-coding arbitrary elements of
> > the GUI.  Maybe one could build a little API on top of these
> > (interpolate across several well-known symbolic color names?) to get
> > palettes suitable for color-coding.
> >
> 
> Why are they useless ? What api on top do you need ?

They are useless for the display capplet because it wants an API to

	"I have $small_number of items, and I want to color-code them.
	Give me the colors; I don't really care what they are.  I'll
	slap some text on top of those colors, so preferably give me
	colors that will look good with text in style->fg[NORMAL],
	or give me suitable text colors as well."

Okay, maybe that's an i_am_lazy_please_do_my_work_for_me() kind of API
request, but I'd say *that's* the kind of API that many apps could find
useful :)

gtk_style_lookup_color() wants me to feed it color names, which (AFAIK)
are in none of the released themes yet.

GTK+ could provide some well-known color names:

	# Stock palette for cute and cuddly pastels
	color["palette0"] = mix (0.66, "white", "red")
	color["palette1"] = mix (0.66, "white", "yellow")
	color["palette2"] = mix (0.66, "white", "green")
	color["palette3"] = mix (0.66, "white", "cyan")
	color["palette4"] = mix (0.66, "white", "blue")

	# Text colors that will look good on top of that palette
	color["text-palette0"] = "black"
	color["text-palette1"] = "black"
	color["text-palette2"] = "black"
	color["text-palette3"] = "black"
	color["text-palette4"] = "black"

And then something like

#define NUM_PALETTE_ELEMENTS 5   /* number of pre-defined colors */

static GdkColor
well_known_color (style, prefix, n)
{
  name = prefix + stringify (n);
  return gtk_style_lookup_color (style, name);
}

void
gtk_make_palette (style, num_elements, out_colors, out_text_colors)
{
  *out_colors = g_new (GdkColor, num_elements);

  if (num_elements <= NUM_PALETTE_ELEMENTS) {
    for (i = 0; i < num_elements; i++)
      (*out_colors)[i] = well_known_color(style, "palette", i);
      (*out_text_colors)[i] = well_known_color(style, "text-palette", i);
  } else {
    interpolate_across_well_known_colors (num_elements);
  }
}

I.e. if the user requests less colors in the palette than the number of
predefined colors, just return the first N of those.  Otherwise,
interpolate across them.

Then, we could have a11y themes override the stock palette with
somethine friendlier to color-blind schemes, or high/low contrast ones.

  Federico



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]