[epiphany] Improve oops screens



commit c36eec7a485eab8f4a02502d53b56bf17ac685b5
Author: William Jon McCann <william jon mccann gmail com>
Date:   Sun Dec 15 15:57:17 2013 -0500

    Improve oops screens
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692336

 data/pages/Makefile.am           |    3 +-
 data/pages/error.css             |   49 ++++++++++++++++++++++++++
 embed/ephy-web-view.c            |   72 +++++++++++++++++++-------------------
 src/resources/error.html         |   43 +----------------------
 src/resources/process-crash.html |   41 +---------------------
 src/resources/recovery.html      |   44 +----------------------
 6 files changed, 90 insertions(+), 162 deletions(-)
---
diff --git a/data/pages/Makefile.am b/data/pages/Makefile.am
index 0ff1540..66a56b0 100644
--- a/data/pages/Makefile.am
+++ b/data/pages/Makefile.am
@@ -1,5 +1,6 @@
 stylepagesdir = $(pkgdatadir)/pages
 stylepages_DATA = \
-       about.css
+       about.css \
+       error.css
 
 EXTRA_DIST = $(stylepages_DATA)
diff --git a/data/pages/error.css b/data/pages/error.css
new file mode 100644
index 0000000..41bc78e
--- /dev/null
+++ b/data/pages/error.css
@@ -0,0 +1,49 @@
+/* Global CSS for error pages */
+
+h1 {
+        color: #babdb6;
+        text-shadow: 0 1px 0 white;
+        margin-bottom: 0;
+}
+
+body {
+        font-family: Cantarell, sans-serif;
+        font: 11pt cantarell;
+        color: #2e3436;
+        padding: 20px 20px 0 20px;
+        background-color: #f6f6f4;
+        background-image: -webkit-gradient(
+                linear,
+                left top,
+                left bottom,
+                color-stop(0, #eeeeec),
+                color-stop(1, #f6f6f4)
+        );
+        background-size: 100% 5em;
+        background-repeat: no-repeat;
+}
+
+#container {
+    padding: 2em;
+    margin: 2em auto;
+    background-color: #fff;
+    border-radius: 1em;
+    border: 2px solid #d3d7cf;
+    max-width: 650px;
+}
+
+#content {
+    vertical-align: top;
+}
+
+#content h1 {
+    margin-top: 0;
+}
+
+#content .buttonbox {
+    text-align: right;
+}
+
+html[dir="rtl"] #content .buttonbox {
+    text-align: left;
+}
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 058386c..0743b4f 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -1689,6 +1689,23 @@ ephy_web_view_set_placeholder (EphyWebView *view,
   ephy_web_view_set_address (view, uri);
 }
 
+
+static char *
+get_style_sheet (void)
+{
+  const gchar *file;
+  GError *error = NULL;
+  char *sheet;
+
+  file = ephy_file ("error.css");
+  if (file && !g_file_get_contents (file, &sheet, NULL, &error)) {
+    g_debug ("Unable to load error style sheet: %s", error->message);
+    g_error_free (error);
+  }
+
+  return sheet;
+}
+
 /**
  * ephy_web_view_load_error_page:
  * @view: an #EphyWebView
@@ -1713,10 +1730,8 @@ ephy_web_view_load_error_page (EphyWebView *view,
   char *msg_title;
   char *msg;
   char *button_label;
+  char *stylesheet;
   GBytes *html_file;
-  const char *stock_icon;
-  GtkIconInfo *icon_info;
-  char *image_data;
 
   if (error)
     reason = error->message;
@@ -1730,49 +1745,43 @@ ephy_web_view_load_error_page (EphyWebView *view,
 
   switch (page) {
     case EPHY_WEB_VIEW_ERROR_PAGE_NETWORK_ERROR:
-      page_title = g_strdup_printf (_("Oops! Error loading %s"), hostname);
+      page_title = g_strdup_printf (_("Problem loading “%s”"), hostname);
 
-      msg_title = g_strdup (_("Oops! It was not possible to show this website"));
-      msg = g_strdup_printf (_("<p>The website at <strong>%s</strong> seems "
+      msg_title = g_strdup (_("Oops! Unable to display this website."));
+      msg = g_strdup_printf (_("<p>The site at “%s” seems "
                                "to be unavailable. The precise error was:</p>"
-                               "<p><em>%s</em></p>"
-                               "<p>It could be "
-                               "temporarily switched off or moved to a new "
-                               "address. Don't forget to check that your "
+                               "<p><code>%s</code></p>"
+                               "<p>It may be "
+                               "temporarily unavailable or moved to a new "
+                               "address. You may wish to verify that your "
                                "internet connection is working correctly.</p>"),
                              uri, reason);
 
-      button_label = g_strdup (_("Try again"));
+      button_label = g_strdup (_("Try Again"));
 
       html_file = g_resources_lookup_data (EPHY_PAGE_TEMPLATE_ERROR, 0, NULL);
-      stock_icon = "dialog-error";
       break;
     case EPHY_WEB_VIEW_ERROR_PAGE_CRASH:
-      page_title = g_strdup_printf (_("Oops! Error loading %s"), hostname);
-
-      msg_title = g_strdup (_("Oops! This site might have caused the web "
-                              "browser to close unexpectedly"));
-      msg = g_strdup_printf (_("<p>This page was loading when the web browser "
-                               "closed unexpectedly.</p>"
-                               "<p>This might happen again if you "
-                               "reload the page. If it does, "
+      page_title = g_strdup_printf (_("Problem loading “%s”"), hostname);
+
+      msg_title = g_strdup (_("Oops! There may be a problem."));
+      msg = g_strdup_printf (_("<p>This site may have caused Web to close unexpectedly.</p>"
+                               "<p>If this happens again, "
                                "please report the problem to the "
                                "<strong>%s</strong> developers.</p>"),
                              LSB_DISTRIBUTOR);
 
-      button_label = g_strdup (_("Load again anyway"));
+      button_label = g_strdup (_("Reload Anyway"));
 
       html_file = g_resources_lookup_data (EPHY_PAGE_TEMPLATE_RECOVERY, 0, NULL);
-      stock_icon = "dialog-information";
       break;
     case EPHY_WEB_VIEW_ERROR_PROCESS_CRASH:
-      page_title = g_strdup_printf (_("Oops! Something went wrong displaying %s"), hostname);
+      page_title = g_strdup_printf (_("Problem displaying “%s”"), hostname);
       msg_title = g_strdup (_("Oops!"));
       msg = g_strdup (_("Something went wrong while displaying this page. Please reload or visit a different 
page to continue."));
       button_label = NULL;
 
       html_file = g_resources_lookup_data (EPHY_PAGE_TEMPLATE_PROCESS_CRASH, 0, NULL);
-      stock_icon = "computer-fail-symbolic";
 
       break;
     default:
@@ -1781,36 +1790,27 @@ ephy_web_view_load_error_page (EphyWebView *view,
   }
   g_free (hostname);
 
-  icon_info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (),
-                                          stock_icon,
-                                          48,
-                                          GTK_ICON_LOOKUP_GENERIC_FALLBACK);
-
-  image_data = icon_info ? ephy_file_create_data_uri_for_filename (gtk_icon_info_get_filename (icon_info), 
NULL) : NULL;
-
   ephy_web_view_set_title (view, page_title);
 
   _ephy_web_view_update_icon (view);
 
+  stylesheet = get_style_sheet ();
   g_string_printf (html,
                    g_bytes_get_data (html_file, NULL),
                    lang, lang,
                    ((gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) ? "rtl" : "ltr"),
                    page_title,
+                   stylesheet,
                    uri,
-                   image_data ? image_data : "",
                    msg_title, msg, button_label);
 
   g_bytes_unref (html_file);
+  g_free (stylesheet);
   g_free (lang);
   g_free (page_title);
   g_free (msg_title);
   g_free (msg);
   g_free (button_label);
-  g_free (image_data);
-
-  if (icon_info)
-    g_object_unref (icon_info);
 
   /* Make our history backend ignore the next page load, since it will be an error page. */
   ephy_web_view_freeze_history (view);
diff --git a/src/resources/error.html b/src/resources/error.html
index 9aa39f6..62831a8 100644
--- a/src/resources/error.html
+++ b/src/resources/error.html
@@ -20,45 +20,7 @@
 <head>
   <meta http-equiv="content-type" content="text/html; charset=utf-8" />
   <title>%s</title>
-  <style type="text/css">
-    body {
-      margin: 0 auto;
-      font: message-box;
-    }
-
-    #container {
-      padding: 10% 12% 5%;
-      margin: 0 auto;
-      max-width: 650px;
-    }
-
-    #main_icon {
-      float: left;
-      padding-right: 20px;
-    }
-
-    html[dir="rtl"] #main_icon {
-      padding-left: 20px;
-      padding-right: 0;
-      float: right;
-    }
-
-    #content {
-      display: table-cell;
-      vertical-align: top;
-    }
-
-    #content h1 {
-      margin-top: 0;
-    }
-
-    #content .buttonbox {
-      text-align: right;
-    }
-
-    html[dir="rtl"] #content .buttonbox {
-      text-align: left;
-    }
+  <style type="text/css">%s</style>
   </style>
   <script type="text/javascript">
     function load_anyway()
@@ -69,9 +31,6 @@
 </head>
 <body>
   <div id="container">
-      <div id="main_icon">
-        <img src="%s" />
-      </div>
       <div id="content">
           <h1>%s</h1>
           <div class="explanation">
diff --git a/src/resources/process-crash.html b/src/resources/process-crash.html
index 7cf7ab9..819f967 100644
--- a/src/resources/process-crash.html
+++ b/src/resources/process-crash.html
@@ -20,49 +20,10 @@
 <head>
   <meta http-equiv="content-type" content="text/html; charset=utf-8" />
   <title>%s</title>
-  <style type="text/css">
-    body {
-      margin: 0 auto;
-      font: message-box;
-      background-color: #2e3436;
-      color: #d0d1cf;
-    }
-
-    #container {
-      padding: 10% 12% 5%;
-      margin: 0 auto;
-      max-width: 650px;
-    }
-
-    #main_icon {
-      float: left;
-      padding-right: 20px;
-    }
-
-    html[dir="rtl"] #main_icon {
-      padding-left: 20px;
-      padding-right: 0;
-      float: right;
-    }
-
-    #content {
-      display: table-cell;
-      vertical-align: top;
-    }
-
-    #content h1 {
-      margin-top: 0;
-      font-size: 200%;
-    }
-  </style>
-
+  <style type="text/css">%s</style>
 </head>
 <body>
   <div id="container">
-      <div id="main_icon">
-      <!-- We do nothing with the URI for now: %s -->
-        <img width="150px" height="150px" src="%s" alt="Sad face icon"/>
-      </div>
       <div id="content">
           <h1>%s</h1>
           <div class="explanation">
diff --git a/src/resources/recovery.html b/src/resources/recovery.html
index 9aa39f6..72b67a1 100644
--- a/src/resources/recovery.html
+++ b/src/resources/recovery.html
@@ -20,46 +20,7 @@
 <head>
   <meta http-equiv="content-type" content="text/html; charset=utf-8" />
   <title>%s</title>
-  <style type="text/css">
-    body {
-      margin: 0 auto;
-      font: message-box;
-    }
-
-    #container {
-      padding: 10% 12% 5%;
-      margin: 0 auto;
-      max-width: 650px;
-    }
-
-    #main_icon {
-      float: left;
-      padding-right: 20px;
-    }
-
-    html[dir="rtl"] #main_icon {
-      padding-left: 20px;
-      padding-right: 0;
-      float: right;
-    }
-
-    #content {
-      display: table-cell;
-      vertical-align: top;
-    }
-
-    #content h1 {
-      margin-top: 0;
-    }
-
-    #content .buttonbox {
-      text-align: right;
-    }
-
-    html[dir="rtl"] #content .buttonbox {
-      text-align: left;
-    }
-  </style>
+  <style type="text/css">%s</style>
   <script type="text/javascript">
     function load_anyway()
     {
@@ -69,9 +30,6 @@
 </head>
 <body>
   <div id="container">
-      <div id="main_icon">
-        <img src="%s" />
-      </div>
       <div id="content">
           <h1>%s</h1>
           <div class="explanation">


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