From fee43b8be62ae2ddbe9352f3c7dddf60c06f66d2 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 2 Sep 2012 21:05:12 +0200 Subject: [PATCH] Progress tweaks in view, unify progres in browser Fixes: https://bugs.launchpad.net/bugs/1020910 --- midori/midori-browser.c | 67 ++++++++++++++++------------------------- midori/midori-view.c | 25 +++++++++------ 2 files changed, 41 insertions(+), 51 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 3a0ffbc6..87db0de6 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -317,12 +317,8 @@ static void _midori_browser_update_interface (MidoriBrowser* browser, MidoriView* view) { - gboolean loading = midori_view_get_load_status (view) != MIDORI_LOAD_FINISHED; - gboolean can_reload = midori_view_can_reload (view); GtkAction* action; - _action_set_sensitive (browser, "Reload", can_reload); - _action_set_sensitive (browser, "Stop", can_reload && loading); _action_set_sensitive (browser, "Back", midori_view_can_go_back (view)); _action_set_sensitive (browser, "Forward", midori_view_can_go_forward (view)); _action_set_sensitive (browser, "Previous", @@ -351,23 +347,6 @@ _midori_browser_update_interface (MidoriBrowser* browser, midori_findbar_set_can_find (MIDORI_FINDBAR (browser->find), midori_view_can_find (view)); - action = _action_by_name (browser, "ReloadStop"); - if (!loading) - { - g_object_set (action, - "stock-id", GTK_STOCK_REFRESH, - "tooltip", _("Reload the current page"), - "sensitive", can_reload, NULL); - katze_item_set_meta_integer (midori_view_get_proxy_item (view), - "dont-write-history", -1); - } - else - { - g_object_set (action, - "stock-id", GTK_STOCK_STOP, - "tooltip", _("Stop loading the current page"), NULL); - } - action = _action_by_name (browser, "NextForward"); if (midori_view_can_go_forward (view)) { @@ -384,16 +363,6 @@ _midori_browser_update_interface (MidoriBrowser* browser, "sensitive", midori_view_get_next_page (view) != NULL, NULL); } - - #if HAVE_HILDON - #if HILDON_CHECK_VERSION (2, 2, 0) - hildon_gtk_window_set_progress_indicator (GTK_WINDOW (browser), loading); - #endif - #else - gtk_widget_set_sensitive (browser->throbber, loading); - katze_throbber_set_animated (KATZE_THROBBER (browser->throbber), loading); - #endif - action = _action_by_name (browser, "Location"); midori_location_action_set_security_hint ( MIDORI_LOCATION_ACTION (action), midori_view_get_security (view)); @@ -462,18 +431,34 @@ static void _midori_browser_update_progress (MidoriBrowser* browser, MidoriView* view) { - MidoriLocationAction* action; - gdouble progress; + GtkAction* action; + gdouble progress = midori_view_get_progress (view); + gboolean loading = progress > 0.0; + + action = _action_by_name (browser, "Location"); + midori_location_action_set_progress (MIDORI_LOCATION_ACTION (action), progress); + + _action_set_sensitive (browser, "Reload", !loading); + _action_set_sensitive (browser, "Stop", loading); - action = MIDORI_LOCATION_ACTION (_action_by_name (browser, "Location")); - progress = midori_view_get_progress (view); - /* When we are finished, we don't want to *see* progress anymore */ - if (midori_view_get_load_status (view) == MIDORI_LOAD_FINISHED) - progress = 0.0; - /* When loading we want to see at minimum 10% progress */ + action = _action_by_name (browser, "ReloadStop"); + if (!loading) + { + g_object_set (action, + "stock-id", GTK_STOCK_REFRESH, + "tooltip", _("Reload the current page"), NULL); + katze_item_set_meta_integer (midori_view_get_proxy_item (view), + "dont-write-history", -1); + } else - progress = CLAMP (progress, 0.1, 1.0); - midori_location_action_set_progress (action, progress); + { + g_object_set (action, + "stock-id", GTK_STOCK_STOP, + "tooltip", _("Stop loading the current page"), NULL); + } + + gtk_widget_set_sensitive (browser->throbber, loading); + katze_throbber_set_animated (KATZE_THROBBER (browser->throbber), loading); } /** diff --git a/midori/midori-view.c b/midori/midori-view.c index 0f01c4f6..7cbf17e9 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -924,12 +924,12 @@ midori_view_update_load_status (MidoriView* view, #ifdef HAVE_GRANITE if (view->tab) - g_object_set (view->tab, - "working", view->load_status != MIDORI_LOAD_FINISHED, NULL); + g_object_set (view->tab, "working", + midori_view_get_progress (view) > 0.0, NULL); #else if (view->tab_icon) katze_throbber_set_animated (KATZE_THROBBER (view->tab_icon), - view->load_status != MIDORI_LOAD_FINISHED); + midori_view_get_progress (view) > 0.0); #endif } @@ -1601,10 +1601,6 @@ webkit_web_view_load_finished_cb (WebKitWebView* web_view, 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 (web_frame == webkit_web_view_get_main_frame (web_view)) { JSContextRef js_context = webkit_web_frame_get_global_context (web_frame); @@ -1687,14 +1683,16 @@ webkit_web_view_load_finished_cb (WebKitWebView* web_view, g_object_set_data_full (G_OBJECT (view), "news-feeds", default_uri, g_free); g_free (value); - /* Ensure load-status is notified again, whether it changed or not */ - g_object_notify (G_OBJECT (view), "load-status"); #if !WEBKIT_CHECK_VERSION (1, 4, 3) _midori_web_view_load_icon (view); #endif } + view->progress = 1.0; + g_object_notify (G_OBJECT (view), "progress"); + midori_view_update_load_status (view, MIDORI_LOAD_FINISHED); + g_object_thaw_notify (G_OBJECT (view)); } @@ -3871,7 +3869,14 @@ midori_view_get_progress (MidoriView* view) { g_return_val_if_fail (MIDORI_IS_VIEW (view), 0.0); - return view->progress; + /* When we are finished, we don't want to *see* progress anymore */ + if (view->load_status == MIDORI_LOAD_FINISHED) + return 0.0; + /* Full progress but not finished: presumably all loaded */ + if (view->progress == 1.0) + return 0.0; + /* When loading we want to see at minimum 10% progress */ + return CLAMP (view->progress, 0.1, 1.0); } static void -- 2.39.5