[epiphany] Handle LOAD_FAILED status



commit c3ce140727235f54c61dca6cc9eb6709422fe3b8
Author: Alejandro G. Castro <alex igalia com>
Date:   Tue May 4 12:43:14 2010 +0200

    Handle LOAD_FAILED status
    
    Modified the state of the webivew in case the load failed to avoid
    keeping the old title or icon in that situation.
    
    Bug #593743

 embed/ephy-web-view.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index b10e38a..669ffd6 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -2095,6 +2095,16 @@ load_status_cb (WebKitWebView *web_view,
 
     _ephy_web_view_hook_into_links (view);
     break;
+  case WEBKIT_LOAD_FAILED:
+    ephy_web_view_set_link_message (view, NULL);
+    ephy_web_view_set_loading_title (view, NULL, FALSE);
+
+    g_free (priv->status_message);
+    priv->status_message = NULL;
+    g_object_notify (object, "status-message");
+
+    update_navigation_flags (view);
+    break;
   default:
     break;
   }
@@ -2102,6 +2112,28 @@ load_status_cb (WebKitWebView *web_view,
   g_object_thaw_notify (object);
 }
 
+ static gboolean
+load_error_cb (WebKitWebView *web_view,
+               WebKitWebFrame *frame,
+               gchar *uri,
+               GError *error,
+               gpointer user_data)
+{
+  if (error->code != WEBKIT_NETWORK_ERROR_CANCELLED) {
+    EphyWebView *view = EPHY_WEB_VIEW (web_view);
+    gchar *message;
+
+    message = g_strdup_printf (_("A problem occurred while loading %s"),
+                               uri);
+    ephy_web_view_set_title (view, message);
+    g_free (message);
+
+    _ephy_web_view_set_icon_address (view, NULL);
+  }
+
+  return FALSE;
+}
+
 static gboolean
 close_web_view_cb (WebKitWebView *web_view,
                    gpointer user_data)
@@ -2162,6 +2194,10 @@ ephy_web_view_init (EphyWebView *web_view)
                     G_CALLBACK (close_web_view_cb),
                     NULL);
 
+  g_signal_connect (web_view, "load-error",
+                    G_CALLBACK (load_error_cb),
+                    NULL);
+
   g_signal_connect_object (web_view, "icon-loaded",
                            G_CALLBACK (favicon_cb),
                            web_view, (GConnectFlags)0);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]