Get rid of the "pixel" member of a color_t.

Now that we're letting GTK+/GDK allocate colors behind the scenes, if it
allocates them at all, there's no reason to save the allocated color in
the toolkit-independent color value.

Change-Id: I99df32bd6b07924f41f3d855d2ddecb3dc8d5201
Reviewed-on: https://code.wireshark.org/review/12983
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2015-12-31 18:04:37 -08:00
parent f7b3bda9b3
commit 93f9416c36
6 changed files with 7 additions and 30 deletions

View File

@ -32,15 +32,8 @@ struct epan_dissect;
/*
* Data structure holding RGB value for a color.
*
* XXX - yes, I know, there's a "pixel" value in there as well; for
* now, it's intended to look just like a GdkColor but not to require
* that any GTK+ header files be included in order to use it.
* The way we handle colors needs to be cleaned up somewhat, in order
* to keep toolkit-specific stuff separate from toolkit-independent stuff.
*/
typedef struct {
guint32 pixel;
guint16 red;
guint16 green;
guint16 blue;

View File

@ -2980,19 +2980,15 @@ pre_init_prefs(void)
/* We try to find the best font in the Qt code */
if (prefs.gui_qt_font_name) g_free(prefs.gui_qt_font_name);
prefs.gui_qt_font_name = g_strdup("");
prefs.gui_marked_fg.pixel = 65535;
prefs.gui_marked_fg.red = 65535;
prefs.gui_marked_fg.green = 65535;
prefs.gui_marked_fg.blue = 65535;
prefs.gui_marked_bg.pixel = 0;
prefs.gui_marked_bg.red = 0;
prefs.gui_marked_bg.green = 8224;
prefs.gui_marked_bg.blue = 10794;
prefs.gui_ignored_fg.pixel = 32767;
prefs.gui_ignored_fg.red = 32767;
prefs.gui_ignored_fg.green = 32767;
prefs.gui_ignored_fg.blue = 32767;
prefs.gui_ignored_bg.pixel = 65535;
prefs.gui_ignored_bg.red = 65535;
prefs.gui_ignored_bg.green = 65535;
prefs.gui_ignored_bg.blue = 65535;
@ -3000,32 +2996,25 @@ pre_init_prefs(void)
prefs.gui_colorized_fg = g_strdup("000000,000000,000000,000000,000000,000000,000000,000000,000000,000000");
if (prefs.gui_colorized_bg) g_free(prefs.gui_colorized_bg);
prefs.gui_colorized_bg = g_strdup("ffc0c0,ffc0ff,e0c0e0,c0c0ff,c0e0e0,c0ffff,c0ffc0,ffffc0,e0e0c0,e0e0e0");
prefs.st_client_fg.pixel = 0;
prefs.st_client_fg.red = 32767;
prefs.st_client_fg.green = 0;
prefs.st_client_fg.blue = 0;
prefs.st_client_bg.pixel = 0;
prefs.st_client_bg.red = 64507;
prefs.st_client_bg.green = 60909;
prefs.st_client_bg.blue = 60909;
prefs.st_server_fg.pixel = 0;
prefs.st_server_fg.red = 0;
prefs.st_server_fg.green = 0;
prefs.st_server_fg.blue = 32767;
prefs.st_server_bg.pixel = 0;
prefs.st_server_bg.red = 60909;
prefs.st_server_bg.green = 60909;
prefs.st_server_bg.blue = 64507;
prefs.gui_text_valid.pixel = 0; /* light green */
prefs.gui_text_valid.red = 0xAFFF;
prefs.gui_text_valid.green = 0xFFFF;
prefs.gui_text_valid.blue = 0xAFFF;
prefs.gui_text_invalid.pixel = 0; /* light red */
prefs.gui_text_invalid.red = 0xFFFF;
prefs.gui_text_valid.red = 0xAFFF; /* light green */
prefs.gui_text_valid.green = 0xFFFF;
prefs.gui_text_valid.blue = 0xAFFF;
prefs.gui_text_invalid.red = 0xFFFF; /* light red */
prefs.gui_text_invalid.green = 0xAFFF;
prefs.gui_text_invalid.blue = 0xAFFF;
prefs.gui_text_deprecated.pixel = 0; /* light yellow */
prefs.gui_text_deprecated.red = 0xFFFF;
prefs.gui_text_deprecated.red = 0xFFFF; /* light yellow */
prefs.gui_text_deprecated.green = 0xFFFF;
prefs.gui_text_deprecated.blue = 0xAFFF;
prefs.gui_geometry_save_position = TRUE;
@ -4438,7 +4427,6 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
case PREF_COLOR:
{
cval = strtoul(value, NULL, 16);
pref->varp.colorp->pixel = 0;
if ((pref->varp.colorp->red != RED_COMPONENT(cval)) ||
(pref->varp.colorp->green != GREEN_COMPONENT(cval)) ||
(pref->varp.colorp->blue != BLUE_COMPONENT(cval))) {

View File

@ -50,7 +50,7 @@ initialize_color(color_t *color, guint16 red, guint16 green, guint16 blue)
void
color_t_to_gdkcolor(GdkColor *target, const color_t *source)
{
target->pixel = source->pixel;
target->pixel = 0;
target->red = source->red;
target->green = source->green;
target->blue = source->blue;
@ -67,7 +67,6 @@ color_t_to_gdkRGBAcolor(GdkRGBA *target, const color_t *source)
void
gdkcolor_to_color_t(color_t *target, const GdkColor *source)
{
target->pixel = source->pixel;
target->red = source->red;
target->green = source->green;
target->blue = source->blue;
@ -76,7 +75,6 @@ gdkcolor_to_color_t(color_t *target, const GdkColor *source)
void
gdkRGBAcolor_to_color_t(color_t *target, const GdkRGBA *source)
{
target->pixel = 0;
target->red = (guint16)(source->red*65535);
target->green = (guint16)(source->green*65535);
target->blue = (guint16)(source->blue*65535);

View File

@ -98,7 +98,7 @@ static void update_font(PangoFontDescription *, GtkWidget *, GtkWidget *);
static void update_text_color(GObject *obj, GParamSpec *pspec, gpointer data);
static void update_current_color(GtkWidget *, gpointer);
static const color_t filter_text_fg_color = {0, 0, 0, 0}; /* black */
static const color_t filter_text_fg_color = {0, 0, 0}; /* black */
static GdkXxx tcolors[MAX_IDX], filter_text_fg, *curcolor = NULL;
#if ! GTK_CHECK_VERSION(3,4,0)

View File

@ -67,7 +67,6 @@ QColor ColorUtils::fromColorT(color_t color)
const color_t ColorUtils::toColorT(const QColor color)
{
color_t colort;
colort.pixel = 0;
colort.red = (color.red() << 8) | color.red();
colort.green = (color.green() << 8) | color.green();
colort.blue = (color.blue() << 8) | color.blue();

View File

@ -454,7 +454,6 @@ initialize_color(color_t *color, guint16 red, guint16 green, guint16 blue)
color->red = red;
color->green = green;
color->blue = blue;
color->pixel = 0;
return TRUE;
}