Mercurial > pidgin
changeset 14333:cf8d25072151
[gaim-migrate @ 17029]
add font-weight support to gtkimhtml
use it in our outgoing text
closes sf 1083365
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Fri, 25 Aug 2006 16:42:38 +0000 |
parents | af0d0e23b937 |
children | 17eba43f98a9 |
files | gtk/gtkimhtml.c gtk/gtkimhtml.h libgaim/util.c |
diffstat | 3 files changed, 48 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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 {
--- 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, "<b>", 3) || !g_ascii_strncasecmp(c, "<bold>", strlen("<bold>"))) { + 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, "<span style='font-weight: bold;'>"); + continue; + } if(!g_ascii_strncasecmp(c, "<u>", 3) || !g_ascii_strncasecmp(c, "<underline>", strlen("<underline>"))) { struct gaim_parse_tag *pt = g_new0(struct gaim_parse_tag, 1); pt->src_tag = *(c+2) == '>' ? "u" : "underline";