diff options
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/Makefile | 4 | ||||
-rw-r--r-- | desktop/browser.c | 24 | ||||
-rw-r--r-- | desktop/cookies.c | 2 | ||||
-rw-r--r-- | desktop/download.c | 3 | ||||
-rw-r--r-- | desktop/gui.h | 4 | ||||
-rw-r--r-- | desktop/netsurf.c | 33 | ||||
-rw-r--r-- | desktop/netsurf.h | 2 | ||||
-rw-r--r-- | desktop/options.c | 475 | ||||
-rw-r--r-- | desktop/options.h | 372 | ||||
-rw-r--r-- | desktop/options_main.h | 401 | ||||
-rw-r--r-- | desktop/print.c | 2 | ||||
-rw-r--r-- | desktop/save_pdf/font_haru.c | 2 | ||||
-rw-r--r-- | desktop/save_pdf/pdf_plotters.c | 2 | ||||
-rw-r--r-- | desktop/scrollbar.c | 2 | ||||
-rw-r--r-- | desktop/search.c | 2 | ||||
-rw-r--r-- | desktop/searchweb.c | 2 | ||||
-rw-r--r-- | desktop/system_colour.c | 101 | ||||
-rw-r--r-- | desktop/thumbnail.c | 2 | ||||
-rw-r--r-- | desktop/tree.c | 2 | ||||
-rw-r--r-- | desktop/tree_url_node.c | 2 |
20 files changed, 374 insertions, 1065 deletions
diff --git a/desktop/Makefile b/desktop/Makefile index b587e679e..f91754eb9 100644 --- a/desktop/Makefile +++ b/desktop/Makefile @@ -1,9 +1,9 @@ # Sources for desktop S_DESKTOP := cookies.c history_global_core.c hotlist.c knockout.c \ - mouse.c options.c plot_style.c print.c search.c searchweb.c \ + mouse.c plot_style.c print.c search.c searchweb.c \ scrollbar.c sslcert.c textarea.c thumbnail.c tree.c \ - tree_url_node.c version.c + tree_url_node.c version.c system_colour.c S_DESKTOP := $(addprefix desktop/,$(S_DESKTOP)) diff --git a/desktop/browser.c b/desktop/browser.c index 12cc9c830..b7ec98947 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -49,7 +49,7 @@ #include "desktop/hotlist.h" #include "desktop/gui.h" #include "desktop/knockout.h" -#include "desktop/options.h" +#include "utils/nsoption.h" #include "desktop/scrollbar.h" #include "desktop/selection.h" #include "desktop/plotters.h" @@ -683,6 +683,19 @@ void browser_window_debug_dump(struct browser_window *bw, FILE *f) content_debug_dump(bw->current_content, f); } +/** slow script handler +*/ +static bool slow_script(void *ctx) +{ + static int count = 0; + LOG(("Continuing execution %d", count)); + count++; + if (count > 1) { + count = 0; + return false; + } + return true; +} /* exported interface, documented in desktop/browser.h */ @@ -707,7 +720,9 @@ browser_window_create(enum browser_window_nav_flags flags, } /* new javascript context for window */ - bw->jsctx = js_newcontext(); + bw->jsctx = js_newcontext(nsoption_int(script_timeout), + slow_script, + NULL); /* Initialise common parts */ browser_window_initialise_common(bw, clone); @@ -1340,6 +1355,11 @@ nserror browser_window_callback(hlcache_handle *c, browser_window_stop_throbber(bw); break; + case CONTENT_MSG_REDIRECT: + if (urldb_add_url(event->data.redirect.from)) + urldb_update_url_visit_data(event->data.redirect.from); + break; + case CONTENT_MSG_STATUS: if (event->data.explicit_status_text == NULL) { /* Object content's status text updated */ diff --git a/desktop/cookies.c b/desktop/cookies.c index 197b3fbd1..9f66aea1e 100644 --- a/desktop/cookies.c +++ b/desktop/cookies.c @@ -31,7 +31,7 @@ #include "content/hlcache.h" #include "content/urldb.h" #include "desktop/cookies.h" -#include "desktop/options.h" +#include "utils/nsoption.h" #include "desktop/tree.h" #include "utils/log.h" #include "utils/messages.h" diff --git a/desktop/download.c b/desktop/download.c index f4bedc8e9..b775eb18e 100644 --- a/desktop/download.c +++ b/desktop/download.c @@ -238,6 +238,9 @@ static nserror download_callback(llcache_handle *handle, case LLCACHE_EVENT_PROGRESS: break; + + case LLCACHE_EVENT_REDIRECT: + break; } return error; diff --git a/desktop/gui.h b/desktop/gui.h index f4b8b7215..dc190952b 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -64,10 +64,6 @@ struct form_control; #include "desktop/search.h" #include "utils/errors.h" -/** \todo remove these when each frontend calls nslog_init */ -#include <stdio.h> -bool nslog_ensure(FILE *fptr); - void gui_poll(bool active); void gui_quit(void); diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 0b1cffe0a..fa026dc6a 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -40,7 +40,7 @@ #include "desktop/401login.h" #include "desktop/browser.h" #include "desktop/gui.h" -#include "desktop/options.h" +#include "utils/nsoption.h" #include "desktop/searchweb.h" #include "javascript/js.h" @@ -115,10 +115,7 @@ static nserror netsurf_llcache_query_handler(const llcache_query *query, * Initialise components used by gui NetSurf. */ -nserror netsurf_init(int *pargc, - char ***pargv, - const char *options, - const char *messages) +nserror netsurf_init(const char *messages) { nserror error; struct utsname utsname; @@ -138,24 +135,12 @@ nserror netsurf_init(int *pargc, * way of determining the cause of the SIGPIPE (other than using * sigaction() and some mechanism for getting the file descriptor * out of libcurl). However, we expect nothing else to generate a - * SIGPIPE, anyway, so may as well just ignore them all. */ - + * SIGPIPE, anyway, so may as well just ignore them all. + */ signal(SIGPIPE, SIG_IGN); #endif -#ifndef HAVE_STDOUT - ret = nslog_init(nslog_ensure, pargc, *pargv); -#else - ret = nslog_init(NULL, pargc, *pargv); -#endif - - if (ret != NSERROR_OK) - return ret; - -#ifdef _MEMDEBUG_H_ - memdebug_memdebug("memdump"); -#endif - LOG(("version '%s'", netsurf_version)); + LOG(("NetSurf version '%s'", netsurf_version)); if (uname(&utsname) < 0) LOG(("Failed to extract machine information")); else @@ -164,10 +149,6 @@ nserror netsurf_init(int *pargc, utsname.nodename, utsname.release, utsname.version, utsname.machine)); - LOG(("Using '%s' for Options file", options)); - nsoption_read(options); - gui_options_init_defaults(); - messages_load(messages); /* corestrings init */ @@ -187,7 +168,7 @@ nserror netsurf_init(int *pargc, /* image cache is 25% of total memory cache size */ image_cache_parameters.limit = (hlcache_parameters.limit * 25) / 100; - /* image cache hysteresis is 20% of teh image cache size */ + /* image cache hysteresis is 20% of the image cache size */ image_cache_parameters.hysteresis = (image_cache_parameters.limit * 20) / 100; /* account for image cache use from total */ @@ -232,8 +213,6 @@ nserror netsurf_init(int *pargc, /* Initialize system colours */ gui_system_colour_init(); - nsoption_commandline(pargc, *pargv); - js_initialise(); return ret; diff --git a/desktop/netsurf.h b/desktop/netsurf.h index 10c1e00e3..bfdb647ff 100644 --- a/desktop/netsurf.h +++ b/desktop/netsurf.h @@ -28,7 +28,7 @@ extern const char * const netsurf_version; extern const int netsurf_version_major; extern const int netsurf_version_minor; -nserror netsurf_init(int *argc, char ***argv, const char *options, const char *messages); +nserror netsurf_init(const char *messages); extern void netsurf_exit(void); extern int netsurf_main_loop(void); diff --git a/desktop/options.c b/desktop/options.c deleted file mode 100644 index 2a080d564..000000000 --- a/desktop/options.c +++ /dev/null @@ -1,475 +0,0 @@ -/* - * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net> - * Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk> - * Copyright 2004 James Bursa <bursa@users.sourceforge.net> - * Copyright 2005 Richard Wilson <info@tinct.net> - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/** \file - * Option reading and saving (implementation). - * - * Options are stored in the format key:value, one per line. For bool options, - * value is "0" or "1". - */ - -#include <assert.h> -#include <stdbool.h> -#include <stdio.h> -#include <string.h> -#include <strings.h> - -#include "css/css.h" -#include "desktop/plot_style.h" -#include "utils/log.h" -#include "utils/utils.h" -#include "desktop/options.h" - -struct ns_options nsoptions = { - NSOPTION_MAIN_DEFAULTS, - NSOPTION_SYS_COLOUR_DEFAULTS, - NSOPTION_EXTRA_DEFAULTS -}; - -enum option_type_e { - OPTION_BOOL, - OPTION_INTEGER, - OPTION_STRING, - OPTION_COLOUR -} ; - -struct option_entry_s { - const char *key; - enum option_type_e type; - void *p; -}; - -struct option_entry_s option_table[] = { - NSOPTION_MAIN_TABLE, - NSOPTION_EXTRA_TABLE -}; - -#define option_table_entries (sizeof option_table / sizeof option_table[0]) - -/** - * Set an option value based on a string - */ -static bool -strtooption(const char *value, struct option_entry_s *option_entry) -{ - bool ret = false; - colour rgbcolour; /* RRGGBB */ - - switch (option_entry->type) { - case OPTION_BOOL: - *((bool *)option_entry->p) = value[0] == '1'; - ret = true; - break; - - case OPTION_INTEGER: - *((int *)option_entry->p) = atoi(value); - ret = true; - break; - - case OPTION_COLOUR: - sscanf(value, "%x", &rgbcolour); - *((colour *)option_entry->p) = - ((0x000000FF & rgbcolour) << 16) | - ((0x0000FF00 & rgbcolour) << 0) | - ((0x00FF0000 & rgbcolour) >> 16); - ret = true; - break; - - case OPTION_STRING: - free(*((char **)option_entry->p)); - if (*value == 0) { - /* do not allow empty strings in text options */ - *((char **)option_entry->p) = NULL; - } else { - *((char **)option_entry->p) = strdup(value); - } - ret = true; - break; - } - - return ret; -} - -static void nsoptions_validate(struct ns_options *opts) -{ - if (opts->font_size < 50) - opts->font_size = 50; - - if (1000 < opts->font_size) - opts->font_size = 1000; - - if (opts->font_min_size < 10) - opts->font_min_size = 10; - - if (500 < opts->font_min_size) - opts->font_min_size = 500; - - if (opts->memory_cache_size < 0) - opts->memory_cache_size = 0; - -} - -/* exported interface documented in options.h */ -void nsoption_read(const char *path) -{ - char s[100]; - FILE *fp; - - if (path == NULL) { - LOG(("No options loaded")); - return; - } - - fp = fopen(path, "r"); - if (!fp) { - LOG(("failed to open file '%s'", path)); - return; - } - - while (fgets(s, 100, fp)) { - char *colon, *value; - unsigned int i; - - if (s[0] == 0 || s[0] == '#') - continue; - colon = strchr(s, ':'); - if (colon == 0) - continue; - s[strlen(s) - 1] = 0; /* remove \n at end */ - *colon = 0; /* terminate key */ - value = colon + 1; - - for (i = 0; i != option_table_entries; i++) { - if (strcasecmp(s, option_table[i].key) != 0) - continue; - - strtooption(value, option_table + i); - break; - } - } - - fclose(fp); - - nsoptions_validate(&nsoptions); -} - - -/* exported interface documented in options.h */ -void nsoption_write(const char *path) -{ - unsigned int entry; - FILE *fp; - colour rgbcolour; /* RRGGBB */ - - fp = fopen(path, "w"); - if (!fp) { - LOG(("failed to open file '%s' for writing", path)); - return; - } - - for (entry = 0; entry != option_table_entries; entry++) { - switch (option_table[entry].type) { - case OPTION_BOOL: - fprintf(fp, "%s:%c\n", option_table[entry].key, - *((bool *) option_table[entry].p) ? '1' : '0'); - break; - - case OPTION_INTEGER: - fprintf(fp, "%s:%i\n", option_table[entry].key, - *((int *) option_table[entry].p)); - break; - - case OPTION_COLOUR: - rgbcolour = ((0x000000FF & *((colour *) - option_table[entry].p)) << 16) | - ((0x0000FF00 & *((colour *) - option_table[entry].p)) << 0) | - ((0x00FF0000 & *((colour *) - option_table[entry].p)) >> 16); - fprintf(fp, "%s:%06x\n", option_table[entry].key, - rgbcolour); - break; - - case OPTION_STRING: - if (((*((char **) option_table[entry].p)) != NULL) && - (*(*((char **) option_table[entry].p)) != 0)) { - fprintf(fp, "%s:%s\n", option_table[entry].key, - *((char **) option_table[entry].p)); - } - break; - } - } - - fclose(fp); -} - - -/** - * Output an option value into a string, in HTML format. - * - * \param option The option to output the value of. - * \param size The size of the string buffer. - * \param pos The current position in string - * \param string The string in which to output the value. - * \return The number of bytes written to string or -1 on error - */ -static size_t -nsoption_output_value_html(struct option_entry_s *option, - size_t size, size_t pos, char *string) -{ - size_t slen = 0; /* length added to string */ - colour rgbcolour; /* RRGGBB */ - - switch (option->type) { - case OPTION_BOOL: - slen = snprintf(string + pos, size - pos, "%s", - *((bool *)option->p) ? "true" : "false"); - break; - - case OPTION_INTEGER: - slen = snprintf(string + pos, size - pos, "%i", - *((int *)option->p)); - break; - - case OPTION_COLOUR: - rgbcolour = ((0x000000FF & *((colour *) option->p)) << 16) | - ((0x0000FF00 & *((colour *) option->p)) << 0) | - ((0x00FF0000 & *((colour *) option->p)) >> 16); - slen = snprintf(string + pos, size - pos, - "<span style=\"background-color: #%06x; " - "color: #%06x;\">#%06x</span>", rgbcolour, - (~rgbcolour) & 0xffffff, rgbcolour); - break; - - case OPTION_STRING: - if (*((char **)option->p) != NULL) { - slen = snprintf(string + pos, size - pos, "%s", - *((char **)option->p)); - } else { - slen = snprintf(string + pos, size - pos, - "<span class=\"null-content\">NULL" - "</span>"); - } - break; - } - - return slen; -} - - -/** - * Output an option value into a string, in plain text format. - * - * \param option The option to output the value of. - * \param size The size of the string buffer. - * \param pos The current position in string - * \param string The string in which to output the value. - * \return The number of bytes written to string or -1 on error - */ -static size_t -nsoption_output_value_text(struct option_entry_s *option, - size_t size, size_t pos, char *string) -{ - size_t slen = 0; /* length added to string */ - colour rgbcolour; /* RRGGBB */ - - switch (option->type) { - case OPTION_BOOL: - slen = snprintf(string + pos, size - pos, "%c", - *((bool *)option->p) ? '1' : '0'); - break; - - case OPTION_INTEGER: - slen = snprintf(string + pos, size - pos, "%i", - *((int *)option->p)); - break; - - case OPTION_COLOUR: - rgbcolour = ((0x000000FF & *((colour *) option->p)) << 16) | - ((0x0000FF00 & *((colour *) option->p)) << 0) | - ((0x00FF0000 & *((colour *) option->p)) >> 16); - slen = snprintf(string + pos, size - pos, "%06x", rgbcolour); - break; - - case OPTION_STRING: - if (*((char **)option->p) != NULL) { - slen = snprintf(string + pos, size - pos, "%s", - *((char **)option->p)); - } - break; - } - - return slen; -} - -/* exported interface documented in options.h */ -void -nsoption_commandline(int *pargc, char **argv) -{ - char *arg; - char *val; - int arglen; - int idx = 1; - int mv_loop; - - unsigned int entry_loop; - - while (idx < *pargc) { - arg = argv[idx]; - arglen = strlen(arg); - - /* check we have an option */ - /* option must start -- and be as long as the shortest option*/ - if ((arglen < (2+5) ) || (arg[0] != '-') || (arg[1] != '-')) - break; - - arg += 2; /* skip -- */ - - val = strchr(arg, '='); - if (val == NULL) { - /* no equals sign - next parameter is val */ - idx++; - if (idx >= *pargc) - break; - val = argv[idx]; - } else { - /* equals sign */ - arglen = val - arg ; - val++; - } - - /* arg+arglen is the option to set, val is the value */ - - LOG(("%.*s = %s",arglen,arg,val)); - - for (entry_loop = 0; - entry_loop < option_table_entries; - entry_loop++) { - if (strncmp(arg, option_table[entry_loop].key, - arglen) == 0) { - strtooption(val, option_table + entry_loop); - break; - } - } - - idx++; - } - - /* remove processed options from argv */ - for (mv_loop=0;mv_loop < (*pargc - idx); mv_loop++) { - argv[mv_loop + 1] = argv[mv_loop + idx]; - } - *pargc -= (idx - 1); -} - -/* exported interface documented in options.h */ -int -nsoption_snoptionf(char *string, size_t size, unsigned int option, const char *fmt) -{ - size_t slen = 0; /* current output string length */ - int fmtc = 0; /* current index into format string */ - struct option_entry_s *option_entry; - - if (option >= option_table_entries) - return -1; - - option_entry = option_table + option; - - while((slen < size) && (fmt[fmtc] != 0)) { - if (fmt[fmtc] == '%') { - fmtc++; - switch (fmt[fmtc]) { - case 'k': - slen += snprintf(string + slen, size - slen, - "%s", option_entry->key); - break; - - case 't': - switch (option_entry->type) { - case OPTION_BOOL: - slen += snprintf(string + slen, - size - slen, - "boolean"); - break; - - case OPTION_INTEGER: - slen += snprintf(string + slen, - size - slen, - "integer"); - break; - - case OPTION_COLOUR: - slen += snprintf(string + slen, - size - slen, - "colour"); - break; - - case OPTION_STRING: - slen += snprintf(string + slen, - size - slen, - "string"); - break; - - } - break; - - - case 'V': - slen += nsoption_output_value_html(option_entry, - size, slen, string); - break; - case 'v': - slen += nsoption_output_value_text(option_entry, - size, slen, string); - break; - } - fmtc++; - } else { - string[slen] = fmt[fmtc]; - slen++; - fmtc++; - } - } - - /* Ensure that we NUL-terminate the output */ - string[min(slen, size - 1)] = '\0'; - - return slen; -} - -/* exported interface documented in options.h */ -void -nsoption_dump(FILE *outf) -{ - char buffer[256]; - int opt_loop = 0; - int res; - - do { - res = nsoption_snoptionf(buffer, sizeof buffer, opt_loop, - "%k:%v\n"); - if (res > 0) { - fprintf(outf, "%s", buffer); - } - opt_loop++; - } while (res > 0); -} - diff --git a/desktop/options.h b/desktop/options.h index 17ba64f6c..79566184b 100644 --- a/desktop/options.h +++ b/desktop/options.h @@ -1,6 +1,5 @@ /* - * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net> - * Copyright 2004 James Bursa <bursa@users.sourceforge.net> + * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -18,171 +17,258 @@ */ /** \file - * Option reading and saving (interface). + * Option available on all platforms * - * Non-platform specific options can be added by editing this file and - * netsurf/desktop/options.c + * Non-platform specific options can be added by editing this file * * Platform specific options should be added in the platform options.h. * - * The following types of options are supported: - * - bool (OPTION_BOOL) - * - int (OPTION_INTEGER) - * - char* (OPTION_STRING) (must be allocated on heap, may be 0, free before - * assigning a new value) + * This header is specificaly intented to be included multiple times + * with different macro definitions so there is no guard */ #ifndef _NETSURF_DESKTOP_OPTIONS_H_ #define _NETSURF_DESKTOP_OPTIONS_H_ -#define _NETSURF_DESKTOP_OPTIONS_INCLUDING_ +#include "desktop/plot_style.h" -#include <stdbool.h> -#include <stdio.h> +/* defines for system colour table */ +#define NSOPTION_SYS_COLOUR_START NSOPTION_sys_colour_ActiveBorder +#define NSOPTION_SYS_COLOUR_END NSOPTION_sys_colour_WindowText -#include "desktop/plot_style.h" -#include "desktop/options_main.h" - -#if defined(riscos) -#include "riscos/options.h" -#elif defined(nsgtk) -#include "gtk/options.h" -#elif defined(nsbeos) -#include "beos/options.h" -#elif defined(nsamiga) -#include "amiga/options.h" -#elif defined(nsframebuffer) -#include "framebuffer/options.h" -#elif defined(nsatari) -#include "atari/options.h" -#elif defined(nsmonkey) -#include "monkey/options.h" -#else -#define NSOPTION_EXTRA_DEFINE -#define NSOPTION_EXTRA_DEFAULTS -#define NSOPTION_EXTRA_TABLE #endif -/* allow the colour defaults to be overidden by the frontends */ -#ifndef NSOPTION_SYS_COLOUR_DEFAULTS -#define NSOPTION_SYS_COLOUR_DEFAULTS NSOPTION_MAIN_SYS_COLOUR_DEFAULTS -#endif +/** An HTTP proxy should be used. */ +NSOPTION_BOOL(http_proxy, false) -#undef _NETSURF_DESKTOP_OPTIONS_INCLUDING_ +/** Hostname of proxy. */ +NSOPTION_STRING(http_proxy_host, NULL) +/** Proxy port. */ +NSOPTION_INTEGER(http_proxy_port, 8080) -enum { OPTION_HTTP_PROXY_AUTH_NONE = 0, - OPTION_HTTP_PROXY_AUTH_BASIC = 1, - OPTION_HTTP_PROXY_AUTH_NTLM = 2 }; +/** Proxy authentication method. */ +NSOPTION_INTEGER(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE) -#define DEFAULT_MARGIN_TOP_MM 10 -#define DEFAULT_MARGIN_BOTTOM_MM 10 -#define DEFAULT_MARGIN_LEFT_MM 10 -#define DEFAULT_MARGIN_RIGHT_MM 10 -#define DEFAULT_EXPORT_SCALE 0.7 -#ifdef riscos -#define DEFAULT_REFLOW_PERIOD 100 /* time in cs */ -#else -#define DEFAULT_REFLOW_PERIOD 25 /* time in cs */ -#endif +/** Proxy authentication user name */ +NSOPTION_STRING(http_proxy_auth_user, NULL) -struct ns_options { - NSOPTION_MAIN_DEFINE; - NSOPTION_EXTRA_DEFINE; -}; - -/* global option struct */ -extern struct ns_options nsoptions; - -/* acessors */ -#define nsoption_bool(OPTION) (nsoptions.OPTION) -#define nsoption_int(OPTION) (nsoptions.OPTION) -#define nsoption_charp(OPTION) (nsoptions.OPTION) -#define nsoption_colour(OPTION) (nsoptions.OPTION) - -#define nsoption_set_bool(OPTION, VALUE) nsoptions.OPTION = VALUE -#define nsoption_set_int(OPTION, VALUE) nsoptions.OPTION = VALUE -#define nsoption_set_colour(OPTION, VALUE) nsoptions.OPTION = VALUE -#define nsoption_set_charp(OPTION, VALUE) do { \ - if (nsoptions.OPTION != NULL) { \ - free(nsoptions.OPTION); \ - } \ - nsoptions.OPTION = VALUE; \ - if ((nsoptions.OPTION != NULL) && \ - (*nsoptions.OPTION == 0)) { \ - free(nsoptions.OPTION); \ - nsoptions.OPTION = NULL; \ - } \ - } while (0) - -#define nsoption_setnull_charp(OPTION, VALUE) \ - do { \ - if (nsoptions.OPTION == NULL) { \ - nsoptions.OPTION = VALUE; \ - if (*nsoptions.OPTION == 0) { \ - free(nsoptions.OPTION); \ - nsoptions.OPTION = NULL; \ - } \ - } else { \ - free(VALUE); \ - } \ - } while (0) - - -/** - * Read options from a file. - * - * \param path name of file to read options from - * - * Option variables corresponding to lines in the file are updated. Missing - * options are unchanged. If the file fails to open, options are unchanged. - */ -void nsoption_read(const char *path); +/** Proxy authentication password */ +NSOPTION_STRING(http_proxy_auth_pass, NULL) -/** - * Save options to a file. - * - * \param path name of file to write options to - * - * Errors are ignored. - */ -void nsoption_write(const char *path); +/** Default font size / 0.1pt. */ +NSOPTION_INTEGER(font_size, 128) -/** - * Dump user options to stream - * - * \param outf output stream to dump options to. - */ -void nsoption_dump(FILE *outf); +/** Minimum font size. */ +NSOPTION_INTEGER(font_min_size, 85) -/** - * Fill a buffer with an option using a format. - * - * The format string is copied into the output buffer with the - * following replaced: - * %k - The options key - * %t - The options type - * %V - value - HTML type formatting - * %v - value - plain formatting - * - * \param string The buffer in which to place the results. - * \param size The size of the string buffer. - * \param option The opaque option number. - * \param fmt The format string. - * \return The number of bytes written to \a string or -1 on error - */ -int nsoption_snoptionf(char *string, size_t size, unsigned int option, - const char *fmt); +/** Default sans serif font */ +NSOPTION_STRING(font_sans, NULL) +/** Default serif font */ +NSOPTION_STRING(font_serif, NULL) + +/** Default monospace font */ +NSOPTION_STRING(font_mono, NULL) + +/** Default cursive font */ +NSOPTION_STRING(font_cursive, NULL) + +/** Default fantasy font */ +NSOPTION_STRING(font_fantasy, NULL) + +/** Accept-Language header. */ +NSOPTION_STRING(accept_language, NULL) + +/** Accept-Charset header. */ +NSOPTION_STRING(accept_charset, NULL) + +/** Preferred maximum size of memory cache / bytes. */ +NSOPTION_INTEGER(memory_cache_size, 12 * 1024 * 1024) + +/** Preferred expiry size of disc cache / bytes. */ +NSOPTION_INTEGER(disc_cache_size, 1024 * 1024 * 1024) + +/** Preferred expiry age of disc cache / days. */ +NSOPTION_INTEGER(disc_cache_age, 28) + +/** Whether to block advertisements */ +NSOPTION_BOOL(block_advertisements, false) + +/** Disable website tracking, see + * http://www.w3.org/Submission/2011/SUBM-web-tracking-protection-20110224/#dnt-uas */ +NSOPTION_BOOL(do_not_track, false) + +/** Minimum GIF animation delay */ +NSOPTION_INTEGER(minimum_gif_delay, 10) + +/** Whether to send the referer HTTP header */ +NSOPTION_BOOL(send_referer, true) + +/** Whether to fetch foreground images */ +NSOPTION_BOOL(foreground_images, true) + +/** Whether to fetch background images */ +NSOPTION_BOOL(background_images, true) + +/** Whether to animate images */ +NSOPTION_BOOL(animate_images, true) + +/** Whether to execute javascript */ +NSOPTION_BOOL(enable_javascript, false) + +/** Maximum time (in seconds) to wait for a script to run */ +NSOPTION_INTEGER(script_timeout, 10) + +/** How many days to retain URL data for */ +NSOPTION_INTEGER(expire_url, 28) + +/** Default font family */ +NSOPTION_INTEGER(font_default, PLOT_FONT_FAMILY_SANS_SERIF) + +/** ca-bundle location */ +NSOPTION_STRING(ca_bundle, NULL) -/** - * Process commandline and set options approriately. +/** ca-path location */ +NSOPTION_STRING(ca_path, NULL) + +/** Cookie file location */ +NSOPTION_STRING(cookie_file, NULL) + +/** Cookie jar location */ +NSOPTION_STRING(cookie_jar, NULL) + +/** Home page location */ +NSOPTION_STRING(homepage_url, NULL) + +/** search web from url bar */ +NSOPTION_BOOL(search_url_bar, false) + +/** default web search provider */ +NSOPTION_INTEGER(search_provider, 0) + +/** URL completion in url bar */ +NSOPTION_BOOL(url_suggestion, true) + +/** default x position of new windows */ +NSOPTION_INTEGER(window_x, 0) + +/** default y position of new windows */ +NSOPTION_INTEGER(window_y, 0) + +/** default width of new windows */ +NSOPTION_INTEGER(window_width, 0) + +/** default height of new windows */ +NSOPTION_INTEGER(window_height, 0) + +/** width of screen when above options were saved */ +NSOPTION_INTEGER(window_screen_width, 0) + +/** height of screen when above options were saved */ +NSOPTION_INTEGER(window_screen_height, 0) + +/** default size of status bar vs. h scroll bar */ +NSOPTION_INTEGER(toolbar_status_size, 6667) + +/** default window scale */ +NSOPTION_INTEGER(scale, 100) + +/* Whether to reflow web pages while objects are fetching */ +NSOPTION_BOOL(incremental_reflow, true) + +/* Minimum time (in cs) between HTML reflows while objects are fetching */ +NSOPTION_UINT(min_reflow_period, DEFAULT_REFLOW_PERIOD) + +/* use core selection menu */ +NSOPTION_BOOL(core_select_menu, false) + +/******** Fetcher options ********/ + +/** Maximum simultaneous active fetchers */ +NSOPTION_INTEGER(max_fetchers, 24) + +/** Maximum simultaneous active fetchers per host. + * (<=option_max_fetchers else it makes no sense) Note that rfc2616 + * section 8.1.4 says that there should be no more than two keepalive + * connections per host. None of the main browsers follow this as it + * slows page fetches down considerably. See + * https://bugzilla.mozilla.org/show_bug.cgi?id=423377#c4 */ -void nsoption_commandline(int *pargc, char **argv); +NSOPTION_INTEGER(max_fetchers_per_host, 5) -/** - * Set default values for unset front-end specific options +/** Maximum number of inactive fetchers cached. The total number of + * handles netsurf will therefore have open is this plus + * option_max_fetchers. */ -void gui_options_init_defaults(void); +NSOPTION_INTEGER(max_cached_fetch_handles, 6) -#endif +/** Suppress debug output from cURL. */ +NSOPTION_BOOL(suppress_curl_debug, true) + +/** Whether to allow target="_blank" */ +NSOPTION_BOOL(target_blank, true) + +/** Whether second mouse button opens in new tab */ +NSOPTION_BOOL(button_2_tab, true) + +/******** PDF / Print options ********/ + +/** top margin of exported page */ +NSOPTION_INTEGER(margin_top, DEFAULT_MARGIN_TOP_MM) + +/** bottom margin of exported page */ +NSOPTION_INTEGER(margin_bottom, DEFAULT_MARGIN_BOTTOM_MM) + +/** left margin of exported page */ +NSOPTION_INTEGER(margin_left, DEFAULT_MARGIN_LEFT_MM) + +/** right margin of exported page */ +NSOPTION_INTEGER(margin_right, DEFAULT_MARGIN_RIGHT_MM) + +/** scale of exported content */ +NSOPTION_INTEGER(export_scale, DEFAULT_EXPORT_SCALE * 100) + +/** suppressing images in printed content */ +NSOPTION_BOOL(suppress_images, false) + +/** turning off all backgrounds for printed content */ +NSOPTION_BOOL(remove_backgrounds, false) + +/** turning on content loosening for printed content */ +NSOPTION_BOOL(enable_loosening, true) + +/** compression of PDF documents */ +NSOPTION_BOOL(enable_PDF_compression, true) + +/** setting a password and encoding PDF documents */ +NSOPTION_BOOL(enable_PDF_password, false) +/******** System colours ********/ +NSOPTION_COLOUR(sys_colour_ActiveBorder, 0x00d3d3d3) +NSOPTION_COLOUR(sys_colour_ActiveCaption, 0x00f1f1f1) +NSOPTION_COLOUR(sys_colour_AppWorkspace, 0x00f1f1f1) +NSOPTION_COLOUR(sys_colour_Background, 0x006e6e6e) +NSOPTION_COLOUR(sys_colour_ButtonFace, 0x00f9f9f9) +NSOPTION_COLOUR(sys_colour_ButtonHighlight, 0x00ffffff) +NSOPTION_COLOUR(sys_colour_ButtonShadow, 0x00aeaeae) +NSOPTION_COLOUR(sys_colour_ButtonText, 0x004c4c4c) +NSOPTION_COLOUR(sys_colour_CaptionText, 0x004c4c4c) +NSOPTION_COLOUR(sys_colour_GrayText, 0x00505050) +NSOPTION_COLOUR(sys_colour_Highlight, 0x00c00800) +NSOPTION_COLOUR(sys_colour_HighlightText, 0x00ffffff) +NSOPTION_COLOUR(sys_colour_InactiveBorder, 0x00f1f1f1) +NSOPTION_COLOUR(sys_colour_InactiveCaption, 0x00e6e6e6) +NSOPTION_COLOUR(sys_colour_InactiveCaptionText, 0x00a6a6a6) +NSOPTION_COLOUR(sys_colour_InfoBackground, 0x008fdfef) +NSOPTION_COLOUR(sys_colour_InfoText, 0x00000000) +NSOPTION_COLOUR(sys_colour_Menu, 0x00f1f1f1) +NSOPTION_COLOUR(sys_colour_MenuText, 0x004e4e4e) +NSOPTION_COLOUR(sys_colour_Scrollbar, 0x00cccccc) +NSOPTION_COLOUR(sys_colour_ThreeDDarkShadow, 0x00aeaeae) +NSOPTION_COLOUR(sys_colour_ThreeDFace, 0x00f9f9f9) +NSOPTION_COLOUR(sys_colour_ThreeDHighlight, 0x00ffffff) +NSOPTION_COLOUR(sys_colour_ThreeDLightShadow, 0x00ffffff) +NSOPTION_COLOUR(sys_colour_ThreeDShadow, 0x00d5d5d5) +NSOPTION_COLOUR(sys_colour_Window, 0x00f1f1f1) +NSOPTION_COLOUR(sys_colour_WindowFrame, 0x004e4e4e) +NSOPTION_COLOUR(sys_colour_WindowText, 0x00000000) diff --git a/desktop/options_main.h b/desktop/options_main.h deleted file mode 100644 index 7b9e7314b..000000000 --- a/desktop/options_main.h +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright 2004 James Bursa <bursa@users.sourceforge.net> - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/** \file - * Option available on all platforms - * - * Non-platform specific options can be added by editing this file - * - * Platform specific options should be added in the platform options.h. - * - * The following types of options are supported: - * - bool (OPTION_BOOL) boolean - * - int (OPTION_INTEGER) integer - * - colour (OPTION_COLOUR) colour - * - char* (OPTION_STRING) must be allocated on heap, may be NULL - */ - -#ifndef _NETSURF_DESKTOP_OPTIONS_MAIN_H_ -#define _NETSURF_DESKTOP_OPTIONS_MAIN_H_ - -#define NSOPTION_MAIN_DEFINE \ - /** An HTTP proxy should be used. */ \ - bool http_proxy; \ - /** Hostname of proxy. */ \ - char *http_proxy_host; \ - /** Proxy port. */ \ - int http_proxy_port; \ - /** Proxy authentication method. */ \ - int http_proxy_auth; \ - /** Proxy authentication user name */ \ - char *http_proxy_auth_user; \ - /** Proxy authentication password */ \ - char *http_proxy_auth_pass; \ - /** Default font size / 0.1pt. */ \ - int font_size; \ - /** Minimum font size. */ \ - int font_min_size; \ - /** Default sans serif font */ \ - char *font_sans; \ - /** Default serif font */ \ - char *font_serif; \ - /** Default monospace font */ \ - char *font_mono; \ - /** Default cursive font */ \ - char *font_cursive; \ - /** Default fantasy font */ \ - char *font_fantasy; \ - /** Accept-Language header. */ \ - char *accept_language; \ - /** Accept-Charset header. */ \ - char *accept_charset; \ - /** Preferred maximum size of memory cache / bytes. */ \ - int memory_cache_size; \ - /** Preferred expiry size of disc cache / bytes. */ \ - int disc_cache_size; \ - /** Preferred expiry age of disc cache / days. */ \ - int disc_cache_age; \ - /** Whether to block advertisements */ \ - bool block_ads; \ - /** Disable website tracking, see \ - * http://www.w3.org/Submission/2011/SUBM-web-tracking-protection-20110224/#dnt-uas */ \ - bool do_not_track; \ - /** Minimum GIF animation delay */ \ - int minimum_gif_delay; \ - /** Whether to send the referer HTTP header */ \ - bool send_referer; \ - /** Whether to fetch foreground images */ \ - bool foreground_images; \ - /** Whether to fetch background images */ \ - bool background_images; \ - /** Whether to animate images */ \ - bool animate_images; \ - /** Whether to execute javascript */ \ - bool enable_javascript; \ - /** How many days to retain URL data for */ \ - int expire_url; \ - /** Default font family */ \ - int font_default; \ - /** ca-bundle location */ \ - char *ca_bundle; \ - /** ca-path location */ \ - char *ca_path; \ - /** Cookie file location */ \ - char *cookie_file; \ - /** Cookie jar location */ \ - char *cookie_jar; \ - /** Home page location */ \ - char *homepage_url; \ - /** search web from url bar */ \ - bool search_url_bar; \ - /** URL completion in url bar */ \ - bool url_suggestion; \ - /** default web search provider */ \ - int search_provider; \ - /** default x position of new windows */ \ - int window_x; \ - /** default y position of new windows */ \ - int window_y; \ - /** default width of new windows */ \ - int window_width; \ - /** default height of new windows */ \ - int window_height; \ - /** width of screen when above options were saved */ \ - int window_screen_width; \ - /** height of screen when above options were saved */ \ - int window_screen_height; \ - /** default size of status bar vs. h scroll bar */ \ - int toolbar_status_width; \ - /** default window scale */ \ - int scale; \ - /* Whether to reflow web pages while objects are fetching */ \ - bool incremental_reflow; \ - /* Minimum time between HTML reflows while objects are fetching */ \ - unsigned int min_reflow_period; /* time in cs */ \ - bool core_select_menu; \ - /** top margin of exported page */ \ - int margin_top; \ - /** bottom margin of exported page */ \ - int margin_bottom; \ - /** left margin of exported page */ \ - int margin_left; \ - /** right margin of exported page*/ \ - int margin_right; \ - /** scale of exported content*/ \ - int export_scale; \ - /** suppressing images in printed content*/ \ - bool suppress_images; \ - /** turning off all backgrounds for printed content*/ \ - bool remove_backgrounds; \ - /** turning on content loosening for printed content*/ \ - bool enable_loosening; \ - /** compression of PDF documents*/ \ - bool enable_PDF_compression; \ - /** setting a password and encoding PDF documents*/ \ - bool enable_PDF_password; \ - \ - /* Fetcher configuration */ \ - /** Maximum simultaneous active fetchers */ \ - int max_fetchers; \ - /** Maximum simultaneous active fetchers per host. \ - * (<=option_max_fetchers else it makes no sense) Note that \ - * rfc2616 section 8.1.4 says that there should be no more \ - * than two keepalive connections per host. None of the main \ - * browsers follow this as it slows page fetches down \ - * considerably. See \ - * https://bugzilla.mozilla.org/show_bug.cgi?id=423377#c4 \ - */ \ - int max_fetchers_per_host; \ - /** Maximum number of inactive fetchers cached. The total \ - * number of handles netsurf will therefore have open is this \ - * plus option_max_fetchers. \ - */ \ - int max_cached_fetch_handles; \ - /** Suppress debug output from cURL. */ \ - bool suppress_curl_debug; \ - \ - /** Whether to allow target="_blank" */ \ - bool target_blank; \ - \ - /** Whether second mouse button opens in new tab */ \ - bool button_2_tab; \ - \ - /* system colours */ \ - colour sys_colour_ActiveBorder; \ - colour sys_colour_ActiveCaption; \ - colour sys_colour_AppWorkspace; \ - colour sys_colour_Background; \ - colour sys_colour_ButtonFace; \ - colour sys_colour_ButtonHighlight; \ - colour sys_colour_ButtonShadow; \ - colour sys_colour_ButtonText; \ - colour sys_colour_CaptionText; \ - colour sys_colour_GrayText; \ - colour sys_colour_Highlight; \ - colour sys_colour_HighlightText; \ - colour sys_colour_InactiveBorder; \ - colour sys_colour_InactiveCaption; \ - colour sys_colour_InactiveCaptionText; \ - colour sys_colour_InfoBackground; \ - colour sys_colour_InfoText; \ - colour sys_colour_Menu; \ - colour sys_colour_MenuText; \ - colour sys_colour_Scrollbar; \ - colour sys_colour_ThreeDDarkShadow; \ - colour sys_colour_ThreeDFace; \ - colour sys_colour_ThreeDHighlight; \ - colour sys_colour_ThreeDLightShadow; \ - colour sys_colour_ThreeDShadow; \ - colour sys_colour_Window; \ - colour sys_colour_WindowFrame; \ - colour sys_colour_WindowText - -#define NSOPTION_MAIN_DEFAULTS \ - .http_proxy = false, \ - .http_proxy_host = NULL, \ - .http_proxy_port = 8080, \ - .http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NONE, \ - .http_proxy_auth_user = NULL, \ - .http_proxy_auth_pass = NULL, \ - .font_size = 128, \ - .font_min_size = 85, \ - .font_sans = NULL, \ - .font_serif = NULL, \ - .font_mono = NULL, \ - .font_cursive = NULL, \ - .font_fantasy = NULL, \ - .accept_language = NULL, \ - .accept_charset = NULL, \ - .memory_cache_size = 12 * 1024 * 1024, \ - .disc_cache_size = 1024 * 1024 * 1024, \ - .disc_cache_age = 28, \ - .block_ads = false, \ - .do_not_track = false, \ - .minimum_gif_delay = 10, \ - .send_referer = true, \ - .foreground_images = true, \ - .background_images = true, \ - .animate_images = true, \ - .expire_url = 28, \ - .font_default = PLOT_FONT_FAMILY_SANS_SERIF, \ - .ca_bundle = NULL, \ - .ca_path = NULL, \ - .cookie_file = NULL, \ - .cookie_jar = NULL, \ - .homepage_url = NULL, \ - .search_url_bar = false, \ - .url_suggestion = true, \ - .search_provider = 0, \ - .window_x = 0, \ - .window_y = 0, \ - .window_width = 0, \ - .window_height = 0, \ - .window_screen_width = 0, \ - .window_screen_height = 0, \ - .toolbar_status_width = 6667, \ - .scale = 100, \ - .incremental_reflow = true, \ - .min_reflow_period = DEFAULT_REFLOW_PERIOD, \ - .core_select_menu = false, \ - .margin_top = DEFAULT_MARGIN_TOP_MM, \ - .margin_bottom = DEFAULT_MARGIN_BOTTOM_MM, \ - .margin_left = DEFAULT_MARGIN_LEFT_MM, \ - .margin_right = DEFAULT_MARGIN_RIGHT_MM, \ - .export_scale = DEFAULT_EXPORT_SCALE * 100, \ - .suppress_images = false, \ - .remove_backgrounds = false, \ - .enable_loosening = true, \ - .enable_PDF_compression = true, \ - .enable_PDF_password = false, \ - .max_fetchers = 24, \ - .max_fetchers_per_host = 5, \ - .max_cached_fetch_handles = 6, \ - .suppress_curl_debug = true, \ - .target_blank = true, \ - .button_2_tab = true, \ - .enable_javascript = true - -#define NSOPTION_MAIN_SYS_COLOUR_DEFAULTS \ - .sys_colour_ActiveBorder = 0x00000000, \ - .sys_colour_ActiveCaption = 0x00000000, \ - .sys_colour_AppWorkspace = 0x00000000, \ - .sys_colour_Background = 0x00000000, \ - .sys_colour_ButtonFace = 0x00000000, \ - .sys_colour_ButtonHighlight = 0x00000000, \ - .sys_colour_ButtonShadow = 0x00000000, \ - .sys_colour_ButtonText = 0x00000000, \ - .sys_colour_CaptionText = 0x0000000, \ - .sys_colour_GrayText = 0x00000000, \ - .sys_colour_Highlight = 0x00000000, \ - .sys_colour_HighlightText = 0x00000000, \ - .sys_colour_InactiveBorder = 0x00000000, \ - .sys_colour_InactiveCaption = 0x00000000, \ - .sys_colour_InactiveCaptionText = 0x00000000, \ - .sys_colour_InfoBackground = 0x00000000, \ - .sys_colour_InfoText = 0x00000000, \ - .sys_colour_Menu = 0x00000000, \ - .sys_colour_MenuText = 0x0000000, \ - .sys_colour_Scrollbar = 0x0000000, \ - .sys_colour_ThreeDDarkShadow = 0x000000, \ - .sys_colour_ThreeDFace = 0x000000, \ - .sys_colour_ThreeDHighlight = 0x000000, \ - .sys_colour_ThreeDLightShadow = 0x000000, \ - .sys_colour_ThreeDShadow = 0x000000, \ - .sys_colour_Window = 0x000000, \ - .sys_colour_WindowFrame = 0x000000, \ - .sys_colour_WindowText = 0x000000 - - -#define NSOPTION_MAIN_TABLE \ - { "http_proxy", OPTION_BOOL, &nsoptions.http_proxy }, \ - { "http_proxy_host", OPTION_STRING, &nsoptions.http_proxy_host }, \ - { "http_proxy_port", OPTION_INTEGER, &nsoptions.http_proxy_port }, \ - { "http_proxy_auth", OPTION_INTEGER, &nsoptions.http_proxy_auth }, \ - { "http_proxy_auth_user", OPTION_STRING, &nsoptions.http_proxy_auth_user }, \ - { "http_proxy_auth_pass", OPTION_STRING, &nsoptions.http_proxy_auth_pass }, \ - { "font_size", OPTION_INTEGER, &nsoptions.font_size }, \ - { "font_min_size", OPTION_INTEGER, &nsoptions.font_min_size }, \ - { "font_sans", OPTION_STRING, &nsoptions.font_sans }, \ - { "font_serif", OPTION_STRING, &nsoptions.font_serif }, \ - { "font_mono", OPTION_STRING, &nsoptions.font_mono }, \ - { "font_cursive", OPTION_STRING, &nsoptions.font_cursive }, \ - { "font_fantasy", OPTION_STRING, &nsoptions.font_fantasy }, \ - { "accept_language", OPTION_STRING, &nsoptions.accept_language }, \ - { "accept_charset", OPTION_STRING, &nsoptions.accept_charset }, \ - { "memory_cache_size", OPTION_INTEGER, &nsoptions.memory_cache_size }, \ - { "disc_cache_size", OPTION_INTEGER, &nsoptions.disc_cache_size }, \ - { "disc_cache_age", OPTION_INTEGER, &nsoptions.disc_cache_age }, \ - { "block_advertisements", OPTION_BOOL, &nsoptions.block_ads }, \ - { "do_not_track", OPTION_BOOL, &nsoptions.do_not_track }, \ - { "minimum_gif_delay", OPTION_INTEGER, &nsoptions.minimum_gif_delay }, \ - { "send_referer", OPTION_BOOL, &nsoptions.send_referer }, \ - { "foreground_images", OPTION_BOOL, &nsoptions.foreground_images }, \ - { "background_images", OPTION_BOOL, &nsoptions.background_images }, \ - { "animate_images", OPTION_BOOL, &nsoptions.animate_images }, \ - { "enable_javascript", OPTION_BOOL, &nsoptions.enable_javascript}, \ - { "expire_url", OPTION_INTEGER, &nsoptions.expire_url }, \ - { "font_default", OPTION_INTEGER, &nsoptions.font_default }, \ - { "ca_bundle", OPTION_STRING, &nsoptions.ca_bundle }, \ - { "ca_path", OPTION_STRING, &nsoptions.ca_path }, \ - { "cookie_file", OPTION_STRING, &nsoptions.cookie_file }, \ - { "cookie_jar", OPTION_STRING, &nsoptions.cookie_jar }, \ - { "homepage_url", OPTION_STRING, &nsoptions.homepage_url }, \ - { "search_url_bar", OPTION_BOOL, &nsoptions.search_url_bar}, \ - { "search_provider", OPTION_INTEGER, &nsoptions.search_provider}, \ - { "url_suggestion", OPTION_BOOL, &nsoptions.url_suggestion }, \ - { "window_x", OPTION_INTEGER, &nsoptions.window_x }, \ - { "window_y", OPTION_INTEGER, &nsoptions.window_y }, \ - { "window_width", OPTION_INTEGER, &nsoptions.window_width }, \ - { "window_height", OPTION_INTEGER, &nsoptions.window_height }, \ - { "window_screen_width", OPTION_INTEGER, &nsoptions.window_screen_width }, \ - { "window_screen_height", OPTION_INTEGER, &nsoptions.window_screen_height }, \ - { "toolbar_status_size", OPTION_INTEGER, &nsoptions.toolbar_status_width }, \ - { "scale", OPTION_INTEGER, &nsoptions.scale }, \ - { "incremental_reflow", OPTION_BOOL, &nsoptions.incremental_reflow }, \ - { "min_reflow_period", OPTION_INTEGER, &nsoptions.min_reflow_period }, \ - { "core_select_menu", OPTION_BOOL, &nsoptions.core_select_menu }, \ - /* Fetcher options */ \ - { "max_fetchers", OPTION_INTEGER, &nsoptions.max_fetchers }, \ - { "max_fetchers_per_host", OPTION_INTEGER, &nsoptions.max_fetchers_per_host }, \ - { "max_cached_fetch_handles", OPTION_INTEGER, &nsoptions.max_cached_fetch_handles }, \ - { "suppress_curl_debug",OPTION_BOOL, &nsoptions.suppress_curl_debug }, \ - { "target_blank", OPTION_BOOL, &nsoptions.target_blank }, \ - { "button_2_tab", OPTION_BOOL, &nsoptions.button_2_tab }, \ - /* PDF / Print options*/ \ - { "margin_top", OPTION_INTEGER, &nsoptions.margin_top}, \ - { "margin_bottom", OPTION_INTEGER, &nsoptions.margin_bottom}, \ - { "margin_left", OPTION_INTEGER, &nsoptions.margin_left}, \ - { "margin_right", OPTION_INTEGER, &nsoptions.margin_right}, \ - { "export_scale", OPTION_INTEGER, &nsoptions.export_scale}, \ - { "suppress_images", OPTION_BOOL, &nsoptions.suppress_images}, \ - { "remove_backgrounds", OPTION_BOOL, &nsoptions.remove_backgrounds}, \ - { "enable_loosening", OPTION_BOOL, &nsoptions.enable_loosening}, \ - { "enable_PDF_compression", OPTION_BOOL, &nsoptions.enable_PDF_compression}, \ - { "enable_PDF_password", OPTION_BOOL, &nsoptions.enable_PDF_password}, \ - \ - /* System colours */ \ - { "sys_colour_ActiveBorder",OPTION_COLOUR,&nsoptions.sys_colour_ActiveBorder }, \ - { "sys_colour_ActiveCaption",OPTION_COLOUR,&nsoptions.sys_colour_ActiveCaption }, \ - { "sys_colour_AppWorkspace",OPTION_COLOUR,&nsoptions.sys_colour_AppWorkspace }, \ - { "sys_colour_Background",OPTION_COLOUR,&nsoptions.sys_colour_Background }, \ - { "sys_colour_ButtonFace",OPTION_COLOUR,&nsoptions.sys_colour_ButtonFace }, \ - { "sys_colour_ButtonHighlight",OPTION_COLOUR,&nsoptions.sys_colour_ButtonHighlight }, \ - { "sys_colour_ButtonShadow",OPTION_COLOUR,&nsoptions.sys_colour_ButtonShadow }, \ - { "sys_colour_ButtonText",OPTION_COLOUR,&nsoptions.sys_colour_ButtonText }, \ - { "sys_colour_CaptionText",OPTION_COLOUR,&nsoptions.sys_colour_CaptionText }, \ - { "sys_colour_GrayText",OPTION_COLOUR,&nsoptions.sys_colour_GrayText }, \ - { "sys_colour_Highlight",OPTION_COLOUR,&nsoptions.sys_colour_Highlight }, \ - { "sys_colour_HighlightText",OPTION_COLOUR,&nsoptions.sys_colour_HighlightText }, \ - { "sys_colour_InactiveBorder",OPTION_COLOUR,&nsoptions.sys_colour_InactiveBorder }, \ - { "sys_colour_InactiveCaption",OPTION_COLOUR,&nsoptions.sys_colour_InactiveCaption }, \ - { "sys_colour_InactiveCaptionText",OPTION_COLOUR,&nsoptions.sys_colour_InactiveCaptionText }, \ - { "sys_colour_InfoBackground",OPTION_COLOUR,&nsoptions.sys_colour_InfoBackground }, \ - { "sys_colour_InfoText",OPTION_COLOUR,&nsoptions.sys_colour_InfoText }, \ - { "sys_colour_Menu",OPTION_COLOUR,&nsoptions.sys_colour_Menu }, \ - { "sys_colour_MenuText",OPTION_COLOUR,&nsoptions.sys_colour_MenuText }, \ - { "sys_colour_Scrollbar",OPTION_COLOUR,&nsoptions.sys_colour_Scrollbar }, \ - { "sys_colour_ThreeDDarkShadow",OPTION_COLOUR,&nsoptions.sys_colour_ThreeDDarkShadow }, \ - { "sys_colour_ThreeDFace",OPTION_COLOUR,&nsoptions.sys_colour_ThreeDFace }, \ - { "sys_colour_ThreeDHighlight",OPTION_COLOUR,&nsoptions.sys_colour_ThreeDHighlight }, \ - { "sys_colour_ThreeDLightShadow", OPTION_COLOUR,&nsoptions.sys_colour_ThreeDLightShadow }, \ - { "sys_colour_ThreeDShadow", OPTION_COLOUR,&nsoptions.sys_colour_ThreeDShadow }, \ - { "sys_colour_Window", OPTION_COLOUR,&nsoptions.sys_colour_Window }, \ - { "sys_colour_WindowFrame", OPTION_COLOUR,&nsoptions.sys_colour_WindowFrame }, \ - { "sys_colour_WindowText", OPTION_COLOUR,&nsoptions.sys_colour_WindowText } - -#endif diff --git a/desktop/print.c b/desktop/print.c index e1cd48f93..8f83f2d19 100644 --- a/desktop/print.c +++ b/desktop/print.c @@ -30,7 +30,7 @@ #include "content/content.h" #include "content/hlcache.h" #include "css/utils.h" -#include "desktop/options.h" +#include "utils/nsoption.h" #include "desktop/print.h" #include "desktop/printer.h" #include "render/box.h" diff --git a/desktop/save_pdf/font_haru.c b/desktop/save_pdf/font_haru.c index c90753121..57d36fe95 100644 --- a/desktop/save_pdf/font_haru.c +++ b/desktop/save_pdf/font_haru.c @@ -39,7 +39,7 @@ #include "css/css.h" #include "css/utils.h" -#include "desktop/options.h" +#include "utils/nsoption.h" #include "desktop/save_pdf/font_haru.h" #include "render/font.h" #include "utils/log.h" diff --git a/desktop/save_pdf/pdf_plotters.c b/desktop/save_pdf/pdf_plotters.c index 847d6dafc..123408dd3 100644 --- a/desktop/save_pdf/pdf_plotters.c +++ b/desktop/save_pdf/pdf_plotters.c @@ -31,7 +31,7 @@ #include <hpdf.h> #include "content/hlcache.h" -#include "desktop/options.h" +#include "utils/nsoption.h" #include "desktop/plotters.h" #include "desktop/print.h" #include "desktop/printer.h" diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c index 5517a6f0d..d24ea727a 100644 --- a/desktop/scrollbar.c +++ b/desktop/scrollbar.c @@ -27,7 +27,7 @@ #include "desktop/mouse.h" #include "desktop/scrollbar.h" -#include "desktop/options.h" +#include "utils/nsoption.h" #include "desktop/plotters.h" #include "desktop/plot_style.h" #include "utils/log.h" diff --git a/desktop/search.c b/desktop/search.c index 014488e2d..3a7c768a5 100644 --- a/desktop/search.c +++ b/desktop/search.c @@ -30,7 +30,7 @@ #include "content/hlcache.h" #include "desktop/browser_private.h" #include "desktop/gui.h" -#include "desktop/options.h" +#include "utils/nsoption.h" #include "desktop/search.h" #include "desktop/selection.h" #include "render/box.h" diff --git a/desktop/searchweb.c b/desktop/searchweb.c index a90627ac6..87e3e21f1 100644 --- a/desktop/searchweb.c +++ b/desktop/searchweb.c @@ -27,7 +27,7 @@ #include "content/hlcache.h" #include "desktop/browser.h" #include "desktop/gui.h" -#include "desktop/options.h" +#include "utils/nsoption.h" #include "desktop/searchweb.h" #include "utils/config.h" #include "utils/log.h" diff --git a/desktop/system_colour.c b/desktop/system_colour.c new file mode 100644 index 000000000..4ef170981 --- /dev/null +++ b/desktop/system_colour.c @@ -0,0 +1,101 @@ +/* + * Copyright 2011 Vincent Sanders <vince@netsurf-browser.org> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** \file + * System colour handling + * + */ + +#include "utils/utils.h" +#include "utils/log.h" +#include "css/utils.h" +#include "desktop/gui.h" +#include "utils/nsoption.h" + + + +#define colour_list_len ((NSOPTION_SYS_COLOUR_END - NSOPTION_SYS_COLOUR_START) + 1) + +static lwc_string *colour_list[colour_list_len]; + +static lwc_string **gui_system_colour_pw = NULL; + + +bool gui_system_colour_init(void) +{ + unsigned int ccount; + + if (gui_system_colour_pw != NULL) + return false; + + /* Intern colour strings */ + for (ccount = 0; ccount < colour_list_len; ccount++) { + struct nsoption_s *opt; + opt = &nsoptions[ccount + NSOPTION_SYS_COLOUR_START]; + if (lwc_intern_string(opt->key + SLEN("sys_colour_"), + opt->key_len - SLEN("sys_colour_"), + &(colour_list[ccount])) != lwc_error_ok) { + return false; + } + } + + gui_system_colour_pw = colour_list; + + return true; +} + +void gui_system_colour_finalize(void) +{ + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + lwc_string_unref(colour_list[ccount]); + } +} + +colour gui_system_colour_char(const char *name) +{ + colour ret = 0; + unsigned int ccount; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (strcmp(name, + nsoptions[ccount + NSOPTION_SYS_COLOUR_START].key + SLEN("sys_colour_")) == 0) { + ret = nsoptions[ccount + NSOPTION_SYS_COLOUR_START].value.c; + break; + } + } + return ret; +} + +css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour) +{ + unsigned int ccount; + bool match; + + for (ccount = 0; ccount < colour_list_len; ccount++) { + if (lwc_string_caseless_isequal(name, + colour_list[ccount], + &match) == lwc_error_ok && match) { + *colour = ns_color_to_nscss(nsoptions[ccount + NSOPTION_SYS_COLOUR_START].value.c); + return CSS_OK; + } + } + + return CSS_INVALID; +} diff --git a/desktop/thumbnail.c b/desktop/thumbnail.c index 975e799fa..1011adc1f 100644 --- a/desktop/thumbnail.c +++ b/desktop/thumbnail.c @@ -27,7 +27,7 @@ #include "content/hlcache.h" #include "desktop/browser.h" #include "desktop/knockout.h" -#include "desktop/options.h" +#include "utils/nsoption.h" #include "desktop/plotters.h" #include "desktop/thumbnail.h" #include "utils/log.h" diff --git a/desktop/tree.c b/desktop/tree.c index e12da8b0b..2e35b5bf8 100644 --- a/desktop/tree.c +++ b/desktop/tree.c @@ -34,7 +34,7 @@ #include "desktop/textarea.h" #include "desktop/textinput.h" #include "desktop/tree.h" -#include "desktop/options.h" +#include "utils/nsoption.h" #include "desktop/plotters.h" #include "render/font.h" #include "utils/log.h" diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c index 541636f56..8472fff24 100644 --- a/desktop/tree_url_node.c +++ b/desktop/tree_url_node.c @@ -32,7 +32,7 @@ #include "content/hlcache.h" #include "content/urldb.h" #include "desktop/browser.h" -#include "desktop/options.h" +#include "utils/nsoption.h" #include "desktop/tree_url_node.h" #include "utils/corestrings.h" #include "utils/libdom.h" |