From 1490b52a6b96b6a69a0c4fe9e0515dc717425128 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 22 Mar 2012 09:34:34 +0000 Subject: [PATCH] NetSurf options rework (a=vince r=daniels,jmb) svn path=/trunk/netsurf/; revision=13548 --- amiga/arexx.c | 10 +- amiga/bitmap.c | 8 +- amiga/clipboard.c | 10 +- amiga/context_menu.c | 8 +- amiga/download.c | 8 +- amiga/drag.c | 10 +- amiga/dt_sound.c | 2 +- amiga/file.c | 3 +- amiga/font.c | 28 +- amiga/gui.c | 237 ++++++------ amiga/gui_options.c | 421 ++++++++++++---------- amiga/menu.c | 28 +- amiga/options.h | 318 ++++++++-------- amiga/plotters.c | 26 +- amiga/print.c | 19 +- amiga/stringview/urlhistory.c | 2 +- amiga/system_colour.c | 56 +-- amiga/theme.c | 19 +- amiga/thumbnail.c | 10 +- amiga/tree.c | 68 ++-- atari/ctxmenu.c | 13 +- atari/download.c | 7 +- atari/font.c | 1 - atari/global_evnt.c | 15 +- atari/gui.c | 31 +- atari/hotlist.c | 5 +- atari/options.h | 131 +++---- atari/plot.c | 7 +- atari/plot/font_freetype.c | 20 +- atari/plot/plotter.h | 2 +- atari/settings.c | 193 +++++----- atari/system_colour.c | 56 +-- beos/beos_font.cpp | 10 +- beos/beos_gui.cpp | 83 ++--- beos/beos_options.cpp | 227 +----------- beos/beos_plotters.cpp | 16 +- beos/beos_scaffolding.cpp | 35 +- beos/beos_window.cpp | 2 +- beos/options.h | 22 +- beos/system_colour.cpp | 56 +-- cocoa/BrowserViewController.m | 6 +- cocoa/BrowserWindowController.m | 2 +- cocoa/NetSurfAppDelegate.m | 2 +- cocoa/NetsurfApp.m | 24 +- cocoa/PreferencesWindowController.m | 5 +- cocoa/gui.m | 2 +- cocoa/system_colour.m | 56 +-- content/fetch.c | 6 +- content/fetchers/about.c | 4 +- content/fetchers/curl.c | 58 +-- content/urldb.c | 4 +- css/select.c | 11 +- css/utils.c | 4 +- desktop/browser.c | 39 +- desktop/netsurf.c | 6 +- desktop/options.c | 366 +++---------------- desktop/options.h | 176 ++++----- desktop/options_main.h | 400 +++++++++++++++++++++ desktop/print.c | 12 +- desktop/tree.c | 25 +- framebuffer/font_freetype.c | 25 +- framebuffer/gui.c | 51 +-- framebuffer/options.h | 161 ++++----- framebuffer/system_colour.c | 310 ++++++++-------- gtk/completion.c | 3 +- gtk/dialogs/options.c | 537 +++++++++++++++++----------- gtk/dialogs/source.c | 3 +- gtk/download.c | 18 +- gtk/font_pango.c | 10 +- gtk/gui.c | 64 ++-- gtk/hotlist.c | 5 +- gtk/options.h | 113 +++--- gtk/plotters.c | 1 - gtk/print.c | 1 - gtk/scaffolding.c | 83 +++-- gtk/system_colour.c | 56 +-- gtk/tabs.c | 8 +- gtk/theme.c | 6 +- gtk/window.c | 15 +- image/gif.c | 12 +- image/mng.c | 4 +- monkey/main.c | 14 +- monkey/options.h | 110 +++--- monkey/system_colour.c | 56 +-- render/box_construct.c | 13 +- render/font.c | 4 +- render/html.c | 8 +- render/html_interaction.c | 2 +- render/html_redraw.c | 2 +- render/layout.c | 4 +- render/search.c | 1 - render/textplain.c | 2 +- riscos/bitmap.c | 10 +- riscos/buffer.c | 4 +- riscos/configure/con_cache.c | 8 +- riscos/configure/con_connect.c | 82 +++-- riscos/configure/con_content.c | 27 +- riscos/configure/con_fonts.c | 61 ++-- riscos/configure/con_home.c | 18 +- riscos/configure/con_image.c | 25 +- riscos/configure/con_inter.c | 58 +-- riscos/configure/con_language.c | 22 +- riscos/configure/con_memory.c | 17 +- riscos/configure/con_secure.c | 14 +- riscos/configure/con_theme.c | 15 +- riscos/cookies.c | 8 +- riscos/dialog.c | 4 +- riscos/download.c | 8 +- riscos/font.c | 37 +- riscos/global_history.c | 8 +- riscos/gui.c | 139 ++++--- riscos/help.c | 4 +- riscos/history.c | 4 +- riscos/hotlist.c | 19 +- riscos/iconbar.c | 12 +- riscos/image.c | 6 +- riscos/menus.c | 2 +- riscos/options.h | 235 ++++++------ riscos/save.c | 8 +- riscos/system_colour.c | 56 +-- riscos/theme.c | 6 +- riscos/theme_install.c | 7 +- riscos/thumbnail.c | 2 +- riscos/toolbar.c | 2 +- riscos/url_complete.c | 4 +- riscos/window.c | 126 ++++--- windows/font.c | 25 +- windows/gui.c | 28 +- windows/main.c | 12 +- windows/prefs.c | 282 ++++++++------- windows/system_colour.c | 56 +-- 131 files changed, 3367 insertions(+), 3227 deletions(-) create mode 100644 desktop/options_main.h diff --git a/amiga/arexx.c b/amiga/arexx.c index 4809ef1c3..4a24cb428 100755 --- a/amiga/arexx.c +++ b/amiga/arexx.c @@ -21,7 +21,7 @@ #include "amiga/arexx.h" #include "amiga/download.h" #include "amiga/gui.h" -#include "amiga/options.h" +#include "desktop/options.h" #include "amiga/theme.h" #include "desktop/browser.h" @@ -411,13 +411,13 @@ STATIC VOID rx_pubscreen(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__ { cmd->ac_RC = 0; - if(!option_use_pubscreen || option_use_pubscreen[0] == '\0') + if(nsoption_charp(use_pubscreen) == NULL) { strcpy(result,"NetSurf"); } else { - strcpy(result,option_use_pubscreen); + strcpy(result, nsoption_charp(use_pubscreen)); } cmd->ac_Result = result; @@ -457,7 +457,7 @@ STATIC VOID rx_home(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1])) bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]); - if(bw) browser_window_go(bw, option_homepage_url, NULL, true); + if(bw) browser_window_go(bw, nsoption_charp(homepage_url), NULL, true); } STATIC VOID rx_reload(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused))) @@ -520,7 +520,7 @@ STATIC VOID rx_active(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((u int window = 0, tab = 0; struct browser_window *bw = curbw; struct nsObject *node, *nnode; - struct gui_window_2 *gwin; + struct gui_window_2 *gwin = NULL; cmd->ac_RC = 0; diff --git a/amiga/bitmap.c b/amiga/bitmap.c index 173f66349..4e1057eb6 100644 --- a/amiga/bitmap.c +++ b/amiga/bitmap.c @@ -28,7 +28,7 @@ #include #endif #include -#include "amiga/options.h" +#include "desktop/options.h" #include #include #include @@ -378,7 +378,7 @@ struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,s bitmap->width, bitmap->height); } - if(option_cache_bitmaps == 2) + if(nsoption_int(cache_bitmaps) == 2) { bitmap->nativebm = tbm; bitmap->nativebmwidth = bitmap->width; @@ -400,7 +400,7 @@ struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,s uint32 flags = 0; if(bitmap->opaque) flags |= COMPFLAG_IgnoreDestAlpha; - if(option_scale_quality) flags |= COMPFLAG_SrcFilter; + if(nsoption_bool(scale_quality)) flags |= COMPFLAG_SrcFilter; CompositeTags(comptype,tbm,scaledbm, COMPTAG_ScaleX,COMP_FLOAT_TO_FIX(width/bitmap->width), @@ -442,7 +442,7 @@ struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,s tbm = scaledbm; bitmap->nativebm = NULL; - if(option_cache_bitmaps >= 1) + if(nsoption_int(cache_bitmaps) >= 1) { bitmap->nativebm = tbm; bitmap->nativebmwidth = width; diff --git a/amiga/clipboard.c b/amiga/clipboard.c index 2af7d81ac..193b2bcd2 100755 --- a/amiga/clipboard.c +++ b/amiga/clipboard.c @@ -29,7 +29,7 @@ #include "amiga/iff_cset.h" #include "amiga/iff_dr2d.h" #include "amiga/menu.h" -#include "amiga/options.h" +#include "desktop/options.h" #include "amiga/utf8.h" #include @@ -85,7 +85,7 @@ void gui_start_selection(struct gui_window *g) { if(!g) return; if(!g->shared->win) return; - if(option_kiosk_mode == true) return; + if(nsoption_bool(kiosk_mode) == true) return; OnMenu(g->shared->win, AMI_MENU_CLEAR); OnMenu(g->shared->win, AMI_MENU_COPY); @@ -98,7 +98,7 @@ void gui_clear_selection(struct gui_window *g) { if(!g) return; if(!g->shared->win) return; - if(option_kiosk_mode == true) return; + if(nsoption_bool(kiosk_mode) == true) return; OffMenu(g->shared->win, AMI_MENU_CLEAR); OffMenu(g->shared->win, AMI_MENU_CUT); @@ -170,7 +170,7 @@ bool gui_empty_clipboard(void) { if(!(PushChunk(iffh,ID_FTXT,ID_FORM,IFFSIZE_UNKNOWN))) { - if(option_utf8_clipboard || ami_utf8_clipboard) + if(nsoption_bool(utf8_clipboard) || ami_utf8_clipboard) { if(!(PushChunk(iffh,0,ID_CSET,32))) { @@ -219,7 +219,7 @@ bool ami_add_to_clipboard(const char *text, size_t length, bool space) { char *buffer; - if(option_utf8_clipboard || ami_utf8_clipboard) + if(nsoption_bool(utf8_clipboard) || ami_utf8_clipboard) { WriteChunkBytes(iffh,text,length); } diff --git a/amiga/context_menu.c b/amiga/context_menu.c index ec2816035..3d2625ec0 100755 --- a/amiga/context_menu.c +++ b/amiga/context_menu.c @@ -34,7 +34,7 @@ #include "amiga/gui.h" #include "amiga/history_local.h" #include "amiga/iff_dr2d.h" -#include "amiga/options.h" +#include "desktop/options.h" #include "amiga/plugin_hack.h" #include "amiga/theme.h" #include "amiga/tree.h" @@ -555,9 +555,9 @@ BOOL ami_context_menu_mouse_trap(struct gui_window_2 *gwin, BOOL trap) { int top, left, width, height; - if(option_context_menu == false) return FALSE; + if(nsoption_bool(context_menu) == false) return FALSE; - if((option_kiosk_mode == false) && (trap == FALSE)) + if((nsoption_bool(kiosk_mode) == false) && (trap == FALSE)) { if(browser_window_back_available(gwin->bw) && ami_gadget_hit(gwin->objects[GID_BACK], @@ -871,7 +871,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved break; case CMID_NAVHOME: - browser_window_go(gwin->bw, option_homepage_url, NULL, true); + browser_window_go(gwin->bw, nsoption_charp(homepage_url), NULL, true); break; case CMID_NAVBACK: diff --git a/amiga/download.c b/amiga/download.c index 2a5cae8e6..ac261e52b 100644 --- a/amiga/download.c +++ b/amiga/download.c @@ -34,7 +34,7 @@ #include "amiga/download.h" #include "amiga/icon.h" #include "amiga/object.h" -#include "amiga/options.h" +#include "desktop/options.h" #include "amiga/bitmap.h" #include "amiga/iff_dr2d.h" #include "amiga/theme.h" @@ -226,14 +226,14 @@ void ami_download_window_abort(struct gui_download_window *dw) void gui_download_window_done(struct gui_download_window *dw) { - struct dlnode *dln,*dln2; + struct dlnode *dln,*dln2 = NULL; struct browser_window *bw = dw->bw; bool queuedl = false; STRPTR sendcmd = NULL; if(!dw) return; - if(option_download_notify) + if(nsoption_bool(download_notify)) { Notify(ami_appid, APPNOTIFY_Title, messages_get("amiDownloadComplete"), APPNOTIFY_PubScreenName, "FRONT", @@ -366,7 +366,7 @@ BOOL ami_download_check_overwrite(const char *file, struct Window *win, ULONG si int64 oldsize = 0; char *overwritetext; - if(option_ask_overwrite == false) return TRUE; + if(nsoption_bool(ask_overwrite) == false) return TRUE; lock = Lock(file, ACCESS_READ); diff --git a/amiga/drag.c b/amiga/drag.c index 9bc8262c6..e19b27393 100644 --- a/amiga/drag.c +++ b/amiga/drag.c @@ -37,7 +37,7 @@ #include "amiga/drag.h" #include "amiga/file.h" #include "amiga/filetype.h" -#include "amiga/options.h" +#include "desktop/options.h" #include "amiga/theme.h" #include "desktop/selection.h" @@ -55,9 +55,9 @@ BOOL drag_in_progress = FALSE; void gui_drag_save_object(gui_save_type type, hlcache_handle *c, struct gui_window *g) { - const char *filetype; + const char *filetype = NULL; - if(strcmp(option_use_pubscreen,"Workbench")) return; + if(strcmp(nsoption_charp(use_pubscreen), "Workbench")) return; switch(type) { @@ -108,7 +108,7 @@ void ami_drag_save(struct Window *win) ami_drag_icon_close(NULL); ami_autoscroll = FALSE; - if(option_use_pubscreen && (strcmp(option_use_pubscreen,"Workbench") == 0)) + if(nsoption_charp(use_pubscreen) && (strcmp(nsoption_charp(use_pubscreen),"Workbench") == 0)) { which = WhichWorkbenchObject(NULL,scrn->MouseX,scrn->MouseY, WBOBJA_Type,&type, @@ -203,7 +203,7 @@ void ami_drag_icon_show(struct Window *win, const char *type) drag_in_progress = TRUE; - if(option_drag_save_icons == false) + if(nsoption_bool(drag_save_icons) == false) { ami_update_pointer(win, AMI_GUI_POINTER_DRAG); return; diff --git a/amiga/dt_sound.c b/amiga/dt_sound.c index 386ffe220..4b6940210 100644 --- a/amiga/dt_sound.c +++ b/amiga/dt_sound.c @@ -149,7 +149,7 @@ bool amiga_dt_sound_convert(struct content *c) amiga_dt_sound_content *plugin = (amiga_dt_sound_content *) c; union content_msg_data msg_data; - int width, height; + int width = 50, height = 50; char title[100]; const uint8 *data; ULONG size; diff --git a/amiga/file.c b/amiga/file.c index 4bae9734f..126c4e355 100644 --- a/amiga/file.c +++ b/amiga/file.c @@ -22,7 +22,6 @@ #include "amiga/filetype.h" #include "amiga/icon.h" #include "amiga/iff_dr2d.h" -#include "amiga/options.h" #include "amiga/save_pdf.h" #include "amiga/theme.h" @@ -198,7 +197,7 @@ void ami_file_req_init(void) savereq = (struct FileRequester *)AllocAslRequestTags(ASL_FileRequest, ASLFR_DoSaveMode, TRUE, ASLFR_RejectIcons, TRUE, - ASLFR_InitialDrawer, option_download_dir, + ASLFR_InitialDrawer, nsoption_charp(download_dir), TAG_DONE); aslhookfunc.h_Entry = (void *)&ami_file_asl_mime_hook; diff --git a/amiga/font.c b/amiga/font.c index 91b8731e9..54b943de8 100644 --- a/amiga/font.c +++ b/amiga/font.c @@ -22,7 +22,7 @@ #include "amiga/gui.h" #include "amiga/utf8.h" #include "amiga/object.h" -#include "amiga/options.h" +#include "desktop/options.h" #include "css/css.h" #include "css/utils.h" #include "render/font.h" @@ -400,23 +400,23 @@ struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle, BOOL switch(fontfamily) { case PLOT_FONT_FAMILY_SANS_SERIF: - fontname = option_font_sans; + fontname = nsoption_charp(font_sans); break; case PLOT_FONT_FAMILY_SERIF: - fontname = option_font_serif; + fontname = nsoption_charp(font_serif); break; case PLOT_FONT_FAMILY_MONOSPACE: - fontname = option_font_mono; + fontname = nsoption_charp(font_mono); break; case PLOT_FONT_FAMILY_CURSIVE: - fontname = option_font_cursive; + fontname = nsoption_charp(font_cursive); break; case PLOT_FONT_FAMILY_FANTASY: - fontname = option_font_fantasy; + fontname = nsoption_charp(font_fantasy); break; case NSA_UNICODE_FONT: default: - fontname = option_font_unicode; + fontname = nsoption_charp(font_unicode); break; } @@ -779,12 +779,12 @@ void ami_font_setdevicedpi(int id) { DisplayInfoHandle dih; struct DisplayInfo dinfo; - ULONG ydpi = option_amiga_ydpi; - ULONG xdpi = option_amiga_ydpi; + ULONG ydpi = nsoption_int(amiga_ydpi); + ULONG xdpi = nsoption_int(amiga_ydpi); - nscss_screen_dpi = INTTOFIX(option_amiga_ydpi); + nscss_screen_dpi = INTTOFIX(nsoption_int(amiga_ydpi)); - if(id && (option_monitor_aspect_x != 0) && (option_monitor_aspect_y != 0)) + if(id && (nsoption_int(monitor_aspect_x) != 0) && (nsoption_int(monitor_aspect_y) != 0)) { if(dih = FindDisplayInfo(id)) { @@ -794,12 +794,12 @@ void ami_font_setdevicedpi(int id) int xres = dinfo.Resolution.x; int yres = dinfo.Resolution.y; - if((option_monitor_aspect_x != 4) || (option_monitor_aspect_y != 3)) + if((nsoption_int(monitor_aspect_x) != 4) || (nsoption_int(monitor_aspect_y) != 3)) { /* AmigaOS sees 4:3 modes as square in the DisplayInfo database, * so we correct other modes to "4:3 equiv" here. */ - xres = (xres * option_monitor_aspect_x) / 4; - yres = (yres * option_monitor_aspect_y) / 3; + xres = (xres * nsoption_int(monitor_aspect_x)) / 4; + yres = (yres * nsoption_int(monitor_aspect_y)) / 3; } xdpi = (yres * ydpi) / xres; diff --git a/amiga/gui.c b/amiga/gui.c index 1ab70b388..4a91b6960 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -63,7 +63,6 @@ #include "amiga/login.h" #include "amiga/menu.h" #include "amiga/misc.h" -#include "amiga/options.h" #include "amiga/plotters.h" #include "amiga/plugin_hack.h" #include "amiga/print.h" @@ -290,9 +289,9 @@ bool ami_locate_resource(char *fullpath, const char *file) /* Firstly check the user's selected theme. NB: ami_locate_resource() * gets called for Messages before options are loaded */ - if(option_theme) + if(nsoption_charp(theme)) { - strcpy(fullpath, option_theme); + strcpy(fullpath, nsoption_charp(theme)); found = ami_gui_check_resource(fullpath, file); if(found) return true; } @@ -380,96 +379,96 @@ void ami_set_options(void) ** updated to show more items than can fit in one column vertically */ - option_core_select_menu = true; + nsoption_set_bool(core_select_menu, true); #ifndef NS_AMIGA_CAIRO /* Ensure we get some output when Cairo not available */ - option_cairo_renderer = 0; + nsoption_set_int(cairo_renderer, 0); #endif - if((!option_accept_language) || (option_accept_language[0] == '\0') || - (option_accept_lang_locale == true)) + if((!nsoption_charp(accept_language)) || + (nsoption_charp(accept_language)[0] == '\0') || + (nsoption_bool(accept_lang_locale) == true)) { if(tempacceptlangs = ami_locale_langs()) { - option_accept_language = (char *)strdup(tempacceptlangs); + nsoption_set_charp(accept_language, + (char *)strdup(tempacceptlangs)); FreeVec(tempacceptlangs); } } - if((!option_cookie_file) || (option_cookie_file[0] == '\0')) - option_cookie_file = (char *)strdup("PROGDIR:Resources/Cookies"); + nsoption_setnull_charp(cookie_file, + (char *)strdup("PROGDIR:Resources/Cookies")); - if((!option_hotlist_file) || (option_hotlist_file[0] == '\0')) - option_hotlist_file = (char *)strdup("PROGDIR:Resources/Hotlist"); + nsoption_setnull_charp(hotlist_file, + (char *)strdup("PROGDIR:Resources/Hotlist")); - if((!option_url_file) || (option_url_file[0] == '\0')) - option_url_file = (char *)strdup("PROGDIR:Resources/URLs"); + + nsoption_setnull_charp(url_file, + (char *)strdup("PROGDIR:Resources/URLs")); /* - if((!option_cookie_jar) || (option_cookie_jar[0] == '\0')) - option_cookie_jar = (char *)strdup("PROGDIR:Resources/CookieJar"); + nsoption_setnull_charp(cookie_jar, + (char *)strdup("PROGDIR:Resources/CookieJar")); */ /* devs:curl-ca-bundle.crt is the default place for the ca bundle on OS4, * but we can't rely on it existing, so default to our local one in resources */ - if((!option_ca_bundle) || (option_ca_bundle[0] == '\0')) - option_ca_bundle = (char *)strdup("PROGDIR:Resources/ca-bundle"); - if((!option_search_engines_file) || (option_search_engines_file[0] == '\0')) - option_search_engines_file = (char *)strdup("PROGDIR:Resources/SearchEngines"); + nsoption_setnull_charp(ca_bundle, + (char *)strdup("PROGDIR:Resources/ca-bundle")); - search_engines_file_location = option_search_engines_file; + + nsoption_setnull_charp(search_engines_file, + (char *)strdup("PROGDIR:Resources/SearchEngines")); - if((!option_font_sans) || (option_font_sans[0] == '\0')) - option_font_sans = (char *)strdup("DejaVu Sans"); + search_engines_file_location = nsoption_charp(search_engines_file); - if((!option_font_serif) || (option_font_serif[0] == '\0')) - option_font_serif = (char *)strdup("DejaVu Serif"); + /* font defaults */ + nsoption_setnull_charp(font_sans, (char *)strdup("DejaVu Sans")); + nsoption_setnull_charp(font_serif, (char *)strdup("DejaVu Serif")); + nsoption_setnull_charp(font_mono, (char *)strdup("DejaVu Sans Mono")); + nsoption_setnull_charp(font_cursive, (char *)strdup("DejaVu Sans")); + nsoption_setnull_charp(font_fantasy, (char *)strdup("DejaVu Serif")); - if((!option_font_mono) || (option_font_mono[0] == '\0')) - option_font_mono = (char *)strdup("DejaVu Sans Mono"); - - if((!option_font_cursive) || (option_font_cursive[0] == '\0')) - option_font_cursive = (char *)strdup("DejaVu Sans"); - - if((!option_font_fantasy) || (option_font_fantasy[0] == '\0')) - option_font_fantasy = (char *)strdup("DejaVu Serif"); - - if((!option_font_unicode) || (option_font_unicode[0] == '\0')) + if (nsoption_charp(font_unicode) == NULL) { /* Search for some likely candidates */ if(lock=Lock("FONTS:Code2000.font",ACCESS_READ)) { UnLock(lock); - option_font_unicode = (char *)strdup("Code2000"); + nsoption_set_charp(font_unicode, + (char *)strdup("Code2000")); } else if(lock=Lock("FONTS:Bitstream Cyberbit.font",ACCESS_READ)) { UnLock(lock); - option_font_unicode = (char *)strdup("Bitstream Cyberbit"); + nsoption_set_charp(font_unicode, + (char *)strdup("Bitstream Cyberbit")); + } + else { + nsoption_set_charp(font_unicode, + (char *)strdup("DejaVu Sans")); } - else option_font_unicode = (char *)strdup("DejaVu Sans"); } - if((!option_theme) || (option_theme[0] == '\0')) - option_theme = (char *)strdup("PROGDIR:Resources/Themes/Default"); + nsoption_setnull_charp(theme, + (char *)strdup("PROGDIR:Resources/Themes/Default")); tree_set_icon_dir(strdup("ENV:Sys")); - if((!option_arexx_dir) || (option_arexx_dir[0] == '\0')) - option_arexx_dir = (char *)strdup("Rexx"); - if((!option_arexx_startup) || (option_arexx_startup[0] == '\0')) - option_arexx_startup = (char *)strdup("Startup.nsrx"); + nsoption_setnull_charp(arexx_dir, (char *)strdup("Rexx")); - if((!option_arexx_shutdown) || (option_arexx_shutdown[0] == '\0')) - option_arexx_shutdown = (char *)strdup("Shutdown.nsrx"); + nsoption_setnull_charp(arexx_startup, (char *)strdup("Startup.nsrx")); - if(!option_window_width) option_window_width = 800; - if(!option_window_height) option_window_height = 600; + nsoption_setnull_charp(arexx_shutdown, (char *)strdup("Shutdown.nsrx")); + + if(!nsoption_int(window_width)) nsoption_set_int(window_width, 800); + if(!nsoption_int(window_height)) nsoption_set_int(window_height, 600); } void ami_amiupdate(void) @@ -554,8 +553,8 @@ void gui_init(int argc, char** argv) window_list = NewObjList(); - urldb_load(option_url_file); - urldb_load_cookies(option_cookie_file); + urldb_load(nsoption_charp(url_file)); + urldb_load_cookies(nsoption_charp(cookie_file)); save_complete_init(); ami_theme_init(); @@ -568,15 +567,16 @@ void ami_openscreen(void) ULONG id = 0; ULONG compositing; - if(option_screen_compositing == -1) + if (nsoption_int(screen_compositing) == -1) compositing = ~0UL; - else compositing = option_screen_compositing; + else compositing = nsoption_int(screen_compositing); - if(!option_use_pubscreen || option_use_pubscreen[0] == '\0') + if (nsoption_charp(use_pubscreen) == NULL) { - if((option_modeid) && (strncmp(option_modeid,"0x",2) == 0)) + if((nsoption_charp(modeid)) && + (strncmp(nsoption_charp(modeid), "0x", 2) == 0)) { - id = strtoul(option_modeid,NULL,0); + id = strtoul(nsoption_charp(modeid), NULL, 0); } else { @@ -589,10 +589,11 @@ void ami_openscreen(void) ASLSM_MaxDepth,32, TAG_DONE)) { + char *modeid = malloc(20); id = screenmodereq->sm_DisplayID; - option_modeid = malloc(20); - sprintf(option_modeid,"0x%lx",id); - options_write("PROGDIR:Resources/Options"); + sprintf(modeid, "0x%lx", id); + nsoption_set_charp(modeid, modeid); + nsoption_write("PROGDIR:Resources/Options"); } FreeAslRequest(screenmodereq); } @@ -619,14 +620,15 @@ void ami_openscreen(void) } else { - option_use_pubscreen = strdup("Workbench"); + nsoption_set_charp(use_pubscreen, + strdup("Workbench")); } } } - if(option_use_pubscreen && option_use_pubscreen[0] != '\0') + if (nsoption_charp(use_pubscreen) != NULL) { - scrn = LockPubScreen(option_use_pubscreen); + scrn = LockPubScreen(nsoption_charp(use_pubscreen)); if(scrn == NULL) { @@ -668,18 +670,19 @@ static void gui_init2(int argc, char** argv) glob = &browserglob; /**/ - ami_hotlist_initialise(option_hotlist_file); + ami_hotlist_initialise(nsoption_charp(hotlist_file)); ami_cookies_initialise(); ami_global_history_initialise(); sslcert_init(tree_content_icon_name); - search_web_provider_details(option_search_provider); + search_web_provider_details(nsoption_int(search_provider)); if(argc) // argc==0 is started from wb { if(args = ReadArgs(template,rarray,NULL)) { - if(notalreadyrunning && (option_startup_no_window == false)) + if (notalreadyrunning && + (nsoption_bool(startup_no_window) == false)) ami_openscreenfirst(); if(rarray[A_URL]) @@ -708,7 +711,8 @@ static void gui_init2(int argc, char** argv) int first=0,i=0; char fullpath[1024]; - if(notalreadyrunning && (option_startup_no_window == false)) + if (notalreadyrunning && + (nsoption_bool(startup_no_window) == false)) ami_openscreenfirst(); for(i=0,wbarg=WBenchMsg->sm_ArgList;ism_NumArgs;i++,wbarg++) @@ -739,8 +743,7 @@ static void gui_init2(int argc, char** argv) } } - if ((!option_homepage_url) || (option_homepage_url[0] == '\0')) - option_homepage_url = (char *)strdup(NETSURF_HOMEPAGE); + nsoption_setnull_charp(homepage_url, (char *)strdup(NETSURF_HOMEPAGE)); if(!notalreadyrunning) { @@ -753,7 +756,7 @@ static void gui_init2(int argc, char** argv) } else { - sendcmd = ASPrintf("OPEN \"%s\" NEW",option_homepage_url); + sendcmd = ASPrintf("OPEN \"%s\" NEW",nsoption_charp(homepage_url)); } IDoMethod(arexx_obj,AM_EXECUTE,sendcmd,"NETSURF",NULL,NULL,NULL,NULL); IDoMethod(arexx_obj,AM_EXECUTE,"TOFRONT","NETSURF",NULL,NULL,NULL,NULL); @@ -772,7 +775,8 @@ static void gui_init2(int argc, char** argv) { ULONG noicon = TAG_IGNORE; - if(option_hide_docky_icon) noicon = REGAPP_NoIcon; + if (nsoption_bool(hide_docky_icon)) + noicon = REGAPP_NoIcon; ami_appid = RegisterApplication(messages_get("NetSurf"), REGAPP_URLIdentifier, "netsurf-browser.org", @@ -802,8 +806,8 @@ static void gui_init2(int argc, char** argv) if(applibport) applibsig = (1L << applibport->mp_SigBit); } - if(!bw && (option_startup_no_window == false)) - bw = browser_window_create(option_homepage_url, 0, 0, true,false); + if(!bw && (nsoption_bool(startup_no_window) == false)) + bw = browser_window_create(nsoption_charp(homepage_url), 0, 0, true,false); } /** Normal entry point from OS */ @@ -835,14 +839,14 @@ int main(int argc, char** argv) ami_gui_splash_close(splash_window); - strncpy(script, option_arexx_dir, 1024); - AddPart(script, option_arexx_startup, 1024); + strncpy(script, nsoption_charp(arexx_dir), 1024); + AddPart(script, nsoption_charp(arexx_startup), 1024); ami_arexx_execute(script); netsurf_main_loop(); - strncpy(script, option_arexx_dir, 1024); - AddPart(script, option_arexx_shutdown, 1024); + strncpy(script, nsoption_charp(arexx_dir), 1024); + AddPart(script, nsoption_charp(arexx_shutdown), 1024); ami_arexx_execute(script); netsurf_exit(); @@ -1530,7 +1534,7 @@ void ami_handle_msg(void) break; case GID_ADDTAB: - browser_window_create(option_homepage_url, gwin->bw, 0, true, true); + browser_window_create(nsoption_charp(homepage_url), gwin->bw, 0, true, true); break; case GID_URL: @@ -1560,7 +1564,7 @@ void ami_handle_msg(void) break; case GID_HOME: - browser_window_go(gwin->bw,option_homepage_url,NULL,true); + browser_window_go(gwin->bw,nsoption_charp(homepage_url),NULL,true); break; case GID_STOP: @@ -1626,19 +1630,19 @@ void ami_handle_msg(void) switch(nskey) { case 'n': - if((option_kiosk_mode == false)) - browser_window_create(option_homepage_url, NULL, + if ((nsoption_bool(kiosk_mode) == false)) + browser_window_create(nsoption_charp(homepage_url), NULL, 0, true, false); break; case 't': - if((option_kiosk_mode == false)) - browser_window_create(option_homepage_url, + if((nsoption_bool(kiosk_mode) == false)) + browser_window_create(nsoption_charp(homepage_url), gwin->bw, 0, true, true); break; case 'k': - if((option_kiosk_mode == false)) + if((nsoption_bool(kiosk_mode) == false)) browser_window_destroy(gwin->bw); break; @@ -1656,7 +1660,7 @@ void ami_handle_msg(void) break; case 'q': - if((option_kiosk_mode == false)) + if((nsoption_bool(kiosk_mode) == false)) ami_quit_netsurf(); break; @@ -1686,7 +1690,7 @@ void ami_handle_msg(void) break; case 'h': - if((option_kiosk_mode == false)) + if((nsoption_bool(kiosk_mode) == false)) ami_tree_open(hotlist_window, AMI_TREE_HOTLIST); break; @@ -1698,7 +1702,7 @@ void ami_handle_msg(void) break; /* case 'u': // open url - if((option_kiosk_mode == false)) + if((nsoption_bool(kiosk_mode) == false)) ActivateGadget((struct Gadget *)gwin->objects[GID_URL], gwin->win, NULL); break; @@ -1993,7 +1997,7 @@ void ami_handle_applib(void) switch (applibmsg->type) { case APPLIBMT_NewBlankDoc: - bw = browser_window_create(option_homepage_url, 0, 0, true, false); + bw = browser_window_create(nsoption_charp(homepage_url), 0, 0, true, false); break; case APPLIBMT_OpenDoc: @@ -2017,7 +2021,7 @@ void ami_handle_applib(void) } else { - bw = browser_window_create(option_homepage_url, 0, 0, true, false); + bw = browser_window_create(nsoption_charp(homepage_url), 0, 0, true, false); } break; @@ -2194,7 +2198,7 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw) void ami_try_quit(void) { - if(option_close_no_quit == false) + if(nsoption_bool(close_no_quit) == false) { netsurf_quit = true; return; @@ -2259,9 +2263,9 @@ void gui_quit(void) ami_theme_throbber_free(); - urldb_save(option_url_file); - urldb_save_cookies(option_cookie_file); - ami_hotlist_free(option_hotlist_file); + urldb_save(nsoption_charp(url_file)); + urldb_save_cookies(nsoption_charp(cookie_file)); + ami_hotlist_free(nsoption_charp(hotlist_file)); ami_cookies_free(); ami_global_history_free(); sslcert_cleanup(); @@ -2324,7 +2328,7 @@ void ami_update_buttons(struct gui_window_2 *gwin) if(!browser_window_reload_available(gwin->bw)) reload=TRUE; - if(option_kiosk_mode == false) + if(nsoption_bool(kiosk_mode) == false) { if(gwin->tabs <= 1) { @@ -2429,7 +2433,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, struct gui_window *gwin = NULL; bool closegadg=TRUE; struct Node *node; - ULONG curx=option_window_x,cury=option_window_y,curw=option_window_width,curh=option_window_height; + ULONG curx=nsoption_int(window_x),cury=nsoption_int(window_y),curw=nsoption_int(window_width),curh=nsoption_int(window_height); char nav_west[100],nav_west_s[100],nav_west_g[100]; char nav_east[100],nav_east_s[100],nav_east_g[100]; char stop[100],stop_s[100],stop_g[100]; @@ -2439,9 +2443,9 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, char addtab[100],addtab_s[100],addtab_g[100]; char tabthrobber[100]; - if(!scrn) ami_openscreenfirst(); + if (!scrn) ami_openscreenfirst(); - if(option_kiosk_mode) new_tab = false; + if (nsoption_bool(kiosk_mode)) new_tab = false; bw->scale = 1.0; if(clone) @@ -2484,7 +2488,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, TNA_CloseGadget, TRUE, TAG_DONE); - if(option_new_tab_last) + if(nsoption_bool(new_tab_last)) { AddTail(&gwin->shared->tab_list, gwin->tab_node); } @@ -2503,7 +2507,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, CLICKTAB_Labels, &gwin->shared->tab_list, TAG_DONE); - if(option_new_tab_active) + if(nsoption_bool(new_tab_active)) { RefreshSetGadgetAttrs((struct Gadget *)gwin->shared->objects[GID_TABS],gwin->shared->win,NULL, CLICKTAB_Current,gwin->tab, @@ -2516,7 +2520,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, gwin->shared->tabs++; gwin->shared->next_tab++; - if(option_new_tab_active) ami_switch_tab(gwin->shared,false); + if(nsoption_bool(new_tab_active)) ami_switch_tab(gwin->shared,false); ami_update_buttons(gwin->shared); @@ -2537,13 +2541,14 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, gwin->shared->search_ico_hook.h_Entry = (void *)ami_set_search_ico_render_hook; gwin->shared->search_ico_hook.h_Data = gwin->shared; - if(!option_kiosk_mode) + if(!nsoption_bool(kiosk_mode)) { ULONG addtabclosegadget = TAG_IGNORE; ULONG iconifygadget = FALSE; - if(option_use_pubscreen && (locked_screen == TRUE) && - (strcmp(option_use_pubscreen,"Workbench") == 0)) + if (nsoption_charp(use_pubscreen) && + (locked_screen == TRUE) && + (strcmp(nsoption_charp(use_pubscreen), "Workbench") == 0)) iconifygadget = TRUE; ami_create_menu(gwin->shared); @@ -2909,7 +2914,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, ICA_TARGET, ICTARGET_IDCMP, TAG_DONE); - if(option_kiosk_mode == false) + if(nsoption_bool(kiosk_mode) == false) { ULONG sz, size1, size2; @@ -3031,7 +3036,7 @@ ULONG ami_get_border_gadget_balance(struct gui_window_2 *gwin, ULONG *size1, ULO available_width = gwin->win->Width - scrn->WBorLeft - sz; - gad1percent = option_toolbar_status_width / 10000.0; + gad1percent = nsoption_int(toolbar_status_width) / 10000.0; *size1 = (ULONG)(available_width * gad1percent); *size2 = (ULONG)(available_width * (1 - gad1percent)); @@ -3220,8 +3225,8 @@ void ami_do_redraw_tiled(struct gui_window_2 *gwin, { int x, y; struct rect clip; - int tile_x_scale = (int)(option_redraw_tile_size_x / gwin->bw->scale); - int tile_y_scale = (int)(option_redraw_tile_size_y / gwin->bw->scale); + int tile_x_scale = (int)(nsoption_int(redraw_tile_size_x) / gwin->bw->scale); + int tile_y_scale = (int)(nsoption_int(redraw_tile_size_y) / gwin->bw->scale); if(top < 0) { height += top; @@ -3255,13 +3260,13 @@ void ami_do_redraw_tiled(struct gui_window_2 *gwin, for(y = top; y < (top + height); y += tile_y_scale) { clip.y0 = 0; - clip.y1 = option_redraw_tile_size_y; + clip.y1 = nsoption_int(redraw_tile_size_y); if((((y - sy) * gwin->bw->scale) + clip.y1) > bbox->Height) clip.y1 = bbox->Height - ((y - sy) * gwin->bw->scale); for(x = left; x < (left + width); x += tile_x_scale) { clip.x0 = 0; - clip.x1 = option_redraw_tile_size_x; + clip.x1 = nsoption_int(redraw_tile_size_x); if((((x - sx) * gwin->bw->scale) + clip.x1) > bbox->Width) clip.x1 = bbox->Width - ((x - sx) * gwin->bw->scale); @@ -3453,7 +3458,7 @@ void ami_do_redraw(struct gui_window_2 *g) glob = &browserglob; - if(option_direct_render == false) + if(nsoption_bool(direct_render) == false) { ami_do_redraw_tiled(g, hcurrent, vcurrent, width, height, hcurrent, vcurrent, bbox, &ctx); } @@ -3610,7 +3615,7 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy) } g->shared->redraw_required = true; - if(option_faster_scroll == true) g->shared->redraw_scroll = true; + if(nsoption_bool(faster_scroll) == true) g->shared->redraw_scroll = true; else g->shared->redraw_scroll = false; g->scrollx = sx; @@ -3754,7 +3759,7 @@ void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon) struct IBox *bbox; ULONG cur_tab = 0; - if(option_kiosk_mode == true) return; + if(nsoption_bool(kiosk_mode) == true) return; if(!g) return; if(g->tab_node && (g->shared->tabs > 1)) GetAttr(CLICKTAB_Current, @@ -3809,11 +3814,9 @@ void gui_window_set_search_ico(hlcache_handle *ico) struct nsObject *nnode; struct gui_window_2 *gwin; char fname[100]; - struct bitmap *nsbm; - bool free_bm = false; if(IsMinListEmpty(window_list)) return; - if(option_kiosk_mode == true) return; + if(nsoption_bool(kiosk_mode) == true) return; if (ico == NULL) ico = search_web_ico(); if ((ico != NULL) && (content_get_bitmap(ico) != NULL)) @@ -3856,8 +3859,6 @@ void gui_window_set_search_ico(hlcache_handle *ico) } } } while(node = nnode); - - if(bm && free_bm) bitmap_destroy(nsbm); } static uint32 ami_set_search_ico_render_hook(struct Hook *hook, APTR space, @@ -3899,7 +3900,7 @@ void gui_window_place_caret(struct gui_window *g, int x, int y, int height) g->c_y = y; g->c_h = height; - if((option_kiosk_mode == false)) + if((nsoption_bool(kiosk_mode) == false)) OnMenu(g->shared->win, AMI_MENU_PASTE); } @@ -3911,7 +3912,7 @@ void gui_window_remove_caret(struct gui_window *g) if(!g) return; if(g->c_h == 0) return; - if((option_kiosk_mode == false)) + if((nsoption_bool(kiosk_mode) == false)) OffMenu(g->shared->win, AMI_MENU_PASTE); ami_do_redraw_limits(g, g->shared->bw, g->c_x, g->c_y, @@ -3982,7 +3983,7 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg case GID_HSCROLL: case OID_HSCROLL: case OID_VSCROLL: - if(option_faster_scroll == true) gwin->redraw_scroll = true; + if(nsoption_bool(faster_scroll) == true) gwin->redraw_scroll = true; else gwin->redraw_scroll = false; gwin->redraw_required = true; diff --git a/amiga/gui_options.c b/amiga/gui_options.c index 6b0becaaa..b66d48bc8 100755 --- a/amiga/gui_options.c +++ b/amiga/gui_options.c @@ -34,7 +34,7 @@ #include "amiga/gui.h" #include "amiga/gui_options.h" #include "utils/messages.h" -#include "amiga/options.h" +#include "desktop/options.h" #include "amiga/utf8.h" #include "desktop/searchweb.h" @@ -376,7 +376,7 @@ void ami_gui_opts_open(void) BOOL screenmodedisabled = FALSE, screennamedisabled = FALSE; BOOL proxyhostdisabled = TRUE, proxyauthdisabled = TRUE; BOOL disableanims, animspeeddisabled = FALSE, acceptlangdisabled = FALSE; - BOOL scaleselected = option_scale_quality, scaledisabled = FALSE; + BOOL scaleselected = nsoption_bool(scale_quality), scaledisabled = FALSE; BOOL download_notify_disabled = FALSE; char animspeed[10]; struct TextAttr fontsans, fontserif, fontmono, fontcursive, fontfantasy, fontunicode; @@ -388,9 +388,9 @@ void ami_gui_opts_open(void) return; } - if(option_use_pubscreen && option_use_pubscreen[0] != '\0') + if(nsoption_charp(use_pubscreen)) { - if(strcmp(option_use_pubscreen,"Workbench") == 0) + if(strcmp(nsoption_charp(use_pubscreen),"Workbench") == 0) { screenoptsselected = 1; screennamedisabled = TRUE; @@ -408,15 +408,15 @@ void ami_gui_opts_open(void) screennamedisabled = TRUE; } - if((option_modeid) && (strncmp(option_modeid,"0x",2) == 0)) + if((nsoption_charp(modeid)) && (strncmp(nsoption_charp(modeid),"0x",2) == 0)) { - screenmodeid = strtoul(option_modeid,NULL,0); + screenmodeid = strtoul(nsoption_charp(modeid),NULL,0); } - if(option_http_proxy) + if(nsoption_bool(http_proxy)) { - proxytype = option_http_proxy_auth + 1; - switch(option_http_proxy_auth) + proxytype = nsoption_int(http_proxy_auth) + 1; + switch(nsoption_int(http_proxy_auth)) { case OPTION_HTTP_PROXY_AUTH_BASIC: case OPTION_HTTP_PROXY_AUTH_NTLM: @@ -427,9 +427,9 @@ void ami_gui_opts_open(void) } } - sprintf(animspeed,"%.2f",(float)(option_minimum_gif_delay/100.0)); + sprintf(animspeed,"%.2f",(float)(nsoption_int(minimum_gif_delay)/100.0)); - if(option_animate_images) + if(nsoption_bool(animate_images)) { disableanims = FALSE; animspeeddisabled = FALSE; @@ -440,7 +440,7 @@ void ami_gui_opts_open(void) animspeeddisabled = TRUE; } - if(option_accept_lang_locale) + if(nsoption_bool(accept_lang_locale)) acceptlangdisabled = TRUE; else acceptlangdisabled = FALSE; @@ -454,15 +454,15 @@ void ami_gui_opts_open(void) if(ApplicationBase->lib_Version < 53) { download_notify_disabled = TRUE; - option_download_notify = FALSE; + nsoption_set_bool(download_notify, FALSE); } - fontsans.ta_Name = ASPrintf("%s.font",option_font_sans); - fontserif.ta_Name = ASPrintf("%s.font",option_font_serif); - fontmono.ta_Name = ASPrintf("%s.font",option_font_mono); - fontcursive.ta_Name = ASPrintf("%s.font",option_font_cursive); - fontfantasy.ta_Name = ASPrintf("%s.font",option_font_fantasy); - fontunicode.ta_Name = ASPrintf("%s.font",option_font_unicode); + fontsans.ta_Name = ASPrintf("%s.font", nsoption_charp(font_sans)); + fontserif.ta_Name = ASPrintf("%s.font", nsoption_charp(font_serif)); + fontmono.ta_Name = ASPrintf("%s.font", nsoption_charp(font_mono)); + fontcursive.ta_Name = ASPrintf("%s.font", nsoption_charp(font_cursive)); + fontfantasy.ta_Name = ASPrintf("%s.font", nsoption_charp(font_fantasy)); + fontunicode.ta_Name = ASPrintf("%s.font", nsoption_charp(font_unicode)); fontsans.ta_Style = 0; fontserif.ta_Style = 0; @@ -522,7 +522,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_HOMEPAGE] = StringObject, GA_ID, GID_OPTS_HOMEPAGE, GA_RelVerify, TRUE, - STRINGA_TextVal, option_homepage_url, + STRINGA_TextVal, nsoption_charp(homepage_url), STRINGA_BufferPos,0, StringEnd, CHILD_Label, LabelObject, @@ -556,7 +556,7 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_HIDEADS, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_HIDEADS], - GA_Selected, option_block_ads, + GA_Selected, nsoption_bool(block_ads), CheckBoxEnd, LayoutEnd, // content blocking LAYOUT_AddChild,VGroupObject, @@ -567,14 +567,14 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_CONTENTLANG, GA_RelVerify, TRUE, GA_Disabled, acceptlangdisabled, - STRINGA_TextVal, option_accept_language, + STRINGA_TextVal, nsoption_charp(accept_language), STRINGA_BufferPos,0, StringEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_FROMLOCALE] = CheckBoxObject, GA_ID, GID_OPTS_FROMLOCALE, GA_Text, gadlab[GID_OPTS_FROMLOCALE], GA_RelVerify, TRUE, - GA_Selected, option_accept_lang_locale, + GA_Selected, nsoption_bool(accept_lang_locale), ButtonEnd, // CHILD_WeightedWidth, 0, LayoutEnd, // content language @@ -588,7 +588,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_HISTORY] = IntegerObject, GA_ID, GID_OPTS_CACHE_DISC, GA_RelVerify, TRUE, - INTEGER_Number, option_expire_url, + INTEGER_Number, nsoption_int(expire_url), INTEGER_Minimum, 0, INTEGER_Maximum, 366, INTEGER_Arrows, TRUE, @@ -612,13 +612,13 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_REFERRAL, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_REFERRAL], - GA_Selected, option_send_referer, + GA_Selected, nsoption_bool(send_referer), CheckBoxEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_FASTSCROLL] = CheckBoxObject, GA_ID, GID_OPTS_FASTSCROLL, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_FASTSCROLL], - GA_Selected, option_faster_scroll, + GA_Selected, nsoption_bool(faster_scroll), CheckBoxEnd, LayoutEnd, // misc CHILD_WeightedHeight, 0, @@ -655,7 +655,7 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_SCREENNAME, GA_RelVerify, TRUE, GA_Disabled,screennamedisabled, - STRINGA_TextVal, option_use_pubscreen, + STRINGA_TextVal, nsoption_bool(use_pubscreen), STRINGA_BufferPos,0, StringEnd, LayoutEnd, @@ -670,7 +670,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_THEME] = GetFileObject, GA_ID, GID_OPTS_THEME, GA_RelVerify, TRUE, - GETFILE_Drawer, option_theme, + GETFILE_Drawer, nsoption_charp(theme), GETFILE_DrawersOnly, TRUE, GETFILE_ReadOnly, TRUE, GETFILE_FullFileExpand, FALSE, @@ -685,13 +685,13 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_PTRTRUE, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_PTRTRUE], - GA_Selected, option_truecolour_mouse_pointers, + GA_Selected, nsoption_bool(truecolour_mouse_pointers), CheckBoxEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_PTROS] = CheckBoxObject, GA_ID, GID_OPTS_PTROS, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_PTROS], - GA_Selected, option_use_os_pointers, + GA_Selected, nsoption_bool(use_os_pointers), CheckBoxEnd, LayoutEnd, // mouse CHILD_WeightedHeight,0, @@ -725,14 +725,14 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_PROXY_HOST, GA_RelVerify, TRUE, GA_Disabled, proxyhostdisabled, - STRINGA_TextVal, option_http_proxy_host, + STRINGA_TextVal, nsoption_charp(http_proxy_host), STRINGA_BufferPos,0, StringEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_PROXY_PORT] = IntegerObject, GA_ID, GID_OPTS_PROXY_PORT, GA_RelVerify, TRUE, GA_Disabled, proxyhostdisabled, - INTEGER_Number, option_http_proxy_port, + INTEGER_Number, nsoption_charp(http_proxy_port), INTEGER_Minimum, 1, INTEGER_Maximum, 65535, INTEGER_Arrows, FALSE, @@ -750,7 +750,7 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_PROXY_USER, GA_RelVerify, TRUE, GA_Disabled, proxyauthdisabled, - STRINGA_TextVal, option_http_proxy_auth_user, + STRINGA_TextVal, nsoption_charp(http_proxy_auth_user), STRINGA_BufferPos,0, StringEnd, CHILD_Label, LabelObject, @@ -760,7 +760,7 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_PROXY_PASS, GA_RelVerify, TRUE, GA_Disabled, proxyauthdisabled, - STRINGA_TextVal, option_http_proxy_auth_pass, + STRINGA_TextVal, nsoption_charp(http_proxy_auth_pass), STRINGA_BufferPos,0, StringEnd, CHILD_Label, LabelObject, @@ -775,7 +775,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_FETCHMAX] = IntegerObject, GA_ID, GID_OPTS_FETCHMAX, GA_RelVerify, TRUE, - INTEGER_Number, option_max_fetchers, + INTEGER_Number, nsoption_int(max_fetchers), INTEGER_Minimum, 1, INTEGER_Maximum, 99, INTEGER_Arrows, TRUE, @@ -787,7 +787,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_FETCHHOST] = IntegerObject, GA_ID, GID_OPTS_FETCHHOST, GA_RelVerify, TRUE, - INTEGER_Number, option_max_fetchers_per_host, + INTEGER_Number, nsoption_int(max_fetchers_per_host), INTEGER_Minimum, 1, INTEGER_Maximum, 99, INTEGER_Arrows, TRUE, @@ -799,7 +799,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_FETCHCACHE] = IntegerObject, GA_ID, GID_OPTS_FETCHCACHE, GA_RelVerify, TRUE, - INTEGER_Number, option_max_cached_fetch_handles, + INTEGER_Number, nsoption_int(max_cached_fetch_handles), INTEGER_Minimum, 1, INTEGER_Maximum, 99, INTEGER_Arrows, TRUE, @@ -827,7 +827,7 @@ void ami_gui_opts_open(void) GA_RelVerify, TRUE, CHOOSER_PopUp, TRUE, CHOOSER_LabelArray, nativebmopts, - CHOOSER_Selected, option_cache_bitmaps, + CHOOSER_Selected, nsoption_int(cache_bitmaps), ChooserEnd, CHILD_Label, LabelObject, LABEL_Text, gadlab[GID_OPTS_NATIVEBM], @@ -880,7 +880,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_DPI_Y] = IntegerObject, GA_ID, GID_OPTS_DPI_Y, GA_RelVerify, TRUE, - INTEGER_Number, option_amiga_ydpi, + INTEGER_Number, nsoption_int(amiga_ydpi), INTEGER_Minimum, 60, INTEGER_Maximum, 150, INTEGER_Arrows, TRUE, @@ -967,7 +967,7 @@ void ami_gui_opts_open(void) GA_RelVerify, TRUE, CHOOSER_PopUp, TRUE, CHOOSER_LabelArray, fontopts, - CHOOSER_Selected, option_font_default - PLOT_FONT_FAMILY_SANS_SERIF, + CHOOSER_Selected, nsoption_int(font_default) - PLOT_FONT_FAMILY_SANS_SERIF, ChooserEnd, CHILD_Label, LabelObject, LABEL_Text, gadlab[GID_OPTS_FONT_DEFAULT], @@ -983,7 +983,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_FONT_SIZE] = IntegerObject, GA_ID, GID_OPTS_FONT_SIZE, GA_RelVerify, TRUE, - INTEGER_Number, option_font_size / 10, + INTEGER_Number, nsoption_int(font_size) / 10, INTEGER_Minimum, 1, INTEGER_Maximum, 99, INTEGER_Arrows, TRUE, @@ -1001,7 +1001,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_FONT_MINSIZE] = IntegerObject, GA_ID, GID_OPTS_FONT_MINSIZE, GA_RelVerify, TRUE, - INTEGER_Number, option_font_min_size / 10, + INTEGER_Number, nsoption_int(font_min_size) / 10, INTEGER_Minimum, 1, INTEGER_Maximum, 99, INTEGER_Arrows, TRUE, @@ -1033,7 +1033,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_CACHE_MEM] = IntegerObject, GA_ID, GID_OPTS_CACHE_MEM, GA_RelVerify, TRUE, - INTEGER_Number, option_memory_cache_size / 1048576, + INTEGER_Number, nsoption_int(memory_cache_size) / 1048576, INTEGER_Minimum, 0, INTEGER_Maximum, 2048, INTEGER_Arrows, TRUE, @@ -1058,7 +1058,7 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_CACHE_DISC, GA_RelVerify, TRUE, GA_Disabled, TRUE, - INTEGER_Number, option_disc_cache_age, + INTEGER_Number, nsoption_int(disc_cache_age), INTEGER_Minimum, 0, INTEGER_Maximum, 366, INTEGER_Arrows, TRUE, @@ -1091,20 +1091,20 @@ void ami_gui_opts_open(void) GA_RelVerify, TRUE, GA_Disabled, FALSE, GA_Text, gadlab[GID_OPTS_OVERWRITE], - GA_Selected, option_ask_overwrite, + GA_Selected, nsoption_bool(ask_overwrite), CheckBoxEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_NOTIFY] = CheckBoxObject, GA_ID, GID_OPTS_NOTIFY, GA_RelVerify, TRUE, GA_Disabled, download_notify_disabled, GA_Text, gadlab[GID_OPTS_NOTIFY], - GA_Selected, option_download_notify, + GA_Selected, nsoption_bool(download_notify), CheckBoxEnd, LayoutEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_DLDIR] = GetFileObject, GA_ID, GID_OPTS_DLDIR, GA_RelVerify, TRUE, - GETFILE_Drawer, option_download_dir, + GETFILE_Drawer, nsoption_charp(download_dir), GETFILE_DrawersOnly, TRUE, GETFILE_ReadOnly, TRUE, GETFILE_FullFileExpand, FALSE, @@ -1123,19 +1123,19 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_TAB_ACTIVE, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_TAB_ACTIVE], - GA_Selected, !option_new_tab_active, + GA_Selected, !nsoption_bool(new_tab_active), CheckBoxEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_TAB_LAST] = CheckBoxObject, GA_ID, GID_OPTS_TAB_LAST, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_TAB_LAST], - GA_Selected, option_new_tab_last, + GA_Selected, nsoption_bool(new_tab_last), CheckBoxEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_TAB_2] = CheckBoxObject, GA_ID, GID_OPTS_TAB_2, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_TAB_2], - GA_Selected, option_button_2_tab, + GA_Selected, nsoption_bool(button_2_tab), CheckBoxEnd, LayoutEnd, // tabbed browsing @@ -1147,19 +1147,19 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_STARTUP_NO_WIN, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_STARTUP_NO_WIN], - GA_Selected, option_startup_no_window, + GA_Selected, nsoption_bool(startup_no_window), CheckBoxEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_CLOSE_NO_QUIT] = CheckBoxObject, GA_ID, GID_OPTS_CLOSE_NO_QUIT, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_CLOSE_NO_QUIT], - GA_Selected, option_close_no_quit, + GA_Selected, nsoption_bool(close_no_quit), CheckBoxEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_DOCKY] = CheckBoxObject, GA_ID, GID_OPTS_DOCKY, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_DOCKY], - GA_Selected, !option_hide_docky_icon, + GA_Selected, !nsoption_bool(hide_docky_icon), CheckBoxEnd, LayoutEnd, // behaviour CHILD_WeightedHeight, 0, @@ -1175,7 +1175,7 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_CLIPBOARD, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_CLIPBOARD], - GA_Selected, option_utf8_clipboard, + GA_Selected, nsoption_bool(utf8_clipboard), CheckBoxEnd, LayoutEnd, // clipboard CHILD_WeightedHeight, 0, @@ -1188,7 +1188,7 @@ void ami_gui_opts_open(void) GA_RelVerify, TRUE, CHOOSER_PopUp, TRUE, CHOOSER_LabelArray, websearch_list, - CHOOSER_Selected, option_search_provider, + CHOOSER_Selected, nsoption_int(search_provider), CHOOSER_MaxLabels, 40, ChooserEnd, CHILD_Label, LabelObject, @@ -1207,7 +1207,7 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_CMENU_ENABLE, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_CMENU_ENABLE], - GA_Selected, option_context_menu, + GA_Selected, nsoption_bool(context_menu), CheckBoxEnd, LayoutEnd, // context menus CHILD_WeightedHeight, 0, @@ -1230,7 +1230,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_MARGIN_TOP] = IntegerObject, GA_ID, GID_OPTS_MARGIN_TOP, GA_RelVerify, TRUE, - INTEGER_Number, option_margin_top, + INTEGER_Number, nsoption_int(margin_top), INTEGER_Minimum, 0, INTEGER_Maximum, 99, INTEGER_Arrows, TRUE, @@ -1248,7 +1248,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_MARGIN_LEFT] = IntegerObject, GA_ID, GID_OPTS_MARGIN_LEFT, GA_RelVerify, TRUE, - INTEGER_Number, option_margin_left, + INTEGER_Number, nsoption_int(margin_left), INTEGER_Minimum, 0, INTEGER_Maximum, 99, INTEGER_Arrows, TRUE, @@ -1266,7 +1266,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_MARGIN_BOTTOM] = IntegerObject, GA_ID, GID_OPTS_MARGIN_BOTTOM, GA_RelVerify, TRUE, - INTEGER_Number, option_margin_bottom, + INTEGER_Number, nsoption_int(margin_bottom), INTEGER_Minimum, 0, INTEGER_Maximum, 99, INTEGER_Arrows, TRUE, @@ -1284,7 +1284,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_MARGIN_RIGHT] = IntegerObject, GA_ID, GID_OPTS_MARGIN_RIGHT, GA_RelVerify, TRUE, - INTEGER_Number, option_margin_right, + INTEGER_Number, nsoption_int(margin_right), INTEGER_Minimum, 0, INTEGER_Maximum, 99, INTEGER_Arrows, TRUE, @@ -1308,7 +1308,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_EXPORT_SCALE] = IntegerObject, GA_ID, GID_OPTS_EXPORT_SCALE, GA_RelVerify, TRUE, - INTEGER_Number, option_export_scale, + INTEGER_Number, nsoption_int(export_scale), INTEGER_Minimum, 0, INTEGER_Maximum, 100, INTEGER_Arrows, TRUE, @@ -1331,19 +1331,19 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_EXPORT_NOIMAGES, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_EXPORT_NOIMAGES], - GA_Selected, option_suppress_images, + GA_Selected, nsoption_bool(suppress_images), CheckBoxEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_EXPORT_NOBKG] = CheckBoxObject, GA_ID, GID_OPTS_EXPORT_NOBKG, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_EXPORT_NOBKG], - GA_Selected, option_remove_backgrounds, + GA_Selected, nsoption_bool(remove_backgrounds), CheckBoxEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_EXPORT_LOOSEN] = CheckBoxObject, GA_ID, GID_OPTS_EXPORT_LOOSEN, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_EXPORT_LOOSEN], - GA_Selected, option_enable_loosening, + GA_Selected, nsoption_bool(enable_loosening), CheckBoxEnd, LayoutEnd, // appearance CHILD_WeightedHeight, 0, @@ -1355,14 +1355,14 @@ void ami_gui_opts_open(void) GA_ID, GID_OPTS_EXPORT_COMPRESS, GA_RelVerify, TRUE, GA_Text, gadlab[GID_OPTS_EXPORT_COMPRESS], - GA_Selected, option_enable_PDF_compression, + GA_Selected, nsoption_bool(enable_PDF_compression), CheckBoxEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_EXPORT_PASSWORD] = CheckBoxObject, GA_ID, GID_OPTS_EXPORT_PASSWORD, GA_RelVerify, TRUE, GA_Disabled, TRUE, GA_Text, gadlab[GID_OPTS_EXPORT_PASSWORD], - GA_Selected, option_enable_PDF_password, + GA_Selected, nsoption_bool(enable_PDF_password), CheckBoxEnd, LayoutEnd, // export CHILD_WeightedHeight, 0, @@ -1406,244 +1406,303 @@ void ami_gui_opts_use(void) char *dot; GetAttr(STRINGA_TextVal,gow->objects[GID_OPTS_HOMEPAGE],(ULONG *)&data); - if(option_homepage_url) free(option_homepage_url); - option_homepage_url = (char *)strdup((char *)data); + nsoption_set_charp(homepage_url, (char *)strdup((char *)data)); GetAttr(STRINGA_TextVal,gow->objects[GID_OPTS_CONTENTLANG],(ULONG *)&data); - if(option_accept_language) free(option_accept_language); - option_accept_language = (char *)strdup((char *)data); + nsoption_set_charp(accept_language, (char *)strdup((char *)data)); GetAttr(GA_Selected, gow->objects[GID_OPTS_FROMLOCALE],(ULONG *)&data); - if(data) option_accept_lang_locale = true; - else option_accept_lang_locale = false; + if (data) { + nsoption_set_bool(accept_lang_locale, true); + } else { + nsoption_set_bool(accept_lang_locale, false); + } GetAttr(GA_Selected,gow->objects[GID_OPTS_HIDEADS],(ULONG *)&data); - if(data) option_block_ads = true; - else option_block_ads = false; + if (data) { + nsoption_set_bool(block_ads, true); + } else { + nsoption_set_bool(block_ads, false); + } - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_HISTORY],(ULONG *)&option_expire_url); + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_HISTORY],(ULONG *)&nsoption_int(expire_url)); GetAttr(GA_Selected,gow->objects[GID_OPTS_REFERRAL],(ULONG *)&data); - if(data) option_send_referer = true; - else option_send_referer = false; + if (data) { + nsoption_set_bool(send_referer, true); + } else { + nsoption_set_bool(send_referer, false); + } GetAttr(GA_Selected,gow->objects[GID_OPTS_FASTSCROLL],(ULONG *)&data); - if(data) option_faster_scroll = true; - else option_faster_scroll = false; + if (data) { + nsoption_set_bool(faster_scroll, true); + } else { + nsoption_set_bool(faster_scroll, false); + } GetAttr(RADIOBUTTON_Selected,gow->objects[GID_OPTS_SCREEN],(ULONG *)&data); switch(data) { case 0: - if(option_use_pubscreen) free(option_use_pubscreen); - option_use_pubscreen = NULL; - break; + nsoption_set_charp(use_pubscreen, NULL); + break; case 1: - if(option_use_pubscreen) free(option_use_pubscreen); - option_use_pubscreen = (char *)strdup("Workbench"); - break; + nsoption_set_charp(use_pubscreen, (char *)strdup("Workbench")); + break; case 2: GetAttr(STRINGA_TextVal,gow->objects[GID_OPTS_SCREENNAME],(ULONG *)&data); - if(option_use_pubscreen) free(option_use_pubscreen); - option_use_pubscreen = (char *)strdup((char *)data); - break; + nsoption_set_charp(use_pubscreen, (char *)strdup((char *)data)); + break; } GetAttr(GETSCREENMODE_DisplayID, gow->objects[GID_OPTS_SCREENMODE], (ULONG *)&id); if(id) { - if(option_modeid) free(option_modeid); - option_modeid = malloc(20); - sprintf(option_modeid,"0x%lx", id); + char *modeid = malloc(20); + sprintf(modeid,"0x%lx", id); + nsoption_set_charp(modeid, modeid); } GetAttr(GETFILE_Drawer,gow->objects[GID_OPTS_THEME],(ULONG *)&data); - if(option_theme) free(option_theme); - option_theme = (char *)strdup((char *)data); + nsoption_set_charp(theme, (char *)strdup((char *)data)); GetAttr(GA_Selected,gow->objects[GID_OPTS_PTRTRUE],(ULONG *)&data); - if(data) option_truecolour_mouse_pointers = true; - else option_truecolour_mouse_pointers = false; + if (data) { + nsoption_set_bool(truecolour_mouse_pointers, true); + } else { + nsoption_set_bool(truecolour_mouse_pointers, false); + } GetAttr(GA_Selected,gow->objects[GID_OPTS_PTROS],(ULONG *)&data); - if(data) option_use_os_pointers = true; - else option_use_os_pointers = false; + if (data) { + nsoption_set_bool(use_os_pointers, true); + } else { + nsoption_set_bool(use_os_pointers, false); + } GetAttr(CHOOSER_Selected,gow->objects[GID_OPTS_PROXY],(ULONG *)&data); if(data) { - option_http_proxy = true; - option_http_proxy_auth = data - 1; + nsoption_set_bool(http_proxy, true); + nsoption_set_int(http_proxy_auth, data - 1); } else { - option_http_proxy = false; + nsoption_set_bool(http_proxy, false); } GetAttr(STRINGA_TextVal,gow->objects[GID_OPTS_PROXY_HOST],(ULONG *)&data); - if(option_http_proxy_host) free(option_http_proxy_host); - option_http_proxy_host = (char *)strdup((char *)data); + nsoption_set_charp(http_proxy_host, (char *)strdup((char *)data)); - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_PROXY_PORT],(ULONG *)&option_http_proxy_port); + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_PROXY_PORT],(ULONG *)&nsoption_int(http_proxy_port)); GetAttr(STRINGA_TextVal,gow->objects[GID_OPTS_PROXY_USER],(ULONG *)&data); - if(option_http_proxy_auth_user) free(option_http_proxy_auth_user); - option_http_proxy_auth_user = (char *)strdup((char *)data); + nsoption_set_charp(http_proxy_auth_user, (char *)strdup((char *)data)); GetAttr(STRINGA_TextVal,gow->objects[GID_OPTS_PROXY_PASS],(ULONG *)&data); - if(option_http_proxy_auth_pass) free(option_http_proxy_auth_pass); - option_http_proxy_auth_pass = (char *)strdup((char *)data); + nsoption_set_charp(http_proxy_auth_pass, (char *)strdup((char *)data)); - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_FETCHMAX],(ULONG *)&option_max_fetchers); - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_FETCHHOST],(ULONG *)&option_max_fetchers_per_host); - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_FETCHCACHE],(ULONG *)&option_max_cached_fetch_handles); + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_FETCHMAX],(ULONG *)&nsoption_int(max_fetchers)); + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_FETCHHOST],(ULONG *)&nsoption_int(max_fetchers_per_host)); + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_FETCHCACHE],(ULONG *)&nsoption_int(max_cached_fetch_handles)); - GetAttr(CHOOSER_Selected,gow->objects[GID_OPTS_NATIVEBM],(ULONG *)&option_cache_bitmaps); + GetAttr(CHOOSER_Selected,gow->objects[GID_OPTS_NATIVEBM],(ULONG *)&nsoption_int(cache_bitmaps)); GetAttr(GA_Selected,gow->objects[GID_OPTS_SCALEQ],(ULONG *)&data); - if(data) option_scale_quality = true; - else option_scale_quality = false; + if (data) { + nsoption_set_bool(scale_quality, true); + } else { + nsoption_set_bool(scale_quality, false); + } GetAttr(STRINGA_TextVal,gow->objects[GID_OPTS_ANIMSPEED],(ULONG *)&data); - animspeed = strtof((char *)data,NULL); - option_minimum_gif_delay = (int)(animspeed * 100); + animspeed = strtof((char *)data, NULL); + nsoption_set_int(minimum_gif_delay, (int)(animspeed * 100)); GetAttr(GA_Selected,gow->objects[GID_OPTS_ANIMDISABLE],(ULONG *)&data); - if(data) option_animate_images = false; - else option_animate_images = true; + if(data) { + nsoption_set_bool(animate_images, false); + } else { + nsoption_set_bool(animate_images, true); + } - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_DPI_Y],(ULONG *)&option_amiga_ydpi); + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_DPI_Y],(ULONG *)&nsoption_int(amiga_ydpi)); ami_font_setdevicedpi(id); // id set above GetAttr(GETFONT_TextAttr,gow->objects[GID_OPTS_FONT_SANS],(ULONG *)&data); tattr = (struct TextAttr *)data; - if(option_font_sans) free(option_font_sans); + if(dot = strrchr(tattr->ta_Name,'.')) *dot = '\0'; - option_font_sans = (char *)strdup((char *)tattr->ta_Name); + nsoption_set_charp(font_sans, (char *)strdup((char *)tattr->ta_Name)); GetAttr(GETFONT_TextAttr,gow->objects[GID_OPTS_FONT_SERIF],(ULONG *)&data); tattr = (struct TextAttr *)data; - if(option_font_serif) free(option_font_serif); + if(dot = strrchr(tattr->ta_Name,'.')) *dot = '\0'; - option_font_serif = (char *)strdup((char *)tattr->ta_Name); + nsoption_set_charp(font_serif, (char *)strdup((char *)tattr->ta_Name)); GetAttr(GETFONT_TextAttr,gow->objects[GID_OPTS_FONT_MONO],(ULONG *)&data); tattr = (struct TextAttr *)data; - if(option_font_mono) free(option_font_mono); + if(dot = strrchr(tattr->ta_Name,'.')) *dot = '\0'; - option_font_mono = (char *)strdup((char *)tattr->ta_Name); + nsoption_set_charp(font_mono, (char *)strdup((char *)tattr->ta_Name)); GetAttr(GETFONT_TextAttr,gow->objects[GID_OPTS_FONT_CURSIVE],(ULONG *)&data); tattr = (struct TextAttr *)data; - if(option_font_cursive) free(option_font_cursive); + if(dot = strrchr(tattr->ta_Name,'.')) *dot = '\0'; - option_font_cursive = (char *)strdup((char *)tattr->ta_Name); + nsoption_set_charp(font_cursive, (char *)strdup((char *)tattr->ta_Name)); GetAttr(GETFONT_TextAttr,gow->objects[GID_OPTS_FONT_FANTASY],(ULONG *)&data); tattr = (struct TextAttr *)data; - if(option_font_fantasy) free(option_font_fantasy); + if(dot = strrchr(tattr->ta_Name,'.')) *dot = '\0'; - option_font_fantasy = (char *)strdup((char *)tattr->ta_Name); + nsoption_set_charp(font_fantasy, (char *)strdup((char *)tattr->ta_Name)); GetAttr(GETFONT_TextAttr,gow->objects[GID_OPTS_FONT_UNICODE],(ULONG *)&data); tattr = (struct TextAttr *)data; - if(option_font_unicode) free(option_font_unicode); + if(dot = strrchr(tattr->ta_Name,'.')) *dot = '\0'; - option_font_unicode = (char *)strdup((char *)tattr->ta_Name); + nsoption_set_charp(font_unicode, (char *)strdup((char *)tattr->ta_Name)); - GetAttr(CHOOSER_Selected,gow->objects[GID_OPTS_FONT_DEFAULT],(ULONG *)&option_font_default); - option_font_default += PLOT_FONT_FAMILY_SANS_SERIF; + GetAttr(CHOOSER_Selected,gow->objects[GID_OPTS_FONT_DEFAULT],(ULONG *)&nsoption_int(font_default)); + nsoption_set_int(font_default, nsoption_int(font_default) + PLOT_FONT_FAMILY_SANS_SERIF); - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_FONT_SIZE],(ULONG *)&option_font_size); - option_font_size *= 10; + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_FONT_SIZE],(ULONG *)&nsoption_int(font_size)); + nsoption_set_int(font_size, nsoption_int(font_size) * 10); - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_FONT_MINSIZE],(ULONG *)&option_font_min_size); - option_font_min_size *= 10; + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_FONT_MINSIZE],(ULONG *)&nsoption_int(font_min_size)); + nsoption_set_int(font_min_size, nsoption_int(font_min_size) * 10); - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_MEM],(ULONG *)&option_memory_cache_size); - option_memory_cache_size *= 1048576; + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_MEM],(ULONG *)&nsoption_int(memory_cache_size)); + nsoption_set_int(memory_cache_size, nsoption_int(memory_cache_size) * 1048576); - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_DISC],(ULONG *)&option_disc_cache_age); + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_DISC],(ULONG *)&nsoption_int(disc_cache_age)); GetAttr(GA_Selected,gow->objects[GID_OPTS_OVERWRITE],(ULONG *)&data); - if(data) option_ask_overwrite = true; - else option_ask_overwrite = false; + if (data) { + nsoption_set_bool(ask_overwrite, true); + } else { + nsoption_set_bool(ask_overwrite, false); + } GetAttr(GA_Selected,gow->objects[GID_OPTS_NOTIFY],(ULONG *)&data); - if(data) option_download_notify = true; - else option_download_notify = false; + if (data) { + nsoption_set_bool(download_notify, true); + } else { + nsoption_set_bool(download_notify, false); + } GetAttr(GETFILE_Drawer,gow->objects[GID_OPTS_DLDIR],(ULONG *)&data); - if(option_download_dir) free(option_download_dir); - option_download_dir = (char *)strdup((char *)data); + nsoption_set_charp(download_dir, (char *)strdup((char *)data)); GetAttr(GA_Selected,gow->objects[GID_OPTS_TAB_ACTIVE],(ULONG *)&data); - if(data) option_new_tab_active = false; - else option_new_tab_active = true; + if (data) { + nsoption_set_bool(new_tab_active, false); + } else { + nsoption_set_bool(new_tab_active, true); + } GetAttr(GA_Selected,gow->objects[GID_OPTS_TAB_LAST],(ULONG *)&data); - if(data) option_new_tab_last = true; - else option_new_tab_last = false; + if (data) { + nsoption_set_bool(new_tab_last, true); + } else { + nsoption_set_bool(new_tab_last, false); + } GetAttr(GA_Selected,gow->objects[GID_OPTS_TAB_2],(ULONG *)&data); - if(data) option_button_2_tab = true; - else option_button_2_tab = false; + if (data) { + nsoption_set_bool(button_2_tab, true); + } else { + nsoption_set_bool(button_2_tab, false); + } - GetAttr(CHOOSER_Selected,gow->objects[GID_OPTS_SEARCH_PROV],(ULONG *)&option_search_provider); - search_web_provider_details(option_search_provider); + GetAttr(CHOOSER_Selected,gow->objects[GID_OPTS_SEARCH_PROV],(ULONG *)&nsoption_int(search_provider)); + search_web_provider_details(nsoption_int(search_provider)); search_web_retrieve_ico(false); GetAttr(GA_Selected,gow->objects[GID_OPTS_CLIPBOARD],(ULONG *)&data); - if(data) option_utf8_clipboard = true; - else option_utf8_clipboard = false; + if (data) { + nsoption_set_bool(utf8_clipboard, true); + } else { + nsoption_set_bool(utf8_clipboard, false); + } GetAttr(GA_Selected,gow->objects[GID_OPTS_CMENU_ENABLE],(ULONG *)&data); - if(data) option_context_menu = true; - else option_context_menu = false; + if (data) { + nsoption_set_bool(context_menu, true); + } else { + nsoption_set_bool(context_menu, false); + } GetAttr(GA_Selected,gow->objects[GID_OPTS_STARTUP_NO_WIN],(ULONG *)&data); - if(data) option_startup_no_window = true; - else option_startup_no_window = false; + if (data) { + nsoption_set_bool(startup_no_window, true); + } else { + nsoption_set_bool(startup_no_window, false); + } GetAttr(GA_Selected,gow->objects[GID_OPTS_CLOSE_NO_QUIT],(ULONG *)&data); - if(data) option_close_no_quit = true; - else option_close_no_quit = false; + if (data) { + nsoption_set_bool(close_no_quit, true); + } else { + nsoption_set_bool(close_no_quit, false); + } GetAttr(GA_Selected,gow->objects[GID_OPTS_DOCKY],(ULONG *)&data); - if(data) option_hide_docky_icon = false; - else option_hide_docky_icon = true; + if (data) { + nsoption_set_bool(hide_docky_icon, false); + } else { + nsoption_set_bool(hide_docky_icon, true); + } - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_MARGIN_TOP],(ULONG *)&option_margin_top); + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_MARGIN_TOP],(ULONG *)&nsoption_int(margin_top)); - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_MARGIN_LEFT],(ULONG *)&option_margin_left); + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_MARGIN_LEFT],(ULONG *)&nsoption_int(margin_left)); - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_MARGIN_BOTTOM],(ULONG *)&option_margin_bottom); + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_MARGIN_BOTTOM],(ULONG *)&nsoption_int(margin_bottom)); - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_MARGIN_RIGHT],(ULONG *)&option_margin_right); + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_MARGIN_RIGHT],(ULONG *)&nsoption_int(margin_right)); - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_EXPORT_SCALE],(ULONG *)&option_export_scale); + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_EXPORT_SCALE],(ULONG *)&nsoption_int(export_scale)); GetAttr(GA_Selected,gow->objects[GID_OPTS_EXPORT_NOIMAGES],(ULONG *)&data); - if(data) option_suppress_images = true; - else option_suppress_images = false; + if (data) { + nsoption_set_bool(suppress_images, true); + } else { + nsoption_set_bool(suppress_images, false); + } GetAttr(GA_Selected,gow->objects[GID_OPTS_EXPORT_NOBKG],(ULONG *)&data); - if(data) option_remove_backgrounds = true; - else option_remove_backgrounds = false; + if (data) { + nsoption_set_bool(remove_backgrounds, true); + } else { + nsoption_set_bool(remove_backgrounds, false); + } GetAttr(GA_Selected,gow->objects[GID_OPTS_EXPORT_LOOSEN],(ULONG *)&data); - if(data) option_enable_loosening = true; - else option_enable_loosening = false; + if (data) { + nsoption_set_bool(enable_loosening, true); + } else { + nsoption_set_bool(enable_loosening, false); + } GetAttr(GA_Selected,gow->objects[GID_OPTS_EXPORT_COMPRESS],(ULONG *)&data); - if(data) option_enable_PDF_compression = true; - else option_enable_PDF_compression = false; + if (data) { + nsoption_set_bool(enable_PDF_compression, true); + } else { + nsoption_set_bool(enable_PDF_compression, false); + } GetAttr(GA_Selected,gow->objects[GID_OPTS_EXPORT_PASSWORD],(ULONG *)&data); - if(data) option_enable_PDF_password = true; - else option_enable_PDF_password = false; + if (data) { + nsoption_set_bool(enable_PDF_password, true); + } else { + nsoption_set_bool(enable_PDF_password, false); + } } void ami_gui_opts_close(void) @@ -1675,7 +1734,7 @@ BOOL ami_gui_opts_event(void) { case GID_OPTS_SAVE: ami_gui_opts_use(); - options_write("PROGDIR:Resources/Options"); + nsoption_write("PROGDIR:Resources/Options"); ami_gui_opts_close(); return TRUE; break; @@ -1852,9 +1911,9 @@ STRPTR *ami_gui_opts_websearch(void) websearchlist = AllocVec(200, MEMF_CLEAR); - if (option_search_engines_file == NULL) return websearchlist; + if (nsoption_charp(search_engines_file) == NULL) return websearchlist; - FILE *f = fopen(option_search_engines_file, "r"); + FILE *f = fopen(nsoption_charp(search_engines_file), "r"); if (f == NULL) return websearchlist; while (fgets(buf, sizeof(buf), f) != NULL) { diff --git a/amiga/menu.c b/amiga/menu.c index 92f366c95..60858823e 100755 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -50,7 +50,7 @@ #include "amiga/history_local.h" #include "amiga/hotlist.h" #include "amiga/menu.h" -#include "amiga/options.h" +#include "desktop/options.h" #include "amiga/print.h" #include "amiga/search.h" #include "amiga/theme.h" @@ -300,8 +300,8 @@ struct NewMenu *ami_create_menu(struct gui_window_2 *gwin) ami_menu_arexx_scan(gwin); /* Set up scheduler to refresh the hotlist menu */ - if(option_menu_refresh > 0) - schedule(option_menu_refresh, (void *)ami_menu_refresh, gwin); + if(nsoption_int(menu_refresh) > 0) + schedule(nsoption_int(menu_refresh), (void *)ami_menu_refresh, gwin); return(gwin->menu); } @@ -316,7 +316,7 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin) LONG cont; struct ExAllData *ead; - if(lock = Lock(option_arexx_dir,SHARED_LOCK)) + if(lock = Lock(nsoption_charp(arexx_dir), SHARED_LOCK)) { if(buffer = AllocVec(1024,MEMF_PRIVATE | MEMF_CLEAR)) { @@ -457,11 +457,11 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item) switch(itemnum) { case 0: // new window - bw = browser_window_create(option_homepage_url, NULL, 0, true, false); + bw = browser_window_create(nsoption_charp(homepage_url), NULL, 0, true, false); break; case 1: // new tab - bw = browser_window_create(option_homepage_url, gwin->bw, 0, true, true); + bw = browser_window_create(nsoption_charp(homepage_url), gwin->bw, 0, true, true); break; case 3: // open local file @@ -680,14 +680,14 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item) break; case 2: // snapshot - option_window_x = gwin->win->LeftEdge; - option_window_y = gwin->win->TopEdge; - option_window_width = gwin->win->Width; - option_window_height = gwin->win->Height; + nsoption_set_int(window_x, gwin->win->LeftEdge); + nsoption_set_int(window_y, gwin->win->TopEdge); + nsoption_set_int(window_width, gwin->win->Width); + nsoption_set_int(window_height, gwin->win->Height); break; case 3: // save settings - options_write("PROGDIR:Resources/Options"); + nsoption_write("PROGDIR:Resources/Options"); break; } break; @@ -700,7 +700,7 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item) ASLFR_TitleText,messages_get("NetSurf"), ASLFR_Screen,scrn, ASLFR_DoSaveMode,FALSE, - ASLFR_InitialDrawer,option_arexx_dir, + ASLFR_InitialDrawer,nsoption_charp(arexx_dir), ASLFR_InitialPattern,"#?.nsrx", TAG_DONE)) { @@ -719,7 +719,7 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item) { if(temp = AllocVec(1024,MEMF_PRIVATE | MEMF_CLEAR)) { - strcpy(temp,option_arexx_dir); + strcpy(temp,nsoption_charp(arexx_dir)); AddPart(temp,GTMENUITEM_USERDATA(item),1024); ami_arexx_execute(temp); FreeVec(temp); @@ -735,7 +735,7 @@ void ami_menu_update_disabled(struct gui_window *g, hlcache_handle *c) { struct Window *win = g->shared->win; - if(option_kiosk_mode == true) return; + if(nsoption_bool(kiosk_mode) == true) return; OffMenu(win,AMI_MENU_CUT); OffMenu(win,AMI_MENU_COPY); diff --git a/amiga/options.h b/amiga/options.h index fe0487560..1c260c59e 100644 --- a/amiga/options.h +++ b/amiga/options.h @@ -16,165 +16,171 @@ * along with this program. If not, see . */ +#ifndef _NETSURF_DESKTOP_OPTIONS_INCLUDING_ +#error "Frontend options header cannot be included directly" +#endif + #ifndef AMIGA_OPTIONS_H #define AMIGA_OPTIONS_H -#include "desktop/options.h" -extern char *option_url_file; -extern char *option_hotlist_file; -extern char *option_use_pubscreen; -extern char *option_modeid; -extern int option_screen_compositing; -extern int option_cache_bitmaps; -extern char *option_theme; -extern bool option_utf8_clipboard; -extern bool option_context_menu; -extern bool option_truecolour_mouse_pointers; -extern bool option_use_os_pointers; -extern bool option_new_tab_active; -extern bool option_new_tab_last; -extern bool option_kiosk_mode; -extern char *option_search_engines_file; -extern char *option_arexx_dir; -extern char *option_arexx_startup; -extern char *option_arexx_shutdown; -extern char *option_download_dir; -extern bool option_download_notify; -extern bool option_faster_scroll; -extern bool option_scale_quality; -extern bool option_ask_overwrite; -extern int option_printer_unit; -extern int option_print_scale; -extern bool option_startup_no_window; -extern bool option_close_no_quit; -extern bool option_hide_docky_icon; -extern char *option_font_unicode; -extern bool option_drag_save_icons; -extern int option_hotlist_window_xpos; -extern int option_hotlist_window_ypos; -extern int option_hotlist_window_xsize; -extern int option_hotlist_window_ysize; -extern int option_history_window_xpos; -extern int option_history_window_ypos; -extern int option_history_window_xsize; -extern int option_history_window_ysize; -extern int option_cookies_window_xpos; -extern int option_cookies_window_ypos; -extern int option_cookies_window_xsize; -extern int option_cookies_window_ysize; -extern int option_cairo_renderer; -extern bool option_direct_render; -extern int option_amiga_ydpi; -extern int option_redraw_tile_size_x; -extern int option_redraw_tile_size_y; -extern int option_monitor_aspect_x; -extern int option_monitor_aspect_y; -extern bool option_accept_lang_locale; -extern int option_menu_refresh; +#define NSOPTION_EXTRA_DEFINE \ + char *url_file; \ + char *hotlist_file; \ + char *use_pubscreen; \ + char *modeid; \ + int screen_compositing; \ + int cache_bitmaps; \ + char *theme; \ + bool utf8_clipboard; \ + bool context_menu; \ + bool truecolour_mouse_pointers; \ + bool use_os_pointers; \ + bool new_tab_active; \ + bool new_tab_last; \ + bool kiosk_mode; \ + char *search_engines_file; \ + char *arexx_dir; \ + char *arexx_startup; \ + char *arexx_shutdown; \ + char *download_dir; \ + bool download_notify; \ + bool faster_scroll; \ + bool scale_quality; \ + bool ask_overwrite; \ + int printer_unit; \ + int print_scale; \ + bool startup_no_window; \ + bool close_no_quit; \ + bool hide_docky_icon; \ + char *font_unicode; \ + bool drag_save_icons; \ + int hotlist_window_xpos; \ + int hotlist_window_ypos; \ + int hotlist_window_xsize; \ + int hotlist_window_ysize; \ + int history_window_xpos; \ + int history_window_ypos; \ + int history_window_xsize; \ + int history_window_ysize; \ + int cookies_window_xpos; \ + int cookies_window_ypos; \ + int cookies_window_xsize; \ + int cookies_window_ysize; \ + int cairo_renderer; \ + bool direct_render; \ + int amiga_ydpi; \ + int redraw_tile_size_x; \ + int redraw_tile_size_y; \ + int monitor_aspect_x; \ + int monitor_aspect_y; \ + bool accept_lang_locale; \ + int menu_refresh -#define EXTRA_OPTION_DEFINE \ -char *option_url_file = 0; \ -char *option_hotlist_file = 0; \ -char *option_use_pubscreen = 0; \ -char *option_modeid = 0; \ -int option_screen_compositing = -1; \ -int option_cache_bitmaps = 0; \ -char *option_theme = 0; \ -bool option_utf8_clipboard = false; \ -bool option_context_menu = true; \ -bool option_truecolour_mouse_pointers = false; \ -bool option_use_os_pointers = true; \ -bool option_new_tab_active = false; \ -bool option_new_tab_last = false; \ -bool option_kiosk_mode = false; \ -char *option_search_engines_file = 0; \ -char *option_arexx_dir = 0; \ -char *option_arexx_startup = 0; \ -char *option_arexx_shutdown = 0; \ -char *option_download_dir = 0; \ -bool option_download_notify = false; \ -bool option_faster_scroll = true; \ -bool option_scale_quality = false; \ -bool option_ask_overwrite = true; \ -int option_printer_unit = 0; \ -int option_print_scale = 100; \ -bool option_startup_no_window = false; \ -bool option_close_no_quit = false; \ -bool option_hide_docky_icon = false; \ -char *option_font_unicode = 0; \ -bool option_drag_save_icons = true; \ -int option_hotlist_window_xpos = 0; \ -int option_hotlist_window_ypos = 0; \ -int option_hotlist_window_xsize = 0; \ -int option_hotlist_window_ysize = 0; \ -int option_history_window_xpos = 0; \ -int option_history_window_ypos = 0; \ -int option_history_window_xsize = 0; \ -int option_history_window_ysize = 0; \ -int option_cookies_window_xpos = 0; \ -int option_cookies_window_ypos = 0; \ -int option_cookies_window_xsize = 0; \ -int option_cookies_window_ysize = 0; \ -int option_cairo_renderer = 1; \ -bool option_direct_render = false; \ -int option_amiga_ydpi = 72; \ -int option_redraw_tile_size_x = 400; \ -int option_redraw_tile_size_y = 150; \ -int option_monitor_aspect_x = 0; \ -int option_monitor_aspect_y = 0; \ -bool option_accept_lang_locale = true; \ -int option_menu_refresh = 0; \ -#define EXTRA_OPTION_TABLE \ -{ "url_file", OPTION_STRING, &option_url_file }, \ -{ "hotlist_file", OPTION_STRING, &option_hotlist_file }, \ -{ "use_pubscreen", OPTION_STRING, &option_use_pubscreen}, \ -{ "screen_modeid", OPTION_STRING, &option_modeid}, \ -{ "screen_compositing", OPTION_INTEGER, &option_screen_compositing}, \ -{ "cache_bitmaps", OPTION_INTEGER, &option_cache_bitmaps}, \ -{ "theme", OPTION_STRING, &option_theme}, \ -{ "clipboard_write_utf8", OPTION_BOOL, &option_utf8_clipboard}, \ -{ "context_menu", OPTION_BOOL, &option_context_menu}, \ -{ "truecolour_mouse_pointers", OPTION_BOOL, &option_truecolour_mouse_pointers}, \ -{ "os_mouse_pointers", OPTION_BOOL, &option_use_os_pointers}, \ -{ "new_tab_is_active", OPTION_BOOL, &option_new_tab_active}, \ -{ "new_tab_last", OPTION_BOOL, &option_new_tab_last}, \ -{ "kiosk_mode", OPTION_BOOL, &option_kiosk_mode}, \ -{ "search_engines_file", OPTION_STRING, &option_search_engines_file }, \ -{ "arexx_dir", OPTION_STRING, &option_arexx_dir }, \ -{ "arexx_startup", OPTION_STRING, &option_arexx_startup }, \ -{ "arexx_shutdown", OPTION_STRING, &option_arexx_shutdown }, \ -{ "download_dir", OPTION_STRING, &option_download_dir }, \ -{ "download_notify", OPTION_BOOL, &option_download_notify}, \ -{ "faster_scroll", OPTION_BOOL, &option_faster_scroll}, \ -{ "scale_quality", OPTION_BOOL, &option_scale_quality}, \ -{ "ask_overwrite", OPTION_BOOL, &option_ask_overwrite}, \ -{ "printer_unit", OPTION_INTEGER, &option_printer_unit}, \ -{ "print_scale", OPTION_INTEGER, &option_print_scale}, \ -{ "startup_no_window", OPTION_BOOL, &option_startup_no_window}, \ -{ "close_no_quit", OPTION_BOOL, &option_close_no_quit}, \ -{ "hide_docky_icon", OPTION_BOOL, &option_hide_docky_icon}, \ -{ "font_unicode", OPTION_STRING, &option_font_unicode }, \ -{ "drag_save_icons", OPTION_BOOL, &option_drag_save_icons}, \ -{ "hotlist_window_xpos", OPTION_INTEGER, &option_hotlist_window_xpos}, \ -{ "hotlist_window_ypos", OPTION_INTEGER, &option_hotlist_window_ypos}, \ -{ "hotlist_window_xsize", OPTION_INTEGER, &option_hotlist_window_xsize}, \ -{ "hotlist_window_ysize", OPTION_INTEGER, &option_hotlist_window_ysize}, \ -{ "history_window_xpos", OPTION_INTEGER, &option_history_window_xpos}, \ -{ "history_window_ypos", OPTION_INTEGER, &option_history_window_ypos}, \ -{ "history_window_xsize", OPTION_INTEGER, &option_history_window_xsize}, \ -{ "history_window_ysize", OPTION_INTEGER, &option_history_window_ysize}, \ -{ "cookies_window_xpos", OPTION_INTEGER, &option_cookies_window_xpos}, \ -{ "cookies_window_ypos", OPTION_INTEGER, &option_cookies_window_ypos}, \ -{ "cookies_window_xsize", OPTION_INTEGER, &option_cookies_window_xsize}, \ -{ "cookies_window_ysize", OPTION_INTEGER, &option_cookies_window_ysize}, \ -{ "cairo_renderer", OPTION_INTEGER, &option_cairo_renderer}, \ -{ "direct_render", OPTION_BOOL, &option_direct_render}, \ -{ "amiga_ydpi", OPTION_INTEGER, &option_amiga_ydpi}, \ -{ "redraw_tile_size_x", OPTION_INTEGER, &option_redraw_tile_size_x}, \ -{ "redraw_tile_size_y", OPTION_INTEGER, &option_redraw_tile_size_y}, \ -{ "monitor_aspect_x", OPTION_INTEGER, &option_monitor_aspect_x}, \ -{ "monitor_aspect_y", OPTION_INTEGER, &option_monitor_aspect_y}, \ -{ "accept_lang_locale", OPTION_BOOL, &option_accept_lang_locale}, \ -{ "menu_refresh", OPTION_INTEGER, &option_menu_refresh}, +#define NSOPTION_EXTRA_DEFAULTS \ + .url_file = NULL, \ + .hotlist_file = NULL, \ + .use_pubscreen = NULL, \ + .modeid = NULL, \ + .screen_compositing = -1, \ + .cache_bitmaps = 0, \ + .theme = NULL, \ + .utf8_clipboard = false, \ + .context_menu = true, \ + .truecolour_mouse_pointers = false, \ + .use_os_pointers = true, \ + .new_tab_active = false, \ + .new_tab_last = false, \ + .kiosk_mode = false, \ + .search_engines_file = NULL, \ + .arexx_dir = NULL, \ + .arexx_startup = NULL, \ + .arexx_shutdown = NULL, \ + .download_dir = NULL, \ + .download_notify = false, \ + .faster_scroll = true, \ + .scale_quality = false, \ + .ask_overwrite = true, \ + .printer_unit = 0, \ + .print_scale = 100, \ + .startup_no_window = false, \ + .close_no_quit = false, \ + .hide_docky_icon = false, \ + .font_unicode = NULL, \ + .drag_save_icons = true, \ + .hotlist_window_xpos = 0, \ + .hotlist_window_ypos = 0, \ + .hotlist_window_xsize = 0, \ + .hotlist_window_ysize = 0, \ + .history_window_xpos = 0, \ + .history_window_ypos = 0, \ + .history_window_xsize = 0, \ + .history_window_ysize = 0, \ + .cookies_window_xpos = 0, \ + .cookies_window_ypos = 0, \ + .cookies_window_xsize = 0, \ + .cookies_window_ysize = 0, \ + .cairo_renderer = 1, \ + .direct_render = false, \ + .amiga_ydpi = 72, \ + .redraw_tile_size_x = 400, \ + .redraw_tile_size_y = 150, \ + .monitor_aspect_x = 0, \ + .monitor_aspect_y = 0, \ + .accept_lang_locale = true, \ + .menu_refresh = 0 + +#define NSOPTION_EXTRA_TABLE \ +{ "url_file", OPTION_STRING, &nsoptions.url_file }, \ +{ "hotlist_file", OPTION_STRING, &nsoptions.hotlist_file }, \ +{ "use_pubscreen", OPTION_STRING, &nsoptions.use_pubscreen}, \ +{ "screen_modeid", OPTION_STRING, &nsoptions.modeid}, \ +{ "screen_compositing", OPTION_INTEGER, &nsoptions.screen_compositing}, \ +{ "cache_bitmaps", OPTION_INTEGER, &nsoptions.cache_bitmaps}, \ +{ "theme", OPTION_STRING, &nsoptions.theme}, \ +{ "clipboard_write_utf8", OPTION_BOOL, &nsoptions.utf8_clipboard}, \ +{ "context_menu", OPTION_BOOL, &nsoptions.context_menu}, \ +{ "truecolour_mouse_pointers", OPTION_BOOL, &nsoptions.truecolour_mouse_pointers}, \ +{ "os_mouse_pointers", OPTION_BOOL, &nsoptions.use_os_pointers}, \ +{ "new_tab_is_active", OPTION_BOOL, &nsoptions.new_tab_active}, \ +{ "new_tab_last", OPTION_BOOL, &nsoptions.new_tab_last}, \ +{ "kiosk_mode", OPTION_BOOL, &nsoptions.kiosk_mode}, \ +{ "search_engines_file",OPTION_STRING, &nsoptions.search_engines_file }, \ +{ "arexx_dir", OPTION_STRING, &nsoptions.arexx_dir }, \ +{ "arexx_startup", OPTION_STRING, &nsoptions.arexx_startup }, \ +{ "arexx_shutdown", OPTION_STRING, &nsoptions.arexx_shutdown }, \ +{ "download_dir", OPTION_STRING, &nsoptions.download_dir }, \ +{ "download_notify", OPTION_BOOL, &nsoptions.download_notify}, \ +{ "faster_scroll", OPTION_BOOL, &nsoptions.faster_scroll}, \ +{ "scale_quality", OPTION_BOOL, &nsoptions.scale_quality}, \ +{ "ask_overwrite", OPTION_BOOL, &nsoptions.ask_overwrite}, \ +{ "printer_unit", OPTION_INTEGER, &nsoptions.printer_unit}, \ +{ "print_scale", OPTION_INTEGER, &nsoptions.print_scale}, \ +{ "startup_no_window", OPTION_BOOL, &nsoptions.startup_no_window}, \ +{ "close_no_quit", OPTION_BOOL, &nsoptions.close_no_quit}, \ +{ "hide_docky_icon", OPTION_BOOL, &nsoptions.hide_docky_icon}, \ +{ "font_unicode", OPTION_STRING, &nsoptions.font_unicode }, \ +{ "drag_save_icons", OPTION_BOOL, &nsoptions.drag_save_icons}, \ +{ "hotlist_window_xpos", OPTION_INTEGER, &nsoptions.hotlist_window_xpos}, \ +{ "hotlist_window_ypos", OPTION_INTEGER, &nsoptions.hotlist_window_ypos}, \ +{ "hotlist_window_xsize", OPTION_INTEGER, &nsoptions.hotlist_window_xsize}, \ +{ "hotlist_window_ysize", OPTION_INTEGER, &nsoptions.hotlist_window_ysize}, \ +{ "history_window_xpos", OPTION_INTEGER, &nsoptions.history_window_xpos}, \ +{ "history_window_ypos", OPTION_INTEGER, &nsoptions.history_window_ypos}, \ +{ "history_window_xsize", OPTION_INTEGER, &nsoptions.history_window_xsize}, \ +{ "history_window_ysize", OPTION_INTEGER, &nsoptions.history_window_ysize}, \ +{ "cookies_window_xpos", OPTION_INTEGER, &nsoptions.cookies_window_xpos}, \ +{ "cookies_window_ypos", OPTION_INTEGER, &nsoptions.cookies_window_ypos}, \ +{ "cookies_window_xsize", OPTION_INTEGER, &nsoptions.cookies_window_xsize}, \ +{ "cookies_window_ysize", OPTION_INTEGER, &nsoptions.cookies_window_ysize}, \ +{ "cairo_renderer", OPTION_INTEGER, &nsoptions.cairo_renderer}, \ +{ "direct_render", OPTION_BOOL, &nsoptions.direct_render}, \ +{ "amiga_ydpi", OPTION_INTEGER, &nsoptions.amiga_ydpi}, \ +{ "redraw_tile_size_x", OPTION_INTEGER, &nsoptions.redraw_tile_size_x}, \ +{ "redraw_tile_size_y", OPTION_INTEGER, &nsoptions.redraw_tile_size_y}, \ +{ "monitor_aspect_x", OPTION_INTEGER, &nsoptions.monitor_aspect_x}, \ +{ "monitor_aspect_y", OPTION_INTEGER, &nsoptions.monitor_aspect_y}, \ +{ "accept_lang_locale", OPTION_BOOL, &nsoptions.accept_lang_locale}, \ +{ "menu_refresh", OPTION_INTEGER, &nsoptions.menu_refresh} + #endif diff --git a/amiga/plotters.c b/amiga/plotters.c index 4dd6256ff..c2a5c0b2e 100755 --- a/amiga/plotters.c +++ b/amiga/plotters.c @@ -25,7 +25,7 @@ #include #include #include "amiga/utf8.h" -#include "amiga/options.h" +#include "desktop/options.h" #ifdef __amigaos4__ #include #include @@ -121,10 +121,10 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height) struct BitMap *friend = NULL; /* Required to be NULL for Cairo and ARGB bitmaps */ - if(option_redraw_tile_size_x <= 0) option_redraw_tile_size_x = scrn->Width; - if(option_redraw_tile_size_y <= 0) option_redraw_tile_size_y = scrn->Height; - if(!width) width = option_redraw_tile_size_x; - if(!height) height = option_redraw_tile_size_y; + if(nsoption_int(redraw_tile_size_x) <= 0) nsoption_set_int(redraw_tile_size_x, scrn->Width); + if(nsoption_int(redraw_tile_size_y) <= 0) nsoption_set_int(redraw_tile_size_y, scrn->Height); + if(!width) width = nsoption_int(redraw_tile_size_x); + if(!height) height = nsoption_int(redraw_tile_size_y); gg->layerinfo = NewLayerInfo(); gg->areabuf = AllocVec(100,MEMF_PRIVATE | MEMF_CLEAR); @@ -206,7 +206,7 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style) if (style->fill_type != PLOT_OP_TYPE_NONE) { - if(option_cairo_renderer < 2) + if(nsoption_int(cairo_renderer) < 2) { SetRPAttrs(glob->rp, RPTAG_APenColor, p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour), @@ -228,7 +228,7 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style) } if (style->stroke_type != PLOT_OP_TYPE_NONE) { - if(option_cairo_renderer < 2) + if(nsoption_int(cairo_renderer) < 2) { glob->rp->PenWidth = style->stroke_width; glob->rp->PenHeight = style->stroke_width; @@ -301,7 +301,7 @@ bool ami_line(int x0, int y0, int x1, int y1, const plot_style_t *style) LOG(("[ami_plotter] Entered ami_line()")); #endif - if(option_cairo_renderer < 2) + if(nsoption_int(cairo_renderer) < 2) { glob->rp->PenWidth = style->stroke_width; glob->rp->PenHeight = style->stroke_width; @@ -377,7 +377,7 @@ bool ami_polygon(const int *p, unsigned int n, const plot_style_t *style) int k; - if(option_cairo_renderer < 1) + if(nsoption_int(cairo_renderer) < 1) { ULONG cx,cy; @@ -443,7 +443,7 @@ bool ami_clip(const struct rect *clip) } #ifdef NS_AMIGA_CAIRO - if(option_cairo_renderer == 2) + if(nsoption_int(cairo_renderer) == 2) { cairo_reset_clip(glob->cr); cairo_rectangle(glob->cr, clip->x0, clip->y0, @@ -472,7 +472,7 @@ bool ami_disc(int x, int y, int radius, const plot_style_t *style) LOG(("[ami_plotter] Entered ami_disc()")); #endif - if(option_cairo_renderer < 2) + if(nsoption_int(cairo_renderer) < 2) { if (style->fill_type != PLOT_OP_TYPE_NONE) { SetRPAttrs(glob->rp, @@ -525,7 +525,7 @@ bool ami_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_ LOG(("[ami_plotter] Entered ami_arc()")); #endif - if(option_cairo_renderer >= 1) + if(nsoption_int(cairo_renderer) >= 1) { #ifdef NS_AMIGA_CAIRO ami_cairo_set_colour(glob->cr, style->fill_colour); @@ -801,7 +801,7 @@ bool ami_path(const float *p, unsigned int n, colour fill, float width, /* We should probably check if the off-screen bitmap is 32-bit and render * using Cairo regardless if it is. For now, we respect user preferences. */ - if(option_cairo_renderer >= 1) + if(nsoption_int(cairo_renderer) >= 1) { unsigned int i; cairo_matrix_t old_ctm, n_ctm; diff --git a/amiga/print.c b/amiga/print.c index 9a2bd54d9..405d55b09 100644 --- a/amiga/print.c +++ b/amiga/print.c @@ -20,7 +20,7 @@ #include "amiga/plotters.h" #include "render/font.h" #include "amiga/gui.h" -#include "amiga/options.h" +#include "desktop/options.h" #include "amiga/print.h" #include "utils/messages.h" #include "utils/utils.h" @@ -255,7 +255,7 @@ void ami_print_ui(struct hlcache_handle *c) GA_RelVerify, TRUE, GA_TabCycle, TRUE, CHOOSER_LabelArray, printers, - CHOOSER_Selected, option_printer_unit, + CHOOSER_Selected, nsoption_int(printer_unit), ChooserEnd, CHILD_Label, LabelObject, LABEL_Text, gadlab[PGID_PRINTER], @@ -278,7 +278,7 @@ void ami_print_ui(struct hlcache_handle *c) GA_ID, PGID_SCALE, GA_RelVerify, TRUE, GA_TabCycle, TRUE, - INTEGER_Number, option_print_scale, + INTEGER_Number, nsoption_int(print_scale), INTEGER_Minimum, 0, INTEGER_Maximum, 100, INTEGER_Arrows, TRUE, @@ -331,6 +331,8 @@ BOOL ami_print_event(struct ami_print_window *pw) uint16 code; struct hlcache_handle *c; int copies; + int print_scale; + int printer_unit; while((result = RA_HandleInput(pw->objects[OID_MAIN],&code)) != WMHI_LASTMSG) { @@ -341,11 +343,14 @@ BOOL ami_print_event(struct ami_print_window *pw) { case PGID_PRINT: GetAttr(INTEGER_Number, pw->gadgets[PGID_SCALE], - (ULONG *)&option_print_scale); + (ULONG *)&print_scale); GetAttr(INTEGER_Number, pw->gadgets[PGID_COPIES], (ULONG *)&copies); GetAttr(CHOOSER_Selected, pw->gadgets[PGID_PRINTER], - (ULONG *)&option_printer_unit); + (ULONG *)&printer_unit); + + nsoption_set_int(print_scale, print_scale); + nsoption_set_int(printer_unit, printer_unit); c = pw->c; ami_print_close(pw); @@ -372,7 +377,7 @@ BOOL ami_print_event(struct ami_print_window *pw) void ami_print(struct hlcache_handle *c, int copies) { double height, print_height; - float scale = option_print_scale / 100.0; + float scale = nsoption_int(print_scale) / 100.0; if(!ami_print_info.msgport) return; @@ -383,7 +388,7 @@ void ami_print(struct hlcache_handle *c, int copies) ASO_NoTrack, FALSE, TAG_DONE))) return; - if(OpenDevice("printer.device", option_printer_unit, + if(OpenDevice("printer.device", nsoption_int(printer_unit), (struct IORequest *)ami_print_info.PReq, 0)) { warn_user("CompError","printer.device"); diff --git a/amiga/stringview/urlhistory.c b/amiga/stringview/urlhistory.c index 659e7d4c7..af9c35b13 100644 --- a/amiga/stringview/urlhistory.c +++ b/amiga/stringview/urlhistory.c @@ -106,7 +106,7 @@ struct Node * URLHistory_FindPage( const char *urlString ) void URLHistory_AddPage( const char * urlString ) { - if(!option_url_suggestion) return; + if(!nsoption_bool(url_suggestion)) return; // Only search if length > 0 if( strlen( urlString ) > 0 ) diff --git a/amiga/system_colour.c b/amiga/system_colour.c index e5dace808..2c7f7d343 100644 --- a/amiga/system_colour.c +++ b/amiga/system_colour.c @@ -49,189 +49,189 @@ static struct gui_system_colour_ctx colour_list[] = { "ActiveBorder", SLEN("ActiveBorder"), 0xff000000, - &option_sys_colour_ActiveBorder, + &nsoption_colour(sys_colour_ActiveBorder), FILLPEN, NULL }, { "ActiveCaption", SLEN("ActiveCaption"), 0xffdddddd, - &option_sys_colour_ActiveCaption, + &nsoption_colour(sys_colour_ActiveCaption), FILLPEN, NULL }, { "AppWorkspace", SLEN("AppWorkspace"), 0xffeeeeee, - &option_sys_colour_AppWorkspace, + &nsoption_colour(sys_colour_AppWorkspace), BACKGROUNDPEN, NULL }, { "Background", SLEN("Background"), 0xff0000aa, - &option_sys_colour_Background, + &nsoption_colour(sys_colour_Background), BACKGROUNDPEN, NULL }, { "ButtonFace", SLEN("ButtonFace"), 0xffaaaaaa, - &option_sys_colour_ButtonFace, + &nsoption_colour(sys_colour_ButtonFace), FOREGROUNDPEN, NULL }, { "ButtonHighlight", SLEN("ButtonHighlight"), 0xffdddddd, - &option_sys_colour_ButtonHighlight, + &nsoption_colour(sys_colour_ButtonHighlight), FORESHINEPEN, NULL }, { "ButtonShadow", SLEN("ButtonShadow"), 0xffbbbbbb, - &option_sys_colour_ButtonShadow, + &nsoption_colour(sys_colour_ButtonShadow), FORESHADOWPEN, NULL }, { "ButtonText", SLEN("ButtonText"), 0xff000000, - &option_sys_colour_ButtonText, + &nsoption_colour(sys_colour_ButtonText), TEXTPEN, NULL }, { "CaptionText", SLEN("CaptionText"), 0xff000000, - &option_sys_colour_CaptionText, + &nsoption_colour(sys_colour_CaptionText), FILLTEXTPEN, NULL }, { "GrayText", SLEN("GrayText"), 0xffcccccc, - &option_sys_colour_GrayText, + &nsoption_colour(sys_colour_GrayText), DISABLEDTEXTPEN, NULL }, { "Highlight", SLEN("Highlight"), 0xff0000ee, - &option_sys_colour_Highlight, + &nsoption_colour(sys_colour_Highlight), SELECTPEN, NULL }, { "HighlightText", SLEN("HighlightText"), 0xff000000, - &option_sys_colour_HighlightText, + &nsoption_colour(sys_colour_HighlightText), SELECTTEXTPEN, NULL }, { "InactiveBorder", SLEN("InactiveBorder"), 0xffffffff, - &option_sys_colour_InactiveBorder, + &nsoption_colour(sys_colour_InactiveBorder), INACTIVEFILLPEN, NULL }, { "InactiveCaption", SLEN("InactiveCaption"), 0xffffffff, - &option_sys_colour_InactiveCaption, + &nsoption_colour(sys_colour_InactiveCaption), INACTIVEFILLPEN, NULL }, { "InactiveCaptionText", SLEN("InactiveCaptionText"), 0xffcccccc, - &option_sys_colour_InactiveCaptionText, + &nsoption_colour(sys_colour_InactiveCaptionText), INACTIVEFILLTEXTPEN, NULL }, { "InfoBackground", SLEN("InfoBackground"), 0xffaaaaaa, - &option_sys_colour_InfoBackground, + &nsoption_colour(sys_colour_InfoBackground), BACKGROUNDPEN, /* This is wrong, HelpHint backgrounds are pale yellow but doesn't seem to be a DrawInfo pen defined for it. */ NULL }, { "InfoText", SLEN("InfoText"), 0xff000000, - &option_sys_colour_InfoText, + &nsoption_colour(sys_colour_InfoText), TEXTPEN, NULL }, { "Menu", SLEN("Menu"), 0xffaaaaaa, - &option_sys_colour_Menu, + &nsoption_colour(sys_colour_Menu), MENUBACKGROUNDPEN, NULL }, { "MenuText", SLEN("MenuText"), 0xff000000, - &option_sys_colour_MenuText, + &nsoption_colour(sys_colour_MenuText), MENUTEXTPEN, NULL }, { "Scrollbar", SLEN("Scrollbar"), 0xffaaaaaa, - &option_sys_colour_Scrollbar, + &nsoption_colour(sys_colour_Scrollbar), AMINS_SCROLLERPEN, NULL }, { "ThreeDDarkShadow", SLEN("ThreeDDarkShadow"), 0xff555555, - &option_sys_colour_ThreeDDarkShadow, + &nsoption_colour(sys_colour_ThreeDDarkShadow), FORESHADOWPEN, NULL }, { "ThreeDFace", SLEN("ThreeDFace"), 0xffdddddd, - &option_sys_colour_ThreeDFace, + &nsoption_colour(sys_colour_ThreeDFace), FOREGROUNDPEN, NULL }, { "ThreeDHighlight", SLEN("ThreeDHighlight"), 0xffaaaaaa, - &option_sys_colour_ThreeDHighlight, + &nsoption_colour(sys_colour_ThreeDHighlight), FORESHINEPEN, NULL }, { "ThreeDLightShadow", SLEN("ThreeDLightShadow"), 0xff999999, - &option_sys_colour_ThreeDLightShadow, + &nsoption_colour(sys_colour_ThreeDLightShadow), HALFSHINEPEN, NULL }, { "ThreeDShadow", SLEN("ThreeDShadow"), 0xff777777, - &option_sys_colour_ThreeDShadow, + &nsoption_colour(sys_colour_ThreeDShadow), HALFSHADOWPEN, NULL }, { "Window", SLEN("Window"), 0xffaaaaaa, - &option_sys_colour_Window, + &nsoption_colour(sys_colour_Window), BACKGROUNDPEN, NULL }, { "WindowFrame", SLEN("WindowFrame"), 0xff000000, - &option_sys_colour_WindowFrame, + &nsoption_colour(sys_colour_WindowFrame), INACTIVEFILLPEN, NULL }, { @@ -239,7 +239,7 @@ static struct gui_system_colour_ctx colour_list[] = { "WindowText", SLEN("WindowText"), 0xff000000, - &option_sys_colour_WindowText, + &nsoption_colour(sys_colour_WindowText), INACTIVEFILLTEXTPEN, NULL }, diff --git a/amiga/theme.c b/amiga/theme.c index bee0a0b75..1bcd6a7be 100644 --- a/amiga/theme.c +++ b/amiga/theme.c @@ -36,7 +36,7 @@ #include #include "amiga/drag.h" -#include "amiga/options.h" +#include "desktop/options.h" #include "amiga/theme.h" #include "desktop/searchweb.h" #include "utils/messages.h" @@ -100,17 +100,16 @@ void ami_theme_init(void) char searchico[1024]; BPTR lock = 0; - strcpy(themefile,option_theme); + strcpy(themefile,nsoption_charp(theme)); AddPart(themefile,"Theme",100); lock = Lock(themefile,ACCESS_READ); if(!lock) { - warn_user("ThemeApplyErr",option_theme); + warn_user("ThemeApplyErr",nsoption_charp(theme)); strcpy(themefile,"PROGDIR:Resources/Themes/Default/Theme"); - free(option_theme); - option_theme = (char *)strdup("PROGDIR:Resources/Themes/Default"); + nsoption_set_charp(theme, (char *)strdup("PROGDIR:Resources/Themes/Default")); } else { @@ -194,7 +193,7 @@ void ami_get_theme_filename(char *filename, char *themestring, bool protocol) } else { - strcat(filename, option_theme); + strcat(filename, nsoption_charp(theme)); AddPart(filename, messages_get(themestring), 100); } } @@ -209,7 +208,7 @@ void ami_update_pointer(struct Window *win, gui_pointer_shape shape) if(mouseptrcurrent == shape) return; if(drag_save_data) return; - if(option_use_os_pointers) + if(nsoption_bool(use_os_pointers)) { switch(shape) { @@ -287,7 +286,7 @@ void ami_init_mouse_pointers(void) mouseptrobj[i] = NULL; char ptrfname[1024]; - if(option_truecolour_mouse_pointers) + if(nsoption_bool(truecolour_mouse_pointers)) { ami_get_theme_filename((char *)&ptrfname,ptrs32[i], false); if(dobj = GetIconTags(ptrfname,ICONGETA_UseFriendBitMap,TRUE,TAG_DONE)) @@ -405,7 +404,7 @@ void gui_window_start_throbber(struct gui_window *g) ULONG cur_tab = 0; if(!g) return; - if(option_kiosk_mode) return; + if(nsoption_bool(kiosk_mode)) return; if(g->tab_node && (g->shared->tabs > 1)) { @@ -435,7 +434,7 @@ void gui_window_stop_throbber(struct gui_window *g) ULONG cur_tab = 0; if(!g) return; - if(option_kiosk_mode) return; + if(nsoption_bool(kiosk_mode)) return; if(g->tab_node && (g->shared->tabs > 1)) { diff --git a/amiga/thumbnail.c b/amiga/thumbnail.c index ae8993a72..08ab90a95 100755 --- a/amiga/thumbnail.c +++ b/amiga/thumbnail.c @@ -20,7 +20,7 @@ #include "desktop/browser.h" #include "amiga/gui.h" #include "amiga/bitmap.h" -#include "amiga/options.h" +#include "desktop/options.h" #include "content/urldb.h" #include "desktop/plotters.h" #include "desktop/thumbnail.h" @@ -42,15 +42,15 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, struct BitScaleArgs bsa; int plot_width; int plot_height; - int redraw_tile_size = option_redraw_tile_size_x; + int redraw_tile_size = nsoption_int(redraw_tile_size_x); struct redraw_context ctx = { .interactive = false, .background_images = true, .plot = &amiplot }; - if(option_redraw_tile_size_y < option_redraw_tile_size_x) - redraw_tile_size = option_redraw_tile_size_y; + if(nsoption_int(redraw_tile_size_y) < nsoption_int(redraw_tile_size_x)) + redraw_tile_size = nsoption_int(redraw_tile_size_y); plot_width = MIN(content_get_width(content), redraw_tile_size); plot_height = ((plot_width * bitmap->height) + (bitmap->width / 2)) / @@ -70,7 +70,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, { float resample_scale = bitmap->width / (float)plot_width; uint32 flags = COMPFLAG_IgnoreDestAlpha | COMPFLAG_SrcAlphaOverride; - if(option_scale_quality) flags |= COMPFLAG_SrcFilter; + if(nsoption_bool(scale_quality)) flags |= COMPFLAG_SrcFilter; CompositeTags(COMPOSITE_Src,browserglob.bm,bitmap->nativebm, COMPTAG_ScaleX, diff --git a/amiga/tree.c b/amiga/tree.c index 51cb35865..0ec527ec7 100755 --- a/amiga/tree.c +++ b/amiga/tree.c @@ -53,7 +53,7 @@ #include "amiga/drag.h" /* drag icon stuff */ #include "amiga/theme.h" /* pointers */ #include "amiga/filetype.h" -#include "amiga/options.h" +#include "desktop/options.h" #include "content/urldb.h" #include "desktop/cookies.h" #include "desktop/history_global_core.h" @@ -573,26 +573,26 @@ void ami_tree_open(struct treeview_window *twin,int type) ULONG top = (scrn->Height / 2) - (height / 2); ULONG left = (scrn->Width / 2) - (width / 2); - if((type == AMI_TREE_HOTLIST) && (option_hotlist_window_xsize > 0)) + if((type == AMI_TREE_HOTLIST) && (nsoption_int(hotlist_window_xsize) > 0)) { - top = option_hotlist_window_ypos; - left = option_hotlist_window_xpos; - width = option_hotlist_window_xsize; - height = option_hotlist_window_ysize; + top = nsoption_int(hotlist_window_ypos); + left = nsoption_int(hotlist_window_xpos); + width = nsoption_int(hotlist_window_xsize); + height = nsoption_int(hotlist_window_ysize); } - else if((type == AMI_TREE_HISTORY) && (option_history_window_xsize > 0)) + else if((type == AMI_TREE_HISTORY) && (nsoption_int(history_window_xsize) > 0)) { - top = option_history_window_ypos; - left = option_history_window_xpos; - width = option_history_window_xsize; - height = option_history_window_ysize; + top = nsoption_int(history_window_ypos); + left = nsoption_int(history_window_xpos); + width = nsoption_int(history_window_xsize); + height = nsoption_int(history_window_ysize); } - else if((type == AMI_TREE_COOKIES) && (option_cookies_window_xsize > 0)) + else if((type == AMI_TREE_COOKIES) && (nsoption_int(cookies_window_xsize) > 0)) { - top = option_cookies_window_ypos; - left = option_cookies_window_xpos; - width = option_cookies_window_xsize; - height = option_cookies_window_ysize; + top = nsoption_int(cookies_window_ypos); + left = nsoption_int(cookies_window_xpos); + width = nsoption_int(cookies_window_xsize); + height = nsoption_int(cookies_window_ysize); } twin->objects[OID_MAIN] = WindowObject, @@ -1093,22 +1093,22 @@ BOOL ami_tree_event(struct treeview_window *twin) switch(twin->type) { case AMI_TREE_HISTORY: - option_history_window_ypos = twin->win->TopEdge; - option_history_window_xpos = twin->win->LeftEdge; - option_history_window_xsize = twin->win->Width; - option_history_window_ysize = twin->win->Height; + nsoption_set_int(history_window_ypos, twin->win->TopEdge); + nsoption_set_int(history_window_xpos, twin->win->LeftEdge); + nsoption_set_int(history_window_xsize, twin->win->Width); + nsoption_set_int(history_window_ysize, twin->win->Height); break; case AMI_TREE_COOKIES: - option_cookies_window_ypos = twin->win->TopEdge; - option_cookies_window_xpos = twin->win->LeftEdge; - option_cookies_window_xsize = twin->win->Width; - option_cookies_window_ysize = twin->win->Height; + nsoption_set_int(cookies_window_ypos, twin->win->TopEdge); + nsoption_set_int(cookies_window_xpos, twin->win->LeftEdge); + nsoption_set_int(cookies_window_xsize, twin->win->Width); + nsoption_set_int(cookies_window_ysize, twin->win->Height); break; case AMI_TREE_HOTLIST: - option_hotlist_window_ypos = twin->win->TopEdge; - option_hotlist_window_xpos = twin->win->LeftEdge; - option_hotlist_window_xsize = twin->win->Width; - option_hotlist_window_ysize = twin->win->Height; + nsoption_set_int(hotlist_window_ypos, twin->win->TopEdge); + nsoption_set_int(hotlist_window_xpos, twin->win->LeftEdge); + nsoption_set_int(hotlist_window_xsize, twin->win->Width); + nsoption_set_int(hotlist_window_ysize, twin->win->Height); break; } break; @@ -1248,14 +1248,14 @@ void ami_tree_redraw_request(int x, int y, int width, int height, void *data) y = pos_y; } - for(tile_y = y; tile_y < (y + height); tile_y += option_redraw_tile_size_y) { - tile_h = option_redraw_tile_size_y; - if(((y + height) - tile_y) < option_redraw_tile_size_y) + for(tile_y = y; tile_y < (y + height); tile_y += nsoption_int(redraw_tile_size_y)) { + tile_h = nsoption_int(redraw_tile_size_y); + if(((y + height) - tile_y) < nsoption_int(redraw_tile_size_y)) tile_h = (y + height) - tile_y; - for(tile_x = x; tile_x < (x + width); tile_x += option_redraw_tile_size_x) { - tile_w = option_redraw_tile_size_x; - if(((x + width) - tile_x) < option_redraw_tile_size_x) + for(tile_x = x; tile_x < (x + width); tile_x += nsoption_int(redraw_tile_size_x)) { + tile_w = nsoption_int(redraw_tile_size_x); + if(((x + width) - tile_x) < nsoption_int(redraw_tile_size_x)) tile_w = (x + width) - tile_x; tree_draw(twin->tree, - tile_x, - tile_y, diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c index 76001ff39..3e481e048 100644 --- a/atari/ctxmenu.c +++ b/atari/ctxmenu.c @@ -44,7 +44,7 @@ #include "atari/browser_win.h" #include "atari/misc.h" #include "atari/clipboard.h" -#include "atari/options.h" +#include "desktop/options.h" #include "atari/res/netsurf.rsh" #include "atari/ctxmenu.h" @@ -245,7 +245,7 @@ void context_popup( struct gui_window * gw, short x, short y ) break; case POP_CTX_VIEW_SOURCE: - if( option_atari_editor != NULL ) { + if( nsoption_charp(atari_editor) != NULL ) { data = content_get_source_data( gw->browser->bw->current_content, &size ); if( size > 0 && data != NULL ){ tempfile = tmpnam( NULL ); @@ -255,11 +255,12 @@ void context_popup( struct gui_window * gw, short x, short y ) fclose( fp_tmpfile ); // TODO: check if app is runnin, if not, use pexec or such. - /*sprintf((char*)&cmdline, "%s \"%s\"", option_atari_editor, tempfile ); - system( (char*)&cmdline ); + /* + sprintf((char*)&cmdline, "%s \"%s\"", nsoption_charp(atari_editor), tempfile ); + system( (char*)&cmdline ); */ - err = ShelWrite( option_atari_editor, tempfile , option_atari_editor, 1, 0); - LOG(("Launched: %s %s (%d)\n", option_atari_editor, tempfile, err )); + err = ShelWrite( nsoption_charp(atari_editor), tempfile , nsoption_charp(atari_editor), 1, 0); + LOG(("Launched: %s %s (%d)\n", nsoption_charp(atari_editor), tempfile, err )); } else { printf("Could not open temp file: %s!\n", tempfile ); } diff --git a/atari/download.c b/atari/download.c index 2af2d707e..e8f916515 100755 --- a/atari/download.c +++ b/atari/download.c @@ -45,7 +45,6 @@ #include "atari/misc.h" #include "atari/res/netsurf.rsh" #include "atari/download.h" -#include "atari/options.h" #include "atari/osspec.h" /*TODO: get filename from core. */ @@ -150,7 +149,7 @@ struct gui_download_window *gui_download_window_create(download_context *ctx, { char *filename; - char *destination; + char *destination; char gdos_path[PATH_MAX]; const char * url; struct gui_download_window * gdw; @@ -168,13 +167,13 @@ struct gui_download_window *gui_download_window_create(download_context *ctx, return( NULL ); } else if( dlgres == 2 ){ - gemdos_realpath(option_downloads_path, gdos_path); + gemdos_realpath(nsoption_charp(downloads_path), gdos_path); char * tmp = select_filepath( gdos_path, filename ); if( tmp == NULL ) return( NULL ); destination = tmp; } else { - gemdos_realpath(option_downloads_path, gdos_path); + gemdos_realpath(nsoption_charp(downloads_path), gdos_path); destination = malloc( strlen(gdos_path)+1 + strlen(filename)+1 ); sprintf( destination, "%s/%s", gdos_path, filename ); diff --git a/atari/font.c b/atari/font.c index 2098055eb..cb47c8ef3 100755 --- a/atari/font.c +++ b/atari/font.c @@ -32,7 +32,6 @@ #include "atari/gui.h" #include "atari/font.h" #include "atari/plot.h" -#include "atari/options.h" #include "atari/findfile.h" #include "atari/gui.h" #include "atari/plot.h" diff --git a/atari/global_evnt.c b/atari/global_evnt.c index 3170b8a9e..3a34a4ac9 100755 --- a/atari/global_evnt.c +++ b/atari/global_evnt.c @@ -46,7 +46,6 @@ #include "atari/browser_win.h" #include "atari/res/netsurf.rsh" #include "atari/search.h" -#include "atari/options.h" #include "atari/findfile.h" #include "atari/settings.h" #include "cflib.h" @@ -280,14 +279,14 @@ static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *da static void __CDECL menu_fg_images(WINDOW *win, int item, int title, void *data) { - option_foreground_images = !option_foreground_images; - MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (option_foreground_images) ? 1 : 0); + nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images)); + MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0); } static void __CDECL menu_bg_images(WINDOW *win, int item, int title, void *data) { - option_background_images = !option_background_images; - MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (option_background_images) ? 1 : 0); + nsoption_set_bool(background_images, !nsoption_bool(background_images)); + MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0); } static void __CDECL menu_back(WINDOW *win, int item, int title, void *data) @@ -326,7 +325,7 @@ static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data) LOG(("%s", __FUNCTION__)); char buf[PATH_MAX]; strcpy((char*)&buf, "file://"); - strncat((char*)&buf, option_url_file, PATH_MAX - (strlen("file://")+1) ); + strncat((char*)&buf, nsoption_charp(url_file), PATH_MAX - (strlen("file://")+1) ); browser_window_create((char*)&buf, 0, 0, true, false); } @@ -678,8 +677,8 @@ static void set_menu_title(int rid, const char * nsid) void main_menu_update( void ) { MenuIcheck( NULL, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0); - MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (option_foreground_images) ? 1 : 0); - MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (option_background_images) ? 1 : 0); + MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0); + MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0); } diff --git a/atari/gui.c b/atari/gui.c index f2b6d064f..37d09f37e 100755 --- a/atari/gui.c +++ b/atari/gui.c @@ -56,7 +56,6 @@ #include "utils/utils.h" #include "atari/gui.h" -#include "atari/options.h" #include "atari/misc.h" #include "atari/findfile.h" #include "atari/schedule.h" @@ -824,8 +823,8 @@ void gui_quit(void) hotlist_destroy(); - urldb_save_cookies(option_cookie_file); - urldb_save(option_url_file); + urldb_save_cookies(nsoption_charp(cookie_file)); + urldb_save(nsoption_charp(url_file)); RsrcXtype( 0, rsc_trindex, rsc_ntree); unbind_global_events(); @@ -852,9 +851,9 @@ process_cmdline(int argc, char** argv) LOG(("argc %d, argv %p", argc, argv)); - if ((option_window_width != 0) && (option_window_height != 0)) { - cfg_width = option_window_width; - cfg_height = option_window_height; + if ((nsoption_int(window_width) != 0) && (nsoption_int(window_height) != 0)) { + cfg_width = nsoption_int(window_width); + cfg_height = nsoption_int(window_height); } else { if( sys_type() == SYS_TOS ){ /* on single tasking OS, start as fulled window: */ @@ -866,8 +865,8 @@ process_cmdline(int argc, char** argv) } } - if (option_homepage_url != NULL && option_homepage_url[0] != '\0') - cfg_homepage_url = option_homepage_url; + if (nsoption_charp(homepage_url) != NULL) + cfg_homepage_url = nsoption_charp(homepage_url); else cfg_homepage_url = NETSURF_HOMEPAGE; @@ -964,21 +963,21 @@ static void gui_init(int argc, char** argv) cursors, &gem_cursors.help); LOG(("Enabling core select menu")); - option_core_select_menu = true; + nsoption_set_bool(core_select_menu, true); - if( strlen(option_url_file) ){ - urldb_load(option_url_file); + if( strlen(nsoption_charp(url_file)) ){ + urldb_load(nsoption_charp(url_file)); } - if( strlen(option_cookie_file) ){ - urldb_load_cookies(option_cookie_file); - LOG(("Loading cookies from: %s", option_cookie_file )); + if( strlen(nsoption_charp(cookie_file)) ){ + urldb_load_cookies(nsoption_charp(cookie_file)); + LOG(("Loading cookies from: %s", nsoption_charp(cookie_file) )); } if (process_cmdline(argc,argv) != true) die("unable to process command line.\n"); nkc_init(); - atari_plotter_init( option_atari_screen_driver, option_atari_font_driver ); + atari_plotter_init( nsoption_charp(atari_screen_driver), nsoption_charp(atari_font_driver) ); } static char *theapp = (char*)"NetSurf"; @@ -990,7 +989,7 @@ static void gui_init2(int argc, char** argv) if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) { menu_register( _AESapid, (char*)" NetSurf "); } - tree_set_icon_dir( option_tree_icons_path ); + tree_set_icon_dir( nsoption_charp(tree_icons_path) ); hotlist_init(); } diff --git a/atari/hotlist.c b/atari/hotlist.c index 067d9c123..89c06c7fc 100755 --- a/atari/hotlist.c +++ b/atari/hotlist.c @@ -41,7 +41,6 @@ #include "atari/hotlist.h" #include "atari/findfile.h" #include "atari/res/netsurf.rsh" -#include "atari/options.h" struct atari_hotlist hl; @@ -86,10 +85,10 @@ static void __CDECL evnt_hl_mbutton( WINDOW *win, short buff[8] ) void hotlist_init(void) { - if( strcmp(option_hotlist_file, "") == 0 ){ + if( strcmp(nsoption_charp(hotlist_file), "") == 0 ){ atari_find_resource( (char*)&hl.path, "hotlist", "hotlist" ); } else { - strncpy( (char*)&hl.path, option_hotlist_file, PATH_MAX-1 ); + strncpy( (char*)&hl.path, nsoption_charp(hotlist_file), PATH_MAX-1 ); } LOG(("Hotlist: %s", (char*)&hl.path )); diff --git a/atari/options.h b/atari/options.h index e2bfc35f8..6da17cbd9 100755 --- a/atari/options.h +++ b/atari/options.h @@ -16,74 +16,79 @@ * along with this program. If not, see . */ +#ifndef _NETSURF_DESKTOP_OPTIONS_INCLUDING_ +#error "Frontend options header cannot be included directly" +#endif + #ifndef NS_ATARI_OPTIONS_H_ #define NS_ATARI_OPTIONS_H_ -#include "desktop/options.h" -extern char * option_atari_screen_driver; -extern char * option_atari_font_driver; -extern int option_atari_font_monochrom; -extern int option_atari_dither; -extern int option_atari_transparency; -extern char *option_atari_face_sans_serif; /* default sans face */ -extern char *option_atari_face_sans_serif_bold; /* bold sans face */ -extern char *option_atari_face_sans_serif_italic; /* bold sans face */ -extern char *option_atari_face_sans_serif_italic_bold; /* bold sans face */ -extern char *option_atari_face_monospace; /* monospace face */ -extern char *option_atari_face_monospace_bold; /* monospace face */ -extern char *option_atari_face_serif; /* serif face */ -extern char *option_atari_face_serif_bold; /* bold serif face */ -extern char *option_atari_face_cursive; -extern char *option_atari_face_fantasy; -extern char *option_atari_editor; -extern char *option_downloads_path; -extern char *option_url_file; -extern char *option_hotlist_file; -extern char *option_tree_icons_path; +#define NSOPTION_EXTRA_DEFINE \ + char *atari_screen_driver; \ + char *atari_font_driver; \ + int atari_font_monochrom; \ + int atari_dither; \ + int atari_transparency; \ + char *atari_face_sans_serif; /* default sans face */ \ + char *atari_face_sans_serif_bold; /* bold sans face */ \ + char *atari_face_sans_serif_italic; /* bold sans face */ \ + char *atari_face_sans_serif_italic_bold; /* bold sans face */ \ + char *atari_face_monospace; /* monospace face */ \ + char *atari_face_monospace_bold; /* monospace face */ \ + char *atari_face_serif; /* serif face */ \ + char *atari_face_serif_bold; /* bold serif face */ \ + char *atari_face_cursive; \ + char *atari_face_fantasy; \ + char *atari_editor; \ + char *downloads_path; \ + char *url_file; \ + char *hotlist_file; \ + char *tree_icons_path -#define EXTRA_OPTION_DEFINE \ -char * option_atari_screen_driver = (char*)"vdi";\ -char * option_atari_font_driver = (char*)"vdi";\ -int option_atari_font_monochrom = 0;\ -int option_atari_dither = 1;\ -int option_atari_transparency = 1;\ -char *option_atari_face_sans_serif;\ -char *option_atari_face_sans_serif_bold;\ -char *option_atari_face_sans_serif_italic;\ -char *option_atari_face_sans_serif_italic_bold;\ -char *option_atari_face_monospace;\ -char *option_atari_face_monospace_bold;\ -char *option_atari_face_serif;\ -char *option_atari_face_serif_bold;\ -char *option_atari_face_cursive; \ -char *option_atari_face_fantasy; \ -char *option_atari_editor = (char*)"";\ -char *option_downloads_path = (char*)""; \ -char *option_url_file = (char*)"url.db";\ -char *option_hotlist_file = (char*)"hotlist";\ -char *option_tree_icons_path = (char*)"./res/icons"; +#define NSOPTION_EXTRA_DEFAULTS \ + .atari_screen_driver = (char*)"vdi", \ + .atari_font_driver = (char*)"vdi", \ + .atari_font_monochrom = 0, \ + .atari_dither = 1, \ + .atari_transparency = 1, \ + .atari_face_sans_serif = NULL, \ + .atari_face_sans_serif_bold = NULL, \ + .atari_face_sans_serif_italic = NULL, \ + .atari_face_sans_serif_italic_bold = NULL, \ + .atari_face_monospace = NULL, \ + .atari_face_monospace_bold = NULL, \ + .atari_face_serif = NULL, \ + .atari_face_serif_bold = NULL, \ + .atari_face_cursive = NULL, \ + .atari_face_fantasy = NULL, \ + .atari_editor = (char*)"", \ + .downloads_path = (char*)"", \ + .url_file = (char*)"url.db", \ + .hotlist_file = (char*)"hotlist", \ + .tree_icons_path = (char*)"./res/icons" + +#define NSOPTION_EXTRA_TABLE \ + { "atari_screen_driver", OPTION_STRING, &nsoptions.atari_screen_driver },\ + { "atari_font_driver", OPTION_STRING, &nsoptions.atari_font_driver },\ + { "atari_font_monochrom", OPTION_INTEGER, &nsoptions.atari_font_monochrom },\ + { "atari_transparency", OPTION_INTEGER, &nsoptions.atari_transparency },\ + { "atari_dither", OPTION_INTEGER, &nsoptions.atari_dither },\ + { "atari_editor", OPTION_STRING, &nsoptions.atari_editor },\ + { "font_face_sans_serif", OPTION_STRING, &nsoptions.atari_face_sans_serif },\ + { "font_face_sans_serif_bold", OPTION_STRING, &nsoptions.atari_face_sans_serif_bold },\ + { "font_face_sans_serif_italic", OPTION_STRING, &nsoptions.atari_face_sans_serif_italic },\ + { "font_face_sans_serif_italic_bold", OPTION_STRING, &nsoptions.atari_face_sans_serif_italic_bold },\ + { "font_face_monospace", OPTION_STRING, &nsoptions.atari_face_monospace },\ + { "font_face_monospace_bold", OPTION_STRING, &nsoptions.atari_face_monospace_bold },\ + { "font_face_serif", OPTION_STRING, &nsoptions.atari_face_serif },\ + { "font_face_serif_bold", OPTION_STRING, &nsoptions.atari_face_serif_bold },\ + { "font_face_cursive", OPTION_STRING, &nsoptions.atari_face_cursive },\ + { "font_face_fantasy", OPTION_STRING, &nsoptions.atari_face_fantasy },\ + { "downloads_path", OPTION_STRING, &nsoptions.downloads_path },\ + { "url_file", OPTION_STRING, &nsoptions.url_file },\ + { "hotlist_file", OPTION_STRING, &nsoptions.hotlist_file },\ + { "tree_icons_path", OPTION_STRING, &nsoptions.tree_icons_path } -#define EXTRA_OPTION_TABLE \ - { "atari_screen_driver", OPTION_STRING, &option_atari_screen_driver },\ - { "atari_font_driver", OPTION_STRING, &option_atari_font_driver },\ - { "atari_font_monochrom", OPTION_INTEGER, &option_atari_font_monochrom },\ - { "atari_transparency", OPTION_INTEGER, &option_atari_transparency },\ - { "atari_dither", OPTION_INTEGER, &option_atari_dither },\ - { "atari_editor", OPTION_STRING, &option_atari_editor },\ - { "font_face_sans_serif", OPTION_STRING, &option_atari_face_sans_serif },\ - { "font_face_sans_serif_bold", OPTION_STRING, &option_atari_face_sans_serif_bold },\ - { "font_face_sans_serif_italic", OPTION_STRING, &option_atari_face_sans_serif_italic },\ - { "font_face_sans_serif_italic_bold", OPTION_STRING, &option_atari_face_sans_serif_italic_bold },\ - { "font_face_monospace", OPTION_STRING, &option_atari_face_monospace },\ - { "font_face_monospace_bold", OPTION_STRING, &option_atari_face_monospace_bold },\ - { "font_face_serif", OPTION_STRING, &option_atari_face_serif },\ - { "font_face_serif_bold", OPTION_STRING, &option_atari_face_serif_bold },\ - { "font_face_cursive", OPTION_STRING, &option_atari_face_cursive },\ - { "font_face_fantasy", OPTION_STRING, &option_atari_face_fantasy },\ - { "downloads_path", OPTION_STRING, &option_downloads_path },\ - { "url_file", OPTION_STRING, &option_url_file },\ - { "hotlist_file", OPTION_STRING, &option_hotlist_file },\ - { "tree_icons_path", OPTION_STRING, &option_tree_icons_path } #endif diff --git a/atari/plot.c b/atari/plot.c index 25e433e13..1ce08a7e8 100755 --- a/atari/plot.c +++ b/atari/plot.c @@ -34,7 +34,6 @@ #include "atari/bitmap.h" #include "atari/gui.h" #include "atari/plot.h" -#include "atari/options.h" #include "desktop/options.h" #include "atari/plot.h" @@ -57,11 +56,11 @@ int atari_plotter_init( char* drvrname, char * fdrvrname ) int flags = 0; unsigned long font_flags = 0; - if( option_atari_dither == 1) + if( nsoption_int(atari_dither) == 1) flags |= PLOT_FLAG_DITHER; - if( option_atari_transparency == 1 ) + if( nsoption_int(atari_transparency) == 1 ) flags |= PLOT_FLAG_TRANS; - if( option_atari_font_monochrom == 1 ) + if( nsoption_int(atari_font_monochrom) == 1 ) font_flags |= FONTPLOT_FLAG_MONOGLYPH; vdih = app.graf.handle; diff --git a/atari/plot/font_freetype.c b/atari/plot/font_freetype.c index e62263ec7..551302e79 100755 --- a/atari/plot/font_freetype.c +++ b/atari/plot/font_freetype.c @@ -223,7 +223,7 @@ static bool ft_font_init(void) font_faces[FONT_FACE_SANS_SERIF] = NULL; font_faces[FONT_FACE_SANS_SERIF] = ft_new_face( - option_atari_face_sans_serif, + nsoption_charp(atari_face_sans_serif), "fonts/ss.ttf", DEJAVU_PATH"DejaVuSans.ttf" ); @@ -235,47 +235,47 @@ static bool ft_font_init(void) } font_faces[FONT_FACE_SANS_SERIF_BOLD] = - ft_new_face(option_atari_face_sans_serif_bold, + ft_new_face(nsoption_charp(atari_face_sans_serif_bold), "fonts/ssb.ttf", DEJAVU_PATH"DejaVuSans-Bold.ttf"); font_faces[FONT_FACE_SANS_SERIF_ITALIC] = - ft_new_face(option_atari_face_sans_serif_italic, + ft_new_face(nsoption_charp(atari_face_sans_serif_italic), "fonts/ssi.ttf", DEJAVU_PATH"DejaVuSans-Oblique.ttf"); font_faces[FONT_FACE_SANS_SERIF_ITALIC_BOLD] = - ft_new_face(option_atari_face_sans_serif_italic_bold, + ft_new_face(nsoption_charp(atari_face_sans_serif_italic_bold), "fonts/ssib.ttf", DEJAVU_PATH"DejaVuSans-BoldOblique.ttf"); font_faces[FONT_FACE_MONOSPACE] = - ft_new_face(option_atari_face_monospace, + ft_new_face(nsoption_charp(atari_face_monospace), "fonts/mono.ttf", DEJAVU_PATH"DejaVuSansMono.ttf"); font_faces[FONT_FACE_MONOSPACE_BOLD] = - ft_new_face(option_atari_face_monospace_bold, + ft_new_face(nsoption_charp(atari_face_monospace_bold), "fonts/monob.ttf", DEJAVU_PATH"DejaVuSansMono-Bold.ttf"); font_faces[FONT_FACE_SERIF] = - ft_new_face(option_atari_face_serif, + ft_new_face(nsoption_charp(atari_face_serif), "fonts/s.ttf", DEJAVU_PATH"DejaVuSerif.ttf"); font_faces[FONT_FACE_SERIF_BOLD] = - ft_new_face(option_atari_face_serif_bold, + ft_new_face(nsoption_charp(atari_face_serif_bold), "fonts/sb.ttf", DEJAVU_PATH"DejaVuSerif-Bold.ttf"); font_faces[FONT_FACE_CURSIVE] = - ft_new_face(option_atari_face_cursive, + ft_new_face(nsoption_charp(atari_face_cursive), "fonts/cursive.ttf", DEJAVU_PATH"DejaVuSansMono-Oblique.ttf"); font_faces[FONT_FACE_FANTASY] = - ft_new_face(option_atari_face_fantasy, + ft_new_face(nsoption_charp(atari_face_fantasy), "fonts/fantasy.ttf", DEJAVU_PATH"DejaVuSerifCondensed-Bold.ttf"); diff --git a/atari/plot/plotter.h b/atari/plot/plotter.h index ebaaec826..9ec4d2d64 100755 --- a/atari/plot/plotter.h +++ b/atari/plot/plotter.h @@ -32,7 +32,7 @@ #include "atari/osspec.h" #include "atari/gui.h" #include "atari/font.h" -#include "atari/options.h" +#include "desktop/options.h" #include "atari/findfile.h" #include "utils/utf8.h" #include "utils/log.h" diff --git a/atari/settings.c b/atari/settings.c index fa7c2d219..661ac0902 100644 --- a/atari/settings.c +++ b/atari/settings.c @@ -13,7 +13,6 @@ #include "atari/settings.h" #include "atari/global_evnt.h" #include "atari/misc.h" -#include "atari/options.h" extern char options[PATH_MAX]; @@ -193,8 +192,8 @@ saveform( WINDOW *win, int index, int unused, void *unused2) { apply_settings(); // Save settings - options_write( (const char*)&options ); - options_read( (const char*)&options ); + nsoption_write( (const char*)&options ); + nsoption_read( (const char*)&options ); close_settings(); ObjcChange( OC_FORM, win, index, NORMAL, TRUE); form_alert(1, "[1][Some options require an netsurf restart!][OK]"); @@ -479,111 +478,111 @@ static void display_settings( void ) // read current settings and display them /* "Browser" tab: */ - set_text( CHOICES_EDIT_HOMEPAGE, option_homepage_url, + set_text( CHOICES_EDIT_HOMEPAGE, nsoption_charp(homepage_url), INPUT_HOMEPAGE_URL_MAX_LEN ); - if( option_block_ads ){ + if( nsoption_bool(block_ads) ){ OBJ_CHECK( CHOICES_CB_HIDE_ADVERTISEMENT ); } else { OBJ_UNCHECK( CHOICES_CB_HIDE_ADVERTISEMENT ); } - if( option_target_blank ){ + if( nsoption_bool(target_blank) ){ OBJ_UNCHECK( CHOICES_CB_DISABLE_POPUP_WINDOWS ); } else { OBJ_CHECK( CHOICES_CB_DISABLE_POPUP_WINDOWS ); } - if( option_send_referer ){ + if( nsoption_bool(send_referer) ){ OBJ_CHECK( CHOICES_CB_SEND_HTTP_REFERRER ); } else { OBJ_UNCHECK( CHOICES_CB_SEND_HTTP_REFERRER ); } set_text( CHOICES_BT_SEL_LOCALE, - option_accept_language ? option_accept_language : (char*)"en", + nsoption_charp(accept_language) ? nsoption_charp(accept_language) : (char*)"en", INPUT_LOCALE_MAX_LEN ); - tmp_option_expire_url = option_expire_url; - sprintf( spare, "%02d", option_expire_url ); + tmp_option_expire_url = nsoption_int(expire_url); + sprintf( spare, "%02d", nsoption_int(expire_url) ); set_text( CHOICES_EDIT_HISTORY_AGE, spare, 2 ); /* "Cache" tab: */ - tmp_option_memory_cache_size = option_memory_cache_size / 100000; + tmp_option_memory_cache_size = nsoption_int(memory_cache_size) / 100000; sprintf( spare, "%03.1f", tmp_option_memory_cache_size ); set_text( CHOICES_STR_MAX_MEM_CACHE, spare, 5 ); /* "Paths" tab: */ - set_text( CHOICES_EDIT_DOWNLOAD_PATH, option_downloads_path, + set_text( CHOICES_EDIT_DOWNLOAD_PATH, nsoption_charp(downloads_path), LABEL_PATH_MAX_LEN ); - set_text( CHOICES_EDIT_HOTLIST_FILE, option_hotlist_file, + set_text( CHOICES_EDIT_HOTLIST_FILE, nsoption_charp(hotlist_file), LABEL_PATH_MAX_LEN ); - set_text( CHOICES_EDIT_CA_BUNDLE, option_ca_bundle, + set_text( CHOICES_EDIT_CA_BUNDLE, nsoption_charp(ca_bundle), LABEL_PATH_MAX_LEN ); - set_text( CHOICES_EDIT_CA_CERTS_PATH, option_ca_path, + set_text( CHOICES_EDIT_CA_CERTS_PATH, nsoption_charp(ca_path), LABEL_PATH_MAX_LEN ); - set_text( CHOICES_EDIT_EDITOR, option_atari_editor, + set_text( CHOICES_EDIT_EDITOR, nsoption_charp(atari_editor), LABEL_PATH_MAX_LEN ); /* "Rendering" tab: */ - set_text( CHOICES_BT_SEL_FONT_RENDERER, option_atari_font_driver, + set_text( CHOICES_BT_SEL_FONT_RENDERER, nsoption_charp(atari_font_driver), LABEL_FONT_RENDERER_MAX_LEN ); SET_BIT(dlgtree[CHOICES_CB_TRANSPARENCY].ob_state, - SELECTED, option_atari_transparency ? 1 : 0 ); + SELECTED, nsoption_int(atari_transparency) ? 1 : 0 ); SET_BIT(dlgtree[CHOICES_CB_ENABLE_ANIMATION].ob_state, - SELECTED, option_animate_images ? 1 : 0 ); + SELECTED, nsoption_bool(animate_images) ? 1 : 0 ); SET_BIT(dlgtree[CHOICES_CB_INCREMENTAL_REFLOW].ob_state, - SELECTED, option_incremental_reflow ? 1 : 0 ); + SELECTED, nsoption_bool(incremental_reflow) ? 1 : 0 ); SET_BIT(dlgtree[CHOICES_CB_ANTI_ALIASING].ob_state, - SELECTED, option_atari_font_monochrom ? 0 : 1 ); + SELECTED, nsoption_int(atari_font_monochrom) ? 0 : 1 ); - tmp_option_min_reflow_period = option_min_reflow_period; + tmp_option_min_reflow_period = nsoption_int(min_reflow_period); sprintf( spare, "%04d", tmp_option_min_reflow_period ); set_text( CHOICES_EDIT_MIN_REFLOW_PERIOD, spare, INPUT_MIN_REFLOW_PERIOD_MAX_LEN ); - tmp_option_minimum_gif_delay = (float)option_minimum_gif_delay / (float)100; + tmp_option_minimum_gif_delay = (float)nsoption_int(minimum_gif_delay) / (float)100; sprintf( spare, "%01.1f", tmp_option_minimum_gif_delay ); set_text( CHOICES_EDIT_MIN_GIF_DELAY, spare, 3 ); /* "Network" tab: */ - set_text( CHOICES_EDIT_PROXY_HOST, option_http_proxy_host, + set_text( CHOICES_EDIT_PROXY_HOST, nsoption_charp(http_proxy_host), INPUT_PROXY_HOST_MAX_LEN ); - sprintf( spare, "%5d", option_http_proxy_port ); + sprintf( spare, "%5d", nsoption_int(http_proxy_port) ); set_text( CHOICES_EDIT_PROXY_PORT, spare, INPUT_PROXY_PORT_MAX_LEN ); - set_text( CHOICES_EDIT_PROXY_USERNAME, option_http_proxy_auth_user, + set_text( CHOICES_EDIT_PROXY_USERNAME, nsoption_charp(http_proxy_auth_user), INPUT_PROXY_USERNAME_MAX_LEN ); - set_text( CHOICES_EDIT_PROXY_PASSWORD, option_http_proxy_auth_pass, + set_text( CHOICES_EDIT_PROXY_PASSWORD, nsoption_charp(http_proxy_auth_pass), INPUT_PROXY_PASSWORD_MAX_LEN ); SET_BIT(dlgtree[CHOICES_CB_USE_PROXY].ob_state, - SELECTED, option_http_proxy ? 1 : 0 ); + SELECTED, nsoption_bool(http_proxy) ? 1 : 0 ); SET_BIT(dlgtree[CHOICES_CB_PROXY_AUTH].ob_state, - SELECTED, option_http_proxy_auth ? 1 : 0 ); + SELECTED, nsoption_int(http_proxy_auth) ? 1 : 0 ); SET_BIT(dlgtree[CHOICES_CB_FG_IMAGES].ob_state, - SELECTED, option_foreground_images ? 1 : 0 ); + SELECTED, nsoption_bool(foreground_images) ? 1 : 0 ); SET_BIT(dlgtree[CHOICES_CB_BG_IMAGES].ob_state, - SELECTED, option_background_images ? 1 : 0 ); + SELECTED, nsoption_bool(background_images) ? 1 : 0 ); - tmp_option_max_cached_fetch_handles = option_max_cached_fetch_handles; - sprintf( spare, "%2d", option_max_cached_fetch_handles ); + tmp_option_max_cached_fetch_handles = nsoption_int(max_cached_fetch_handles); + sprintf( spare, "%2d", nsoption_int(max_cached_fetch_handles) ); set_text( CHOICES_EDIT_MAX_CACHED_CONNECTIONS, spare , 2 ); - tmp_option_max_fetchers = option_max_fetchers; - sprintf( spare, "%2d", option_max_fetchers ); + tmp_option_max_fetchers = nsoption_int(max_fetchers); + sprintf( spare, "%2d", nsoption_int(max_fetchers) ); set_text( CHOICES_EDIT_MAX_FETCHERS, spare , 2 ); - tmp_option_max_fetchers_per_host = option_max_fetchers_per_host; - sprintf( spare, "%2d", option_max_fetchers_per_host ); + tmp_option_max_fetchers_per_host = nsoption_int(max_fetchers_per_host); + sprintf( spare, "%2d", nsoption_int(max_fetchers_per_host) ); set_text( CHOICES_EDIT_MAX_FETCHERS_PER_HOST, spare , 2 ); /* "Style" tab: */ - tmp_option_font_min_size = option_font_min_size; - sprintf( spare, "%3d", option_font_min_size ); + tmp_option_font_min_size = nsoption_int(font_min_size); + sprintf( spare, "%3d", nsoption_int(font_min_size) ); set_text( CHOICES_EDIT_MIN_FONT_SIZE, spare , 3 ); - tmp_option_font_size = option_font_size; - sprintf( spare, "%3d", option_font_size ); + tmp_option_font_size = nsoption_int(font_size); + sprintf( spare, "%3d", nsoption_int(font_size) ); set_text( CHOICES_EDIT_DEF_FONT_SIZE, spare , 3 ); /* Only first tab is refreshed: */ @@ -595,64 +594,82 @@ static void display_settings( void ) static void apply_settings( void ) { - - /* "Network" tab: */ - option_http_proxy = OBJ_SELECTED(CHOICES_CB_USE_PROXY); - if( OBJ_SELECTED(CHOICES_CB_PROXY_AUTH) ) - option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_BASIC; - else - option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NONE; - option_http_proxy_auth_pass = - ObjcString( dlgtree, CHOICES_EDIT_PROXY_PASSWORD, NULL); - option_http_proxy_auth_user = - ObjcString( dlgtree, CHOICES_EDIT_PROXY_USERNAME, NULL); - option_http_proxy_host = - ObjcString( dlgtree, CHOICES_EDIT_PROXY_HOST, NULL); - option_http_proxy_port = - atoi( ObjcString( dlgtree, CHOICES_EDIT_PROXY_PORT, NULL) ); - option_max_fetchers_per_host = - atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_FETCHERS_PER_HOST, NULL)); - option_max_cached_fetch_handles = - atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_CACHED_CONNECTIONS, NULL)); - option_max_fetchers = - atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_FETCHERS, NULL) ); - option_foreground_images = OBJ_SELECTED( CHOICES_CB_FG_IMAGES ); - option_background_images = OBJ_SELECTED( CHOICES_CB_BG_IMAGES ); + nsoption_set_bool(http_proxy, OBJ_SELECTED(CHOICES_CB_USE_PROXY)); + if ( OBJ_SELECTED(CHOICES_CB_PROXY_AUTH) ) { + nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_BASIC); + } else { + nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE); + } + nsoption_set_charp(http_proxy_auth_pass, + ObjcString( dlgtree, CHOICES_EDIT_PROXY_PASSWORD, NULL)); + nsoption_set_charp(http_proxy_auth_user, + ObjcString( dlgtree, CHOICES_EDIT_PROXY_USERNAME, NULL)); + nsoption_set_charp(http_proxy_host, + ObjcString( dlgtree, CHOICES_EDIT_PROXY_HOST, NULL)); + nsoption_set_int(http_proxy_port, + atoi( ObjcString( dlgtree, CHOICES_EDIT_PROXY_PORT, NULL) )); + nsoption_set_int(max_fetchers_per_host, + atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_FETCHERS_PER_HOST, NULL))); + nsoption_set_int(max_cached_fetch_handles, + atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_CACHED_CONNECTIONS, NULL))); + nsoption_set_int(max_fetchers, + atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_FETCHERS, NULL) )); + nsoption_set_bool(foreground_images, + OBJ_SELECTED( CHOICES_CB_FG_IMAGES )); + nsoption_set_bool(background_images, + OBJ_SELECTED( CHOICES_CB_BG_IMAGES )); /* "Style" tab: */ - option_font_min_size = tmp_option_font_min_size; - option_font_size = tmp_option_font_size; + nsoption_set_int(font_min_size, tmp_option_font_min_size); + nsoption_set_int(font_size, tmp_option_font_size); /* "Rendering" tab: */ - option_atari_font_driver = ObjcString( dlgtree, - CHOICES_BT_SEL_FONT_RENDERER, NULL); - option_atari_transparency = OBJ_SELECTED(CHOICES_CB_TRANSPARENCY); - option_animate_images = OBJ_SELECTED(CHOICES_CB_ENABLE_ANIMATION); - option_minimum_gif_delay = (int)(tmp_option_minimum_gif_delay*100+0.5); - option_incremental_reflow = OBJ_SELECTED(CHOICES_CB_INCREMENTAL_REFLOW); - option_min_reflow_period = tmp_option_min_reflow_period; - option_atari_font_monochrom = !OBJ_SELECTED( CHOICES_CB_ANTI_ALIASING ); + nsoption_set_charp(atari_font_driver, + ObjcString( dlgtree, CHOICES_BT_SEL_FONT_RENDERER, NULL)); + nsoption_set_bool(atari_transparency, + OBJ_SELECTED(CHOICES_CB_TRANSPARENCY)); + nsoption_set_bool(animate_images, + OBJ_SELECTED(CHOICES_CB_ENABLE_ANIMATION)); + nsoption_set_int(minimum_gif_delay, + (int)(tmp_option_minimum_gif_delay*100+0.5)); + nsoption_set_bool(incremental_reflow, + OBJ_SELECTED(CHOICES_CB_INCREMENTAL_REFLOW)); + nsoption_set_int(min_reflow_period, tmp_option_min_reflow_period); + nsoption_set_int(atari_font_monochrom, + !OBJ_SELECTED( CHOICES_CB_ANTI_ALIASING )); /* "Paths" tabs: */ - option_ca_bundle = ObjcString( dlgtree, CHOICES_EDIT_CA_BUNDLE, NULL); - option_ca_path = ObjcString( dlgtree, CHOICES_EDIT_CA_CERTS_PATH, NULL); - option_homepage_url = ObjcString( dlgtree, CHOICES_EDIT_CA_CERTS_PATH, NULL); - option_hotlist_file = ObjcString( dlgtree, CHOICES_EDIT_HOTLIST_FILE, NULL); - option_atari_editor = ObjcString( dlgtree, CHOICES_EDIT_EDITOR, NULL); - option_downloads_path = ObjcString( dlgtree, CHOICES_EDIT_DOWNLOAD_PATH, NULL); + nsoption_set_charp(ca_bundle, + ObjcString( dlgtree, CHOICES_EDIT_CA_BUNDLE, NULL)); + nsoption_set_charp(ca_path, + ObjcString( dlgtree, CHOICES_EDIT_CA_CERTS_PATH, NULL)); + nsoption_set_charp(homepage_url, + ObjcString( dlgtree, CHOICES_EDIT_CA_CERTS_PATH, NULL)); + nsoption_set_charp(hotlist_file, + ObjcString( dlgtree, CHOICES_EDIT_HOTLIST_FILE, NULL)); + nsoption_set_charp(atari_editor, + ObjcString( dlgtree, CHOICES_EDIT_EDITOR, NULL)); + nsoption_set_charp(downloads_path, + ObjcString( dlgtree, CHOICES_EDIT_DOWNLOAD_PATH, NULL)); /* "Cache" tab: */ - option_memory_cache_size = tmp_option_memory_cache_size * 100000; + nsoption_set_int(memory_cache_size, + tmp_option_memory_cache_size * 100000); /* "Browser" tab: */ - option_target_blank = !OBJ_SELECTED(CHOICES_CB_DISABLE_POPUP_WINDOWS); - option_block_ads = OBJ_SELECTED(CHOICES_CB_HIDE_ADVERTISEMENT); - option_accept_language = ObjcString( dlgtree, CHOICES_BT_SEL_LOCALE, NULL); - option_expire_url = atoi(ObjcString( dlgtree, CHOICES_EDIT_HISTORY_AGE, - NULL)); - option_send_referer = OBJ_SELECTED(CHOICES_CB_SEND_HTTP_REFERRER); - option_homepage_url = ObjcString( dlgtree, CHOICES_EDIT_HOMEPAGE, NULL); + nsoption_set_bool(target_blank, + !OBJ_SELECTED(CHOICES_CB_DISABLE_POPUP_WINDOWS)); + nsoption_set_bool(block_ads, + OBJ_SELECTED(CHOICES_CB_HIDE_ADVERTISEMENT)); + nsoption_set_charp(accept_language, + ObjcString( dlgtree, CHOICES_BT_SEL_LOCALE, NULL)); + nsoption_set_int(expire_url, + atoi(ObjcString( dlgtree, CHOICES_EDIT_HISTORY_AGE, NULL))); + nsoption_set_bool(send_referer, + OBJ_SELECTED(CHOICES_CB_SEND_HTTP_REFERRER)); + nsoption_set_charp(homepage_url, + ObjcString( dlgtree, CHOICES_EDIT_HOMEPAGE, NULL)); } #undef OBJ_SELECTED diff --git a/atari/system_colour.c b/atari/system_colour.c index 69ce5a88c..c0c125b9b 100644 --- a/atari/system_colour.c +++ b/atari/system_colour.c @@ -44,170 +44,170 @@ static struct gui_system_colour_ctx colour_list[] = { "ActiveBorder", SLEN("ActiveBorder"), 0xff000000, - &option_sys_colour_ActiveBorder, + &nsoption_colour(sys_colour_ActiveBorder), NULL }, { "ActiveCaption", SLEN("ActiveCaption"), 0xffdddddd, - &option_sys_colour_ActiveCaption, + &nsoption_colour(sys_colour_ActiveCaption), NULL }, { "AppWorkspace", SLEN("AppWorkspace"), 0xffeeeeee, - &option_sys_colour_AppWorkspace, + &nsoption_colour(sys_colour_AppWorkspace), NULL }, { "Background", SLEN("Background"), 0xff0000aa, - &option_sys_colour_Background, + &nsoption_colour(sys_colour_Background), NULL }, { "ButtonFace", SLEN("ButtonFace"), 0xffaaaaaa, - &option_sys_colour_ButtonFace, + &nsoption_colour(sys_colour_ButtonFace), NULL }, { "ButtonHighlight", SLEN("ButtonHighlight"), 0xffdddddd, - &option_sys_colour_ButtonHighlight, + &nsoption_colour(sys_colour_ButtonHighlight), NULL }, { "ButtonShadow", SLEN("ButtonShadow"), 0xffbbbbbb, - &option_sys_colour_ButtonShadow, + &nsoption_colour(sys_colour_ButtonShadow), NULL }, { "ButtonText", SLEN("ButtonText"), 0xff000000, - &option_sys_colour_ButtonText, + &nsoption_colour(sys_colour_ButtonText), NULL }, { "CaptionText", SLEN("CaptionText"), 0xff000000, - &option_sys_colour_CaptionText, + &nsoption_colour(sys_colour_CaptionText), NULL }, { "GrayText", SLEN("GrayText"), 0xffcccccc, - &option_sys_colour_GrayText, + &nsoption_colour(sys_colour_GrayText), NULL }, { "Highlight", SLEN("Highlight"), 0xff0000ee, - &option_sys_colour_Highlight, + &nsoption_colour(sys_colour_Highlight), NULL }, { "HighlightText", SLEN("HighlightText"), 0xff000000, - &option_sys_colour_HighlightText, + &nsoption_colour(sys_colour_HighlightText), NULL }, { "InactiveBorder", SLEN("InactiveBorder"), 0xffffffff, - &option_sys_colour_InactiveBorder, + &nsoption_colour(sys_colour_InactiveBorder), NULL }, { "InactiveCaption", SLEN("InactiveCaption"), 0xffffffff, - &option_sys_colour_InactiveCaption, + &nsoption_colour(sys_colour_InactiveCaption), NULL }, { "InactiveCaptionText", SLEN("InactiveCaptionText"), 0xffcccccc, - &option_sys_colour_InactiveCaptionText, + &nsoption_colour(sys_colour_InactiveCaptionText), NULL }, { "InfoBackground", SLEN("InfoBackground"), 0xffaaaaaa, - &option_sys_colour_InfoBackground, + &nsoption_colour(sys_colour_InfoBackground), NULL }, { "InfoText", SLEN("InfoText"), 0xff000000, - &option_sys_colour_InfoText, + &nsoption_colour(sys_colour_InfoText), NULL }, { "Menu", SLEN("Menu"), 0xffaaaaaa, - &option_sys_colour_Menu, + &nsoption_colour(sys_colour_Menu), NULL }, { "MenuText", SLEN("MenuText"), 0xff000000, - &option_sys_colour_MenuText, + &nsoption_colour(sys_colour_MenuText), NULL }, { "Scrollbar", SLEN("Scrollbar"), 0xffaaaaaa, - &option_sys_colour_Scrollbar, + &nsoption_colour(sys_colour_Scrollbar), NULL }, { "ThreeDDarkShadow", SLEN("ThreeDDarkShadow"), 0xff555555, - &option_sys_colour_ThreeDDarkShadow, + &nsoption_colour(sys_colour_ThreeDDarkShadow), NULL }, { "ThreeDFace", SLEN("ThreeDFace"), 0xffdddddd, - &option_sys_colour_ThreeDFace, + &nsoption_colour(sys_colour_ThreeDFace), NULL }, { "ThreeDHighlight", SLEN("ThreeDHighlight"), 0xffaaaaaa, - &option_sys_colour_ThreeDHighlight, + &nsoption_colour(sys_colour_ThreeDHighlight), NULL }, { "ThreeDLightShadow", SLEN("ThreeDLightShadow"), 0xff999999, - &option_sys_colour_ThreeDLightShadow, + &nsoption_colour(sys_colour_ThreeDLightShadow), NULL }, { "ThreeDShadow", SLEN("ThreeDShadow"), 0xff777777, - &option_sys_colour_ThreeDShadow, + &nsoption_colour(sys_colour_ThreeDShadow), NULL }, { "Window", SLEN("Window"), 0xffaaaaaa, - &option_sys_colour_Window, + &nsoption_colour(sys_colour_Window), NULL }, { "WindowFrame", SLEN("WindowFrame"), 0xff000000, - &option_sys_colour_WindowFrame, + &nsoption_colour(sys_colour_WindowFrame), NULL }, { "WindowText", SLEN("WindowText"), 0xff000000, - &option_sys_colour_WindowText, + &nsoption_colour(sys_colour_WindowText), NULL }, diff --git a/beos/beos_font.cpp b/beos/beos_font.cpp index eca2fab9e..5c7d1caf8 100644 --- a/beos/beos_font.cpp +++ b/beos/beos_font.cpp @@ -296,20 +296,20 @@ void nsbeos_style_to_font(BFont &font, const plot_font_style_t *fstyle) switch (fstyle->family) { case PLOT_FONT_FAMILY_SERIF: - family = option_font_serif; + family = nsoption_charp(font_serif); break; case PLOT_FONT_FAMILY_MONOSPACE: - family = option_font_mono; + family = nsoption_charp(font_mono); break; case PLOT_FONT_FAMILY_CURSIVE: - family = option_font_cursive; + family = nsoption_charp(font_cursive); break; case PLOT_FONT_FAMILY_FANTASY: - family = option_font_fantasy; + family = nsoption_charp(font_fantasy); break; case PLOT_FONT_FAMILY_SANS_SERIF: default: - family = option_font_sans; + family = nsoption_charp(font_sans); break; } diff --git a/beos/beos_gui.cpp b/beos/beos_gui.cpp index e535b3658..f6abd43a5 100644 --- a/beos/beos_gui.cpp +++ b/beos/beos_gui.cpp @@ -436,8 +436,8 @@ static void gui_init2(int argc, char** argv) CALLED(); const char *addr = NETSURF_HOMEPAGE; - if (option_homepage_url != NULL && option_homepage_url[0] != '\0') - addr = option_homepage_url; + if (nsoption_charp(homepage_url) != NULL) + addr = nsoption_charp(homepage_url); if (argc > 1) addr = argv[1]; if (gFirstRefsReceived) addr = NULL; @@ -544,78 +544,79 @@ void gui_init(int argc, char** argv) find_resource(buf, "Choices", "%/Choices"); LOG(("Using '%s' as Preferences file", buf)); options_file_location = strdup(buf); - options_read(buf); + nsoption_read(buf); /* check what the font settings are, setting them to a default font * if they're not set - stops Pango whinging */ -#define SETFONTDEFAULT(x,y) (x) = ((x) != NULL) ? (x) : strdup((y)) + //XXX: use be_plain_font & friends, when we can check if font is serif or not. /* font_family family; font_style style; be_plain_font->GetFamilyAndStyle(&family, &style); - SETFONTDEFAULT(option_font_sans, family); - SETFONTDEFAULT(option_font_serif, family); - SETFONTDEFAULT(option_font_mono, family); - SETFONTDEFAULT(option_font_cursive, family); - SETFONTDEFAULT(option_font_fantasy, family); + nsoption_setnull_charp(font_sans, family); + nsoption_setnull_charp(font_serif, family); + nsoption_setnull_charp(font_mono, family); + nsoption_setnull_charp(font_cursive, family); + nsoption_setnull_charp(font_fantasy, family); */ #ifdef __HAIKU__ - SETFONTDEFAULT(option_font_sans, "DejaVu Sans"); - SETFONTDEFAULT(option_font_serif, "DejaVu Serif"); - SETFONTDEFAULT(option_font_mono, "DejaVu Mono"); - SETFONTDEFAULT(option_font_cursive, "DejaVu Sans"); - SETFONTDEFAULT(option_font_fantasy, "DejaVu Sans"); + nsoption_setnull_charp(font_sans, "DejaVu Sans"); + nsoption_setnull_charp(font_serif, "DejaVu Serif"); + nsoption_setnull_charp(font_mono, "DejaVu Mono"); + nsoption_setnull_charp(font_cursive, "DejaVu Sans"); + nsoption_setnull_charp(font_fantasy, "DejaVu Sans"); #else - SETFONTDEFAULT(option_font_sans, "Bitstream Vera Sans"); - SETFONTDEFAULT(option_font_serif, "Bitstream Vera Serif"); - SETFONTDEFAULT(option_font_mono, "Bitstream Vera Sans Mono"); - SETFONTDEFAULT(option_font_cursive, "Bitstream Vera Serif"); - SETFONTDEFAULT(option_font_fantasy, "Bitstream Vera Serif"); + nsoption_setnull_charp(font_sans, "Bitstream Vera Sans"); + nsoption_setnull_charp(font_serif, "Bitstream Vera Serif"); + nsoption_setnull_charp(font_mono, "Bitstream Vera Sans Mono"); + nsoption_setnull_charp(font_cursive, "Bitstream Vera Serif"); + nsoption_setnull_charp(font_fantasy, "Bitstream Vera Serif"); #if 0 - SETFONTDEFAULT(option_font_sans, "Swis721 BT"); - SETFONTDEFAULT(option_font_serif, "Dutch801 Rm BT"); - //SETFONTDEFAULT(option_font_mono, "Monospac821 BT"); - SETFONTDEFAULT(option_font_mono, "Courier10 BT"); - SETFONTDEFAULT(option_font_cursive, "Swis721 BT"); - SETFONTDEFAULT(option_font_fantasy, "Swis721 BT"); + nsoption_setnull_charp(font_sans, "Swis721 BT"); + nsoption_setnull_charp(font_serif, "Dutch801 Rm BT"); + //nsoption_setnull_charp(font_mono, "Monospac821 BT"); + nsoption_setnull_charp(font_mono, "Courier10 BT"); + nsoption_setnull_charp(font_cursive, "Swis721 BT"); + nsoption_setnull_charp(font_fantasy, "Swis721 BT"); #endif #endif nsbeos_options_init(); - if (!option_cookie_file) { + if (nsoption_charp(cookie_file) == NULL) { find_resource(buf, "Cookies", "%/Cookies"); LOG(("Using '%s' as Cookies file", buf)); - option_cookie_file = strdup(buf); + nsoption_set_charp(cookie_file, strdup(buf)); } - if (!option_cookie_jar) { + if (nsoption_charp(cookie_jar) == NULL) { find_resource(buf, "Cookies", "%/Cookies"); LOG(("Using '%s' as Cookie Jar file", buf)); - option_cookie_jar = strdup(buf); + nsoption_set_charp(cookie_jar, strdup(buf)); } - if (!option_cookie_file || !option_cookie_jar) + if ((nsoption_charp(cookie_file) == NULL) || + (nsoption_charp(cookie_jar) == NULL)) die("Failed initialising cookie options"); - if (!option_url_file) { + if (nsoption_charp(url_file) == NULL) { find_resource(buf, "URLs", "%/URLs"); LOG(("Using '%s' as URL file", buf)); - option_url_file = strdup(buf); + onsption_set_charp(url_file, strdup(buf)); } - if (!option_ca_path) { + if (nsoption_charp(ca_path) == NULL) { find_resource(buf, "certs", "/etc/ssl/certs"); LOG(("Using '%s' as certificate path", buf)); - option_ca_path = strdup(buf); + nsoption_set_charp(ca_path, strdup(buf)); } //find_resource(buf, "mime.types", "/etc/mime.types"); beos_fetch_filetype_init(); - urldb_load(option_url_file); - urldb_load_cookies(option_cookie_file); + urldb_load(nsoption_charp(url_file)); + urldb_load_cookies(nsoption_charp(cookie_file)); //nsbeos_download_initialise(); @@ -736,12 +737,12 @@ void gui_poll(bool active) void gui_quit(void) { CALLED(); - urldb_save_cookies(option_cookie_jar); - urldb_save(option_url_file); - //options_save_tree(hotlist,option_hotlist_file,messages_get("TreeHotlist")); + urldb_save_cookies(nsoption_charp(cookie_jar)); + urldb_save(nsoption_charp(url_file)); + //options_save_tree(hotlist,nsoption_charp(hotlist_file),messages_get("TreeHotlist")); - free(option_cookie_file); - free(option_cookie_jar); + free(nsoption_charp(cookie_file)); + free(nsoption_charp(cookie_jar)); beos_fetch_filetype_fin(); fetch_rsrc_unregister(); } diff --git a/beos/beos_options.cpp b/beos/beos_options.cpp index 6e492a6a4..ff88349b7 100644 --- a/beos/beos_options.cpp +++ b/beos/beos_options.cpp @@ -29,247 +29,22 @@ extern "C" { #include "beos/beos_gui.h" #include "beos/beos_scaffolding.h" #include "beos/beos_options.h" -//#include "beos/beos_window.h" + #include #include BWindow *wndPreferences; -#if 0 /* GTK */ -GtkWindow *wndPreferences; - -static GtkWidget *entryHomePageURL, - *checkHideAdverts, - *checkDisablePopups, - *checkDisablePlugins, - *spinHistoryAge, - *checkHoverURLs, - *checkRequestOverwrite, - *checkDisplayRecentURLs, - *checkSendReferer, - - *comboProxyType, - *entryProxyHost, - *entryProxyPort, - *entryProxyUser, - *entryProxyPassword, - *spinMaxFetchers, - *spinFetchesPerHost, - *spinCachedConnections, - - *checkUseCairo, - *checkResampleImages, - *spinAnimationSpeed, - *checkDisableAnimations, - - *fontSansSerif, - *fontSerif, - *fontMonospace, - *fontCursive, - *fontFantasy, - *comboDefault, - *spinDefaultSize, - *spinMinimumSize, - - *spinMemoryCacheSize, - *spinDiscCacheAge; - -#define FIND_WIDGET(x) (x) = glade_xml_get_widget(gladeWindows, #x); if ((x) == NULL) LOG(("Unable to find widget '%s'!", #x)) -#endif - void nsbeos_options_init(void) { -#if 0 /* GTK */ - wndPreferences = GTK_WINDOW(glade_xml_get_widget(gladeWindows, - "wndPreferences")); - - /* get widget objects */ - FIND_WIDGET(entryHomePageURL); - FIND_WIDGET(checkHideAdverts); - FIND_WIDGET(checkDisablePopups); - FIND_WIDGET(checkDisablePlugins); - FIND_WIDGET(spinHistoryAge); - FIND_WIDGET(checkHoverURLs); - FIND_WIDGET(checkRequestOverwrite); - FIND_WIDGET(checkDisplayRecentURLs); - FIND_WIDGET(checkSendReferer); - - FIND_WIDGET(comboProxyType); - FIND_WIDGET(entryProxyHost); - FIND_WIDGET(entryProxyPort); - FIND_WIDGET(entryProxyUser); - FIND_WIDGET(entryProxyPassword); - FIND_WIDGET(spinMaxFetchers); - FIND_WIDGET(spinFetchesPerHost); - FIND_WIDGET(spinCachedConnections); - - FIND_WIDGET(checkUseCairo); - FIND_WIDGET(checkResampleImages); - FIND_WIDGET(spinAnimationSpeed); - FIND_WIDGET(checkDisableAnimations); - - FIND_WIDGET(fontSansSerif); - FIND_WIDGET(fontSerif); - FIND_WIDGET(fontMonospace); - FIND_WIDGET(fontCursive); - FIND_WIDGET(fontFantasy); - FIND_WIDGET(comboDefault); - FIND_WIDGET(spinDefaultSize); - FIND_WIDGET(spinMinimumSize); - - FIND_WIDGET(spinMemoryCacheSize); - FIND_WIDGET(spinDiscCacheAge); - -#endif /* set the widgets to reflect the current options */ nsbeos_options_load(); } -#if 0 /* GTK */ -#define SET_ENTRY(x, y) gtk_entry_set_text(GTK_ENTRY((x)), (y)) -#define SET_SPIN(x, y) gtk_spin_button_set_value(GTK_SPIN_BUTTON((x)), (y)) -#define SET_CHECK(x, y) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((x)), (y)) -#define SET_COMBO(x, y) gtk_combo_box_set_active(GTK_COMBO_BOX((x)), (y)) -#define SET_FONT(x, y) gtk_font_button_set_font_name(GTK_FONT_BUTTON((x)), (y)) -#endif - void nsbeos_options_load(void) { #warning WRITEME -#if 0 /* GTK */ - char b[20]; - int proxytype = 0; - - SET_ENTRY(entryHomePageURL, - option_homepage_url ? option_homepage_url : ""); - SET_CHECK(checkHideAdverts, option_block_ads); - SET_CHECK(checkDisplayRecentURLs, option_url_suggestion); - SET_CHECK(checkSendReferer, option_send_referer); - - switch (option_http_proxy_auth) { - case OPTION_HTTP_PROXY_AUTH_NONE: - proxytype = 1; - break; - case OPTION_HTTP_PROXY_AUTH_BASIC: - proxytype = 2; - break; - case OPTION_HTTP_PROXY_AUTH_NTLM: - proxytype = 3; - break; - } - - if (option_http_proxy == false) - proxytype = 0; - - SET_COMBO(comboProxyType, proxytype); - SET_ENTRY(entryProxyHost, - option_http_proxy_host ? option_http_proxy_host : ""); - snprintf(b, 20, "%d", option_http_proxy_port); - SET_ENTRY(entryProxyPort, b); - SET_ENTRY(entryProxyUser, option_http_proxy_auth_user ? - option_http_proxy_auth_user : ""); - SET_ENTRY(entryProxyPassword, option_http_proxy_auth_pass ? - option_http_proxy_auth_pass : ""); - - SET_SPIN(spinMaxFetchers, option_max_fetchers); - SET_SPIN(spinFetchesPerHost, option_max_fetchers_per_host); - SET_SPIN(spinCachedConnections, option_max_cached_fetch_handles); - - SET_CHECK(checkUseCairo, option_render_cairo); - SET_CHECK(checkResampleImages, option_render_resample); - SET_SPIN(spinAnimationSpeed, option_minimum_gif_delay / 100); - SET_CHECK(checkDisableAnimations, !option_animate_images); - - SET_FONT(fontSansSerif, option_font_sans); - SET_FONT(fontSerif, option_font_serif); - SET_FONT(fontMonospace, option_font_mono); - SET_FONT(fontCursive, option_font_cursive); - SET_FONT(fontFantasy, option_font_fantasy); - SET_COMBO(comboDefault, option_font_default - 1); - SET_SPIN(spinDefaultSize, option_font_size / 10); - SET_SPIN(spinMinimumSize, option_font_min_size / 10); - - SET_SPIN(spinMemoryCacheSize, option_memory_cache_size >> 20); - SET_SPIN(spinDiscCacheAge, option_disc_cache_age); -#endif } -#if 0 /* GTK */ -#define GET_ENTRY(x, y) if ((y)) free((y)); \ - (y) = strdup(gtk_entry_get_text(GTK_ENTRY((x)))) -#define GET_CHECK(x, y) (y) = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON((x))) -#define GET_SPIN(x, y) (y) = gtk_spin_button_get_value(GTK_SPIN_BUTTON((x))) -#define GET_COMBO(x, y) (y) = gtk_combo_box_get_active(GTK_COMBO_BOX((x))) -#define GET_FONT(x, y) if ((y)) free((y)); \ - (y) = strdup(gtk_font_button_get_font_name(GTK_FONT_BUTTON((x)))) -#endif void nsbeos_options_save(void) { #warning WRITEME -#if 0 /* GTK */ - char *b = NULL; - int i; - - GET_ENTRY(entryHomePageURL, option_homepage_url); - GET_CHECK(checkDisplayRecentURLs, option_url_suggestion); - - GET_COMBO(comboProxyType, i); - LOG(("proxy type: %d", i)); - switch (i) - { - case 0: - option_http_proxy = false; - option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NONE; - break; - case 1: - option_http_proxy = true; - option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NONE; - break; - case 2: - option_http_proxy = true; - option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_BASIC; - break; - case 3: - option_http_proxy = true; - option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NTLM; - break; - default: - option_http_proxy = false; - option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NONE; - break; - } - - GET_ENTRY(entryProxyHost, option_http_proxy_host); - GET_ENTRY(entryProxyPort, b); - option_http_proxy_port = atoi(b); - free(b); - GET_ENTRY(entryProxyUser, option_http_proxy_auth_user); - GET_ENTRY(entryProxyPassword, option_http_proxy_auth_pass); - - GET_SPIN(spinMaxFetchers, option_max_fetchers); - GET_SPIN(spinFetchesPerHost, option_max_fetchers_per_host); - GET_SPIN(spinCachedConnections, option_max_cached_fetch_handles); - - GET_CHECK(checkUseCairo, option_render_cairo); - GET_CHECK(checkResampleImages, option_render_resample); - GET_SPIN(spinAnimationSpeed, option_minimum_gif_delay); - option_minimum_gif_delay *= 100; - - GET_FONT(fontSansSerif, option_font_sans); - GET_FONT(fontSerif, option_font_serif); - GET_FONT(fontMonospace, option_font_mono); - GET_FONT(fontCursive, option_font_cursive); - GET_FONT(fontFantasy, option_font_fantasy); - GET_COMBO(comboDefault, option_font_default); - option_font_default++; - - GET_SPIN(spinDefaultSize, option_font_size); - option_font_size *= 10; - GET_SPIN(spinMinimumSize, option_font_min_size); - option_font_min_size *= 10; - - GET_SPIN(spinMemoryCacheSize, option_memory_cache_size); - option_memory_cache_size <<= 20; - - options_write(options_file_location); - nsgtk_reflow_all_windows(); -#endif } diff --git a/beos/beos_plotters.cpp b/beos/beos_plotters.cpp index ee8d312d2..adc9588b3 100644 --- a/beos/beos_plotters.cpp +++ b/beos/beos_plotters.cpp @@ -155,7 +155,7 @@ bool nsbeos_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *s nsbeos_set_colour(style->fill_colour); nsbeos_set_solid(); #ifdef CAIRO_VERSION - if (option_render_cairo) { + if (nsoption_bool(render_cairo)) { cairo_set_line_width(current_cr, 0); cairo_rectangle(current_cr, x0, y0, x1 - x0, y1 - y0); cairo_fill(current_cr); @@ -206,7 +206,7 @@ bool nsbeos_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *s #if 0 /* GTK */ #ifdef CAIRO_VERSION - if (option_render_cairo) { + if (nsoption_bool(render_cairo)) { if (line_width == 0) line_width = 1; @@ -267,7 +267,7 @@ bool nsbeos_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style) #if 0 /* GTK */ #ifdef CAIRO_VERSION - if (option_render_cairo) { + if (nsoption_bool(render_cairo)) { if (width == 0) width = 1; @@ -337,7 +337,7 @@ bool nsbeos_plot_clip(const struct rect *ns_clip) #if 0 /* GTK */ #ifdef CAIRO_VERSION - if (option_render_cairo) { + if (nsoption_bool(render_cairo)) { cairo_reset_clip(current_cr); cairo_rectangle(current_cr, clip->x0, clip->y0, clip->x1 - clip->x0, clip->y1 - clip->y0); @@ -385,7 +385,7 @@ bool nsbeos_plot_disc(int x, int y, int radius, const plot_style_t *style) nsbeos_set_colour(c); nsbeos_set_solid(); #ifdef CAIRO_VERSION - if (option_render_cairo) { + if (nsoption_bool(render_cairo)) { if (filled) cairo_set_line_width(current_cr, 0); else @@ -432,7 +432,7 @@ bool nsbeos_plot_arc(int x, int y, int radius, int angle1, int angle2, const plo nsbeos_set_colour(style->fill_colour); nsbeos_set_solid(); #ifdef CAIRO_VERSION - if (option_render_cairo) { + if (nsoption_bool(render_cairo)) { cairo_set_line_width(current_cr, 1); cairo_arc(current_cr, x, y, radius, (angle1 + 90) * (M_PI / 180), @@ -516,7 +516,7 @@ static bool nsbeos_plot_bbitmap(int x, int y, int width, int height, GdkPixbuf *scaled; scaled = gdk_pixbuf_scale_simple(pixbuf, width, height, - option_render_resample ? GDK_INTERP_BILINEAR + nsoption_bool(render_resample) ? GDK_INTERP_BILINEAR : GDK_INTERP_NEAREST); if (!scaled) return false; @@ -772,7 +772,7 @@ void nsbeos_set_colour(colour c) &colour); gdk_gc_set_foreground(current_gc, &colour); #ifdef CAIRO_VERSION - if (option_render_cairo) + if (nsoption_bool(render_cairo)) cairo_set_source_rgba(current_cr, r / 255.0, g / 255.0, b / 255.0, 1.0); #endif diff --git a/beos/beos_scaffolding.cpp b/beos/beos_scaffolding.cpp index ba0ded909..0ba2004d9 100644 --- a/beos/beos_scaffolding.cpp +++ b/beos/beos_scaffolding.cpp @@ -824,8 +824,8 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m { static const char *addr = NETSURF_HOMEPAGE; - if (option_homepage_url != NULL && option_homepage_url[0] != '\0') - addr = option_homepage_url; + if (nsoption_charp(homepage_url) != NULL) + addr = nsoption_charp(homepage_url); browser_window_go(bw, addr, 0, true); break; @@ -1261,14 +1261,19 @@ MENUHANDLER(downloads) MENUHANDLER(save_window_size) { struct beos_scaffolding *gw = (struct beos_scaffolding *)g; + int x,y,w,h; - option_toolbar_status_width = beos_paned_get_position(gw->status_pane); - beos_window_get_position(gw->window, &option_window_x, &option_window_y); - beos_window_get_size(gw->window, &option_window_width, - &option_window_height); + nsoption_set_int(toolbar_status_width, + beos_paned_get_position(gw->status_pane)); + beos_window_get_position(gw->window, &x, &y); + beos_window_get_size(gw->window, &w, &h); + nsoption_set_int(window_x, x); + nsoption_set_int(window_y, y); + nsoption_set_int(window_width, w); + nsoption_set_int(window_height, h); - options_write(options_file_location); + nsoption_write(options_file_location); return TRUE; } @@ -1690,9 +1695,9 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel) if (!replicant_view) { BRect frame(0, 0, 600-1, 500-1); - if (option_window_width > 0) { - frame.Set(0, 0, option_window_width - 1, option_window_height - 1); - frame.OffsetToSelf(option_window_x, option_window_y); + if (nsoption_int(window_width) > 0) { + frame.Set(0, 0, nsoption_int(window_width) - 1, nsoption_int(window_height) - 1); + frame.OffsetToSelf(nsoption_int(window_x), nsoption_int(window_y)); } else { BPoint pos(50, 50); // XXX: use last BApplication::WindowAt()'s dynamic_cast Frame() @@ -2158,16 +2163,16 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel) /* set this window's size and position to what's in the options, or * or some sensible default if they're not set yet. */ - if (option_window_width > 0) { - beos_window_move(g->window, option_window_x, option_window_y); - beos_window_resize(g->window, option_window_width, - option_window_height); + if (nsoption_int(window_width) > 0) { + beos_window_move(g->window, nsoption_int(window_x), nsoption_int(window_y)); + beos_window_resize(g->window, nsoption_int(window_width), + nsoption_int(window_height)); } else { beos_window_set_default_size(g->window, 600, 600); } /* set the size of the hpane with status bar and h scrollbar */ - beos_paned_set_position(g->status_pane, option_toolbar_status_width); + beos_paned_set_position(g->status_pane, nsoption_int(toolbar_status_width)); /* set the URL entry box to expand, as we can't do this from within * glade because of the way it emulates toolbars. diff --git a/beos/beos_window.cpp b/beos/beos_window.cpp index 2e4db7e4c..9c608d50d 100644 --- a/beos/beos_window.cpp +++ b/beos/beos_window.cpp @@ -384,7 +384,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, if (clone != NULL) bw->scale = clone->scale; else - bw->scale = (float) option_scale / 100; + bw->scale = (float) nsoption_int(scale) / 100; g->careth = 0; g->pending_resizes = 0; diff --git a/beos/options.h b/beos/options.h index 9ea69ac92..9b8a3d109 100644 --- a/beos/options.h +++ b/beos/options.h @@ -17,19 +17,23 @@ * along with this program. If not, see . */ +#ifndef _NETSURF_DESKTOP_OPTIONS_INCLUDING_ +#error "Frontend options header cannot be included directly" +#endif + #ifndef _NETSURF_BEOS_OPTIONS_H_ #define _NETSURF_BEOS_OPTIONS_H_ -#include "desktop/options.h" +#define NSOPTION_EXTRA_DEFINE \ + bool render_resample; \ + char *url_file -extern bool option_render_resample; -extern char *option_url_file; +#define NSOPTION_EXTRA_DEFAULTS \ + .render_resample = false, \ + .url_file = 0 -#define EXTRA_OPTION_DEFINE \ -bool option_render_resample = false; \ -char *option_url_file = 0; +#define NSOPTION_EXTRA_TABLE \ + { "render_resample", OPTION_BOOL, &nsoptions.render_resample }, \ + { "url_file", OPTION_STRING, &nsoptions.url_file } -#define EXTRA_OPTION_TABLE \ -{ "render_resample", OPTION_BOOL, &option_render_resample }, \ -{ "url_file", OPTION_STRING, &option_url_file }, #endif diff --git a/beos/system_colour.cpp b/beos/system_colour.cpp index 9acf89757..1d03b35e6 100644 --- a/beos/system_colour.cpp +++ b/beos/system_colour.cpp @@ -85,189 +85,189 @@ static struct gui_system_colour_ctx colour_list[] = { "ActiveBorder", SLEN("ActiveBorder"), 0xff000000, - &option_sys_colour_ActiveBorder, + &nsoption_colour(sys_colour_ActiveBorder), NULL, NOCOL }, { "ActiveCaption", SLEN("ActiveCaption"), 0xffdddddd, - &option_sys_colour_ActiveCaption, + &nsoption_colour(sys_colour_ActiveCaption), NULL, B_WINDOW_TAB_COLOR }, { "AppWorkspace", SLEN("AppWorkspace"), 0xffeeeeee, - &option_sys_colour_AppWorkspace, + &nsoption_colour(sys_colour_AppWorkspace), NULL, B_PANEL_BACKGROUND_COLOR }, { "Background", SLEN("Background"), 0xff0000aa, - &option_sys_colour_Background, + &nsoption_colour(sys_colour_Background), NULL, B_DESKTOP_COLOR }, { "ButtonFace", SLEN("ButtonFace"), 0xffaaaaaa, - &option_sys_colour_ButtonFace, + &nsoption_colour(sys_colour_ButtonFace), NULL, B_CONTROL_BACKGROUND_COLOR }, { "ButtonHighlight", SLEN("ButtonHighlight"), 0xffdddddd, - &option_sys_colour_ButtonHighlight, + &nsoption_colour(sys_colour_ButtonHighlight), NULL, B_CONTROL_HIGHLIGHT_COLOR }, { "ButtonShadow", SLEN("ButtonShadow"), 0xffbbbbbb, - &option_sys_colour_ButtonShadow, + &nsoption_colour(sys_colour_ButtonShadow), NULL, NOCOL }, { "ButtonText", SLEN("ButtonText"), 0xff000000, - &option_sys_colour_ButtonText, + &nsoption_colour(sys_colour_ButtonText), NULL, B_CONTROL_TEXT_COLOR }, { "CaptionText", SLEN("CaptionText"), 0xff000000, - &option_sys_colour_CaptionText, + &nsoption_colour(sys_colour_CaptionText), NULL, NOCOL }, { "GrayText", SLEN("GrayText"), 0xffcccccc, - &option_sys_colour_GrayText, + &nsoption_colour(sys_colour_GrayText), NULL, NOCOL }, { "Highlight", SLEN("Highlight"), 0xff0000ee, - &option_sys_colour_Highlight, + &nsoption_colour(sys_colour_Highlight), NULL, NOCOL }, { "HighlightText", SLEN("HighlightText"), 0xff000000, - &option_sys_colour_HighlightText, + &nsoption_colour(sys_colour_HighlightText), NULL, NOCOL }, { "InactiveBorder", SLEN("InactiveBorder"), 0xffffffff, - &option_sys_colour_InactiveBorder, + &nsoption_colour(sys_colour_InactiveBorder), NULL, NOCOL }, { "InactiveCaption", SLEN("InactiveCaption"), 0xffffffff, - &option_sys_colour_InactiveCaption, + &nsoption_colour(sys_colour_InactiveCaption), NULL, NOCOL }, { "InactiveCaptionText", SLEN("InactiveCaptionText"), 0xffcccccc, - &option_sys_colour_InactiveCaptionText, + &nsoption_colour(sys_colour_InactiveCaptionText), NULL, NOCOL }, { "InfoBackground", SLEN("InfoBackground"), 0xffaaaaaa, - &option_sys_colour_InfoBackground, + &nsoption_colour(sys_colour_InfoBackground), NULL, B_TOOLTIP_BACKGROUND_COLOR }, { "InfoText", SLEN("InfoText"), 0xff000000, - &option_sys_colour_InfoText, + &nsoption_colour(sys_colour_InfoText), NULL, B_TOOLTIP_TEXT_COLOR }, { "Menu", SLEN("Menu"), 0xffaaaaaa, - &option_sys_colour_Menu, + &nsoption_colour(sys_colour_Menu), NULL, B_MENU_BACKGROUND_COLOR }, { "MenuText", SLEN("MenuText"), 0xff000000, - &option_sys_colour_MenuText, + &nsoption_colour(sys_colour_MenuText), NULL, B_MENU_ITEM_TEXT_COLOR }, { "Scrollbar", SLEN("Scrollbar"), 0xffaaaaaa, - &option_sys_colour_Scrollbar, + &nsoption_colour(sys_colour_Scrollbar), NULL, NOCOL }, { "ThreeDDarkShadow", SLEN("ThreeDDarkShadow"), 0xff555555, - &option_sys_colour_ThreeDDarkShadow, + &nsoption_colour(sys_colour_ThreeDDarkShadow), NULL, NOCOL }, { "ThreeDFace", SLEN("ThreeDFace"), 0xffdddddd, - &option_sys_colour_ThreeDFace, + &nsoption_colour(sys_colour_ThreeDFace), NULL, NOCOL }, { "ThreeDHighlight", SLEN("ThreeDHighlight"), 0xffaaaaaa, - &option_sys_colour_ThreeDHighlight, + &nsoption_colour(sys_colour_ThreeDHighlight), NULL, NOCOL }, { "ThreeDLightShadow", SLEN("ThreeDLightShadow"), 0xff999999, - &option_sys_colour_ThreeDLightShadow, + &nsoption_colour(sys_colour_ThreeDLightShadow), NULL, NOCOL }, { "ThreeDShadow", SLEN("ThreeDShadow"), 0xff777777, - &option_sys_colour_ThreeDShadow, + &nsoption_colour(sys_colour_ThreeDShadow), NULL, NOCOL }, { "Window", SLEN("Window"), 0xffaaaaaa, - &option_sys_colour_Window, + &nsoption_colour(sys_colour_Window), NULL, B_DOCUMENT_BACKGROUND_COLOR }, { "WindowFrame", SLEN("WindowFrame"), 0xff000000, - &option_sys_colour_WindowFrame, + &nsoption_colour(sys_colour_WindowFrame), NULL, NOCOL }, { @@ -275,7 +275,7 @@ static struct gui_system_colour_ctx colour_list[] = { "WindowText", SLEN("WindowText"), 0xff000000, - &option_sys_colour_WindowText, + &nsoption_colour(sys_colour_WindowText), NULL, B_DOCUMENT_TEXT_COLOR }, diff --git a/cocoa/BrowserViewController.m b/cocoa/BrowserViewController.m index b188dccf0..3ae0210c3 100644 --- a/cocoa/BrowserViewController.m +++ b/cocoa/BrowserViewController.m @@ -87,7 +87,7 @@ - (IBAction) zoomOriginal: (id) sender; { - browser_window_set_scale( browser, (float)option_scale / 100.0, true ); + browser_window_set_scale( browser, (float)nsoption_int(scale) / 100.0, true ); } - (IBAction) backForwardSelected: (id) sender; @@ -114,7 +114,7 @@ - (IBAction) goHome: (id) sender; { - browser_window_go( browser, option_homepage_url, NULL, true ); + browser_window_go( browser, nsoption_charp(homepage_url), NULL, true ); } - (IBAction) reloadPage: (id) sender; @@ -218,7 +218,7 @@ static inline bool compare_float( float a, float b ) } if (action == @selector( zoomOriginal: )) { - return !compare_float( browser->scale, (float)option_scale / 100.0 ); + return !compare_float( browser->scale, (float)nsoption_int(scale) / 100.0 ); } if (action == @selector( goBack: )) { diff --git a/cocoa/BrowserWindowController.m b/cocoa/BrowserWindowController.m index 343bd42e6..b709ec613 100644 --- a/cocoa/BrowserWindowController.m +++ b/cocoa/BrowserWindowController.m @@ -150,7 +150,7 @@ - (IBAction) newTab: (id) sender; { - browser_window_create( option_homepage_url, [activeBrowser browser], NULL, false, true ); + browser_window_create( nsoption_charp(homepage_url), [activeBrowser browser], NULL, false, true ); } - (IBAction) closeCurrentTab: (id) sender; diff --git a/cocoa/NetSurfAppDelegate.m b/cocoa/NetSurfAppDelegate.m index 80f29618e..651df1259 100644 --- a/cocoa/NetSurfAppDelegate.m +++ b/cocoa/NetSurfAppDelegate.m @@ -39,7 +39,7 @@ - (void) newDocument: (id) sender; { - browser_window_create( option_homepage_url, NULL, NULL, true, false ); + browser_window_create( nsoption_charp(homepage_url), NULL, NULL, true, false ); } - (void) openDocument: (id) sender; diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m index 2194b966c..e7ba6f036 100644 --- a/cocoa/NetsurfApp.m +++ b/cocoa/NetsurfApp.m @@ -62,27 +62,21 @@ nil]]; - if (NULL == option_cookie_file) { - option_cookie_file = strdup( [[defaults objectForKey: kCookiesFileOption] UTF8String] ); - } - - if (NULL == option_cookie_jar) { - option_cookie_jar = strdup( option_cookie_file ); - } - - if (NULL == option_homepage_url) { - option_homepage_url = strdup( [[defaults objectForKey: kHomepageURLOption] UTF8String] ); - } + nsoption_setnull(cookie_file, strdup( [[defaults objectForKey: kCookiesFileOption] UTF8String] )); + + nsoption_setnull(cookie_jar, strdup( nsoption_charp(cookie_file) )); + + nsoption_setnull(homepage_url, strdup( [[defaults objectForKey: kHomepageURLOption] UTF8String] )); urldb_load( [[defaults objectForKey: kURLsFileOption] UTF8String] ); - urldb_load_cookies( option_cookie_file ); + urldb_load_cookies( nsoption_charp(cookie_file) ); cocoa_update_scale_factor(); } - (void) saveOptions; { - urldb_save_cookies( option_cookie_file ); + urldb_save_cookies( nsoption_charp(cookie_file) ); urldb_save( [[[NSUserDefaults standardUserDefaults] objectForKey: kURLsFileOption] UTF8String] ); } @@ -178,9 +172,7 @@ int main( int argc, char **argv ) const char * const options = cocoa_get_options_file(); const char * const ca_bundle = [[[NSBundle mainBundle] pathForResource: @"ca-bundle" ofType: @""] UTF8String]; - if (ca_bundle != NULL) { - option_ca_bundle = strdup(ca_bundle); - } + nsoption_setnull(ca_bundle, strdup(ca_bundle)); netsurf_init(&argc, &argv, options, messages); diff --git a/cocoa/PreferencesWindowController.m b/cocoa/PreferencesWindowController.m index adba8cf75..7038647f9 100644 --- a/cocoa/PreferencesWindowController.m +++ b/cocoa/PreferencesWindowController.m @@ -44,15 +44,14 @@ - (void) setHomepageURL: (NSString *) newUrl; { - free( option_homepage_url ); - option_homepage_url = strdup( [newUrl UTF8String] ); + nsoption_set_charp(homepage_url, strdup( [newUrl UTF8String] )); [[NSUserDefaults standardUserDefaults] setObject: newUrl forKey: kHomepageURLOption]; [[NSUserDefaults standardUserDefaults] synchronize]; } - (NSString *) homepageURL; { - return [NSString stringWithUTF8String: option_homepage_url]; + return [NSString stringWithUTF8String: nsoption_charp(homepage_url)]; } @end diff --git a/cocoa/gui.m b/cocoa/gui.m index 911bc93c3..5d4bb0124 100644 --- a/cocoa/gui.m +++ b/cocoa/gui.m @@ -84,7 +84,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, bw->scale = clone->scale; window = [(BrowserViewController *)(clone->window) windowController]; } else { - bw->scale = (float) option_scale / 100; + bw->scale = (float) nsoption_int(scale) / 100; } BrowserViewController *result = [[BrowserViewController alloc] initWithBrowser: bw]; diff --git a/cocoa/system_colour.m b/cocoa/system_colour.m index 975fea2f5..5477dbfbe 100644 --- a/cocoa/system_colour.m +++ b/cocoa/system_colour.m @@ -39,170 +39,170 @@ static struct gui_system_colour_ctx colour_list[] = { "ActiveBorder", SLEN("ActiveBorder"), 0xff000000, - &option_sys_colour_ActiveBorder, + &nsoption_colour(sys_colour_ActiveBorder), NULL }, { "ActiveCaption", SLEN("ActiveCaption"), 0xffdddddd, - &option_sys_colour_ActiveCaption, + &nsoption_colour(sys_colour_ActiveCaption), NULL }, { "AppWorkspace", SLEN("AppWorkspace"), 0xffeeeeee, - &option_sys_colour_AppWorkspace, + &nsoption_colour(sys_colour_AppWorkspace), NULL }, { "Background", SLEN("Background"), 0xff0000aa, - &option_sys_colour_Background, + &nsoption_colour(sys_colour_Background), NULL }, { "ButtonFace", SLEN("ButtonFace"), 0xffaaaaaa, - &option_sys_colour_ButtonFace, + &nsoption_colour(sys_colour_ButtonFace), NULL }, { "ButtonHighlight", SLEN("ButtonHighlight"), 0xffdddddd, - &option_sys_colour_ButtonHighlight, + &nsoption_colour(sys_colour_ButtonHighlight), NULL }, { "ButtonShadow", SLEN("ButtonShadow"), 0xffbbbbbb, - &option_sys_colour_ButtonShadow, + &nsoption_colour(sys_colour_ButtonShadow), NULL }, { "ButtonText", SLEN("ButtonText"), 0xff000000, - &option_sys_colour_ButtonText, + &nsoption_colour(sys_colour_ButtonText), NULL }, { "CaptionText", SLEN("CaptionText"), 0xff000000, - &option_sys_colour_CaptionText, + &nsoption_colour(sys_colour_CaptionText), NULL }, { "GrayText", SLEN("GrayText"), 0xffcccccc, - &option_sys_colour_GrayText, + &nsoption_colour(sys_colour_GrayText), NULL }, { "Highlight", SLEN("Highlight"), 0xff0000ee, - &option_sys_colour_Highlight, + &nsoption_colour(sys_colour_Highlight), NULL }, { "HighlightText", SLEN("HighlightText"), 0xff000000, - &option_sys_colour_HighlightText, + &nsoption_colour(sys_colour_HighlightText), NULL }, { "InactiveBorder", SLEN("InactiveBorder"), 0xffffffff, - &option_sys_colour_InactiveBorder, + &nsoption_colour(sys_colour_InactiveBorder), NULL }, { "InactiveCaption", SLEN("InactiveCaption"), 0xffffffff, - &option_sys_colour_InactiveCaption, + &nsoption_colour(sys_colour_InactiveCaption), NULL }, { "InactiveCaptionText", SLEN("InactiveCaptionText"), 0xffcccccc, - &option_sys_colour_InactiveCaptionText, + &nsoption_colour(sys_colour_InactiveCaptionText), NULL }, { "InfoBackground", SLEN("InfoBackground"), 0xffaaaaaa, - &option_sys_colour_InfoBackground, + &nsoption_colour(sys_colour_InfoBackground), NULL }, { "InfoText", SLEN("InfoText"), 0xff000000, - &option_sys_colour_InfoText, + &nsoption_colour(sys_colour_InfoText), NULL }, { "Menu", SLEN("Menu"), 0xffaaaaaa, - &option_sys_colour_Menu, + &nsoption_colour(sys_colour_Menu), NULL }, { "MenuText", SLEN("MenuText"), 0xff000000, - &option_sys_colour_MenuText, + &nsoption_colour(sys_colour_MenuText), NULL }, { "Scrollbar", SLEN("Scrollbar"), 0xffaaaaaa, - &option_sys_colour_Scrollbar, + &nsoption_colour(sys_colour_Scrollbar), NULL }, { "ThreeDDarkShadow", SLEN("ThreeDDarkShadow"), 0xff555555, - &option_sys_colour_ThreeDDarkShadow, + &nsoption_colour(sys_colour_ThreeDDarkShadow), NULL }, { "ThreeDFace", SLEN("ThreeDFace"), 0xffdddddd, - &option_sys_colour_ThreeDFace, + &nsoption_colour(sys_colour_ThreeDFace), NULL }, { "ThreeDHighlight", SLEN("ThreeDHighlight"), 0xffaaaaaa, - &option_sys_colour_ThreeDHighlight, + &nsoption_colour(sys_colour_ThreeDHighlight), NULL }, { "ThreeDLightShadow", SLEN("ThreeDLightShadow"), 0xff999999, - &option_sys_colour_ThreeDLightShadow, + &nsoption_colour(sys_colour_ThreeDLightShadow), NULL }, { "ThreeDShadow", SLEN("ThreeDShadow"), 0xff777777, - &option_sys_colour_ThreeDShadow, + &nsoption_colour(sys_colour_ThreeDShadow), NULL }, { "Window", SLEN("Window"), 0xffaaaaaa, - &option_sys_colour_Window, + &nsoption_colour(sys_colour_Window), NULL }, { "WindowFrame", SLEN("WindowFrame"), 0xff000000, - &option_sys_colour_WindowFrame, + &nsoption_colour(sys_colour_WindowFrame), NULL }, { "WindowText", SLEN("WindowText"), 0xff000000, - &option_sys_colour_WindowText, + &nsoption_colour(sys_colour_WindowText), NULL }, diff --git a/content/fetch.c b/content/fetch.c index 2a91ffef1..8c725af0e 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -278,7 +278,7 @@ struct fetch * fetch_start(nsurl *url, nsurl *referer, /* Not a problem if referer has no scheme */ /* Determine whether to send the Referer header */ - if (option_send_referer && ref_scheme != NULL) { + if (nsoption_bool(send_referer) && ref_scheme != NULL) { /* User permits us to send the header * Only send it if: * 1) The fetch and referer schemes match @@ -389,7 +389,7 @@ void fetch_dispatch_jobs(void) } #endif - while ( all_queued && all_active < option_max_fetchers ) { + while ( all_queued && all_active < nsoption_int(max_fetchers) ) { /*LOG(("%d queued, %d fetching", all_queued, all_active));*/ if (fetch_choose_and_dispatch()) { all_queued--; @@ -426,7 +426,7 @@ bool fetch_choose_and_dispatch(void) int countbyhost; RING_COUNTBYLWCHOST(struct fetch, fetch_ring, countbyhost, queueitem->host); - if (countbyhost < option_max_fetchers_per_host) { + if (countbyhost < nsoption_int(max_fetchers_per_host)) { /* We can dispatch this item in theory */ return fetch_dispatch_job(queueitem); } diff --git a/content/fetchers/about.c b/content/fetchers/about.c index 9b6ec88db..a52aa120e 100644 --- a/content/fetchers/about.c +++ b/content/fetchers/about.c @@ -320,7 +320,7 @@ static bool fetch_about_config_handler(struct fetch_about_context *ctx) "\n"); do { - res = options_snoptionf(buffer + slen, sizeof buffer - slen, + res = nsoption_snoptionf(buffer + slen, sizeof buffer - slen, opt_loop, "%k%t%V\n"); if (res <= 0) @@ -382,7 +382,7 @@ static bool fetch_about_choices_handler(struct fetch_about_context *ctx) "# Automatically generated current NetSurf browser Choices\n"); do { - res = options_snoptionf(buffer + slen, + res = nsoption_snoptionf(buffer + slen, sizeof buffer - slen, opt_loop, "%k:%v\n"); diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c index dab7d2b93..6b94390d4 100644 --- a/content/fetchers/curl.c +++ b/content/fetchers/curl.c @@ -25,7 +25,7 @@ * * * The CURL handles are cached in the curl_handle_ring. There are at most - * ::option_max_cached_fetch_handles in this ring. + * ::max_cached_fetch_handles in this ring. */ #include @@ -195,7 +195,7 @@ void fetch_curl_register(void) SETOPT(CURLOPT_VERBOSE, 0); } SETOPT(CURLOPT_ERRORBUFFER, fetch_error_buffer); - if (option_suppress_curl_debug) + if (nsoption_bool(suppress_curl_debug)) SETOPT(CURLOPT_DEBUGFUNCTION, fetch_curl_ignore_debug); SETOPT(CURLOPT_WRITEFUNCTION, fetch_curl_data); SETOPT(CURLOPT_HEADERFUNCTION, fetch_curl_header); @@ -208,13 +208,14 @@ void fetch_curl_register(void) SETOPT(CURLOPT_NOSIGNAL, 1L); SETOPT(CURLOPT_CONNECTTIMEOUT, 30L); - if (option_ca_bundle && strcmp(option_ca_bundle, "")) { - LOG(("option_ca_bundle: '%s'", option_ca_bundle)); - SETOPT(CURLOPT_CAINFO, option_ca_bundle); + if (nsoption_charp(ca_bundle) && + strcmp(nsoption_charp(ca_bundle), "")) { + LOG(("ca_bundle: '%s'", nsoption_charp(ca_bundle))); + SETOPT(CURLOPT_CAINFO, nsoption_charp(ca_bundle)); } - if (option_ca_path && strcmp(option_ca_path, "")) { - LOG(("option_ca_path: '%s'", option_ca_path)); - SETOPT(CURLOPT_CAPATH, option_ca_path); + if (nsoption_charp(ca_path) && strcmp(nsoption_charp(ca_path), "")) { + LOG(("ca_path: '%s'", nsoption_charp(ca_path))); + SETOPT(CURLOPT_CAPATH, nsoption_charp(ca_path)); } /* Detect whether the SSL CTX function API works */ @@ -405,20 +406,20 @@ void * fetch_curl_setup(struct fetch *parent_fetch, nsurl *url, * which fails with lighttpd, so disable it (see bug 1429054) */ APPEND(fetch->headers, "Expect:"); - if (option_accept_language != NULL && - option_accept_language[0] != '\0') { + if ((nsoption_charp(accept_language) != NULL) && + (nsoption_charp(accept_language)[0] != '\0')) { char s[80]; snprintf(s, sizeof s, "Accept-Language: %s, *;q=0.1", - option_accept_language); + nsoption_charp(accept_language)); s[sizeof s - 1] = 0; APPEND(fetch->headers, s); } - if (option_accept_charset != NULL && - option_accept_charset[0] != '\0') { + if (nsoption_charp(accept_charset) != NULL && + nsoption_charp(accept_charset)[0] != '\0') { char s[80]; snprintf(s, sizeof s, "Accept-Charset: %s, *;q=0.1", - option_accept_charset); + nsoption_charp(accept_charset)); s[sizeof s - 1] = 0; APPEND(fetch->headers, s); } @@ -525,11 +526,13 @@ void fetch_curl_cache_handle(CURL *handle, lwc_string *host) } /* We do not have a handle cached, first up determine if the cache is full */ RING_GETSIZE(struct cache_handle, curl_handle_ring, c); - if (c >= option_max_cached_fetch_handles) { - /* Cache is full, so, we rotate the ring by one and replace the - * oldest handle with this one. We do this without freeing/allocating - * memory (except the hostname) and without removing the entry from the - * ring and then re-inserting it, in order to be as efficient as we can. + if (c >= nsoption_int(max_cached_fetch_handles)) { + /* Cache is full, so, we rotate the ring by one and + * replace the oldest handle with this one. We do this + * without freeing/allocating memory (except the + * hostname) and without removing the entry from the + * ring and then re-inserting it, in order to be as + * efficient as we can. */ if (curl_handle_ring != NULL) { h = curl_handle_ring; @@ -605,21 +608,22 @@ fetch_curl_set_options(struct curl_fetch_info *f) SETOPT(CURLOPT_USERPWD, NULL); } - if (option_http_proxy && option_http_proxy_host && - strncmp(nsurl_access(f->url), "file:", 5) != 0) { - SETOPT(CURLOPT_PROXY, option_http_proxy_host); - SETOPT(CURLOPT_PROXYPORT, (long) option_http_proxy_port); - if (option_http_proxy_auth != OPTION_HTTP_PROXY_AUTH_NONE) { + if (nsoption_bool(http_proxy) && + (nsoption_charp(http_proxy_host) != NULL) && + (strncmp(nsurl_access(f->url), "file:", 5) != 0)) { + SETOPT(CURLOPT_PROXY, nsoption_charp(http_proxy_host)); + SETOPT(CURLOPT_PROXYPORT, (long) nsoption_int(http_proxy_port)); + if (nsoption_int(http_proxy_auth) != OPTION_HTTP_PROXY_AUTH_NONE) { SETOPT(CURLOPT_PROXYAUTH, - option_http_proxy_auth == + nsoption_int(http_proxy_auth) == OPTION_HTTP_PROXY_AUTH_BASIC ? (long) CURLAUTH_BASIC : (long) CURLAUTH_NTLM); snprintf(fetch_proxy_userpwd, sizeof fetch_proxy_userpwd, "%s:%s", - option_http_proxy_auth_user, - option_http_proxy_auth_pass); + nsoption_charp(http_proxy_auth_user), + nsoption_charp(http_proxy_auth_pass)); SETOPT(CURLOPT_PROXYUSERPWD, fetch_proxy_userpwd); } } else { diff --git a/content/urldb.c b/content/urldb.c index 4d206e720..733875638 100644 --- a/content/urldb.c +++ b/content/urldb.c @@ -545,7 +545,9 @@ void urldb_save_search_tree(struct search_node *parent, FILE *fp) unsigned int path_count = 0; char *path, *p, *end; int path_alloc = 64, path_used = 1; - time_t expiry = time(NULL) - (60 * 60 * 24) * option_expire_url; + time_t expiry; + + expiry = time(NULL) - ((60 * 60 * 24) * nsoption_int(expire_url)); if (parent == &empty) return; diff --git a/css/select.c b/css/select.c index c033ec142..b313a465e 100644 --- a/css/select.c +++ b/css/select.c @@ -329,7 +329,7 @@ css_error nscss_compute_font_size(void *pw, const css_hint *parent, /* Grab parent size, defaulting to medium if none */ if (parent == NULL) { parent_size.value = FDIV(FMUL(factors[CSS_FONT_SIZE_MEDIUM - 1], - INTTOFIX(option_font_size)), + INTTOFIX(nsoption_int(font_size))), INTTOFIX(10)); parent_size.unit = CSS_UNIT_PT; } else { @@ -346,7 +346,7 @@ css_error nscss_compute_font_size(void *pw, const css_hint *parent, if (size->status < CSS_FONT_SIZE_LARGER) { /* Keyword -- simple */ size->data.length.value = FDIV(FMUL(factors[size->status - 1], - INTTOFIX(option_font_size)), + INTTOFIX(nsoption_int(font_size))), F_10); size->data.length.unit = CSS_UNIT_PT; } else if (size->status == CSS_FONT_SIZE_LARGER) { @@ -816,8 +816,9 @@ css_error node_has_id(void *pw, void *node, *match = false; - if (p->id != NULL) + if (p->id != NULL) { lwc_string_isequal(name, p->id, match); + } return CSS_OK; } @@ -2192,7 +2193,7 @@ css_error ua_default_for_property(void *pw, uint32_t property, css_hint *hint) hint->status = CSS_COLOR_COLOR; } else if (property == CSS_PROP_FONT_FAMILY) { hint->data.strings = NULL; - switch (option_font_default) { + switch (nsoption_int(font_default)) { case PLOT_FONT_FAMILY_SANS_SERIF: hint->status = CSS_FONT_FAMILY_SANS_SERIF; break; @@ -2643,7 +2644,7 @@ bool parse_font_size(const char *size, uint8_t *val, if (value == 7) { /* Manufacture xxx-large */ - *len = FDIV(FMUL(INTTOFIX(3), INTTOFIX(option_font_size)), + *len = FDIV(FMUL(INTTOFIX(3), INTTOFIX(nsoption_int(font_size))), F_10); } else { /* Len is irrelevant */ diff --git a/css/utils.c b/css/utils.c index 422d0fbb1..d5acf4932 100644 --- a/css/utils.c +++ b/css/utils.c @@ -91,8 +91,8 @@ css_fixed nscss_len2px(css_fixed length, css_unit unit, font_size = nscss_len2pt(font_size, font_unit); /* Clamp to configured minimum */ - if (font_size < FDIV(INTTOFIX(option_font_min_size), F_10)) { - font_size = FDIV(INTTOFIX(option_font_min_size), F_10); + if (font_size < FDIV(INTTOFIX(nsoption_int(font_min_size)), F_10)) { + font_size = FDIV(INTTOFIX(nsoption_int(font_min_size)), F_10); } /* Convert to pixels (manually, to maximise precision) diff --git a/desktop/browser.c b/desktop/browser.c index 6f35f7c97..dbdb725e2 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -158,7 +158,8 @@ bool browser_window_redraw(struct browser_window *bw, int x, int y, /* Browser window has content OR children (frames) */ - if (bw->window != NULL && ctx->plot->option_knockout) { + if ((bw->window != NULL) && + (ctx->plot->option_knockout)) { /* Root browser window: start knockout */ knockout_plot_start(ctx, &new_ctx); } @@ -725,7 +726,7 @@ void browser_window_initialise_common(struct browser_window *bw, bw->reformat_pending = false; bw->drag_type = DRAGGING_NONE; - bw->scale = (float) option_scale / 100.0; + bw->scale = (float) nsoption_int(scale) / 100.0; bw->scroll_x = NULL; bw->scroll_y = NULL; @@ -2157,7 +2158,7 @@ struct browser_window *browser_window_find_target(struct browser_window *bw, if ((!(mouse & BROWSER_MOUSE_CLICK_2)) && (!((mouse & BROWSER_MOUSE_CLICK_2) && (mouse & BROWSER_MOUSE_MOD_2))) && - (!option_target_blank)) { + (!nsoption_bool(target_blank))) { /* not a mouse button 2 click * not a mouse button 1 click with ctrl pressed * configured to ignore target="_blank" */ @@ -2166,12 +2167,14 @@ struct browser_window *browser_window_find_target(struct browser_window *bw, } /* handle reserved keywords */ - if (((option_button_2_tab) && (mouse & BROWSER_MOUSE_CLICK_2)) || - ((!option_button_2_tab) && - ((mouse & BROWSER_MOUSE_CLICK_1) && - (mouse & BROWSER_MOUSE_MOD_2))) || - ((option_button_2_tab) && ((target == TARGET_BLANK) || - (!strcasecmp(target, "_blank"))))) { + if (((nsoption_bool(button_2_tab)) && + (mouse & BROWSER_MOUSE_CLICK_2))|| + ((!nsoption_bool(button_2_tab)) && + ((mouse & BROWSER_MOUSE_CLICK_1) && + (mouse & BROWSER_MOUSE_MOD_2))) || + ((nsoption_bool(button_2_tab)) && + ((target == TARGET_BLANK) || + (!strcasecmp(target, "_blank"))))) { /* open in new tab if: * - button_2 opens in new tab and button_2 was pressed * OR @@ -2184,13 +2187,14 @@ struct browser_window *browser_window_find_target(struct browser_window *bw, if (!bw_target) return bw; return bw_target; - } else if (((!option_button_2_tab) && - (mouse & BROWSER_MOUSE_CLICK_2)) || - ((option_button_2_tab) && - ((mouse & BROWSER_MOUSE_CLICK_1) && - (mouse & BROWSER_MOUSE_MOD_2))) || - ((!option_button_2_tab) && ((target == TARGET_BLANK) || - (!strcasecmp(target, "_blank"))))) { + } else if (((!nsoption_bool(button_2_tab)) && + (mouse & BROWSER_MOUSE_CLICK_2)) || + ((nsoption_bool(button_2_tab)) && + ((mouse & BROWSER_MOUSE_CLICK_1) && + (mouse & BROWSER_MOUSE_MOD_2))) || + ((!nsoption_bool(button_2_tab)) && + ((target == TARGET_BLANK) || + (!strcasecmp(target, "_blank"))))) { /* open in new window if: * - button_2 doesn't open in new tabs and button_2 was pressed * OR @@ -2231,8 +2235,9 @@ struct browser_window *browser_window_find_target(struct browser_window *bw, return bw_target; /* we require a new window using the target name */ - if (!option_target_blank) + if (!nsoption_bool(target_blank)) return bw; + bw_target = browser_window_create(NULL, bw, NULL, false, false); if (!bw_target) return bw; diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 698606da1..7d498b50a 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -167,12 +167,12 @@ nserror netsurf_init(int *pargc, utsname.version, utsname.machine)); LOG(("Using '%s' for Options file", options)); - options_read(options); + nsoption_read(options); messages_load(messages); /* set up cache limits based on the memory cache size option */ - hlcache_parameters.limit = option_memory_cache_size; + hlcache_parameters.limit = nsoption_int(memory_cache_size); if (hlcache_parameters.limit < MINIMUM_MEMORY_CACHE_SIZE) { hlcache_parameters.limit = MINIMUM_MEMORY_CACHE_SIZE; @@ -228,7 +228,7 @@ nserror netsurf_init(int *pargc, /* Initialize system colours */ gui_system_colour_init(); - options_commandline(pargc, *pargv); + nsoption_commandline(pargc, *pargv); js_initialise(); diff --git a/desktop/options.c b/desktop/options.c index 0fbf40b32..82e08ebb2 100644 --- a/desktop/options.c +++ b/desktop/options.c @@ -31,206 +31,18 @@ #include #include #include + #include "css/css.h" -#include "desktop/options.h" #include "desktop/plot_style.h" #include "utils/log.h" #include "utils/utils.h" +#include "desktop/options.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 EXTRA_OPTION_DEFINE -#define EXTRA_OPTION_TABLE -#endif - - -/** An HTTP proxy should be used. */ -bool option_http_proxy = false; -/** Hostname of proxy. */ -char *option_http_proxy_host = 0; -/** Proxy port. */ -int option_http_proxy_port = 8080; -/** Proxy authentication method. */ -int option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NONE; -/** Proxy authentication user name */ -char *option_http_proxy_auth_user = 0; -/** Proxy authentication password */ -char *option_http_proxy_auth_pass = 0; -/** Default font size / 0.1pt. */ -int option_font_size = 128; -/** Minimum font size. */ -int option_font_min_size = 85; -/** Default sans serif font */ -char *option_font_sans; -/** Default serif font */ -char *option_font_serif; -/** Default monospace font */ -char *option_font_mono; -/** Default cursive font */ -char *option_font_cursive; -/** Default fantasy font */ -char *option_font_fantasy; -/** Accept-Language header. */ -char *option_accept_language = 0; -/** Accept-Charset header. */ -char *option_accept_charset = 0; -/** Preferred maximum size of memory cache / bytes. */ -int option_memory_cache_size = 12 * 1024 * 1024; -/** Preferred expiry age of disc cache / days. */ -int option_disc_cache_age = 28; -/** Whether to block advertisements */ -bool option_block_ads = false; -/** Minimum GIF animation delay */ -int option_minimum_gif_delay = 10; -/** Whether to send the referer HTTP header */ -bool option_send_referer = true; -/** Whether to fetch foreground images */ -bool option_foreground_images = true; -/** Whether to fetch background images */ -bool option_background_images = true; -/** Whether to animate images */ -bool option_animate_images = true; -/** How many days to retain URL data for */ -int option_expire_url = 28; -/** Default font family */ -int option_font_default = PLOT_FONT_FAMILY_SANS_SERIF; -/** ca-bundle location */ -char *option_ca_bundle = 0; -/** ca-path location */ -char *option_ca_path = 0; -/** Cookie file location */ -char *option_cookie_file = 0; -/** Cookie jar location */ -char *option_cookie_jar = 0; -/** Home page location */ -char *option_homepage_url = 0; -/** search web from url bar */ -bool option_search_url_bar = false; -/** URL completion in url bar */ -bool option_url_suggestion = true; -/** default web search provider */ -int option_search_provider = 0; -/** default x position of new windows */ -int option_window_x = 0; -/** default y position of new windows */ -int option_window_y = 0; -/** default width of new windows */ -int option_window_width = 0; -/** default height of new windows */ -int option_window_height = 0; -/** width of screen when above options were saved */ -int option_window_screen_width = 0; -/** height of screen when above options were saved */ -int option_window_screen_height = 0; -/** default size of status bar vs. h scroll bar */ -int option_toolbar_status_width = 6667; -/** default window scale */ -int option_scale = 100; -/* Whether to reflow web pages while objects are fetching */ -bool option_incremental_reflow = true; -/* Minimum time between HTML reflows while objects are fetching */ -#ifdef riscos -unsigned int option_min_reflow_period = 100; /* time in cs */ -#else -unsigned int option_min_reflow_period = 25; /* time in cs */ -#endif -bool option_core_select_menu = false; -/** top margin of exported page*/ -int option_margin_top = DEFAULT_MARGIN_TOP_MM; -/** bottom margin of exported page*/ -int option_margin_bottom = DEFAULT_MARGIN_BOTTOM_MM; -/** left margin of exported page*/ -int option_margin_left = DEFAULT_MARGIN_LEFT_MM; -/** right margin of exported page*/ -int option_margin_right = DEFAULT_MARGIN_RIGHT_MM; -/** scale of exported content*/ -int option_export_scale = DEFAULT_EXPORT_SCALE * 100; -/**suppressing images in printed content*/ -bool option_suppress_images = false; -/**turning off all backgrounds for printed content*/ -bool option_remove_backgrounds = false; -/**turning on content loosening for printed content*/ -bool option_enable_loosening = true; -/**compression of PDF documents*/ -bool option_enable_PDF_compression = true; -/**setting a password and encoding PDF documents*/ -bool option_enable_PDF_password = false; - -/* Fetcher configuration */ -/** Maximum simultaneous active fetchers */ -int option_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 - */ -int option_max_fetchers_per_host = 5; -/** Maximum number of inactive fetchers cached. - * The total number of handles netsurf will therefore have open - * is this plus option_max_fetchers. - */ -int option_max_cached_fetch_handles = 6; -/** Suppress debug output from cURL. */ -bool option_suppress_curl_debug = true; - -/** Whether to allow target="_blank" */ -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) */ - -/* system colours */ -colour option_sys_colour_ActiveBorder = 0x00000000; -colour option_sys_colour_ActiveCaption = 0x00000000; -colour option_sys_colour_AppWorkspace = 0x00000000; -colour option_sys_colour_Background = 0x00000000; -colour option_sys_colour_ButtonFace = 0x00000000; -colour option_sys_colour_ButtonHighlight = 0x00000000; -colour option_sys_colour_ButtonShadow = 0x00000000; -colour option_sys_colour_ButtonText = 0x00000000; -colour option_sys_colour_CaptionText = 0x0000000; -colour option_sys_colour_GrayText = 0x00000000; -colour option_sys_colour_Highlight = 0x00000000; -colour option_sys_colour_HighlightText = 0x00000000; -colour option_sys_colour_InactiveBorder = 0x00000000; -colour option_sys_colour_InactiveCaption = 0x00000000; -colour option_sys_colour_InactiveCaptionText = 0x00000000; -colour option_sys_colour_InfoBackground = 0x00000000; -colour option_sys_colour_InfoText = 0x00000000; -colour option_sys_colour_Menu = 0x00000000; -colour option_sys_colour_MenuText = 0x0000000; -colour option_sys_colour_Scrollbar = 0x0000000; -colour option_sys_colour_ThreeDDarkShadow = 0x000000; -colour option_sys_colour_ThreeDFace = 0x000000; -colour option_sys_colour_ThreeDHighlight = 0x000000; -colour option_sys_colour_ThreeDLightShadow = 0x000000; -colour option_sys_colour_ThreeDShadow = 0x000000; -colour option_sys_colour_Window = 0x000000; -colour option_sys_colour_WindowFrame = 0x000000; -colour option_sys_colour_WindowText = 0x000000; - - -EXTRA_OPTION_DEFINE +struct ns_options nsoptions = { + NSOPTION_MAIN_DEFAULTS, + NSOPTION_SYS_COLOUR_DEFAULTS, + NSOPTION_EXTRA_DEFAULTS +}; enum option_type_e { OPTION_BOOL, @@ -246,104 +58,8 @@ struct option_entry_s { }; struct option_entry_s option_table[] = { - { "http_proxy", OPTION_BOOL, &option_http_proxy }, - { "http_proxy_host", OPTION_STRING, &option_http_proxy_host }, - { "http_proxy_port", OPTION_INTEGER, &option_http_proxy_port }, - { "http_proxy_auth", OPTION_INTEGER, &option_http_proxy_auth }, - { "http_proxy_auth_user", OPTION_STRING, &option_http_proxy_auth_user }, - { "http_proxy_auth_pass", OPTION_STRING, &option_http_proxy_auth_pass }, - { "font_size", OPTION_INTEGER, &option_font_size }, - { "font_min_size", OPTION_INTEGER, &option_font_min_size }, - { "font_sans", OPTION_STRING, &option_font_sans }, - { "font_serif", OPTION_STRING, &option_font_serif }, - { "font_mono", OPTION_STRING, &option_font_mono }, - { "font_cursive", OPTION_STRING, &option_font_cursive }, - { "font_fantasy", OPTION_STRING, &option_font_fantasy }, - { "accept_language", OPTION_STRING, &option_accept_language }, - { "accept_charset", OPTION_STRING, &option_accept_charset }, - { "memory_cache_size", OPTION_INTEGER, &option_memory_cache_size }, - { "disc_cache_age", OPTION_INTEGER, &option_disc_cache_age }, - { "block_advertisements", OPTION_BOOL, &option_block_ads }, - { "minimum_gif_delay", OPTION_INTEGER, &option_minimum_gif_delay }, - { "send_referer", OPTION_BOOL, &option_send_referer }, - { "foreground_images", OPTION_BOOL, &option_foreground_images }, - { "background_images", OPTION_BOOL, &option_background_images }, - { "animate_images", OPTION_BOOL, &option_animate_images }, - { "expire_url", OPTION_INTEGER, &option_expire_url }, - { "font_default", OPTION_INTEGER, &option_font_default }, - { "ca_bundle", OPTION_STRING, &option_ca_bundle }, - { "ca_path", OPTION_STRING, &option_ca_path }, - { "cookie_file", OPTION_STRING, &option_cookie_file }, - { "cookie_jar", OPTION_STRING, &option_cookie_jar }, - { "homepage_url", OPTION_STRING, &option_homepage_url }, - { "search_url_bar", OPTION_BOOL, &option_search_url_bar}, - { "search_provider", OPTION_INTEGER, &option_search_provider}, - { "url_suggestion", OPTION_BOOL, &option_url_suggestion }, - { "window_x", OPTION_INTEGER, &option_window_x }, - { "window_y", OPTION_INTEGER, &option_window_y }, - { "window_width", OPTION_INTEGER, &option_window_width }, - { "window_height", OPTION_INTEGER, &option_window_height }, - { "window_screen_width", OPTION_INTEGER, &option_window_screen_width }, - { "window_screen_height", OPTION_INTEGER, &option_window_screen_height }, - { "toolbar_status_size", OPTION_INTEGER, &option_toolbar_status_width }, - { "scale", OPTION_INTEGER, &option_scale }, - { "incremental_reflow", OPTION_BOOL, &option_incremental_reflow }, - { "min_reflow_period", OPTION_INTEGER, &option_min_reflow_period }, - { "core_select_menu", OPTION_BOOL, &option_core_select_menu }, - /* Fetcher options */ - { "max_fetchers", OPTION_INTEGER, &option_max_fetchers }, - { "max_fetchers_per_host", OPTION_INTEGER, &option_max_fetchers_per_host }, - { "max_cached_fetch_handles", OPTION_INTEGER, &option_max_cached_fetch_handles }, - { "suppress_curl_debug",OPTION_BOOL, &option_suppress_curl_debug }, - { "target_blank", OPTION_BOOL, &option_target_blank }, - { "button_2_tab", OPTION_BOOL, &option_button_2_tab }, - /* PDF / Print options*/ - { "margin_top", OPTION_INTEGER, &option_margin_top}, - { "margin_bottom", OPTION_INTEGER, &option_margin_bottom}, - { "margin_left", OPTION_INTEGER, &option_margin_left}, - { "margin_right", OPTION_INTEGER, &option_margin_right}, - { "export_scale", OPTION_INTEGER, &option_export_scale}, - { "suppress_images", OPTION_BOOL, &option_suppress_images}, - { "remove_backgrounds", OPTION_BOOL, &option_remove_backgrounds}, - { "enable_loosening", OPTION_BOOL, &option_enable_loosening}, - { "enable_PDF_compression", 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}, - - /* System colours */ - { "sys_colour_ActiveBorder",OPTION_COLOUR,&option_sys_colour_ActiveBorder }, - { "sys_colour_ActiveCaption",OPTION_COLOUR,&option_sys_colour_ActiveCaption }, - { "sys_colour_AppWorkspace",OPTION_COLOUR,&option_sys_colour_AppWorkspace }, - { "sys_colour_Background",OPTION_COLOUR,&option_sys_colour_Background }, - { "sys_colour_ButtonFace",OPTION_COLOUR,&option_sys_colour_ButtonFace }, - { "sys_colour_ButtonHighlight",OPTION_COLOUR,&option_sys_colour_ButtonHighlight }, - { "sys_colour_ButtonShadow",OPTION_COLOUR,&option_sys_colour_ButtonShadow }, - { "sys_colour_ButtonText",OPTION_COLOUR,&option_sys_colour_ButtonText }, - { "sys_colour_CaptionText",OPTION_COLOUR,&option_sys_colour_CaptionText }, - { "sys_colour_GrayText",OPTION_COLOUR,&option_sys_colour_GrayText }, - { "sys_colour_Highlight",OPTION_COLOUR,&option_sys_colour_Highlight }, - { "sys_colour_HighlightText",OPTION_COLOUR,&option_sys_colour_HighlightText }, - { "sys_colour_InactiveBorder",OPTION_COLOUR,&option_sys_colour_InactiveBorder }, - { "sys_colour_InactiveCaption",OPTION_COLOUR,&option_sys_colour_InactiveCaption }, - { "sys_colour_InactiveCaptionText",OPTION_COLOUR,&option_sys_colour_InactiveCaptionText }, - { "sys_colour_InfoBackground",OPTION_COLOUR,&option_sys_colour_InfoBackground }, - { "sys_colour_InfoText",OPTION_COLOUR,&option_sys_colour_InfoText }, - { "sys_colour_Menu",OPTION_COLOUR,&option_sys_colour_Menu }, - { "sys_colour_MenuText",OPTION_COLOUR,&option_sys_colour_MenuText }, - { "sys_colour_Scrollbar",OPTION_COLOUR,&option_sys_colour_Scrollbar }, - { "sys_colour_ThreeDDarkShadow",OPTION_COLOUR,&option_sys_colour_ThreeDDarkShadow }, - { "sys_colour_ThreeDFace",OPTION_COLOUR,&option_sys_colour_ThreeDFace }, - { "sys_colour_ThreeDHighlight",OPTION_COLOUR,&option_sys_colour_ThreeDHighlight }, - { "sys_colour_ThreeDLightShadow",OPTION_COLOUR,&option_sys_colour_ThreeDLightShadow }, - { "sys_colour_ThreeDShadow",OPTION_COLOUR,&option_sys_colour_ThreeDShadow }, - { "sys_colour_Window",OPTION_COLOUR,&option_sys_colour_Window }, - { "sys_colour_WindowFrame",OPTION_COLOUR,&option_sys_colour_WindowFrame }, - { "sys_colour_WindowText",OPTION_COLOUR,&option_sys_colour_WindowText }, - - EXTRA_OPTION_TABLE + NSOPTION_MAIN_TABLE, + NSOPTION_EXTRA_TABLE }; #define option_table_entries (sizeof option_table / sizeof option_table[0]) @@ -379,7 +95,12 @@ strtooption(const char *value, struct option_entry_s *option_entry) case OPTION_STRING: free(*((char **)option_entry->p)); - *((char **)option_entry->p) = strdup(value); + 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; } @@ -387,8 +108,27 @@ strtooption(const char *value, struct option_entry_s *option_entry) 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 options_read(const char *path) +void nsoption_read(const char *path) { char s[100]; FILE *fp; @@ -423,22 +163,12 @@ void options_read(const char *path) fclose(fp); - if (option_font_size < 50) - option_font_size = 50; - if (1000 < option_font_size) - option_font_size = 1000; - if (option_font_min_size < 10) - option_font_min_size = 10; - if (500 < option_font_min_size) - option_font_min_size = 500; - - if (option_memory_cache_size < 0) - option_memory_cache_size = 0; + nsoptions_validate(&nsoptions); } /* exported interface documented in options.h */ -void options_write(const char *path) +void nsoption_write(const char *path) { unsigned int entry; FILE *fp; @@ -496,7 +226,8 @@ void options_write(const char *path) * \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 options_output_value_html(struct option_entry_s *option, +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 */ @@ -548,7 +279,8 @@ static size_t options_output_value_html(struct option_entry_s *option, * \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 options_output_value_text(struct option_entry_s *option, +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 */ @@ -584,7 +316,8 @@ static size_t options_output_value_text(struct option_entry_s *option, } /* exported interface documented in options.h */ -void options_commandline(int *pargc, char **argv) +void +nsoption_commandline(int *pargc, char **argv) { char *arg; char *val; @@ -643,8 +376,8 @@ void options_commandline(int *pargc, char **argv) } /* exported interface documented in options.h */ -int options_snoptionf(char *string, size_t size, unsigned int option, - const char *fmt) +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 */ @@ -695,11 +428,11 @@ int options_snoptionf(char *string, size_t size, unsigned int option, case 'V': - slen += options_output_value_html(option_entry, + slen += nsoption_output_value_html(option_entry, size, slen, string); break; case 'v': - slen += options_output_value_text(option_entry, + slen += nsoption_output_value_text(option_entry, size, slen, string); break; } @@ -718,14 +451,15 @@ int options_snoptionf(char *string, size_t size, unsigned int option, } /* exported interface documented in options.h */ -void options_dump(FILE *outf) +void +nsoption_dump(FILE *outf) { char buffer[256]; int opt_loop = 0; int res; do { - res = options_snoptionf(buffer, sizeof buffer, opt_loop, + res = nsoption_snoptionf(buffer, sizeof buffer, opt_loop, "%k:%v\n"); if (res > 0) { fprintf(outf, "%s", buffer); diff --git a/desktop/options.h b/desktop/options.h index 42375f9ef..b96aaec52 100644 --- a/desktop/options.h +++ b/desktop/options.h @@ -35,116 +35,94 @@ #ifndef _NETSURF_DESKTOP_OPTIONS_H_ #define _NETSURF_DESKTOP_OPTIONS_H_ +#define _NETSURF_DESKTOP_OPTIONS_INCLUDING_ + #include #include + #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 + +#undef _NETSURF_DESKTOP_OPTIONS_INCLUDING_ + enum { OPTION_HTTP_PROXY_AUTH_NONE = 0, OPTION_HTTP_PROXY_AUTH_BASIC = 1, OPTION_HTTP_PROXY_AUTH_NTLM = 2 }; -extern bool option_http_proxy; -extern char *option_http_proxy_host; -extern int option_http_proxy_port; -extern int option_http_proxy_auth; -extern char *option_http_proxy_auth_user; -extern char *option_http_proxy_auth_pass; -extern int option_font_size; -extern int option_font_min_size; -extern char *option_accept_language; -extern char *option_accept_charset; -extern int option_memory_cache_size; -extern int option_disc_cache_age; -extern bool option_block_ads; -extern int option_minimum_gif_delay; -extern bool option_send_referer; -extern bool option_foreground_images; -extern bool option_background_images; -extern bool option_animate_images; -extern int option_expire_url; -extern int option_font_default; /* a css_font_family */ -extern char *option_font_sans; -extern char *option_font_serif; -extern char *option_font_mono; -extern char *option_font_cursive; -extern char *option_font_fantasy; -extern char *option_ca_bundle; -extern char *option_ca_path; -extern char *option_cookie_file; -extern char *option_cookie_jar; -extern char *option_homepage_url; -extern bool option_search_url_bar; -extern int option_search_provider; -extern bool option_target_blank; -extern bool option_button_2_tab; -extern bool option_url_suggestion; -extern int option_window_x; -extern int option_window_y; -extern int option_window_width; -extern int option_window_height; -extern int option_window_screen_width; -extern int option_window_screen_height; -extern int option_toolbar_status_width; -extern int option_scale; -extern bool option_incremental_reflow; -extern unsigned int option_min_reflow_period; -extern bool option_core_select_menu; - -extern int option_margin_top; -extern int option_margin_bottom; -extern int option_margin_left; -extern int option_margin_right; -extern int option_export_scale; -extern bool option_suppress_images; -extern bool option_remove_backgrounds; -extern bool option_enable_loosening; -extern bool option_enable_PDF_compression; -extern bool option_enable_PDF_password; #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 -/* Fetcher configuration. */ -extern int option_max_fetchers; -extern int option_max_fetchers_per_host; -extern int option_max_cached_fetch_handles; -extern bool option_suppress_curl_debug; +struct ns_options { + NSOPTION_MAIN_DEFINE; + NSOPTION_EXTRA_DEFINE; +}; -/* Interface colours */ -extern colour option_gui_colour_bg_1; -extern colour option_gui_colour_fg_1; -extern colour option_gui_colour_fg_2; +/* global option struct */ +extern struct ns_options nsoptions; -extern colour option_sys_colour_ActiveBorder; -extern colour option_sys_colour_ActiveCaption; -extern colour option_sys_colour_AppWorkspace; -extern colour option_sys_colour_Background; -extern colour option_sys_colour_ButtonFace; -extern colour option_sys_colour_ButtonHighlight; -extern colour option_sys_colour_ButtonShadow; -extern colour option_sys_colour_ButtonText; -extern colour option_sys_colour_CaptionText; -extern colour option_sys_colour_GrayText; -extern colour option_sys_colour_Highlight; -extern colour option_sys_colour_HighlightText; -extern colour option_sys_colour_InactiveBorder; -extern colour option_sys_colour_InactiveCaption; -extern colour option_sys_colour_InactiveCaptionText; -extern colour option_sys_colour_InfoBackground; -extern colour option_sys_colour_InfoText; -extern colour option_sys_colour_Menu; -extern colour option_sys_colour_MenuText; -extern colour option_sys_colour_Scrollbar; -extern colour option_sys_colour_ThreeDDarkShadow; -extern colour option_sys_colour_ThreeDFace; -extern colour option_sys_colour_ThreeDHighlight; -extern colour option_sys_colour_ThreeDLightShadow; -extern colour option_sys_colour_ThreeDShadow; -extern colour option_sys_colour_Window; -extern colour option_sys_colour_WindowFrame; -extern colour option_sys_colour_WindowText; +/* 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 == 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; \ + } \ + } \ + } while (0) /** @@ -155,7 +133,7 @@ extern colour option_sys_colour_WindowText; * Option variables corresponding to lines in the file are updated. Missing * options are unchanged. If the file fails to open, options are unchanged. */ -void options_read(const char *path); +void nsoption_read(const char *path); /** * Save options to a file. @@ -164,14 +142,14 @@ void options_read(const char *path); * * Errors are ignored. */ -void options_write(const char *path); +void nsoption_write(const char *path); /** * Dump user options to stream * * \param outf output stream to dump options to. */ -void options_dump(FILE *outf); +void nsoption_dump(FILE *outf); /** * Fill a buffer with an option using a format. @@ -189,13 +167,13 @@ void options_dump(FILE *outf); * \param fmt The format string. * \return The number of bytes written to \a string or -1 on error */ -int options_snoptionf(char *string, size_t size, unsigned int option, +int nsoption_snoptionf(char *string, size_t size, unsigned int option, const char *fmt); /** * Process commandline and set options approriately. */ -void options_commandline(int *pargc, char **argv); +void nsoption_commandline(int *pargc, char **argv); #endif diff --git a/desktop/options_main.h b/desktop/options_main.h new file mode 100644 index 000000000..fc7af3d28 --- /dev/null +++ b/desktop/options_main.h @@ -0,0 +1,400 @@ +/* + * Copyright 2004 James Bursa + * + * 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 . + */ + +/** \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 age of disc cache / days. */ \ + int disc_cache_age; \ + /** Whether to block advertisements */ \ + bool block_ads; \ + /** 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; \ + /** 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; \ + \ + /* Interface colours */ \ + colour gui_colour_bg_1; /** Background (bbggrr) */ \ + colour gui_colour_fg_1; /** Foreground (bbggrr) */ \ + colour gui_colour_fg_2; /** Foreground selected (bbggrr) */ \ + \ + /* 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_age = 28, \ + .block_ads = 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, \ + .gui_colour_bg_1 = 0xFFCCBB, \ + .gui_colour_fg_1 = 0x000000, \ + .gui_colour_fg_2 = 0xFFFBF8 + +#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_age", OPTION_INTEGER, &nsoptions.disc_cache_age }, \ + { "block_advertisements", OPTION_BOOL, &nsoptions.block_ads }, \ + { "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 }, \ + { "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}, \ + /* Interface colours */ \ + { "gui_colour_bg_1", OPTION_COLOUR, &nsoptions.gui_colour_bg_1}, \ + { "gui_colour_fg_1", OPTION_COLOUR, &nsoptions.gui_colour_fg_1}, \ + { "gui_colour_fg_2", OPTION_COLOUR, &nsoptions.gui_colour_fg_2}, \ + \ + /* 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 ae0992ac0..4b8092b6f 100644 --- a/desktop/print.c +++ b/desktop/print.c @@ -126,7 +126,7 @@ bool print_draw_next_page(const struct printer *printer, struct content_redraw_data data; struct redraw_context ctx = { .interactive = false, - .background_images = !option_remove_backgrounds, + .background_images = !nsoption_bool(remove_backgrounds), .plot = printer->plotter }; @@ -288,18 +288,18 @@ struct print_settings *print_make_settings(print_configuration configuration, settings->page_height = DEFAULT_PAGE_HEIGHT; settings->copies = DEFAULT_COPIES; - settings->scale = (float)option_export_scale / 100; + settings->scale = (float)nsoption_int(export_scale) / 100; - length = INTTOFIX(option_margin_left); + length = INTTOFIX(nsoption_int(margin_left)); settings->margins[MARGINLEFT] = nscss_len2px(length, unit, NULL); - length = INTTOFIX(option_margin_right); + length = INTTOFIX(nsoption_int(margin_right)); settings->margins[MARGINRIGHT] = nscss_len2px(length, unit, NULL); - length = INTTOFIX(option_margin_top); + length = INTTOFIX(nsoption_int(margin_top)); settings->margins[MARGINTOP] = nscss_len2px(length, unit, NULL); - length = INTTOFIX(option_margin_bottom); + length = INTTOFIX(nsoption_int(margin_bottom)); settings->margins[MARGINBOTTOM] = nscss_len2px(length, unit, NULL); break; diff --git a/desktop/tree.c b/desktop/tree.c index bab474ded..8facdfd42 100644 --- a/desktop/tree.c +++ b/desktop/tree.c @@ -186,29 +186,30 @@ void tree_set_icon_dir(char *icon_dir) static void tree_setup_colours(void) { /* Background colour */ - plot_style_fill_tree_background.fill_colour = option_gui_colour_bg_1; + plot_style_fill_tree_background.fill_colour = nsoption_colour(gui_colour_bg_1); /* Selection background colour */ - plot_style_fill_tree_selected.fill_colour = option_gui_colour_fg_1; + plot_style_fill_tree_selected.fill_colour = nsoption_colour(gui_colour_fg_1); /* Furniture line colour */ plot_style_stroke_tree_furniture.stroke_colour = blend_colour( - option_gui_colour_bg_1, option_gui_colour_fg_1); + nsoption_colour(gui_colour_bg_1), + nsoption_colour(gui_colour_fg_1)); /* Furniture fill colour */ - plot_style_fill_tree_furniture.fill_colour = option_gui_colour_fg_2; + plot_style_fill_tree_furniture.fill_colour = nsoption_colour(gui_colour_fg_2); /* Text colour */ - plot_fstyle.foreground = option_gui_colour_fg_1; - plot_fstyle.background = option_gui_colour_bg_1; - plot_fstyle_def_folder.foreground = option_gui_colour_fg_1; - plot_fstyle_def_folder.background = option_gui_colour_bg_1; + plot_fstyle.foreground = nsoption_colour(gui_colour_fg_1); + plot_fstyle.background = nsoption_colour(gui_colour_bg_1); + plot_fstyle_def_folder.foreground = nsoption_colour(gui_colour_fg_1); + plot_fstyle_def_folder.background = nsoption_colour(gui_colour_bg_1); /* Selected text colour */ - plot_fstyle_selected.foreground = option_gui_colour_fg_2; - plot_fstyle_selected.background = option_gui_colour_fg_1; - plot_fstyle_selected_def_folder.foreground = option_gui_colour_fg_2; - plot_fstyle_selected_def_folder.background = option_gui_colour_fg_1; + plot_fstyle_selected.foreground = nsoption_colour(gui_colour_fg_2); + plot_fstyle_selected.background = nsoption_colour(gui_colour_fg_1); + plot_fstyle_selected_def_folder.foreground = nsoption_colour(gui_colour_fg_2); + plot_fstyle_selected_def_folder.background = nsoption_colour(gui_colour_fg_1); } diff --git a/framebuffer/font_freetype.c b/framebuffer/font_freetype.c index 5fc305616..b3c993f40 100644 --- a/framebuffer/font_freetype.c +++ b/framebuffer/font_freetype.c @@ -33,7 +33,6 @@ #include "framebuffer/gui.h" #include "framebuffer/font.h" -#include "framebuffer/options.h" #include "framebuffer/findfile.h" /* glyph cache minimum size */ @@ -172,7 +171,7 @@ bool fb_font_init(void) } /* set the Glyph cache size up */ - max_cache_size = option_fb_font_cachesize * 1024; + max_cache_size = nsoption_int(fb_font_cachesize) * 1024; if (max_cache_size < CACHE_MIN_SIZE) { max_cache_size = CACHE_MIN_SIZE; @@ -199,7 +198,7 @@ bool fb_font_init(void) /* need to obtain the generic font faces */ /* Start with the sans serif font */ - fb_face = fb_new_face(option_fb_face_sans_serif, + fb_face = fb_new_face(nsoption_charp(fb_face_sans_serif), "sans_serif.ttf", NETSURF_FB_FONT_SANS_SERIF); if (fb_face == NULL) { @@ -213,7 +212,7 @@ bool fb_font_init(void) } /* Bold sans serif face */ - fb_face = fb_new_face(option_fb_face_sans_serif_bold, + fb_face = fb_new_face(nsoption_charp(fb_face_sans_serif_bold), "sans_serif_bold.ttf", NETSURF_FB_FONT_SANS_SERIF_BOLD); if (fb_face == NULL) { @@ -224,7 +223,7 @@ bool fb_font_init(void) } /* Italic sans serif face */ - fb_face = fb_new_face(option_fb_face_sans_serif_italic, + fb_face = fb_new_face(nsoption_charp(fb_face_sans_serif_italic), "sans_serif_italic.ttf", NETSURF_FB_FONT_SANS_SERIF_ITALIC); if (fb_face == NULL) { @@ -235,7 +234,7 @@ bool fb_font_init(void) } /* Bold italic sans serif face */ - fb_face = fb_new_face(option_fb_face_sans_serif_italic_bold, + fb_face = fb_new_face(nsoption_charp(fb_face_sans_serif_italic_bold), "sans_serif_italic_bold.ttf", NETSURF_FB_FONT_SANS_SERIF_ITALIC_BOLD); if (fb_face == NULL) { @@ -246,7 +245,7 @@ bool fb_font_init(void) } /* serif face */ - fb_face = fb_new_face(option_fb_face_serif, + fb_face = fb_new_face(nsoption_charp(fb_face_serif), "serif.ttf", NETSURF_FB_FONT_SERIF); if (fb_face == NULL) { @@ -257,7 +256,7 @@ bool fb_font_init(void) } /* bold serif face*/ - fb_face = fb_new_face(option_fb_face_serif_bold, + fb_face = fb_new_face(nsoption_charp(fb_face_serif_bold), "serif_bold.ttf", NETSURF_FB_FONT_SERIF_BOLD); if (fb_face == NULL) { @@ -269,7 +268,7 @@ bool fb_font_init(void) /* monospace face */ - fb_face = fb_new_face(option_fb_face_monospace, + fb_face = fb_new_face(nsoption_charp(fb_face_monospace), "monospace.ttf", NETSURF_FB_FONT_MONOSPACE); if (fb_face == NULL) { @@ -280,7 +279,7 @@ bool fb_font_init(void) } /* bold monospace face*/ - fb_face = fb_new_face(option_fb_face_monospace_bold, + fb_face = fb_new_face(nsoption_charp(fb_face_monospace_bold), "monospace_bold.ttf", NETSURF_FB_FONT_MONOSPACE_BOLD); if (fb_face == NULL) { @@ -291,7 +290,7 @@ bool fb_font_init(void) } /* cursive face */ - fb_face = fb_new_face(option_fb_face_cursive, + fb_face = fb_new_face(nsoption_charp(fb_face_cursive), "cursive.ttf", NETSURF_FB_FONT_CURSIVE); if (fb_face == NULL) { @@ -302,7 +301,7 @@ bool fb_font_init(void) } /* fantasy face */ - fb_face = fb_new_face(option_fb_face_fantasy, + fb_face = fb_new_face(nsoption_charp(fb_face_fantasy), "fantasy.ttf", NETSURF_FB_FONT_FANTASY); if (fb_face == NULL) { @@ -314,7 +313,7 @@ bool fb_font_init(void) /* set the default render mode */ - if (option_fb_font_monochrome == true) + if (nsoption_bool(fb_font_monochrome) == true) ft_load_type = FT_LOAD_MONOCHROME; /* faster but less pretty */ else ft_load_type = 0; diff --git a/framebuffer/gui.c b/framebuffer/gui.c index 0cbe1a2e5..4822a9e28 100644 --- a/framebuffer/gui.c +++ b/framebuffer/gui.c @@ -53,7 +53,6 @@ #include "framebuffer/findfile.h" #include "framebuffer/image_data.h" #include "framebuffer/font.h" -#include "framebuffer/options.h" #include "content/urldb.h" #include "desktop/history_core.h" @@ -388,19 +387,21 @@ process_cmdline(int argc, char** argv) fename = "sdl"; febpp = 32; - if ((option_window_width != 0) && (option_window_height != 0)) { - fewidth = option_window_width; - feheight = option_window_height; + if ((nsoption_int(window_width) != 0) && + (nsoption_int(window_height) != 0)) { + fewidth = nsoption_int(window_width); + feheight = nsoption_int(window_height); } else { fewidth = 800; feheight = 600; } - if (option_homepage_url != NULL && option_homepage_url[0] != '\0') - feurl = option_homepage_url; - else + if ((nsoption_charp(homepage_url) != NULL) && + (nsoption_charp(homepage_url)[0] != '\0')) { + feurl = nsoption_charp(homepage_url); + } else { feurl = NETSURF_HOMEPAGE; - + } while((opt = getopt(argc, argv, "f:b:w:h:")) != -1) { switch (opt) { @@ -440,19 +441,19 @@ gui_init(int argc, char** argv) { nsfb_t *nsfb; - option_core_select_menu = true; + nsoption_set_bool(core_select_menu, true); - if (option_cookie_file == NULL) { - option_cookie_file = strdup("~/.netsurf/Cookies"); - LOG(("Using '%s' as Cookies file", option_cookie_file)); + if (nsoption_charp(cookie_file) == NULL) { + nsoption_set_charp(cookie_file, strdup("~/.netsurf/Cookies")); + LOG(("Using '%s' as Cookies file", nsoption_charp(cookie_file))); } - if (option_cookie_jar == NULL) { - option_cookie_jar = strdup("~/.netsurf/Cookies"); - LOG(("Using '%s' as Cookie Jar file", option_cookie_jar)); + if (nsoption_charp(cookie_jar) == NULL) { + nsoption_set_charp(cookie_jar, strdup("~/.netsurf/Cookies")); + LOG(("Using '%s' as Cookie Jar file", nsoption_charp(cookie_jar))); } - if (option_cookie_file == NULL || option_cookie_jar == NULL) + if (nsoption_charp(cookie_file) == NULL || nsoption_charp(cookie_jar == NULL)) die("Failed initialising cookie options"); if (process_cmdline(argc,argv) != true) @@ -471,7 +472,7 @@ gui_init(int argc, char** argv) fbtk_enable_oskb(fbtk); - urldb_load_cookies(option_cookie_file); + urldb_load_cookies(nsoption_charp(cookie_file)); } /** Entry point from OS. @@ -546,7 +547,7 @@ gui_quit(void) { LOG(("gui_quit")); - urldb_save_cookies(option_cookie_jar); + urldb_save_cookies(nsoption_charp(cookie_jar)); framebuffer_finalise(); } @@ -1150,13 +1151,13 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width) fbtk_widget_t *widget; fbtk_widget_t *toolbar; int statusbar_width = 0; - int toolbar_height = option_fb_toolbar_size; + int toolbar_height = nsoption_int(fb_toolbar_size); LOG(("Normal window")); gw->window = fbtk_create_window(fbtk, 0, 0, 0, 0, 0); - statusbar_width = option_toolbar_status_width * + statusbar_width = nsoption_int(toolbar_status_width) * fbtk_get_width(gw->window) / 10000; /* toolbar */ @@ -1164,7 +1165,7 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width) toolbar_height, 2, FB_FRAME_COLOUR, - option_fb_toolbar_layout); + nsoption_charp(fb_toolbar_layout)); /* set the actually created toolbar height */ if (toolbar != NULL) { @@ -1197,7 +1198,7 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width) /* fill bottom right area */ - if (option_fb_osk == true) { + if (nsoption_bool(fb_osk) == true) { widget = fbtk_create_text_button(gw->window, fbtk_get_width(gw->window) - furniture_width, fbtk_get_height(gw->window) - furniture_width, @@ -1230,7 +1231,7 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width) gw); /* browser widget */ - create_browser_widget(gw, toolbar_height, option_fb_furniture_size); + create_browser_widget(gw, toolbar_height, nsoption_int(fb_furniture_size)); /* Give browser_window's user widget input focus */ fbtk_set_focus(gw->browser); @@ -1254,8 +1255,8 @@ gui_create_browser_window(struct browser_window *bw, */ gw->bw = bw; - create_normal_browser_window(gw, option_fb_furniture_size); - gw->localhistory = fb_create_localhistory(bw, fbtk, option_fb_furniture_size); + create_normal_browser_window(gw, nsoption_int(fb_furniture_size)); + gw->localhistory = fb_create_localhistory(bw, fbtk, nsoption_int(fb_furniture_size)); /* map and request redraw of gui window */ fbtk_set_mapping(gw->window, true); diff --git a/framebuffer/options.h b/framebuffer/options.h index 0874f11f4..760cc3b51 100644 --- a/framebuffer/options.h +++ b/framebuffer/options.h @@ -16,93 +16,90 @@ * along with this program. If not, see . */ +#ifndef _NETSURF_DESKTOP_OPTIONS_INCLUDING_ +#error "Frontend options header cannot be included directly" +#endif + #ifndef _NETSURF_FRAMEBUFFER_OPTIONS_H_ #define _NETSURF_FRAMEBUFFER_OPTIONS_H_ -#include "desktop/options.h" +#define NSOPTION_EXTRA_DEFINE \ + /* surface options */ \ + int fb_depth; \ + int fb_refresh; \ + char *fb_device; \ + char *fb_input_devpath; \ + char *fb_input_glob; \ + \ + /* toolkit options */ \ + int fb_furniture_size; /**< toolkit furniture size */ \ + int fb_toolbar_size; /**< toolbar furniture size */ \ + char *fb_toolbar_layout; /**< toolbar layout */ \ + bool fb_osk; /**< enable on screen keyboard */ \ + \ + /* font options */ \ + bool fb_font_monochrome; /**< render font monochrome */ \ + int fb_font_cachesize; /**< size of font glyph cache in kilobytes. */ \ + \ + char *fb_face_sans_serif; /**< default sans face */ \ + char *fb_face_sans_serif_bold; /**< bold sans face */ \ + char *fb_face_sans_serif_italic; /**< bold sans face */ \ + char *fb_face_sans_serif_italic_bold; /**< bold sans face */ \ + \ + char *fb_face_serif; /**< serif face */ \ + char *fb_face_serif_bold; /**< bold serif face */ \ + \ + char *fb_face_monospace; /**< monospace face */ \ + char *fb_face_monospace_bold; /**< bold monospace face */ \ + \ + char *fb_face_cursive; /**< cursive face */ \ + char *fb_face_fantasy /**< fantasy face */ -/* surface options */ +#define NSOPTION_EXTRA_DEFAULTS \ + .fb_depth = 32, \ + .fb_refresh = 70, \ + .fb_device = NULL, \ + .fb_input_devpath = NULL, \ + .fb_input_glob = NULL, \ + .fb_furniture_size = 18, \ + .fb_toolbar_size = 30, \ + .fb_toolbar_layout = NULL, \ + .fb_osk = false, \ + .fb_font_monochrome = false, \ + .fb_font_cachesize = 2048, \ + .fb_face_sans_serif = NULL, \ + .fb_face_sans_serif_bold = NULL, \ + .fb_face_sans_serif_italic = NULL, \ + .fb_face_sans_serif_italic_bold = NULL, \ + .fb_face_serif = NULL, \ + .fb_face_serif_bold = NULL, \ + .fb_face_monospace = NULL, \ + .fb_face_monospace_bold = NULL, \ + .fb_face_cursive = NULL, \ + .fb_face_fantasy = NULL -extern int option_fb_depth; -extern int option_fb_refresh; -extern char *option_fb_device; -extern char *option_fb_input_devpath; -extern char *option_fb_input_glob; - -/* toolkit options */ - -extern int option_fb_furniture_size; /* toolkit furniture size */ -extern int option_fb_toolbar_size; /* toolbar furniture size */ -extern char *option_fb_toolbar_layout; /* toolbar layout */ -extern bool option_fb_osk; /* enable on screen keyboard */ - -/* font options */ - -/* render font monochrome */ -extern bool option_fb_font_monochrome; -/** size of font glyph cache in kilobytes. */ -extern int option_fb_font_cachesize; - -extern char *option_fb_face_sans_serif; /* default sans face */ -extern char *option_fb_face_sans_serif_bold; /* bold sans face */ -extern char *option_fb_face_sans_serif_italic; /* bold sans face */ -extern char *option_fb_face_sans_serif_italic_bold; /* bold sans face */ - -extern char *option_fb_face_serif; /* serif face */ -extern char *option_fb_face_serif_bold; /* bold serif face */ - -extern char *option_fb_face_monospace; /* monospace face */ -extern char *option_fb_face_monospace_bold; /* bold monospace face */ - -extern char *option_fb_face_cursive; /* cursive face */ -extern char *option_fb_face_fantasy; /* fantasy face */ - - -#define EXTRA_OPTION_DEFINE \ - int option_fb_depth = 32; \ - int option_fb_refresh = 70; \ - char *option_fb_device = 0; \ - char *option_fb_input_devpath = 0; \ - char *option_fb_input_glob = 0; \ - int option_fb_furniture_size = 18; \ - int option_fb_toolbar_size = 30; \ - char *option_fb_toolbar_layout; \ - bool option_fb_osk = false; \ - bool option_fb_font_monochrome = false; \ - int option_fb_font_cachesize = 2048; \ - char *option_fb_face_sans_serif; \ - char *option_fb_face_sans_serif_bold; \ - char *option_fb_face_sans_serif_italic; \ - char *option_fb_face_sans_serif_italic_bold; \ - char *option_fb_face_serif; \ - char *option_fb_face_serif_bold; \ - char *option_fb_face_monospace; \ - char *option_fb_face_monospace_bold; \ - char *option_fb_face_cursive; \ - char *option_fb_face_fantasy; - -#define EXTRA_OPTION_TABLE \ - { "fb_depth", OPTION_INTEGER, &option_fb_depth }, \ - { "fb_refresh", OPTION_INTEGER, &option_fb_refresh }, \ - { "fb_device", OPTION_STRING, &option_fb_device }, \ - { "fb_input_devpath", OPTION_STRING, &option_fb_input_devpath }, \ - { "fb_input_glob", OPTION_STRING, &option_fb_input_glob }, \ - { "fb_furniture_size", OPTION_INTEGER, &option_fb_furniture_size }, \ - { "fb_toolbar_size", OPTION_INTEGER, &option_fb_toolbar_size }, \ - { "fb_toolbar_layout", OPTION_STRING, &option_fb_toolbar_layout }, \ - { "fb_osk", OPTION_BOOL, &option_fb_osk }, \ - { "fb_font_monochrome", OPTION_BOOL, &option_fb_font_monochrome }, \ - { "fb_font_cachesize", OPTION_INTEGER, &option_fb_font_cachesize }, \ - { "fb_face_sans_serif", OPTION_STRING, &option_fb_face_sans_serif }, \ - { "fb_face_sans_serif_bold", OPTION_STRING, &option_fb_face_sans_serif_bold }, \ - { "fb_face_sans_serif_italic", OPTION_STRING, &option_fb_face_sans_serif_italic }, \ - { "fb_face_sans_serif_italic_bold", OPTION_STRING, &option_fb_face_sans_serif_italic_bold }, \ - { "fb_face_serif", OPTION_STRING, &option_fb_face_serif }, \ - { "fb_serif_bold", OPTION_STRING, &option_fb_face_serif_bold }, \ - { "fb_face_monospace", OPTION_STRING, &option_fb_face_monospace }, \ - { "fb_face_monospace_bold", OPTION_STRING, &option_fb_face_monospace_bold }, \ - { "fb_face_cursive", OPTION_STRING, &option_fb_face_cursive }, \ - { "fb_face_fantasy", OPTION_STRING, &option_fb_face_fantasy } +#define NSOPTION_EXTRA_TABLE \ + { "fb_depth", OPTION_INTEGER, &nsoptions.fb_depth }, \ + { "fb_refresh", OPTION_INTEGER, &nsoptions.fb_refresh }, \ + { "fb_device", OPTION_STRING, &nsoptions.fb_device }, \ + { "fb_input_devpath", OPTION_STRING, &nsoptions.fb_input_devpath }, \ + { "fb_input_glob", OPTION_STRING, &nsoptions.fb_input_glob }, \ + { "fb_furniture_size", OPTION_INTEGER, &nsoptions.fb_furniture_size }, \ + { "fb_toolbar_size", OPTION_INTEGER, &nsoptions.fb_toolbar_size }, \ + { "fb_toolbar_layout", OPTION_STRING, &nsoptions.fb_toolbar_layout }, \ + { "fb_osk", OPTION_BOOL, &nsoptions.fb_osk }, \ + { "fb_font_monochrome", OPTION_BOOL, &nsoptions.fb_font_monochrome }, \ + { "fb_font_cachesize", OPTION_INTEGER, &nsoptions.fb_font_cachesize }, \ + { "fb_face_sans_serif", OPTION_STRING, &nsoptions.fb_face_sans_serif }, \ + { "fb_face_sans_serif_bold", OPTION_STRING, &nsoptions.fb_face_sans_serif_bold }, \ + { "fb_face_sans_serif_italic", OPTION_STRING, &nsoptions.fb_face_sans_serif_italic }, \ + { "fb_face_sans_serif_italic_bold", OPTION_STRING, &nsoptions.fb_face_sans_serif_italic_bold }, \ + { "fb_face_serif", OPTION_STRING, &nsoptions.fb_face_serif }, \ + { "fb_serif_bold", OPTION_STRING, &nsoptions.fb_face_serif_bold }, \ + { "fb_face_monospace", OPTION_STRING, &nsoptions.fb_face_monospace }, \ + { "fb_face_monospace_bold", OPTION_STRING, &nsoptions.fb_face_monospace_bold }, \ + { "fb_face_cursive", OPTION_STRING, &nsoptions.fb_face_cursive }, \ + { "fb_face_fantasy", OPTION_STRING, &nsoptions.fb_face_fantasy } #endif diff --git a/framebuffer/system_colour.c b/framebuffer/system_colour.c index b58717492..abe1adcd2 100644 --- a/framebuffer/system_colour.c +++ b/framebuffer/system_colour.c @@ -34,176 +34,176 @@ struct gui_system_colour_ctx { lwc_string *lwcstr; }; -static struct gui_system_colour_ctx colour_list[] = { - { - "ActiveBorder", - SLEN("ActiveBorder"), - 0xff000000, - &option_sys_colour_ActiveBorder, - NULL - }, { - "ActiveCaption", - SLEN("ActiveCaption"), - 0xffdddddd, - &option_sys_colour_ActiveCaption, - NULL - }, { - "AppWorkspace", - SLEN("AppWorkspace"), - 0xffeeeeee, - &option_sys_colour_AppWorkspace, - NULL - }, { - "Background", - SLEN("Background"), - 0xff0000aa, - &option_sys_colour_Background, - NULL - }, { - "ButtonFace", - SLEN("ButtonFace"), - 0xffaaaaaa, - &option_sys_colour_ButtonFace, - NULL - }, { - "ButtonHighlight", - SLEN("ButtonHighlight"), - 0xffdddddd, - &option_sys_colour_ButtonHighlight, +static struct gui_system_colour_ctx colour_list[] = { + { + "ActiveBorder", + SLEN("ActiveBorder"), + 0xff000000, + &nsoption_colour(sys_colour_ActiveBorder), NULL }, { - "ButtonShadow", - SLEN("ButtonShadow"), - 0xffbbbbbb, - &option_sys_colour_ButtonShadow, - NULL + "ActiveCaption", + SLEN("ActiveCaption"), + 0xffdddddd, + &nsoption_colour(sys_colour_ActiveCaption), + NULL }, { - "ButtonText", - SLEN("ButtonText"), - 0xff000000, - &option_sys_colour_ButtonText, - NULL + "AppWorkspace", + SLEN("AppWorkspace"), + 0xffeeeeee, + &nsoption_colour(sys_colour_AppWorkspace), + NULL }, { - "CaptionText", - SLEN("CaptionText"), - 0xff000000, - &option_sys_colour_CaptionText, - NULL + "Background", + SLEN("Background"), + 0xff0000aa, + &nsoption_colour(sys_colour_Background), + NULL }, { - "GrayText", - SLEN("GrayText"), - 0xffcccccc, - &option_sys_colour_GrayText, - NULL + "ButtonFace", + SLEN("ButtonFace"), + 0xffaaaaaa, + &nsoption_colour(sys_colour_ButtonFace), + NULL }, { - "Highlight", - SLEN("Highlight"), - 0xff0000ee, - &option_sys_colour_Highlight, - NULL + "ButtonHighlight", + SLEN("ButtonHighlight"), + 0xffdddddd, + &nsoption_colour(sys_colour_ButtonHighlight), + NULL }, { - "HighlightText", - SLEN("HighlightText"), - 0xff000000, - &option_sys_colour_HighlightText, - NULL + "ButtonShadow", + SLEN("ButtonShadow"), + 0xffbbbbbb, + &nsoption_colour(sys_colour_ButtonShadow), + NULL }, { - "InactiveBorder", - SLEN("InactiveBorder"), - 0xffffffff, - &option_sys_colour_InactiveBorder, - NULL + "ButtonText", + SLEN("ButtonText"), + 0xff000000, + &nsoption_colour(sys_colour_ButtonText), + NULL }, { - "InactiveCaption", - SLEN("InactiveCaption"), - 0xffffffff, - &option_sys_colour_InactiveCaption, - NULL + "CaptionText", + SLEN("CaptionText"), + 0xff000000, + &nsoption_colour(sys_colour_CaptionText), + NULL }, { - "InactiveCaptionText", - SLEN("InactiveCaptionText"), - 0xffcccccc, - &option_sys_colour_InactiveCaptionText, - NULL + "GrayText", + SLEN("GrayText"), + 0xffcccccc, + &nsoption_colour(sys_colour_GrayText), + NULL }, { - "InfoBackground", - SLEN("InfoBackground"), - 0xffaaaaaa, - &option_sys_colour_InfoBackground, - NULL + "Highlight", + SLEN("Highlight"), + 0xff0000ee, + &nsoption_colour(sys_colour_Highlight), + NULL }, { - "InfoText", - SLEN("InfoText"), - 0xff000000, - &option_sys_colour_InfoText, - NULL + "HighlightText", + SLEN("HighlightText"), + 0xff000000, + &nsoption_colour(sys_colour_HighlightText), + NULL }, { - "Menu", - SLEN("Menu"), - 0xffaaaaaa, - &option_sys_colour_Menu, - NULL + "InactiveBorder", + SLEN("InactiveBorder"), + 0xffffffff, + &nsoption_colour(sys_colour_InactiveBorder), + NULL }, { - "MenuText", - SLEN("MenuText"), - 0xff000000, - &option_sys_colour_MenuText, - NULL + "InactiveCaption", + SLEN("InactiveCaption"), + 0xffffffff, + &nsoption_colour(sys_colour_InactiveCaption), + NULL }, { - "Scrollbar", - SLEN("Scrollbar"), - 0xffaaaaaa, - &option_sys_colour_Scrollbar, - NULL + "InactiveCaptionText", + SLEN("InactiveCaptionText"), + 0xffcccccc, + &nsoption_colour(sys_colour_InactiveCaptionText), + NULL }, { - "ThreeDDarkShadow", - SLEN("ThreeDDarkShadow"), - 0xff555555, - &option_sys_colour_ThreeDDarkShadow, - NULL + "InfoBackground", + SLEN("InfoBackground"), + 0xffaaaaaa, + &nsoption_colour(sys_colour_InfoBackground), + NULL }, { - "ThreeDFace", - SLEN("ThreeDFace"), - 0xffdddddd, - &option_sys_colour_ThreeDFace, - NULL + "InfoText", + SLEN("InfoText"), + 0xff000000, + &nsoption_colour(sys_colour_InfoText), + NULL }, { - "ThreeDHighlight", - SLEN("ThreeDHighlight"), - 0xffaaaaaa, - &option_sys_colour_ThreeDHighlight, - NULL + "Menu", + SLEN("Menu"), + 0xffaaaaaa, + &nsoption_colour(sys_colour_Menu), + NULL }, { - "ThreeDLightShadow", - SLEN("ThreeDLightShadow"), - 0xff999999, - &option_sys_colour_ThreeDLightShadow, - NULL + "MenuText", + SLEN("MenuText"), + 0xff000000, + &nsoption_colour(sys_colour_MenuText), + NULL }, { - "ThreeDShadow", - SLEN("ThreeDShadow"), - 0xff777777, - &option_sys_colour_ThreeDShadow, - NULL + "Scrollbar", + SLEN("Scrollbar"), + 0xffaaaaaa, + &nsoption_colour(sys_colour_Scrollbar), + NULL }, { - "Window", - SLEN("Window"), - 0xffaaaaaa, - &option_sys_colour_Window, - NULL + "ThreeDDarkShadow", + SLEN("ThreeDDarkShadow"), + 0xff555555, + &nsoption_colour(sys_colour_ThreeDDarkShadow), + NULL }, { - "WindowFrame", - SLEN("WindowFrame"), - 0xff000000, - &option_sys_colour_WindowFrame, - NULL + "ThreeDFace", + SLEN("ThreeDFace"), + 0xffdddddd, + &nsoption_colour(sys_colour_ThreeDFace), + NULL }, { - - "WindowText", - SLEN("WindowText"), - 0xff000000, - &option_sys_colour_WindowText, - NULL + "ThreeDHighlight", + SLEN("ThreeDHighlight"), + 0xffaaaaaa, + &nsoption_colour(sys_colour_ThreeDHighlight), + NULL + }, { + "ThreeDLightShadow", + SLEN("ThreeDLightShadow"), + 0xff999999, + &nsoption_colour(sys_colour_ThreeDLightShadow), + NULL + }, { + "ThreeDShadow", + SLEN("ThreeDShadow"), + 0xff777777, + &nsoption_colour(sys_colour_ThreeDShadow), + NULL + }, { + "Window", + SLEN("Window"), + 0xffaaaaaa, + &nsoption_colour(sys_colour_Window), + NULL + }, { + "WindowFrame", + SLEN("WindowFrame"), + 0xff000000, + &nsoption_colour(sys_colour_WindowFrame), + NULL + }, { + + "WindowText", + SLEN("WindowText"), + 0xff000000, + &nsoption_colour(sys_colour_WindowText), + NULL }, }; @@ -217,13 +217,13 @@ bool gui_system_colour_init(void) { unsigned int ccount; - if (gui_system_colour_pw != NULL) + if (gui_system_colour_pw != NULL) return false; /* Intern colour strings */ for (ccount = 0; ccount < colour_list_len; ccount++) { - if (lwc_intern_string(colour_list[ccount].name, - colour_list[ccount].length, + if (lwc_intern_string(colour_list[ccount].name, + colour_list[ccount].length, &(colour_list[ccount].lwcstr)) != lwc_error_ok) { return false; } @@ -237,7 +237,7 @@ bool gui_system_colour_init(void) } gui_system_colour_pw = colour_list; - + return true; } @@ -256,8 +256,8 @@ colour gui_system_colour_char(char *name) unsigned int ccount; for (ccount = 0; ccount < colour_list_len; ccount++) { - if (strncasecmp(name, - colour_list[ccount].name, + if (strncasecmp(name, + colour_list[ccount].name, colour_list[ccount].length) == 0) { ret = colour_list[ccount].colour; break; @@ -272,13 +272,13 @@ css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour) bool match; for (ccount = 0; ccount < colour_list_len; ccount++) { - if (lwc_string_caseless_isequal(name, + if (lwc_string_caseless_isequal(name, colour_list[ccount].lwcstr, &match) == lwc_error_ok && match) { *colour = colour_list[ccount].colour; return CSS_OK; } - } + } return CSS_INVALID; } diff --git a/gtk/completion.c b/gtk/completion.c index 80a4693e4..8782c876e 100644 --- a/gtk/completion.c +++ b/gtk/completion.c @@ -70,6 +70,7 @@ bool nsgtk_completion_udb_callback(const char *url, const struct url_data *data) void nsgtk_completion_update(const char *prefix) { nsgtk_completion_empty(); - if (option_url_suggestion == true) + if (nsoption_bool(url_suggestion) == true) { urldb_iterate_partial(prefix, nsgtk_completion_udb_callback); + } } diff --git a/gtk/dialogs/options.c b/gtk/dialogs/options.c index 32eb62567..62cf9061f 100644 --- a/gtk/dialogs/options.c +++ b/gtk/dialogs/options.c @@ -32,7 +32,6 @@ #include "desktop/searchweb.h" #include "gtk/compat.h" -#include "gtk/options.h" #include "gtk/gui.h" #include "gtk/scaffolding.h" #include "gtk/theme.h" @@ -48,7 +47,6 @@ static GladeXML *gladeFile; static struct browser_window *current_browser; static int proxy_type; -static float animation_delay; static void dialog_response_handler (GtkDialog *dlg, gint res_id); static gboolean on_dialog_close (GtkDialog *dlg, gboolean stay_alive); @@ -294,14 +292,42 @@ GtkDialog* nsgtk_options_init(struct browser_window *bw, GtkWindow *parent) void nsgtk_options_load(void) { GtkBox *box; - const char *default_accept_language = - option_accept_language ? option_accept_language : "en"; + const char *default_accept_language = "en"; + const char *default_homepage_url = ""; + const char *default_http_proxy_host = ""; + const char *default_http_proxy_auth_user = ""; + const char *default_http_proxy_auth_pass = ""; int combo_row_count = 0; int active_language = 0; int proxytype = 0; FILE *fp; char buf[50]; + /* get widget text */ + if (nsoption_charp(accept_language) != NULL) { + default_accept_language = nsoption_charp(accept_language); + } + + if (nsoption_charp(homepage_url) != NULL) { + default_homepage_url = nsoption_charp(homepage_url); + } + + if (nsoption_charp(http_proxy_host) != NULL) { + default_http_proxy_host = nsoption_charp(http_proxy_host); + } + + if (nsoption_charp(http_proxy_auth_user) != NULL) { + default_http_proxy_auth_user = nsoption_charp(http_proxy_auth_user); + } + + if (nsoption_charp(http_proxy_auth_pass) != NULL) { + default_http_proxy_auth_pass = nsoption_charp(http_proxy_auth_pass); + } + + if (nsoption_bool(http_proxy) == true) { + proxytype = nsoption_int(http_proxy_auth) + 1; + } + /* Create combobox */ box = GTK_BOX(glade_xml_get_widget(gladeFile, "combolanguagevbox")); comboLanguage = nsgtk_combo_box_text_new(); @@ -343,91 +369,85 @@ void nsgtk_options_load(void) nsgtk_options_theme_combo(); - SET_ENTRY(entryHomePageURL, - option_homepage_url ? option_homepage_url : ""); + SET_ENTRY(entryHomePageURL, default_homepage_url); SET_BUTTON(setCurrentPage); SET_BUTTON(setDefaultPage); - SET_CHECK(checkHideAdverts, option_block_ads); + SET_CHECK(checkHideAdverts, nsoption_bool(block_ads)); - SET_CHECK(checkDisablePopups, option_disable_popups); - SET_CHECK(checkDisablePlugins, option_disable_plugins); - SET_SPIN(spinHistoryAge, option_history_age); - SET_CHECK(checkHoverURLs, option_hover_urls); + SET_CHECK(checkDisablePopups, nsoption_bool(disable_popups)); + SET_CHECK(checkDisablePlugins, nsoption_bool(disable_plugins)); + SET_SPIN(spinHistoryAge, nsoption_int(history_age)); + SET_CHECK(checkHoverURLs, nsoption_bool(hover_urls)); - SET_CHECK(checkDisplayRecentURLs, option_url_suggestion); - SET_CHECK(checkSendReferer, option_send_referer); - SET_CHECK(checkShowSingleTab, option_show_single_tab); + SET_CHECK(checkDisplayRecentURLs, nsoption_bool(url_suggestion)); + SET_CHECK(checkSendReferer, nsoption_bool(send_referer)); + SET_CHECK(checkShowSingleTab, nsoption_bool(show_single_tab)); - if (option_http_proxy == false) - proxytype = 0; - else - proxytype = option_http_proxy_auth + 1; - SET_COMBO(comboProxyType, proxytype); - SET_ENTRY(entryProxyHost, - option_http_proxy_host ? option_http_proxy_host : ""); + SET_ENTRY(entryProxyHost, default_http_proxy_host); + gtk_widget_set_sensitive(entryProxyHost, proxytype != 0); - snprintf(buf, sizeof(buf), "%d", option_http_proxy_port); + snprintf(buf, sizeof(buf), "%d", nsoption_int(http_proxy_port)); SET_ENTRY(entryProxyPort, buf); gtk_widget_set_sensitive(entryProxyPort, proxytype != 0); - SET_ENTRY(entryProxyUser, option_http_proxy_auth_user ? - option_http_proxy_auth_user : ""); + SET_ENTRY(entryProxyUser, default_http_proxy_auth_user); + gtk_widget_set_sensitive(entryProxyUser, proxytype != 0); - SET_ENTRY(entryProxyPassword, option_http_proxy_auth_pass ? - option_http_proxy_auth_pass : ""); + SET_ENTRY(entryProxyPassword, default_http_proxy_auth_pass); + gtk_widget_set_sensitive(entryProxyPassword, proxytype != 0); - SET_SPIN(spinMaxFetchers, option_max_fetchers); - SET_SPIN(spinFetchesPerHost, option_max_fetchers_per_host); - SET_SPIN(spinCachedConnections, option_max_cached_fetch_handles); + SET_SPIN(spinMaxFetchers, nsoption_int(max_fetchers)); + SET_SPIN(spinFetchesPerHost, nsoption_int(max_fetchers_per_host)); + SET_SPIN(spinCachedConnections, nsoption_int(max_cached_fetch_handles)); - SET_CHECK(checkResampleImages, option_render_resample); - SET_SPIN(spinAnimationSpeed, option_minimum_gif_delay / 100.0); - SET_CHECK(checkDisableAnimations, !option_animate_images); + SET_CHECK(checkResampleImages, nsoption_bool(render_resample)); + SET_SPIN(spinAnimationSpeed, nsoption_int(minimum_gif_delay) / 100.0); + SET_CHECK(checkDisableAnimations, !nsoption_bool(animate_images)); - SET_FONT(fontSansSerif, option_font_sans); - SET_FONT(fontSerif, option_font_serif); - SET_FONT(fontMonospace, option_font_mono); - SET_FONT(fontCursive, option_font_cursive); - SET_FONT(fontFantasy, option_font_fantasy); - SET_COMBO(comboDefault, option_font_default); - SET_SPIN(spinDefaultSize, option_font_size / 10); - SET_SPIN(spinMinimumSize, option_font_min_size / 10); + SET_FONT(fontSansSerif, nsoption_charp(font_sans)); + SET_FONT(fontSerif, nsoption_charp(font_serif)); + SET_FONT(fontMonospace, nsoption_charp(font_mono)); + SET_FONT(fontCursive, nsoption_charp(font_cursive)); + SET_FONT(fontFantasy, nsoption_charp(font_fantasy)); + SET_COMBO(comboDefault, nsoption_int(font_default)); + SET_SPIN(spinDefaultSize, nsoption_int(font_size) / 10); + SET_SPIN(spinMinimumSize, nsoption_bool(font_min_size) / 10); SET_BUTTON(fontPreview); - SET_COMBO(comboButtonType, option_button_type -1); + SET_COMBO(comboButtonType, nsoption_int(button_type) -1); - SET_COMBO(comboTabPosition, option_position_tab); + SET_COMBO(comboTabPosition, nsoption_int(position_tab)); - SET_SPIN(spinMemoryCacheSize, option_memory_cache_size >> 20); - SET_SPIN(spinDiscCacheAge, option_disc_cache_age); + SET_SPIN(spinMemoryCacheSize, nsoption_int(memory_cache_size) >> 20); + SET_SPIN(spinDiscCacheAge, nsoption_int(disc_cache_age)); - SET_CHECK(checkClearDownloads, option_downloads_clear); - SET_CHECK(checkRequestOverwrite, option_request_overwrite); - SET_FILE_CHOOSER(fileChooserDownloads, option_downloads_directory); + SET_CHECK(checkClearDownloads, nsoption_bool(downloads_clear)); + SET_CHECK(checkRequestOverwrite, nsoption_bool(request_overwrite)); + SET_FILE_CHOOSER(fileChooserDownloads, nsoption_charp(downloads_directory)); - SET_CHECK(checkFocusNew, option_focus_new); - SET_CHECK(checkNewBlank, option_new_blank); - SET_CHECK(checkUrlSearch, option_search_url_bar); - SET_COMBO(comboSearch, option_search_provider); + SET_CHECK(checkFocusNew, nsoption_bool(focus_new)); + SET_CHECK(checkNewBlank, nsoption_bool(new_blank)); + SET_CHECK(checkUrlSearch, nsoption_bool(search_url_bar)); + SET_COMBO(comboSearch, nsoption_int(search_provider)); SET_BUTTON(buttonaddtheme); - SET_CHECK(sourceButtonTab, option_source_tab); + SET_CHECK(sourceButtonTab, nsoption_bool(source_tab)); - SET_SPIN(spinMarginTop, option_margin_top); - SET_SPIN(spinMarginBottom, option_margin_bottom); - SET_SPIN(spinMarginLeft, option_margin_left); - SET_SPIN(spinMarginRight, option_margin_right); - SET_SPIN(spinExportScale, option_export_scale); - SET_CHECK(checkSuppressImages, option_suppress_images); - SET_CHECK(checkRemoveBackgrounds, option_remove_backgrounds); - SET_CHECK(checkFitPage, option_enable_loosening); - SET_CHECK(checkCompressPDF, option_enable_PDF_compression); - SET_CHECK(checkPasswordPDF, option_enable_PDF_password); + SET_SPIN(spinMarginTop, nsoption_int(margin_top)); + SET_SPIN(spinMarginBottom, nsoption_int(margin_bottom)); + SET_SPIN(spinMarginLeft, nsoption_int(margin_left)); + SET_SPIN(spinMarginRight, nsoption_int(margin_right)); + SET_SPIN(spinExportScale, nsoption_int(export_scale)); + SET_CHECK(checkSuppressImages, nsoption_bool(suppress_images)); + SET_CHECK(checkRemoveBackgrounds, nsoption_bool(remove_backgrounds)); + SET_CHECK(checkFitPage, nsoption_bool(enable_loosening)); + SET_CHECK(checkCompressPDF, nsoption_bool(enable_PDF_compression)); + SET_CHECK(checkPasswordPDF, nsoption_bool(enable_PDF_password)); SET_BUTTON(setDefaultExportOptions); } @@ -446,7 +466,7 @@ static void dialog_response_handler (GtkDialog *dlg, gint res_id) static gboolean on_dialog_close (GtkDialog *dlg, gboolean stay_alive) { LOG(("Writing options to file")); - options_write(options_file_location); + nsoption_write(options_file_location); if ((stay_alive) && GTK_IS_WIDGET(dlg)) gtk_widget_hide(GTK_WIDGET(dlg)); else { @@ -487,7 +507,7 @@ static void nsgtk_options_theme_combo(void) { } fclose(fp); gtk_combo_box_set_active(GTK_COMBO_BOX(combotheme), - option_current_theme); + nsoption_int(current_theme)); gtk_box_pack_start(box, combotheme, FALSE, TRUE, 0); gtk_widget_show(combotheme); } @@ -505,54 +525,47 @@ bool nsgtk_options_combo_theme_add(const char *themename) * nsgtk_reflow_all_windows only where necessary */ #define ENTRY_CHANGED(widget, option) \ - static gboolean on_##widget##_changed(GtkWidget *widget, gpointer data) { \ - if (!g_str_equal(gtk_entry_get_text(GTK_ENTRY((widget))), (option) ? (option) : "")) { \ +static gboolean on_##widget##_changed(GtkWidget *widget, gpointer data) \ +{ \ + if (!g_str_equal(gtk_entry_get_text(GTK_ENTRY((widget))), \ + nsoption_charp(option) ? nsoption_charp(option) : "")) { \ LOG(("Signal emitted on '%s'", #widget)); \ - if ((option)) \ - free((option)); \ - (option) = strdup(gtk_entry_get_text(GTK_ENTRY((widget)))); \ - } \ - do { \ + nsoption_set_charp(option, strdup(gtk_entry_get_text(GTK_ENTRY((widget))))); \ + } \ + return FALSE; \ +} #define CHECK_CHANGED(widget, option) \ static gboolean on_##widget##_changed(GtkWidget *widget, gpointer data) { \ LOG(("Signal emitted on '%s'", #widget)); \ - (option) = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON((widget))); \ - do { \ + nsoption_set_bool(option, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON((widget)))); \ + do #define SPIN_CHANGED(widget, option) \ static gboolean on_##widget##_changed(GtkWidget *widget, gpointer data) { \ LOG(("Signal emitted on '%s'", #widget)); \ - (option) = gtk_spin_button_get_value(GTK_SPIN_BUTTON((widget))); \ - do { \ + nsoption_set_int(option, gtk_spin_button_get_value(GTK_SPIN_BUTTON((widget)))); \ + do #define COMBO_CHANGED(widget, option) \ static gboolean on_##widget##_changed(GtkWidget *widget, gpointer data) { \ LOG(("Signal emitted on '%s'", #widget)); \ - (option) = gtk_combo_box_get_active(GTK_COMBO_BOX((widget))); \ - do { + nsoption_set_int(option, gtk_combo_box_get_active(GTK_COMBO_BOX((widget)))); \ + do #define FONT_CHANGED(widget, option) \ static gboolean on_##widget##_changed(GtkWidget *widget, gpointer data) { \ LOG(("Signal emitted on '%s'", #widget)); \ - if ((option)) \ - free((option)); \ - (option) = strdup(gtk_font_button_get_font_name(GTK_FONT_BUTTON((widget)))); \ - do { - -#define FILE_CHOOSER_CHANGED(widget, option) \ - static gboolean on_##widget##_changed(GtkWidget *widget, gpointer data) { \ - LOG(("Signal emitted on '%s'", #widget)); \ - (option) = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER((widget))); \ - do { + nsoption_set_charp(option, strdup(gtk_font_button_get_font_name(GTK_FONT_BUTTON((widget))))); \ + do #define BUTTON_CLICKED(widget) \ static gboolean on_##widget##_changed(GtkWidget *widget, gpointer data) { \ LOG(("Signal emitted on '%s'", #widget)); \ - do { + do #define END_HANDLER \ - } while (0); \ + while (0); \ return FALSE; \ } @@ -564,79 +577,84 @@ static gboolean on_comboLanguage_changed(GtkWidget *widget, gpointer data) if (lang == NULL) return FALSE; - if (option_accept_language != NULL) { - free(option_accept_language); - } - - option_accept_language = lang; + nsoption_set_charp(accept_language, lang); g_free(lang); return FALSE; } -ENTRY_CHANGED(entryHomePageURL, option_homepage_url) -END_HANDLER +ENTRY_CHANGED(entryHomePageURL, homepage_url) BUTTON_CLICKED(setCurrentPage) - const gchar *url = nsurl_access(hlcache_handle_get_url( - current_browser->current_content)); +{ + const gchar *url; + url = nsurl_access(hlcache_handle_get_url(current_browser->current_content)); gtk_entry_set_text(GTK_ENTRY(entryHomePageURL), url); - option_homepage_url = - strdup(gtk_entry_get_text(GTK_ENTRY(entryHomePageURL))); + nsoption_set_charp(homepage_url, + strdup(gtk_entry_get_text(GTK_ENTRY(entryHomePageURL)))); +} END_HANDLER BUTTON_CLICKED(setDefaultPage) - gtk_entry_set_text(GTK_ENTRY(entryHomePageURL), - "http://www.netsurf-browser.org/welcome/"); - option_homepage_url = - strdup(gtk_entry_get_text(GTK_ENTRY(entryHomePageURL))); +{ + gtk_entry_set_text(GTK_ENTRY(entryHomePageURL), NETSURF_HOMEPAGE); + nsoption_set_charp(homepage_url, + strdup(gtk_entry_get_text(GTK_ENTRY(entryHomePageURL)))); +} END_HANDLER -CHECK_CHANGED(checkHideAdverts, option_block_ads) +CHECK_CHANGED(checkHideAdverts, block_ads) +{ +} END_HANDLER -CHECK_CHANGED(checkDisplayRecentURLs, option_url_suggestion) +CHECK_CHANGED(checkDisplayRecentURLs, url_suggestion) +{ +} END_HANDLER -CHECK_CHANGED(checkSendReferer, option_send_referer) +CHECK_CHANGED(checkSendReferer, send_referer) +{ +} END_HANDLER -CHECK_CHANGED(checkShowSingleTab, option_show_single_tab) +CHECK_CHANGED(checkShowSingleTab, show_single_tab) +{ nsgtk_reflow_all_windows(); +} END_HANDLER -COMBO_CHANGED(comboProxyType, proxy_type) - LOG(("proxy type: %d", proxy_type)); - switch (proxy_type) - { +COMBO_CHANGED(comboProxyType, http_proxy_auth) +{ + LOG(("proxy auth: %d", nsoption_int(http_proxy_auth))); + switch (nsoption_int(http_proxy_auth)) { case 0: - option_http_proxy = false; - option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NONE; + nsoption_set_bool(http_proxy, false); + nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE); break; case 1: - option_http_proxy = true; - option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NONE; + nsoption_set_bool(http_proxy, true); + nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE); break; case 2: - option_http_proxy = true; - option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_BASIC; + nsoption_set_bool(http_proxy, true); + nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_BASIC); break; case 3: - option_http_proxy = true; - option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NTLM; + nsoption_set_bool(http_proxy, true); + nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NTLM); break; } gboolean sensitive = (!proxy_type == 0); - gtk_widget_set_sensitive (entryProxyHost, sensitive); - gtk_widget_set_sensitive (entryProxyPort, sensitive); - gtk_widget_set_sensitive (entryProxyUser, sensitive); - gtk_widget_set_sensitive (entryProxyPassword, sensitive); - + gtk_widget_set_sensitive(entryProxyHost, sensitive); + gtk_widget_set_sensitive(entryProxyPort, sensitive); + gtk_widget_set_sensitive(entryProxyUser, sensitive); + gtk_widget_set_sensitive(entryProxyPassword, sensitive); +} END_HANDLER -ENTRY_CHANGED(entryProxyHost, option_http_proxy_host) -END_HANDLER +ENTRY_CHANGED(entryProxyHost, http_proxy_host) gboolean on_entryProxyPort_changed(GtkWidget *widget, gpointer data) { @@ -645,92 +663,132 @@ gboolean on_entryProxyPort_changed(GtkWidget *widget, gpointer data) errno = 0; port = strtol((char *)gtk_entry_get_text(GTK_ENTRY(entryProxyPort)), NULL, 10) & 0xffff; - if (port != 0 && errno == 0) { - option_http_proxy_port = port; + if ((port != 0) && (errno == 0)) { + nsoption_set_int(http_proxy_port, port); } else { char buf[32]; - snprintf(buf, sizeof(buf), "%d", option_http_proxy_port); + snprintf(buf, sizeof(buf), "%d", nsoption_int(http_proxy_port)); SET_ENTRY(entryProxyPort, buf); } return FALSE; } -ENTRY_CHANGED(entryProxyUser, option_http_proxy_auth_user) +ENTRY_CHANGED(entryProxyUser, http_proxy_auth_user) + +ENTRY_CHANGED(entryProxyPassword, http_proxy_auth_pass) + +SPIN_CHANGED(spinMaxFetchers, max_fetchers) +{ +} END_HANDLER -ENTRY_CHANGED(entryProxyPassword, option_http_proxy_auth_pass) +SPIN_CHANGED(spinFetchesPerHost, max_fetchers_per_host) +{ +} END_HANDLER -SPIN_CHANGED(spinMaxFetchers, option_max_fetchers) +SPIN_CHANGED(spinCachedConnections, max_cached_fetch_handles) +{ +} END_HANDLER -SPIN_CHANGED(spinFetchesPerHost, option_max_fetchers_per_host) +CHECK_CHANGED(checkResampleImages, render_resample) +{ +} END_HANDLER -SPIN_CHANGED(spinCachedConnections, option_max_cached_fetch_handles) +static gboolean on_spinAnimationSpeed_changed(GtkWidget *widget, gpointer data) +{ + LOG(("Signal emitted on '%s'", "spinAnimationSpeed")); + nsoption_set_int(minimum_gif_delay, + round(gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget)) * 100.0)); + return FALSE; +} + +CHECK_CHANGED(checkDisableAnimations, animate_images) +{ + nsoption_set_bool(animate_images, !nsoption_bool(animate_images)); +} END_HANDLER -CHECK_CHANGED(checkResampleImages, option_render_resample) +CHECK_CHANGED(checkDisablePopups, disable_popups) +{ +} END_HANDLER -SPIN_CHANGED(spinAnimationSpeed, animation_delay) - option_minimum_gif_delay = round(animation_delay * 100.0); +CHECK_CHANGED(checkDisablePlugins, disable_plugins) +{ +} END_HANDLER -CHECK_CHANGED(checkDisableAnimations, option_animate_images); - option_animate_images = !option_animate_images; +SPIN_CHANGED(spinHistoryAge, history_age) +{ +} END_HANDLER -CHECK_CHANGED(checkDisablePopups, option_disable_popups) +CHECK_CHANGED(checkHoverURLs, hover_urls) +{ +} END_HANDLER -CHECK_CHANGED(checkDisablePlugins, option_disable_plugins) +FONT_CHANGED(fontSansSerif, font_sans) +{ +} END_HANDLER -SPIN_CHANGED(spinHistoryAge, option_history_age) +FONT_CHANGED(fontSerif, font_serif) +{ +} END_HANDLER -CHECK_CHANGED(checkHoverURLs, option_hover_urls) +FONT_CHANGED(fontMonospace, font_mono) +{ +} END_HANDLER -FONT_CHANGED(fontSansSerif, option_font_sans) +FONT_CHANGED(fontCursive, font_cursive) +{ +} END_HANDLER -FONT_CHANGED(fontSerif, option_font_serif) +FONT_CHANGED(fontFantasy, font_fantasy) +{ +} END_HANDLER -FONT_CHANGED(fontMonospace, option_font_mono) +COMBO_CHANGED(comboDefault, font_default) +{ +} END_HANDLER -FONT_CHANGED(fontCursive, option_font_cursive) +SPIN_CHANGED(spinDefaultSize, font_size) +{ + nsoption_set_int(font_size, nsoption_int(font_size) * 10); +} END_HANDLER -FONT_CHANGED(fontFantasy, option_font_fantasy) -END_HANDLER - -COMBO_CHANGED(comboDefault, option_font_default) -END_HANDLER - -SPIN_CHANGED(spinDefaultSize, option_font_size) - option_font_size *= 10; -END_HANDLER - -SPIN_CHANGED(spinMinimumSize, option_font_min_size) - option_font_min_size *= 10; +SPIN_CHANGED(spinMinimumSize, font_min_size) +{ + nsoption_set_int(font_min_size, nsoption_int(font_min_size) * 10); +} END_HANDLER BUTTON_CLICKED(fontPreview) +{ nsgtk_reflow_all_windows(); +} END_HANDLER -COMBO_CHANGED(comboButtonType, option_button_type) +COMBO_CHANGED(comboButtonType, button_type) +{ nsgtk_scaffolding *current = scaf_list; - option_button_type++; + nsoption_set_int(button_type, nsoption_int(button_type) + 1); + /* value of 0 is reserved for 'unset' */ while (current) { nsgtk_scaffolding_reset_offset(current); - switch(option_button_type) { + switch(nsoption_int(button_type)) { case 1: gtk_toolbar_set_style( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), @@ -764,11 +822,14 @@ COMBO_CHANGED(comboButtonType, option_button_type) } current = nsgtk_scaffolding_iterate(current); } +} END_HANDLER -COMBO_CHANGED(comboTabPosition, option_position_tab) +COMBO_CHANGED(comboTabPosition, position_tab) +{ nsgtk_scaffolding *current = scaf_list; - option_button_type++; + nsoption_set_int(button_type, nsoption_int(button_type) + 1); + /* value of 0 is reserved for 'unset' */ while (current) { nsgtk_scaffolding_reset_offset(current); @@ -777,43 +838,67 @@ COMBO_CHANGED(comboTabPosition, option_position_tab) current = nsgtk_scaffolding_iterate(current); } +} END_HANDLER -SPIN_CHANGED(spinMemoryCacheSize, option_memory_cache_size) - option_memory_cache_size <<= 20; +SPIN_CHANGED(spinMemoryCacheSize, memory_cache_size) +{ + nsoption_set_int(memory_cache_size, nsoption_int(memory_cache_size) << 20); +} END_HANDLER -SPIN_CHANGED(spinDiscCacheAge, option_disc_cache_age) +SPIN_CHANGED(spinDiscCacheAge, disc_cache_age) +{ +} END_HANDLER -CHECK_CHANGED(checkClearDownloads, option_downloads_clear) +CHECK_CHANGED(checkClearDownloads, downloads_clear) +{ +} END_HANDLER -CHECK_CHANGED(checkRequestOverwrite, option_request_overwrite) +CHECK_CHANGED(checkRequestOverwrite, request_overwrite) +{ +} END_HANDLER -FILE_CHOOSER_CHANGED(fileChooserDownloads, option_downloads_directory) +static gboolean on_fileChooserDownloads_changed(GtkWidget *widget, gpointer data) +{ + LOG(("Signal emitted on '%s'", "fileChooserDownloads")); + nsoption_set_charp(downloads_directory, gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER((widget)))); + return FALSE; +} + +CHECK_CHANGED(checkFocusNew, focus_new) +{ +} END_HANDLER -CHECK_CHANGED(checkFocusNew, option_focus_new) +CHECK_CHANGED(checkNewBlank, new_blank) +{ +} END_HANDLER -CHECK_CHANGED(checkNewBlank, option_new_blank) +CHECK_CHANGED(checkUrlSearch, search_url_bar) +{ +} END_HANDLER -CHECK_CHANGED(checkUrlSearch, option_search_url_bar) -END_HANDLER - -COMBO_CHANGED(comboSearch, option_search_provider) +COMBO_CHANGED(comboSearch, search_provider) +{ nsgtk_scaffolding *current = scaf_list; char *name; + /* refresh web search prefs from file */ - search_web_provider_details(option_search_provider); + search_web_provider_details(nsoption_charp(search_provider)); + /* retrieve ico */ search_web_retrieve_ico(false); + /* callback may handle changing gui */ if (search_web_ico() != NULL) gui_window_set_search_ico(search_web_ico()); + /* set entry */ name = search_web_provider_name(); if (name == NULL) { @@ -827,12 +912,14 @@ COMBO_CHANGED(comboSearch, option_search_provider) nsgtk_scaffolding_set_websearch(current, content); current = nsgtk_scaffolding_iterate(current); } +} END_HANDLER -COMBO_CHANGED(combotheme, option_current_theme) +COMBO_CHANGED(combotheme, current_theme) +{ nsgtk_scaffolding *current = scaf_list; char *name; - if (option_current_theme != 0) { + if (nsoption_int(current_theme) != 0) { if (nsgtk_theme_name() != NULL) free(nsgtk_theme_name()); name = nsgtk_combo_box_text_get_active_text(combotheme); @@ -850,9 +937,11 @@ COMBO_CHANGED(combotheme, option_current_theme) nsgtk_theme_implement(current); current = nsgtk_scaffolding_iterate(current); } +} END_HANDLER BUTTON_CLICKED(buttonaddtheme) +{ char *filename, *directory; size_t len; GtkWidget *fc = gtk_file_chooser_dialog_new( @@ -903,62 +992,86 @@ BUTTON_CLICKED(buttonaddtheme) if (filename != NULL) free(filename); } - +} END_HANDLER -CHECK_CHANGED(sourceButtonTab, option_source_tab) +CHECK_CHANGED(sourceButtonTab, source_tab) +{ +} END_HANDLER -SPIN_CHANGED(spinMarginTop, option_margin_top) +SPIN_CHANGED(spinMarginTop, margin_top) +{ +} END_HANDLER -SPIN_CHANGED(spinMarginBottom, option_margin_bottom) +SPIN_CHANGED(spinMarginBottom, margin_bottom) +{ +} END_HANDLER -SPIN_CHANGED(spinMarginLeft, option_margin_left) +SPIN_CHANGED(spinMarginLeft, margin_left) +{ +} END_HANDLER -SPIN_CHANGED(spinMarginRight, option_margin_right) +SPIN_CHANGED(spinMarginRight, margin_right) +{ +} END_HANDLER -SPIN_CHANGED(spinExportScale, option_export_scale) +SPIN_CHANGED(spinExportScale, export_scale) +{ +} END_HANDLER -CHECK_CHANGED(checkSuppressImages, option_suppress_images) +CHECK_CHANGED(checkSuppressImages, suppress_images) +{ +} END_HANDLER -CHECK_CHANGED(checkRemoveBackgrounds, option_remove_backgrounds) +CHECK_CHANGED(checkRemoveBackgrounds, remove_backgrounds) +{ +} END_HANDLER -CHECK_CHANGED(checkFitPage, option_enable_loosening) +CHECK_CHANGED(checkFitPage, enable_loosening) +{ +} END_HANDLER -CHECK_CHANGED(checkCompressPDF, option_enable_PDF_compression) +CHECK_CHANGED(checkCompressPDF, enable_PDF_compression) +{ +} END_HANDLER -CHECK_CHANGED(checkPasswordPDF, option_enable_PDF_password) +CHECK_CHANGED(checkPasswordPDF, enable_PDF_password) +{ +} END_HANDLER BUTTON_CLICKED(setDefaultExportOptions) - option_margin_top = DEFAULT_MARGIN_TOP_MM; - option_margin_bottom = DEFAULT_MARGIN_BOTTOM_MM; - option_margin_left = DEFAULT_MARGIN_LEFT_MM; - option_margin_right = DEFAULT_MARGIN_RIGHT_MM; - option_export_scale = DEFAULT_EXPORT_SCALE * 100; - option_suppress_images = false; - option_remove_backgrounds = false; - option_enable_loosening = true; - option_enable_PDF_compression = true; - option_enable_PDF_password = false; +{ + nsoption_set_int(margin_top, DEFAULT_MARGIN_TOP_MM); + nsoption_set_int(margin_bottom, DEFAULT_MARGIN_BOTTOM_MM); + nsoption_set_int(margin_left, DEFAULT_MARGIN_LEFT_MM); + nsoption_set_int(margin_right, DEFAULT_MARGIN_RIGHT_MM); + nsoption_set_int(export_scale, DEFAULT_EXPORT_SCALE * 100); + nsoption_set_bool(suppress_images, false); + nsoption_set_bool(remove_backgrounds, false); + nsoption_set_bool(enable_loosening, true); + nsoption_set_bool(enable_PDF_compression, true); + nsoption_set_bool(enable_PDF_password, false); - SET_SPIN(spinMarginTop, option_margin_top); - SET_SPIN(spinMarginBottom, option_margin_bottom); - SET_SPIN(spinMarginLeft, option_margin_left); - SET_SPIN(spinMarginRight, option_margin_right); - SET_SPIN(spinExportScale, option_export_scale); - SET_CHECK(checkSuppressImages, option_suppress_images); - SET_CHECK(checkRemoveBackgrounds, option_remove_backgrounds); - SET_CHECK(checkCompressPDF, option_enable_PDF_compression); - SET_CHECK(checkPasswordPDF, option_enable_PDF_password); - SET_CHECK(checkFitPage, option_enable_loosening); + SET_SPIN(spinMarginTop, nsoption_int(margin_top)); + SET_SPIN(spinMarginBottom, nsoption_int(margin_bottom)); + SET_SPIN(spinMarginLeft, nsoption_int(margin_left)); + SET_SPIN(spinMarginRight, nsoption_int(margin_right)); + SET_SPIN(spinExportScale, nsoption_int(export_scale)); + SET_CHECK(checkSuppressImages, nsoption_bool(suppress_images)); + SET_CHECK(checkRemoveBackgrounds, nsoption_bool(remove_backgrounds)); + SET_CHECK(checkCompressPDF, nsoption_bool(enable_PDF_compression)); + SET_CHECK(checkPasswordPDF, nsoption_bool(enable_PDF_password)); + SET_CHECK(checkFitPage, nsoption_bool(enable_loosening)); +} END_HANDLER diff --git a/gtk/dialogs/source.c b/gtk/dialogs/source.c index d4bf429c1..5fbd9bcd5 100644 --- a/gtk/dialogs/source.c +++ b/gtk/dialogs/source.c @@ -29,7 +29,6 @@ #include "gtk/gui.h" #include "gtk/print.h" #include "gtk/selection.h" -#include "gtk/options.h" #include "desktop/netsurf.h" #include "desktop/print.h" #include "desktop/options.h" @@ -111,7 +110,7 @@ void nsgtk_source_dialog_init(GtkWindow *parent, struct browser_window *bw) if (content_get_type(bw->current_content) != CONTENT_HTML) return; - if (option_source_tab) { + if (nsoption_bool(source_tab)) { nsgtk_source_tab_init(parent, bw); return; } diff --git a/gtk/download.c b/gtk/download.c index 2a054791e..5e22352b4 100644 --- a/gtk/download.c +++ b/gtk/download.c @@ -30,7 +30,7 @@ #include "desktop/gui.h" #include "gtk/gui.h" #include "gtk/scaffolding.h" -#include "gtk/options.h" +#include "desktop/options.h" #include "gtk/download.h" #include "gtk/window.h" #include "gtk/compat.h" @@ -373,7 +373,7 @@ void gui_download_window_done(struct gui_download_window *dw) nsgtk_download_change_sensitivity(dw, NSGTK_DOWNLOAD_CLEAR); nsgtk_download_change_status(dw, NSGTK_DOWNLOAD_COMPLETE); - if (option_downloads_clear) + if (nsoption_bool(downloads_clear)) nsgtk_download_store_clear_item(dw); else nsgtk_download_update(TRUE); @@ -735,10 +735,10 @@ gchar* nsgtk_download_dialog_show (const gchar *filename, const gchar *domain, (GTK_FILE_CHOOSER(dialog), filename); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(dialog), - option_downloads_directory); + nsoption_charp(downloads_directory)); gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER(dialog), - option_request_overwrite); + nsoption_bool(request_overwrite)); gint result = gtk_dialog_run(GTK_DIALOG(dialog)); if (result == GTK_RESPONSE_ACCEPT) @@ -748,23 +748,23 @@ gchar* nsgtk_download_dialog_show (const gchar *filename, const gchar *domain, break; } case GTK_RESPONSE_DOWNLOAD: { - destination = malloc(strlen(option_downloads_directory) + destination = malloc(strlen(nsoption_charp(downloads_directory)) + strlen(filename) + SLEN("/") + 1); if (destination == NULL) { warn_user(messages_get("NoMemory"), 0); break; } sprintf(destination, "%s/%s", - option_downloads_directory, filename); + nsoption_charp(downloads_directory), filename); /* Test if file already exists and display overwrite * confirmation if needed */ - if (g_file_test(destination, G_FILE_TEST_EXISTS) - && option_request_overwrite) { + if (g_file_test(destination, G_FILE_TEST_EXISTS) && + nsoption_bool(request_overwrite)) { message = g_strdup_printf(messages_get( "gtkOverwrite"), filename); info = g_strdup_printf(messages_get( "gtkOverwriteInfo"), - option_downloads_directory); + nsoption_charp(downloads_directory)); dialog = gtk_message_dialog_new_with_markup( nsgtk_download_parent, diff --git a/gtk/font_pango.c b/gtk/font_pango.c index 99da51561..00131b416 100644 --- a/gtk/font_pango.c +++ b/gtk/font_pango.c @@ -281,20 +281,20 @@ PangoFontDescription *nsfont_style_to_description( switch (fstyle->family) { case PLOT_FONT_FAMILY_SERIF: - desc = pango_font_description_from_string(option_font_serif); + desc = pango_font_description_from_string(nsoption_charp(font_serif)); break; case PLOT_FONT_FAMILY_MONOSPACE: - desc = pango_font_description_from_string(option_font_mono); + desc = pango_font_description_from_string(nsoption_charp(font_mono)); break; case PLOT_FONT_FAMILY_CURSIVE: - desc = pango_font_description_from_string(option_font_cursive); + desc = pango_font_description_from_string(nsoption_charp(font_cursive)); break; case PLOT_FONT_FAMILY_FANTASY: - desc = pango_font_description_from_string(option_font_fantasy); + desc = pango_font_description_from_string(nsoption_charp(font_fantasy)); break; case PLOT_FONT_FAMILY_SANS_SERIF: default: - desc = pango_font_description_from_string(option_font_sans); + desc = pango_font_description_from_string(nsoption_charp(font_sans)); break; } diff --git a/gtk/gui.c b/gtk/gui.c index 9d352036f..b403297bf 100644 --- a/gtk/gui.c +++ b/gtk/gui.c @@ -69,7 +69,6 @@ #include "gtk/throbber.h" #include "gtk/treeview.h" #include "gtk/window.h" -#include "gtk/options.h" #include "gtk/schedule.h" #include "render/box.h" @@ -240,7 +239,7 @@ static void check_options(char **respath) char *hdir = getenv("HOME"); char buf[PATH_MAX]; - option_core_select_menu = true; + nsoption_set_bool(core_select_menu, true); /* Attempt to handle nonsense status bar widths. These may exist * in people's Choices as the GTK front end used to abuse the @@ -248,8 +247,8 @@ static void check_options(char **respath) * The GTK front end now correctly uses it as a proportion of window * width. Here we assume that a value of less than 15% is wrong * and set to the default two thirds. */ - if (option_toolbar_status_width < 1500) { - option_toolbar_status_width = 6667; + if (nsoption_int(toolbar_status_width) < 1500) { + nsoption_set_int(toolbar_status_width, 6667); } /* user options should be stored in the users home directory */ @@ -260,46 +259,47 @@ static void check_options(char **respath) * resource path, they should just be set to the default * values! */ - if (!option_cookie_file) { + if (nsoption_charp(cookie_file) == NULL) { filepath_sfinddef(respath, buf, "Cookies", "~/.netsurf/"); LOG(("Using '%s' as Cookies file", buf)); - option_cookie_file = strdup(buf); + nsoption_set_charp(cookie_file, strdup(buf)); } - if (!option_cookie_jar) { + if (nsoption_charp(cookie_jar) == NULL) { filepath_sfinddef(respath, buf, "Cookies", "~/.netsurf/"); LOG(("Using '%s' as Cookie Jar file", buf)); - option_cookie_jar = strdup(buf); + nsoption_set_charp(cookie_jar, strdup(buf)); } - if (!option_cookie_file || !option_cookie_jar) + if (nsoption_charp(cookie_file) == NULL || + nsoption_charp(cookie_jar) == NULL) die("Failed initialising cookie options"); - if (!option_url_file) { + if (nsoption_charp(url_file) == NULL) { filepath_sfinddef(respath, buf, "URLs", "~/.netsurf/"); LOG(("Using '%s' as URL file", buf)); - option_url_file = strdup(buf); + nsoption_set_charp(url_file, strdup(buf)); } - if (!option_ca_path) { + if (nsoption_charp(ca_path) == NULL) { filepath_sfinddef(respath, buf, "certs", "/etc/ssl/"); LOG(("Using '%s' as certificate path", buf)); - option_ca_path = strdup(buf); + nsoption_set_charp(ca_path, strdup(buf)); } - if (!option_downloads_directory) { + if (nsoption_charp(downloads_directory) == NULL) { LOG(("Using '%s' as download directory", hdir)); - option_downloads_directory = hdir; + nsoption_set_charp(downloads_directory, hdir); } filepath_sfinddef(respath, buf, "icons/", "~/.netsurf/"); LOG(("Using '%s' as Tree icons dir", buf)); tree_set_icon_dir(strdup(buf)); - if (!option_hotlist_path) { + if (nsoption_charp(hotlist_path) == NULL) { filepath_sfinddef(respath, buf, "Hotlist", "~/.netsurf/"); LOG(("Using '%s' as Hotlist file", buf)); - option_hotlist_path = strdup(buf); + nsoption_set_charp(hotlist_path, strdup(buf)); } - if (!option_hotlist_path) + if (nsoption_charp(hotlist_path) == NULL) die("Failed initialising hotlist option"); @@ -310,12 +310,12 @@ static void check_options(char **respath) /* check what the font settings are, setting them to a default font * if they're not set - stops Pango whinging */ -#define SETFONTDEFAULT(x,y) (x) = ((x) != NULL) ? (x) : strdup((y)) - SETFONTDEFAULT(option_font_sans, "Sans"); - SETFONTDEFAULT(option_font_serif, "Serif"); - SETFONTDEFAULT(option_font_mono, "Monospace"); - SETFONTDEFAULT(option_font_cursive, "Serif"); - SETFONTDEFAULT(option_font_fantasy, "Serif"); +#define SETFONTDEFAULT(OPTION,y) if (nsoption_charp(OPTION) == NULL) nsoption_set_charp(OPTION, strdup((y))) + SETFONTDEFAULT(font_sans, "Sans"); + SETFONTDEFAULT(font_serif, "Serif"); + SETFONTDEFAULT(font_mono, "Monospace"); + SETFONTDEFAULT(font_cursive, "Serif"); + SETFONTDEFAULT(font_fantasy, "Serif"); } @@ -416,8 +416,8 @@ static void gui_init(int argc, char** argv, char **respath) filepath_sfinddef(respath, buf, "mime.types", "/etc/"); gtk_fetch_filetype_init(buf); - urldb_load(option_url_file); - urldb_load_cookies(option_cookie_file); + urldb_load(nsoption_charp(url_file)); + urldb_load_cookies(nsoption_charp(cookie_file)); /* The tree view system needs to know the screen's DPI, so we * find that out here, rather than when we create a first browser @@ -442,9 +442,9 @@ static void gui_init(int argc, char** argv, char **respath) sslcert_init(tree_content_icon_name); - if ((option_homepage_url != NULL) && - (option_homepage_url[0] != '\0')) - addr = option_homepage_url; + if (nsoption_charp(homepage_url) != NULL) { + addr = nsoption_charp(homepage_url); + } if (2 <= argc) addr = argv[1]; @@ -587,14 +587,12 @@ void gui_poll(bool active) void gui_quit(void) { nsgtk_download_destroy(); - urldb_save_cookies(option_cookie_jar); - urldb_save(option_url_file); + urldb_save_cookies(nsoption_charp(cookie_jar)); + urldb_save(nsoption_charp(url_file)); nsgtk_cookies_destroy(); nsgtk_history_destroy(); nsgtk_hotlist_destroy(); sslcert_cleanup(); - free(option_cookie_file); - free(option_cookie_jar); free(print_options_file_location); free(search_engines_file_location); free(search_default_ico_location); diff --git a/gtk/hotlist.c b/gtk/hotlist.c index e3c6b7068..dc95866db 100644 --- a/gtk/hotlist.c +++ b/gtk/hotlist.c @@ -23,7 +23,6 @@ #include "desktop/tree.h" #include "gtk/gui.h" #include "gtk/hotlist.h" -#include "gtk/options.h" #include "gtk/plotters.h" #include "gtk/scaffolding.h" #include "gtk/treeview.h" @@ -131,7 +130,7 @@ bool nsgtk_hotlist_init(const char *glade_file_location) CONNECT(window, "hide", nsgtk_tree_window_hide, hotlist_window); hotlist_initialise(nsgtk_treeview_get_tree(hotlist_window), - option_hotlist_path, + nsoption_charp(hotlist_path), tree_directory_icon_name); nsgtk_hotlist_init_menu(); @@ -163,7 +162,7 @@ void nsgtk_hotlist_init_menu(void) void nsgtk_hotlist_destroy(void) { /* TODO: what about gladeFile? */ - hotlist_cleanup(option_hotlist_path); + hotlist_cleanup(nsoption_charp(hotlist_path)); nsgtk_treeview_destroy(hotlist_window); } diff --git a/gtk/options.h b/gtk/options.h index 23de8b745..795eca91d 100644 --- a/gtk/options.h +++ b/gtk/options.h @@ -16,65 +16,68 @@ * along with this program. If not, see . */ +#ifndef _NETSURF_DESKTOP_OPTIONS_INCLUDING_ +#error "Frontend options header cannot be included directly" +#endif + #ifndef _NETSURF_GTK_OPTIONS_H_ #define _NETSURF_GTK_OPTIONS_H_ -#include "desktop/options.h" +#define NSOPTION_EXTRA_DEFINE \ + bool render_resample; \ + bool downloads_clear; \ + bool request_overwrite; \ + char *downloads_directory; \ + char *url_file; \ + bool show_single_tab; \ + int button_type; \ + bool disable_popups; \ + bool disable_plugins; \ + int history_age; \ + bool hover_urls; \ + bool focus_new; \ + bool new_blank; \ + char *hotlist_path; \ + bool source_tab; \ + int current_theme; \ + int position_tab -extern bool option_render_resample; -extern bool option_downloads_clear; -extern bool option_request_overwrite; -extern char *option_downloads_directory; -extern char *option_url_file; -extern bool option_show_single_tab; -extern int option_button_type; -extern bool option_disable_popups; -extern bool option_disable_plugins; -extern int option_history_age; -extern bool option_hover_urls; -extern bool option_focus_new; -extern bool option_new_blank; -extern char *option_hotlist_path; -extern bool option_source_tab; -extern int option_current_theme; -extern int option_position_tab; +#define NSOPTION_EXTRA_DEFAULTS \ + .render_resample = true, \ + .downloads_clear = false, \ + .request_overwrite = true, \ + .downloads_directory = NULL, \ + .url_file = NULL, \ + .show_single_tab = false, \ + .button_type = 0, \ + .disable_popups = false, \ + .disable_plugins = false, \ + .history_age = 0, \ + .hover_urls = false, \ + .focus_new = false, \ + .new_blank = false, \ + .hotlist_path = NULL, \ + .source_tab = false, \ + .current_theme = 0, \ + .position_tab = 0 -#define EXTRA_OPTION_DEFINE \ -bool option_render_resample = true; \ -bool option_downloads_clear = false; \ -bool option_request_overwrite = true; \ -char *option_downloads_directory = 0; \ -char *option_url_file = 0; \ -bool option_show_single_tab = false; \ -int option_button_type = 0; \ -bool option_disable_popups = false; \ -bool option_disable_plugins = false; \ -int option_history_age = 0; \ -bool option_hover_urls = false; \ -bool option_focus_new = false; \ -bool option_new_blank = false; \ -char *option_hotlist_path = NULL; \ -bool option_source_tab = false;\ -int option_current_theme = 0;\ -int option_position_tab = 0; - -#define EXTRA_OPTION_TABLE \ -{ "render_resample", OPTION_BOOL, &option_render_resample }, \ -{ "downloads_clear", OPTION_BOOL, &option_downloads_clear }, \ -{ "request_overwrite", OPTION_BOOL, &option_request_overwrite }, \ -{ "downloads_directory",OPTION_STRING, &option_downloads_directory }, \ -{ "url_file", OPTION_STRING, &option_url_file }, \ -{ "show_single_tab", OPTION_BOOL, &option_show_single_tab }, \ -{ "button_type", OPTION_INTEGER, &option_button_type}, \ -{ "disable_popups", OPTION_BOOL, &option_disable_popups}, \ -{ "disable_plugins", OPTION_BOOL, &option_disable_plugins}, \ -{ "history_age", OPTION_INTEGER, &option_history_age}, \ -{ "hover_urls", OPTION_BOOL, &option_hover_urls}, \ -{ "focus_new", OPTION_BOOL, &option_focus_new}, \ -{ "new_blank", OPTION_BOOL, &option_new_blank}, \ -{ "hotlist_path", OPTION_STRING, &option_hotlist_path}, \ -{ "source_tab", OPTION_BOOL, &option_source_tab},\ -{ "current_theme", OPTION_INTEGER, &option_current_theme}, \ -{ "position_tab", OPTION_INTEGER, &option_position_tab} +#define NSOPTION_EXTRA_TABLE \ +{ "render_resample", OPTION_BOOL, &nsoptions.render_resample }, \ +{ "downloads_clear", OPTION_BOOL, &nsoptions.downloads_clear }, \ +{ "request_overwrite", OPTION_BOOL, &nsoptions.request_overwrite }, \ +{ "downloads_directory",OPTION_STRING, &nsoptions.downloads_directory }, \ +{ "url_file", OPTION_STRING, &nsoptions.url_file }, \ +{ "show_single_tab", OPTION_BOOL, &nsoptions.show_single_tab }, \ +{ "button_type", OPTION_INTEGER, &nsoptions.button_type}, \ +{ "disable_popups", OPTION_BOOL, &nsoptions.disable_popups}, \ +{ "disable_plugins", OPTION_BOOL, &nsoptions.disable_plugins}, \ +{ "history_age", OPTION_INTEGER, &nsoptions.history_age}, \ +{ "hover_urls", OPTION_BOOL, &nsoptions.hover_urls}, \ +{ "focus_new", OPTION_BOOL, &nsoptions.focus_new}, \ +{ "new_blank", OPTION_BOOL, &nsoptions.new_blank}, \ +{ "hotlist_path", OPTION_STRING, &nsoptions.hotlist_path}, \ +{ "source_tab", OPTION_BOOL, &nsoptions.source_tab},\ +{ "current_theme", OPTION_INTEGER, &nsoptions.current_theme}, \ +{ "position_tab", OPTION_INTEGER, &nsoptions.position_tab} #endif diff --git a/gtk/plotters.c b/gtk/plotters.c index 4c9627380..2f2b111db 100644 --- a/gtk/plotters.c +++ b/gtk/plotters.c @@ -38,7 +38,6 @@ #include "gtk/scaffolding.h" #include "render/font.h" #include "desktop/options.h" -#include "gtk/options.h" #include "gtk/bitmap.h" GtkWidget *current_widget; diff --git a/gtk/print.c b/gtk/print.c index 63489884a..73bf3b397 100644 --- a/gtk/print.c +++ b/gtk/print.c @@ -41,7 +41,6 @@ #include "gtk/bitmap.h" #include "gtk/print.h" #include "gtk/scaffolding.h" -#include "gtk/options.h" #include "render/font.h" #include "utils/log.h" #include "utils/utils.h" diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c index 27aff2f97..34e0d514b 100644 --- a/gtk/scaffolding.c +++ b/gtk/scaffolding.c @@ -73,7 +73,6 @@ #include "gtk/toolbar.h" #include "gtk/treeview.h" #include "gtk/window.h" -#include "gtk/options.h" #include "gtk/compat.h" #include "gtk/gdk.h" #include "image/ico.h" @@ -546,9 +545,9 @@ static void nsgtk_openfile_open(const char *filename) MULTIHANDLER(newwindow) { struct browser_window *bw = nsgtk_get_browser_window(g->top_level); - const char *url = option_homepage_url; + const char *url = nsoption_charp(homepage_url); - if ((url != NULL) && (url[0] == '\0')) + if (url != NULL) url = NULL; if (url == NULL) @@ -563,15 +562,15 @@ MULTIHANDLER(newtab) { struct browser_window *bw = nsgtk_get_browser_window(g->top_level); - if (option_new_blank) { + if (nsoption_bool(new_blank)) { browser_window_create(NULL, bw, NULL, false, true); GtkWidget *window = gtk_notebook_get_nth_page(g->notebook, -1); gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &((GdkColor) {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF})); } else { - const char *url = option_homepage_url; + const char *url = nsoption_charp(homepage_url); - if ((url != NULL) && (url[0] == '\0')) + if (url != NULL) url = NULL; if (url == NULL) @@ -1177,16 +1176,21 @@ MULTIHANDLER(downloads) MULTIHANDLER(savewindowsize) { - if (GTK_IS_PANED(g->status_pane)) - option_toolbar_status_width = - gtk_paned_get_position(g->status_pane); - gtk_window_get_position(g->window, &option_window_x, - &option_window_y); - gtk_window_get_size(g->window, &option_window_width, - &option_window_height); + int x,y,w,h; + if (GTK_IS_PANED(g->status_pane)) { + nsoption_set_int(toolbar_status_width, + gtk_paned_get_position(g->status_pane)); + } + gtk_window_get_position(g->window, &x, &y); + gtk_window_get_size(g->window, &w, &h); - options_write(options_file_location); + nsoption_set_int(window_width, w); + nsoption_set_int(window_height, h); + nsoption_set_int(window_x, x); + nsoption_set_int(window_y, y); + + nsoption_write(options_file_location); return TRUE; } @@ -1371,8 +1375,9 @@ MULTIHANDLER(home) struct browser_window *bw = nsgtk_get_browser_window(g->top_level); - if (option_homepage_url != NULL && option_homepage_url[0] != '\0') - addr = option_homepage_url; + if (nsoption_charp(homepage_url) != NULL) { + addr = nsoption_charp(homepage_url); + } browser_window_go(bw, addr, 0, true); @@ -1381,8 +1386,7 @@ MULTIHANDLER(home) MULTIHANDLER(localhistory) { - struct browser_window *bw = - nsgtk_get_browser_window(g->top_level); + struct browser_window *bw = nsgtk_get_browser_window(g->top_level); int x,y, width, height, mainwidth, mainheight, margin = 20; /* if entries of the same url but different frag_ids have been added @@ -1728,10 +1732,13 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) /* set this window's size and position to what's in the options, or * or some sensible default if they're not set yet. */ - if (option_window_width > 0) { - gtk_window_move(g->window, option_window_x, option_window_y); - gtk_window_resize(g->window, option_window_width, - option_window_height); + if (nsoption_int(window_width) > 0) { + gtk_window_move(g->window, + nsoption_int(window_x), + nsoption_int(window_y)); + gtk_window_resize(g->window, + nsoption_int(window_width), + nsoption_int(window_height)); } else { /* Set to 1000x700, so we're very likely to fit even on * 1024x768 displays, not being able to take into account @@ -1741,32 +1748,39 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) } /* Default toolbar button type uses system defaults */ - if (option_button_type == 0) { + if (nsoption_int(button_type) == 0) { GtkSettings *settings = gtk_settings_get_default(); GtkIconSize tooliconsize; GtkToolbarStyle toolbarstyle; - g_object_get(settings, "gtk-toolbar-icon-size", &tooliconsize, - "gtk-toolbar-style", &toolbarstyle, NULL); + + g_object_get(settings, + "gtk-toolbar-icon-size", &tooliconsize, + "gtk-toolbar-style", &toolbarstyle, NULL); + switch (toolbarstyle) { case GTK_TOOLBAR_ICONS: - option_button_type = (tooliconsize == - GTK_ICON_SIZE_SMALL_TOOLBAR) ? - 1 : 2; + if (tooliconsize == GTK_ICON_SIZE_SMALL_TOOLBAR) { + nsoption_set_int(button_type, 1); + } else { + nsoption_set_int(button_type, 2); + } break; + case GTK_TOOLBAR_TEXT: - option_button_type = 4; + nsoption_set_int(button_type, 4); break; + case GTK_TOOLBAR_BOTH: case GTK_TOOLBAR_BOTH_HORIZ: - /* no labels in default configuration */ + /* no labels in default configuration */ default: /* No system default, so use large icons */ - option_button_type = 2; + nsoption_set_int(button_type, 2); break; } } - switch (option_button_type) { + switch (nsoption_int(button_type)) { /* case 0 is 'unset' [from fresh install / clearing options] * see above */ @@ -1901,11 +1915,12 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) /* prepare to set the web search ico */ /* init web search prefs from file */ - search_web_provider_details(option_search_provider); + search_web_provider_details(nsoption_int(search_provider)); /* potentially retrieve ico */ - if (search_web_ico() == NULL) + if (search_web_ico() == NULL) { search_web_retrieve_ico(false); + } /* set entry */ searchname = search_web_provider_name(); diff --git a/gtk/system_colour.c b/gtk/system_colour.c index b58717492..ec40947c0 100644 --- a/gtk/system_colour.c +++ b/gtk/system_colour.c @@ -39,170 +39,170 @@ static struct gui_system_colour_ctx colour_list[] = { "ActiveBorder", SLEN("ActiveBorder"), 0xff000000, - &option_sys_colour_ActiveBorder, + &nsoption_charp(sys_colour_ActiveBorder), NULL }, { "ActiveCaption", SLEN("ActiveCaption"), 0xffdddddd, - &option_sys_colour_ActiveCaption, + &nsoption_charp(sys_colour_ActiveCaption), NULL }, { "AppWorkspace", SLEN("AppWorkspace"), 0xffeeeeee, - &option_sys_colour_AppWorkspace, + &nsoption_charp(sys_colour_AppWorkspace), NULL }, { "Background", SLEN("Background"), 0xff0000aa, - &option_sys_colour_Background, + &nsoption_charp(sys_colour_Background), NULL }, { "ButtonFace", SLEN("ButtonFace"), 0xffaaaaaa, - &option_sys_colour_ButtonFace, + &nsoption_charp(sys_colour_ButtonFace), NULL }, { "ButtonHighlight", SLEN("ButtonHighlight"), 0xffdddddd, - &option_sys_colour_ButtonHighlight, + &nsoption_charp(sys_colour_ButtonHighlight), NULL }, { "ButtonShadow", SLEN("ButtonShadow"), 0xffbbbbbb, - &option_sys_colour_ButtonShadow, + &nsoption_charp(sys_colour_ButtonShadow), NULL }, { "ButtonText", SLEN("ButtonText"), 0xff000000, - &option_sys_colour_ButtonText, + &nsoption_charp(sys_colour_ButtonText), NULL }, { "CaptionText", SLEN("CaptionText"), 0xff000000, - &option_sys_colour_CaptionText, + &nsoption_charp(sys_colour_CaptionText), NULL }, { "GrayText", SLEN("GrayText"), 0xffcccccc, - &option_sys_colour_GrayText, + &nsoption_charp(sys_colour_GrayText), NULL }, { "Highlight", SLEN("Highlight"), 0xff0000ee, - &option_sys_colour_Highlight, + &nsoption_charp(sys_colour_Highlight), NULL }, { "HighlightText", SLEN("HighlightText"), 0xff000000, - &option_sys_colour_HighlightText, + &nsoption_charp(sys_colour_HighlightText), NULL }, { "InactiveBorder", SLEN("InactiveBorder"), 0xffffffff, - &option_sys_colour_InactiveBorder, + &nsoption_charp(sys_colour_InactiveBorder), NULL }, { "InactiveCaption", SLEN("InactiveCaption"), 0xffffffff, - &option_sys_colour_InactiveCaption, + &nsoption_charp(sys_colour_InactiveCaption), NULL }, { "InactiveCaptionText", SLEN("InactiveCaptionText"), 0xffcccccc, - &option_sys_colour_InactiveCaptionText, + &nsoption_charp(sys_colour_InactiveCaptionText), NULL }, { "InfoBackground", SLEN("InfoBackground"), 0xffaaaaaa, - &option_sys_colour_InfoBackground, + &nsoption_charp(sys_colour_InfoBackground), NULL }, { "InfoText", SLEN("InfoText"), 0xff000000, - &option_sys_colour_InfoText, + &nsoption_charp(sys_colour_InfoText), NULL }, { "Menu", SLEN("Menu"), 0xffaaaaaa, - &option_sys_colour_Menu, + &nsoption_charp(sys_colour_Menu), NULL }, { "MenuText", SLEN("MenuText"), 0xff000000, - &option_sys_colour_MenuText, + &nsoption_charp(sys_colour_MenuText), NULL }, { "Scrollbar", SLEN("Scrollbar"), 0xffaaaaaa, - &option_sys_colour_Scrollbar, + &nsoption_charp(sys_colour_Scrollbar), NULL }, { "ThreeDDarkShadow", SLEN("ThreeDDarkShadow"), 0xff555555, - &option_sys_colour_ThreeDDarkShadow, + &nsoption_charp(sys_colour_ThreeDDarkShadow), NULL }, { "ThreeDFace", SLEN("ThreeDFace"), 0xffdddddd, - &option_sys_colour_ThreeDFace, + &nsoption_charp(sys_colour_ThreeDFace), NULL }, { "ThreeDHighlight", SLEN("ThreeDHighlight"), 0xffaaaaaa, - &option_sys_colour_ThreeDHighlight, + &nsoption_charp(sys_colour_ThreeDHighlight), NULL }, { "ThreeDLightShadow", SLEN("ThreeDLightShadow"), 0xff999999, - &option_sys_colour_ThreeDLightShadow, + &nsoption_charp(sys_colour_ThreeDLightShadow), NULL }, { "ThreeDShadow", SLEN("ThreeDShadow"), 0xff777777, - &option_sys_colour_ThreeDShadow, + &nsoption_charp(sys_colour_ThreeDShadow), NULL }, { "Window", SLEN("Window"), 0xffaaaaaa, - &option_sys_colour_Window, + &nsoption_charp(sys_colour_Window), NULL }, { "WindowFrame", SLEN("WindowFrame"), 0xff000000, - &option_sys_colour_WindowFrame, + &nsoption_charp(sys_colour_WindowFrame), NULL }, { "WindowText", SLEN("WindowText"), 0xff000000, - &option_sys_colour_WindowText, + &nsoption_charp(sys_colour_WindowText), NULL }, diff --git a/gtk/tabs.c b/gtk/tabs.c index 9f7a68605..13f6d393d 100644 --- a/gtk/tabs.c +++ b/gtk/tabs.c @@ -25,7 +25,6 @@ #include "desktop/options.h" #include "desktop/search.h" #include "utils/utils.h" -#include "gtk/options.h" #include "gtk/search.h" #include "gtk/tabs.h" @@ -64,7 +63,7 @@ static GtkWidget *nsgtk_tab_label_setup(struct gui_window *window) hbox = gtk_hbox_new(FALSE, 2); - if (option_new_blank == true) + if (nsoption_bool(new_blank) == true) label = gtk_label_new("New Tab"); else label = gtk_label_new("Loading..."); @@ -119,7 +118,7 @@ static void nsgtk_tab_page_changed(GtkNotebook *notebook, gpointer *page, static void nsgtk_tab_orientation(GtkNotebook *notebook) { - switch (option_position_tab) { + switch (nsoption_int(position_tab)) { case 0: gtk_notebook_set_tab_pos(notebook, GTK_POS_TOP); break; @@ -144,7 +143,8 @@ static void nsgtk_tab_visibility_update(GtkNotebook *notebook, GtkWidget *child, guint page) { gint num_pages = gtk_notebook_get_n_pages(notebook); - if (option_show_single_tab == true || num_pages > 1) { + + if ((nsoption_bool(show_single_tab) == true) || (num_pages > 1)) { gtk_notebook_set_show_tabs(notebook, TRUE); } else { gtk_notebook_set_show_tabs(notebook, FALSE); diff --git a/gtk/theme.c b/gtk/theme.c index 6284e92d1..26206110e 100644 --- a/gtk/theme.c +++ b/gtk/theme.c @@ -29,7 +29,7 @@ #include "gtk/menu.h" #include "gtk/theme.h" #include "gtk/window.h" -#include "gtk/options.h" +#include "desktop/options.h" #include "gtk/dialogs/options.h" #include "utils/container.h" #include "utils/log.h" @@ -156,7 +156,7 @@ static bool nsgtk_theme_verify(const char *themename) void nsgtk_theme_init(void) { size_t len; - if (option_current_theme == 0) { + if (nsoption_int(current_theme) == 0) { return; } @@ -174,7 +174,7 @@ void nsgtk_theme_init(void) if (buf[0] == '\0') continue; - if (row_count++ == option_current_theme) { + if (row_count++ == nsoption_int(current_theme)) { if (current_theme_name != NULL) free(current_theme_name); /* clear the '\n' ["\n\0"->"\0\0"] */ diff --git a/gtk/window.c b/gtk/window.c index 068da6fa7..14a17df40 100644 --- a/gtk/window.c +++ b/gtk/window.c @@ -34,7 +34,6 @@ #include "desktop/selection.h" #include "gtk/compat.h" #include "gtk/gui.h" -#include "gtk/options.h" #include "gtk/scaffolding.h" #include "gtk/plotters.h" #include "gtk/schedule.h" @@ -507,8 +506,9 @@ static gboolean nsgtk_window_size_allocate_event(GtkWidget *widget, /* TODO: Probably want to detect when the user adjusts the * status bar width, remember that proportion for the * window, and use that here. */ - gtk_paned_set_position(g->paned, (option_toolbar_status_width * - allocation->width) / 10000); + gtk_paned_set_position(g->paned, + (nsoption_int(toolbar_status_width) * + allocation->width) / 10000); } return TRUE; @@ -533,10 +533,11 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, g->paned = NULL; g->mouse.state = 0; g->current_pointer = GUI_POINTER_DEFAULT; - if (clone != NULL) + if (clone != NULL) { bw->scale = clone->scale; - else - bw->scale = (float) option_scale / 100; + } else { + bw->scale = (float) nsoption_int(scale) / 100.0; + } g->careth = 0; @@ -582,7 +583,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, bool tempback = true; switch (temp_open_background) { case -1: - tempback = !(option_focus_new); + tempback = !(nsoption_bool(focus_new)); break; case 0: tempback = false; diff --git a/image/gif.c b/image/gif.c index 8cb89c7d7..d92eede85 100644 --- a/image/gif.c +++ b/image/gif.c @@ -158,14 +158,15 @@ static void nsgif_animate(void *p) /* Continue animating if we should */ if (gif->gif->loop_count >= 0) { delay = gif->gif->frames[gif->current_frame].frame_delay; - if (delay < option_minimum_gif_delay) - delay = option_minimum_gif_delay; + if (delay < nsoption_int(minimum_gif_delay)) + delay = nsoption_int(minimum_gif_delay); schedule(delay, nsgif_animate, gif); } - if ((!option_animate_images) || - (!gif->gif->frames[gif->current_frame].display)) + if ((!nsoption_bool(animate_images)) || + (!gif->gif->frames[gif->current_frame].display)) { return; + } /* area within gif to redraw */ f = gif->current_frame; @@ -319,8 +320,9 @@ static gif_result nsgif_get_frame(nsgif_content *gif) gif_result res = GIF_OK; current_frame = gif->current_frame; - if (!option_animate_images) + if (!nsoption_bool(animate_images)) { current_frame = 0; + } if (current_frame < gif->gif->decoded_frame) previous_frame = 0; diff --git a/image/mng.c b/image/mng.c index 32e3a2f75..8d9769b70 100644 --- a/image/mng.c +++ b/image/mng.c @@ -712,8 +712,10 @@ static bool nsmng_redraw(struct content *c, struct content_redraw_data *data, mng->bitmap, data->background_colour, flags); /* Check if we need to restart the animation */ - if ((mng->waiting) && (option_animate_images)) + if ((mng->waiting) && + (nsoption_bool(animate_images))) { nsmng_animate(c); + } return ret; } diff --git a/monkey/main.c b/monkey/main.c index d1507f6b4..45be754e1 100644 --- a/monkey/main.c +++ b/monkey/main.c @@ -21,7 +21,7 @@ #include #include "monkey/filetype.h" -#include "monkey/options.h" +#include "desktop/options.h" #include "monkey/poll.h" #include "monkey/dispatch.h" #include "monkey/browser.h" @@ -57,11 +57,11 @@ nsmonkey_init_resource(const char *resource_path) void gui_quit(void) { - urldb_save_cookies(option_cookie_jar); - urldb_save(option_url_file); + urldb_save_cookies(nsoption_charp(cookie_jar)); + urldb_save(nsoption_charp(url_file)); sslcert_cleanup(); - free(option_cookie_file); - free(option_cookie_jar); + free(nsoption_charp(cookie_file)); + free(nsoption_charp(cookie_jar)); gtk_fetch_filetype_fin(); } @@ -117,8 +117,8 @@ main(int argc, char **argv) filepath_sfinddef(respaths, buf, "mime.types", "/etc/"); gtk_fetch_filetype_init(buf); - urldb_load(option_url_file); - urldb_load_cookies(option_cookie_file); + urldb_load(nsoption_charp(url_file)); + urldb_load_cookies(nsoption_charp(cookie_file)); sslcert_init("content.png"); diff --git a/monkey/options.h b/monkey/options.h index ac14259d8..88fb7e11b 100644 --- a/monkey/options.h +++ b/monkey/options.h @@ -16,62 +16,66 @@ * along with this program. If not, see . */ -#ifndef _NETSURF_GTK_OPTIONS_H_ -#define _NETSURF_GTK_OPTIONS_H_ +#ifndef _NETSURF_DESKTOP_OPTIONS_INCLUDING_ +#error "Frontend options header cannot be included directly" +#endif -#include "desktop/options.h" +#ifndef _NETSURF_MONKEY_OPTIONS_H_ +#define _NETSURF_MONKEY_OPTIONS_H_ -extern bool option_render_resample; -extern bool option_downloads_clear; -extern bool option_request_overwrite; -extern char *option_downloads_directory; -extern char *option_url_file; -extern bool option_show_single_tab; -extern int option_button_type; -extern bool option_disable_popups; -extern bool option_disable_plugins; -extern int option_history_age; -extern bool option_hover_urls; -extern bool option_focus_new; -extern bool option_new_blank; -extern char *option_hotlist_path; -extern bool option_source_tab; -extern int option_current_theme; +#define NSOPTION_EXTRA_DEFINE \ + bool render_resample; \ + bool downloads_clear; \ + bool request_overwrite; \ + char *downloads_directory; \ + char *url_file; \ + bool show_single_tab; \ + int button_type; \ + bool disable_popups; \ + bool disable_plugins; \ + int history_age; \ + bool hover_urls; \ + bool focus_new; \ + bool new_blank; \ + char *hotlist_path; \ + bool source_tab; \ + int current_theme -#define EXTRA_OPTION_DEFINE \ -bool option_render_resample = true; \ -bool option_downloads_clear = false; \ -bool option_request_overwrite = true; \ -char *option_downloads_directory = 0; \ -char *option_url_file = 0; \ -bool option_show_single_tab = false; \ -int option_button_type = 0; \ -bool option_disable_popups = false; \ -bool option_disable_plugins = false; \ -int option_history_age = 0; \ -bool option_hover_urls = false; \ -bool option_focus_new = false; \ -bool option_new_blank = false; \ -char *option_hotlist_path = NULL; \ -bool option_source_tab = false;\ -int option_current_theme = 0; +#define NSOPTION_EXTRA_DEFAULTS \ + .render_resample = true, \ + .downloads_clear = false, \ + .request_overwrite = true, \ + .downloads_directory = NULL, \ + .url_file = NULL, \ + .show_single_tab = false, \ + .button_type = 0, \ + .disable_popups = false, \ + .disable_plugins = false, \ + .history_age = 0, \ + .hover_urls = false, \ + .focus_new = false, \ + .new_blank = false, \ + .hotlist_path = NULL, \ + .source_tab = false, \ + .current_theme = 0 + +#define NSOPTION_EXTRA_TABLE \ +{ "render_resample", OPTION_BOOL, &nsoptions.render_resample }, \ +{ "downloads_clear", OPTION_BOOL, &nsoptions.downloads_clear }, \ +{ "request_overwrite", OPTION_BOOL, &nsoptions.request_overwrite }, \ +{ "downloads_directory",OPTION_STRING, &nsoptions.downloads_directory }, \ +{ "url_file", OPTION_STRING, &nsoptions.url_file }, \ +{ "show_single_tab", OPTION_BOOL, &nsoptions.show_single_tab }, \ +{ "button_type", OPTION_INTEGER, &nsoptions.button_type}, \ +{ "disable_popups", OPTION_BOOL, &nsoptions.disable_popups}, \ +{ "disable_plugins", OPTION_BOOL, &nsoptions.disable_plugins}, \ +{ "history_age", OPTION_INTEGER, &nsoptions.history_age}, \ +{ "hover_urls", OPTION_BOOL, &nsoptions.hover_urls}, \ +{ "focus_new", OPTION_BOOL, &nsoptions.focus_new}, \ +{ "new_blank", OPTION_BOOL, &nsoptions.new_blank}, \ +{ "hotlist_path", OPTION_STRING, &nsoptions.hotlist_path}, \ +{ "source_tab", OPTION_BOOL, &nsoptions.source_tab},\ +{ "current_theme", OPTION_INTEGER, &nsoptions.current_theme} -#define EXTRA_OPTION_TABLE \ -{ "render_resample", OPTION_BOOL, &option_render_resample }, \ -{ "downloads_clear", OPTION_BOOL, &option_downloads_clear }, \ -{ "request_overwrite", OPTION_BOOL, &option_request_overwrite }, \ -{ "downloads_directory",OPTION_STRING, &option_downloads_directory }, \ -{ "url_file", OPTION_STRING, &option_url_file }, \ -{ "show_single_tab", OPTION_BOOL, &option_show_single_tab }, \ -{ "button_type", OPTION_INTEGER, &option_button_type}, \ -{ "disable_popups", OPTION_BOOL, &option_disable_popups}, \ -{ "disable_plugins", OPTION_BOOL, &option_disable_plugins}, \ -{ "history_age", OPTION_INTEGER, &option_history_age}, \ -{ "hover_urls", OPTION_BOOL, &option_hover_urls}, \ -{ "focus_new", OPTION_BOOL, &option_focus_new}, \ -{ "new_blank", OPTION_BOOL, &option_new_blank}, \ -{ "hotlist_path", OPTION_STRING, &option_hotlist_path}, \ -{ "source_tab", OPTION_BOOL, &option_source_tab},\ -{ "current_theme", OPTION_INTEGER, &option_current_theme} #endif diff --git a/monkey/system_colour.c b/monkey/system_colour.c index b58717492..ec40947c0 100644 --- a/monkey/system_colour.c +++ b/monkey/system_colour.c @@ -39,170 +39,170 @@ static struct gui_system_colour_ctx colour_list[] = { "ActiveBorder", SLEN("ActiveBorder"), 0xff000000, - &option_sys_colour_ActiveBorder, + &nsoption_charp(sys_colour_ActiveBorder), NULL }, { "ActiveCaption", SLEN("ActiveCaption"), 0xffdddddd, - &option_sys_colour_ActiveCaption, + &nsoption_charp(sys_colour_ActiveCaption), NULL }, { "AppWorkspace", SLEN("AppWorkspace"), 0xffeeeeee, - &option_sys_colour_AppWorkspace, + &nsoption_charp(sys_colour_AppWorkspace), NULL }, { "Background", SLEN("Background"), 0xff0000aa, - &option_sys_colour_Background, + &nsoption_charp(sys_colour_Background), NULL }, { "ButtonFace", SLEN("ButtonFace"), 0xffaaaaaa, - &option_sys_colour_ButtonFace, + &nsoption_charp(sys_colour_ButtonFace), NULL }, { "ButtonHighlight", SLEN("ButtonHighlight"), 0xffdddddd, - &option_sys_colour_ButtonHighlight, + &nsoption_charp(sys_colour_ButtonHighlight), NULL }, { "ButtonShadow", SLEN("ButtonShadow"), 0xffbbbbbb, - &option_sys_colour_ButtonShadow, + &nsoption_charp(sys_colour_ButtonShadow), NULL }, { "ButtonText", SLEN("ButtonText"), 0xff000000, - &option_sys_colour_ButtonText, + &nsoption_charp(sys_colour_ButtonText), NULL }, { "CaptionText", SLEN("CaptionText"), 0xff000000, - &option_sys_colour_CaptionText, + &nsoption_charp(sys_colour_CaptionText), NULL }, { "GrayText", SLEN("GrayText"), 0xffcccccc, - &option_sys_colour_GrayText, + &nsoption_charp(sys_colour_GrayText), NULL }, { "Highlight", SLEN("Highlight"), 0xff0000ee, - &option_sys_colour_Highlight, + &nsoption_charp(sys_colour_Highlight), NULL }, { "HighlightText", SLEN("HighlightText"), 0xff000000, - &option_sys_colour_HighlightText, + &nsoption_charp(sys_colour_HighlightText), NULL }, { "InactiveBorder", SLEN("InactiveBorder"), 0xffffffff, - &option_sys_colour_InactiveBorder, + &nsoption_charp(sys_colour_InactiveBorder), NULL }, { "InactiveCaption", SLEN("InactiveCaption"), 0xffffffff, - &option_sys_colour_InactiveCaption, + &nsoption_charp(sys_colour_InactiveCaption), NULL }, { "InactiveCaptionText", SLEN("InactiveCaptionText"), 0xffcccccc, - &option_sys_colour_InactiveCaptionText, + &nsoption_charp(sys_colour_InactiveCaptionText), NULL }, { "InfoBackground", SLEN("InfoBackground"), 0xffaaaaaa, - &option_sys_colour_InfoBackground, + &nsoption_charp(sys_colour_InfoBackground), NULL }, { "InfoText", SLEN("InfoText"), 0xff000000, - &option_sys_colour_InfoText, + &nsoption_charp(sys_colour_InfoText), NULL }, { "Menu", SLEN("Menu"), 0xffaaaaaa, - &option_sys_colour_Menu, + &nsoption_charp(sys_colour_Menu), NULL }, { "MenuText", SLEN("MenuText"), 0xff000000, - &option_sys_colour_MenuText, + &nsoption_charp(sys_colour_MenuText), NULL }, { "Scrollbar", SLEN("Scrollbar"), 0xffaaaaaa, - &option_sys_colour_Scrollbar, + &nsoption_charp(sys_colour_Scrollbar), NULL }, { "ThreeDDarkShadow", SLEN("ThreeDDarkShadow"), 0xff555555, - &option_sys_colour_ThreeDDarkShadow, + &nsoption_charp(sys_colour_ThreeDDarkShadow), NULL }, { "ThreeDFace", SLEN("ThreeDFace"), 0xffdddddd, - &option_sys_colour_ThreeDFace, + &nsoption_charp(sys_colour_ThreeDFace), NULL }, { "ThreeDHighlight", SLEN("ThreeDHighlight"), 0xffaaaaaa, - &option_sys_colour_ThreeDHighlight, + &nsoption_charp(sys_colour_ThreeDHighlight), NULL }, { "ThreeDLightShadow", SLEN("ThreeDLightShadow"), 0xff999999, - &option_sys_colour_ThreeDLightShadow, + &nsoption_charp(sys_colour_ThreeDLightShadow), NULL }, { "ThreeDShadow", SLEN("ThreeDShadow"), 0xff777777, - &option_sys_colour_ThreeDShadow, + &nsoption_charp(sys_colour_ThreeDShadow), NULL }, { "Window", SLEN("Window"), 0xffaaaaaa, - &option_sys_colour_Window, + &nsoption_charp(sys_colour_Window), NULL }, { "WindowFrame", SLEN("WindowFrame"), 0xff000000, - &option_sys_colour_WindowFrame, + &nsoption_charp(sys_colour_WindowFrame), NULL }, { "WindowText", SLEN("WindowText"), 0xff000000, - &option_sys_colour_WindowText, + &nsoption_charp(sys_colour_WindowText), NULL }, diff --git a/render/box_construct.c b/render/box_construct.c index 4b280fbe9..b53328d1f 100644 --- a/render/box_construct.c +++ b/render/box_construct.c @@ -404,9 +404,9 @@ static bool box_construct_marker(struct box *box, const char *title, break; } - if (css_computed_list_style_image(box->style, &image_uri) == - CSS_LIST_STYLE_IMAGE_URI && image_uri != NULL && - option_foreground_images == true) { + if (css_computed_list_style_image(box->style, &image_uri) == CSS_LIST_STYLE_IMAGE_URI && + (image_uri != NULL) && + (nsoption_bool(foreground_images) == true)) { nsurl *url; nserror error; @@ -712,7 +712,7 @@ bool box_construct_element(struct box_construct_ctx *ctx, /* Kick off fetch for any background image */ if (css_computed_background_image(box->style, &bgimage_uri) == CSS_BACKGROUND_IMAGE_IMAGE && bgimage_uri != NULL && - option_background_images == true) { + nsoption_bool(background_images) == true) { nsurl *url; nserror error; @@ -1380,8 +1380,9 @@ bool box_image(BOX_SPECIAL_PARAMS) box->length = strlen(box->text); } - if (option_foreground_images == false) + if (nsoption_bool(foreground_images) == false) { return true; + } /* imagemap associated with this image */ if (!box_get_attribute(n, "usemap", content, &box->usemap)) @@ -2041,7 +2042,7 @@ bool box_input(BOX_SPECIAL_PARAMS) if (box->style && css_computed_display(box->style, n->parent == NULL) != CSS_DISPLAY_NONE && - option_foreground_images == true) { + nsoption_bool(foreground_images) == true) { if ((s = (char *) xmlGetProp(n, (const xmlChar*) "src"))) { error = nsurl_join(content->base_url, s, &url); diff --git a/render/font.c b/render/font.c index 87511b261..a98a89ada 100644 --- a/render/font.c +++ b/render/font.c @@ -49,8 +49,8 @@ void font_plot_style_from_css(const css_computed_style *css, INTTOFIX(FONT_SIZE_SCALE))); /* Clamp font size to configured minimum */ - if (fstyle->size < (option_font_min_size * FONT_SIZE_SCALE) / 10) - fstyle->size = (option_font_min_size * FONT_SIZE_SCALE) / 10; + if (fstyle->size < (nsoption_int(font_min_size) * FONT_SIZE_SCALE) / 10) + fstyle->size = (nsoption_int(font_min_size) * FONT_SIZE_SCALE) / 10; fstyle->weight = plot_font_weight(css_computed_font_weight(css)); fstyle->flags = plot_font_flags(css_computed_font_style(css), diff --git a/render/html.c b/render/html.c index 1e447b1c1..26232a230 100644 --- a/render/html.c +++ b/render/html.c @@ -1205,7 +1205,7 @@ bool html_find_stylesheets(html_content *c, xmlNode *html) c->base.active++; } - if (option_block_ads) { + if (nsoption_bool(block_ads)) { ns_error = hlcache_handle_retrieve(html_adblock_stylesheet_url, 0, content_get_url(&c->base), NULL, html_convert_css_callback, c, &child, accept, @@ -1791,7 +1791,7 @@ nserror html_object_callback(hlcache_handle *object, * 5) the time since the previous reformat is more than the * configured minimum time between reformats * then reformat the page to display newly fetched objects */ - else if (option_incremental_reflow && + else if (nsoption_bool(incremental_reflow) && event->type == CONTENT_MSG_DONE && !(box->flags & REPLACE_DIM) && (c->base.status == CONTENT_STATUS_READY || @@ -1966,8 +1966,8 @@ void html_reformat(struct content *c, int width, int height) time_taken = wallclock() - time_before; c->reformat_time = wallclock() + - ((time_taken * 3 < option_min_reflow_period ? - option_min_reflow_period : time_taken * 3)); + ((time_taken * 3 < nsoption_int(min_reflow_period) ? + nsoption_int(min_reflow_period) : time_taken * 3)); } diff --git a/render/html_interaction.c b/render/html_interaction.c index 91bbd920e..0078b3070 100644 --- a/render/html_interaction.c +++ b/render/html_interaction.c @@ -372,7 +372,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw, status = messages_get("FormSelect"); pointer = GUI_POINTER_MENU; if (mouse & BROWSER_MOUSE_CLICK_1 && - option_core_select_menu) { + nsoption_bool(core_select_menu)) { html->visible_select_menu = gadget; form_open_select_menu(c, gadget, form_select_menu_callback, diff --git a/render/html_redraw.c b/render/html_redraw.c index bfef82406..5473152e5 100644 --- a/render/html_redraw.c +++ b/render/html_redraw.c @@ -2252,7 +2252,7 @@ bool html_redraw_inline_background(int x, int y, struct box *box, float scale, plot_content = (box->background != NULL); - if (html_redraw_printing && option_remove_backgrounds) + if (html_redraw_printing && nsoption_bool(remove_backgrounds)) return true; if (plot_content) { diff --git a/render/layout.c b/render/layout.c index d1eefdc46..ac6339757 100644 --- a/render/layout.c +++ b/render/layout.c @@ -2402,7 +2402,7 @@ bool layout_line(struct box *first, int *width, int *y, opt_maxwidth =opt_width; } b->width = opt_maxwidth; - if (option_core_select_menu) + if (nsoption_bool(core_select_menu)) b->width += SCROLLBAR_WIDTH; } else { font_func->font_width(&fstyle, b->text, @@ -3076,7 +3076,7 @@ struct box *layout_minmax_line(struct box *first, } b->width = opt_maxwidth; - if (option_core_select_menu) + if (nsoption_bool(core_select_menu)) b->width += SCROLLBAR_WIDTH; } else { diff --git a/render/search.c b/render/search.c index a1852c22a..a51b279da 100644 --- a/render/search.c +++ b/render/search.c @@ -29,7 +29,6 @@ #include "content/hlcache.h" #include "desktop/browser.h" #include "desktop/gui.h" -#include "desktop/options.h" #include "desktop/selection.h" #include "render/box.h" #include "render/html.h" diff --git a/render/textplain.c b/render/textplain.c index eabc19b20..f397689ee 100644 --- a/render/textplain.c +++ b/render/textplain.c @@ -267,7 +267,7 @@ nserror textplain_create_internal(textplain_content *c, lwc_string *encoding) parserutils_error error; union content_msg_data msg_data; - textplain_style.size = (option_font_size * FONT_SIZE_SCALE) / 10; + textplain_style.size = (nsoption_int(font_size) * FONT_SIZE_SCALE) / 10; utf8_data = talloc_array(c, char, CHUNK); if (utf8_data == NULL) diff --git a/riscos/bitmap.c b/riscos/bitmap.c index 12198fe13..257d7ced2 100644 --- a/riscos/bitmap.c +++ b/riscos/bitmap.c @@ -39,7 +39,7 @@ #include "image/bitmap.h" #include "riscos/bitmap.h" #include "riscos/image.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/palettes.h" #include "riscos/content-handlers/sprite.h" #include "riscos/tinct.h" @@ -138,7 +138,7 @@ void bitmap_initialise_memory(void) available_memory = free_slot; /* calculate our memory block sizes */ - if (option_image_memory_direct == -1) { + if (nsoption_int(image_memory_direct) == -1) { /* claim 25% of free memory - min 256KB, max 32768KB */ direct_size = available_memory / 4; if (direct_size < (256 << 10)) @@ -146,9 +146,9 @@ void bitmap_initialise_memory(void) if (direct_size > (32768 << 10)) direct_size = (32768 << 10); } else { - direct_size = (option_image_memory_direct << 10); + direct_size = (nsoption_int(image_memory_direct) << 10); } - if (option_image_memory_compressed == -1) { + if (nsoption_int(image_memory_compressed) == -1) { /* claim 10% of free memory - min 256KB, max 4192KB */ compressed_size = available_memory / 10; if (compressed_size < (256 << 10)) @@ -156,7 +156,7 @@ void bitmap_initialise_memory(void) if (compressed_size > (4192 << 10)) compressed_size = (4192 << 10); } else { - compressed_size = (option_image_memory_compressed << 10); + compressed_size = (nsoption_int(image_memory_compressed) << 10); } /* set our values. No fixed buffers here, ho hum. */ diff --git a/riscos/buffer.c b/riscos/buffer.c index d135d3d84..6eec8bf7e 100644 --- a/riscos/buffer.c +++ b/riscos/buffer.c @@ -27,7 +27,7 @@ #include "oslib/wimpreadsysinfo.h" #include "riscos/buffer.h" #include "riscos/gui.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/tinct.h" #include "riscos/wimp.h" #include "riscos/wimputils.h" @@ -274,7 +274,7 @@ void ro_gui_buffer_close(void) _swix(Tinct_Plot, _IN(2) | _IN(3) | _IN(4) | _IN(7), (char *)(buffer + 1), clipping.x0, clipping.y0, - option_fg_plot_style); + nsoption_int(fg_plot_style)); else xosspriteop_put_sprite_user_coords(osspriteop_PTR, buffer, (osspriteop_id)(buffer + 1), diff --git a/riscos/configure/con_cache.c b/riscos/configure/con_cache.c index 45a952cdb..cd211236e 100644 --- a/riscos/configure/con_cache.c +++ b/riscos/configure/con_cache.c @@ -21,7 +21,6 @@ #include "desktop/options.h" #include "riscos/dialog.h" #include "riscos/gui.h" -#include "riscos/options.h" #include "riscos/wimp.h" #include "riscos/wimp_event.h" #include "riscos/configure.h" @@ -45,7 +44,7 @@ bool ro_gui_options_cache_initialise(wimp_w w) { /* set the current values */ ro_gui_set_icon_decimal(w, CACHE_MEMORY_SIZE, - (option_memory_cache_size * 10) >> 20, 1); + (nsoption_int(memory_cache_size) * 10) >> 20, 1); /* initialise all functions for a newly created window */ ro_gui_wimp_event_register_numeric_field(w, CACHE_MEMORY_SIZE, @@ -74,8 +73,9 @@ bool ro_gui_options_cache_click(wimp_pointer *pointer) bool ro_gui_options_cache_ok(wimp_w w) { - option_memory_cache_size = (((ro_gui_get_icon_decimal(w, - CACHE_MEMORY_SIZE, 1) + 1) << 20) - 1) / 10; + nsoption_set_int(memory_cache_size, + (((ro_gui_get_icon_decimal(w, + CACHE_MEMORY_SIZE, 1) + 1) << 20) - 1) / 10); ro_gui_save_options(); return true; diff --git a/riscos/configure/con_connect.c b/riscos/configure/con_connect.c index fd74155bd..c47e90419 100644 --- a/riscos/configure/con_connect.c +++ b/riscos/configure/con_connect.c @@ -24,7 +24,6 @@ #include "riscos/configure/configure.h" #include "riscos/dialog.h" #include "riscos/menus.h" -#include "riscos/options.h" #include "riscos/tinct.h" #include "riscos/wimp.h" #include "riscos/wimp_event.h" @@ -55,7 +54,7 @@ #define CONNECTION_CANCEL_BUTTON 28 #define CONNECTION_OK_BUTTON 29 -#define http_proxy_type (option_http_proxy ? (option_http_proxy_auth + 1) : 0) +#define http_proxy_type (nsoption_bool(http_proxy) ? (nsoption_int(http_proxy_auth) + 1) : 0) static int ro_gui_options_connection_proxy_type(wimp_w w); static void ro_gui_options_connection_default(wimp_pointer *pointer); @@ -68,27 +67,27 @@ bool ro_gui_options_connection_initialise(wimp_w w) int proxy_type; /* set the current values */ - proxy_type = (option_http_proxy ? (option_http_proxy_auth + 1) : 0); + proxy_type = (nsoption_bool(http_proxy) ? (nsoption_int(http_proxy_auth) + 1) : 0); ro_gui_set_icon_string(w, CONNECTION_PROXY_FIELD, proxy_type_menu->entries[proxy_type]. data.indirected_text.text, true); ro_gui_set_icon_string(w, CONNECTION_PROXY_HOST, - option_http_proxy_host ? - option_http_proxy_host : "", true); + nsoption_charp(http_proxy_host) ? + nsoption_charp(http_proxy_host) : "", true); ro_gui_set_icon_integer(w, CONNECTION_PROXY_PORT, - option_http_proxy_port); + nsoption_int(http_proxy_port)); ro_gui_set_icon_string(w, CONNECTION_PROXY_USERNAME, - option_http_proxy_auth_user ? - option_http_proxy_auth_user : "", true); + nsoption_charp(http_proxy_auth_user) ? + nsoption_charp(http_proxy_auth_user) : "", true); ro_gui_set_icon_string(w, CONNECTION_PROXY_PASSWORD, - option_http_proxy_auth_pass ? - option_http_proxy_auth_pass : "", true); + nsoption_charp(http_proxy_auth_pass) ? + nsoption_charp(http_proxy_auth_pass) : "", true); ro_gui_set_icon_integer(w, CONNECTION_MAX_FETCH_FIELD, - option_max_fetchers); + nsoption_int(max_fetchers)); ro_gui_set_icon_integer(w, CONNECTION_HOST_FETCH_FIELD, - option_max_fetchers_per_host); + nsoption_int(max_fetchers_per_host)); ro_gui_set_icon_integer(w, CONNECTION_CACHE_FETCH_FIELD, - option_max_cached_fetch_handles); + nsoption_int(max_cached_fetch_handles)); ro_gui_options_connection_update(w, -1, NULL, NULL, NO_ACTION); /* register icons */ @@ -181,32 +180,39 @@ bool ro_gui_options_connection_ok(wimp_w w) int proxy_type; proxy_type = ro_gui_options_connection_proxy_type(w); - if (proxy_type == 0) - option_http_proxy = false; - else { - option_http_proxy = true; - option_http_proxy_auth = proxy_type - 1; + if (proxy_type == 0) { + nsoption_set_bool(http_proxy, false); + } else { + nsoption_set_bool(http_proxy, true); + nsoption_set_int(http_proxy_auth, proxy_type - 1); } - if (option_http_proxy_host) - free(option_http_proxy_host); - option_http_proxy_host = strdup(ro_gui_get_icon_string(w, - CONNECTION_PROXY_HOST)); - option_http_proxy_port = ro_gui_get_icon_decimal(w, - CONNECTION_PROXY_PORT, 0); - if (option_http_proxy_auth_user) - free(option_http_proxy_auth_user); - option_http_proxy_auth_user = strdup(ro_gui_get_icon_string(w, - CONNECTION_PROXY_USERNAME)); - if (option_http_proxy_auth_pass) - free(option_http_proxy_auth_pass); - option_http_proxy_auth_pass = strdup(ro_gui_get_icon_string(w, - CONNECTION_PROXY_PASSWORD)); - option_max_fetchers = ro_gui_get_icon_decimal(w, - CONNECTION_MAX_FETCH_FIELD, 0); - option_max_fetchers_per_host = ro_gui_get_icon_decimal(w, - CONNECTION_HOST_FETCH_FIELD, 0); - option_max_cached_fetch_handles = ro_gui_get_icon_decimal(w, - CONNECTION_CACHE_FETCH_FIELD, 0); + + nsoption_set_charp(http_proxy_host, + strdup(ro_gui_get_icon_string(w, + CONNECTION_PROXY_HOST))); + + nsoption_set_int(http_proxy_port, + ro_gui_get_icon_decimal(w, CONNECTION_PROXY_PORT, 0)); + + nsoption_set_charp(http_proxy_auth_user, + strdup(ro_gui_get_icon_string(w, + CONNECTION_PROXY_USERNAME))); + + nsoption_set_charp(http_proxy_auth_pass, + strdup(ro_gui_get_icon_string(w, + CONNECTION_PROXY_PASSWORD))); + + nsoption_set_int(max_fetchers, + ro_gui_get_icon_decimal(w, + CONNECTION_MAX_FETCH_FIELD, 0)); + + nsoption_set_int(max_fetchers_per_host, + ro_gui_get_icon_decimal(w, + CONNECTION_HOST_FETCH_FIELD, 0)); + + nsoption_set_int(max_cached_fetch_handles, + ro_gui_get_icon_decimal(w, + CONNECTION_CACHE_FETCH_FIELD, 0)); ro_gui_save_options(); return true; diff --git a/riscos/configure/con_content.c b/riscos/configure/con_content.c index bda7b6d57..a8e9f78b4 100644 --- a/riscos/configure/con_content.c +++ b/riscos/configure/con_content.c @@ -20,7 +20,6 @@ #include "desktop/options.h" #include "riscos/dialog.h" #include "riscos/gui.h" -#include "riscos/options.h" #include "riscos/wimp.h" #include "riscos/wimp_event.h" #include "riscos/configure.h" @@ -44,13 +43,13 @@ bool ro_gui_options_content_initialise(wimp_w w) { /* set the current values */ ro_gui_set_icon_selected_state(w, CONTENT_BLOCK_ADVERTISEMENTS, - option_block_ads); + nsoption_bool(block_ads)); ro_gui_set_icon_selected_state(w, CONTENT_BLOCK_POPUPS, - option_block_popups); + nsoption_bool(block_popups)); ro_gui_set_icon_selected_state(w, CONTENT_NO_PLUGINS, - option_no_plugins); + nsoption_bool(no_plugins)); ro_gui_set_icon_selected_state(w, CONTENT_TARGET_BLANK, - option_target_blank); + nsoption_bool(target_blank)); /* initialise all functions for a newly created window */ ro_gui_wimp_event_register_checkbox(w, CONTENT_BLOCK_ADVERTISEMENTS); @@ -83,14 +82,16 @@ void ro_gui_options_content_default(wimp_pointer *pointer) bool ro_gui_options_content_ok(wimp_w w) { - option_block_ads = ro_gui_get_icon_selected_state(w, - CONTENT_BLOCK_ADVERTISEMENTS); - option_block_popups = ro_gui_get_icon_selected_state(w, - CONTENT_BLOCK_POPUPS); - option_no_plugins = ro_gui_get_icon_selected_state(w, - CONTENT_NO_PLUGINS); - option_target_blank = ro_gui_get_icon_selected_state(w, - CONTENT_TARGET_BLANK); + nsoption_set_bool(block_ads, + ro_gui_get_icon_selected_state(w, CONTENT_BLOCK_ADVERTISEMENTS)); + + nsoption_set_bool(block_popups, + ro_gui_get_icon_selected_state(w, CONTENT_BLOCK_POPUPS)); + nsoption_set_bool(no_plugins, + ro_gui_get_icon_selected_state(w, CONTENT_NO_PLUGINS)); + + nsoption_set_bool(target_blank, + ro_gui_get_icon_selected_state(w, CONTENT_TARGET_BLANK)); ro_gui_save_options(); return true; diff --git a/riscos/configure/con_fonts.c b/riscos/configure/con_fonts.c index b420b26e5..0bd13ce2a 100644 --- a/riscos/configure/con_fonts.c +++ b/riscos/configure/con_fonts.c @@ -23,7 +23,6 @@ #include "riscos/dialog.h" #include "riscos/gui.h" #include "riscos/menus.h" -#include "riscos/options.h" #include "riscos/wimp.h" #include "riscos/wimp_event.h" #include "riscos/configure.h" @@ -74,15 +73,15 @@ static bool ro_gui_options_fonts_init_menu(void); bool ro_gui_options_fonts_initialise(wimp_w w) { /* set the current values */ - ro_gui_set_icon_decimal(w, FONT_DEFAULT_SIZE, option_font_size, 1); - ro_gui_set_icon_decimal(w, FONT_MINIMUM_SIZE, option_font_min_size, 1); - ro_gui_set_icon_string(w, FONT_SANS_FIELD, option_font_sans, true); - ro_gui_set_icon_string(w, FONT_SERIF_FIELD, option_font_serif, true); - ro_gui_set_icon_string(w, FONT_MONOSPACE_FIELD, option_font_mono, true); - ro_gui_set_icon_string(w, FONT_CURSIVE_FIELD, option_font_cursive, true); - ro_gui_set_icon_string(w, FONT_FANTASY_FIELD, option_font_fantasy, true); + ro_gui_set_icon_decimal(w, FONT_DEFAULT_SIZE, nsoption_int(font_size), 1); + ro_gui_set_icon_decimal(w, FONT_MINIMUM_SIZE, nsoption_int(font_min_size), 1); + ro_gui_set_icon_string(w, FONT_SANS_FIELD, nsoption_charp(font_sans), true); + ro_gui_set_icon_string(w, FONT_SERIF_FIELD, nsoption_charp(font_serif), true); + ro_gui_set_icon_string(w, FONT_MONOSPACE_FIELD, nsoption_charp(font_mono), true); + ro_gui_set_icon_string(w, FONT_CURSIVE_FIELD, nsoption_charp(font_cursive), true); + ro_gui_set_icon_string(w, FONT_FANTASY_FIELD, nsoption_charp(font_fantasy), true); ro_gui_set_icon_string(w, FONT_DEFAULT_FIELD, - font_names[option_font_default], true); + font_names[nsoption_int(font_default)], true); if (!ro_gui_options_fonts_init_menu()) return false; @@ -140,22 +139,32 @@ bool ro_gui_options_fonts_ok(wimp_w w) { unsigned int i; - option_font_size = ro_gui_get_icon_decimal(w, FONT_DEFAULT_SIZE, 1); - option_font_min_size = ro_gui_get_icon_decimal(w, FONT_MINIMUM_SIZE, 1); - if (option_font_size < option_font_min_size) { - option_font_size = option_font_min_size; - ro_gui_set_icon_decimal(w, FONT_DEFAULT_SIZE, option_font_size, 1); - } - free(option_font_sans); - option_font_sans = strdup(ro_gui_get_icon_string(w, FONT_SANS_FIELD)); - free(option_font_serif); - option_font_serif = strdup(ro_gui_get_icon_string(w, FONT_SERIF_FIELD)); - free(option_font_mono); - option_font_mono = strdup(ro_gui_get_icon_string(w, FONT_MONOSPACE_FIELD)); - free(option_font_cursive); - option_font_cursive = strdup(ro_gui_get_icon_string(w, FONT_CURSIVE_FIELD)); - free(option_font_fantasy); - option_font_fantasy = strdup(ro_gui_get_icon_string(w, FONT_FANTASY_FIELD)); + nsoption_set_int(font_size, + ro_gui_get_icon_decimal(w, FONT_DEFAULT_SIZE, 1)); + + nsoption_set_int(font_min_size, + ro_gui_get_icon_decimal(w, FONT_MINIMUM_SIZE, 1)); + + if (nsoption_int(font_size) < nsoption_int(font_min_size)) { + nsoption_set_int(font_size, nsoption_int(font_min_size)); + ro_gui_set_icon_decimal(w, FONT_DEFAULT_SIZE, nsoption_int(font_size), 1); + +} + + nsoption_set_charp(font_sans, + strdup(ro_gui_get_icon_string(w, FONT_SANS_FIELD))); + + nsoption_set_charp(font_serif, + strdup(ro_gui_get_icon_string(w, FONT_SERIF_FIELD))); + + nsoption_set_charp(font_mono, + strdup(ro_gui_get_icon_string(w, FONT_MONOSPACE_FIELD))); + + nsoption_set_charp(font_cursive, + strdup(ro_gui_get_icon_string(w, FONT_CURSIVE_FIELD))); + + nsoption_set_charp(font_fantasy, + strdup(ro_gui_get_icon_string(w, FONT_FANTASY_FIELD))); for (i = 0; i != 5; i++) { if (!strcmp(font_names[i], ro_gui_get_icon_string(w, @@ -166,7 +175,7 @@ bool ro_gui_options_fonts_ok(wimp_w w) /* this should never happen, but still */ i = 0; - option_font_default = i; + nsoption_set_int(font_default, i); ro_gui_save_options(); return true; diff --git a/riscos/configure/con_home.c b/riscos/configure/con_home.c index 65cc4e39a..9e966b96e 100644 --- a/riscos/configure/con_home.c +++ b/riscos/configure/con_home.c @@ -21,7 +21,6 @@ #include "riscos/dialog.h" #include "riscos/gui.h" #include "riscos/menus.h" -#include "riscos/options.h" #include "riscos/url_suggest.h" #include "riscos/wimp.h" #include "riscos/wimp_event.h" @@ -46,9 +45,12 @@ bool ro_gui_options_home_initialise(wimp_w w) { /* set the current values */ ro_gui_set_icon_string(w, HOME_URL_FIELD, - option_homepage_url ? option_homepage_url : "", true); + nsoption_charp(homepage_url) ? + nsoption_charp(homepage_url) : "", true); + ro_gui_set_icon_selected_state(w, HOME_OPEN_STARTUP, - option_open_browser_at_startup); + nsoption_bool(open_browser_at_startup)); + ro_gui_set_icon_shaded_state(w, HOME_URL_GRIGHT, !ro_gui_url_suggest_prepare_menu()); @@ -78,11 +80,11 @@ void ro_gui_options_home_default(wimp_pointer *pointer) bool ro_gui_options_home_ok(wimp_w w) { - if (option_homepage_url) - free(option_homepage_url); - option_homepage_url = strdup(ro_gui_get_icon_string(w, HOME_URL_FIELD)); - option_open_browser_at_startup = ro_gui_get_icon_selected_state(w, - HOME_OPEN_STARTUP); + nsoption_set_charp(homepage_url, + strdup(ro_gui_get_icon_string(w, HOME_URL_FIELD))); + + nsoption_set_bool(open_browser_at_startup, + ro_gui_get_icon_selected_state(w, HOME_OPEN_STARTUP)); ro_gui_save_options(); return true; diff --git a/riscos/configure/con_image.c b/riscos/configure/con_image.c index 1cb29a267..8617e6d2e 100644 --- a/riscos/configure/con_image.c +++ b/riscos/configure/con_image.c @@ -24,7 +24,6 @@ #include "riscos/configure/configure.h" #include "riscos/dialog.h" #include "riscos/menus.h" -#include "riscos/options.h" #include "riscos/tinct.h" #include "riscos/wimp.h" #include "riscos/wimp_event.h" @@ -78,19 +77,19 @@ bool ro_gui_options_image_initialise(wimp_w w) /* set the current values */ for (i = 0; (i < 4); i++) { - if ((unsigned int)option_fg_plot_style == tinct_options[i]) + if ((unsigned int)nsoption_int(fg_plot_style) == tinct_options[i]) ro_gui_set_icon_string(w, IMAGE_FOREGROUND_FIELD, image_quality_menu->entries[i]. data.indirected_text.text, true); - if ((unsigned int)option_bg_plot_style == tinct_options[i]) + if ((unsigned int)nsoption_int(bg_plot_style) == tinct_options[i]) ro_gui_set_icon_string(w, IMAGE_BACKGROUND_FIELD, image_quality_menu->entries[i]. data.indirected_text.text, true); } ro_gui_set_icon_decimal(w, IMAGE_SPEED_FIELD, - option_minimum_gif_delay, 2); + nsoption_int(minimum_gif_delay), 2); ro_gui_set_icon_selected_state(w, IMAGE_DISABLE_ANIMATION, - !option_animate_images); + !nsoption_bool(animate_images)); ro_gui_options_update_shading(w); /* register icons */ @@ -252,12 +251,16 @@ void ro_gui_options_update_shading(wimp_w w) bool ro_gui_options_image_ok(wimp_w w) { - ro_gui_options_image_read(w, (unsigned int *) &option_bg_plot_style, - (unsigned int *) &option_fg_plot_style); - option_minimum_gif_delay = ro_gui_get_icon_decimal(w, - IMAGE_SPEED_FIELD, 2); - option_animate_images = !ro_gui_get_icon_selected_state(w, - IMAGE_DISABLE_ANIMATION); + ro_gui_options_image_read(w, + (unsigned int *)&nsoption_int(bg_plot_style), + (unsigned int *)&nsoption_int(fg_plot_style)); + + nsoption_set_int(minimum_gif_delay, + ro_gui_get_icon_decimal(w, IMAGE_SPEED_FIELD, 2)); + + nsoption_set_bool(animate_images, + !ro_gui_get_icon_selected_state(w, + IMAGE_DISABLE_ANIMATION)); ro_gui_save_options(); return true; diff --git a/riscos/configure/con_inter.c b/riscos/configure/con_inter.c index 570ba5782..be2114b05 100644 --- a/riscos/configure/con_inter.c +++ b/riscos/configure/con_inter.c @@ -19,7 +19,7 @@ #include #include "riscos/dialog.h" #include "riscos/gui.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/wimp.h" #include "riscos/wimp_event.h" #include "riscos/configure.h" @@ -46,23 +46,23 @@ bool ro_gui_options_interface_initialise(wimp_w w) { /* set the current values */ ro_gui_set_icon_selected_state(w, INTERFACE_STRIP_EXTNS_OPTION, - option_strip_extensions); + nsoption_bool(strip_extensions)); ro_gui_set_icon_selected_state(w, INTERFACE_CONFIRM_OVWR_OPTION, - option_confirm_overwrite); + nsoption_bool(confirm_overwrite)); ro_gui_set_icon_selected_state(w, INTERFACE_URL_COMPLETE_OPTION, - option_url_suggestion); + nsoption_bool(url_suggestion)); ro_gui_set_icon_selected_state(w, INTERFACE_HISTORY_TOOLTIP_OPTION, - option_history_tooltip); + nsoption_bool(history_tooltip)); ro_gui_set_icon_selected_state(w, INTERFACE_THUMBNAIL_ICONISE_OPTION, - option_thumbnail_iconise); + nsoption_bool(thumbnail_iconise)); ro_gui_set_icon_selected_state(w, INTERFACE_USE_EXTERNAL_HOTLIST, - option_external_hotlists); + nsoption_bool(external_hotlists)); ro_gui_set_icon_string(w, INTERFACE_EXTERNAL_HOTLIST_APP, - (option_external_hotlist_app) ? - option_external_hotlist_app : "", false); + (nsoption_charp(external_hotlist_app)) ? + nsoption_charp(external_hotlist_app) : "", false); ro_gui_set_icon_shaded_state(w, INTERFACE_EXTERNAL_HOTLIST_APP, - !option_external_hotlists); + !nsoption_bool(external_hotlists)); /* initialise all functions for a newly created window */ ro_gui_wimp_event_register_mouse_click(w, @@ -117,23 +117,27 @@ void ro_gui_options_interface_default(wimp_pointer *pointer) bool ro_gui_options_interface_ok(wimp_w w) { - option_strip_extensions = ro_gui_get_icon_selected_state(w, - INTERFACE_STRIP_EXTNS_OPTION); - option_confirm_overwrite = ro_gui_get_icon_selected_state(w, - INTERFACE_CONFIRM_OVWR_OPTION); - option_url_suggestion = ro_gui_get_icon_selected_state(w, - INTERFACE_URL_COMPLETE_OPTION); - option_history_tooltip = ro_gui_get_icon_selected_state(w, - INTERFACE_HISTORY_TOOLTIP_OPTION); - option_thumbnail_iconise = ro_gui_get_icon_selected_state(w, - INTERFACE_THUMBNAIL_ICONISE_OPTION); - option_external_hotlists = ro_gui_get_icon_selected_state(w, - INTERFACE_USE_EXTERNAL_HOTLIST); - if (option_external_hotlist_app) - free(option_external_hotlist_app); - option_external_hotlist_app = - strdup(ro_gui_get_icon_string(w, - INTERFACE_EXTERNAL_HOTLIST_APP)); + nsoption_set_bool(strip_extensions, + ro_gui_get_icon_selected_state(w, + INTERFACE_STRIP_EXTNS_OPTION)); + nsoption_set_bool(confirm_overwrite, + ro_gui_get_icon_selected_state(w, + INTERFACE_CONFIRM_OVWR_OPTION)); + nsoption_set_bool(url_suggestion, + ro_gui_get_icon_selected_state(w, + INTERFACE_URL_COMPLETE_OPTION)); + nsoption_set_bool(history_tooltip, + ro_gui_get_icon_selected_state(w, + INTERFACE_HISTORY_TOOLTIP_OPTION)); + nsoption_set_bool(thumbnail_iconise, + ro_gui_get_icon_selected_state(w, + INTERFACE_THUMBNAIL_ICONISE_OPTION)); + nsoption_set_bool(external_hotlists, + ro_gui_get_icon_selected_state(w, + INTERFACE_USE_EXTERNAL_HOTLIST)); + nsoption_set_charp(external_hotlist_app, + strdup(ro_gui_get_icon_string(w, + INTERFACE_EXTERNAL_HOTLIST_APP))); ro_gui_save_options(); return true; diff --git a/riscos/configure/con_language.c b/riscos/configure/con_language.c index 4e8490055..be40b1c39 100644 --- a/riscos/configure/con_language.c +++ b/riscos/configure/con_language.c @@ -22,7 +22,6 @@ #include "riscos/dialog.h" #include "riscos/gui.h" #include "riscos/menus.h" -#include "riscos/options.h" #include "riscos/wimp.h" #include "riscos/wimp_event.h" #include "riscos/configure.h" @@ -48,11 +47,11 @@ bool ro_gui_options_language_initialise(wimp_w w) { /* set the current values */ ro_gui_set_icon_string(w, LANGUAGE_INTERFACE_FIELD, - ro_gui_options_language_name(option_language ? - option_language : "en"), true); + ro_gui_options_language_name(nsoption_charp(language) ? + nsoption_charp(language) : "en"), true); ro_gui_set_icon_string(w, LANGUAGE_WEB_PAGES_FIELD, - ro_gui_options_language_name(option_accept_language ? - option_accept_language : "en"), true); + ro_gui_options_language_name(nsoption_charp(accept_language) ? + nsoption_charp(accept_language) : "en"), true); /* initialise all functions for a newly created window */ ro_gui_wimp_event_register_menu_gright(w, LANGUAGE_INTERFACE_FIELD, @@ -92,11 +91,11 @@ bool ro_gui_options_language_ok(wimp_w w) ro_gui_get_icon_string(w, LANGUAGE_INTERFACE_FIELD)); if (code) { code += 5; /* skip 'lang_' */ - if ((!option_language) || (strcmp(option_language, code))) { + if ((!nsoption_charp(language)) || + (strcmp(nsoption_charp(language), code))) { temp = strdup(code); if (temp) { - free(option_language); - option_language = temp; + nsoption_set_charp(language, temp); } else { LOG(("No memory to duplicate language code")); warn_user("NoMemory", 0); @@ -107,12 +106,11 @@ bool ro_gui_options_language_ok(wimp_w w) ro_gui_get_icon_string(w, LANGUAGE_WEB_PAGES_FIELD)); if (code) { code += 5; /* skip 'lang_' */ - if ((!option_accept_language) || - (strcmp(option_accept_language, code))) { + if ((!nsoption_charp(accept_language)) || + (strcmp(nsoption_charp(accept_language), code))) { temp = strdup(code); if (temp) { - free(option_accept_language); - option_accept_language = temp; + nsoption_set_charp(accept_language,temp); } else { LOG(("No memory to duplicate language code")); warn_user("NoMemory", 0); diff --git a/riscos/configure/con_memory.c b/riscos/configure/con_memory.c index 65d9bed26..5bf890597 100644 --- a/riscos/configure/con_memory.c +++ b/riscos/configure/con_memory.c @@ -19,7 +19,6 @@ #include #include "desktop/options.h" #include "riscos/bitmap.h" -#include "riscos/options.h" #include "riscos/wimp.h" #include "riscos/wimp_event.h" #include "riscos/dialog.h" @@ -52,9 +51,9 @@ bool ro_gui_options_memory_initialise(wimp_w w) ro_gui_set_icon_decimal(w, MEMORY_COMPRESSED_FIELD, (bitmap_compressed_size * 10) >> 20, 1); ro_gui_set_icon_selected_state(w, MEMORY_DIRECT_AUTO, - (option_image_memory_direct == -1)); + (nsoption_int(image_memory_direct) == -1)); ro_gui_set_icon_selected_state(w, MEMORY_COMPRESSED_AUTO, - (option_image_memory_compressed == -1)); + (nsoption_int(image_memory_compressed) == -1)); ro_gui_options_update_shading(w); /* register icons */ @@ -123,17 +122,17 @@ bool ro_gui_options_memory_ok(wimp_w w) { /* set the option values */ if (ro_gui_get_icon_selected_state(w, MEMORY_DIRECT_AUTO)) - option_image_memory_direct = -1; + nsoption_set_int(image_memory_direct, -1); else - option_image_memory_direct = + nsoption_set_int(image_memory_direct, (((ro_gui_get_icon_decimal(w, MEMORY_DIRECT_FIELD, 1) - << 10) + 1023) / 10); + << 10) + 1023) / 10)); if (ro_gui_get_icon_selected_state(w, MEMORY_COMPRESSED_AUTO)) - option_image_memory_compressed = -1; + nsoption_set_int(image_memory_compressed, -1); else - option_image_memory_compressed = + nsoption_set_int(image_memory_compressed, (((ro_gui_get_icon_decimal(w, MEMORY_COMPRESSED_FIELD, 1) - << 10) + 1023) / 10); + << 10) + 1023) / 10)); /* update the memory usage */ bitmap_initialise_memory(); ro_gui_set_icon_decimal(w, MEMORY_DIRECT_FIELD, diff --git a/riscos/configure/con_secure.c b/riscos/configure/con_secure.c index c3b289b45..568a03ddd 100644 --- a/riscos/configure/con_secure.c +++ b/riscos/configure/con_secure.c @@ -20,7 +20,6 @@ #include "desktop/options.h" #include "riscos/dialog.h" #include "riscos/gui.h" -#include "riscos/options.h" #include "riscos/wimp.h" #include "riscos/wimp_event.h" #include "riscos/configure.h" @@ -44,9 +43,9 @@ bool ro_gui_options_security_initialise(wimp_w w) { /* set the current values */ ro_gui_set_icon_selected_state(w, SECURITY_REFERRER, - option_send_referer); + nsoption_bool(send_referer)); ro_gui_set_icon_integer(w, SECURITY_DURATION_FIELD, - option_expire_url); + nsoption_int(expire_url)); /* initialise all functions for a newly created window */ ro_gui_wimp_event_register_checkbox(w, SECURITY_REFERRER); @@ -73,10 +72,11 @@ void ro_gui_options_security_default(wimp_pointer *pointer) bool ro_gui_options_security_ok(wimp_w w) { - option_send_referer = ro_gui_get_icon_selected_state(w, - SECURITY_REFERRER); - option_expire_url = ro_gui_get_icon_decimal(w, - SECURITY_DURATION_FIELD, 0); + nsoption_set_bool(send_referer, + ro_gui_get_icon_selected_state(w, SECURITY_REFERRER)); + + nsoption_set_int(expire_url, + ro_gui_get_icon_decimal(w,SECURITY_DURATION_FIELD, 0)); ro_gui_save_options(); return true; diff --git a/riscos/configure/con_theme.c b/riscos/configure/con_theme.c index a6dc98265..b41484be0 100644 --- a/riscos/configure/con_theme.c +++ b/riscos/configure/con_theme.c @@ -23,11 +23,11 @@ #include "oslib/wimp.h" #include "oslib/wimpspriteop.h" #include "utils/config.h" +#include "desktop/options.h" #include "riscos/configure/configure.h" #include "riscos/configure.h" #include "riscos/dialog.h" #include "riscos/menus.h" -#include "riscos/options.h" #include "riscos/theme.h" #include "riscos/toolbar.h" #include "riscos/url_complete.h" @@ -151,7 +151,7 @@ bool ro_gui_options_theme_initialise(wimp_w w) ro_gui_options_theme_load(); /* set the current selection */ - theme_choice = ro_gui_theme_find(option_theme); + theme_choice = ro_gui_theme_find(nsoption_charp(theme)); if (!theme_choice) theme_choice = ro_gui_theme_find("Aletheia"); for (toolbar = toolbars; toolbar; toolbar = toolbar->next) @@ -202,13 +202,12 @@ bool ro_gui_options_theme_ok(wimp_w w) } /* set the options */ - if (option_theme) - free(option_theme); if (theme_new) { - option_theme = strdup(theme_new->leafname); + nsoption_set_charp(theme, strdup(theme_new->leafname)); ro_gui_theme_apply(theme_new); - } else - option_theme = NULL; + } else { + nsoption_set_charp(theme, NULL); + } ro_gui_save_options(); /* store the pane status */ @@ -269,7 +268,7 @@ void ro_gui_options_theme_load(void) TOOLBAR_FLAGS_DISPLAY, NULL, NULL, NULL); if (toolbar != NULL) { ro_toolbar_add_buttons(toolbar, brower_toolbar_buttons, - option_toolbar_browser); + nsoption_charp(toolbar_browser)); ro_toolbar_add_url(toolbar); ro_toolbar_add_throbber(toolbar); ro_toolbar_rebuild(toolbar); diff --git a/riscos/cookies.c b/riscos/cookies.c index 76c7f4673..347b43d0e 100644 --- a/riscos/cookies.c +++ b/riscos/cookies.c @@ -35,7 +35,7 @@ #include "riscos/cookies.h" #include "riscos/dialog.h" #include "riscos/menus.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/toolbar.h" #include "riscos/treeview.h" #include "riscos/wimp.h" @@ -99,7 +99,7 @@ void ro_gui_cookies_postinitialise(void) if (cookies_window.toolbar != NULL) { ro_toolbar_add_buttons(cookies_window.toolbar, cookies_toolbar_buttons, - option_toolbar_cookies); + nsoption_charp(toolbar_cookies)); ro_toolbar_rebuild(cookies_window.toolbar); } @@ -232,9 +232,7 @@ void ro_gui_cookies_toolbar_update_buttons(void) void ro_gui_cookies_toolbar_save_buttons(char *config) { - if (option_toolbar_cookies != NULL) - free(option_toolbar_cookies); - option_toolbar_cookies = config; + nsoption_set_charp(toolbar_cookies, config); ro_gui_save_options(); } diff --git a/riscos/dialog.c b/riscos/dialog.c index 96746329e..ab53603dc 100644 --- a/riscos/dialog.c +++ b/riscos/dialog.c @@ -41,7 +41,7 @@ #include "riscos/gui.h" #include "riscos/hotlist.h" #include "riscos/menus.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/save.h" #include "riscos/sslcert.h" #include "riscos/toolbar.h" @@ -664,7 +664,7 @@ void ro_gui_dialog_close_persistent(wimp_w parent) { void ro_gui_save_options(void) { - options_write(""); + nsoption_write(""); } bool ro_gui_dialog_zoom_apply(wimp_w w) { diff --git a/riscos/download.c b/riscos/download.c index eade5a176..233d19300 100644 --- a/riscos/download.c +++ b/riscos/download.c @@ -44,7 +44,7 @@ #include "desktop/gui.h" #include "desktop/netsurf.h" #include "riscos/dialog.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/save.h" #include "riscos/query.h" #include "riscos/wimp.h" @@ -364,7 +364,7 @@ struct gui_download_window *gui_download_window_create(download_context *ctx, filename[i] = '_'; } - if (option_strip_extensions && last_dot != (size_t) -1) + if (nsoption_bool(strip_extensions) && last_dot != (size_t) -1) filename[last_dot] = '\0'; if (download_dir != NULL && strlen(download_dir) > 0) @@ -881,7 +881,7 @@ bool ro_gui_download_keypress(wimp_key *key) dw->send_dataload = false; if (ro_gui_download_save(dw, dw->path, - !option_confirm_overwrite) && !dw->ctx) + !nsoption_bool(confirm_overwrite)) && !dw->ctx) { /* finished already */ schedule(200, ro_gui_download_window_destroy_wrapper, dw); @@ -967,7 +967,7 @@ void ro_gui_download_datasave_ack(wimp_message *message) memcpy(&dw->save_message, message, sizeof(wimp_message)); if (!ro_gui_download_save(dw, message->data.data_xfer.file_name, - !option_confirm_overwrite)) + !nsoption_bool(confirm_overwrite))) return; if (!dw->ctx) { diff --git a/riscos/font.c b/riscos/font.c index ce9e70a99..ff9127c0b 100644 --- a/riscos/font.c +++ b/riscos/font.c @@ -31,7 +31,7 @@ #include "css/utils.h" #include "render/font.h" #include "riscos/gui.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "utils/log.h" #include "utils/messages.h" #include "utils/utils.h" @@ -94,18 +94,19 @@ void nsfont_init(void) fallback = nsfont_fallback_font(); - nsfont_check_option(&option_font_sans, "Homerton", fallback); - nsfont_check_option(&option_font_serif, "Trinity", fallback); - nsfont_check_option(&option_font_mono, "Corpus", fallback); - nsfont_check_option(&option_font_cursive, "Churchill", fallback); - nsfont_check_option(&option_font_fantasy, "Sassoon", fallback); + nsfont_check_option(&nsoption_charp(font_sans), "Homerton", fallback); + nsfont_check_option(&nsoption_charp(font_serif), "Trinity", fallback); + nsfont_check_option(&nsoption_charp(font_mono), "Corpus", fallback); + nsfont_check_option(&nsoption_charp(font_cursive), "Churchill", fallback); + nsfont_check_option(&nsoption_charp(font_fantasy), "Sassoon", fallback); - if (option_font_default != PLOT_FONT_FAMILY_SANS_SERIF && - option_font_default != PLOT_FONT_FAMILY_SERIF && - option_font_default != PLOT_FONT_FAMILY_MONOSPACE && - option_font_default != PLOT_FONT_FAMILY_CURSIVE && - option_font_default != PLOT_FONT_FAMILY_FANTASY) - option_font_default = PLOT_FONT_FAMILY_SANS_SERIF; + if (nsoption_int(font_default) != PLOT_FONT_FAMILY_SANS_SERIF && + nsoption_int(font_default) != PLOT_FONT_FAMILY_SERIF && + nsoption_int(font_default) != PLOT_FONT_FAMILY_MONOSPACE && + nsoption_int(font_default) != PLOT_FONT_FAMILY_CURSIVE && + nsoption_int(font_default) != PLOT_FONT_FAMILY_FANTASY) { + nsoption_set_int(font_default, PLOT_FONT_FAMILY_SANS_SERIF); + } } @@ -447,22 +448,22 @@ void nsfont_read_style(const plot_font_style_t *fstyle, switch (fstyle->family) { case PLOT_FONT_FAMILY_SANS_SERIF: - *font_family = option_font_sans; + *font_family = nsoption_charp(font_sans); break; case PLOT_FONT_FAMILY_SERIF: - *font_family = option_font_serif; + *font_family = nsoption_charp(font_serif); break; case PLOT_FONT_FAMILY_MONOSPACE: - *font_family = option_font_mono; + *font_family = nsoption_charp(font_mono); break; case PLOT_FONT_FAMILY_CURSIVE: - *font_family = option_font_cursive; + *font_family = nsoption_charp(font_cursive); break; case PLOT_FONT_FAMILY_FANTASY: - *font_family = option_font_fantasy; + *font_family = nsoption_charp(font_fantasy); break; default: - *font_family = option_font_sans; + *font_family = nsoption_charp(font_sans); break; } diff --git a/riscos/global_history.c b/riscos/global_history.c index a6b43b863..ca51b7253 100644 --- a/riscos/global_history.c +++ b/riscos/global_history.c @@ -36,7 +36,7 @@ #include "riscos/global_history.h" #include "riscos/gui.h" #include "riscos/menus.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/save.h" #include "riscos/toolbar.h" #include "riscos/treeview.h" @@ -102,7 +102,7 @@ void ro_gui_global_history_postinitialise(void) if (global_history_window.toolbar != NULL) { ro_toolbar_add_buttons(global_history_window.toolbar, global_history_toolbar_buttons, - option_toolbar_history); + nsoption_charp(toolbar_history)); ro_toolbar_rebuild(global_history_window.toolbar); } @@ -246,9 +246,7 @@ void ro_gui_global_history_toolbar_update_buttons(void) void ro_gui_global_history_toolbar_save_buttons(char *config) { - if (option_toolbar_history != NULL) - free(option_toolbar_history); - option_toolbar_history = config; + nsoption_set_charp(toolbar_history, config); ro_gui_save_options(); } diff --git a/riscos/gui.c b/riscos/gui.c index f65d89f85..11f4e1df7 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -81,7 +81,6 @@ #include "riscos/iconbar.h" #include "riscos/menus.h" #include "riscos/message.h" -#include "riscos/options.h" #include "riscos/print.h" #include "riscos/query.h" #include "riscos/save.h" @@ -379,49 +378,40 @@ static void gui_init(int argc, char** argv) } /* Set defaults for absent option strings */ - if (!option_theme) - option_theme = strdup("Aletheia"); - if (!option_toolbar_browser) - option_toolbar_browser = strdup("0123|58|9"); - if (!option_toolbar_hotlist) - option_toolbar_hotlist = strdup("40|12|3"); - if (!option_toolbar_history) - option_toolbar_history = strdup("0|12|3"); - if (!option_toolbar_cookies) - option_toolbar_cookies = strdup("0|12"); - if (!option_ca_bundle) - option_ca_bundle = strdup("NetSurf:Resources.ca-bundle"); - if (!option_cookie_file) - option_cookie_file = strdup("NetSurf:Cookies"); - if (!option_cookie_jar) - option_cookie_jar = strdup(CHOICES_PREFIX "Cookies"); - if (!option_url_path) - option_url_path = strdup("NetSurf:URL"); - if (!option_url_save) - option_url_save = strdup(CHOICES_PREFIX "URL"); - if (!option_hotlist_path) - option_hotlist_path = strdup("NetSurf:Hotlist"); - if (!option_hotlist_save) - option_hotlist_save = strdup(CHOICES_PREFIX "Hotlist"); - if (!option_recent_path) - option_recent_path = strdup("NetSurf:Recent"); - if (!option_recent_save) - option_recent_save = strdup(CHOICES_PREFIX "Recent"); - if (!option_theme_path) - option_theme_path = strdup("NetSurf:Themes"); - if (!option_theme_save) - option_theme_save = strdup(CHOICES_PREFIX "Themes"); + nsoption_setnull_charp(theme, strdup("Aletheia")); + nsoption_setnull_charp(toolbar_browser, strdup("0123|58|9")); + nsoption_setnull_charp(toolbar_hotlist, strdup("40|12|3")); + nsoption_setnull_charp(toolbar_history, strdup("0|12|3")); + nsoption_setnull_charp(toolbar_cookies, strdup("0|12")); + nsoption_setnull_charp(ca_bundle, strdup("NetSurf:Resources.ca-bundle")); + nsoption_setnull_charp(cookie_file, strdup("NetSurf:Cookies")); + nsoption_setnull_charp(cookie_jar, strdup(CHOICES_PREFIX "Cookies")); + nsoption_setnull_charp(url_path, strdup("NetSurf:URL")); + nsoption_setnull_charp(url_save, strdup(CHOICES_PREFIX "URL")); + nsoption_setnull_charp(hotlist_path, strdup("NetSurf:Hotlist")); + nsoption_setnull_charp(hotlist_save, strdup(CHOICES_PREFIX "Hotlist")); + nsoption_setnull_charp(recent_path, strdup("NetSurf:Recent")); + nsoption_setnull_charp(recent_save, strdup(CHOICES_PREFIX "Recent")); + nsoption_setnull_charp(theme_path, strdup("NetSurf:Themes")); + nsoption_setnull_charp(theme_save, strdup(CHOICES_PREFIX "Themes")); tree_set_icon_dir(strdup("NetSurf:Resources.Icons")); - if (!option_theme || ! option_toolbar_browser || - !option_toolbar_hotlist || !option_toolbar_history || - !option_ca_bundle || !option_cookie_file || - !option_cookie_jar || !option_url_path || - !option_url_save || !option_hotlist_path || - !option_hotlist_save || !option_recent_path || - !option_recent_save || !option_theme_path || - !option_theme_save) + if (nsoption_charp(theme) == NULL || + nsoption_charp(toolbar_browser) == NULL || + nsoption_charp(toolbar_hotlist) == NULL || + nsoption_charp(toolbar_history) == NULL || + nsoption_charp(ca_bundle) == NULL || + nsoption_charp(cookie_file) == NULL || + nsoption_charp(cookie_jar) == NULL || + nsoption_charp(url_path) == NULL || + nsoption_charp(url_save) == NULL || + nsoption_charp(hotlist_path) == NULL || + nsoption_charp(hotlist_save) == NULL || + nsoption_charp(recent_path) == NULL || + nsoption_charp(recent_save) == NULL || + nsoption_charp(theme_path) == NULL || + nsoption_charp(theme_save) == NULL) die("Failed initialising string options"); /* Create our choices directories */ @@ -466,8 +456,8 @@ static void gui_init(int argc, char** argv) bitmap_initialise_memory(); /* Load in visited URLs and Cookies */ - urldb_load(option_url_path); - urldb_load_cookies(option_cookie_file); + urldb_load(nsoption_charp(url_path)); + urldb_load_cookies(nsoption_charp(cookie_file)); /* Initialise with the wimp */ error = xwimp_initialise(wimp_VERSION_RO38, task_name, @@ -512,7 +502,7 @@ static void gui_init(int argc, char** argv) /* Open the templates */ if ((length = snprintf(path, sizeof(path), "NetSurf:Resources.%s.Templates", - option_language)) < 0 || length >= (int)sizeof(path)) + nsoption_charp(language))) < 0 || length >= (int)sizeof(path)) die("Failed to locate Templates resource."); error = xwimp_open_template(path); if (error) { @@ -565,19 +555,19 @@ void ro_gui_create_dirs(void) ro_gui_create_dir(buf); /* URL */ - snprintf(buf, sizeof(buf), "%s", option_url_save); + snprintf(buf, sizeof(buf), "%s", nsoption_charp(url_save)); ro_gui_create_dir(buf); /* Hotlist */ - snprintf(buf, sizeof(buf), "%s", option_hotlist_save); + snprintf(buf, sizeof(buf), "%s", nsoption_charp(hotlist_save)); ro_gui_create_dir(buf); /* Recent */ - snprintf(buf, sizeof(buf), "%s", option_recent_save); + snprintf(buf, sizeof(buf), "%s", nsoption_charp(recent_save)); ro_gui_create_dir(buf); /* Theme */ - snprintf(buf, sizeof(buf), "%s", option_theme_save); + snprintf(buf, sizeof(buf), "%s", nsoption_charp(theme_save)); ro_gui_create_dir(buf); /* and the final directory part (as theme_save is a directory) */ xosfile_create_dir(buf, 0); @@ -611,24 +601,23 @@ void ro_gui_choose_language(void) char path[40]; /* if option_language exists and is valid, use that */ - if (option_language) { - if (2 < strlen(option_language)) - option_language[2] = 0; - sprintf(path, "NetSurf:Resources.%s", option_language); + if (nsoption_charp(language)) { + if (2 < strlen(nsoption_charp(language))) + nsoption_charp(language)[2] = 0; + sprintf(path, "NetSurf:Resources.%s", nsoption_charp(language)); if (is_dir(path)) { - if (!option_accept_language) - option_accept_language = strdup(option_language); + nsoption_setnull_charp(accept_language, + strdup(nsoption_charp(language))); return; } - free(option_language); - option_language = 0; + nsoption_set_charp(language, NULL); } - option_language = strdup(ro_gui_default_language()); - if (!option_language) + nsoption_set_charp(language, strdup(ro_gui_default_language())); + if (nsoption_charp(language) == NULL) die("Out of memory"); - option_accept_language = strdup(option_language); - if (!option_accept_language) + nsoption_set_charp(accept_language, strdup(nsoption_charp(language))); + if (nsoption_charp(accept_language) == NULL) die("Out of memory"); } @@ -702,7 +691,7 @@ void ro_gui_check_resolvers(void) static void gui_init2(int argc, char** argv) { char *url = 0; - bool open_window = option_open_browser_at_startup; + bool open_window = nsoption_bool(open_browser_at_startup); /* Complete initialisation of the treeview modules. */ @@ -762,13 +751,13 @@ static void gui_init2(int argc, char** argv) } } /* get user's homepage (if configured) */ - else if (option_homepage_url && option_homepage_url[0]) { - url = calloc(strlen(option_homepage_url) + 5, sizeof(char)); + else if (nsoption_charp(homepage_url) && nsoption_charp(homepage_url)[0]) { + url = calloc(strlen(nsoption_charp(homepage_url)) + 5, sizeof(char)); if (!url) { LOG(("malloc failed")); die("Insufficient memory for URL"); } - sprintf(url, "%s", option_homepage_url); + sprintf(url, "%s", nsoption_charp(homepage_url)); } /* default homepage */ else { @@ -778,7 +767,7 @@ static void gui_init2(int argc, char** argv) die("Insufficient memory for URL"); } snprintf(url, 80, "file:////Docs/welcome/index_%s", - option_language); + nsoption_charp(language)); } if (open_window) @@ -807,7 +796,7 @@ int main(int argc, char** argv) /* Load in our language-specific Messages */ if ((length = snprintf(path, sizeof(path), "NetSurf:Resources.%s.Messages", - option_language)) < 0 || length >= (int)sizeof(path)) + nsoption_charp(language))) < 0 || length >= (int)sizeof(path)) die("Failed to locate Messages resource."); messages_load(path); messages_load("NetSurf:Resources.LangNames"); @@ -831,12 +820,12 @@ int main(int argc, char** argv) void gui_quit(void) { bitmap_quit(); - urldb_save_cookies(option_cookie_jar); - urldb_save(option_url_save); + urldb_save_cookies(nsoption_charp(cookie_jar)); + urldb_save(nsoption_charp(url_save)); ro_gui_window_quit(); history_global_cleanup(); cookies_cleanup(); - hotlist_cleanup(option_hotlist_save); + hotlist_cleanup(nsoption_charp(hotlist_save)); sslcert_cleanup(); ro_gui_saveas_quit(); rufl_quit(); @@ -861,7 +850,7 @@ void ro_gui_signal(int sig) xhourglass_on(); xhourglass_colours(0x0000ffff, 0x000000ff, &old_sand, &old_glass); - options_dump(stderr); + nsoption_dump(stderr); /*rufl_dump_state();*/ #ifndef __ELF__ @@ -1836,14 +1825,14 @@ void ro_msg_dataopen(wimp_message *message) if (len < 9 || strcmp(".!NetSurf", message->data.data_xfer.file_name + len - 9)) return; - if (option_homepage_url && option_homepage_url[0]) { - url = strdup(option_homepage_url); + if (nsoption_charp(homepage_url) && nsoption_charp(homepage_url)[0]) { + url = strdup(nsoption_charp(homepage_url)); } else { url = malloc(80); if (url) snprintf(url, 80, "file:////Docs/welcome/index_%s", - option_language); + nsoption_charp(language)); } if (!url) warn_user("NoMemory", 0); @@ -1943,7 +1932,7 @@ void ro_msg_window_info(wimp_message *message) struct gui_window *g; /* allow the user to turn off thumbnail icons */ - if (!option_thumbnail_iconise) + if (!nsoption_bool(thumbnail_iconise)) return; wi = (wimp_full_message_window_info*)message; @@ -2141,7 +2130,7 @@ void ro_gui_open_help_page(const char *page) if ((length = snprintf(url, sizeof url, "file:////Docs/%s_%s", - page, option_language)) >= 0 && + page, nsoption_charp(language))) >= 0 && length < (int)sizeof(url)) browser_window_create(url, NULL, 0, true, false); } diff --git a/riscos/help.c b/riscos/help.c index 6a71fb1ec..ae2a2af84 100644 --- a/riscos/help.c +++ b/riscos/help.c @@ -35,7 +35,7 @@ #include "riscos/help.h" #include "riscos/iconbar.h" #include "riscos/menus.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/treeview.h" #include "riscos/wimp.h" #include "riscos/wimp_event.h" @@ -106,7 +106,7 @@ void ro_gui_interactive_help_request(wimp_message *message) int i; /* check we aren't turned off */ - if (!option_interactive_help) + if (!nsoption_bool(interactive_help)) return; /* only accept help requests */ diff --git a/riscos/history.c b/riscos/history.c index c8094e5a0..00ff5d6ff 100644 --- a/riscos/history.c +++ b/riscos/history.c @@ -30,7 +30,7 @@ #include "desktop/history_core.h" #include "desktop/plotters.h" #include "riscos/dialog.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/gui.h" #include "riscos/wimp.h" #include "riscos/wimp_event.h" @@ -183,7 +183,7 @@ void ro_gui_history_mouse_at(wimp_pointer *pointer) /* If the mouse hasn't moved, or if we don't want tooltips, exit */ if ((mouse_x == pointer->pos.x && mouse_y == pointer->pos.y) || - !option_history_tooltip) + !nsoption_bool(history_tooltip)) return; /* Update mouse position */ diff --git a/riscos/hotlist.c b/riscos/hotlist.c index 532a657ca..a01b9256e 100644 --- a/riscos/hotlist.c +++ b/riscos/hotlist.c @@ -39,7 +39,7 @@ #include "riscos/hotlist.h" #include "riscos/menus.h" #include "riscos/message.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/save.h" #include "riscos/toolbar.h" #include "riscos/treeview.h" @@ -123,7 +123,7 @@ void ro_gui_hotlist_postinitialise(void) if (hotlist_window.toolbar != NULL) { ro_toolbar_add_buttons(hotlist_window.toolbar, hotlist_toolbar_buttons, - option_toolbar_hotlist); + nsoption_charp(toolbar_hotlist)); ro_toolbar_rebuild(hotlist_window.toolbar); } @@ -143,7 +143,7 @@ void ro_gui_hotlist_postinitialise(void) /* Initialise the hotlist into the tree. */ hotlist_initialise(ro_treeview_get_tree(hotlist_window.tv), - option_hotlist_path, + nsoption_charp(hotlist_path), tree_directory_icon_name); @@ -200,10 +200,11 @@ void ro_gui_hotlist_open(void) os_error *error; char command[2048]; - if (option_external_hotlists && option_external_hotlist_app != NULL && - *option_external_hotlist_app != '\0') { + if (nsoption_bool(external_hotlists) && + nsoption_charp(external_hotlist_app) != NULL && + *nsoption_charp(external_hotlist_app) != '\0') { snprintf(command, sizeof(command), "Filer_Run %s", - option_external_hotlist_app); + nsoption_charp(external_hotlist_app)); error = xos_cli(command); if (error == NULL) @@ -292,9 +293,7 @@ void ro_gui_hotlist_toolbar_update_buttons(void) void ro_gui_hotlist_toolbar_save_buttons(char *config) { - if (option_toolbar_hotlist != NULL) - free(option_toolbar_hotlist); - option_toolbar_hotlist = config; + nsoption_set_charp(toolbar_hotlist, config); ro_gui_save_options(); } @@ -481,7 +480,7 @@ void ro_gui_hotlist_add_page(const char *url) * own hotlist and return... */ - if (!option_external_hotlists) { + if (!nsoption_bool(external_hotlists)) { hotlist_add_page(url); return; } diff --git a/riscos/iconbar.c b/riscos/iconbar.c index 85ca59155..9e3a050e1 100644 --- a/riscos/iconbar.c +++ b/riscos/iconbar.c @@ -37,7 +37,7 @@ #include "riscos/global_history.h" #include "riscos/hotlist.h" #include "riscos/iconbar.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/wimp_event.h" #include "utils/log.h" #include "utils/utils.h" @@ -122,13 +122,13 @@ bool ro_gui_iconbar_click(wimp_pointer *pointer) switch (pointer->buttons) { case wimp_CLICK_SELECT: - if (option_homepage_url && option_homepage_url[0]) { - browser_window_create(option_homepage_url, NULL, 0, - true, false); + if (nsoption_charp(homepage_url) != NULL) { + browser_window_create(nsoption_charp(homepage_url), + NULL, 0, true, false); } else { snprintf(url, sizeof url, - "file:////Docs/welcome/index_%s", - option_language); + "file:////Docs/welcome/index_%s", + nsoption_charp(language)); browser_window_create(url, NULL, 0, true, false); } break; diff --git a/riscos/image.c b/riscos/image.c index 6ba57695b..3d4f28b1d 100644 --- a/riscos/image.c +++ b/riscos/image.c @@ -22,7 +22,7 @@ #include "oslib/osspriteop.h" #include "riscos/image.h" #include "riscos/gui.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/tinct.h" #include "utils/log.h" #include "utils/utils.h" @@ -69,8 +69,8 @@ bool image_redraw(osspriteop_area *area, int x, int y, int req_width, req_height *= 2; width *= 2; height *= 2; - tinct_options = background ? option_bg_plot_style : - option_fg_plot_style; + tinct_options = background ? nsoption_int(bg_plot_style) : + nsoption_int(fg_plot_style); switch (type) { case IMAGE_PLOT_TINCT_ALPHA: return image_redraw_tinct(header, x, y, diff --git a/riscos/menus.c b/riscos/menus.c index 133aa9d6d..6f69b7535 100644 --- a/riscos/menus.c +++ b/riscos/menus.c @@ -54,7 +54,7 @@ #include "riscos/help.h" #include "riscos/hotlist.h" #include "riscos/menus.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/save.h" #include "riscos/tinct.h" #include "riscos/toolbar.h" diff --git a/riscos/options.h b/riscos/options.h index 6aa6a8b20..62bfcf2bb 100644 --- a/riscos/options.h +++ b/riscos/options.h @@ -22,126 +22,131 @@ * RISC OS specific options. */ +#include "riscos/tinct.h" + +#ifndef _NETSURF_DESKTOP_OPTIONS_INCLUDING_ +#error "Frontend options header cannot be included directly" +#endif + #ifndef _NETSURF_RISCOS_OPTIONS_H_ #define _NETSURF_RISCOS_OPTIONS_H_ -#include -#include "desktop/options.h" -#include "riscos/tinct.h" +#define NSOPTION_EXTRA_DEFINE \ + bool use_mouse_gestures; \ + bool allow_text_selection; \ + char *theme; \ + char *language; \ + int fg_plot_style; /* tinct flagword */ \ + int bg_plot_style; /* tinct flagword */ \ + bool history_tooltip; \ + bool toolbar_show_buttons; \ + bool toolbar_show_address; \ + bool toolbar_show_throbber; \ + char *toolbar_browser; \ + char *toolbar_hotlist; \ + char *toolbar_history; \ + char *toolbar_cookies; \ + bool window_stagger; \ + bool window_size_clone; \ + bool buffer_animations; \ + bool buffer_everything; \ + bool open_browser_at_startup; \ + bool no_plugins; \ + bool block_popups; \ + int image_memory_direct; /* -1 means auto-detect */ \ + int image_memory_compressed; /* -1 means auto-detect */ \ + bool strip_extensions; \ + bool confirm_overwrite; \ + char *url_path; \ + char *url_save; \ + char *hotlist_path; \ + char *hotlist_save; \ + char *recent_path; \ + char *recent_save; \ + char *theme_path; \ + char *theme_save; \ + bool thumbnail_iconise; \ + bool interactive_help; \ + bool external_hotlists; \ + char *external_hotlist_app -extern bool option_allow_text_selection; -extern char *option_theme; -extern char *option_language; -extern int option_fg_plot_style; /* tinct flagword */ -extern int option_bg_plot_style; /* tinct flagword */ -extern bool option_history_tooltip; -extern bool option_toolbar_show_buttons; -extern bool option_toolbar_show_address; -extern bool option_toolbar_show_throbber; -extern char *option_toolbar_browser; -extern char *option_toolbar_hotlist; -extern char *option_toolbar_history; -extern char *option_toolbar_cookies; -extern bool option_window_stagger; -extern bool option_window_size_clone; -extern bool option_buffer_animations; -extern bool option_buffer_everything; -extern bool option_open_browser_at_startup; -extern bool option_no_plugins; -extern bool option_block_popups; -extern int option_image_memory_direct; /* -1 means auto-detect */ -extern int option_image_memory_compressed; /* -1 means auto-detect */ -extern bool option_strip_extensions; -extern bool option_confirm_overwrite; -extern char *option_url_path; -extern char *option_url_save; -extern char *option_hotlist_path; -extern char *option_hotlist_save; -extern char *option_recent_path; -extern char *option_recent_save; -extern char *option_theme_path; -extern char *option_theme_save; -extern bool option_thumbnail_iconise; -extern bool option_interactive_help; -extern bool option_external_hotlists; -extern char *option_external_hotlist_app; -#define EXTRA_OPTION_DEFINE \ -bool option_use_mouse_gestures = false;\ -bool option_allow_text_selection = true;\ -char *option_theme = 0;\ -char *option_language = 0;\ -int option_fg_plot_style = tinct_ERROR_DIFFUSE;\ -int option_bg_plot_style = tinct_DITHER;\ -bool option_history_tooltip = true; \ -bool option_toolbar_show_buttons = true; \ -bool option_toolbar_show_address = true; \ -bool option_toolbar_show_throbber = true; \ -char *option_toolbar_browser = 0; \ -char *option_toolbar_hotlist = 0; \ -char *option_toolbar_history = 0; \ -char *option_toolbar_cookies = 0; \ -bool option_window_stagger = true; \ -bool option_window_size_clone = true; \ -bool option_buffer_animations = true; \ -bool option_buffer_everything = true; \ -bool option_open_browser_at_startup = false; \ -bool option_no_plugins = false; \ -bool option_block_popups = false; \ -int option_image_memory_direct = -1; \ -int option_image_memory_compressed = -1; \ -bool option_strip_extensions = true; \ -bool option_confirm_overwrite = true; \ -char *option_url_path = 0; \ -char *option_url_save = 0; \ -char *option_hotlist_path = 0; \ -char *option_hotlist_save = 0; \ -char *option_recent_path = 0; \ -char *option_recent_save = 0; \ -char *option_theme_path = 0; \ -char *option_theme_save = 0; \ -bool option_thumbnail_iconise = true; \ -bool option_interactive_help = true; \ -bool option_external_hotlists = false; \ -char *option_external_hotlist_app = 0; +#define NSOPTION_EXTRA_DEFAULTS \ + .use_mouse_gestures = false, \ + .allow_text_selection = true, \ + .theme = NULL, \ + .language = NULL, \ + .fg_plot_style = tinct_ERROR_DIFFUSE, \ + .bg_plot_style = tinct_DITHER, \ + .history_tooltip = true, \ + .toolbar_show_buttons = true, \ + .toolbar_show_address = true, \ + .toolbar_show_throbber = true, \ + .toolbar_browser = NULL, \ + .toolbar_hotlist = NULL, \ + .toolbar_history = NULL, \ + .toolbar_cookies = NULL, \ + .window_stagger = true, \ + .window_size_clone = true, \ + .buffer_animations = true, \ + .buffer_everything = true, \ + .open_browser_at_startup = false, \ + .no_plugins = false, \ + .block_popups = false, \ + .image_memory_direct = -1, \ + .image_memory_compressed = -1, \ + .strip_extensions = true, \ + .confirm_overwrite = true, \ + .url_path = NULL, \ + .url_save = NULL, \ + .hotlist_path = NULL, \ + .hotlist_save = NULL, \ + .recent_path = NULL, \ + .recent_save = NULL, \ + .theme_path = NULL, \ + .theme_save = NULL, \ + .thumbnail_iconise = true, \ + .interactive_help = true, \ + .external_hotlists = false, \ + .external_hotlist_app = NULL -#define EXTRA_OPTION_TABLE \ -{ "use_mouse_gestures", OPTION_BOOL, &option_use_mouse_gestures },\ -{ "allow_text_selection", OPTION_BOOL, &option_allow_text_selection },\ -{ "theme", OPTION_STRING, &option_theme },\ -{ "language", OPTION_STRING, &option_language },\ -{ "plot_fg_quality", OPTION_INTEGER, &option_fg_plot_style },\ -{ "plot_bg_quality", OPTION_INTEGER, &option_bg_plot_style },\ -{ "history_tooltip", OPTION_BOOL, &option_history_tooltip }, \ -{ "toolbar_show_buttons", OPTION_BOOL, &option_toolbar_show_buttons }, \ -{ "toolbar_show_address", OPTION_BOOL, &option_toolbar_show_address }, \ -{ "toolbar_show_throbber", OPTION_BOOL, &option_toolbar_show_throbber }, \ -{ "toolbar_browser", OPTION_STRING, &option_toolbar_browser }, \ -{ "toolbar_hotlist", OPTION_STRING, &option_toolbar_hotlist }, \ -{ "toolbar_history", OPTION_STRING, &option_toolbar_history }, \ -{ "toolbar_cookies", OPTION_STRING, &option_toolbar_cookies }, \ -{ "window_stagger", OPTION_BOOL, &option_window_stagger }, \ -{ "window_size_clone", OPTION_BOOL, &option_window_size_clone }, \ -{ "buffer_animations", OPTION_BOOL, &option_buffer_animations }, \ -{ "buffer_everything", OPTION_BOOL, &option_buffer_everything }, \ -{ "open_browser_at_startup",OPTION_BOOL, &option_open_browser_at_startup }, \ -{ "no_plugins", OPTION_BOOL, &option_no_plugins }, \ -{ "block_popups", OPTION_BOOL, &option_block_popups }, \ -{ "image_memory_direct", OPTION_INTEGER, &option_image_memory_direct }, \ -{ "image_memory_compressed",OPTION_INTEGER, &option_image_memory_compressed }, \ -{ "strip_extensions", OPTION_BOOL, &option_strip_extensions }, \ -{ "confirm_overwrite", OPTION_BOOL, &option_confirm_overwrite }, \ -{ "url_path", OPTION_STRING, &option_url_path }, \ -{ "url_save", OPTION_STRING, &option_url_save }, \ -{ "hotlist_path", OPTION_STRING, &option_hotlist_path }, \ -{ "hotlist_save", OPTION_STRING, &option_hotlist_save }, \ -{ "recent_path", OPTION_STRING, &option_recent_path }, \ -{ "recent_save", OPTION_STRING, &option_recent_save }, \ -{ "theme_path", OPTION_STRING, &option_theme_path }, \ -{ "theme_save", OPTION_STRING, &option_theme_save }, \ -{ "thumbnail_iconise", OPTION_BOOL, &option_thumbnail_iconise }, \ -{ "interactive_help", OPTION_BOOL, &option_interactive_help }, \ -{ "external_hotlists", OPTION_BOOL, &option_external_hotlists }, \ -{ "external_hotlist_app", OPTION_STRING, &option_external_hotlist_app } +#define NSOPTION_EXTRA_TABLE \ +{ "use_mouse_gestures", OPTION_BOOL, &nsoptions.use_mouse_gestures },\ +{ "allow_text_selection", OPTION_BOOL, &nsoptions.allow_text_selection },\ +{ "theme", OPTION_STRING, &nsoptions.theme },\ +{ "language", OPTION_STRING, &nsoptions.language },\ +{ "plot_fg_quality", OPTION_INTEGER, &nsoptions.fg_plot_style },\ +{ "plot_bg_quality", OPTION_INTEGER, &nsoptions.bg_plot_style },\ +{ "history_tooltip", OPTION_BOOL, &nsoptions.history_tooltip }, \ +{ "toolbar_show_buttons", OPTION_BOOL, &nsoptions.toolbar_show_buttons }, \ +{ "toolbar_show_address", OPTION_BOOL, &nsoptions.toolbar_show_address }, \ +{ "toolbar_show_throbber", OPTION_BOOL, &nsoptions.toolbar_show_throbber }, \ +{ "toolbar_browser", OPTION_STRING, &nsoptions.toolbar_browser }, \ +{ "toolbar_hotlist", OPTION_STRING, &nsoptions.toolbar_hotlist }, \ +{ "toolbar_history", OPTION_STRING, &nsoptions.toolbar_history }, \ +{ "toolbar_cookies", OPTION_STRING, &nsoptions.toolbar_cookies }, \ +{ "window_stagger", OPTION_BOOL, &nsoptions.window_stagger }, \ +{ "window_size_clone", OPTION_BOOL, &nsoptions.window_size_clone }, \ +{ "buffer_animations", OPTION_BOOL, &nsoptions.buffer_animations }, \ +{ "buffer_everything", OPTION_BOOL, &nsoptions.buffer_everything }, \ +{ "open_browser_at_startup",OPTION_BOOL, &nsoptions.open_browser_at_startup }, \ +{ "no_plugins", OPTION_BOOL, &nsoptions.no_plugins }, \ +{ "block_popups", OPTION_BOOL, &nsoptions.block_popups }, \ +{ "image_memory_direct", OPTION_INTEGER, &nsoptions.image_memory_direct }, \ +{ "image_memory_compressed",OPTION_INTEGER, &nsoptions.image_memory_compressed }, \ +{ "strip_extensions", OPTION_BOOL, &nsoptions.strip_extensions }, \ +{ "confirm_overwrite", OPTION_BOOL, &nsoptions.confirm_overwrite }, \ +{ "url_path", OPTION_STRING, &nsoptions.url_path }, \ +{ "url_save", OPTION_STRING, &nsoptions.url_save }, \ +{ "hotlist_path", OPTION_STRING, &nsoptions.hotlist_path }, \ +{ "hotlist_save", OPTION_STRING, &nsoptions.hotlist_save }, \ +{ "recent_path", OPTION_STRING, &nsoptions.recent_path }, \ +{ "recent_save", OPTION_STRING, &nsoptions.recent_save }, \ +{ "theme_path", OPTION_STRING, &nsoptions.theme_path }, \ +{ "theme_save", OPTION_STRING, &nsoptions.theme_save }, \ +{ "thumbnail_iconise", OPTION_BOOL, &nsoptions.thumbnail_iconise }, \ +{ "interactive_help", OPTION_BOOL, &nsoptions.interactive_help }, \ +{ "external_hotlists", OPTION_BOOL, &nsoptions.external_hotlists }, \ +{ "external_hotlist_app", OPTION_STRING, &nsoptions.external_hotlist_app } #endif diff --git a/riscos/save.c b/riscos/save.c index f585ad5ea..8233eb7cd 100644 --- a/riscos/save.c +++ b/riscos/save.c @@ -51,7 +51,7 @@ #include "riscos/gui.h" #include "riscos/menus.h" #include "riscos/message.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/query.h" #include "riscos/save.h" #include "riscos/save_draw.h" @@ -337,7 +337,7 @@ bool ro_gui_save_ok(wimp_w w) || !(pointer.buttons & wimp_CLICK_ADJUST); memcpy(&gui_save_message.data.data_xfer.file_name, path, 1 + strlen(path)); - if (ro_gui_save_content(gui_save_content, path, !option_confirm_overwrite)) { + if (ro_gui_save_content(gui_save_content, path, !nsoption_bool(confirm_overwrite))) { ro_gui_save_done(); return true; } @@ -794,7 +794,7 @@ void ro_gui_save_datasave_ack(wimp_message *message) if (message->data.data_xfer.est_size == -1) force_overwrite = true; else - force_overwrite = !option_confirm_overwrite; + force_overwrite = !nsoption_bool(confirm_overwrite); if (ro_gui_save_content(h, path, force_overwrite)) ro_gui_save_done(); @@ -1312,7 +1312,7 @@ void ro_gui_save_set_state(hlcache_handle *h, gui_save_type save_type, } /* leafname */ - if (url && url_nice(url, &nice, option_strip_extensions) == + if (url && url_nice(url, &nice, nsoption_bool(strip_extensions)) == URL_FUNC_OK) { for (i = 0; nice[i]; i++) { if (nice[i] == '.') diff --git a/riscos/system_colour.c b/riscos/system_colour.c index dbb909c36..7334fde73 100644 --- a/riscos/system_colour.c +++ b/riscos/system_colour.c @@ -49,196 +49,196 @@ static struct gui_system_colour_ctx colour_list[] = { SLEN("ActiveBorder"), 0xff000000, wimp_COLOUR_BLACK, - &option_sys_colour_ActiveBorder, + &nsoption_colour(sys_colour_ActiveBorder), NULL }, { "ActiveCaption", SLEN("ActiveCaption"), 0xffdddddd, wimp_COLOUR_CREAM, - &option_sys_colour_ActiveCaption, + &nsoption_colour(sys_colour_ActiveCaption), NULL }, { "AppWorkspace", SLEN("AppWorkspace"), 0xffeeeeee, wimp_COLOUR_VERY_LIGHT_GREY, - &option_sys_colour_AppWorkspace, + &nsoption_colour(sys_colour_AppWorkspace), NULL }, { "Background", SLEN("Background"), 0xff0000aa, wimp_COLOUR_VERY_LIGHT_GREY, /* \TODO -- Check */ - &option_sys_colour_Background, + &nsoption_colour(sys_colour_Background), NULL }, { "ButtonFace", SLEN("ButtonFace"), 0xffaaaaaa, wimp_COLOUR_VERY_LIGHT_GREY, - &option_sys_colour_ButtonFace, + &nsoption_colour(sys_colour_ButtonFace), NULL }, { "ButtonHighlight", SLEN("ButtonHighlight"), 0xffdddddd, wimp_COLOUR_DARK_GREY, /* \TODO -- Check */ - &option_sys_colour_ButtonHighlight, + &nsoption_colour(sys_colour_ButtonHighlight), NULL }, { "ButtonShadow", SLEN("ButtonShadow"), 0xffbbbbbb, wimp_COLOUR_MID_DARK_GREY, - &option_sys_colour_ButtonShadow, + &nsoption_colour(sys_colour_ButtonShadow), NULL }, { "ButtonText", SLEN("ButtonText"), 0xff000000, wimp_COLOUR_BLACK, - &option_sys_colour_ButtonText, + &nsoption_colour(sys_colour_ButtonText), NULL }, { "CaptionText", SLEN("CaptionText"), 0xff000000, wimp_COLOUR_BLACK, - &option_sys_colour_CaptionText, + &nsoption_colour(sys_colour_CaptionText), NULL }, { "GrayText", SLEN("GrayText"), 0xffcccccc, wimp_COLOUR_MID_LIGHT_GREY, /* \TODO -- Check */ - &option_sys_colour_GrayText, + &nsoption_colour(sys_colour_GrayText), NULL }, { "Highlight", SLEN("Highlight"), 0xff0000ee, wimp_COLOUR_BLACK, - &option_sys_colour_Highlight, + &nsoption_colour(sys_colour_Highlight), NULL }, { "HighlightText", SLEN("HighlightText"), 0xff000000, wimp_COLOUR_WHITE, - &option_sys_colour_HighlightText, + &nsoption_colour(sys_colour_HighlightText), NULL }, { "InactiveBorder", SLEN("InactiveBorder"), 0xffffffff, wimp_COLOUR_BLACK, - &option_sys_colour_InactiveBorder, + &nsoption_colour(sys_colour_InactiveBorder), NULL }, { "InactiveCaption", SLEN("InactiveCaption"), 0xffffffff, wimp_COLOUR_LIGHT_GREY, - &option_sys_colour_InactiveCaption, + &nsoption_colour(sys_colour_InactiveCaption), NULL }, { "InactiveCaptionText", SLEN("InactiveCaptionText"), 0xffcccccc, wimp_COLOUR_BLACK, - &option_sys_colour_InactiveCaptionText, + &nsoption_colour(sys_colour_InactiveCaptionText), NULL }, { "InfoBackground", SLEN("InfoBackground"), 0xffaaaaaa, wimp_COLOUR_CREAM, - &option_sys_colour_InfoBackground, + &nsoption_colour(sys_colour_InfoBackground), NULL }, { "InfoText", SLEN("InfoText"), 0xff000000, wimp_COLOUR_BLACK, - &option_sys_colour_InfoText, + &nsoption_colour(sys_colour_InfoText), NULL }, { "Menu", SLEN("Menu"), 0xffaaaaaa, wimp_COLOUR_WHITE, - &option_sys_colour_Menu, + &nsoption_colour(sys_colour_Menu), NULL }, { "MenuText", SLEN("MenuText"), 0xff000000, wimp_COLOUR_BLACK, - &option_sys_colour_MenuText, + &nsoption_colour(sys_colour_MenuText), NULL }, { "Scrollbar", SLEN("Scrollbar"), 0xffaaaaaa, wimp_COLOUR_LIGHT_GREY, /* \TODO -- Check */ - &option_sys_colour_Scrollbar, + &nsoption_colour(sys_colour_Scrollbar), NULL }, { "ThreeDDarkShadow", SLEN("ThreeDDarkShadow"), 0xff555555, wimp_COLOUR_MID_DARK_GREY, - &option_sys_colour_ThreeDDarkShadow, + &nsoption_colour(sys_colour_ThreeDDarkShadow), NULL }, { "ThreeDFace", SLEN("ThreeDFace"), 0xffdddddd, wimp_COLOUR_VERY_LIGHT_GREY, - &option_sys_colour_ThreeDFace, + &nsoption_colour(sys_colour_ThreeDFace), NULL }, { "ThreeDHighlight", SLEN("ThreeDHighlight"), 0xffaaaaaa, wimp_COLOUR_WHITE, - &option_sys_colour_ThreeDHighlight, + &nsoption_colour(sys_colour_ThreeDHighlight), NULL }, { "ThreeDLightShadow", SLEN("ThreeDLightShadow"), 0xff999999, wimp_COLOUR_WHITE, - &option_sys_colour_ThreeDLightShadow, + &nsoption_colour(sys_colour_ThreeDLightShadow), NULL }, { "ThreeDShadow", SLEN("ThreeDShadow"), 0xff777777, wimp_COLOUR_MID_DARK_GREY, - &option_sys_colour_ThreeDShadow, + &nsoption_colour(sys_colour_ThreeDShadow), NULL }, { "Window", SLEN("Window"), 0xffaaaaaa, wimp_COLOUR_VERY_LIGHT_GREY, - &option_sys_colour_Window, + &nsoption_colour(sys_colour_Window), NULL }, { "WindowFrame", SLEN("WindowFrame"), 0xff000000, wimp_COLOUR_BLACK, - &option_sys_colour_WindowFrame, + &nsoption_colour(sys_colour_WindowFrame), NULL }, { "WindowText", SLEN("WindowText"), 0xff000000, wimp_COLOUR_BLACK, - &option_sys_colour_WindowText, + &nsoption_colour(sys_colour_WindowText), NULL }, diff --git a/riscos/theme.c b/riscos/theme.c index 6b83cad92..b44493dd9 100644 --- a/riscos/theme.c +++ b/riscos/theme.c @@ -44,7 +44,7 @@ #include "riscos/gui.h" #include "riscos/hotlist.h" #include "riscos/menus.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/theme.h" #include "riscos/treeview.h" #include "riscos/wimp.h" @@ -72,7 +72,7 @@ void ro_gui_theme_initialise(void) struct theme_descriptor *descriptor; theme_descriptors = ro_gui_theme_get_available(); - descriptor = ro_gui_theme_find(option_theme); + descriptor = ro_gui_theme_find(nsoption_charp(theme)); if (!descriptor) descriptor = ro_gui_theme_find("Aletheia"); ro_gui_theme_apply(descriptor); @@ -136,7 +136,7 @@ struct theme_descriptor *ro_gui_theme_get_available(void) ro_gui_theme_add_descriptor("NetSurf:Resources", "Aletheia"); /* scan our choices directory */ - ro_gui_theme_get_available_in_dir(option_theme_path); + ro_gui_theme_get_available_in_dir(nsoption_charp(theme_path)); /* sort alphabetically in a very rubbish way */ if ((theme_descriptors) && (theme_descriptors->next)) { diff --git a/riscos/theme_install.c b/riscos/theme_install.c index 574a380d4..e5d5aafa3 100644 --- a/riscos/theme_install.c +++ b/riscos/theme_install.c @@ -28,7 +28,7 @@ #include "desktop/browser.h" #include "riscos/dialog.h" #include "riscos/gui.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/theme.h" #include "riscos/wimp.h" #include "riscos/wimp_event.h" @@ -198,7 +198,7 @@ bool ro_gui_theme_install_apply(wimp_w w) /* simply overwrite previous theme versions */ snprintf(theme_save, sizeof theme_save, "%s.%s", - option_theme_save, theme_file); + nsoption_charp(theme_save), theme_file); theme_save[sizeof theme_save - 1] = '\0'; @@ -222,8 +222,7 @@ bool ro_gui_theme_install_apply(wimp_w w) if (!theme_install || !ro_gui_theme_apply(theme_install)) { warn_user("ThemeApplyErr", 0); } else { - free(option_theme); - option_theme = strdup(theme_install->leafname); + nsoption_set_charp(theme, strdup(theme_install->leafname)); } free(theme_file); ro_gui_save_options(); diff --git a/riscos/thumbnail.c b/riscos/thumbnail.c index a9ee005af..43100cab1 100644 --- a/riscos/thumbnail.c +++ b/riscos/thumbnail.c @@ -40,7 +40,7 @@ #include "render/font.h" #include "riscos/bitmap.h" #include "riscos/gui.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/oslib_pre7.h" #include "riscos/thumbnail.h" #include "riscos/tinct.h" diff --git a/riscos/toolbar.c b/riscos/toolbar.c index 96bd5a8d7..7e95ce6b0 100644 --- a/riscos/toolbar.c +++ b/riscos/toolbar.c @@ -49,7 +49,7 @@ #include "riscos/gui/url_bar.h" #include "riscos/hotlist.h" #include "riscos/menus.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/save.h" #include "riscos/theme.h" #include "riscos/toolbar.h" diff --git a/riscos/url_complete.c b/riscos/url_complete.c index 98820b7a3..d962f195d 100644 --- a/riscos/url_complete.c +++ b/riscos/url_complete.c @@ -30,7 +30,7 @@ #include "utils/log.h" #include "riscos/global_history.h" #include "riscos/gui.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/toolbar.h" #include "riscos/url_complete.h" #include "riscos/wimp.h" @@ -105,7 +105,7 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key) /* we must have a toolbar/url bar */ if (!ro_toolbar_get_display_url(toolbar) || - (!option_url_suggestion)) { + (!nsoption_bool(url_suggestion))) { ro_gui_url_complete_close(); return false; } diff --git a/riscos/window.c b/riscos/window.c index 7674419d7..9cdcb19f6 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -69,7 +69,7 @@ #include "riscos/help.h" #include "riscos/hotlist.h" #include "riscos/menus.h" -#include "riscos/options.h" +#include "desktop/options.h" #include "riscos/oslib_pre7.h" #include "riscos/save.h" #include "riscos/content-handlers/sprite.h" @@ -398,7 +398,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, g->iconise_icon = -1; /* Set the window position */ - if (clone && clone->window && option_window_size_clone) { + if (clone && clone->window && nsoption_bool(window_size_clone)) { for (top = clone; top->parent; top = top->parent); state.w = top->window->window; error = xwimp_get_window_state(&state); @@ -416,17 +416,17 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, ro_gui_screen_size(&screen_width, &screen_height); /* Check if we have a preferred position */ - if ((option_window_screen_width != 0) && - (option_window_screen_height != 0)) { - win_width = (option_window_width * screen_width) / - option_window_screen_width; - win_height = (option_window_height * screen_height) / - option_window_screen_height; - window.visible.x0 = (option_window_x * screen_width) / - option_window_screen_width; - window.visible.y0 = (option_window_y * screen_height) / - option_window_screen_height; - if (option_window_stagger) { + if ((nsoption_int(window_screen_width) != 0) && + (nsoption_int(window_screen_height) != 0)) { + win_width = (nsoption_int(window_width) * screen_width) / + nsoption_int(window_screen_width); + win_height = (nsoption_int(window_height) * screen_height) / + nsoption_int(window_screen_height); + window.visible.x0 = (nsoption_int(window_x) * screen_width) / + nsoption_int(window_screen_width); + window.visible.y0 = (nsoption_int(window_y) * screen_height) / + nsoption_int(window_screen_height); + if (nsoption_bool(window_stagger)) { window.visible.y0 += 96 - (48 * (window_count % 5)); } @@ -520,7 +520,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, /* Add in a toolbar and status bar */ g->status_bar = ro_gui_status_bar_create(g->window, - option_toolbar_status_width); + nsoption_int(toolbar_status_width)); g->toolbar = ro_toolbar_create(NULL, g->window, THEME_STYLE_BROWSER_TOOLBAR, TOOLBAR_FLAGS_NONE, &ro_gui_window_toolbar_callbacks, g, @@ -528,7 +528,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, if (g->toolbar != NULL) { ro_toolbar_add_buttons(g->toolbar, brower_toolbar_buttons, - option_toolbar_browser); + nsoption_charp(toolbar_browser)); ro_toolbar_add_url(g->toolbar); ro_toolbar_add_throbber(g->toolbar); ro_toolbar_rebuild(g->toolbar); @@ -2349,10 +2349,10 @@ bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu, /* View Submenu */ ro_gui_menu_set_entry_ticked(menu, BROWSER_IMAGES_FOREGROUND, - g != NULL && option_foreground_images); + g != NULL && nsoption_bool(foreground_images)); ro_gui_menu_set_entry_ticked(menu, BROWSER_IMAGES_BACKGROUND, - g != NULL && option_background_images); + g != NULL && nsoption_bool(background_images)); ro_gui_menu_set_entry_shaded(menu, BROWSER_BUFFER_ANIMS, g == NULL || g->option.buffer_everything); @@ -2367,16 +2367,16 @@ bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu, ro_gui_menu_set_entry_shaded(menu, BROWSER_SCALE_VIEW, h == NULL); ro_gui_menu_set_entry_shaded(menu, BROWSER_WINDOW_STAGGER, - option_window_screen_width == 0); + nsoption_int(window_screen_width) == 0); ro_gui_menu_set_entry_ticked(menu, BROWSER_WINDOW_STAGGER, - ((option_window_screen_width == 0) || - option_window_stagger)); + ((nsoption_int(window_screen_width) == 0) || + nsoption_bool(window_stagger))); ro_gui_menu_set_entry_ticked(menu, BROWSER_WINDOW_COPY, - option_window_size_clone); + nsoption_bool(window_size_clone)); ro_gui_menu_set_entry_shaded(menu, BROWSER_WINDOW_RESET, - option_window_screen_width == 0); + nsoption_int(window_screen_width) == 0); /* Utilities Submenu */ @@ -2393,7 +2393,7 @@ bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu, ro_gui_menu_set_entry_ticked(menu, HELP_LAUNCH_INTERACTIVE, ro_gui_interactive_help_available() && - option_interactive_help); + nsoption_bool(interactive_help)); return true; } @@ -2658,9 +2658,9 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu, case HELP_LAUNCH_INTERACTIVE: if (!ro_gui_interactive_help_available()) { ro_gui_interactive_help_start(); - option_interactive_help = true; + nsoption_set_bool(interactive_help, true); } else { - option_interactive_help = !option_interactive_help; + nsoption_set_bool(interactive_help, !nsoption_bool(interactive_help)); } break; @@ -2868,13 +2868,13 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu, break; case BROWSER_IMAGES_FOREGROUND: if (g != NULL) - option_foreground_images = - !option_foreground_images; + nsoption_set_bool(foreground_images, + !nsoption_bool(foreground_images)); break; case BROWSER_IMAGES_BACKGROUND: if (g != NULL) - option_background_images = - !option_background_images; + nsoption_set_bool(background_images, + !nsoption_bool(background_images)); break; case BROWSER_BUFFER_ANIMS: if (g != NULL) @@ -2894,8 +2894,8 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu, break; case BROWSER_WINDOW_DEFAULT: if (g != NULL) { - ro_gui_screen_size(&option_window_screen_width, - &option_window_screen_height); + ro_gui_screen_size(&nsoption_int(window_screen_width), + &nsoption_int(window_screen_height)); state.w = w; error = xwimp_get_window_state(&state); if (error) { @@ -2904,26 +2904,26 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu, error->errmess)); warn_user("WimpError", error->errmess); } - option_window_x = state.visible.x0; - option_window_y = state.visible.y0; - option_window_width = - state.visible.x1 - state.visible.x0; - option_window_height = - state.visible.y1 - state.visible.y0; + nsoption_set_int(window_x, state.visible.x0); + nsoption_set_int(window_y, state.visible.y0); + nsoption_set_int(window_width, + state.visible.x1 - state.visible.x0); + nsoption_set_int(window_height, + state.visible.y1 - state.visible.y0); ro_gui_save_options(); } break; case BROWSER_WINDOW_STAGGER: - option_window_stagger = !option_window_stagger; + nsoption_set_bool(window_stagger, !nsoption_bool(window_stagger)); ro_gui_save_options(); break; case BROWSER_WINDOW_COPY: - option_window_size_clone = !option_window_size_clone; + nsoption_set_bool(window_size_clone, !nsoption_bool(window_size_clone)); ro_gui_save_options(); break; case BROWSER_WINDOW_RESET: - option_window_screen_width = 0; - option_window_screen_height = 0; + nsoption_set_int(window_screen_width, 0); + nsoption_set_int(window_screen_height, 0); ro_gui_save_options(); break; @@ -3886,12 +3886,12 @@ void ro_gui_window_action_home(struct gui_window *g) if (g == NULL || g->bw == NULL) return; - if ((option_homepage_url) && (option_homepage_url[0])) { - browser_window_go(g->bw, option_homepage_url, 0, true); + if ((nsoption_charp(homepage_url)) && (nsoption_charp(homepage_url)[0])) { + browser_window_go(g->bw, nsoption_charp(homepage_url), 0, true); } else { snprintf(url, sizeof url, "file:////Docs/welcome/index_%s", - option_language); + nsoption_charp(language)); browser_window_go(g->bw, url, 0, true); } } @@ -4325,9 +4325,7 @@ void ro_gui_window_update_toolbar(void *data) void ro_gui_window_save_toolbar_buttons(void *data, char *config) { - if (option_toolbar_browser != NULL) - free(option_toolbar_browser); - option_toolbar_browser = config; + nsoption_set_charp(toolbar_browser, config); ro_gui_save_options(); } @@ -4467,9 +4465,9 @@ void ro_gui_window_clone_options(struct browser_window *new_bw, /* Clone the basic options */ if (!old_gui) { - new_bw->scale = ((float)option_scale) / 100; - new_gui->option.buffer_animations = option_buffer_animations; - new_gui->option.buffer_everything = option_buffer_everything; + new_bw->scale = ((float)nsoption_int(scale)) / 100; + new_gui->option.buffer_animations = nsoption_bool(buffer_animations); + new_gui->option.buffer_everything = nsoption_bool(buffer_everything); } else { new_gui->option = old_gui->option; } @@ -4478,11 +4476,11 @@ void ro_gui_window_clone_options(struct browser_window *new_bw, */ if (new_gui->toolbar) { ro_toolbar_set_display_buttons(new_gui->toolbar, - option_toolbar_show_buttons); + nsoption_bool(toolbar_show_buttons)); ro_toolbar_set_display_url(new_gui->toolbar, - option_toolbar_show_address); + nsoption_bool(toolbar_show_address)); ro_toolbar_set_display_throbber(new_gui->toolbar, - option_toolbar_show_throbber); + nsoption_bool(toolbar_show_throbber)); if ((old_gui) && (old_gui->toolbar)) { ro_toolbar_set_display_buttons(new_gui->toolbar, ro_toolbar_get_display_buttons( @@ -4518,23 +4516,23 @@ void ro_gui_window_default_options(struct browser_window *bw) /* Save the basic options */ - option_scale = bw->scale * 100; - option_buffer_animations = gui->option.buffer_animations; - option_buffer_everything = gui->option.buffer_everything; + nsoption_set_int(scale, bw->scale * 100); + nsoption_set_bool(buffer_animations, gui->option.buffer_animations); + nsoption_set_bool(buffer_everything, gui->option.buffer_everything); /* Set up the toolbar */ if (gui->toolbar != NULL) { - option_toolbar_show_buttons = - ro_toolbar_get_display_buttons(gui->toolbar); - option_toolbar_show_address = - ro_toolbar_get_display_url(gui->toolbar); - option_toolbar_show_throbber = - ro_toolbar_get_display_throbber(gui->toolbar); + nsoption_set_bool(toolbar_show_buttons, + ro_toolbar_get_display_buttons(gui->toolbar)); + nsoption_set_bool(toolbar_show_address, + ro_toolbar_get_display_url(gui->toolbar)); + nsoption_set_bool(toolbar_show_throbber, + ro_toolbar_get_display_throbber(gui->toolbar)); } if (gui->status_bar != NULL) - option_toolbar_status_width = - ro_gui_status_bar_get_width(gui->status_bar); + nsoption_set_int(toolbar_status_width, + ro_gui_status_bar_get_width(gui->status_bar)); } diff --git a/windows/font.c b/windows/font.c index ada54eef0..f97e366f6 100644 --- a/windows/font.c +++ b/windows/font.c @@ -46,30 +46,45 @@ utf8_convert_ret utf8_to_local_encoding(const char *string, return utf8_to_enc(string, "UCS-2", len, result); } +utf8_convert_ret utf8_from_local_encoding(const char *string, size_t len, + char **result) +{ + assert(string && result); + + if (len == 0) + len = strlen(string); + + *result = strndup(string, len); + if (!(*result)) + return UTF8_CONVERT_NOMEM; + + return UTF8_CONVERT_OK; +} + HFONT get_font(const plot_font_style_t *style) { char *face = NULL; DWORD family; switch(style->family) { case PLOT_FONT_FAMILY_SERIF: - face = strdup(option_font_serif); + face = strdup(nsoption_charp(font_serif)); family = FF_ROMAN | DEFAULT_PITCH; break; case PLOT_FONT_FAMILY_MONOSPACE: - face = strdup(option_font_mono); + face = strdup(nsoption_charp(font_mono)); family = FF_MODERN | DEFAULT_PITCH; break; case PLOT_FONT_FAMILY_CURSIVE: - face = strdup(option_font_cursive); + face = strdup(nsoption_charp(font_cursive)); family = FF_SCRIPT | DEFAULT_PITCH; break; case PLOT_FONT_FAMILY_FANTASY: - face = strdup(option_font_fantasy); + face = strdup(nsoption_charp(font_fantasy)); family = FF_DECORATIVE | DEFAULT_PITCH; break; case PLOT_FONT_FAMILY_SANS_SERIF: default: - face = strdup(option_font_sans); + face = strdup(nsoption_charp(font_sans)); family = FF_SWISS | DEFAULT_PITCH; break; } diff --git a/windows/gui.c b/windows/gui.c index f3a2a730d..b98bde469 100644 --- a/windows/gui.c +++ b/windows/gui.c @@ -832,7 +832,7 @@ nsws_window_command(HWND hwnd, break; case IDM_NAV_HOME: - browser_window_go(gw->bw, option_homepage_url, 0, true); + browser_window_go(gw->bw, nsoption_charp(homepage_url), 0, true); break; case IDM_NAV_STOP: @@ -893,11 +893,11 @@ nsws_window_command(HWND hwnd, case IDM_VIEW_SAVE_WIN_METRICS: { RECT r; GetWindowRect(gw->main, &r); - option_window_x = r.left; - option_window_y = r.top; - option_window_width = r.right - r.left; - option_window_height = r.bottom - r.top; - options_write(options_file_location); + nsoption_set_int(window_x, r.left); + nsoption_set_int(window_y, r.top); + nsoption_set_int(window_width, r.right - r.left); + nsoption_set_int(window_height, r.bottom - r.top); + nsoption_write(options_file_location); break; } @@ -1140,16 +1140,16 @@ static HWND nsws_window_create(struct gui_window *gw) nscss_screen_dpi = get_window_dpi(hwnd); - if ((option_window_width >= 100) && - (option_window_height >= 100) && - (option_window_x >= 0) && - (option_window_y >= 0)) { + if ((nsoption_int(window_width) >= 100) && + (nsoption_int(window_height) >= 100) && + (nsoption_int(window_x) >= 0) && + (nsoption_int(window_y) >= 0)) { LOG(("Setting Window position %d,%d %d,%d", - option_window_x, option_window_y, - option_window_width, option_window_height)); + nsoption_int(window_x), nsoption_int(window_y), + nsoption_int(window_width), nsoption_int(window_height))); SetWindowPos(hwnd, HWND_TOP, - option_window_x, option_window_y, - option_window_width, option_window_height, + nsoption_int(window_x), nsoption_int(window_y), + nsoption_int(window_width), nsoption_int(window_height), SWP_SHOWWINDOW); } diff --git a/windows/main.c b/windows/main.c index 26b966d25..8213ca8c7 100644 --- a/windows/main.c +++ b/windows/main.c @@ -131,19 +131,19 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd) ret = nsws_create_drawable_class(hInstance); ret = nsws_create_localhistory_class(hInstance); - option_target_blank = false; + nsoption_set_bool(target_blank, false); nsws_window_init_pointers(hInstance); /* ensure homepage option has a default */ - if (option_homepage_url == NULL || option_homepage_url[0] == '\0') - option_homepage_url = strdup(NETSURF_HOMEPAGE); + nsoption_setnull_charp(homepage_url, strdup(NETSURF_HOMEPAGE)); /* If there is a url specified on the command line use it */ - if (argc > 1) + if (argc > 1) { addr = argv[1]; - else - addr = option_homepage_url; + } else { + addr = nsoption_charp(homepage_url); + } LOG(("calling browser_window_create")); bw = browser_window_create(addr, 0, 0, true, false); diff --git a/windows/prefs.c b/windows/prefs.c index d7cc51afa..b3cdca3ae 100644 --- a/windows/prefs.c +++ b/windows/prefs.c @@ -47,26 +47,27 @@ static CHOOSEFONT *nsws_prefs_font_prepare(int fontfamily, HWND parent) switch(fontfamily) { case FF_ROMAN: snprintf(lf->lfFaceName, LF_FACESIZE, "%s", - option_font_serif); + nsoption_charp(font_serif)); break; case FF_MODERN: snprintf(lf->lfFaceName, LF_FACESIZE, "%s", - option_font_mono); + nsoption_charp(font_mono)); break; case FF_SCRIPT: snprintf(lf->lfFaceName, LF_FACESIZE, "%s", - option_font_cursive); + nsoption_charp(font_cursive)); break; case FF_DECORATIVE: snprintf(lf->lfFaceName, LF_FACESIZE, "%s", - option_font_fantasy); + nsoption_charp(font_fantasy)); break; case FF_SWISS: default: snprintf(lf->lfFaceName, LF_FACESIZE, "%s", - option_font_sans); + nsoption_charp(font_sans)); break; } + cf->lStructSize = sizeof(CHOOSEFONT); cf->hwndOwner = parent; cf->lpLogFont = lf; @@ -124,76 +125,75 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND hwnd, SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Cursive"); SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Fantasy"); SendMessage(sub, CB_SETCURSEL, - (WPARAM) (option_font_default - 1), 0); + (WPARAM) (nsoption_int(font_default) - 1), 0); - if ((option_font_sans != NULL) && - (option_font_sans[0] != '\0')) { + if ((nsoption_charp(font_sans) != NULL) && + (nsoption_charp(font_sans)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_SANS); SendMessage(sub, WM_SETTEXT, 0, - (LPARAM)option_font_sans); + (LPARAM)nsoption_charp(font_sans)); } - if ((option_font_serif != NULL) && - (option_font_serif[0] != '\0')) { + if ((nsoption_charp(font_serif) != NULL) && + (nsoption_charp(font_serif)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_SERIF); SendMessage(sub, WM_SETTEXT, 0, - (LPARAM)option_font_serif); + (LPARAM)nsoption_charp(font_serif)); } - if ((option_font_mono != NULL) && - (option_font_mono[0] != '\0')) { + if ((nsoption_charp(font_mono) != NULL) && + (nsoption_charp(font_mono)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_MONO); SendMessage(sub, WM_SETTEXT, 0, - (LPARAM)option_font_mono); + (LPARAM)nsoption_charp(font_mono)); } - if ((option_font_cursive != NULL) && - (option_font_cursive[0] != '\0')) { + if ((nsoption_charp(font_cursive) != NULL) && + (nsoption_charp(font_cursive)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_CURSIVE); SendMessage(sub, WM_SETTEXT, 0, - (LPARAM)option_font_cursive); + (LPARAM)nsoption_charp(font_cursive)); } - if ((option_font_fantasy != NULL) && - (option_font_fantasy[0] != '\0')) { + if ((nsoption_charp(font_fantasy) != NULL) && + (nsoption_charp(font_fantasy)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_FANTASY); SendMessage(sub, WM_SETTEXT, 0, - (LPARAM)option_font_fantasy); + (LPARAM)nsoption_charp(font_fantasy)); } - if (option_font_min_size != 0) { + if (nsoption_int(font_min_size) != 0) { sub = GetDlgItem(hwnd, IDC_PREFS_FONT_MINSIZE); - snprintf(number, 6, "%.1f", option_font_min_size / - 10.0); + snprintf(number, 6, "%.1f", nsoption_int(font_min_size) / 10.0); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); } - if (option_font_size != 0) { + if (nsoption_int(font_size) != 0) { sub = GetDlgItem(hwnd, IDC_PREFS_FONT_SIZE); - snprintf(number, 6, "%.1f", option_font_size / 10.0); + snprintf(number, 6, "%.1f", nsoption_int(font_size) / 10.0); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); } - if (option_max_fetchers != 0) { + if (nsoption_int(max_fetchers) != 0) { sub = GetDlgItem(hwnd, IDC_PREFS_FETCHERS); - snprintf(number, 6, "%d", option_max_fetchers); + snprintf(number, 6, "%d", nsoption_int(max_fetchers)); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); } - if (option_max_fetchers_per_host != 0) { + if (nsoption_int(max_fetchers_per_host) != 0) { sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HOST); snprintf(number, 6, "%d", - option_max_fetchers_per_host); + nsoption_int(max_fetchers_per_host)); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); } - if (option_max_cached_fetch_handles != 0) { + if (nsoption_int(max_cached_fetch_handles) != 0) { sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HANDLES); snprintf(number, 6, "%d", - option_max_cached_fetch_handles); + nsoption_int(max_cached_fetch_handles)); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); } /* animation */ sub = GetDlgItem(hwnd, IDC_PREFS_NOANIMATION); - SendMessage(sub, BM_SETCHECK, (WPARAM)((option_animate_images) + SendMessage(sub, BM_SETCHECK, (WPARAM)((nsoption_bool(animate_images)) ? BST_UNCHECKED : BST_CHECKED), 0); - if (option_minimum_gif_delay != 0) { + if (nsoption_int(minimum_gif_delay) != 0) { sub = GetDlgItem(hwnd, IDC_PREFS_ANIMATIONDELAY); - snprintf(number, 6, "%.1f", option_minimum_gif_delay / + snprintf(number, 6, "%.1f", nsoption_int(minimum_gif_delay) / 100.0); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); } @@ -208,7 +208,7 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND hwnd, if (temp != NULL) { SendMessage(sub, WM_GETTEXT, (WPARAM) (len + 1), (LPARAM) temp); - option_font_size = (int) + nsoption_int(font_size) = (int) (10 * strtod(temp, NULL)); free(temp); } @@ -219,13 +219,14 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND hwnd, if (temp != NULL) { SendMessage(sub, WM_GETTEXT, (WPARAM) (len + 1), (LPARAM) temp); - option_font_min_size = (int) - (10 * strtod(temp, NULL)); + nsoption_set_int(font_min_size, + (int)(10 * strtod(temp, NULL))); free(temp); } /* animation */ - option_animate_images = (IsDlgButtonChecked(hwnd, IDC_PREFS_NOANIMATION) == BST_CHECKED) ? true : false; + nsoption_set_bool(animate_images, + (IsDlgButtonChecked(hwnd, IDC_PREFS_NOANIMATION) == BST_CHECKED) ? true : false); sub = GetDlgItem(hwnd, IDC_PREFS_ANIMATIONDELAY); @@ -234,8 +235,8 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND hwnd, if (temp != NULL) { SendMessage(sub, WM_GETTEXT, (WPARAM) (len + 1), (LPARAM) temp); - option_minimum_gif_delay = (int) - (100 * strtod(temp, NULL)); + nsoption_set_int(minimum_gif_delay, + (int)(100 * strtod(temp, NULL))); free(temp); } @@ -255,7 +256,7 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND hwnd, case IDC_PREFS_ANIMATIONDELAY_SPIN: change_spinner(GetDlgItem(hwnd, IDC_PREFS_ANIMATIONDELAY), 0.1 * ud->iDelta, 0.1, 100.0); return TRUE; - + } } break; @@ -264,131 +265,134 @@ static BOOL CALLBACK options_appearance_dialog_handler(HWND hwnd, case WM_COMMAND: LOG(("WM_COMMAND Identifier 0x%x",LOWORD(wparam))); + switch(LOWORD(wparam)) { case IDC_PREFS_PROXYTYPE: sub = GetDlgItem(hwnd, IDC_PREFS_PROXYTYPE); - option_http_proxy_auth = SendMessage(sub, - CB_GETCURSEL, 0, 0) - 1; - option_http_proxy = (option_http_proxy_auth != -1); - option_http_proxy_auth += (option_http_proxy) ? 0 : 1; + nsoption_set_int(http_proxy_auth, + SendMessage(sub, CB_GETCURSEL, 0, 0) - 1); + nsoption_set_bool(http_proxy, + (nsoption_int(http_proxy_auth) != -1)); + nsoption_set_int(http_proxy_auth, + nsoption_int(http_proxy_auth) + + (nsoption_bool(http_proxy)) ? 0 : 1); break; case IDC_PREFS_SANS: { - CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_SWISS, - hwnd); - if (cf == NULL) + CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_SWISS, hwnd); + if (cf == NULL) { break; - if (ChooseFont(cf) == TRUE) { - if (option_font_sans != NULL) - free(option_font_sans); - option_font_sans = strdup( - cf->lpLogFont->lfFaceName); } + + if (ChooseFont(cf) == TRUE) { + nsoption_set_charp(font_sans, + strdup(cf->lpLogFont->lfFaceName)); + } + free(cf->lpLogFont); free(cf); - if ((option_font_sans != NULL) && - (option_font_sans[0] != '\0')) { + if ((nsoption_charp(font_sans) != NULL) && + (nsoption_charp(font_sans)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_SANS); SendMessage(sub, WM_SETTEXT, 0, - (LPARAM)option_font_sans); + (LPARAM)nsoption_charp(font_sans)); } break; } case IDC_PREFS_SERIF: { - CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_ROMAN, - hwnd); - if (cf == NULL) + CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_ROMAN, hwnd); + if (cf == NULL) { break; + } if (ChooseFont(cf) == TRUE) { - if (option_font_serif != NULL) - free(option_font_serif); - option_font_serif = strdup( - cf->lpLogFont->lfFaceName); + nsoption_set_charp(font_serif, + strdup(cf->lpLogFont->lfFaceName)); } + free(cf->lpLogFont); free(cf); - if ((option_font_serif != NULL) && - (option_font_serif[0] != '\0')) { + if ((nsoption_charp(font_serif) != NULL) && + (nsoption_charp(font_serif)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_SERIF); SendMessage(sub, WM_SETTEXT, 0, - (LPARAM)option_font_serif); + (LPARAM)nsoption_charp(font_serif)); } break; } + case IDC_PREFS_MONO: { - CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_MODERN, - hwnd); - if (cf == NULL) + CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_MODERN, hwnd); + if (cf == NULL) { break; + } if (ChooseFont(cf) == TRUE) { - if (option_font_mono != NULL) - free(option_font_mono); - option_font_mono = strdup( - cf->lpLogFont->lfFaceName); + nsoption_set_charp(font_mono, + strdup(cf->lpLogFont->lfFaceName)); } + free(cf->lpLogFont); free(cf); - if ((option_font_mono != NULL) && - (option_font_mono[0] != '\0')) { + + if ((nsoption_charp(font_mono) != NULL) && + (nsoption_charp(font_mono)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_MONO); SendMessage(sub, WM_SETTEXT, 0, - (LPARAM)option_font_mono); + (LPARAM)nsoption_charp(font_mono)); } break; } + case IDC_PREFS_CURSIVE: { - CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_SCRIPT, - hwnd); - if (cf == NULL) + CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_SCRIPT, hwnd); + if (cf == NULL) { break; + } if (ChooseFont(cf) == TRUE) { - if (option_font_cursive != NULL) - free(option_font_cursive); - option_font_cursive = strdup( - cf->lpLogFont->lfFaceName); + nsoption_set_charp(font_cursive, + strdup(cf->lpLogFont->lfFaceName)); } free(cf->lpLogFont); free(cf); - if ((option_font_cursive != NULL) && - (option_font_cursive[0] != '\0')) { + if ((nsoption_charp(font_cursive) != NULL) && + (nsoption_charp(font_cursive)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_CURSIVE); SendMessage(sub, WM_SETTEXT, 0, - (LPARAM)option_font_cursive); + (LPARAM)nsoption_charp(font_cursive)); } break; } + case IDC_PREFS_FANTASY: { - CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_DECORATIVE, - hwnd); - if (cf == NULL) + CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_DECORATIVE, hwnd); + if (cf == NULL) { break; + } + if (ChooseFont(cf) == TRUE) { - if (option_font_fantasy != NULL) - free(option_font_fantasy); - option_font_fantasy = strdup( - cf->lpLogFont->lfFaceName); + nsoption_set_charp(font_fantasy, + strdup(cf->lpLogFont->lfFaceName)); } free(cf->lpLogFont); free(cf); - if ((option_font_fantasy != NULL) && - (option_font_fantasy[0] != '\0')) { + if ((nsoption_charp(font_fantasy) != NULL) && + (nsoption_charp(font_fantasy)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_FANTASY); SendMessage(sub, WM_SETTEXT, 0, - (LPARAM)option_font_fantasy); + (LPARAM)nsoption_charp(font_fantasy)); } break; } case IDC_PREFS_FONTDEF: sub = GetDlgItem(hwnd, IDC_PREFS_FONTDEF); - option_font_default = SendMessage(sub, CB_GETCURSEL, 0, 0) + 1; + nsoption_set_int(font_default, + SendMessage(sub, CB_GETCURSEL, 0, 0) + 1); break; - } break; @@ -412,46 +416,47 @@ static BOOL CALLBACK options_connections_dialog_handler(HWND hwnd, SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Simple"); SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Basic Auth"); SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"NTLM Auth"); - if (option_http_proxy) + if (nsoption_bool(http_proxy)) { SendMessage(sub, CB_SETCURSEL, (WPARAM) - (option_http_proxy_auth + 1), 0); - else + (nsoption_int(http_proxy_auth) + 1), 0); + } else { SendMessage(sub, CB_SETCURSEL, 0, 0); + } sub = GetDlgItem(hwnd, IDC_PREFS_PROXYHOST); - if ((option_http_proxy_host != NULL) && - (option_http_proxy_host[0] != '\0')) + if ((nsoption_charp(http_proxy_host) != NULL) && + (nsoption_charp(http_proxy_host)[0] != '\0')) SendMessage(sub, WM_SETTEXT, 0, - (LPARAM)option_http_proxy_host); + (LPARAM)nsoption_charp(http_proxy_host)); sub = GetDlgItem(hwnd, IDC_PREFS_PROXYPORT); - if (option_http_proxy_port != 0) { - snprintf(number, 6, "%d", option_http_proxy_port); + if (nsoption_int(http_proxy_port) != 0) { + snprintf(number, 6, "%d", nsoption_int(http_proxy_port)); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); } sub = GetDlgItem(hwnd, IDC_PREFS_PROXYNAME); - if ((option_http_proxy_auth_user != NULL) && - (option_http_proxy_auth_user[0] != '\0')) + if ((nsoption_charp(http_proxy_auth_user) != NULL) && + (nsoption_charp(http_proxy_auth_user)[0] != '\0')) SendMessage(sub, WM_SETTEXT, 0, - (LPARAM)option_http_proxy_auth_user); + (LPARAM)nsoption_charp(http_proxy_auth_user)); sub = GetDlgItem(hwnd, IDC_PREFS_PROXYPASS); - if ((option_http_proxy_auth_pass != NULL) && - (option_http_proxy_auth_pass[0] != '\0')) + if ((nsoption_charp(http_proxy_auth_pass) != NULL) && + (nsoption_charp(http_proxy_auth_pass)[0] != '\0')) SendMessage(sub, WM_SETTEXT, 0, - (LPARAM)option_http_proxy_auth_pass); + (LPARAM)nsoption_charp(http_proxy_auth_pass)); sub = GetDlgItem(hwnd, IDC_PREFS_FETCHERS); - snprintf(number, 6, "%d", option_max_fetchers); + snprintf(number, 6, "%d", nsoption_int(max_fetchers)); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HOST); - snprintf(number, 6, "%d", option_max_fetchers_per_host); + snprintf(number, 6, "%d", nsoption_int(max_fetchers_per_host)); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HANDLES); - snprintf(number, 6, "%d", option_max_cached_fetch_handles); + snprintf(number, 6, "%d", nsoption_int(max_cached_fetch_handles)); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); break; @@ -463,11 +468,9 @@ static BOOL CALLBACK options_connections_dialog_handler(HWND hwnd, len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0); temp = malloc(len + 1); if (temp != NULL) { - if (option_http_proxy_host != NULL) - free(option_http_proxy_host); SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM)temp); - option_http_proxy_host = strdup(temp); + nsoption_set_charp(http_proxy_host, strdup(temp)); free(temp); } @@ -477,7 +480,7 @@ static BOOL CALLBACK options_connections_dialog_handler(HWND hwnd, if (temp != NULL) { SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM)temp); - option_http_proxy_port = atoi(temp); + nsoption_set_int(http_proxy_port, atoi(temp)); free(temp); } @@ -485,11 +488,9 @@ static BOOL CALLBACK options_connections_dialog_handler(HWND hwnd, len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0); temp = malloc(len + 1); if (temp != NULL) { - if (option_http_proxy_auth_user != NULL) - free(option_http_proxy_auth_user); SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM)temp); - option_http_proxy_auth_user = strdup(temp); + nsoption_set_charp(http_proxy_auth_user, strdup(temp)); free(temp); } @@ -497,11 +498,9 @@ static BOOL CALLBACK options_connections_dialog_handler(HWND hwnd, len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0); temp = malloc(len + 1); if (temp != NULL) { - if (option_http_proxy_auth_pass != NULL) - free(option_http_proxy_auth_pass); SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM)temp); - option_http_proxy_auth_pass = strdup(temp); + nsoption_set_charp(http_proxy_auth_pass, strdup(temp)); free(temp); } @@ -512,7 +511,7 @@ static BOOL CALLBACK options_connections_dialog_handler(HWND hwnd, if (temp != NULL) { SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM)temp); - option_max_fetchers = atoi(temp); + nsoption_set_int(max_fetchers, atoi(temp)); free(temp); } @@ -522,7 +521,7 @@ static BOOL CALLBACK options_connections_dialog_handler(HWND hwnd, if (temp != NULL) { SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM)temp); - option_max_fetchers_per_host = atoi(temp); + nsoption_set_int(max_fetchers_per_host, atoi(temp)); free(temp); } @@ -532,7 +531,7 @@ static BOOL CALLBACK options_connections_dialog_handler(HWND hwnd, if (temp != NULL) { SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM)temp); - option_max_cached_fetch_handles = atoi(temp); + nsoption_set_int(max_cached_fetch_handles, atoi(temp)); free(temp); } break; @@ -571,24 +570,24 @@ static BOOL CALLBACK options_general_dialog_handler(HWND hwnd, case WM_INITDIALOG: /* homepage url */ sub = GetDlgItem(hwnd, IDC_PREFS_HOMEPAGE); - SendMessage(sub, WM_SETTEXT, 0, (LPARAM)option_homepage_url); + SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(homepage_url)); /* Display images */ sub = GetDlgItem(hwnd, IDC_PREFS_IMAGES); SendMessage(sub, BM_SETCHECK, - (WPARAM) ((option_suppress_images) ? + (WPARAM) ((nsoption_bool(suppress_images)) ? BST_CHECKED : BST_UNCHECKED), 0); /* advert blocking */ sub = GetDlgItem(hwnd, IDC_PREFS_ADVERTS); SendMessage(sub, BM_SETCHECK, - (WPARAM) ((option_block_ads) ? + (WPARAM) ((nsoption_bool(block_ads)) ? BST_CHECKED : BST_UNCHECKED), 0); /* Referrer sending */ sub = GetDlgItem(hwnd, IDC_PREFS_REFERER); SendMessage(sub, BM_SETCHECK, - (WPARAM)((option_send_referer) ? + (WPARAM)((nsoption_bool(send_referer)) ? BST_CHECKED : BST_UNCHECKED), 0); break; @@ -607,19 +606,18 @@ static BOOL CALLBACK options_general_dialog_handler(HWND hwnd, SendMessage(sub, WM_GETTEXT, (WPARAM)text_length + 1, (LPARAM)text); - free(option_homepage_url); - option_homepage_url = text; + nsoption_set_charp(homepage_url, text); } } - option_suppress_images = (IsDlgButtonChecked(hwnd, - IDC_PREFS_IMAGES) == BST_CHECKED) ? true : false; + nsoption_set_bool(suppress_images, + (IsDlgButtonChecked(hwnd, IDC_PREFS_IMAGES) == BST_CHECKED) ? true : false); - option_block_ads = (IsDlgButtonChecked(hwnd, - IDC_PREFS_ADVERTS) == BST_CHECKED) ? true : false; + nsoption_set_bool(block_ads, (IsDlgButtonChecked(hwnd, + IDC_PREFS_ADVERTS) == BST_CHECKED) ? true : false); - option_send_referer = (IsDlgButtonChecked(hwnd, - IDC_PREFS_REFERER) == BST_CHECKED) ? true : false; + nsoption_set_bool(send_referer, (IsDlgButtonChecked(hwnd, + IDC_PREFS_REFERER) == BST_CHECKED) ? true : false); break; @@ -675,7 +673,7 @@ void nsws_prefs_dialog_init(HINSTANCE hinst, HWND parent) win_perror("PropertySheet"); } else if (ret > 0) { /* user saved changes */ - options_write(options_file_location); + nsoption_write(options_file_location); } } diff --git a/windows/system_colour.c b/windows/system_colour.c index b58717492..ec40947c0 100644 --- a/windows/system_colour.c +++ b/windows/system_colour.c @@ -39,170 +39,170 @@ static struct gui_system_colour_ctx colour_list[] = { "ActiveBorder", SLEN("ActiveBorder"), 0xff000000, - &option_sys_colour_ActiveBorder, + &nsoption_charp(sys_colour_ActiveBorder), NULL }, { "ActiveCaption", SLEN("ActiveCaption"), 0xffdddddd, - &option_sys_colour_ActiveCaption, + &nsoption_charp(sys_colour_ActiveCaption), NULL }, { "AppWorkspace", SLEN("AppWorkspace"), 0xffeeeeee, - &option_sys_colour_AppWorkspace, + &nsoption_charp(sys_colour_AppWorkspace), NULL }, { "Background", SLEN("Background"), 0xff0000aa, - &option_sys_colour_Background, + &nsoption_charp(sys_colour_Background), NULL }, { "ButtonFace", SLEN("ButtonFace"), 0xffaaaaaa, - &option_sys_colour_ButtonFace, + &nsoption_charp(sys_colour_ButtonFace), NULL }, { "ButtonHighlight", SLEN("ButtonHighlight"), 0xffdddddd, - &option_sys_colour_ButtonHighlight, + &nsoption_charp(sys_colour_ButtonHighlight), NULL }, { "ButtonShadow", SLEN("ButtonShadow"), 0xffbbbbbb, - &option_sys_colour_ButtonShadow, + &nsoption_charp(sys_colour_ButtonShadow), NULL }, { "ButtonText", SLEN("ButtonText"), 0xff000000, - &option_sys_colour_ButtonText, + &nsoption_charp(sys_colour_ButtonText), NULL }, { "CaptionText", SLEN("CaptionText"), 0xff000000, - &option_sys_colour_CaptionText, + &nsoption_charp(sys_colour_CaptionText), NULL }, { "GrayText", SLEN("GrayText"), 0xffcccccc, - &option_sys_colour_GrayText, + &nsoption_charp(sys_colour_GrayText), NULL }, { "Highlight", SLEN("Highlight"), 0xff0000ee, - &option_sys_colour_Highlight, + &nsoption_charp(sys_colour_Highlight), NULL }, { "HighlightText", SLEN("HighlightText"), 0xff000000, - &option_sys_colour_HighlightText, + &nsoption_charp(sys_colour_HighlightText), NULL }, { "InactiveBorder", SLEN("InactiveBorder"), 0xffffffff, - &option_sys_colour_InactiveBorder, + &nsoption_charp(sys_colour_InactiveBorder), NULL }, { "InactiveCaption", SLEN("InactiveCaption"), 0xffffffff, - &option_sys_colour_InactiveCaption, + &nsoption_charp(sys_colour_InactiveCaption), NULL }, { "InactiveCaptionText", SLEN("InactiveCaptionText"), 0xffcccccc, - &option_sys_colour_InactiveCaptionText, + &nsoption_charp(sys_colour_InactiveCaptionText), NULL }, { "InfoBackground", SLEN("InfoBackground"), 0xffaaaaaa, - &option_sys_colour_InfoBackground, + &nsoption_charp(sys_colour_InfoBackground), NULL }, { "InfoText", SLEN("InfoText"), 0xff000000, - &option_sys_colour_InfoText, + &nsoption_charp(sys_colour_InfoText), NULL }, { "Menu", SLEN("Menu"), 0xffaaaaaa, - &option_sys_colour_Menu, + &nsoption_charp(sys_colour_Menu), NULL }, { "MenuText", SLEN("MenuText"), 0xff000000, - &option_sys_colour_MenuText, + &nsoption_charp(sys_colour_MenuText), NULL }, { "Scrollbar", SLEN("Scrollbar"), 0xffaaaaaa, - &option_sys_colour_Scrollbar, + &nsoption_charp(sys_colour_Scrollbar), NULL }, { "ThreeDDarkShadow", SLEN("ThreeDDarkShadow"), 0xff555555, - &option_sys_colour_ThreeDDarkShadow, + &nsoption_charp(sys_colour_ThreeDDarkShadow), NULL }, { "ThreeDFace", SLEN("ThreeDFace"), 0xffdddddd, - &option_sys_colour_ThreeDFace, + &nsoption_charp(sys_colour_ThreeDFace), NULL }, { "ThreeDHighlight", SLEN("ThreeDHighlight"), 0xffaaaaaa, - &option_sys_colour_ThreeDHighlight, + &nsoption_charp(sys_colour_ThreeDHighlight), NULL }, { "ThreeDLightShadow", SLEN("ThreeDLightShadow"), 0xff999999, - &option_sys_colour_ThreeDLightShadow, + &nsoption_charp(sys_colour_ThreeDLightShadow), NULL }, { "ThreeDShadow", SLEN("ThreeDShadow"), 0xff777777, - &option_sys_colour_ThreeDShadow, + &nsoption_charp(sys_colour_ThreeDShadow), NULL }, { "Window", SLEN("Window"), 0xffaaaaaa, - &option_sys_colour_Window, + &nsoption_charp(sys_colour_Window), NULL }, { "WindowFrame", SLEN("WindowFrame"), 0xff000000, - &option_sys_colour_WindowFrame, + &nsoption_charp(sys_colour_WindowFrame), NULL }, { "WindowText", SLEN("WindowText"), 0xff000000, - &option_sys_colour_WindowText, + &nsoption_charp(sys_colour_WindowText), NULL },