diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2020-04-07 21:16:07 +0100 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2020-04-07 21:32:27 +0100 |
commit | 0e04059f539891e741a4b64d3a7fc41a1ffc2ed7 (patch) | |
tree | b239c02ebae2898c00dfeb0339018e3bc6d45499 /content/fetchers/about.c | |
parent | 9fa6ac7113a7e6bf8949c09aec2e060518a91c53 (diff) | |
download | netsurf-0e04059f539891e741a4b64d3a7fc41a1ffc2ed7.tar.gz netsurf-0e04059f539891e741a4b64d3a7fc41a1ffc2ed7.tar.bz2 |
about fetcher: Add about:nscolour.css generated colour stylesheet.
Diffstat (limited to 'content/fetchers/about.c')
-rw-r--r-- | content/fetchers/about.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/content/fetchers/about.c b/content/fetchers/about.c index e553cb43e..02eb79d3e 100644 --- a/content/fetchers/about.c +++ b/content/fetchers/about.c @@ -36,6 +36,7 @@ #include "utils/log.h" #include "testament.h" #include "utils/corestrings.h" +#include "utils/nscolour.h" #include "utils/nsoption.h" #include "utils/utils.h" #include "utils/messages.h" @@ -787,6 +788,51 @@ fetch_about_config_handler_aborted: /** + * Handler to generate the nscolours stylesheet + * + * \param ctx The fetcher context. + * \return true if handled false if aborted. + */ +static bool fetch_about_nscolours_handler(struct fetch_about_context *ctx) +{ + nserror res; + const char *stylesheet; + + /* content is going to return ok */ + fetch_set_http_code(ctx->fetchh, 200); + + /* content type */ + if (fetch_about_send_header(ctx, "Content-Type: text/css; charset=utf-8")) { + goto aborted; + } + + res = nscolour_get_stylesheet(&stylesheet); + if (res != NSERROR_OK) { + goto aborted; + } + + res = ssenddataf(ctx, + "html {\n" + "\tbackground-color: #%06x;\n" + "}\n" + "%s", + colour_rb_swap(nscolours[NSCOLOUR_WIN_ODD_BG]), + stylesheet); + if (res != NSERROR_OK) { + goto aborted; + } + + fetch_about_send_finished(ctx); + + return true; + +aborted: + + return false; +} + + +/** * Generate the text of a Choices file which represents the current * in use options. * |