Get rid of the "pixel" member of a color_t.
authorGuy Harris <guy@alum.mit.edu>
Fri, 1 Jan 2016 02:04:37 +0000 (18:04 -0800)
committerGuy Harris <guy@alum.mit.edu>
Fri, 1 Jan 2016 02:05:07 +0000 (02:05 +0000)
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>
epan/color_filters.h
epan/prefs.c
ui/gtk/color_utils.c
ui/gtk/prefs_font_color.c
ui/qt/color_utils.cpp
ui/qt/coloring_rules_dialog.cpp

index 2fe8b018cb980fa248e908aebb49bf2ac0e483c0..a240a67862c04d2a6812300b2d6f10f2f76aaefb 100644 (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;
index a15232e78257a4526ab3d1aeb57b8046c7e9a43a..0d8b53fc61655d2bd4f060075a74e9101e7a7533 100644 (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))) {
index 9df4f5b4b33f5646d92e58caab201f7eb4915f8c..65889a2fbfe1b77511400052df59a289b91a5b64 100644 (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);
index fafe0f07b9c7551dabb49fe7072aa88b75043a88..a2486eeea1d9453a9ef588532134ee029cb2d3fd 100644 (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)
index d90d6046f7708f48a09d0911dba1ac4b043b3036..e6576b09386cfa8d977424cacc5cecf4c414a91a 100644 (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();
index 846ff13112bbba36b0c17efe5a8b748b3c0515a8..264cda04d895c6642a333fecee27f82c8100c90c 100644 (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;
 }