[hackers] [surf] Keybindings for scrolling left and right; code by stanio. || Troels Henriksen
changeset: 240:ee772272a082
tag: tip
user: Troels Henriksen <athas_AT_sigkill.dk>
date: Thu May 31 11:46:24 2012 +0200
files: config.def.h surf.c
description:
Keybindings for scrolling left and right; code by stanio.
diff -r 51a6d05c2c84 -r ee772272a082 config.def.h
--- a/config.def.h Mon Mar 26 09:33:42 2012 +0200
+++ b/config.def.h Thu May 31 11:46:24 2012 +0200
_AT_@ -34,8 +34,14 @@
{ MODKEY|GDK_SHIFT_MASK,GDK_i, zoom, { .i = 0 } },
{ MODKEY, GDK_l, navigate, { .i = +1 } },
{ MODKEY, GDK_h, navigate, { .i = -1 } },
- { MODKEY, GDK_j, scroll, { .i = +1 } },
- { MODKEY, GDK_k, scroll, { .i = -1 } },
+ { MODKEY, GDK_j, scroll_v, { .i = +1 } },
+ { MODKEY, GDK_k, scroll_v, { .i = -1 } },
+ { MODKEY, GDK_g, scroll_v, { .i = -20000 } },
+ { MODKEY|GDK_SHIFT_MASK,GDK_g, scroll_v, { .i = +20000 } },
+ { MODKEY, GDK_b, scroll_v, { .i = -10000 } },
+ { MODKEY, GDK_space, scroll_v, { .i = +10000 } },
+ { MODKEY, GDK_l, scroll_h, { .i = +1 } },
+ { MODKEY, GDK_h, scroll_h, { .i = -1 } },
{ 0, GDK_Escape, stop, { 0 } },
{ MODKEY, GDK_o, source, { 0 } },
{ MODKEY, GDK_g, spawn, SETPROP("_SURF_URI", "_SURF_GO") },
diff -r 51a6d05c2c84 -r ee772272a082 surf.c
--- a/surf.c Mon Mar 26 09:33:42 2012 +0200
+++ b/surf.c Thu May 31 11:46:24 2012 +0200
_AT_@ -96,7 +96,9 @@
static void progresschange(WebKitWebView *view, GParamSpec *pspec, Client *c);
static void reload(Client *c, const Arg *arg);
static void resize(GtkWidget *w, GtkAllocation *a, Client *c);
-static void scroll(Client *c, const Arg *arg);
+static void scroll_h(Client *c, const Arg *arg);
+static void scroll_v(Client *c, const Arg *arg);
+static void scroll(GtkAdjustment *a, const Arg *arg);
static void setatom(Client *c, int a, const char *v);
static void setcookie(SoupCookie *c);
static void setup(void);
_AT_@ -662,16 +664,32 @@
}
void
-scroll(Client *c, const Arg *arg) {
- gdouble v;
- GtkAdjustment *a;
+scroll_h(Client *c, const Arg *arg) {
+ scroll(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(c->scroll)), arg);
+}
- a = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(c->scroll));
- v = gtk_adjustment_get_value(a);
- v += gtk_adjustment_get_step_increment(a) * arg->i;
- v = MAX(v, 0.0);
- v = MIN(v, gtk_adjustment_get_upper(a) - gtk_adjustment_get_page_size(a));
- gtk_adjustment_set_value(a, v);
+void
+scroll_v(Client *c, const Arg *arg) {
+ scroll(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(c->scroll)), arg);
+}
+
+void
+scroll(GtkAdjustment *a, const Arg *arg) {
+ gdouble v;
+
+ v = gtk_adjustment_get_value(a);
+ switch (arg->i){
+ case +10000:
+ case -10000:
+ v += gtk_adjustment_get_page_increment(a) * (arg->i / 10000); break;
+ case +20000:
+ case -20000:
+ default:
+ v += gtk_adjustment_get_step_increment(a) * arg->i;
+ }
+ v = MAX(v, 0.0);
+ v = MIN(v, gtk_adjustment_get_upper(a) - gtk_adjustment_get_page_size(a));
+ gtk_adjustment_set_value(a, v);
}
void
Received on Fri Jun 01 2012 - 09:10:36 CEST
This archive was generated by hypermail 2.3.0
: Fri Jun 01 2012 - 09:12:06 CEST