[evolution-patches] parse_color cleanup
- From: Larry Ewing <lewing ximian com>
- To: patches <evolution-patches ximian com>
- Subject: [evolution-patches] parse_color cleanup
- Date: Fri, 26 Mar 2004 09:29:51 -0600
Rodo has already fixed the actual bug this was a partial patch for but
this removed the c&p duplicate function that was responsible for part of
the problem.
--Larry
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.1954
diff -u -p -r1.1954 ChangeLog
--- ChangeLog 26 Mar 2004 15:12:25 -0000 1.1954
+++ ChangeLog 26 Mar 2004 17:29:47 -0000
@@ -1,3 +1,11 @@
+2004-03-26 Larry Ewing <lewing ximian com>
+
+ * htmlengine.c: replace all parse_color calls with
+ html_parse_color. Remove duplicate parse_color definition.
+
+ * htmlstyle.c: replace all parse_color calls with
+ html_parse_color.
+
2004-03-26 Radek Doulik <rodo ximian com>
* htmlstyle.c (parse_color): do not copy more than 7 bytes which
Index: htmlstyle.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlstyle.c,v
retrieving revision 1.17
diff -u -p -r1.17 htmlstyle.c
--- htmlstyle.c 26 Mar 2004 15:12:25 -0000 1.17
+++ htmlstyle.c 26 Mar 2004 17:29:47 -0000
@@ -23,9 +23,9 @@
#include "htmlstyle.h"
/* Color handling. */
-static gboolean
-parse_color (const gchar *text,
- GdkColor *color)
+gboolean
+html_parse_color (const gchar *text,
+ GdkColor *color)
{
gchar c [8];
gint len = strlen (text);
@@ -321,7 +321,7 @@ html_style_add_attribute (HTMLStyle *sty
if (!strncasecmp ("color: ", text, 7)) {
GdkColor color;
- if (parse_color (g_strstrip (text + 7), &color)) {
+ if (html_parse_color (g_strstrip (text + 7), &color)) {
HTMLColor *hc = html_color_new_from_gdk_color (&color);
style = html_style_add_color (style, hc);
html_color_unref (hc);
@@ -330,7 +330,7 @@ html_style_add_attribute (HTMLStyle *sty
} else if (!strncasecmp ("background: ", text, 12)) {
GdkColor color;
- if (parse_color (text + 12, &color)) {
+ if (html_parse_color (text + 12, &color)) {
HTMLColor *hc = html_color_new_from_gdk_color (&color);
style = html_style_add_background_color (style, hc);
html_color_unref (hc);
@@ -338,7 +338,7 @@ html_style_add_attribute (HTMLStyle *sty
} else if (!strncasecmp ("background-color: ", text, 18)) {
GdkColor color;
- if (parse_color (text + 18, &color)) {
+ if (html_parse_color (text + 18, &color)) {
HTMLColor *hc = html_color_new_from_gdk_color (&color);
style = html_style_add_background_color (style, hc);
html_color_unref (hc);
Index: htmlengine.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine.c,v
retrieving revision 1.594
diff -u -p -r1.594 htmlengine.c
--- htmlengine.c 25 Mar 2004 19:57:30 -0000 1.594
+++ htmlengine.c 26 Mar 2004 17:29:48 -0000
@@ -406,32 +406,6 @@ free_element (gpointer data)
#define DI(x)
-/* Color handling. */
-static gboolean
-parse_color (const gchar *text,
- GdkColor *color)
-{
- gchar c [8];
- gint len = strlen (text);
-
- if (gdk_color_parse (text, color))
- return TRUE;
-
- c [7] = 0;
- if (*text != '#') {
- c[0] = '#';
- strncpy (c + 1, text, 6);
- len++;
- } else {
- strncpy (c, text, 7);
- }
-
- if (len < 7)
- memset (c + len, '\0', 7-len);
-
- return gdk_color_parse (c, color);
-}
-
static HTMLColor *
current_color (HTMLEngine *e) {
HTMLElement *span;
@@ -1970,7 +1944,7 @@ element_parse_body (HTMLEngine *e, HTMLO
if (strncasecmp (token, "bgcolor=", 8) == 0) {
gtk_html_debug_log (e->widget, "setting color\n");
- if (parse_color (token + 8, &color)) {
+ if (html_parse_color (token + 8, &color)) {
gtk_html_debug_log (e->widget, "bgcolor is set\n");
html_colorset_set_color (e->settings->color_set, &color, HTMLBgColor);
} else {
@@ -1988,22 +1962,22 @@ element_parse_body (HTMLEngine *e, HTMLO
g_free (bgurl);
} else if ( strncasecmp( token, "text=", 5 ) == 0
&& !e->defaultSettings->forceDefault ) {
- if (parse_color (token + 5, &color)) {
+ if (html_parse_color (token + 5, &color)) {
html_colorset_set_color (e->settings->color_set, &color, HTMLTextColor);
push_element (e, ID_BODY, NULL,
html_style_add_color (NULL, html_colorset_get_color (e->settings->color_set, HTMLTextColor)));
}
} else if ( strncasecmp( token, "link=", 5 ) == 0
&& !e->defaultSettings->forceDefault ) {
- parse_color (token + 5, &color);
+ html_parse_color (token + 5, &color);
html_colorset_set_color (e->settings->color_set, &color, HTMLLinkColor);
} else if ( strncasecmp( token, "vlink=", 6 ) == 0
&& !e->defaultSettings->forceDefault ) {
- parse_color (token + 6, &color);
+ html_parse_color (token + 6, &color);
html_colorset_set_color (e->settings->color_set, &color, HTMLVLinkColor);
} else if ( strncasecmp( token, "alink=", 6 ) == 0
&& !e->defaultSettings->forceDefault ) {
- parse_color (token + 6, &color);
+ html_parse_color (token + 6, &color);
html_colorset_set_color (e->settings->color_set, &color, HTMLALinkColor);
} else if ( strncasecmp( token, "leftmargin=", 11 ) == 0) {
e->leftBorder = atoi (token + 11);
@@ -3013,7 +2987,7 @@ element_parse_table (HTMLEngine *e, HTML
&& !e->defaultSettings->forceDefault) {
GdkColor color;
- if (parse_color (value, &color)) {
+ if (html_parse_color (value, &color)) {
HTMLColor *hcolor = html_color_new_from_gdk_color (&color);
element->style = html_style_add_background_color (element->style, hcolor);
html_color_unref (hcolor);
@@ -3143,7 +3117,7 @@ element_parse_tr (HTMLEngine *e, HTMLObj
if (html_element_get_attr (element, "bgcolor", &value)) {
GdkColor color;
- if (parse_color (value, &color)) {
+ if (html_parse_color (value, &color)) {
HTMLColor *hcolor = html_color_new_from_gdk_color (&color);
element->style = html_style_add_background_color (element->style, hcolor);
html_color_unref (hcolor);
@@ -3247,7 +3221,7 @@ element_parse_cell (HTMLEngine *e, HTMLO
if (html_element_get_attr (element, "bgcolor", &value)) {
GdkColor color;
- if (parse_color (value, &color)) {
+ if (html_parse_color (value, &color)) {
HTMLColor *hcolor = html_color_new_from_gdk_color (&color);
element->style = html_style_add_background_color (element->style, hcolor);
html_color_unref (hcolor);
@@ -3511,7 +3485,7 @@ element_parse_font (HTMLEngine *e, HTMLO
if (html_element_get_attr (element, "color", &value)) {
GdkColor color;
- if (parse_color (value, &color)) {
+ if (html_parse_color (value, &color)) {
HTMLColor *html_color = NULL;
html_color = html_color_new_from_gdk_color (&color);
Index: htmlstyle.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlstyle.h,v
retrieving revision 1.8
diff -u -p -r1.8 htmlstyle.h
--- htmlstyle.h 30 Sep 2003 01:21:09 -0000 1.8
+++ htmlstyle.h 26 Mar 2004 17:29:48 -0000
@@ -109,4 +109,6 @@ HTMLStyle *html_style_add_width
HTMLStyle *html_style_add_height (HTMLStyle *style, char *height);
void html_style_free (HTMLStyle *style);
+gboolean html_parse_color (const gchar *text, GdkColor *color);
+
#endif /* __HTML_COLOR_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]