6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #include "color.h" /* to declare "color_t" */
35 #include "simple_dialog.h"
36 #include "gtkglobals.h"
38 static GdkColormap* sys_cmap;
39 static GdkColormap* our_cmap = NULL;
41 GdkColor WHITE = { 0, 65535, 65535, 65535 };
42 GdkColor LTGREY = { 0, 57343, 57343, 57343 };
43 GdkColor BLACK = { 0, 0, 0, 0 };
45 /* Initialize the colors */
49 gboolean got_white, got_black;
51 sys_cmap = gdk_colormap_get_system();
53 /* Allocate "constant" colors. */
54 got_white = get_color(&WHITE);
55 got_black = get_color(&BLACK);
60 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
61 "Could not allocate colors black or white.");
63 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
64 "Could not allocate color white.");
67 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
68 "Could not allocate color black.");
72 /* allocate a color from the color map */
74 get_color(GdkColor *new_color)
79 if (!gdk_colormap_alloc_color (sys_cmap, new_color, FALSE,
81 pv = gdk_visual_get_best();
82 if (!(our_cmap = gdk_colormap_new(pv, TRUE))) {
83 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
84 "Could not create new colormap");
89 return (gdk_colormap_alloc_color(our_cmap, new_color, FALSE, TRUE));
93 color_t_to_gdkcolor(GdkColor *target, color_t *source)
95 target->pixel = source->pixel;
96 target->red = source->red;
97 target->green = source->green;
98 target->blue = source->blue;
102 gdkcolor_to_color_t(color_t *target, GdkColor *source)
104 target->pixel = source->pixel;
105 target->red = source->red;
106 target->green = source->green;
107 target->blue = source->blue;