6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
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 BLACK = { 0, 0, 0, 0 };
44 /* Initialize the colors */
48 gboolean got_white, got_black;
50 sys_cmap = gdk_colormap_get_system();
52 /* Allocate "constant" colors. */
53 got_white = get_color(&WHITE);
54 got_black = get_color(&BLACK);
59 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
60 "Could not allocate colors black or white.");
62 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
63 "Could not allocate color white.");
66 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
67 "Could not allocate color black.");
71 /* allocate a color from the color map */
73 get_color(GdkColor *new_color)
78 if (!gdk_colormap_alloc_color (sys_cmap, new_color, FALSE,
80 pv = gdk_visual_get_best();
81 if (!(our_cmap = gdk_colormap_new(pv, TRUE))) {
82 simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
83 "Could not create new colormap");
88 return (gdk_colormap_alloc_color(our_cmap, new_color, FALSE, TRUE));
92 color_t_to_gdkcolor(GdkColor *target, color_t *source)
94 target->pixel = source->pixel;
95 target->red = source->red;
96 target->green = source->green;
97 target->blue = source->blue;
101 gdkcolor_to_color_t(color_t *target, GdkColor *source)
103 target->pixel = source->pixel;
104 target->red = source->red;
105 target->green = source->green;
106 target->blue = source->blue;