Mercurial > pidgin.yaz
comparison gtk/gtkimhtml.c @ 15318:d928cf5ead1b
[gaim-migrate @ 18108]
bug fix. Breaks 'don't scroll if you're not already scrolled at the bottom' and selecton. I'll look at those tomorrow, but amd committing it in case someone knowledgable wants to beat me to it.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Thu, 11 Jan 2007 08:43:34 +0000 |
parents | d728da06e0e8 |
children | 3abb476aab94 |
comparison
equal
deleted
inserted
replaced
15317:a92c64f06995 | 15318:d928cf5ead1b |
---|---|
1218 | 1218 |
1219 g_list_free(imhtml->scalables); | 1219 g_list_free(imhtml->scalables); |
1220 g_slist_free(imhtml->im_images); | 1220 g_slist_free(imhtml->im_images); |
1221 g_free(imhtml->protocol_name); | 1221 g_free(imhtml->protocol_name); |
1222 g_free(imhtml->search_string); | 1222 g_free(imhtml->search_string); |
1223 g_object_unref(imhtml->empty_buffer); | |
1224 g_object_unref(imhtml->text_buffer); | |
1223 G_OBJECT_CLASS(parent_class)->finalize (object); | 1225 G_OBJECT_CLASS(parent_class)->finalize (object); |
1224 } | 1226 } |
1225 | 1227 |
1226 /* Boring GTK+ stuff */ | 1228 /* Boring GTK+ stuff */ |
1227 static void gtk_imhtml_class_init (GtkIMHtmlClass *klass) | 1229 static void gtk_imhtml_class_init (GtkIMHtmlClass *klass) |
1315 | 1317 |
1316 static void gtk_imhtml_init (GtkIMHtml *imhtml) | 1318 static void gtk_imhtml_init (GtkIMHtml *imhtml) |
1317 { | 1319 { |
1318 GtkTextIter iter; | 1320 GtkTextIter iter; |
1319 imhtml->text_buffer = gtk_text_buffer_new(NULL); | 1321 imhtml->text_buffer = gtk_text_buffer_new(NULL); |
1322 imhtml->empty_buffer = gtk_text_buffer_new(NULL); | |
1320 gtk_text_buffer_get_end_iter (imhtml->text_buffer, &iter); | 1323 gtk_text_buffer_get_end_iter (imhtml->text_buffer, &iter); |
1321 gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->text_buffer); | 1324 gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->text_buffer); |
1322 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR); | 1325 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR); |
1323 gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(imhtml), 5); | 1326 gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(imhtml), 5); |
1324 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(imhtml), 2); | 1327 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(imhtml), 2); |
2353 imhtml->scroll_time = NULL; | 2356 imhtml->scroll_time = NULL; |
2354 imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, imhtml, NULL); | 2357 imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, imhtml, NULL); |
2355 } | 2358 } |
2356 } | 2359 } |
2357 | 2360 |
2361 static gboolean | |
2362 set_adj_idle_cb(gpointer data) | |
2363 { | |
2364 GtkIMHtml *imhtml = data; | |
2365 gtk_adjustment_set_value(GTK_TEXT_VIEW(imhtml)->vadjustment, imhtml->adj); | |
2366 return FALSE; | |
2367 } | |
2368 | |
2358 void gtk_imhtml_insert_html_at_iter(GtkIMHtml *imhtml, | 2369 void gtk_imhtml_insert_html_at_iter(GtkIMHtml *imhtml, |
2359 const gchar *text, | 2370 const gchar *text, |
2360 GtkIMHtmlOptions options, | 2371 GtkIMHtmlOptions options, |
2361 GtkTextIter *iter) | 2372 GtkTextIter *iter) |
2362 { | 2373 { |
2363 GdkRectangle rect; | 2374 GdkRectangle rect; |
2375 GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; | |
2364 gint pos = 0; | 2376 gint pos = 0; |
2365 gchar *ws; | 2377 gchar *ws; |
2366 gchar *tag; | 2378 gchar *tag; |
2367 gchar *bg = NULL; | 2379 gchar *bg = NULL; |
2368 gint len; | 2380 gint len; |
2370 gint type; | 2382 gint type; |
2371 const gchar *c; | 2383 const gchar *c; |
2372 gchar *amp; | 2384 gchar *amp; |
2373 gint len_protocol; | 2385 gint len_protocol; |
2374 | 2386 |
2387 | |
2375 guint bold = 0, | 2388 guint bold = 0, |
2376 italics = 0, | 2389 italics = 0, |
2377 underline = 0, | 2390 underline = 0, |
2378 strike = 0, | 2391 strike = 0, |
2379 sub = 0, | 2392 sub = 0, |
2392 g_return_if_fail (text != NULL); | 2405 g_return_if_fail (text != NULL); |
2393 c = text; | 2406 c = text; |
2394 len = strlen(text); | 2407 len = strlen(text); |
2395 ws = g_malloc(len + 1); | 2408 ws = g_malloc(len + 1); |
2396 ws[0] = 0; | 2409 ws[0] = 0; |
2410 | |
2411 imhtml->adj = gtk_adjustment_get_value(adj); | |
2412 gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->empty_buffer); | |
2397 | 2413 |
2398 while (pos < len) { | 2414 while (pos < len) { |
2399 if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) { | 2415 if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) { |
2400 c++; | 2416 c++; |
2401 pos++; | 2417 pos++; |
3050 | 3066 |
3051 if (!imhtml->wbfo) | 3067 if (!imhtml->wbfo) |
3052 gtk_imhtml_close_tags(imhtml, iter); | 3068 gtk_imhtml_close_tags(imhtml, iter); |
3053 | 3069 |
3054 object = g_object_ref(G_OBJECT(imhtml)); | 3070 object = g_object_ref(G_OBJECT(imhtml)); |
3071 gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->text_buffer); | |
3072 g_idle_add(set_adj_idle_cb, imhtml); | |
3055 g_signal_emit(object, signals[UPDATE_FORMAT], 0); | 3073 g_signal_emit(object, signals[UPDATE_FORMAT], 0); |
3056 g_object_unref(object); | 3074 g_object_unref(object); |
3057 | 3075 |
3058 } | 3076 } |
3059 | 3077 |