diff options
Diffstat (limited to 'framebuffer')
-rw-r--r-- | framebuffer/Makefile.target | 2 | ||||
-rw-r--r-- | framebuffer/gui.c | 124 | ||||
-rw-r--r-- | framebuffer/options.h | 2 | ||||
-rw-r--r-- | framebuffer/system_colour.c | 282 |
4 files changed, 85 insertions, 325 deletions
diff --git a/framebuffer/Makefile.target b/framebuffer/Makefile.target index 144171024..bad31ed9d 100644 --- a/framebuffer/Makefile.target +++ b/framebuffer/Makefile.target @@ -138,7 +138,7 @@ $(eval $(foreach V,$(filter FB_IMAGE_%,$(.VARIABLES)),$(call convert_image,$($(V # S_FRAMEBUFFER are sources purely for the framebuffer build S_FRAMEBUFFER := gui.c framebuffer.c tree.c schedule.c \ thumbnail.c misc.c bitmap.c filetype.c login.c findfile.c \ - localhistory.c system_colour.c clipboard.c + localhistory.c clipboard.c S_FRAMEBUFFER_FBTK := fbtk.c event.c fill.c bitmap.c user.c window.c \ text.c scroll.c osk.c diff --git a/framebuffer/gui.c b/framebuffer/gui.c index 80322ecc9..024ab283f 100644 --- a/framebuffer/gui.c +++ b/framebuffer/gui.c @@ -476,46 +476,58 @@ process_cmdline(int argc, char** argv) return true; } -/* Documented in utils/nsoption.h */ -void gui_options_init_defaults(void) +/** + * Set option defaults for framebuffer 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("~/.netsurf/Cookies")); nsoption_setnull_charp(cookie_jar, strdup("~/.netsurf/Cookies")); if (nsoption_charp(cookie_file) == NULL || - nsoption_charp(cookie_jar == NULL)) { - die("Failed initialising cookie options"); + nsoption_charp(cookie_jar) == NULL) { + LOG(("Failed initialising cookie options")); + return NSERROR_BAD_PARAMETER; } -} - -static void -gui_init(int argc, char** argv) -{ - nsfb_t *nsfb; - - /* Override, since we have no support for non-core SELECT menu */ - nsoption_set_bool(core_select_menu, true); - - if (process_cmdline(argc,argv) != true) - die("unable to process command line.\n"); - - nsfb = framebuffer_initialise(fename, fewidth, feheight, febpp); - if (nsfb == NULL) - die("Unable to initialise framebuffer"); - - framebuffer_set_cursor(&pointer_image); - if (fb_font_init() == false) - die("Unable to initialise the font system"); + /* set system colours for framebuffer ui */ + nsoption_set_colour(sys_colour_ActiveBorder, 0x00000000); + nsoption_set_colour(sys_colour_ActiveCaption, 0x00ddddcc); + nsoption_set_colour(sys_colour_AppWorkspace, 0x00eeeeee); + nsoption_set_colour(sys_colour_Background, 0x00aa0000); + nsoption_set_colour(sys_colour_ButtonFace, 0x00dddddd); + nsoption_set_colour(sys_colour_ButtonHighlight, 0x00cccccc); + nsoption_set_colour(sys_colour_ButtonShadow, 0x00bbbbbb); + nsoption_set_colour(sys_colour_ButtonText, 0x00000000); + nsoption_set_colour(sys_colour_CaptionText, 0x00000000); + nsoption_set_colour(sys_colour_GrayText, 0x00777777); + nsoption_set_colour(sys_colour_Highlight, 0x00ee0000); + nsoption_set_colour(sys_colour_HighlightText, 0x00000000); + nsoption_set_colour(sys_colour_InactiveBorder, 0x00000000); + nsoption_set_colour(sys_colour_InactiveCaption, 0x00ffffff); + nsoption_set_colour(sys_colour_InactiveCaptionText, 0x00cccccc); + nsoption_set_colour(sys_colour_InfoBackground, 0x00aaaaaa); + nsoption_set_colour(sys_colour_InfoText, 0x00000000); + nsoption_set_colour(sys_colour_Menu, 0x00aaaaaa); + nsoption_set_colour(sys_colour_MenuText, 0x00000000); + nsoption_set_colour(sys_colour_Scrollbar, 0x00aaaaaa); + nsoption_set_colour(sys_colour_ThreeDDarkShadow, 0x00555555); + nsoption_set_colour(sys_colour_ThreeDFace, 0x00dddddd); + nsoption_set_colour(sys_colour_ThreeDHighlight, 0x00aaaaaa); + nsoption_set_colour(sys_colour_ThreeDLightShadow, 0x00999999); + nsoption_set_colour(sys_colour_ThreeDShadow, 0x00777777); + nsoption_set_colour(sys_colour_Window, 0x00aaaaaa); + nsoption_set_colour(sys_colour_WindowFrame, 0x00000000); + nsoption_set_colour(sys_colour_WindowText, 0x00000000); - fbtk = fbtk_init(nsfb); - - fbtk_enable_oskb(fbtk); - - urldb_load_cookies(nsoption_charp(cookie_file)); + return NSERROR_OK; } + /** * Ensures output logging stream is correctly configured */ @@ -540,32 +552,62 @@ main(int argc, char** argv) char *options; char *messages; nsurl *url; - nserror error; + nserror ret; + nsfb_t *nsfb; respaths = fb_init_resource(NETSURF_FB_RESPATH":"NETSURF_FB_FONTPATH); - options = filepath_find(respaths, "Choices"); - messages = filepath_find(respaths, "messages"); - /* initialise logging. Not fatal if it fails but not much we * can do about it either. */ nslog_init(nslog_stream_configure, &argc, argv); - netsurf_init(&argc, &argv, options, messages); + /* user options setup */ + ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default); + if (ret != NSERROR_OK) { + die("Options failed to initialise"); + } + options = filepath_find(respaths, "Choices"); + nsoption_read(options, NULL); + free(options); + nsoption_commandline(&argc, argv, NULL); + /* common initialisation */ + messages = filepath_find(respaths, "Messages"); + ret = netsurf_init(messages); free(messages); - free(options); + if (ret != NSERROR_OK) { + die("NetSurf failed to initialise"); + } + + /* Override, since we have no support for non-core SELECT menu */ + nsoption_set_bool(core_select_menu, true); + + if (process_cmdline(argc,argv) != true) + die("unable to process command line.\n"); + + nsfb = framebuffer_initialise(fename, fewidth, feheight, febpp); + if (nsfb == NULL) + die("Unable to initialise framebuffer"); + + framebuffer_set_cursor(&pointer_image); - gui_init(argc, argv); + if (fb_font_init() == false) + die("Unable to initialise the font system"); + + fbtk = fbtk_init(nsfb); + + fbtk_enable_oskb(fbtk); + + urldb_load_cookies(nsoption_charp(cookie_file)); /* create an initial browser window */ LOG(("calling browser_window_create")); - error = nsurl_create(feurl, &url); - if (error == NSERROR_OK) { - error = browser_window_create(BROWSER_WINDOW_VERIFIABLE | + ret = nsurl_create(feurl, &url); + if (ret == NSERROR_OK) { + ret = browser_window_create(BROWSER_WINDOW_VERIFIABLE | BROWSER_WINDOW_HISTORY, url, NULL, @@ -573,8 +615,8 @@ main(int argc, char** argv) &bw); nsurl_unref(url); } - if (error != NSERROR_OK) { - warn_user(messages_get_errorcode(error), 0); + if (ret != NSERROR_OK) { + warn_user(messages_get_errorcode(ret), 0); } else { netsurf_main_loop(); diff --git a/framebuffer/options.h b/framebuffer/options.h index 5cb5bfb1a..eee6f4bc6 100644 --- a/framebuffer/options.h +++ b/framebuffer/options.h @@ -57,7 +57,7 @@ NSOPTION_STRING(fb_face_sans_serif_bold, NULL) NSOPTION_STRING(fb_face_sans_serif_italic, NULL) NSOPTION_STRING(fb_face_sans_serif_italic_bold, NULL) NSOPTION_STRING(fb_face_serif, NULL) -NSOPTION_STRING(fb_serif_bold, NULL) +NSOPTION_STRING(fb_face_serif_bold, NULL) NSOPTION_STRING(fb_face_monospace, NULL) NSOPTION_STRING(fb_face_monospace_bold, NULL) NSOPTION_STRING(fb_face_cursive, NULL) diff --git a/framebuffer/system_colour.c b/framebuffer/system_colour.c deleted file mode 100644 index 139cd4780..000000000 --- a/framebuffer/system_colour.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright 2011 Vincent Sanders <vince@netsurf-browser.org> - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/** \file - * System colour handling - * - */ - -#include "utils/utils.h" -#include "utils/log.h" -#include "desktop/gui.h" -#include "utils/nsoption.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"), - 0xffddddcc, - &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"), - 0xffdddddd, - &nsoption_colour(sys_colour_ButtonFace), - NULL - }, { - "ButtonHighlight", - SLEN("ButtonHighlight"), - 0xffcccccc, - &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"), - 0xff777777, - &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"), - 0xff000000, - &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; -} |