diff options
Diffstat (limited to 'framebuffer/gui.c')
-rw-r--r-- | framebuffer/gui.c | 124 |
1 files changed, 83 insertions, 41 deletions
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(); |