summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2010-12-21 17:00:44 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2010-12-21 17:00:44 +0000
commit710f0ce844573faf364dda63295dc942e5848fc9 (patch)
tree63323f756404b2429c5bb4464c41d8ced169f474 /desktop
parent2d54d7f798cfaae6783e51e6a12c49988f533ace (diff)
downloadnetsurf-710f0ce844573faf364dda63295dc942e5848fc9.tar.gz
netsurf-710f0ce844573faf364dda63295dc942e5848fc9.tar.bz2
Add COLOUR option type. Add some colour options for rendering core interfaces.
svn path=/trunk/netsurf/; revision=11117
Diffstat (limited to 'desktop')
-rw-r--r--desktop/options.c46
-rw-r--r--desktop/options.h6
2 files changed, 51 insertions, 1 deletions
diff --git a/desktop/options.c b/desktop/options.c
index 47b42dc3b..5d49b9490 100644
--- a/desktop/options.c
+++ b/desktop/options.c
@@ -187,12 +187,17 @@ bool option_target_blank = true;
/** Whether second mouse button opens in new tab */
bool option_button_2_tab = true;
+/* Interface colours */
+colour option_gui_colour_bg_1 = 0xFFCCBB; /** Background (bbggrr) */
+colour option_gui_colour_fg_1 = 0x000000; /** Foreground (bbggrr) */
+colour option_gui_colour_fg_2 = 0xFFFBF8; /** Foreground selected (bbggrr) */
+
EXTRA_OPTION_DEFINE
struct {
const char *key;
- enum { OPTION_BOOL, OPTION_INTEGER, OPTION_STRING } type;
+ enum { OPTION_BOOL, OPTION_INTEGER, OPTION_STRING, OPTION_COLOUR } type;
void *p;
} option_table[] = {
{ "http_proxy", OPTION_BOOL, &option_http_proxy },
@@ -266,6 +271,11 @@ struct {
OPTION_BOOL, &option_enable_PDF_compression},
{ "enable_PDF_password",
OPTION_BOOL, &option_enable_PDF_password},
+ /* Interface colours */
+ { "gui_colour_bg_1", OPTION_COLOUR, &option_gui_colour_bg_1},
+ { "gui_colour_fg_1", OPTION_COLOUR, &option_gui_colour_fg_1},
+ { "gui_colour_fg_2", OPTION_COLOUR, &option_gui_colour_fg_2},
+
EXTRA_OPTION_TABLE
};
@@ -285,6 +295,7 @@ void options_read(const char *path)
{
char s[100];
FILE *fp;
+ colour rgbcolour; /* RRGGBB */
fp = fopen(path, "r");
if (!fp) {
@@ -320,6 +331,17 @@ void options_read(const char *path)
atoi(value);
break;
+ case OPTION_COLOUR:
+ sscanf(value, "%x", &rgbcolour);
+ *((colour *) option_table[i].p) =
+ ((0x000000FF &
+ rgbcolour) << 16) |
+ ((0x0000FF00 &
+ rgbcolour) << 0) |
+ ((0x00FF0000 &
+ rgbcolour) >> 16);
+ break;
+
case OPTION_STRING:
free(*((char **) option_table[i].p));
*((char **) option_table[i].p) =
@@ -358,6 +380,7 @@ void options_write(const char *path)
{
unsigned int i;
FILE *fp;
+ colour rgbcolour; /* RRGGBB */
fp = fopen(path, "w");
if (!fp) {
@@ -377,6 +400,16 @@ void options_write(const char *path)
fprintf(fp, "%i", *((int *) option_table[i].p));
break;
+ case OPTION_COLOUR:
+ rgbcolour = ((0x000000FF & *((colour *)
+ option_table[i].p)) << 16) |
+ ((0x0000FF00 & *((colour *)
+ option_table[i].p)) << 0) |
+ ((0x00FF0000 & *((colour *)
+ option_table[i].p)) >> 16);
+ fprintf(fp, "%06x", rgbcolour);
+ break;
+
case OPTION_STRING:
if (*((char **) option_table[i].p))
fprintf(fp, "%s", *((char **) option_table[i].p));
@@ -394,6 +427,7 @@ void options_write(const char *path)
void options_dump(void)
{
unsigned int i;
+ colour rgbcolour;
for (i = 0; i != option_table_entries; i++) {
fprintf(stderr, "%s:", option_table[i].key);
@@ -409,6 +443,16 @@ void options_dump(void)
*((int *) option_table[i].p));
break;
+ case OPTION_COLOUR:
+ rgbcolour = ((0x000000FF | *((colour *)
+ option_table[i].p)) << 16) &
+ ((0x0000FF00 | *((colour *)
+ option_table[i].p)) << 0) &
+ ((0x00FF0000 | *((colour *)
+ option_table[i].p)) >> 16);
+ fprintf(stderr, "%x", rgbcolour);
+ break;
+
case OPTION_STRING:
if (*((char **) option_table[i].p))
fprintf(stderr, "%s",
diff --git a/desktop/options.h b/desktop/options.h
index 2779692b6..308615d90 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -36,6 +36,7 @@
#define _NETSURF_DESKTOP_OPTIONS_H_
#include <stdbool.h>
+#include "desktop/plot_style.h"
struct tree;
@@ -110,6 +111,11 @@ extern int option_max_fetchers_per_host;
extern int option_max_cached_fetch_handles;
extern bool option_suppress_curl_debug;
+/* Interface colours */
+extern colour option_gui_colour_bg_1;
+extern colour option_gui_colour_fg_1;
+extern colour option_gui_colour_fg_2;
+
void options_read(const char *path);
void options_write(const char *path);