comparison src/conversation.c @ 860:a8633715fb5b

[gaim-migrate @ 870] bgcolors work better. hopefully we can get them to smileys eventually committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 08 Sep 2000 05:05:06 +0000
parents 75172284a1a7
children 00fb90babcb2
comparison
equal deleted inserted replaced
859:75172284a1a7 860:a8633715fb5b
1066 /*------------------------------------------------------------------------*/ 1066 /*------------------------------------------------------------------------*/
1067 /* Takin care of the window.. */ 1067 /* Takin care of the window.. */
1068 /*------------------------------------------------------------------------*/ 1068 /*------------------------------------------------------------------------*/
1069 1069
1070 1070
1071 static GdkPixmap *is_smiley(GtkWidget *window, char *m, int *len) { 1071 static GdkPixmap *is_smiley(GtkWidget *window, char *m, int *len, GdkColor *trans) {
1072 GdkBitmap *mask; 1072 GdkBitmap *mask;
1073 GdkPixmap *face = NULL; 1073 GdkPixmap *face = NULL;
1074 1074
1075 if (strlen(m) < 2) return face; 1075 if (strlen(m) < 2) return face;
1076 *len = 2; 1076 *len = 2;
1077 if ( !strncmp(m, ":)", 2) || 1077 if ( !strncmp(m, ":)", 2) ||
1078 !strncmp(m, "=)", 2)) { 1078 !strncmp(m, "=)", 2)) {
1079 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], smile_xpm); 1079 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, smile_xpm);
1080 } else if (!strncmp(m, ":(", 2) || 1080 } else if (!strncmp(m, ":(", 2) ||
1081 !strncmp(m, "=(", 2)) { 1081 !strncmp(m, "=(", 2)) {
1082 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], sad_xpm); 1082 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, sad_xpm);
1083 } else if (!strncmp(m, ";)", 2)) { 1083 } else if (!strncmp(m, ";)", 2)) {
1084 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], wink_xpm); 1084 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, wink_xpm);
1085 } else if (!strncmp(m, ":p", 2) || 1085 } else if (!strncmp(m, ":p", 2) ||
1086 !strncmp(m, ":P", 2)) { 1086 !strncmp(m, ":P", 2)) {
1087 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], tongue_xpm); 1087 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, tongue_xpm);
1088 } 1088 }
1089 1089
1090 if (face || strlen(m) < 3) return face; 1090 if (face || strlen(m) < 3) return face;
1091 *len = 3; 1091 *len = 3;
1092 if ( !strncmp(m, ":-)", 3)) { 1092 if ( !strncmp(m, ":-)", 3)) {
1093 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], smile_xpm); 1093 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, smile_xpm);
1094 } else if (!strncmp(m, "O-)", 3)) { 1094 } else if (!strncmp(m, "O-)", 3)) {
1095 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], oneeye_xpm); 1095 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, oneeye_xpm);
1096 } else if (!strncmp(m, "C:)", 3)) { 1096 } else if (!strncmp(m, "C:)", 3)) {
1097 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], luke03_xpm); 1097 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, luke03_xpm);
1098 } else if (!strncmp(m, ":-(", 3)) { 1098 } else if (!strncmp(m, ":-(", 3)) {
1099 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], sad_xpm); 1099 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, sad_xpm);
1100 } else if (!strncmp(m, ";-)", 3)) { 1100 } else if (!strncmp(m, ";-)", 3)) {
1101 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], wink_xpm); 1101 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, wink_xpm);
1102 } else if (!strncmp(m, ":-p", 3) || 1102 } else if (!strncmp(m, ":-p", 3) ||
1103 !strncmp(m, ":-P", 3)) { 1103 !strncmp(m, ":-P", 3)) {
1104 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], tongue_xpm); 1104 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, tongue_xpm);
1105 } else if (!strncmp(m, "=-O", 3)) { 1105 } else if (!strncmp(m, "=-O", 3)) {
1106 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], scream_xpm); 1106 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, scream_xpm);
1107 } else if (!strncmp(m, ":-*", 3)) { 1107 } else if (!strncmp(m, ":-*", 3)) {
1108 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], kiss_xpm); 1108 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, kiss_xpm);
1109 } else if (!strncmp(m, ">:o", 3)) { 1109 } else if (!strncmp(m, ">:o", 3)) {
1110 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], yell_xpm); 1110 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, yell_xpm);
1111 } else if (!strncmp(m, "8-)", 3)) { 1111 } else if (!strncmp(m, "8-)", 3)) {
1112 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], smile8_xpm); 1112 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, smile8_xpm);
1113 } else if (!strncmp(m, ":-$", 3)) { 1113 } else if (!strncmp(m, ":-$", 3)) {
1114 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], moneymouth_xpm); 1114 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, moneymouth_xpm);
1115 } else if (!strncmp(m, ":-!", 3)) { 1115 } else if (!strncmp(m, ":-!", 3)) {
1116 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], burp_xpm); 1116 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, burp_xpm);
1117 } else if (!strncmp(m, ":-[", 3)) { 1117 } else if (!strncmp(m, ":-[", 3)) {
1118 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], embarrassed_xpm); 1118 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, embarrassed_xpm);
1119 } else if (!strncmp(m, ":'(", 3)) { 1119 } else if (!strncmp(m, ":'(", 3)) {
1120 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], cry_xpm); 1120 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, cry_xpm);
1121 } else if (!strncmp(m, ":-\\", 3) || 1121 } else if (!strncmp(m, ":-\\", 3) ||
1122 !strncmp(m, ":-/", 3)) { 1122 !strncmp(m, ":-/", 3)) {
1123 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], think_xpm); 1123 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, think_xpm);
1124 } else if (!strncmp(m, ":-X", 3)) { 1124 } else if (!strncmp(m, ":-X", 3)) {
1125 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], crossedlips_xpm); 1125 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, crossedlips_xpm);
1126 } else if (!strncmp(m, ":-D", 3)) { 1126 } else if (!strncmp(m, ":-D", 3)) {
1127 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], bigsmile_xpm); 1127 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, bigsmile_xpm);
1128 } 1128 }
1129 1129
1130 if (face || strlen(m) < 4) return face; 1130 if (face || strlen(m) < 4) return face;
1131 *len = 4; 1131 *len = 4;
1132 if ( !strncmp(m, "O:-)", 4)) { 1132 if ( !strncmp(m, "O:-)", 4)) {
1133 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], angel_xpm); 1133 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, angel_xpm);
1134 } 1134 }
1135 else if (!strncmp(m, "C:-)", 4)) { 1135 else if (!strncmp(m, "C:-)", 4)) {
1136 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], luke03_xpm); 1136 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, luke03_xpm);
1137 } 1137 }
1138 1138
1139 if (face || strlen(m) < 6) return face; 1139 if (face || strlen(m) < 6) return face;
1140 *len = 6; 1140 *len = 6;
1141 if ( !strncmp(m, "&gt;:o", 6)) { 1141 if ( !strncmp(m, "&gt;:o", 6)) {
1142 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->base[GTK_STATE_NORMAL], yell_xpm); 1142 face = gdk_pixmap_create_from_xpm_d(window->window, &mask, trans, yell_xpm);
1143 } 1143 }
1144 1144
1145 return face; 1145 return face;
1146 } 1146 }
1147 1147
1149 { 1149 {
1150 int y = 0; 1150 int y = 0;
1151 char *buf2 = g_strdup(what); 1151 char *buf2 = g_strdup(what);
1152 int i; 1152 int i;
1153 GdkPixmap *face; 1153 GdkPixmap *face;
1154 /* hopefully we can later use this for bgcolors in smileys */
1155 GdkColor *trans = &window->style->base[GTK_STATE_NORMAL];
1154 gboolean in_tag = FALSE; 1156 gboolean in_tag = FALSE;
1155 1157
1156 for (i = 0; i < strlen(what); i++) 1158 for (i = 0; i < strlen(what); i++)
1157 { 1159 {
1158 if (!in_tag) { 1160 if (!in_tag) {
1159 int len; 1161 int len;
1160 if (what[i] == '<') { 1162 if (what[i] == '<') {
1161 buf2[y] = what[i]; 1163 buf2[y] = what[i];
1162 y++; 1164 y++;
1163 in_tag = TRUE; 1165 in_tag = TRUE;
1164 } else if ((face = is_smiley(window, &what[i], &len)) != NULL) { 1166 } else if ((face = is_smiley(window, &what[i], &len, trans)) != NULL) {
1165 buf2[y] = 0; 1167 buf2[y] = 0;
1166 gtk_html_append_text(GTK_HTML(html), buf2, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0); 1168 gtk_html_append_text(GTK_HTML(html), buf2, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0);
1167 gtk_html_add_pixmap(GTK_HTML(html), face, 0, 0); 1169 gtk_html_add_pixmap(GTK_HTML(html), face, 0, 0);
1168 y = 0; 1170 y = 0;
1169 i += len - 1; 1171 i += len - 1;