Re: GdkRGB, function names



On 2 Jul 2000, Owen Taylor wrote:

> 
> I'm having a bit of a mental block for coming up with good function
> names for a few functions dealing with allocating colors via GdkRGB.
> So, I thought I'd ask for suggestions.
> 
> Here are the descriptions of the functions and some possibilities:
> 
>  1) A function to take a GdkColormap and GdkColor and fill in the
>     pixel field using GdkRGB. (It will never allocate a color just for
>     this color, but for a pseudo-color visual, it will result in a
>     color-cube being permanently allocated in the colormap.)
> 
>     void gdk_rgb_find_color (GdkColormap *colormap, GdkColor *color);
>     void gdk_rgb_fill_color (GdkColormap *colormap, GdkColor *color);
>     void gdk_colormap_find_color (GdkColormap *colormap, GdkColor *color);
>     void gdk_colormap_alloc_rgb_color (GdkColormap *colormap, GdkColor *color);

hm, thinking aboutit, "find" is probably the best name, since you
sometimes don't fill in the pixel value...

>  2) Functions to set the foreground or background of a GC using
>     the colormap stored in the GC, the above function and a 
>     unallocated GdkColor:
> 
>     (Note that gdk_gc_set_foreground() exists and takes an allocated
>     color.)
> 
>     void gdk_rgb_gc_set_fg_color (GdkGC *gc, GdkColor *color);
>     void gdk_gc_set_fg_color (GdkGC *gc, GdkColor *color);
>     void gdk_gc_set_rgb_fg_color (GdkGC *gc, GdkColor *color);
>     void gdk_gc_find_fg_gc (GdkGC *gc, GdkColor *color);
>     void gdk_gc_set_fg_color (GdkGC *gc, GdkColor *color, gboolean allocated);

uhm, in general we try to not shuffle around allocated colors in
our API. of course gdk_gc_set_foreground() is there for use with
realized style colors, so it does make sense here.
however, i don't quite get why this function would use gdk_rgb_find_color(),
that means the gc may end up with an unallocated foreground color (or
the previous value)?
shouldn't we force-allocate the color if gdk_rgb_find_color() failed,
and simply call this gdk_gc_set_fg_color (GdkGC *, GdkColor *) then?

> 
> Regards,
>                                         Owen
> 

---
ciaoTJ





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