Updated Esperanto translation
[gtkhtml.git] / gtkhtml / htmlcolor.c
blobb9b05bf49264e91f6a49952f5dd7866313a8c0fd
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* This file is part of the GtkHTML library.
4 * Copyright (C) 2000 Helix Code, Inc.
5 * Authors: Radek Doulik (rodo@helixcode.com)
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #include <config.h>
26 #include "htmlcolor.h"
27 #include "htmlpainter.h"
29 HTMLColor *
30 html_color_new (void)
32 HTMLColor *nc = g_new0 (HTMLColor, 1);
34 nc->refcount = 1;
36 return nc;
39 HTMLColor *
40 html_color_new_from_gdk_color (const GdkColor *color)
42 HTMLColor *nc = html_color_new ();
44 nc->color = *color;
46 return nc;
49 HTMLColor *
50 html_color_new_from_rgb (gushort red,
51 gushort green,
52 gushort blue)
54 HTMLColor *nc = html_color_new ();
56 nc->color.red = red;
57 nc->color.green = green;
58 nc->color.blue = blue;
60 return nc;
63 void
64 html_color_ref (HTMLColor *color)
66 g_assert (color);
68 color->refcount++;
71 void
72 html_color_unref (HTMLColor *color)
74 g_assert (color);
75 g_assert (color->refcount > 0);
77 color->refcount--;
79 if (!color->refcount) {
80 /* if (color->allocated)
81 * g_warning ("FIXME, color free\n"); */
82 /* FIXME commented out to catch g_asserts on refcount so we could hunt "too much unrefs" bugs */
83 g_free (color);
87 void
88 html_color_alloc (HTMLColor *color,
89 HTMLPainter *painter)
91 g_assert (color);
93 if (!color->allocated) {
94 html_painter_alloc_color (painter, &color->color);
95 color->allocated = TRUE;
99 gboolean
100 html_color_equal (HTMLColor *color1,
101 HTMLColor *color2)
103 if (color1 == color2)
104 return TRUE;
105 if (!color1 || !color2)
106 return FALSE;
108 return gdk_color_equal (&color1->color, &color2->color);
111 void
112 html_color_set (HTMLColor *color,
113 GdkColor *c)
115 /* if (color->allocated)
116 * g_warning ("FIXME, color free\n"); */
117 color->allocated = FALSE;
118 color->color = *c;