diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2009-03-17 12:26:41 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2009-03-17 12:26:41 +0000 |
commit | 58cd1423383babef4a59e25f3e9f6a950d2fa6dc (patch) | |
tree | 66ecca9b8efa5fc429fd51cc6412d39df45b8f54 /gtk | |
parent | 6e9618484eef9646115cea549c8e4453b9b9e565 (diff) | |
download | netsurf-58cd1423383babef4a59e25f3e9f6a950d2fa6dc.tar.gz netsurf-58cd1423383babef4a59e25f3e9f6a950d2fa6dc.tar.bz2 |
Remember the scroll position in the history, so that it's maintained when going back. (credit: Paweł Blokus)
svn path=/trunk/netsurf/; revision=6793
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtk_scaffolding.c | 7 | ||||
-rw-r--r-- | gtk/gtk_window.c | 21 | ||||
-rw-r--r-- | gtk/gtk_window.h | 1 |
3 files changed, 29 insertions, 0 deletions
diff --git a/gtk/gtk_scaffolding.c b/gtk/gtk_scaffolding.c index 8e687184c..a2c46ef17 100644 --- a/gtk/gtk_scaffolding.c +++ b/gtk/gtk_scaffolding.c @@ -1064,6 +1064,12 @@ MENUHANDLER(local_history) { struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g; + /* if entries of the same url but different frag_ids have been added + * the history needs redrawing (what is done in the throbber code in + * other cases) + */ + nsgtk_window_update_back_forward(gw); + gtk_widget_show(GTK_WIDGET(gw->history_window->window)); gdk_window_raise(GTK_WIDGET(gw->history_window->window)->window); @@ -1149,6 +1155,7 @@ gboolean nsgtk_history_button_press_event(GtkWidget *widget, history_click(bw, bw->history, event->x, event->y, false); + nsgtk_window_update_back_forward(bw->window->scaffold); return TRUE; } diff --git a/gtk/gtk_window.c b/gtk/gtk_window.c index 1784f5926..7ab698e44 100644 --- a/gtk/gtk_window.c +++ b/gtk/gtk_window.c @@ -20,6 +20,7 @@ #include <inttypes.h> #include "gtk/gtk_window.h" #include "desktop/browser.h" +#include "desktop/history_core.h" #include "desktop/options.h" #include "desktop/textinput.h" #include "desktop/selection.h" @@ -52,6 +53,7 @@ static gboolean nsgtk_window_keypress_event(GtkWidget *, GdkEventKey *, gpointer); static gboolean nsgtk_window_size_allocate_event(GtkWidget *, GtkAllocation *, gpointer); +static void nsgtk_window_scrolled(GtkAdjustment *, gpointer); /* Other useful bits */ static void nsgtk_redraw_caret(struct gui_window *g); @@ -85,6 +87,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, { struct gui_window *g; /**< what we're creating to return */ GtkPolicyType scrollpolicy; + GtkAdjustment *vadj; + GtkAdjustment *hadj; g = malloc(sizeof(*g)); if (!g) { @@ -140,6 +144,9 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, GTK_SHADOW_NONE); g->viewport = GTK_VIEWPORT(gtk_bin_get_child(GTK_BIN(g->scrolledwindow))); g->tab = NULL; + + vadj = gtk_viewport_get_vadjustment(g->viewport); + hadj = gtk_viewport_get_hadjustment(g->viewport); if (bw->parent != NULL) /* Attach ourselves into our parent at the right point */ @@ -225,6 +232,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, nsgtk_window_keypress_event, g); CONNECT(g->viewport, "size_allocate", nsgtk_window_size_allocate_event, g); + CONNECT(vadj, "value-changed", nsgtk_window_scrolled, g); + CONNECT(hadj, "value-changed", nsgtk_window_scrolled, g); return g; } @@ -582,6 +591,16 @@ gboolean nsgtk_window_size_allocate_event(GtkWidget *widget, return TRUE; } +void nsgtk_window_scrolled(GtkAdjustment *ga, gpointer data) +{ + struct gui_window *g = data; + int sx, sy; + + if (!g->setting_scroll) { + gui_window_get_scroll(g->bw->window, &sx, &sy); + history_set_current_scroll(g->bw->history, sx, sy); + } +} void nsgtk_reflow_all_windows(void) { @@ -718,8 +737,10 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy) if (y > (vupper - vpage)) y = vupper - vpage; + g->setting_scroll = true; gtk_adjustment_set_value(vadj, y); gtk_adjustment_set_value(hadj, x); + g->setting_scroll = false; } diff --git a/gtk/gtk_window.h b/gtk/gtk_window.h index 0f99549a7..ba81ad171 100644 --- a/gtk/gtk_window.h +++ b/gtk/gtk_window.h @@ -34,6 +34,7 @@ struct gui_window { int caretx, carety, careth; gui_pointer_shape current_pointer; int last_x, last_y; + bool setting_scroll; /* Within GTK, a gui_window is a scrolled window * with a viewport inside |