src/gtkutils.c

changeset 11549
52fcf3991c92
parent 11525
1d06283bdcc9
child 11632
3ebaf106e56a
equal deleted inserted replaced
11548:a6da5e2af5b3 11549:52fcf3991c92
827 return FALSE; 827 return FALSE;
828 } 828 }
829 829
830 char *stylize(const gchar *text, int length) 830 char *stylize(const gchar *text, int length)
831 { 831 {
832 char *tmp;
832 gchar *buf; 833 gchar *buf;
833 char *tmp = g_malloc(length); 834 const char *font;
834 835 GdkColor fg_color, bg_color;
836
837 tmp = g_malloc(length);
835 buf = g_malloc(length); 838 buf = g_malloc(length);
836 g_snprintf(buf, length, "%s", text); 839 g_snprintf(buf, length, "%s", text);
837 840
838 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_formatting")) { 841 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold"))
839 const char *font; 842 {
840 GdkColor fg_color, bg_color; 843 g_snprintf(tmp, length, "<B>%s</B>", buf);
841
842 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold")) {
843 g_snprintf(tmp, length, "<B>%s</B>", buf);
844 strcpy(buf, tmp);
845 }
846
847 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic")) {
848 g_snprintf(tmp, length, "<I>%s</I>", buf);
849 strcpy(buf, tmp);
850 }
851
852 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline")) {
853 g_snprintf(tmp, length, "<U>%s</U>", buf);
854 strcpy(buf, tmp);
855 }
856
857 font = gaim_prefs_get_string("/gaim/gtk/conversations/font_face");
858
859 if (strcmp(font, "") != 0) {
860 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", font, buf);
861 strcpy(buf, tmp);
862 }
863
864 g_snprintf(tmp, length, "<FONT SIZE=\"%d\">%s</FONT>",
865 gaim_prefs_get_int("/gaim/gtk/conversations/font_size"), buf);
866 strcpy(buf, tmp); 844 strcpy(buf, tmp);
867 845 }
868 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) 846
869 { 847 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic"))
870 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), 848 {
871 &fg_color); 849 g_snprintf(tmp, length, "<I>%s</I>", buf);
872 850 strcpy(buf, tmp);
873 g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>", 851 }
874 fg_color.red/256, fg_color.green/256, 852
875 fg_color.blue/256, buf); 853 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline"))
876 strcpy(buf, tmp); 854 {
877 } 855 g_snprintf(tmp, length, "<U>%s</U>", buf);
878 856 strcpy(buf, tmp);
879 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) 857 }
880 { 858
881 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), 859 font = gaim_prefs_get_string("/gaim/gtk/conversations/font_face");
882 &bg_color); 860
883 861 if (strcmp(font, "") != 0)
884 g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>", 862 {
885 bg_color.red/256, bg_color.green/256, 863 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", font, buf);
886 bg_color.blue/256, buf); 864 strcpy(buf, tmp);
887 strcpy(buf, tmp); 865 }
888 } 866
889 867 g_snprintf(tmp, length, "<FONT SIZE=\"%d\">%s</FONT>",
868 gaim_prefs_get_int("/gaim/gtk/conversations/font_size"), buf);
869 strcpy(buf, tmp);
870
871 if (strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0)
872 {
873 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"),
874 &fg_color);
875
876 g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>",
877 fg_color.red/256, fg_color.green/256,
878 fg_color.blue/256, buf);
879 strcpy(buf, tmp);
880 }
881
882 if (strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0)
883 {
884 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"),
885 &bg_color);
886
887 g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>",
888 bg_color.red/256, bg_color.green/256,
889 bg_color.blue/256, buf);
890 strcpy(buf, tmp);
890 } 891 }
891 892
892 g_free(tmp); 893 g_free(tmp);
893 return buf; 894 return buf;
894 } 895 }

mercurial