diff options
Diffstat (limited to 'widgets/misc/e-colors.c')
-rw-r--r-- | widgets/misc/e-colors.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/widgets/misc/e-colors.c b/widgets/misc/e-colors.c index ba86538dab..0a376262a4 100644 --- a/widgets/misc/e-colors.c +++ b/widgets/misc/e-colors.c @@ -1,74 +1,75 @@ /* - * color.c: Color allocation on the Gnumeric spreadsheet + * e_color.c: General color allocation utilities * * Author: * Miguel de Icaza (miguel@kernel.org) * * We keep our own color context, as the color allocation might take place - * before any of our Canvases are realized. + * before things are realized. */ #include <config.h> #include <gnome.h> -#include "color.h" +#include "e-colors.h" -static int color_inited; -static GdkColorContext *gnumeric_color_context; +static gboolean e_color_inited; +static GdkColorContext *e_color_context; -/* Public colors: shared by all of our items in Gnumeric */ -GdkColor gs_white, gs_black, gs_light_gray, gs_dark_gray, gs_red, gs_lavender; +GdkColor gs_white, gs_dark_gray, gs_black; int -color_alloc (gushort red, gushort green, gushort blue) +e_color_alloc (gushort red, gushort green, gushort blue) { int failed; - if (!color_inited) - color_init (); + if (!e_color_inited) + e_color_init (); - return gdk_color_context_get_pixel (gnumeric_color_context, + return gdk_color_context_get_pixel (e_color_context, red, green, blue, &failed); } void -color_alloc_gdk (GdkColor *c) +e_color_alloc_gdk (GdkColor *c) { int failed; g_return_if_fail (c != NULL); - c->pixel = gdk_color_context_get_pixel (gnumeric_color_context, c->red, c->green, c->blue, &failed); + if (!e_color_inited) + e_color_init (); + + c->pixel = gdk_color_context_get_pixel (e_color_context, c->red, c->green, c->blue, &failed); } void -color_alloc_name (const char *name, GdkColor *c) +e_color_alloc_name (const char *name, GdkColor *c) { int failed; g_return_if_fail (name != NULL); g_return_if_fail (c != NULL); + if (!e_color_inited) + e_color_init (); + gdk_color_parse (name, c); c->pixel = 0; - c->pixel = gdk_color_context_get_pixel (gnumeric_color_context, c->red, c->green, c->blue, &failed); + c->pixel = gdk_color_context_get_pixel (e_color_context, c->red, c->green, c->blue, &failed); } void -color_init (void) +e_color_init (void) { GdkColormap *colormap = gtk_widget_get_default_colormap (); /* Initialize the color context */ - gnumeric_color_context = gdk_color_context_new ( + e_color_context = gdk_color_context_new ( gtk_widget_get_default_visual (), colormap); /* Allocate the default colors */ gdk_color_white (colormap, &gs_white); gdk_color_black (colormap, &gs_black); + e_color_alloc_name ("gray20", &gs_dark_gray); - color_alloc_name ("gray78", &gs_light_gray); - color_alloc_name ("gray20", &gs_dark_gray); - color_alloc_name ("red", &gs_red); - color_alloc_name ("lavender",&gs_lavender); - - color_inited = 1; + e_color_inited = TRUE; } |