diff options
author | Guy Harris <guy@alum.mit.edu> | 2004-07-24 00:35:13 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2004-07-24 00:35:13 +0000 |
commit | 34de3c15d994d65a99b65d0dd55b0e2208685b3b (patch) | |
tree | 40889b5cba6f301462f8498de380ddf094003047 /gtk/color_utils.c | |
parent | 8f79902cb339f422956fedac39037884ca6c8729 (diff) |
Have "gtk/color_utils.c" contain routines with toolkit-independent APIs,
but toolkit-dependent implementations, for manipulating colors, and have
"gtk/color_utils.h" declare them (the header file should eventually be
moved to the top-level directory). Move the routines to convert between
GdkColor and color_t out of there into "colors.c", and move their
declarations into "colors.h", as their APIs are toolkit-dependent.
Have the first such routine be a "create_color()" routine, which takes
RGB values and initializes a "color_t", including doing any
toolkit-dependent work necessary for that; use that in the
"gtk/color_filters.c" code (the goal is to remove as many of the toolkit
dependencies as possible from that code, and move it to the top-level
directory).
svn path=/trunk/; revision=11497
Diffstat (limited to 'gtk/color_utils.c')
-rw-r--r-- | gtk/color_utils.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/gtk/color_utils.c b/gtk/color_utils.c index 6fca4eadfa..ae72adfa91 100644 --- a/gtk/color_utils.c +++ b/gtk/color_utils.c @@ -1,14 +1,12 @@ /* color_utils.c - * Utilities for converting between "toolkit-independent" and GDK - * notions of color + * Toolkit-dependent implementations of routines to handle colors. * * $Id$ * * Ethereal - Network traffic analyzer - * By Gerald Combs <gerald@zing.org> + * By Gerald Combs <gerald@ethereal.com> * Copyright 1998 Gerald Combs * - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -30,22 +28,25 @@ #include <gtk/gtk.h> -#include "color.h" /* to declare "color_t" */ +#include "color.h" -void -color_t_to_gdkcolor(GdkColor *target, color_t *source) -{ - target->pixel = source->pixel; - target->red = source->red; - target->green = source->green; - target->blue = source->blue; -} +#include "color_utils.h" -void -gdkcolor_to_color_t(color_t *target, GdkColor *source) +/* + * Create a color from R, G, and B values, and do whatever toolkit-dependent + * work needs to be done. + * Returns TRUE if it succeeds, FALSE if it fails. + */ +gboolean +create_color(color_t *color, guint16 red, guint16 green, guint16 blue) { - target->pixel = source->pixel; - target->red = source->red; - target->green = source->green; - target->blue = source->blue; + GdkColor gdk_color; + + gdk_color.red = red; + gdk_color.green = green; + gdk_color.blue = blue; + if (!get_color(&gdk_color)) + return FALSE; + gdkcolor_to_color_t(color, &gdk_color); + return TRUE; } |