pidgin/gtkimhtml.c

changeset 19055
43f5771c45f4
parent 18985
877a49e0979d
child 19103
f69a568a9fe2
equal deleted inserted replaced
19054:1c2d94afac92 19055:43f5771c45f4
2268 static gboolean scroll_cb(gpointer data) 2268 static gboolean scroll_cb(gpointer data)
2269 { 2269 {
2270 GtkIMHtml *imhtml = data; 2270 GtkIMHtml *imhtml = data;
2271 GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; 2271 GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment;
2272 gdouble max_val = adj->upper - adj->page_size; 2272 gdouble max_val = adj->upper - adj->page_size;
2273 gdouble scroll_val = gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3);
2273 2274
2274 g_return_val_if_fail(imhtml->scroll_time != NULL, FALSE); 2275 g_return_val_if_fail(imhtml->scroll_time != NULL, FALSE);
2275 2276
2276 if (g_timer_elapsed(imhtml->scroll_time, NULL) > MAX_SCROLL_TIME) { 2277 if (g_timer_elapsed(imhtml->scroll_time, NULL) > MAX_SCROLL_TIME || scroll_val >= max_val) {
2277 /* time's up. jump to the end and kill the timer */ 2278 /* time's up. jump to the end and kill the timer */
2278 gtk_adjustment_set_value(adj, max_val); 2279 gtk_adjustment_set_value(adj, max_val);
2279 g_timer_destroy(imhtml->scroll_time); 2280 g_timer_destroy(imhtml->scroll_time);
2280 imhtml->scroll_time = NULL; 2281 imhtml->scroll_time = NULL;
2281 return FALSE; 2282 return FALSE;
2282 } 2283 }
2283 2284
2284 /* scroll by 1/3rd the remaining distance */ 2285 /* scroll by 1/3rd the remaining distance */
2285 gtk_adjustment_set_value(adj, gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3)); 2286 gtk_adjustment_set_value(adj, scroll_val);
2286 return TRUE; 2287 return TRUE;
2287 } 2288 }
2288 2289
2289 static gboolean smooth_scroll_idle_cb(gpointer data) 2290 static gboolean smooth_scroll_idle_cb(gpointer data)
2290 { 2291 {

mercurial