Mercurial > pidgin
annotate src/gtkimhtml.c @ 4353:539cccfffa46
[gaim-migrate @ 4618]
I have to keep my adopted baby in line, lest it
turn to the dark side and try to light saber me
to death.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Mon, 20 Jan 2003 00:49:52 +0000 |
| parents | 36cb0bb95b9c |
| children | 8299114f5693 |
| 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 | |
| 4343 | 581 #define NEW_COMMENT_BIT 2 |
| 3922 | 582 #define NEW_BIT(x) ws [wpos] = '\0'; \ |
| 583 mark2 = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE); \ | |
| 584 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, -1); \ | |
| 585 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); \ | |
| 586 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &siter, mark2); \ | |
| 587 gtk_text_buffer_delete_mark(imhtml->text_buffer, mark2); \ | |
| 588 if (bold) \ | |
| 589 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &siter, &iter); \ | |
| 590 if (italics) \ | |
| 591 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &siter, &iter); \ | |
| 592 if (underline) \ | |
| 593 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &siter, &iter); \ | |
| 594 if (strike) \ | |
| 595 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &siter, &iter); \ | |
| 596 if (sub) \ | |
| 597 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "SUB", &siter, &iter); \ | |
| 598 if (sup) \ | |
| 599 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "SUP", &siter, &iter); \ | |
| 600 if (pre) \ | |
| 601 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "PRE", &siter, &iter); \ | |
| 602 if (bg) { \ | |
| 603 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "background", bg, NULL); \ | |
| 604 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \ | |
| 605 } \ | |
| 606 if (fonts) { \ | |
| 607 FontDetail *fd = fonts->data; \ | |
| 608 if (fd->fore) { \ | |
| 609 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "foreground", fd->fore, NULL); \ | |
| 610 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \ | |
| 611 } \ | |
| 612 if (fd->back) { \ | |
| 613 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "background", fd->back, NULL); \ | |
| 614 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \ | |
| 615 } \ | |
| 616 if (fd->face) { \ | |
| 617 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "font", fd->face, NULL); \ | |
| 618 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \ | |
| 619 } \ | |
| 620 if (fd->size) { \ | |
| 621 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "size-points", (double)POINT_SIZE(fd->size), NULL); \ | |
| 622 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \ | |
| 623 } \ | |
| 624 } \ | |
| 625 if (url) { \ | |
| 626 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "foreground", "blue", "underline", PANGO_UNDERLINE_SINGLE, NULL); \ | |
| 627 g_signal_connect(G_OBJECT(texttag), "event", G_CALLBACK(tag_event), strdup(url)); \ | |
| 628 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \ | |
| 629 } \ | |
| 630 wpos = 0; \ | |
| 631 ws[0] = 0; \ | |
| 632 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); \ | |
| 4343 | 633 if (x == NEW_HR_BIT) { \ |
| 634 GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, &iter); \ | |
| 635 GtkWidget *sep = gtk_hseparator_new(); \ | |
| 636 gtk_widget_set_size_request(GTK_WIDGET(sep), 5000, 2); \ | |
| 3922 | 637 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), sep, anchor); \ |
| 638 gtk_widget_show(sep); \ | |
| 4343 | 639 } \ |
| 3922 | 640 |
| 641 GString* gtk_imhtml_append_text (GtkIMHtml *imhtml, | |
| 642 const gchar *text, | |
| 643 gint len, | |
| 644 GtkIMHtmlOptions options) | |
| 1428 | 645 { |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
646 gint pos = 0; |
| 3922 | 647 GString *str = NULL; |
| 648 GtkTextIter iter, siter; | |
| 649 GtkTextMark *mark, *mark2; | |
| 650 GtkTextTag *texttag; | |
| 651 gchar *ws; | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
652 gchar *tag; |
| 3922 | 653 gchar *url = NULL; |
| 654 gchar *bg = NULL; | |
| 4032 | 655 gint tlen, smilelen, wpos=0; |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
656 gint type; |
| 3922 | 657 const gchar *c; |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
658 gchar amp; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
659 |
| 1428 | 660 guint bold = 0, |
| 661 italics = 0, | |
| 662 underline = 0, | |
| 663 strike = 0, | |
| 664 sub = 0, | |
| 665 sup = 0, | |
|
1691
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
666 title = 0, |
| 3922 | 667 pre = 0; |
| 1428 | 668 |
| 3922 | 669 GSList *fonts = NULL; |
| 1428 | 670 |
| 671 g_return_val_if_fail (imhtml != NULL, NULL); | |
| 672 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL); | |
| 673 g_return_val_if_fail (text != NULL, NULL); | |
| 3922 | 674 g_return_val_if_fail (len != 0, NULL); |
| 675 | |
| 676 c = text; | |
| 677 if (len == -1) | |
| 678 len = strlen(text); | |
| 679 ws = g_malloc(len + 1); | |
| 680 ws[0] = 0; | |
| 1428 | 681 |
| 682 if (options & GTK_IMHTML_RETURN_LOG) | |
| 3922 | 683 str = g_string_new(""); |
| 1428 | 684 |
| 3922 | 685 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
| 686 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
|
687 while (pos < len) { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
688 if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
689 c++; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
690 pos++; |
| 3922 | 691 switch (type) |
| 692 { | |
| 693 case 1: /* B */ | |
| 694 case 2: /* BOLD */ | |
| 695 NEW_BIT (NEW_TEXT_BIT); | |
| 696 bold++; | |
| 697 break; | |
| 698 case 3: /* /B */ | |
| 699 case 4: /* /BOLD */ | |
| 700 NEW_BIT (NEW_TEXT_BIT); | |
| 701 if (bold) | |
| 702 bold--; | |
| 703 break; | |
| 704 case 5: /* I */ | |
| 705 case 6: /* ITALIC */ | |
| 706 NEW_BIT (NEW_TEXT_BIT); | |
| 707 italics++; | |
| 708 break; | |
| 709 case 7: /* /I */ | |
| 710 case 8: /* /ITALIC */ | |
| 711 NEW_BIT (NEW_TEXT_BIT); | |
| 712 if (italics) | |
| 713 italics--; | |
| 714 break; | |
| 715 case 9: /* U */ | |
| 716 case 10: /* UNDERLINE */ | |
| 717 NEW_BIT (NEW_TEXT_BIT); | |
| 718 underline++; | |
| 719 break; | |
| 720 case 11: /* /U */ | |
| 721 case 12: /* /UNDERLINE */ | |
| 722 NEW_BIT (NEW_TEXT_BIT); | |
| 723 if (underline) | |
| 724 underline--; | |
| 725 break; | |
| 726 case 13: /* S */ | |
| 727 case 14: /* STRIKE */ | |
| 728 NEW_BIT (NEW_TEXT_BIT); | |
| 729 strike++; | |
| 730 break; | |
| 731 case 15: /* /S */ | |
| 732 case 16: /* /STRIKE */ | |
| 733 NEW_BIT (NEW_TEXT_BIT); | |
| 734 if (strike) | |
| 735 strike--; | |
| 736 break; | |
| 737 case 17: /* SUB */ | |
| 738 NEW_BIT (NEW_TEXT_BIT); | |
| 739 sub++; | |
| 740 break; | |
| 741 case 18: /* /SUB */ | |
| 742 NEW_BIT (NEW_TEXT_BIT); | |
| 743 if (sub) | |
| 744 sub--; | |
| 745 break; | |
| 746 case 19: /* SUP */ | |
| 747 NEW_BIT (NEW_TEXT_BIT); | |
| 748 sup++; | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
749 break; |
| 3922 | 750 case 20: /* /SUP */ |
| 751 NEW_BIT (NEW_TEXT_BIT); | |
| 752 if (sup) | |
| 753 sup--; | |
| 754 break; | |
| 755 case 21: /* PRE */ | |
| 756 NEW_BIT (NEW_TEXT_BIT); | |
| 757 pre++; | |
| 758 break; | |
| 759 case 22: /* /PRE */ | |
| 760 NEW_BIT (NEW_TEXT_BIT); | |
| 761 if (pre) | |
| 762 pre--; | |
| 763 break; | |
| 764 case 23: /* TITLE */ | |
| 765 NEW_BIT (NEW_TEXT_BIT); | |
| 766 title++; | |
| 767 break; | |
| 768 case 24: /* /TITLE */ | |
| 769 if (title) { | |
| 770 if (options & GTK_IMHTML_NO_TITLE) { | |
| 771 wpos = 0; | |
| 772 ws [wpos] = '\0'; | |
| 773 } | |
| 774 title--; | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
775 } |
| 3922 | 776 break; |
| 777 case 25: /* BR */ | |
| 778 ws[wpos] = '\n'; | |
| 779 wpos++; | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
780 NEW_BIT (NEW_TEXT_BIT); |
| 3922 | 781 break; |
| 782 case 26: /* HR */ | |
| 783 case 42: /* HR (opt) */ | |
| 784 ws[wpos++] = '\n'; | |
| 785 NEW_BIT(NEW_HR_BIT); | |
| 4343 | 786 ws[wpos++] = '\n'; |
| 3922 | 787 break; |
| 788 case 27: /* /FONT */ | |
| 789 if (fonts) { | |
| 790 FontDetail *font = fonts->data; | |
| 791 NEW_BIT (NEW_TEXT_BIT); | |
| 792 fonts = g_slist_remove (fonts, font); | |
| 793 if (font->face) | |
| 794 g_free (font->face); | |
| 795 if (font->fore) | |
| 796 g_free (font->fore); | |
| 797 if (font->back) | |
| 798 g_free (font->back); | |
| 4032 | 799 if (font->sml) |
| 800 g_free (font->sml); | |
| 3922 | 801 g_free (font); |
| 802 } | |
| 803 break; | |
| 804 case 28: /* /A */ | |
| 805 if (url) { | |
| 806 NEW_BIT(NEW_TEXT_BIT); | |
| 807 g_free(url); | |
| 808 url = NULL; | |
| 2993 | 809 break; |
| 810 } | |
| 3922 | 811 case 29: /* P */ |
| 812 case 30: /* /P */ | |
| 813 case 31: /* H3 */ | |
| 814 case 32: /* /H3 */ | |
| 815 case 33: /* HTML */ | |
| 816 case 34: /* /HTML */ | |
| 817 case 35: /* BODY */ | |
| 818 case 36: /* /BODY */ | |
| 819 case 37: /* FONT */ | |
| 820 case 38: /* HEAD */ | |
| 821 case 39: /* /HEAD */ | |
| 822 break; | |
| 823 case 40: /* BINARY */ | |
| 824 case 41: /* /BINARY */ | |
| 825 break; | |
| 826 case 43: /* FONT (opt) */ | |
| 827 { | |
| 4032 | 828 gchar *color, *back, *face, *size, *sml; |
| 3922 | 829 FontDetail *font, *oldfont = NULL; |
| 830 color = gtk_imhtml_get_html_opt (tag, "COLOR="); | |
| 831 back = gtk_imhtml_get_html_opt (tag, "BACK="); | |
| 832 face = gtk_imhtml_get_html_opt (tag, "FACE="); | |
| 833 size = gtk_imhtml_get_html_opt (tag, "SIZE="); | |
| 4032 | 834 sml = gtk_imhtml_get_html_opt (tag, "SML="); |
| 835 if (!(color || back || face || size || sml)) | |
| 3922 | 836 break; |
| 837 | |
| 838 NEW_BIT (NEW_TEXT_BIT); | |
| 839 | |
| 840 font = g_new0 (FontDetail, 1); | |
| 841 if (fonts) | |
| 842 oldfont = fonts->data; | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
843 |
| 3922 | 844 if (color && !(options & GTK_IMHTML_NO_COLOURS)) |
| 845 font->fore = color; | |
| 846 else if (oldfont && oldfont->fore) | |
| 847 font->fore = g_strdup(oldfont->fore); | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
848 |
| 3922 | 849 if (back && !(options & GTK_IMHTML_NO_COLOURS)) |
| 850 font->back = back; | |
| 851 else if (oldfont && oldfont->back) | |
| 852 font->back = g_strdup(oldfont->back); | |
| 853 | |
| 854 if (face && !(options & GTK_IMHTML_NO_FONTS)) | |
| 855 font->face = face; | |
| 856 else if (oldfont && oldfont->face) | |
| 857 font->face = g_strdup(oldfont->face); | |
| 4032 | 858 |
| 859 if (sml) | |
| 860 font->sml = sml; | |
| 861 else if (oldfont && oldfont->sml) | |
| 862 font->sml = g_strdup(oldfont->sml); | |
| 863 | |
| 3922 | 864 if (size && !(options & GTK_IMHTML_NO_SIZES)) { |
| 865 if (*size == '+') { | |
| 866 sscanf (size + 1, "%hd", &font->size); | |
| 867 font->size += 3; | |
| 868 } else if (*size == '-') { | |
| 869 sscanf (size + 1, "%hd", &font->size); | |
| 870 font->size = MAX (0, 3 - font->size); | |
| 871 } else if (isdigit (*size)) { | |
| 872 sscanf (size, "%hd", &font->size); | |
| 873 } | |
| 874 } else if (oldfont) | |
| 875 font->size = oldfont->size; | |
| 876 g_free(size); | |
| 877 fonts = g_slist_prepend (fonts, font); | |
| 878 } | |
| 879 break; | |
| 880 case 44: /* BODY (opt) */ | |
| 881 if (!(options & GTK_IMHTML_NO_COLOURS)) { | |
| 882 char *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR="); | |
| 883 if (bgcolor) { | |
| 884 NEW_BIT(NEW_TEXT_BIT); | |
| 885 if (bg) | |
| 886 g_free(bg); | |
| 887 bg = bgcolor; | |
|
2885
f72efa29c109
[gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2871
diff
changeset
|
888 } |
| 1428 | 889 } |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
890 break; |
| 3922 | 891 case 45: /* A (opt) */ |
| 892 { | |
| 893 gchar *href = gtk_imhtml_get_html_opt (tag, "HREF="); | |
| 894 if (href) { | |
| 895 NEW_BIT (NEW_TEXT_BIT); | |
| 896 if (url) | |
| 897 g_free (url); | |
| 898 url = href; | |
| 899 } | |
| 2993 | 900 } |
| 3922 | 901 break; |
| 902 case 47: /* P (opt) */ | |
| 903 case 48: /* H3 (opt) */ | |
| 2993 | 904 break; |
| 3922 | 905 case 49: /* comment */ |
| 906 NEW_BIT (NEW_TEXT_BIT); | |
| 4253 | 907 if (imhtml->show_comments) |
| 908 wpos = g_snprintf (ws, len, "%s", tag); | |
| 3922 | 909 NEW_BIT (NEW_COMMENT_BIT); |
| 910 break; | |
| 911 default: | |
| 912 break; | |
| 2993 | 913 } |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
914 c += tlen; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
915 pos += tlen; |
| 4138 | 916 if(tag) |
| 917 g_free(tag); /* This was allocated back in VALID_TAG() */ | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
918 } else if (*c == '&' && gtk_imhtml_is_amp_escape (c, &, &tlen)) { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
919 ws [wpos++] = amp; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
920 c += tlen; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
921 pos += tlen; |
| 1428 | 922 } else if (*c == '\n') { |
| 923 if (!(options & GTK_IMHTML_NO_NEWLINE)) { | |
| 3922 | 924 ws[wpos] = '\n'; |
| 925 wpos++; | |
| 1428 | 926 NEW_BIT (NEW_TEXT_BIT); |
| 927 } | |
| 928 c++; | |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
929 pos++; |
| 4253 | 930 } else if (imhtml->show_smileys && (gtk_imhtml_is_smiley (imhtml, fonts, c, &smilelen) || gtk_imhtml_is_smiley(imhtml, NULL, c, &smilelen))) { |
| 4032 | 931 FontDetail *fd; |
| 932 gchar *sml = NULL; | |
| 933 if (fonts) { | |
| 934 fd = fonts->data; | |
| 935 sml = fd->sml; | |
| 936 } | |
| 937 NEW_BIT (NEW_TEXT_BIT); | |
| 938 wpos = g_snprintf (ws, smilelen + 1, "%s", c); | |
| 4263 | 939 gtk_text_buffer_insert_pixbuf(imhtml->text_buffer, &iter, gtk_smiley_tree_image (imhtml, sml, ws)); |
| 4032 | 940 c += smilelen; |
| 941 pos += smilelen; | |
| 942 wpos = 0; | |
| 943 ws[0] = 0; | |
| 944 } else if (*c) { | |
| 1428 | 945 ws [wpos++] = *c++; |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
946 pos++; |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
947 } else { |
|
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2826
diff
changeset
|
948 break; |
| 1428 | 949 } |
| 950 } | |
| 3922 | 951 |
| 952 NEW_BIT(NEW_TEXT_BIT); | |
| 1428 | 953 if (url) { |
| 954 g_free (url); | |
| 3922 | 955 if (str) |
| 956 str = g_string_append (str, "</A>"); | |
| 1428 | 957 } |
| 3922 | 958 |
| 4032 | 959 while (fonts) { |
| 960 FontDetail *font = fonts->data; | |
| 961 fonts = g_slist_remove (fonts, font); | |
| 962 if (font->face) | |
| 963 g_free (font->face); | |
| 964 if (font->fore) | |
| 965 g_free (font->fore); | |
| 966 if (font->back) | |
| 967 g_free (font->back); | |
| 968 if (font->sml) | |
| 969 g_free (font->sml); | |
| 970 g_free (font); | |
| 971 if (str) | |
| 972 str = g_string_append (str, "</FONT>"); | |
| 973 } | |
| 974 | |
| 3922 | 975 if (str) { |
| 1428 | 976 while (bold) { |
| 3922 | 977 str = g_string_append (str, "</B>"); |
| 1428 | 978 bold--; |
| 979 } | |
| 980 while (italics) { | |
| 3922 | 981 str = g_string_append (str, "</I>"); |
| 1428 | 982 italics--; |
| 983 } | |
| 984 while (underline) { | |
| 3922 | 985 str = g_string_append (str, "</U>"); |
| 1428 | 986 underline--; |
| 987 } | |
| 988 while (strike) { | |
| 3922 | 989 str = g_string_append (str, "</S>"); |
| 1428 | 990 strike--; |
| 991 } | |
| 992 while (sub) { | |
| 3922 | 993 str = g_string_append (str, "</SUB>"); |
| 1428 | 994 sub--; |
| 995 } | |
| 996 while (sup) { | |
| 3922 | 997 str = g_string_append (str, "</SUP>"); |
| 1428 | 998 sup--; |
| 999 } | |
| 1000 while (title) { | |
| 3922 | 1001 str = g_string_append (str, "</TITLE>"); |
| 1428 | 1002 title--; |
| 1003 } | |
|
1691
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
1004 while (pre) { |
| 3922 | 1005 str = g_string_append (str, "</PRE>"); |
|
1691
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
1006 pre--; |
|
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
1007 } |
| 1428 | 1008 } |
| 4032 | 1009 g_free (ws); |
| 1010 if (!(options & GTK_IMHTML_NO_SCROLL)) | |
| 1011 gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (imhtml), mark, | |
| 1012 0, TRUE, 0.0, 1.0); | |
| 3922 | 1013 gtk_text_buffer_delete_mark (imhtml->text_buffer, mark); |
| 1014 return str; | |
| 1015 } | |
| 1016 | |
| 1017 void gtk_imhtml_set_img_handler (GtkIMHtml *imhtml, | |
| 1018 GtkIMHtmlImage handler){} | |
| 1019 | |
| 4288 | 1020 void gtk_imhtml_remove_smileys(GtkIMHtml *imhtml) |
| 1021 { | |
| 1022 g_hash_table_destroy(imhtml->smiley_data); | |
| 1023 gtk_smiley_tree_destroy(imhtml->default_smilies); | |
| 1024 imhtml->smiley_data = g_hash_table_new (g_str_hash, g_str_equal); | |
| 1025 imhtml->default_smilies = gtk_smiley_tree_new(); | |
| 1026 } | |
| 3922 | 1027 void gtk_imhtml_show_smileys (GtkIMHtml *imhtml, |
| 4253 | 1028 gboolean show) |
| 1029 { | |
| 1030 imhtml->show_smileys = show; | |
| 1031 } | |
| 3922 | 1032 |
| 1033 void gtk_imhtml_show_comments (GtkIMHtml *imhtml, | |
| 4253 | 1034 gboolean show) |
| 1035 { | |
| 1036 imhtml->show_comments = show; | |
| 1037 } | |
|
1780
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
1038 |
|
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
1039 void |
|
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
1040 gtk_imhtml_clear (GtkIMHtml *imhtml) |
|
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
1041 { |
| 3922 | 1042 GtkTextIter start, end; |
| 2993 | 1043 |
| 3922 | 1044 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); |
| 1045 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 1046 gtk_text_buffer_delete(imhtml->text_buffer, &start, &end); | |
|
1780
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
1047 } |
|
2363
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
1048 |
| 4046 | 1049 void gtk_imhtml_page_up (GtkIMHtml *imhtml) |
| 1050 { | |
| 1051 | |
| 1052 } | |
| 3922 | 1053 void gtk_imhtml_page_down (GtkIMHtml *imhtml){} |
