Mercurial > pidgin
comparison src/gtkimhtml.c @ 12553:9d7fb0b21d9f
[gaim-migrate @ 14871]
one reactionary pref down, eleventy billion to go
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Mon, 19 Dec 2005 05:55:30 +0000 |
parents | a88ca6da0b38 |
children | e856f985a0b9 |
comparison
equal
deleted
inserted
replaced
12552:5e6c3f539eb6 | 12553:9d7fb0b21d9f |
---|---|
2311 gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &sel, sel_offset); | 2311 gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &sel, sel_offset); |
2312 gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_selection_bound(imhtml->text_buffer), &sel); | 2312 gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_selection_bound(imhtml->text_buffer), &sel); |
2313 } | 2313 } |
2314 | 2314 |
2315 if (!(options & GTK_IMHTML_NO_SCROLL)) { | 2315 if (!(options & GTK_IMHTML_NO_SCROLL)) { |
2316 gtk_imhtml_scroll_to_end(imhtml); | 2316 gtk_imhtml_scroll_to_end(imhtml, (options & GTK_IMHTML_USE_SMOOTHSCROLLING)); |
2317 } | 2317 } |
2318 } | 2318 } |
2319 | 2319 |
2320 #define MAX_SCROLL_TIME 0.4 /* seconds */ | 2320 #define MAX_SCROLL_TIME 0.4 /* seconds */ |
2321 #define SCROLL_DELAY 33 /* milliseconds */ | 2321 #define SCROLL_DELAY 33 /* milliseconds */ |
2344 /* scroll by 1/3rd the remaining distance */ | 2344 /* scroll by 1/3rd the remaining distance */ |
2345 gtk_adjustment_set_value(adj, gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3)); | 2345 gtk_adjustment_set_value(adj, gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3)); |
2346 return TRUE; | 2346 return TRUE; |
2347 } | 2347 } |
2348 | 2348 |
2349 static gboolean scroll_idle_cb(gpointer data) | 2349 static gboolean smooth_scroll_idle_cb(gpointer data) |
2350 { | 2350 { |
2351 GtkIMHtml *imhtml = data; | 2351 GtkIMHtml *imhtml = data; |
2352 imhtml->scroll_src = g_timeout_add(SCROLL_DELAY, scroll_cb, imhtml); | 2352 imhtml->scroll_src = g_timeout_add(SCROLL_DELAY, scroll_cb, imhtml); |
2353 return FALSE; | 2353 return FALSE; |
2354 } | 2354 } |
2355 | 2355 |
2356 void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml) | 2356 static gboolean scroll_idle_cb(gpointer data) |
2357 { | |
2358 GtkIMHtml *imhtml = data; | |
2359 GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; | |
2360 if(adj) { | |
2361 gtk_adjustment_set_value(adj, adj->upper - adj->page_size); | |
2362 } | |
2363 imhtml->scroll_src = 0; | |
2364 return FALSE; | |
2365 } | |
2366 | |
2367 void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml, gboolean smooth) | |
2357 { | 2368 { |
2358 if (imhtml->scroll_time) | 2369 if (imhtml->scroll_time) |
2359 g_timer_destroy(imhtml->scroll_time); | 2370 g_timer_destroy(imhtml->scroll_time); |
2360 imhtml->scroll_time = g_timer_new(); | |
2361 if (imhtml->scroll_src) | 2371 if (imhtml->scroll_src) |
2362 g_source_remove(imhtml->scroll_src); | 2372 g_source_remove(imhtml->scroll_src); |
2363 imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, imhtml, NULL); | 2373 if(smooth) { |
2374 imhtml->scroll_time = g_timer_new(); | |
2375 imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, smooth_scroll_idle_cb, imhtml, NULL); | |
2376 } else { | |
2377 imhtml->scroll_time = NULL; | |
2378 imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, imhtml, NULL); | |
2379 } | |
2364 } | 2380 } |
2365 | 2381 |
2366 void gtk_imhtml_insert_html_at_iter(GtkIMHtml *imhtml, | 2382 void gtk_imhtml_insert_html_at_iter(GtkIMHtml *imhtml, |
2367 const gchar *text, | 2383 const gchar *text, |
2368 GtkIMHtmlOptions options, | 2384 GtkIMHtmlOptions options, |