aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl.c
diff options
context:
space:
mode:
authorGravatar Barrucadu <mike@barrucadu.co.uk>2009-05-01 16:29:27 +0100
committerGravatar Barrucadu <mike@barrucadu.co.uk>2009-05-01 16:29:27 +0100
commit772ac45fff0511e0d83949b94a21304e76209507 (patch)
tree83dd550e9969a6336ec60532519367d839fa1c8e /uzbl.c
parent8ba87ad7653bff70bf44106dc1e3fe1d3e99d9f0 (diff)
parent921b5985eb6c5c82ef68fda58cdfce1f3c2f18ce (diff)
Merge branch 'dieter/experimental' into experimental
Conflicts: uzbl.c
Diffstat (limited to 'uzbl.c')
-rw-r--r--uzbl.c56
1 files changed, 54 insertions, 2 deletions
diff --git a/uzbl.c b/uzbl.c
index eec7097..ed4859a 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -55,6 +55,10 @@
static GtkWidget* main_window;
static GtkWidget* mainbar;
static GtkWidget* mainbar_label;
+static GtkScrollbar* scbar_v; // Horizontal and Vertical Scrollbar
+static GtkScrollbar* scbar_h; // (These are still hidden)
+static GtkAdjustment* bar_v; // Information about document length
+static GtkAdjustment* bar_h; // and scrolling position
static WebKitWebView* web_view;
static gchar* main_title;
static gchar selected_url[500] = "\0";
@@ -81,6 +85,8 @@ static gboolean insert_mode = FALSE;
static gboolean status_top = FALSE;
static gchar* modkey = NULL;
static guint modmask = 0;
+static gdouble hscroll = 20;
+static gdouble vscroll = 20;
/* settings from config: group bindings, key -> action */
static GHashTable* bindings;
@@ -144,10 +150,45 @@ download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data) {
return (FALSE);
}
+/* scroll a bar in a given direction */
+static void
+scroll (double i, GtkAdjustment* bar) {
+ gtk_adjustment_set_value (bar, gtk_adjustment_get_value(bar)+i);
+}
+
+static void scroll_up (WebKitWebView* page, const char *param) {
+ (void) page;
+ (void) param;
+
+ scroll (-vscroll, bar_v);
+}
+
+static void scroll_left (WebKitWebView* page, const char *param) {
+ (void) page;
+ (void) param;
+
+ scroll (-hscroll, bar_h);
+}
+
+static void scroll_down (WebKitWebView* page, const char *param) {
+ (void) page;
+ (void) param;
+
+ scroll (vscroll, bar_v);
+}
+
+static void scroll_right (WebKitWebView* page, const char *param) {
+ (void) page;
+ (void) param;
+
+ scroll (hscroll, bar_h);
+}
+
static void
toggle_status_cb (WebKitWebView* page, const char *param) {
(void)page;
(void)param;
+
if (show_status) {
gtk_widget_hide(mainbar);
} else {
@@ -239,6 +280,10 @@ static struct {char *name; Command command;} cmdlist[] =
{
{ "back", view_go_back },
{ "forward", view_go_forward },
+ { "scroll_down", scroll_down },
+ { "scroll_up", scroll_up },
+ { "scroll_left", scroll_left },
+ { "scroll_right", scroll_right },
{ "reload", view_reload, }, //Buggy
{ "refresh", view_reload, }, /* for convenience, will change */
{ "stop", view_stop_loading, },
@@ -497,6 +542,7 @@ static void
setup_threading () {
pthread_t control_thread;
pthread_create(&control_thread, NULL, control_socket, NULL);
+ pthread_detach(control_thread);
}
static void
@@ -546,9 +592,9 @@ key_press_cb (WebKitWebView* page, GdkEventKey* event)
|| event->keyval == GDK_Up || event->keyval == GDK_Down || event->keyval == GDK_Left || event->keyval == GDK_Right)
return FALSE;
- /* turn of insert mode */
+ /* turn off insert mode (if always_insert_mode is not used) */
if (insert_mode && (event->keyval == GDK_Escape)) {
- insert_mode = !insert_mode || always_insert_mode;
+ insert_mode = always_insert_mode;
update_title();
return TRUE;
}
@@ -791,6 +837,12 @@ main (int argc, char* argv[]) {
printf("window_id %i\n",(int) xwin);
printf("pid %i\n", getpid ());
+ scbar_v = (GtkScrollbar*) gtk_vscrollbar_new (NULL);
+ bar_v = gtk_range_get_adjustment((GtkRange*) scbar_v);
+ scbar_h = (GtkScrollbar*) gtk_hscrollbar_new (NULL);
+ bar_h = gtk_range_get_adjustment((GtkRange*) scbar_h);
+ gtk_widget_set_scroll_adjustments ((GtkWidget*) web_view, bar_h, bar_v);
+
if (!show_status)
gtk_widget_hide(mainbar);