| 2197 return NULL; |
2197 return NULL; |
| 2198 |
2198 |
| 2199 return gtk_smiley_get_image(smiley); |
2199 return gtk_smiley_get_image(smiley); |
| 2200 } |
2200 } |
| 2201 |
2201 |
| 2202 #define VALID_TAG(x) if (!g_ascii_strncasecmp (string, x ">", strlen (x ">"))) { \ |
2202 #define VALID_TAG(x) do { \ |
| 2203 *tag = g_strndup (string, strlen (x)); \ |
2203 if (!g_ascii_strncasecmp (string, x ">", strlen (x ">"))) { \ |
| 2204 *len = strlen (x) + 1; \ |
2204 if (tag) *tag = g_strndup (string, strlen (x)); \ |
| |
2205 if (len) *len = strlen (x) + 1; \ |
| 2205 return TRUE; \ |
2206 return TRUE; \ |
| 2206 } \ |
2207 } \ |
| 2207 (*type)++ |
2208 if (type) (*type)++; \ |
| 2208 |
2209 } while (0) |
| 2209 #define VALID_OPT_TAG(x) if (!g_ascii_strncasecmp (string, x " ", strlen (x " "))) { \ |
2210 |
| |
2211 #define VALID_OPT_TAG(x) do { \ |
| |
2212 if (!g_ascii_strncasecmp (string, x " ", strlen (x " "))) { \ |
| 2210 const gchar *c = string + strlen (x " "); \ |
2213 const gchar *c = string + strlen (x " "); \ |
| 2211 gchar e = '"'; \ |
2214 gchar e = '"'; \ |
| 2212 gboolean quote = FALSE; \ |
2215 gboolean quote = FALSE; \ |
| 2213 while (*c) { \ |
2216 while (*c) { \ |
| 2214 if (*c == '"' || *c == '\'') { \ |
2217 if (*c == '"' || *c == '\'') { \ |
| 2221 } else if (!quote && (*c == '>')) \ |
2224 } else if (!quote && (*c == '>')) \ |
| 2222 break; \ |
2225 break; \ |
| 2223 c++; \ |
2226 c++; \ |
| 2224 } \ |
2227 } \ |
| 2225 if (*c) { \ |
2228 if (*c) { \ |
| 2226 *tag = g_strndup (string, c - string); \ |
2229 if (tag) *tag = g_strndup (string, c - string); \ |
| 2227 *len = c - string + 1; \ |
2230 if (len) *len = c - string + 1; \ |
| 2228 return TRUE; \ |
2231 return TRUE; \ |
| 2229 } \ |
2232 } \ |
| 2230 } \ |
2233 } \ |
| 2231 (*type)++ |
2234 if (type) (*type)++; \ |
| |
2235 } while (0) |
| 2232 |
2236 |
| 2233 |
2237 |
| 2234 static gboolean |
2238 static gboolean |
| 2235 gtk_imhtml_is_tag (const gchar *string, |
2239 gtk_imhtml_is_tag (const gchar *string, |
| 2236 gchar **tag, |
2240 gchar **tag, |
| 2237 gint *len, |
2241 gint *len, |
| 2238 gint *type) |
2242 gint *type) |
| 2239 { |
2243 { |
| 2240 char *close; |
2244 char *close; |
| 2241 *type = 1; |
2245 if (type) |
| 2242 |
2246 *type = 1; |
| 2243 |
2247 |
| 2244 if (!(close = strchr (string, '>'))) |
2248 if (!(close = strchr (string, '>'))) |
| 2245 return FALSE; |
2249 return FALSE; |
| 2246 |
2250 |
| 2247 VALID_TAG ("B"); |
2251 VALID_TAG ("B"); |
| 2310 VALID_OPT_TAG("BR"); |
2314 VALID_OPT_TAG("BR"); |
| 2311 |
2315 |
| 2312 if (!g_ascii_strncasecmp(string, "!--", strlen ("!--"))) { |
2316 if (!g_ascii_strncasecmp(string, "!--", strlen ("!--"))) { |
| 2313 gchar *e = strstr (string + strlen("!--"), "-->"); |
2317 gchar *e = strstr (string + strlen("!--"), "-->"); |
| 2314 if (e) { |
2318 if (e) { |
| 2315 *len = e - string + strlen ("-->"); |
2319 if (len) |
| 2316 *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->")); |
2320 *len = e - string + strlen ("-->"); |
| |
2321 if (tag) |
| |
2322 *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->")); |
| 2317 return TRUE; |
2323 return TRUE; |
| 2318 } |
2324 } |
| 2319 } |
2325 } |
| 2320 |
2326 |
| 2321 *type = -1; |
2327 if (type) |
| 2322 *len = close - string + 1; |
2328 *type = -1; |
| 2323 *tag = g_strndup(string, *len - 1); |
2329 if (len) |
| |
2330 *len = close - string + 1; |
| |
2331 if (tag) |
| |
2332 *tag = g_strndup(string, *len - 1); |
| 2324 return TRUE; |
2333 return TRUE; |
| 2325 } |
2334 } |
| 2326 |
2335 |
| 2327 static gchar* |
2336 static gchar* |
| 2328 gtk_imhtml_get_html_opt (gchar *tag, |
2337 gtk_imhtml_get_html_opt (gchar *tag, |
| 3315 * make sure they're copied into the ws array. |
3324 * make sure they're copied into the ws array. |
| 3316 */ |
3325 */ |
| 3317 ws [wpos++] = *c++; |
3326 ws [wpos++] = *c++; |
| 3318 pos++; |
3327 pos++; |
| 3319 } |
3328 } |
| 3320 if (!imhtml->edit.link) { |
3329 if (!imhtml->edit.link && (imhtml->format_functions & GTK_IMHTML_LINK)) { |
| 3321 while (*c && *c != ' ') { |
3330 while (*c && !isspace((int)*c) && |
| 3322 ws [wpos++] = *c++; |
3331 (*c != '<' || !gtk_imhtml_is_tag(c + 1, NULL, NULL, NULL))) { |
| 3323 pos++; |
3332 if (*c == '&' && (amp = purple_markup_unescape_entity(c, &tlen))) { |
| |
3333 while (*amp) |
| |
3334 ws[wpos++] = *amp++; |
| |
3335 c += tlen; |
| |
3336 pos += tlen; |
| |
3337 } else { |
| |
3338 ws [wpos++] = *c++; |
| |
3339 pos++; |
| |
3340 } |
| 3324 } |
3341 } |
| 3325 ws[wpos] = '\0'; |
3342 ws[wpos] = '\0'; |
| 3326 gtk_imhtml_toggle_link(imhtml, ws); |
3343 gtk_imhtml_toggle_link(imhtml, ws); |
| 3327 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
3344 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 3328 ws[0] = '\0'; wpos = 0; |
3345 ws[0] = '\0'; wpos = 0; |