diff options
author | Brendan Taylor <whateley@gmail.com> | 2009-06-20 12:09:37 -0600 |
---|---|---|
committer | Brendan Taylor <whateley@gmail.com> | 2009-06-20 12:09:37 -0600 |
commit | 12af838675fa5eae32a8b97cf8fe81c2c812639f (patch) | |
tree | 09717aaeaf61749adac992d91b722bab1cbb57be /uzbl.c | |
parent | 02b987003a3c4799e47311294c033dcc355b9974 (diff) |
don't scroll past the end of the page.
Diffstat (limited to 'uzbl.c')
-rw-r--r-- | uzbl.c | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -445,12 +445,24 @@ download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data) { /* scroll a bar in a given direction */ static void scroll (GtkAdjustment* bar, GArray *argv) { - gdouble amount; gchar *end; + gdouble max_value; - amount = g_ascii_strtod(g_array_index(argv, gchar*, 0), &end); - if (*end == '%') amount = gtk_adjustment_get_page_size(bar) * amount * 0.01; - gtk_adjustment_set_value (bar, gtk_adjustment_get_value(bar)+amount); + gdouble page_size = gtk_adjustment_get_page_size(bar); + gdouble value = gtk_adjustment_get_value(bar); + gdouble amount = g_ascii_strtod(g_array_index(argv, gchar*, 0), &end); + + if (*end == '%') + value += page_size * amount * 0.01; + else + value += amount; + + max_value = gtk_adjustment_get_upper(bar) - page_size; + + if (value > max_value) + value = max_value; /* don't scroll past the end of the page */ + + gtk_adjustment_set_value (bar, value); } static void |