# HG changeset patch # User Nathan Walp # Date 1156524158 0 # Node ID cf8d2507215174b85de679c685db66e5f049af17 # Parent af0d0e23b9375686161a071a6c971e6beae1db0c [gaim-migrate @ 17029] add font-weight support to gtkimhtml use it in our outgoing text closes sf 1083365 committer: Tailor Script diff -r af0d0e23b937 -r cf8d25072151 gtk/gtkimhtml.c --- a/gtk/gtkimhtml.c Fri Aug 25 07:02:17 2006 +0000 +++ b/gtk/gtkimhtml.c Fri Aug 25 16:42:38 2006 +0000 @@ -2773,15 +2773,15 @@ * font-family * font-size * text-decoration: underline + * font-weight: bold * * TODO: * background-color * font-style - * font-weight */ { gchar *style, *color, *background, *family, *size; - gchar *textdec; + gchar *textdec, *weight; GtkIMHtmlFontDetail *font, *oldfont = NULL; style = gtk_imhtml_get_html_opt (tag, "style="); @@ -2793,8 +2793,9 @@ "font-family:"); size = gtk_imhtml_get_css_opt (style, "font-size:"); textdec = gtk_imhtml_get_css_opt (style, "text-decoration:"); - - if (!(color || family || size || background || textdec)) { + weight = gtk_imhtml_get_css_opt (style, "font-weight:"); + + if (!(color || family || size || background || textdec || weight)) { g_free(style); break; } @@ -2879,6 +2880,34 @@ font->underline = 1; } + if (oldfont) + { + font->bold = oldfont->bold; + } + if (weight) + { + if(!g_ascii_strcasecmp(weight, "normal")) { + font->bold = 0; + } else if(!g_ascii_strcasecmp(weight, "bold")) { + font->bold = 1; + } else if(!g_ascii_strcasecmp(weight, "bolder")) { + font->bold++; + } else if(!g_ascii_strcasecmp(weight, "lighter")) { + if(font->bold > 0) + font->bold--; + } else { + int num = atoi(weight); + if(num >= 700) + font->bold = 1; + else + font->bold = 0; + } + if((font->bold && !oldfont->bold) || (oldfont->bold && !font->bold)) + { + gtk_imhtml_toggle_bold(imhtml); + } + } + g_free(style); g_free(size); fonts = g_slist_prepend (fonts, font); @@ -2900,6 +2929,8 @@ gtk_imhtml_font_set_size(imhtml, 3); if (font->underline) gtk_imhtml_toggle_underline(imhtml); + if (font->bold) + gtk_imhtml_toggle_bold(imhtml); gtk_imhtml_toggle_fontface(imhtml, NULL); gtk_imhtml_toggle_forecolor(imhtml, NULL); gtk_imhtml_toggle_backcolor(imhtml, NULL); @@ -2913,6 +2944,9 @@ if (font->underline != oldfont->underline) gtk_imhtml_toggle_underline(imhtml); + if ((font->bold && !oldfont->bold) || (oldfont->bold && !font->bold)) + gtk_imhtml_toggle_bold(imhtml); + if (font->face && (!oldfont->face || strcmp(font->face, oldfont->face) != 0)) gtk_imhtml_toggle_fontface(imhtml, oldfont->face); diff -r af0d0e23b937 -r cf8d25072151 gtk/gtkimhtml.h --- a/gtk/gtkimhtml.h Fri Aug 25 07:02:17 2006 +0000 +++ b/gtk/gtkimhtml.h Fri Aug 25 16:42:38 2006 +0000 @@ -145,6 +145,7 @@ gchar *bg; gchar *sml; gboolean underline; + gshort bold; }; struct _GtkSmileyTree { diff -r af0d0e23b937 -r cf8d25072151 libgaim/util.c --- a/libgaim/util.c Fri Aug 25 07:02:17 2006 +0000 +++ b/libgaim/util.c Fri Aug 25 16:42:38 2006 +0000 @@ -1271,9 +1271,7 @@ } } else { /* opening tag */ ALLOW_TAG("a"); - ALLOW_TAG_ALT("b", "strong"); ALLOW_TAG("blockquote"); - ALLOW_TAG_ALT("bold", "strong"); ALLOW_TAG("cite"); ALLOW_TAG("div"); ALLOW_TAG("em"); @@ -1312,6 +1310,15 @@ plain = g_string_append_c(plain, '\n'); continue; } + if(!g_ascii_strncasecmp(c, "", 3) || !g_ascii_strncasecmp(c, "", strlen(""))) { + struct gaim_parse_tag *pt = g_new0(struct gaim_parse_tag, 1); + pt->src_tag = *(c+2) == '>' ? "b" : "bold"; + pt->dest_tag = "span"; + tags = g_list_prepend(tags, pt); + c = strchr(c, '>') + 1; + xhtml = g_string_append(xhtml, ""); + continue; + } if(!g_ascii_strncasecmp(c, "", 3) || !g_ascii_strncasecmp(c, "", strlen(""))) { struct gaim_parse_tag *pt = g_new0(struct gaim_parse_tag, 1); pt->src_tag = *(c+2) == '>' ? "u" : "underline";