From 429a30caa73d80a363a47f307c8688c073d15145 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 27 May 2013 15:02:04 +0100 Subject: move atari to new options code --- atari/Makefile.target | 1 - atari/gui.c | 73 ++++++++----- atari/system_colour.c | 288 -------------------------------------------------- 3 files changed, 45 insertions(+), 317 deletions(-) delete mode 100644 atari/system_colour.c (limited to 'atari') diff --git a/atari/Makefile.target b/atari/Makefile.target index 95d675fc4..bff4f07e1 100644 --- a/atari/Makefile.target +++ b/atari/Makefile.target @@ -96,7 +96,6 @@ S_ATARI := \ toolbar.c \ statusbar.c \ osspec.c \ - system_colour.c \ ctxmenu.c \ settings.c \ deskmenu.c \ diff --git a/atari/gui.c b/atari/gui.c index 97d63ce3c..6b542742e 100644 --- a/atari/gui.c +++ b/atari/gui.c @@ -922,16 +922,21 @@ nsurl *gui_get_resource_url(const char *path) return url; } -/* Documented in utils/nsoption.h */ -void gui_options_init_defaults(void) +/** + * Set option defaults for atari frontend + * + * @param defaults The option table to update. + * @return error status. + */ +static nserror set_defaults(struct nsoption_s *defaults) { /* Set defaults for absent option strings */ nsoption_setnull_charp(cookie_file, strdup("cookies")); if (nsoption_charp(cookie_file) == NULL) { - die("Failed initialising string options"); + LOG(("Failed initialising string options")); + return NSERROR_BAD_PARAMETER; } - - nsoption_set_int(min_reflow_period, 350); + return NSERROR_OK; } static void gui_init(int argc, char** argv) @@ -1031,11 +1036,11 @@ static void gui_init2(int argc, char** argv) int main(int argc, char** argv) { char messages[PATH_MAX]; - const char *addr; - char * file_url = NULL; - struct stat stat_buf; - nsurl *url; - nserror error; + const char *addr; + char * file_url = NULL; + struct stat stat_buf; + nsurl *url; + nserror ret; /* @todo logging file descriptor update belongs in a nslog_init callback */ setbuf(stderr, NULL); @@ -1059,8 +1064,20 @@ int main(int argc, char** argv) */ nslog_init(NULL, &argc, argv); + /* user options setup */ + ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default); + if (ret != NSERROR_OK) { + die("Options failed to initialise"); + } + nsoption_read(options, NULL); + nsoption_commandline(&argc, argv, NULL); + + /* common initialisation */ LOG(("Initialising core...")); - netsurf_init(&argc, &argv, options, messages); + ret = netsurf_init(messages); + if (ret != NSERROR_OK) { + die("NetSurf failed to initialise"); + } LOG(("Initializing GUI...")); gui_init(argc, argv); @@ -1079,23 +1096,23 @@ int main(int argc, char** argv) } } - /* create an initial browser window */ - error = nsurl_create(addr, &url); - if (error == NSERROR_OK) { - error = browser_window_create(BROWSER_WINDOW_VERIFIABLE | - BROWSER_WINDOW_HISTORY, - url, - NULL, - NULL, - NULL); - nsurl_unref(url); - } - if (error != NSERROR_OK) { - warn_user(messages_get_errorcode(error), 0); - } else { - LOG(("Entering NetSurf mainloop...")); - netsurf_main_loop(); - } + /* create an initial browser window */ + ret = nsurl_create(addr, &url); + if (ret == NSERROR_OK) { + ret = browser_window_create(BROWSER_WINDOW_VERIFIABLE | + BROWSER_WINDOW_HISTORY, + url, + NULL, + NULL, + NULL); + nsurl_unref(url); + } + if (ret != NSERROR_OK) { + warn_user(messages_get_errorcode(ret), 0); + } else { + LOG(("Entering NetSurf mainloop...")); + netsurf_main_loop(); + } netsurf_exit(); diff --git a/atari/system_colour.c b/atari/system_colour.c deleted file mode 100644 index efcd7b6ac..000000000 --- a/atari/system_colour.c +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright 2011 Vincent Sanders - * - * 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 - * System colour handling - * - */ - -#define WITH_SYSTEM_COLOUR -#ifdef WITH_SYSTEM_COLOUR -#include -#include -#include "utils/utils.h" -#include "utils/log.h" -#include "desktop/gui.h" -#include "utils/nsoption.h" -#include "desktop/plot_style.h" - -struct gui_system_colour_ctx { - const char *name; - int length; - css_color colour; - colour *option_colour; - lwc_string *lwcstr; -}; - -static struct gui_system_colour_ctx colour_list[] = { - { - "ActiveBorder", - SLEN("ActiveBorder"), - 0xff000000, - &nsoption_colour(sys_colour_ActiveBorder), - NULL - }, { - "ActiveCaption", - SLEN("ActiveCaption"), - 0xffdddddd, - &nsoption_colour(sys_colour_ActiveCaption), - NULL - }, { - "AppWorkspace", - SLEN("AppWorkspace"), - 0xffeeeeee, - &nsoption_colour(sys_colour_AppWorkspace), - NULL - }, { - "Background", - SLEN("Background"), - 0xff0000aa, - &nsoption_colour(sys_colour_Background), - NULL - }, { - "ButtonFace", - SLEN("ButtonFace"), - 0xffaaaaaa, - &nsoption_colour(sys_colour_ButtonFace), - NULL - }, { - "ButtonHighlight", - SLEN("ButtonHighlight"), - 0xffdddddd, - &nsoption_colour(sys_colour_ButtonHighlight), - NULL - }, { - "ButtonShadow", - SLEN("ButtonShadow"), - 0xffbbbbbb, - &nsoption_colour(sys_colour_ButtonShadow), - NULL - }, { - "ButtonText", - SLEN("ButtonText"), - 0xff000000, - &nsoption_colour(sys_colour_ButtonText), - NULL - }, { - "CaptionText", - SLEN("CaptionText"), - 0xff000000, - &nsoption_colour(sys_colour_CaptionText), - NULL - }, { - "GrayText", - SLEN("GrayText"), - 0xffcccccc, - &nsoption_colour(sys_colour_GrayText), - NULL - }, { - "Highlight", - SLEN("Highlight"), - 0xff0000ee, - &nsoption_colour(sys_colour_Highlight), - NULL - }, { - "HighlightText", - SLEN("HighlightText"), - 0xff000000, - &nsoption_colour(sys_colour_HighlightText), - NULL - }, { - "InactiveBorder", - SLEN("InactiveBorder"), - 0xffffffff, - &nsoption_colour(sys_colour_InactiveBorder), - NULL - }, { - "InactiveCaption", - SLEN("InactiveCaption"), - 0xffffffff, - &nsoption_colour(sys_colour_InactiveCaption), - NULL - }, { - "InactiveCaptionText", - SLEN("InactiveCaptionText"), - 0xffcccccc, - &nsoption_colour(sys_colour_InactiveCaptionText), - NULL - }, { - "InfoBackground", - SLEN("InfoBackground"), - 0xffaaaaaa, - &nsoption_colour(sys_colour_InfoBackground), - NULL - }, { - "InfoText", - SLEN("InfoText"), - 0xff000000, - &nsoption_colour(sys_colour_InfoText), - NULL - }, { - "Menu", - SLEN("Menu"), - 0xffaaaaaa, - &nsoption_colour(sys_colour_Menu), - NULL - }, { - "MenuText", - SLEN("MenuText"), - 0xff000000, - &nsoption_colour(sys_colour_MenuText), - NULL - }, { - "Scrollbar", - SLEN("Scrollbar"), - 0xffaaaaaa, - &nsoption_colour(sys_colour_Scrollbar), - NULL - }, { - "ThreeDDarkShadow", - SLEN("ThreeDDarkShadow"), - 0xff555555, - &nsoption_colour(sys_colour_ThreeDDarkShadow), - NULL - }, { - "ThreeDFace", - SLEN("ThreeDFace"), - 0xffdddddd, - &nsoption_colour(sys_colour_ThreeDFace), - 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 - }, - -}; - -#define colour_list_len (sizeof(colour_list) / sizeof(struct gui_system_colour_ctx)) - -static struct gui_system_colour_ctx *gui_system_colour_pw = NULL; - - -bool gui_system_colour_init(void) -{ - unsigned int ccount; - - if (gui_system_colour_pw != NULL) - return false; - - /* Intern colour strings */ - for (ccount = 0; ccount < colour_list_len; ccount++) { - if (lwc_intern_string(colour_list[ccount].name, - colour_list[ccount].length, - &(colour_list[ccount].lwcstr)) != lwc_error_ok) { - return false; - } - } - - /* pull in options if set (ie not transparent) */ - for (ccount = 0; ccount < colour_list_len; ccount++) { - if (*(colour_list[ccount].option_colour) != 0) { - colour_list[ccount].colour = *(colour_list[ccount].option_colour); - } - } - - gui_system_colour_pw = colour_list; - - return true; -} - -void gui_system_colour_finalize(void) -{ - unsigned int ccount; - - for (ccount = 0; ccount < colour_list_len; ccount++) { - lwc_string_unref(colour_list[ccount].lwcstr); - } -} - -colour gui_system_colour_char(const char *name) -{ - colour ret = 0xff00000; - unsigned int ccount; - - for (ccount = 0; ccount < colour_list_len; ccount++) { - if (strcmp(name, colour_list[ccount].name) == 0) { - ret = colour_list[ccount].colour; - break; - } - } - return ret; -} - -css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour) -{ - unsigned int ccount; - bool match; - - for (ccount = 0; ccount < colour_list_len; ccount++) { - if (lwc_string_caseless_isequal(name, - colour_list[ccount].lwcstr, - &match) == lwc_error_ok && match) { - *colour = colour_list[ccount].colour; - return CSS_OK; - } - } - - return CSS_INVALID; -} -#endif -- cgit v1.2.3