diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-27 23:32:21 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-27 23:32:21 (EDT) |
commit | 88d1b9daf602506534b3c64a255c9f3556c36b56 (patch) | |
tree | 827bb026fe3292434c54b6e685fd981eec570b4f /src | |
parent | 83dfeec2cca27ab8c2624f1f3d4f60130832d779 (diff) | |
download | marquee-88d1b9daf602506534b3c64a255c9f3556c36b56.zip marquee-88d1b9daf602506534b3c64a255c9f3556c36b56.tar.gz marquee-88d1b9daf602506534b3c64a255c9f3556c36b56.tar.bz2 |
mq_resource_response(): Return a nicer HTML document on error
Diffstat (limited to 'src')
-rw-r--r-- | src/resources.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/resources.c b/src/resources.c index 77e1994..02283d6 100644 --- a/src/resources.c +++ b/src/resources.c @@ -26,6 +26,20 @@ #include "application.h" +static const gchar *error_document = + "<!doctype html>\n" + "<html dir=\"%s\">\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>Resource Error</title</title>\n" + "</head>\n" + "<body>" + "<h1>Resource Error</h1>\n" + "<p>Failed to load resource “%s”</p>\n" + "<p>%s</p>\n" + "</body>\n" + "</html>"; + void mq_resource_response(MqApplication *application, const gchar *path, WebKitURISchemeRequest *request) @@ -44,9 +58,10 @@ mq_resource_response(MqApplication *application, const gchar *path, stream = G_INPUT_STREAM(g_file_read(file, NULL, &error)); if (!stream) { stream = g_memory_input_stream_new_from_data( - g_strdup_printf("Failed to load resource " - "“%s”: %s", path, error->message), - -1, g_free); + g_strdup_printf(error_document, + gtk_widget_get_default_direction() == + GTK_TEXT_DIR_RTL ? "rtl" : "ltr", + path, error->message), -1, g_free); g_error_free(error); } webkit_uri_scheme_request_finish(request, stream, -1, "text/html"); |