Mercurial > pidgin
annotate src/gtkimhtml.c @ 4328:2cbcaf41cfee
[gaim-migrate @ 4584]
someone else made a mess. I won't name names.
committer: Tailor Script <tailor@pidgin.im>
| author | Nathan Walp <nwalp@pidgin.im> |
|---|---|
| date | Fri, 17 Jan 2003 20:16:39 +0000 |
| parents | cddb50734169 |
| children | 36cb0bb95b9c |
| rev | line source |
|---|---|
| 1428 | 1 /* |
| 2 * GtkIMHtml | |
| 3 * | |
| 4 * Copyright (C) 2000, Eric Warmenhoven <warmenhoven@yahoo.com> | |
| 5 * | |
| 6 * This program is free software; you can redistribute it and/or modify | |
| 7 * under the terms of the GNU General Public License as published by | |
| 8 * the Free Software Foundation; either version 2 of the License, or | |
| 9 * (at your option) any later version. | |
| 10 * | |
| 11 * This program is distributed in the hope that it will be useful, | |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 * GNU General Public License for more details. | |
| 15 * | |
| 16 * You should have received a copy of the GNU General Public License | |
| 17 * along with this program; if not, write to the Free Software | |
| 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 * | |
| 20 */ | |
| 21 | |
|
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
22 #ifdef HAVE_CONFIG_H |
|
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
23 #include <config.h> |
|
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
24 #endif |
| 1428 | 25 #include "gtkimhtml.h" |
| 26 #include <gtk/gtk.h> | |
| 4046 | 27 #include <gdk/gdkkeysyms.h> |
| 1428 | 28 #include <string.h> |
| 29 #include <ctype.h> | |
| 30 #include <stdio.h> | |
| 31 #include <math.h> | |
|
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
32 #ifdef HAVE_LANGINFO_CODESET |
|
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
33 #include <langinfo.h> |
|
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
34 #include <locale.h> |
|
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
35 #endif |
| 1428 | 36 |
|
2349
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
37 |
| 3922 | 38 /* POINT_SIZE converts from AIM font sizes to point sizes. It probably should be redone in such a |
| 39 * way that it base the sizes off the default font size rather than using arbitrary font sizes. */ | |
| 40 #define MAX_FONT_SIZE 7 | |
| 41 #define POINT_SIZE(x) (_point_sizes [MIN ((x), MAX_FONT_SIZE) - 1]) | |
| 3928 | 42 static gint _point_sizes [] = { 8, 10, 12, 14, 20, 30, 40 }; |
|
2349
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
43 |
| 3922 | 44 /* The four elements present in a <FONT> tag contained in a struct */ |
| 45 typedef struct _FontDetail FontDetail; | |
| 1428 | 46 struct _FontDetail { |
| 47 gushort size; | |
| 48 gchar *face; | |
| 3922 | 49 gchar *fore; |
| 50 gchar *back; | |
| 4032 | 51 gchar *sml; |
| 1428 | 52 }; |
| 53 | |
| 4032 | 54 struct _GtkSmileyTree { |
| 55 GString *values; | |
| 56 GtkSmileyTree **children; | |
| 4263 | 57 GtkIMHtmlSmiley *image; |
| 4032 | 58 }; |
| 59 | |
| 60 static GtkSmileyTree* | |
| 61 gtk_smiley_tree_new () | |
| 62 { | |
| 63 return g_new0 (GtkSmileyTree, 1); | |
| 64 } | |
| 65 | |
| 66 static void | |
| 67 gtk_smiley_tree_insert (GtkSmileyTree *tree, | |
| 4263 | 68 GtkIMHtmlSmiley *smiley) |
| 4032 | 69 { |
| 70 GtkSmileyTree *t = tree; | |
| 4263 | 71 const gchar *x = smiley->smile; |
| 4032 | 72 |
| 73 if (!strlen (x)) | |
| 74 return; | |
| 75 | |
| 76 while (*x) { | |
| 77 gchar *pos; | |
| 78 gint index; | |
| 79 | |
| 80 if (!t->values) | |
| 81 t->values = g_string_new (""); | |
| 82 | |
| 83 pos = strchr (t->values->str, *x); | |
| 84 if (!pos) { | |
| 85 t->values = g_string_append_c (t->values, *x); | |
| 86 index = t->values->len - 1; | |
| 87 t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *)); | |
| 88 t->children [index] = g_new0 (GtkSmileyTree, 1); | |
| 89 } else | |
| 90 index = (int) pos - (int) t->values->str; | |
| 91 | |
| 92 t = t->children [index]; | |
| 93 | |
| 94 x++; | |
| 95 } | |
| 96 | |
| 4263 | 97 t->image = smiley; |
| 4032 | 98 } |
| 4041 | 99 |
| 4263 | 100 |
| 4264 | 101 void gtk_smiley_tree_destroy (GtkSmileyTree *tree) |
| 4032 | 102 { |
| 103 GSList *list = g_slist_append (NULL, tree); | |
| 104 | |
| 105 while (list) { | |
| 106 GtkSmileyTree *t = list->data; | |
| 107 gint i; | |
| 108 list = g_slist_remove(list, t); | |
| 109 if (t->values) { | |
| 110 for (i = 0; i < t->values->len; i++) | |
| 111 list = g_slist_append (list, t->children [i]); | |
| 112 g_string_free (t->values, TRUE); | |
| 113 g_free (t->children); | |
| 114 } | |
| 115 g_free (t); | |
| 116 } | |
| 117 } | |
| 118 | |
| 4263 | 119 |
| 4032 | 120 static GtkTextViewClass *parent_class = NULL; |
| 121 | |
| 122 | |
| 3922 | 123 /* GtkIMHtml has one signal--URL_CLICKED */ |
| 1428 | 124 enum { |
| 125 URL_CLICKED, | |
| 126 LAST_SIGNAL | |
| 127 }; | |
| 128 static guint signals [LAST_SIGNAL] = { 0 }; | |
| 129 | |
| 4264 | 130 static gboolean |
| 131 gtk_smiley_tree_destroy_from_hash(gpointer key, gpointer value, | |
| 132 gpointer user_data) | |
| 133 { | |
| 134 gtk_smiley_tree_destroy(value); | |
| 135 return TRUE; | |
| 136 } | |
| 137 | |
| 4032 | 138 static void |
| 139 gtk_imhtml_finalize (GObject *object) | |
| 140 { | |
| 141 GtkIMHtml *imhtml = GTK_IMHTML(object); | |
| 4264 | 142 g_hash_table_foreach_remove(imhtml->smiley_data, gtk_smiley_tree_destroy_from_hash, NULL); |
| 4138 | 143 g_hash_table_destroy(imhtml->smiley_data); |
| 4032 | 144 gtk_smiley_tree_destroy(imhtml->default_smilies); |
| 4138 | 145 gdk_cursor_unref(imhtml->hand_cursor); |
| 146 gdk_cursor_unref(imhtml->arrow_cursor); | |
| 4032 | 147 G_OBJECT_CLASS(parent_class)->finalize (object); |
| 148 } | |
| 1428 | 149 |
| 3922 | 150 /* Boring GTK stuff */ |
| 151 static void gtk_imhtml_class_init (GtkIMHtmlClass *class) | |
| 1428 | 152 { |
| 3922 | 153 GtkObjectClass *object_class; |
| 4032 | 154 GObjectClass *gobject_class; |
| 3922 | 155 object_class = (GtkObjectClass*) class; |
| 4032 | 156 gobject_class = (GObjectClass*) class; |
| 157 parent_class = gtk_type_class(GTK_TYPE_TEXT_VIEW); | |
| 3922 | 158 signals[URL_CLICKED] = gtk_signal_new("url_clicked", |
| 159 GTK_RUN_FIRST, | |
| 160 GTK_CLASS_TYPE(object_class), | |
| 161 GTK_SIGNAL_OFFSET(GtkIMHtmlClass, url_clicked), | |
| 162 gtk_marshal_NONE__POINTER, | |
| 163 GTK_TYPE_NONE, 1, | |
| 164 GTK_TYPE_POINTER); | |
| 4032 | 165 gobject_class->finalize = gtk_imhtml_finalize; |
| 1428 | 166 } |
| 167 | |
| 3922 | 168 static void gtk_imhtml_init (GtkIMHtml *imhtml) |
| 1428 | 169 { |
| 3922 | 170 GtkTextIter iter; |
| 171 imhtml->text_buffer = gtk_text_buffer_new(NULL); | |
| 172 gtk_text_buffer_get_end_iter (imhtml->text_buffer, &iter); | |
| 173 imhtml->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, FALSE); | |
| 174 gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->text_buffer); | |
| 175 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD); | |
| 176 gtk_text_view_set_editable(GTK_TEXT_VIEW(imhtml), FALSE); | |
| 177 gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(imhtml), 5); | |
| 178 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(imhtml), FALSE); | |
| 179 /*gtk_text_view_set_justification(GTK_TEXT_VIEW(imhtml), GTK_JUSTIFY_FILL);*/ | |
| 3465 | 180 |
| 3922 | 181 /* These tags will be used often and can be reused--we create them on init and then apply them by name |
| 182 * other tags (color, size, face, etc.) will have to be created and applied dynamically */ | |
| 183 gtk_text_buffer_create_tag(imhtml->text_buffer, "BOLD", "weight", PANGO_WEIGHT_BOLD, NULL); | |
| 184 gtk_text_buffer_create_tag(imhtml->text_buffer, "ITALICS", "style", PANGO_STYLE_ITALIC, NULL); | |
| 185 gtk_text_buffer_create_tag(imhtml->text_buffer, "UNDERLINE", "underline", PANGO_UNDERLINE_SINGLE, NULL); | |
| 186 gtk_text_buffer_create_tag(imhtml->text_buffer, "STRIKE", "strikethrough", TRUE, NULL); | |
| 187 gtk_text_buffer_create_tag(imhtml->text_buffer, "SUB", "rise", -5000, NULL); | |
| 188 gtk_text_buffer_create_tag(imhtml->text_buffer, "SUP", "rise", 5000, NULL); | |
| 189 gtk_text_buffer_create_tag(imhtml->text_buffer, "PRE", "family", "Monospace", NULL); | |
| 3465 | 190 |
| 3922 | 191 /* When hovering over a link, we show the hand cursor--elsewhere we show the plain ol' pointer cursor */ |
| 192 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); | |
| 193 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); | |
| 2993 | 194 |
| 4253 | 195 imhtml->show_smileys = TRUE; |
| 196 imhtml->show_comments = TRUE; | |
| 197 | |
| 4032 | 198 imhtml->smiley_data = g_hash_table_new (g_str_hash, g_str_equal); |
| 199 imhtml->default_smilies = gtk_smiley_tree_new(); | |
| 2993 | 200 } |
| 201 | |
| 3922 | 202 GtkWidget *gtk_imhtml_new(void *a, void *b) |
| 1428 | 203 { |
| 3922 | 204 return GTK_WIDGET(gtk_type_new(gtk_imhtml_get_type())); |
| 1428 | 205 } |
| 206 | |
| 3922 | 207 GtkType gtk_imhtml_get_type() |
| 1428 | 208 { |
| 3922 | 209 static guint imhtml_type = 0; |
| 1428 | 210 |
| 211 if (!imhtml_type) { | |
| 3922 | 212 GtkTypeInfo imhtml_info = { |
| 1428 | 213 "GtkIMHtml", |
| 214 sizeof (GtkIMHtml), | |
| 215 sizeof (GtkIMHtmlClass), | |
| 216 (GtkClassInitFunc) gtk_imhtml_class_init, | |
| 217 (GtkObjectInitFunc) gtk_imhtml_init, | |
| 218 NULL, | |
| 219 NULL | |
| 220 }; | |
| 3922 | 221 |
| 222 imhtml_type = gtk_type_unique (gtk_text_view_get_type (), &imhtml_info); | |
| 1428 | 223 } |
| 224 | |
| 225 return imhtml_type; | |
| 226 } | |
| 227 | |
| 3922 | 228 /* The call back for an event on a link tag. */ |
| 229 void tag_event(GtkTextTag *tag, GObject *arg1, GdkEvent *event, GtkTextIter *arg2, char *url) { | |
| 230 if (event->type == GDK_BUTTON_RELEASE) { | |
| 231 /* A link was clicked--we emit the "url_clicked" signal with the URL as the argument */ | |
| 232 // if ((GdkEventButton)(event)->button == 1) | |
|
4141
ccec4fde84f4
[gaim-migrate @ 4359]
Christian Hammond <chipx86@chipx86.com>
parents:
4140
diff
changeset
|
233 gtk_signal_emit (GTK_OBJECT(arg1), signals[URL_CLICKED], url); |
| 3922 | 234 } else if (event->type == GDK_ENTER_NOTIFY) { |
| 235 /* make a hand cursor and a tooltip timeout -- if GTK worked as it should */ | |
| 236 } else if (event->type == GDK_LEAVE_NOTIFY) { | |
| 237 /* clear timeout and make an arrow cursor again --if GTK worked as it should */ | |
| 1428 | 238 } |
| 239 } | |
| 240 | |
| 4298 | 241 /* this isn't used yet |
| 4032 | 242 static void |
| 4263 | 243 gtk_smiley_tree_remove (GtkSmileyTree *tree, |
| 244 GtkIMHtmlSmiley *smiley) | |
| 4032 | 245 { |
| 246 GtkSmileyTree *t = tree; | |
| 4263 | 247 const gchar *x = smiley->smile; |
| 4032 | 248 gint len = 0; |
| 249 | |
| 250 while (*x) { | |
| 251 gchar *pos; | |
| 252 | |
| 253 if (!t->values) | |
| 254 return; | |
| 255 | |
| 256 pos = strchr (t->values->str, *x); | |
| 257 if (pos) | |
| 258 t = t->children [(int) pos - (int) t->values->str]; | |
| 259 else | |
| 260 return; | |
| 261 | |
| 262 x++; len++; | |
| 263 } | |
| 264 | |
|
4141
ccec4fde84f4
[gaim-migrate @ 4359]
Christian Hammond <chipx86@chipx86.com>
parents:
4140
diff
changeset
|
265 if (t->image) { |
| 4032 | 266 t->image = NULL; |
|
4141
ccec4fde84f4
[gaim-migrate @ 4359]
Christian Hammond <chipx86@chipx86.com>
parents:
4140
diff
changeset
|
267 } |
| 4032 | 268 } |
| 4298 | 269 */ |
| 270 | |
| 4032 | 271 |
| 272 static gint | |
| 273 gtk_smiley_tree_lookup (GtkSmileyTree *tree, | |
| 274 const gchar *text) | |
| 275 { | |
| 276 GtkSmileyTree *t = tree; | |
| 277 const gchar *x = text; | |
| 278 gint len = 0; | |
| 279 | |
| 280 while (*x) { | |
| 281 gchar *pos; | |
| 282 | |
| 283 if (!t->values) | |
| 284 break; | |
| 285 | |
| 286 pos = strchr (t->values->str, *x); | |
| 287 if (pos) | |
| 288 t = t->children [(int) pos - (int) t->values->str]; | |
| 289 else | |
| 290 break; | |
| 291 | |
| 292 x++; len++; | |
| 293 } | |
| 294 | |
| 295 if (t->image) | |
| 296 return len; | |
| 297 | |
| 298 return 0; | |
| 299 } | |
| 300 | |
| 301 void | |
| 4263 | 302 gtk_imhtml_associate_smiley (GtkIMHtml *imhtml, |
| 303 gchar *sml, | |
| 304 GtkIMHtmlSmiley *smiley) | |
| 4032 | 305 { |
| 306 GtkSmileyTree *tree; | |
| 307 g_return_if_fail (imhtml != NULL); | |
| 308 g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 4263 | 309 |
| 4032 | 310 if (sml == NULL) |
| 311 tree = imhtml->default_smilies; | |
| 312 else if ((tree = g_hash_table_lookup(imhtml->smiley_data, sml))) { | |
| 313 } else { | |
| 314 tree = gtk_smiley_tree_new(); | |
| 315 g_hash_table_insert(imhtml->smiley_data, sml, tree); | |
| 316 } | |
| 317 | |
| 4263 | 318 gtk_smiley_tree_insert (tree, smiley); |
| 4032 | 319 } |
| 320 | |
| 321 static gboolean | |
| 322 gtk_imhtml_is_smiley (GtkIMHtml *imhtml, | |
| 323 GSList *fonts, | |
| 324 const gchar *text, | |
| 325 gint *len) | |
| 326 { | |
| 327 GtkSmileyTree *tree; | |
| 328 FontDetail *font; | |
| 329 char *sml = NULL; | |
| 330 | |
| 331 if (fonts) { | |
| 332 font = fonts->data; | |
| 333 sml = font->sml; | |
| 334 } | |
| 335 | |
| 336 if (sml == NULL) | |
| 337 tree = imhtml->default_smilies; | |
| 338 else { | |
| 339 tree = g_hash_table_lookup(imhtml->smiley_data, sml); | |
| 340 } | |
| 341 if (tree == NULL) | |
| 342 return FALSE; | |
| 343 | |
| 344 *len = gtk_smiley_tree_lookup (tree, text); | |
| 345 return (*len > 0); | |
| 346 } | |
| 347 | |
| 4263 | 348 GdkPixbuf* |
| 4032 | 349 gtk_smiley_tree_image (GtkIMHtml *imhtml, |
| 350 const gchar *sml, | |
| 351 const gchar *text) | |
| 352 { | |
| 353 GtkSmileyTree *t; | |
| 354 const gchar *x = text; | |
| 355 if (sml == NULL) | |
| 356 t = imhtml->default_smilies; | |
| 357 else | |
| 358 t = g_hash_table_lookup(imhtml->smiley_data, sml); | |
| 359 | |
| 360 | |
| 361 if (t == NULL) | |
| 362 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL; | |
| 363 | |
| 364 while (*x) { | |
| 365 gchar *pos; | |
| 366 | |
| 367 if (!t->values) { | |
| 368 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL; | |
| 369 } | |
| 370 | |
| 371 pos = strchr (t->values->str, *x); | |
| 372 if (pos) { | |
| 373 t = t->children [(int) pos - (int) t->values->str]; | |
| 374 } else { | |
| 375 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL; | |
| 376 } | |
| 377 x++; | |
| 378 } | |
| 379 | |
| 4263 | 380 if (!t->image->icon) |
| 381 t->image->icon = gdk_pixbuf_new_from_file(t->image->file, NULL); | |
| 382 | |
| 383 return t->image->icon; | |
| 4032 | 384 } |
| 3922 | 385 #define VALID_TAG(x) if (!g_strncasecmp (string, x ">", strlen (x ">"))) { \ |
| 386 *tag = g_strndup (string, strlen (x)); \ | |
| 387 *len = strlen (x) + 1; \ | |
| 388 return TRUE; \ | |
| 389 } \ | |
| 390 (*type)++ | |
| 1428 | 391 |
| 3922 | 392 #define VALID_OPT_TAG(x) if (!g_strncasecmp (string, x " ", strlen (x " "))) { \ |
| 393 const gchar *c = string + strlen (x " "); \ | |
| 394 gchar e = '"'; \ | |
| 395 gboolean quote = FALSE; \ | |
| 396 while (*c) { \ | |
| 397 if (*c == '"' || *c == '\'') { \ | |
| 398 if (quote && (*c == e)) \ | |
| 399 quote = !quote; \ | |
| 400 else if (!quote) { \ | |
| 401 quote = !quote; \ | |
| 402 e = *c; \ | |
| 403 } \ | |
| 404 } else if (!quote && (*c == '>')) \ | |
| 405 break; \ | |
| 406 c++; \ | |
| 407 } \ | |
| 408 if (*c) { \ | |
| 409 *tag = g_strndup (string, c - string); \ | |
| 410 *len = c - string + 1; \ | |
| 411 return TRUE; \ | |
| 412 } \ | |
| 413 } \ | |
| 414 (*type)++ | |
| 1428 | 415 |
| 416 | |
|
1472
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
417 static gboolean |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
418 gtk_imhtml_is_amp_escape (const gchar *string, |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
419 gchar *replace, |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
420 gint *length) |
|
1472
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
421 { |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
422 g_return_val_if_fail (string != NULL, FALSE); |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
423 g_return_val_if_fail (replace != NULL, FALSE); |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
424 g_return_val_if_fail (length != NULL, FALSE); |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
425 |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
426 if (!g_strncasecmp (string, "&", 5)) { |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
427 *replace = '&'; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
428 *length = 5; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
429 } else if (!g_strncasecmp (string, "<", 4)) { |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
430 *replace = '<'; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
431 *length = 4; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
432 } else if (!g_strncasecmp (string, ">", 4)) { |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
433 *replace = '>'; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
434 *length = 4; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
435 } else if (!g_strncasecmp (string, " ", 6)) { |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
436 *replace = ' '; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
437 *length = 6; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
438 } else if (!g_strncasecmp (string, "©", 6)) { |
|
3717
988485669631
[gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3705
diff
changeset
|
439 *replace = '©'; /* was: '©' */ |
|
1472
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
440 *length = 6; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
441 } else if (!g_strncasecmp (string, """, 6)) { |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
442 *replace = '\"'; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
443 *length = 6; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
444 } else if (!g_strncasecmp (string, "®", 5)) { |
|
3717
988485669631
[gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3705
diff
changeset
|
445 *replace = '®'; /* was: '®' */ |
|
1472
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
446 *length = 5; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
447 } else if (*(string + 1) == '#') { |
|
2022
199ba82faacb
[gaim-migrate @ 2032]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2002
diff
changeset
|
448 guint pound = 0; |
| 3004 | 449 if ((sscanf (string, "&#%u;", £) == 1) && pound != 0) { |
|
1472
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
450 if (*(string + 3 + (gint)log10 (pound)) != ';') |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
451 return FALSE; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
452 *replace = (gchar)pound; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
453 *length = 2; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
454 while (isdigit ((gint) string [*length])) (*length)++; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
455 if (string [*length] == ';') (*length)++; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
456 } else { |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
457 return FALSE; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
458 } |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
459 } else { |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
460 return FALSE; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
461 } |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
462 |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
463 return TRUE; |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
464 } |
|
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
465 |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
466 static gboolean |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
467 gtk_imhtml_is_tag (const gchar *string, |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
468 gchar **tag, |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
469 gint *len, |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
470 gint *type) |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
471 { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
472 *type = 1; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
473 |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
474 if (!strchr (string, '>')) |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
475 return FALSE; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
476 |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
477 VALID_TAG ("B"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
478 VALID_TAG ("BOLD"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
479 VALID_TAG ("/B"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
480 VALID_TAG ("/BOLD"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
481 VALID_TAG ("I"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
482 VALID_TAG ("ITALIC"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
483 VALID_TAG ("/I"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
484 VALID_TAG ("/ITALIC"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
485 VALID_TAG ("U"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
486 VALID_TAG ("UNDERLINE"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
487 VALID_TAG ("/U"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
488 VALID_TAG ("/UNDERLINE"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
489 VALID_TAG ("S"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
490 VALID_TAG ("STRIKE"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
491 VALID_TAG ("/S"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
492 VALID_TAG ("/STRIKE"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
493 VALID_TAG ("SUB"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
494 VALID_TAG ("/SUB"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
495 VALID_TAG ("SUP"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
496 VALID_TAG ("/SUP"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
497 VALID_TAG ("PRE"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
498 VALID_TAG ("/PRE"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
499 VALID_TAG ("TITLE"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
500 VALID_TAG ("/TITLE"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
501 VALID_TAG ("BR"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
502 VALID_TAG ("HR"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
503 VALID_TAG ("/FONT"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
504 VALID_TAG ("/A"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
505 VALID_TAG ("P"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
506 VALID_TAG ("/P"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
507 VALID_TAG ("H3"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
508 VALID_TAG ("/H3"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
509 VALID_TAG ("HTML"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
510 VALID_TAG ("/HTML"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
511 VALID_TAG ("BODY"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
512 VALID_TAG ("/BODY"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
513 VALID_TAG ("FONT"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
514 VALID_TAG ("HEAD"); |
| 2993 | 515 VALID_TAG ("/HEAD"); |
| 516 VALID_TAG ("BINARY"); | |
| 517 VALID_TAG ("/BINARY"); | |
| 518 | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
519 VALID_OPT_TAG ("HR"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
520 VALID_OPT_TAG ("FONT"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
521 VALID_OPT_TAG ("BODY"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
522 VALID_OPT_TAG ("A"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
523 VALID_OPT_TAG ("IMG"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
524 VALID_OPT_TAG ("P"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
525 VALID_OPT_TAG ("H3"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
526 |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
527 if (!g_strncasecmp(string, "!--", strlen ("!--"))) { |
|
2954
f6c4f2187c08
[gaim-migrate @ 2967]
Christian Hammond <chipx86@chipx86.com>
parents:
2898
diff
changeset
|
528 gchar *e = strstr (string + strlen("!--"), "-->"); |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
529 if (e) { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
530 *len = e - string + strlen ("-->"); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
531 *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->")); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
532 return TRUE; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
533 } |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
534 } |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
535 |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
536 return FALSE; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
537 } |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
538 |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
539 static gchar* |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
540 gtk_imhtml_get_html_opt (gchar *tag, |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
541 const gchar *opt) |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
542 { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
543 gchar *t = tag; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
544 gchar *e, *a; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
545 |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
546 while (g_strncasecmp (t, opt, strlen (opt))) { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
547 gboolean quote = FALSE; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
548 if (*t == '\0') break; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
549 while (*t && !((*t == ' ') && !quote)) { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
550 if (*t == '\"') |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
551 quote = ! quote; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
552 t++; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
553 } |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
554 while (*t && (*t == ' ')) t++; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
555 } |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
556 |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
557 if (!g_strncasecmp (t, opt, strlen (opt))) { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
558 t += strlen (opt); |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
559 } else { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
560 return NULL; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
561 } |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
562 |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
563 if ((*t == '\"') || (*t == '\'')) { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
564 e = a = ++t; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
565 while (*e && (*e != *(t - 1))) e++; |
| 2993 | 566 if (*e == '\0') { |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
567 return NULL; |
| 2993 | 568 } else |
| 569 return g_strndup (a, e - a); | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
570 } else { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
571 e = a = t; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
572 while (*e && !isspace ((gint) *e)) e++; |
| 2993 | 573 return g_strndup (a, e - a); |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
574 } |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
575 } |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
576 |
| 3922 | 577 |
| 578 | |
| 579 #define NEW_TEXT_BIT 0 | |
| 580 #define NEW_HR_BIT 1 | |
| 581 #define NEW_BIT(x) ws [wpos] = '\0'; \ | |
| 582 mark2 = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE); \ | |
| 583 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, -1); \ | |
| 584 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); \ | |
| 585 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &siter, mark2); \ | |
| 586 gtk_text_buffer_delete_mark(imhtml->text_buffer, mark2); \ | |
| 587 if (bold) \ | |
| 588 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &siter, &iter); \ | |
| 589 if (italics) \ | |
| 590 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &siter, &iter); \ | |
| 591 if (underline) \ | |
| 592 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &siter, &iter); \ | |
| 593 if (strike) \ | |
| 594 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &siter, &iter); \ | |
| 595 if (sub) \ | |
| 596 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "SUB", &siter, &iter); \ | |
| 597 if (sup) \ | |
| 598 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "SUP", &siter, &iter); \ | |
| 599 if (pre) \ | |
| 600 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "PRE", &siter, &iter); \ | |
| 601 if (bg) { \ | |
| 602 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "background", bg, NULL); \ | |
| 603 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \ | |
| 604 } \ | |
| 605 if (fonts) { \ | |
| 606 FontDetail *fd = fonts->data; \ | |
| 607 if (fd->fore) { \ | |
| 608 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "foreground", fd->fore, NULL); \ | |
| 609 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \ | |
| 610 } \ | |
| 611 if (fd->back) { \ | |
| 612 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "background", fd->back, NULL); \ | |
| 613 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \ | |
| 614 } \ | |
| 615 if (fd->face) { \ | |
| 616 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "font", fd->face, NULL); \ | |
| 617 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \ | |
| 618 } \ | |
| 619 if (fd->size) { \ | |
| 620 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "size-points", (double)POINT_SIZE(fd->size), NULL); \ | |
| 621 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \ | |
| 622 } \ | |
| 623 } \ | |
| 624 if (url) { \ | |
| 625 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "foreground", "blue", "underline", PANGO_UNDERLINE_SINGLE, NULL); \ | |
| 626 g_signal_connect(G_OBJECT(texttag), "event", G_CALLBACK(tag_event), strdup(url)); \ | |
| 627 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \ | |
| 628 } \ | |
| 629 wpos = 0; \ | |
| 630 ws[0] = 0; \ | |
| 631 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); \ | |
| 632 | |
| 633 | |
| 634 /* if (x == NEW_HR_BIT) { \ | |
| 635 sep = gtk_hseparator_new(); \ | |
| 636 gtk_widget_size_request(GTK_WIDGET(imhtml), &req); \ | |
| 637 gtk_widget_set_size_request(sep, 20, -1); \ | |
| 638 anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, &iter); \ | |
| 639 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), sep, anchor); \ | |
| 640 gtk_widget_show(sep); \ | |
| 641 } */ | |
| 642 | |
| 643 GString* gtk_imhtml_append_text (GtkIMHtml *imhtml, | |
| 644 const gchar *text, | |
| 645 gint len, | |
| 646 GtkIMHtmlOptions options) | |
| 1428 | 647 { |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
648 gint pos = 0; |
| 3922 | 649 GString *str = NULL; |
| 650 GtkTextIter iter, siter; | |
| 651 GtkTextMark *mark, *mark2; | |
| 652 GtkTextTag *texttag; | |
| 653 gchar *ws; | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
654 gchar *tag; |
| 3922 | 655 gchar *url = NULL; |
| 656 gchar *bg = NULL; | |
| 4032 | 657 gint tlen, smilelen, wpos=0; |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
658 gint type; |
| 3922 | 659 const gchar *c; |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
660 gchar amp; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
661 |
| 1428 | 662 guint bold = 0, |
| 663 italics = 0, | |
| 664 underline = 0, | |
| 665 strike = 0, | |
| 666 sub = 0, | |
| 667 sup = 0, | |
|
1691
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
668 title = 0, |
| 3922 | 669 pre = 0; |
| 1428 | 670 |
| 3922 | 671 GSList *fonts = NULL; |
| 1428 | 672 |
| 673 g_return_val_if_fail (imhtml != NULL, NULL); | |
| 674 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL); | |
| 675 g_return_val_if_fail (text != NULL, NULL); | |
| 3922 | 676 g_return_val_if_fail (len != 0, NULL); |
| 677 | |
| 678 c = text; | |
| 679 if (len == -1) | |
| 680 len = strlen(text); | |
| 681 ws = g_malloc(len + 1); | |
| 682 ws[0] = 0; | |
| 1428 | 683 |
| 684 if (options & GTK_IMHTML_RETURN_LOG) | |
| 3922 | 685 str = g_string_new(""); |
| 1428 | 686 |
| 3922 | 687 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
| 688 mark = gtk_text_buffer_create_mark (imhtml->text_buffer, NULL, &iter, /* right grav */ FALSE); | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
689 while (pos < len) { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
690 if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
691 c++; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
692 pos++; |
| 3922 | 693 switch (type) |
| 694 { | |
| 695 case 1: /* B */ | |
| 696 case 2: /* BOLD */ | |
| 697 NEW_BIT (NEW_TEXT_BIT); | |
| 698 bold++; | |
| 699 break; | |
| 700 case 3: /* /B */ | |
| 701 case 4: /* /BOLD */ | |
| 702 NEW_BIT (NEW_TEXT_BIT); | |
| 703 if (bold) | |
| 704 bold--; | |
| 705 break; | |
| 706 case 5: /* I */ | |
| 707 case 6: /* ITALIC */ | |
| 708 NEW_BIT (NEW_TEXT_BIT); | |
| 709 italics++; | |
| 710 break; | |
| 711 case 7: /* /I */ | |
| 712 case 8: /* /ITALIC */ | |
| 713 NEW_BIT (NEW_TEXT_BIT); | |
| 714 if (italics) | |
| 715 italics--; | |
| 716 break; | |
| 717 case 9: /* U */ | |
| 718 case 10: /* UNDERLINE */ | |
| 719 NEW_BIT (NEW_TEXT_BIT); | |
| 720 underline++; | |
| 721 break; | |
| 722 case 11: /* /U */ | |
| 723 case 12: /* /UNDERLINE */ | |
| 724 NEW_BIT (NEW_TEXT_BIT); | |
| 725 if (underline) | |
| 726 underline--; | |
| 727 break; | |
| 728 case 13: /* S */ | |
| 729 case 14: /* STRIKE */ | |
| 730 NEW_BIT (NEW_TEXT_BIT); | |
| 731 strike++; | |
| 732 break; | |
| 733 case 15: /* /S */ | |
| 734 case 16: /* /STRIKE */ | |
| 735 NEW_BIT (NEW_TEXT_BIT); | |
| 736 if (strike) | |
| 737 strike--; | |
| 738 break; | |
| 739 case 17: /* SUB */ | |
| 740 NEW_BIT (NEW_TEXT_BIT); | |
| 741 sub++; | |
| 742 break; | |
| 743 case 18: /* /SUB */ | |
| 744 NEW_BIT (NEW_TEXT_BIT); | |
| 745 if (sub) | |
| 746 sub--; | |
| 747 break; | |
| 748 case 19: /* SUP */ | |
| 749 NEW_BIT (NEW_TEXT_BIT); | |
| 750 sup++; | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
751 break; |
| 3922 | 752 case 20: /* /SUP */ |
| 753 NEW_BIT (NEW_TEXT_BIT); | |
| 754 if (sup) | |
| 755 sup--; | |
| 756 break; | |
| 757 case 21: /* PRE */ | |
| 758 NEW_BIT (NEW_TEXT_BIT); | |
| 759 pre++; | |
| 760 break; | |
| 761 case 22: /* /PRE */ | |
| 762 NEW_BIT (NEW_TEXT_BIT); | |
| 763 if (pre) | |
| 764 pre--; | |
| 765 break; | |
| 766 case 23: /* TITLE */ | |
| 767 NEW_BIT (NEW_TEXT_BIT); | |
| 768 title++; | |
| 769 break; | |
| 770 case 24: /* /TITLE */ | |
| 771 if (title) { | |
| 772 if (options & GTK_IMHTML_NO_TITLE) { | |
| 773 wpos = 0; | |
| 774 ws [wpos] = '\0'; | |
| 775 } | |
| 776 title--; | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
777 } |
| 3922 | 778 break; |
| 779 case 25: /* BR */ | |
| 780 ws[wpos] = '\n'; | |
| 781 wpos++; | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
782 NEW_BIT (NEW_TEXT_BIT); |
| 3922 | 783 break; |
| 784 case 26: /* HR */ | |
| 785 case 42: /* HR (opt) */ | |
| 786 ws[wpos++] = '\n'; | |
| 787 NEW_BIT(NEW_HR_BIT); | |
| 788 break; | |
| 789 case 27: /* /FONT */ | |
| 790 if (fonts) { | |
| 791 FontDetail *font = fonts->data; | |
| 792 NEW_BIT (NEW_TEXT_BIT); | |
| 793 fonts = g_slist_remove (fonts, font); | |
| 794 if (font->face) | |
| 795 g_free (font->face); | |
| 796 if (font->fore) | |
| 797 g_free (font->fore); | |
| 798 if (font->back) | |
| 799 g_free (font->back); | |
| 4032 | 800 if (font->sml) |
| 801 g_free (font->sml); | |
| 3922 | 802 g_free (font); |
| 803 } | |
| 804 break; | |
| 805 case 28: /* /A */ | |
| 806 if (url) { | |
| 807 NEW_BIT(NEW_TEXT_BIT); | |
| 808 g_free(url); | |
| 809 url = NULL; | |
| 2993 | 810 break; |
| 811 } | |
| 3922 | 812 case 29: /* P */ |
| 813 case 30: /* /P */ | |
| 814 case 31: /* H3 */ | |
| 815 case 32: /* /H3 */ | |
| 816 case 33: /* HTML */ | |
| 817 case 34: /* /HTML */ | |
| 818 case 35: /* BODY */ | |
| 819 case 36: /* /BODY */ | |
| 820 case 37: /* FONT */ | |
| 821 case 38: /* HEAD */ | |
| 822 case 39: /* /HEAD */ | |
| 823 break; | |
| 824 case 40: /* BINARY */ | |
| 825 case 41: /* /BINARY */ | |
| 826 break; | |
| 827 case 43: /* FONT (opt) */ | |
| 828 { | |
| 4032 | 829 gchar *color, *back, *face, *size, *sml; |
| 3922 | 830 FontDetail *font, *oldfont = NULL; |
| 831 color = gtk_imhtml_get_html_opt (tag, "COLOR="); | |
| 832 back = gtk_imhtml_get_html_opt (tag, "BACK="); | |
| 833 face = gtk_imhtml_get_html_opt (tag, "FACE="); | |
| 834 size = gtk_imhtml_get_html_opt (tag, "SIZE="); | |
| 4032 | 835 sml = gtk_imhtml_get_html_opt (tag, "SML="); |
| 836 if (!(color || back || face || size || sml)) | |
| 3922 | 837 break; |
| 838 | |
| 839 NEW_BIT (NEW_TEXT_BIT); | |
| 840 | |
| 841 font = g_new0 (FontDetail, 1); | |
| 842 if (fonts) | |
| 843 oldfont = fonts->data; | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
844 |
| 3922 | 845 if (color && !(options & GTK_IMHTML_NO_COLOURS)) |
| 846 font->fore = color; | |
| 847 else if (oldfont && oldfont->fore) | |
| 848 font->fore = g_strdup(oldfont->fore); | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
849 |
| 3922 | 850 if (back && !(options & GTK_IMHTML_NO_COLOURS)) |
| 851 font->back = back; | |
| 852 else if (oldfont && oldfont->back) | |
| 853 font->back = g_strdup(oldfont->back); | |
| 854 | |
| 855 if (face && !(options & GTK_IMHTML_NO_FONTS)) | |
| 856 font->face = face; | |
| 857 else if (oldfont && oldfont->face) | |
| 858 font->face = g_strdup(oldfont->face); | |
| 4032 | 859 |
| 860 if (sml) | |
| 861 font->sml = sml; | |
| 862 else if (oldfont && oldfont->sml) | |
| 863 font->sml = g_strdup(oldfont->sml); | |
| 864 | |
| 3922 | 865 if (size && !(options & GTK_IMHTML_NO_SIZES)) { |
| 866 if (*size == '+') { | |
| 867 sscanf (size + 1, "%hd", &font->size); | |
| 868 font->size += 3; | |
| 869 } else if (*size == '-') { | |
| 870 sscanf (size + 1, "%hd", &font->size); | |
| 871 font->size = MAX (0, 3 - font->size); | |
| 872 } else if (isdigit (*size)) { | |
| 873 sscanf (size, "%hd", &font->size); | |
| 874 } | |
| 875 } else if (oldfont) | |
| 876 font->size = oldfont->size; | |
| 877 g_free(size); | |
| 878 fonts = g_slist_prepend (fonts, font); | |
| 879 } | |
| 880 break; | |
| 881 case 44: /* BODY (opt) */ | |
| 882 if (!(options & GTK_IMHTML_NO_COLOURS)) { | |
| 883 char *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR="); | |
| 884 if (bgcolor) { | |
| 885 NEW_BIT(NEW_TEXT_BIT); | |
| 886 if (bg) | |
| 887 g_free(bg); | |
| 888 bg = bgcolor; | |
|
2885
f72efa29c109
[gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2871
diff
changeset
|
889 } |
| 1428 | 890 } |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
891 break; |
| 3922 | 892 case 45: /* A (opt) */ |
| 893 { | |
| 894 gchar *href = gtk_imhtml_get_html_opt (tag, "HREF="); | |
| 895 if (href) { | |
| 896 NEW_BIT (NEW_TEXT_BIT); | |
| 897 if (url) | |
| 898 g_free (url); | |
| 899 url = href; | |
| 900 } | |
| 2993 | 901 } |
| 3922 | 902 break; |
| 903 case 47: /* P (opt) */ | |
| 904 case 48: /* H3 (opt) */ | |
| 2993 | 905 break; |
| 3922 | 906 case 49: /* comment */ |
| 907 NEW_BIT (NEW_TEXT_BIT); | |
| 4253 | 908 if (imhtml->show_comments) |
| 909 wpos = g_snprintf (ws, len, "%s", tag); | |
| 3922 | 910 NEW_BIT (NEW_COMMENT_BIT); |
| 911 break; | |
| 912 default: | |
| 913 break; | |
| 2993 | 914 } |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
915 c += tlen; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
916 pos += tlen; |
| 4138 | 917 if(tag) |
| 918 g_free(tag); /* This was allocated back in VALID_TAG() */ | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
919 } else if (*c == '&' && gtk_imhtml_is_amp_escape (c, &, &tlen)) { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
920 ws [wpos++] = amp; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
921 c += tlen; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
922 pos += tlen; |
| 1428 | 923 } else if (*c == '\n') { |
| 924 if (!(options & GTK_IMHTML_NO_NEWLINE)) { | |
| 3922 | 925 ws[wpos] = '\n'; |
| 926 wpos++; | |
| 1428 | 927 NEW_BIT (NEW_TEXT_BIT); |
| 928 } | |
| 929 c++; | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
930 pos++; |
| 4253 | 931 } else if (imhtml->show_smileys && (gtk_imhtml_is_smiley (imhtml, fonts, c, &smilelen) || gtk_imhtml_is_smiley(imhtml, NULL, c, &smilelen))) { |
| 4032 | 932 FontDetail *fd; |
| 933 gchar *sml = NULL; | |
| 934 if (fonts) { | |
| 935 fd = fonts->data; | |
| 936 sml = fd->sml; | |
| 937 } | |
| 938 NEW_BIT (NEW_TEXT_BIT); | |
| 939 wpos = g_snprintf (ws, smilelen + 1, "%s", c); | |
| 4263 | 940 gtk_text_buffer_insert_pixbuf(imhtml->text_buffer, &iter, gtk_smiley_tree_image (imhtml, sml, ws)); |
| 4032 | 941 c += smilelen; |
| 942 pos += smilelen; | |
| 943 wpos = 0; | |
| 944 ws[0] = 0; | |
| 945 } else if (*c) { | |
| 1428 | 946 ws [wpos++] = *c++; |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
947 pos++; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
948 } else { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
949 break; |
| 1428 | 950 } |
| 951 } | |
| 3922 | 952 |
| 953 NEW_BIT(NEW_TEXT_BIT); | |
| 1428 | 954 if (url) { |
| 955 g_free (url); | |
| 3922 | 956 if (str) |
| 957 str = g_string_append (str, "</A>"); | |
| 1428 | 958 } |
| 3922 | 959 |
| 4032 | 960 while (fonts) { |
| 961 FontDetail *font = fonts->data; | |
| 962 fonts = g_slist_remove (fonts, font); | |
| 963 if (font->face) | |
| 964 g_free (font->face); | |
| 965 if (font->fore) | |
| 966 g_free (font->fore); | |
| 967 if (font->back) | |
| 968 g_free (font->back); | |
| 969 if (font->sml) | |
| 970 g_free (font->sml); | |
| 971 g_free (font); | |
| 972 if (str) | |
| 973 str = g_string_append (str, "</FONT>"); | |
| 974 } | |
| 975 | |
| 3922 | 976 if (str) { |
| 1428 | 977 while (bold) { |
| 3922 | 978 str = g_string_append (str, "</B>"); |
| 1428 | 979 bold--; |
| 980 } | |
| 981 while (italics) { | |
| 3922 | 982 str = g_string_append (str, "</I>"); |
| 1428 | 983 italics--; |
| 984 } | |
| 985 while (underline) { | |
| 3922 | 986 str = g_string_append (str, "</U>"); |
| 1428 | 987 underline--; |
| 988 } | |
| 989 while (strike) { | |
| 3922 | 990 str = g_string_append (str, "</S>"); |
| 1428 | 991 strike--; |
| 992 } | |
| 993 while (sub) { | |
| 3922 | 994 str = g_string_append (str, "</SUB>"); |
| 1428 | 995 sub--; |
| 996 } | |
| 997 while (sup) { | |
| 3922 | 998 str = g_string_append (str, "</SUP>"); |
| 1428 | 999 sup--; |
| 1000 } | |
| 1001 while (title) { | |
| 3922 | 1002 str = g_string_append (str, "</TITLE>"); |
| 1428 | 1003 title--; |
| 1004 } | |
|
1691
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
1005 while (pre) { |
| 3922 | 1006 str = g_string_append (str, "</PRE>"); |
|
1691
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
1007 pre--; |
|
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
1008 } |
| 1428 | 1009 } |
| 4032 | 1010 g_free (ws); |
| 1011 if (!(options & GTK_IMHTML_NO_SCROLL)) | |
| 1012 gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (imhtml), mark, | |
| 1013 0, TRUE, 0.0, 1.0); | |
| 3922 | 1014 gtk_text_buffer_delete_mark (imhtml->text_buffer, mark); |
| 1015 return str; | |
| 1016 } | |
| 1017 | |
| 1018 void gtk_imhtml_set_img_handler (GtkIMHtml *imhtml, | |
| 1019 GtkIMHtmlImage handler){} | |
| 1020 | |
| 4288 | 1021 void gtk_imhtml_remove_smileys(GtkIMHtml *imhtml) |
| 1022 { | |
| 1023 g_hash_table_destroy(imhtml->smiley_data); | |
| 1024 gtk_smiley_tree_destroy(imhtml->default_smilies); | |
| 1025 imhtml->smiley_data = g_hash_table_new (g_str_hash, g_str_equal); | |
| 1026 imhtml->default_smilies = gtk_smiley_tree_new(); | |
| 1027 } | |
| 3922 | 1028 void gtk_imhtml_show_smileys (GtkIMHtml *imhtml, |
| 4253 | 1029 gboolean show) |
| 1030 { | |
| 1031 imhtml->show_smileys = show; | |
| 1032 } | |
| 3922 | 1033 |
| 1034 void gtk_imhtml_show_comments (GtkIMHtml *imhtml, | |
| 4253 | 1035 gboolean show) |
| 1036 { | |
| 1037 imhtml->show_comments = show; | |
| 1038 } | |
|
1780
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
1039 |
|
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
1040 void |
|
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
1041 gtk_imhtml_clear (GtkIMHtml *imhtml) |
|
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
1042 { |
| 3922 | 1043 GtkTextIter start, end; |
| 2993 | 1044 |
| 3922 | 1045 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); |
| 1046 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 1047 gtk_text_buffer_delete(imhtml->text_buffer, &start, &end); | |
|
1780
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
1048 } |
|
2363
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
1049 |
| 4046 | 1050 void gtk_imhtml_page_up (GtkIMHtml *imhtml) |
| 1051 { | |
| 1052 | |
| 1053 } | |
| 3922 | 1054 void gtk_imhtml_page_down (GtkIMHtml *imhtml){} |
