[Xfce4-commits] <midori:master> Conditionalize restoring of the scrolling position
Christian Dywan
noreply at xfce.org
Thu Oct 8 21:28:01 CEST 2009
Updating branch refs/heads/master
to fa8f109da91310589c459bb94ae9c4616574b634 (commit)
from 0706bdbbe76273fff6cc5efa9d7800297369ce5e (commit)
commit fa8f109da91310589c459bb94ae9c4616574b634
Author: Christian Dywan <christian at twotoasts.de>
Date: Wed Oct 7 23:51:35 2009 +0200
Conditionalize restoring of the scrolling position
Ensure that we differentiate an unset value from a valid value
as well as having restored the position already so we don't
accidentally restore a wrong position.
Restoring after having loaded a page is still not ideal but there
doesn't seem to be a better way at this point.
midori/midori-view.c | 46 ++++++++++++++++++++++++++++++++--------------
1 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 1ca49dc..5918293 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -905,27 +905,45 @@ webkit_web_frame_load_done_cb (WebKitWebFrame* web_frame,
#endif
static void
+midori_view_apply_scroll_position (MidoriView* view)
+{
+ if (view->scrollh > -2)
+ {
+ if (view->scrollh > 0)
+ {
+ GtkAdjustment* adjustment = katze_object_get_object (view, "hadjustment");
+ gtk_adjustment_set_value (adjustment, view->scrollh);
+ g_object_unref (adjustment);
+ }
+ view->scrollh = -3;
+ }
+ if (view->scrollv > -2)
+ {
+ if (view->scrollv > 0)
+ {
+ GtkAdjustment* adjustment = katze_object_get_object (view, "vadjustment");
+ gtk_adjustment_set_value (adjustment, view->scrollv);
+ g_object_unref (adjustment);
+ }
+ view->scrollv = -3;
+ }
+}
+
+static void
webkit_web_view_load_finished_cb (WebKitWebView* web_view,
WebKitWebFrame* web_frame,
MidoriView* view)
{
g_object_freeze_notify (G_OBJECT (view));
+ /* TODO: Find a better condition than a finished load.
+ Apparently WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT is too early. */
+ midori_view_apply_scroll_position (view);
+
view->progress = 1.0;
g_object_notify (G_OBJECT (view), "progress");
midori_view_update_load_status (view, MIDORI_LOAD_FINISHED);
- if (view->scrollh || view->scrollv)
- {
- GtkAdjustment* adjustment = katze_object_get_object (view, "hadjustment");
- gtk_adjustment_set_value (adjustment, view->scrollh);
- g_object_unref (adjustment);
- adjustment = katze_object_get_object (view, "vadjustment");
- gtk_adjustment_set_value (adjustment, view->scrollv);
- g_object_unref (adjustment);
- view->scrollh = view->scrollv = 0;
- }
-
if (1)
{
JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
@@ -2208,7 +2226,7 @@ midori_view_init (MidoriView* view)
view->news_feeds = katze_array_new (KATZE_TYPE_ITEM);
view->item = NULL;
- view->scrollh = view->scrollv = 0;
+ view->scrollh = view->scrollv = -2;
view->back_forward_set = FALSE;
view->download_manager = NULL;
@@ -3474,9 +3492,9 @@ midori_view_item_meta_data_changed (KatzeItem* item,
else if (g_str_has_prefix (key, "scroll"))
{
gint value = katze_item_get_meta_integer (item, key);
- if (!view->scrollh && key[6] == 'h')
+ if (view->scrollh == -2 && key[6] == 'h')
view->scrollh = value > -1 ? value : 0;
- else if (!view->scrollv && key[6] == 'v')
+ else if (view->scrollv == -2 && key[6] == 'v')
view->scrollv = value > -1 ? value : 0;
else
return;
More information about the Xfce4-commits
mailing list