aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl.c
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <whateley@gmail.com>2009-06-20 12:09:37 -0600
committerGravatar Brendan Taylor <whateley@gmail.com>2009-06-20 12:09:37 -0600
commit12af838675fa5eae32a8b97cf8fe81c2c812639f (patch)
tree09717aaeaf61749adac992d91b722bab1cbb57be /uzbl.c
parent02b987003a3c4799e47311294c033dcc355b9974 (diff)
don't scroll past the end of the page.
Diffstat (limited to 'uzbl.c')
-rw-r--r--uzbl.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/uzbl.c b/uzbl.c
index b9e5d68..e6e9551 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -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