Support error pages with the load-error signal in WebKitGTK+ 1.1.6
This commit is contained in:
parent
7d0d2d60bc
commit
ca98c68e70
3 changed files with 121 additions and 2 deletions
65
data/error.html
Normal file
65
data/error.html
Normal file
|
@ -0,0 +1,65 @@
|
|||
<!--
|
||||
Error page template for Midori.
|
||||
This file is licensed under the terms of the expat license, see the file EXPAT.
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>{title}</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
background-color: #eee;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#container {
|
||||
background: #f6fff3;
|
||||
min-width: 70%;
|
||||
max-width: 70%;
|
||||
margin: 2em auto 1em;
|
||||
padding: 1em;
|
||||
border: 0.2em solid #9acb7f;
|
||||
-webkit-border-radius: 1em;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.4em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#logo {
|
||||
position: absolute; right: 15px; bottom: 15px;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
message {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
description {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<img id="logo" src="{res}/logo-shade.png" />
|
||||
|
||||
<h1>{title}</h1>
|
||||
<div class="message">
|
||||
<p>{message}</p>
|
||||
<p>{description}</p>
|
||||
</div>
|
||||
|
||||
<form onsubmit="location.reload()">
|
||||
<input type="submit" value="{tryagain}" />
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -615,6 +615,50 @@ webkit_web_view_progress_changed_cb (WebKitWebView* web_view,
|
|||
g_object_notify (G_OBJECT (view), "progress");
|
||||
}
|
||||
|
||||
#if WEBKIT_CHECK_VERSION (1, 1, 6)
|
||||
static gboolean
|
||||
webkit_web_view_load_error_cb (WebKitWebView* web_view,
|
||||
WebKitWebFrame* web_frame,
|
||||
const gchar* uri,
|
||||
GError* error,
|
||||
MidoriView* view)
|
||||
{
|
||||
const gchar* template_file = DATADIR "/midori/res/error.html";
|
||||
gchar* template;
|
||||
|
||||
if (g_file_get_contents (template_file, &template, NULL, NULL))
|
||||
{
|
||||
SoupServer* res_server;
|
||||
guint port;
|
||||
gchar* res_root;
|
||||
gchar* message;
|
||||
gchar* result;
|
||||
|
||||
res_server = sokoke_get_res_server ();
|
||||
port = soup_server_get_port (res_server);
|
||||
res_root = g_strdup_printf ("http://localhost:%d/res", port);
|
||||
|
||||
message = g_strdup_printf (_("The page %s couldn't be loaded."), uri);
|
||||
result = sokoke_replace_variables (template,
|
||||
"{title}", _("Error"),
|
||||
"{message}", message,
|
||||
"{description}", error->message,
|
||||
"{tryagain}", _("Try again"),
|
||||
"{res}", res_root, NULL);
|
||||
g_free (template);
|
||||
g_free (message);
|
||||
|
||||
webkit_web_frame_load_alternate_string (web_frame,
|
||||
result, res_root, uri);
|
||||
g_free (res_root);
|
||||
g_free (result);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#else
|
||||
static void
|
||||
webkit_web_frame_load_done_cb (WebKitWebFrame* web_frame,
|
||||
gboolean success,
|
||||
|
@ -645,6 +689,7 @@ webkit_web_frame_load_done_cb (WebKitWebFrame* web_frame,
|
|||
|
||||
midori_view_update_load_status (view, MIDORI_LOAD_FINISHED);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
webkit_web_view_load_finished_cb (WebKitWebView* web_view,
|
||||
|
@ -1755,12 +1800,18 @@ midori_view_construct_web_view (MidoriView* view)
|
|||
"signal::download-requested",
|
||||
webkit_web_view_download_requested_cb, view,
|
||||
#endif
|
||||
#if WEBKIT_CHECK_VERSION (1, 1, 6)
|
||||
"signal::load-error",
|
||||
webkit_web_view_load_error_cb, view,
|
||||
#endif
|
||||
NULL);
|
||||
|
||||
#if !WEBKIT_CHECK_VERSION (1, 1, 6)
|
||||
g_object_connect (web_frame,
|
||||
"signal::load-done",
|
||||
webkit_web_frame_load_done_cb, view,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
if (view->settings)
|
||||
{
|
||||
|
@ -1802,6 +1853,7 @@ midori_view_set_uri (MidoriView* view,
|
|||
if (g_str_has_prefix (uri, "error:"))
|
||||
{
|
||||
data = NULL;
|
||||
#if !WEBKIT_CHECK_VERSION (1, 1, 3)
|
||||
if (!strncmp (uri, "error:nodisplay ", 16))
|
||||
{
|
||||
gchar* title;
|
||||
|
@ -1818,7 +1870,8 @@ midori_view_set_uri (MidoriView* view,
|
|||
title, title, view->uri, view->mime_type);
|
||||
g_free (title);
|
||||
}
|
||||
else if (!strncmp (uri, "error:nodocs ", 13))
|
||||
#endif
|
||||
if (!strncmp (uri, "error:nodocs ", 13))
|
||||
{
|
||||
gchar* title;
|
||||
|
||||
|
|
3
wscript
3
wscript
|
@ -336,9 +336,10 @@ def build (bld):
|
|||
' -o ' + blddir + '/data/logo-shade.png ' + \
|
||||
srcdir + '/data/logo-shade.svg'
|
||||
if not Utils.exec_command (command):
|
||||
bld.install_files ('${DATADIR}/' + APPNAME, blddir + '/data/logo-shade.png')
|
||||
bld.install_files ('${DATADIR}/' + APPNAME + '/res', blddir + '/data/logo-shade.png')
|
||||
else:
|
||||
Utils.pprint ('BLUE', "logo-shade could not be rasterized.")
|
||||
bld.install_files ('${DATADIR}/' + APPNAME + '/res', 'data/error.html')
|
||||
|
||||
if Options.commands['check']:
|
||||
bld.add_subdirs ('tests')
|
||||
|
|
Loading…
Reference in a new issue