summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2004-02-13 16:09:12 +0000
committerJames Bursa <james@netsurf-browser.org>2004-02-13 16:09:12 +0000
commit1319ff78c89fd0c34feea187ca3d67058875fbe6 (patch)
treeb3a1bb74c14305e38991db53e9119c72084daa87 /riscos
parentadd94ad0381bae4889dcd46620b8bfe4e4f443ce (diff)
downloadnetsurf-1319ff78c89fd0c34feea187ca3d67058875fbe6.tar.gz
netsurf-1319ff78c89fd0c34feea187ca3d67058875fbe6.tar.bz2
[project @ 2004-02-13 16:09:12 by bursa]
Clean up and rewrite options code. svn path=/import/netsurf/; revision=536
Diffstat (limited to 'riscos')
-rw-r--r--riscos/dialog.c182
-rw-r--r--riscos/gui.c16
-rw-r--r--riscos/gui.h11
-rw-r--r--riscos/mouseactions.c4
-rw-r--r--riscos/options.c204
-rw-r--r--riscos/options.h60
6 files changed, 143 insertions, 334 deletions
diff --git a/riscos/dialog.c b/riscos/dialog.c
index 19aad8933..6f6cf46d2 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -3,7 +3,7 @@
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
- * Copyright 2003 James Bursa <bursa@users.sourceforge.net>
+ * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
*/
@@ -32,29 +32,24 @@ wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
;
wimp_menu* theme_menu = NULL;
-static struct ro_choices choices;
-static struct browser_choices browser_choices;
-static struct proxy_choices proxy_choices;
-static struct theme_choices theme_choices;
-
static void ro_gui_dialog_click_config(wimp_pointer *pointer);
static void ro_gui_dialog_click_config_br(wimp_pointer *pointer);
static void ro_gui_dialog_click_config_prox(wimp_pointer *pointer);
static void ro_gui_dialog_click_config_th(wimp_pointer *pointer);
-static void set_browser_choices(struct browser_choices* newchoices);
-static void get_browser_choices(struct browser_choices* newchoices);
-static void set_proxy_choices(struct proxy_choices* newchoices);
-static void get_proxy_choices(struct proxy_choices* newchoices);
+static void set_browser_choices(void);
+static void get_browser_choices(void);
+static void set_proxy_choices(void);
+static void get_proxy_choices(void);
+static void set_theme_choices(void);
+static void get_theme_choices(void);
static void load_theme_preview(char* thname);
-static void set_theme_choices(struct theme_choices* newchoices);
-static void get_theme_choices(struct theme_choices* newchoices);
/*static void ro_gui_destroy_theme_menu(void);*/
static void ro_gui_build_theme_menu(void);
static int file_exists(const char* base, const char* dir, const char* leaf, bits ftype);
static void set_icon_state(wimp_w w, wimp_i i, int state);
static int get_icon_state(wimp_w w, wimp_i i);
-static void set_icon_string(wimp_w w, wimp_i i, char* text);
+static void set_icon_string(wimp_w w, wimp_i i, const char *text);
static char* get_icon_string(wimp_w w, wimp_i i);
static void set_icon_string_i(wimp_w w, wimp_i i, int num);
@@ -75,10 +70,9 @@ void ro_gui_dialog_init(void)
dialog_config_prox = ro_gui_dialog_create("config_prox");
dialog_config_th = ro_gui_dialog_create("config_th");
- options_to_ro(&OPTIONS, &choices);
- set_browser_choices(&choices.browser);
- set_proxy_choices(&choices.proxy);
- set_theme_choices(&choices.theme);
+ set_browser_choices();
+ set_proxy_choices();
+ set_theme_choices();
}
@@ -189,8 +183,12 @@ void ro_gui_dialog_click_config(wimp_pointer *pointer)
{
switch (pointer->i) {
case ICON_CONFIG_SAVE:
- ro_to_options(&choices, &OPTIONS);
- options_write(&OPTIONS, NULL);
+ get_browser_choices();
+ get_proxy_choices();
+ get_theme_choices();
+ xosfile_create_dir("<Choices$Write>.WWW", 0);
+ xosfile_create_dir("<Choices$Write>.WWW.NetSurf", 0);
+ options_write("<Choices$Write>.WWW.NetSurf.Choices");
if (pointer->buttons == wimp_CLICK_SELECT) {
ro_gui_dialog_close(dialog_config_br);
ro_gui_dialog_close(dialog_config_prox);
@@ -204,9 +202,10 @@ void ro_gui_dialog_click_config(wimp_pointer *pointer)
ro_gui_dialog_close(dialog_config_prox);
ro_gui_dialog_close(dialog_config_th);
ro_gui_dialog_close(dialog_config);
- } else {
- options_to_ro(&OPTIONS, &choices);
}
+ set_browser_choices();
+ set_proxy_choices();
+ set_theme_choices();
break;
case ICON_CONFIG_BROWSER:
ro_gui_dialog_open(dialog_config_br);
@@ -231,16 +230,13 @@ void ro_gui_dialog_click_config_br(wimp_pointer *pointer)
switch (pointer->i) {
case ICON_CONFIG_BR_OK:
- get_browser_choices(&choices.browser);
- get_browser_choices(&browser_choices);
if (pointer->buttons == wimp_CLICK_SELECT)
ro_gui_dialog_close(dialog_config_br);
break;
case ICON_CONFIG_BR_CANCEL:
if (pointer->buttons == wimp_CLICK_SELECT)
ro_gui_dialog_close(dialog_config_br);
- else
- set_browser_choices(&choices.browser);
+ set_browser_choices();
break;
case ICON_CONFIG_BR_EXPLAIN:
bw = create_browser_window(browser_TITLE | browser_TOOLBAR |
@@ -264,16 +260,13 @@ void ro_gui_dialog_click_config_prox(wimp_pointer *pointer)
{
switch (pointer->i) {
case ICON_CONFIG_PROX_OK:
- get_proxy_choices(&choices.proxy);
- get_proxy_choices(&proxy_choices);
if (pointer->buttons == wimp_CLICK_SELECT)
ro_gui_dialog_close(dialog_config_prox);
break;
case ICON_CONFIG_PROX_CANCEL:
if (pointer->buttons == wimp_CLICK_SELECT)
ro_gui_dialog_close(dialog_config_prox);
- else
- set_proxy_choices(&choices.proxy);
+ set_proxy_choices();
break;
}
}
@@ -289,16 +282,13 @@ void ro_gui_dialog_click_config_th(wimp_pointer *pointer)
switch (pointer->i) {
case ICON_CONFIG_TH_OK:
- get_theme_choices(&choices.theme);
- get_theme_choices(&theme_choices);
if (pointer->buttons == wimp_CLICK_SELECT)
ro_gui_dialog_close(dialog_config_th);
break;
case ICON_CONFIG_TH_CANCEL:
if (pointer->buttons == wimp_CLICK_SELECT)
ro_gui_dialog_close(dialog_config_th);
- else
- set_theme_choices(&choices.theme);
+ set_theme_choices();
break;
case ICON_CONFIG_TH_NAME:
case ICON_CONFIG_TH_PICK:
@@ -333,41 +323,91 @@ void ro_gui_dialog_close(wimp_w close)
}
+/**
+ * Update the browser choices dialog with the current options.
+ */
+
+void set_browser_choices(void)
+{
+ set_icon_state(dialog_config_br, ICON_CONFIG_BR_GESTURES,
+ option_use_mouse_gestures);
+ set_icon_state(dialog_config_br, ICON_CONFIG_BR_TEXT,
+ option_allow_text_selection);
+ set_icon_state(dialog_config_br, ICON_CONFIG_BR_TOOLBAR,
+ option_show_toolbar);
+}
+
+
+/**
+ * Set the current options to the settings in the browser choices dialog.
+ */
+
+void get_browser_choices(void)
+{
+ option_use_mouse_gestures = get_icon_state(dialog_config_br,
+ ICON_CONFIG_BR_GESTURES);
+ option_allow_text_selection = get_icon_state(dialog_config_br,
+ ICON_CONFIG_BR_TEXT);
+ option_show_toolbar = get_icon_state(dialog_config_br,
+ ICON_CONFIG_BR_TOOLBAR);
+}
+
+
+/**
+ * Update the proxy choices dialog with the current options.
+ */
-void set_browser_choices(struct browser_choices* newchoices)
+void set_proxy_choices(void)
{
- memcpy(&browser_choices, newchoices, sizeof(struct browser_choices));
- set_icon_state(dialog_config_br, ICON_CONFIG_BR_GESTURES, browser_choices.use_mouse_gestures);
- set_icon_state(dialog_config_br, ICON_CONFIG_BR_FORM, browser_choices.use_riscos_elements);
- set_icon_state(dialog_config_br, ICON_CONFIG_BR_TEXT, browser_choices.allow_text_selection);
- set_icon_state(dialog_config_br, ICON_CONFIG_BR_TOOLBAR, browser_choices.show_toolbar);
- set_icon_state(dialog_config_br, ICON_CONFIG_BR_PREVIEW, browser_choices.show_print_preview);
+ set_icon_state(dialog_config_prox, ICON_CONFIG_PROX_HTTP,
+ option_http_proxy);
+ set_icon_string(dialog_config_prox, ICON_CONFIG_PROX_HTTPHOST,
+ option_http_proxy_host);
+ set_icon_string_i(dialog_config_prox, ICON_CONFIG_PROX_HTTPPORT,
+ option_http_proxy_port);
}
-void get_browser_choices(struct browser_choices* newchoices)
+
+/**
+ * Set the current options to the settings in the proxy choices dialog.
+ */
+
+void get_proxy_choices(void)
{
- newchoices->use_mouse_gestures = get_icon_state(dialog_config_br, ICON_CONFIG_BR_GESTURES);
- newchoices->use_riscos_elements = get_icon_state(dialog_config_br, ICON_CONFIG_BR_FORM);
- newchoices->allow_text_selection = get_icon_state(dialog_config_br, ICON_CONFIG_BR_TEXT);
- newchoices->show_toolbar = get_icon_state(dialog_config_br, ICON_CONFIG_BR_TOOLBAR);
- newchoices->show_print_preview = get_icon_state(dialog_config_br, ICON_CONFIG_BR_PREVIEW);
+ option_http_proxy = get_icon_state(dialog_config_prox,
+ ICON_CONFIG_PROX_HTTP);
+ free(option_http_proxy_host);
+ option_http_proxy_host = strdup(get_icon_string(dialog_config_prox,
+ ICON_CONFIG_PROX_HTTPHOST));
+ option_http_proxy_port = atoi(get_icon_string(dialog_config_prox,
+ ICON_CONFIG_PROX_HTTPPORT));
}
-void set_proxy_choices(struct proxy_choices* newchoices)
+
+/**
+ * Update the theme choices dialog with the current options.
+ */
+
+void set_theme_choices(void)
{
- memcpy(&proxy_choices, newchoices, sizeof(struct proxy_choices));
- set_icon_state(dialog_config_prox, ICON_CONFIG_PROX_HTTP, proxy_choices.http);
- set_icon_string(dialog_config_prox, ICON_CONFIG_PROX_HTTPHOST, proxy_choices.http_proxy);
- set_icon_string_i(dialog_config_prox, ICON_CONFIG_PROX_HTTPPORT, proxy_choices.http_port);
+ set_icon_string(dialog_config_th, ICON_CONFIG_TH_NAME,
+ option_theme ? option_theme : "Default");
+ load_theme_preview(option_theme ? option_theme : "Default");
}
-void get_proxy_choices(struct proxy_choices* newchoices)
+
+/**
+ * Set the current options to the settings in the theme choices dialog.
+ */
+
+void get_theme_choices(void)
{
- newchoices->http = get_icon_state(dialog_config_prox, ICON_CONFIG_PROX_HTTP);
- strncpy(newchoices->http_proxy, get_icon_string(dialog_config_prox, ICON_CONFIG_PROX_HTTPHOST), 255);
- newchoices->http_port = atoi(get_icon_string(dialog_config_prox, ICON_CONFIG_PROX_HTTPPORT));
+ free(option_theme);
+ option_theme = strdup(get_icon_string(dialog_config_th,
+ ICON_CONFIG_TH_NAME));
}
+
osspriteop_area* theme_preview = NULL;
void load_theme_preview(char* thname)
@@ -469,18 +509,6 @@ void ro_gui_redraw_config_th(wimp_draw* redraw)
}
-void set_theme_choices(struct theme_choices* newchoices)
-{
- memcpy(&theme_choices, newchoices, sizeof(struct theme_choices));
- set_icon_string(dialog_config_th, ICON_CONFIG_TH_NAME, theme_choices.name);
- load_theme_preview(theme_choices.name);
-}
-
-void get_theme_choices(struct theme_choices* newchoices)
-{
- strncpy(newchoices->name, get_icon_string(dialog_config_th, ICON_CONFIG_TH_NAME), 255);
-}
-
/**
* Construct or update theme_menu by scanning THEMES_DIR.
@@ -527,7 +555,7 @@ void ro_gui_build_theme_menu(void)
theme_menu = xrealloc(theme_menu, wimp_SIZEOF_MENU(i + 1));
theme_menu->entries[i].menu_flags = 0;
- if (strcmp(info.name, theme_choices.name) == 0)
+ if (option_theme && strcmp(info.name, option_theme) == 0)
theme_menu->entries[i].menu_flags |= wimp_MENU_TICKED;
theme_menu->entries[i].sub_menu = wimp_NO_SUB_MENU;
theme_menu->entries[i].icon_flags = wimp_ICON_TEXT |
@@ -554,9 +582,8 @@ void ro_gui_build_theme_menu(void)
void ro_gui_theme_menu_selection(char *theme)
{
- strcpy(theme_choices.name, theme);
- set_icon_string(dialog_config_th, ICON_CONFIG_TH_NAME, theme_choices.name);
- load_theme_preview(theme_choices.name);
+ set_icon_string(dialog_config_th, ICON_CONFIG_TH_NAME, theme);
+ load_theme_preview(theme);
wimp_set_icon_state(dialog_config_th, ICON_CONFIG_TH_NAME, 0, 0);
wimp_set_icon_state(dialog_config_th, ICON_CONFIG_TH_PREVIEW, 0, 0);
@@ -598,14 +625,23 @@ int get_icon_state(wimp_w w, wimp_i i)
return (ic.icon.flags & wimp_ICON_SELECTED) != 0;
}
-void set_icon_string(wimp_w w, wimp_i i, char* text)
+
+/**
+ * Set the contents of an icon to a string.
+ *
+ * \param w window handle
+ * \param i icon handle
+ * \param text string (copied)
+ */
+
+void set_icon_string(wimp_w w, wimp_i i, const char *text)
{
wimp_icon_state ic;
ic.w = w;
ic.i = i;
wimp_get_icon_state(&ic);
strncpy(ic.icon.data.indirected_text.text, text,
- (unsigned int)ic.icon.data.indirected_text.size);
+ (unsigned int)ic.icon.data.indirected_text.size);
}
char* get_icon_string(wimp_w w, wimp_i i)
diff --git a/riscos/gui.c b/riscos/gui.c
index 961d2c927..d24c55167 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -3,7 +3,7 @@
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
- * Copyright 2003 James Bursa <bursa@users.sourceforge.net>
+ * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
*/
@@ -33,6 +33,7 @@
#endif
#include "netsurf/riscos/constdata.h"
#include "netsurf/riscos/gui.h"
+#include "netsurf/riscos/options.h"
#ifdef WITH_PLUGIN
#include "netsurf/riscos/plugin.h"
#endif
@@ -140,18 +141,19 @@ void gui_init(int argc, char** argv)
if (getenv("NetSurf$Start_URI_Handler"))
xwimp_start_task("Desktop", 0);
- if (OPTIONS.theme) {
+ options_read("Choices:WWW.NetSurf.Choices");
+
+ if (option_theme) {
snprintf(theme_fname, sizeof(theme_fname),
- "<NetSurf$Dir>.Themes.%s", OPTIONS.theme);
+ "<NetSurf$Dir>.Themes.%s", option_theme);
/* check if theme directory exists */
if (!is_dir(theme_fname)) {
- free(OPTIONS.theme);
- OPTIONS.theme = strdup("Default");
+ free(option_theme);
+ option_theme = 0;
sprintf(theme_fname, "<NetSurf$Dir>.Themes.Default");
}
} else {
- OPTIONS.theme = strdup("Default");
- sprintf(theme_fname, "<NetSurf$Dir>.Themes.Default");
+ strcpy(theme_fname, "<NetSurf$Dir>.Themes.Default");
}
ro_theme_load(theme_fname);
diff --git a/riscos/gui.h b/riscos/gui.h
index dab34561d..96c1e9fc0 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -3,7 +3,7 @@
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
- * Copyright 2003 James Bursa <bursa@users.sourceforge.net>
+ * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
*/
#ifndef _NETSURF_RISCOS_GUI_H_
@@ -184,12 +184,9 @@ void ro_gui_history_click(wimp_pointer *pointer);
#define ICON_CONFIG_BR_OK 0
#define ICON_CONFIG_BR_CANCEL 1
#define ICON_CONFIG_BR_EXPLAIN 2
-#define ICON_CONFIG_BR_DEFAULT 3
-#define ICON_CONFIG_BR_FORM 4
-#define ICON_CONFIG_BR_GESTURES 5
-#define ICON_CONFIG_BR_TEXT 6
-#define ICON_CONFIG_BR_TOOLBAR 7
-#define ICON_CONFIG_BR_PREVIEW 8
+#define ICON_CONFIG_BR_GESTURES 3
+#define ICON_CONFIG_BR_TEXT 4
+#define ICON_CONFIG_BR_TOOLBAR 5
#define ICON_CONFIG_PROX_OK 0
#define ICON_CONFIG_PROX_CANCEL 1
diff --git a/riscos/mouseactions.c b/riscos/mouseactions.c
index 9c7f76ea6..2fa00d946 100644
--- a/riscos/mouseactions.c
+++ b/riscos/mouseactions.c
@@ -11,8 +11,8 @@
#include "netsurf/utils/config.h"
#include "netsurf/desktop/browser.h"
-#include "netsurf/desktop/options.h"
#include "netsurf/riscos/gui.h"
+#include "netsurf/riscos/options.h"
#include "netsurf/utils/log.h"
typedef enum {
@@ -34,7 +34,7 @@ void ro_gui_mouse_action(gui_window *g) {
int x, y;
mouseaction ma = mouseaction_NONE;
- if (OPTIONS.use_mouse_gestures)
+ if (option_use_mouse_gestures)
ma = ro_gui_try_mouse_action();
if (ma == mouseaction_NONE) {
diff --git a/riscos/options.c b/riscos/options.c
deleted file mode 100644
index a1c096777..000000000
--- a/riscos/options.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * This file is part of NetSurf, http://netsurf.sourceforge.net/
- * Licensed under the GNU General Public License,
- * http://www.opensource.org/licenses/gpl-license
- * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
- * Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
- */
-
-#include "netsurf/desktop/options.h"
-#include <stdio.h>
-#include <string.h>
-#include "oslib/messagetrans.h"
-#include "oslib/osfile.h"
-#include "netsurf/utils/log.h"
-#include "netsurf/utils/utils.h"
-
-struct options OPTIONS;
-static char* lookup(messagetrans_control_block* cb, const char* token, const char* deflt);
-static int lookup_yesno(messagetrans_control_block* cb, const char* token, const char* deflt);
-static int lookup_i(messagetrans_control_block* cb, const char* token, const char* deflt);
-static const char* yesno(int q);
-
-char* lookup(messagetrans_control_block* cb, const char* token, const char* deflt)
-{
- int used;
- char buffer[256];
-
- LOG(("Looking up token '%s'",token));
-
- messagetrans_lookup(cb, token, buffer, 256, 0,0,0,0, &used);
- if (used > 0)
- {
- return strdup(buffer);
- }
- else
- return strdup(deflt);
-}
-
-int lookup_yesno(messagetrans_control_block* cb, const char* token, const char* deflt)
-{
- char* find;
- LOG(("yesno token '%s' (default '%s')", token, deflt));
- find = lookup(cb, token, deflt);
- if (strcmp(find, "Y") == 0)
- {
- xfree(find);
- return -1;
- }
- xfree(find);
- return 0;
-}
-
-int lookup_i(messagetrans_control_block* cb, const char* token, const char* deflt)
-{
- char* find = lookup(cb, token, deflt);
- int ret = atoi(find);
- xfree(find);
- return ret;
-}
-
-const char* yesno(int q)
-{
- if (q)
- return "Y";
- else
- return "N";
-}
-
-static const char * const WRITE_DIR = "<Choices$Write>.WWW.NetSurf";
-
-void options_write(struct options* opt, char* filename)
-{
- char* fn;
- FILE* f;
-
- fn = xcalloc(strlen(WRITE_DIR) + (filename == 0 ? 7 : strlen(filename)) + 10,
- sizeof(char));
- sprintf(fn, "%s.%s", WRITE_DIR, filename == 0 ? "Choices" : filename);
-
- xosfile_create_dir("<Choices$Write>.WWW", 0);
- xosfile_create_dir(WRITE_DIR, 0);
-
- LOG(("filename: %s", fn));
-
- f = fopen(fn, "w");
- if (f != NULL)
- {
- fprintf(f, "# General options - for any platform\n# Proxy\n");
- fprintf(f, "USE_HTTP:%s\n", yesno(opt->http));
- fprintf(f, "HTTP_PROXY:%s\n", opt->http_proxy);
- fprintf(f, "HTTP_PORT:%d\n", opt->http_port);
-
- fprintf(f, "\n# RISC OS specific options\n# Browser\n");
- fprintf(f, "RO_MOUSE_GESTURES:%s\n", yesno(opt->use_mouse_gestures));
- fprintf(f, "RO_TEXT_SELECTION:%s\n", yesno(opt->allow_text_selection));
- fprintf(f, "RO_FORM_ELEMENTS:%s\n", yesno(opt->use_riscos_elements));
- fprintf(f, "RO_SHOW_TOOLBAR:%s\n", yesno(opt->show_toolbar));
- fprintf(f, "RO_SHOW_PRINT:%s\n", yesno(opt->show_print_preview));
- fprintf(f, "\n# Theme\n");
- fprintf(f, "RO_THEME:%s\n", opt->theme);
- }
- else
- LOG(("Couldn't open Choices file"));
-
- fclose(f);
- xfree(fn);
-}
-
-void options_init(struct options* opt)
-{
- opt->http = 0;
- opt->http_proxy = strdup("");
- opt->http_port = 8080;
- opt->use_mouse_gestures = 0;
- opt->allow_text_selection = 1;
- opt->use_riscos_elements = 1;
- opt->show_toolbar = 1;
- opt->show_print_preview = 0;
- opt->theme = strdup("Default");
-}
-
-void options_read(struct options* opt, char* filename)
-{
- messagetrans_control_block cb;
- messagetrans_file_flags flags;
- char* data;
- char* fn;
- int size;
-
- fn = xcalloc(20 + (filename == 0 ? 7 : strlen(filename)), sizeof(char));
- sprintf(fn, "Choices:WWW.NetSurf.%s", filename == 0 ? "Choices" : filename);
-
- LOG(("Getting file info"));
- if (xmessagetrans_file_info(fn, &flags, &size) != NULL)
- return;
-
- /* catch empty choices file - this is a kludge but should work */
- if (size <= 10) {
-
- LOG(("Empty Choices file - using defaults"));
- options_init(opt);
- return;
- }
-
- LOG(("Allocating %d bytes", size));
- data = xcalloc((unsigned int)size, sizeof(char));
- messagetrans_open_file(&cb, fn, data);
-
- opt->http = lookup_yesno(&cb, "USE_HTTP", "N");
- xfree(opt->http_proxy);
- opt->http_proxy = lookup(&cb, "HTTP_PROXY", "");
- opt->http_port = lookup_i(&cb, "HTTP_PORT", "8080");
-
- opt->use_mouse_gestures = lookup_yesno(&cb, "RO_MOUSE_GESTURES", "N");
- opt->allow_text_selection = lookup_yesno(&cb, "RO_TEXT_SELECTION", "Y");
- opt->use_riscos_elements = lookup_yesno(&cb, "RO_FORM_ELEMENTS", "Y");
- opt->show_toolbar = lookup_yesno(&cb, "RO_SHOW_TOOLBAR", "Y");
- opt->show_print_preview = lookup_yesno(&cb, "RO_SHOW_PRINT", "N");
-
- xfree(opt->theme);
- opt->theme = lookup(&cb, "RO_THEME", "Default");
- messagetrans_close_file(&cb);
- xfree(data);
- xfree(fn);
-}
-
-void options_to_ro(struct options* opt, struct ro_choices* ro)
-{
- ro->browser.use_mouse_gestures = opt->use_mouse_gestures;
- ro->browser.allow_text_selection = opt->allow_text_selection;
- ro->browser.use_riscos_elements = opt->use_riscos_elements;
- ro->browser.show_toolbar = opt->show_toolbar;
- ro->browser.show_print_preview = opt->show_print_preview;
-
- ro->proxy.http = opt->http;
- if (opt->http_proxy != NULL)
- strcpy(ro->proxy.http_proxy, opt->http_proxy);
- else
- strcpy(ro->proxy.http_proxy, "");
- ro->proxy.http_port = opt->http_port;
-
- if (opt->theme != NULL)
- strcpy(ro->theme.name, opt->theme);
- else
- strcpy(ro->theme.name, "Default");
-}
-
-void ro_to_options(struct ro_choices* ro, struct options* opt)
-{
- opt->use_mouse_gestures = ro->browser.use_mouse_gestures;
- opt->allow_text_selection = ro->browser.allow_text_selection;
- opt->use_riscos_elements = ro->browser.use_riscos_elements;
- opt->show_toolbar = ro->browser.show_toolbar;
- opt->show_print_preview = ro->browser.show_print_preview;
-
- opt->http = ro->proxy.http;
- xfree(opt->http_proxy);
- opt->http_proxy = strdup(ro->proxy.http_proxy);
- opt->http_port = ro->proxy.http_port;
-
- xfree(opt->theme);
- opt->theme = strdup(ro->theme.name);
-}
-
diff --git a/riscos/options.h b/riscos/options.h
index 6615edec5..368e1964c 100644
--- a/riscos/options.h
+++ b/riscos/options.h
@@ -3,6 +3,11 @@
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
+ * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
+ */
+
+/** \file
+ * RISC OS specific options.
*/
#ifndef _NETSURF_RISCOS_OPTIONS_H_
@@ -10,48 +15,21 @@
#include "netsurf/desktop/options.h"
-#define PLATFORM_OPTIONS \
- int use_mouse_gestures;\
- int allow_text_selection;\
- int use_riscos_elements;\
- int show_toolbar;\
- int show_print_preview;\
- \
- char* theme;
-
-/* choices made easier for the dialogue boxes. only used by the interface */
-
-struct browser_choices
-{
- int use_mouse_gestures;
- int allow_text_selection;
- int use_riscos_elements;
- int show_toolbar;
- int show_print_preview;
-} ;
+extern int option_use_mouse_gestures;
+extern int option_allow_text_selection;
+extern int option_show_toolbar;
+extern char *option_theme;
-struct proxy_choices
-{
- int http;
- char http_proxy[256];
- int http_port;
-} ;
+#define EXTRA_OPTION_DEFINE \
+int option_use_mouse_gestures = false;\
+int option_allow_text_selection = true;\
+int option_show_toolbar = true;\
+char *option_theme = 0;
-struct theme_choices
-{
- char name[256];
-};
-
-struct ro_choices
-{
- struct browser_choices browser;
- struct proxy_choices proxy;
- struct theme_choices theme;
-};
-
-void options_to_ro(struct options* opt, struct ro_choices* ro);
-void ro_to_options(struct ro_choices* ro, struct options* opt);
+#define EXTRA_OPTION_TABLE \
+{ "use_mouse_gestures", OPTION_BOOL, &option_use_mouse_gestures },\
+{ "allow_text_selection", OPTION_BOOL, &option_allow_text_selection },\
+{ "show_toolbar", OPTION_BOOL, &option_show_toolbar },\
+{ "theme", OPTION_STRING, &option_theme }
#endif
-
-