Progress tweaks in view, unify progres in browser

Fixes: https://bugs.launchpad.net/bugs/1020910
This commit is contained in:
Christian Dywan 2012-09-02 21:05:12 +02:00
parent 5555b88959
commit fee43b8be6
2 changed files with 41 additions and 51 deletions

View File

@ -317,12 +317,8 @@ static void
_midori_browser_update_interface (MidoriBrowser* browser, _midori_browser_update_interface (MidoriBrowser* browser,
MidoriView* view) MidoriView* view)
{ {
gboolean loading = midori_view_get_load_status (view) != MIDORI_LOAD_FINISHED;
gboolean can_reload = midori_view_can_reload (view);
GtkAction* action; 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, "Back", midori_view_can_go_back (view));
_action_set_sensitive (browser, "Forward", midori_view_can_go_forward (view)); _action_set_sensitive (browser, "Forward", midori_view_can_go_forward (view));
_action_set_sensitive (browser, "Previous", _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_findbar_set_can_find (MIDORI_FINDBAR (browser->find),
midori_view_can_find (view)); 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"); action = _action_by_name (browser, "NextForward");
if (midori_view_can_go_forward (view)) 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); "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"); action = _action_by_name (browser, "Location");
midori_location_action_set_security_hint ( midori_location_action_set_security_hint (
MIDORI_LOCATION_ACTION (action), midori_view_get_security (view)); MIDORI_LOCATION_ACTION (action), midori_view_get_security (view));
@ -462,18 +431,34 @@ static void
_midori_browser_update_progress (MidoriBrowser* browser, _midori_browser_update_progress (MidoriBrowser* browser,
MidoriView* view) MidoriView* view)
{ {
MidoriLocationAction* action; GtkAction* action;
gdouble progress; gdouble progress = midori_view_get_progress (view);
gboolean loading = progress > 0.0;
action = MIDORI_LOCATION_ACTION (_action_by_name (browser, "Location")); action = _action_by_name (browser, "Location");
progress = midori_view_get_progress (view); midori_location_action_set_progress (MIDORI_LOCATION_ACTION (action), progress);
/* When we are finished, we don't want to *see* progress anymore */
if (midori_view_get_load_status (view) == MIDORI_LOAD_FINISHED) _action_set_sensitive (browser, "Reload", !loading);
progress = 0.0; _action_set_sensitive (browser, "Stop", loading);
/* 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 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);
} }
/** /**

View File

@ -924,12 +924,12 @@ midori_view_update_load_status (MidoriView* view,
#ifdef HAVE_GRANITE #ifdef HAVE_GRANITE
if (view->tab) if (view->tab)
g_object_set (view->tab, g_object_set (view->tab, "working",
"working", view->load_status != MIDORI_LOAD_FINISHED, NULL); midori_view_get_progress (view) > 0.0, NULL);
#else #else
if (view->tab_icon) if (view->tab_icon)
katze_throbber_set_animated (KATZE_THROBBER (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 #endif
} }
@ -1601,10 +1601,6 @@ webkit_web_view_load_finished_cb (WebKitWebView* web_view,
midori_view_apply_scroll_position (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)) if (web_frame == webkit_web_view_get_main_frame (web_view))
{ {
JSContextRef js_context = webkit_web_frame_get_global_context (web_frame); 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_object_set_data_full (G_OBJECT (view), "news-feeds", default_uri, g_free);
g_free (value); 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) #if !WEBKIT_CHECK_VERSION (1, 4, 3)
_midori_web_view_load_icon (view); _midori_web_view_load_icon (view);
#endif #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)); 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); 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 static void