static void gui_init(int argc, char** argv) { const char *addr; nsurl *url; nserror error; char buf[PATH_MAX]; if (pipe(sEventPipe) < 0) return; if (!replicated) { sBAppThreadID = spawn_thread(bapp_thread, "BApplication(NetSurf)", B_NORMAL_PRIORITY, (void *)find_thread(NULL)); if (sBAppThreadID < B_OK) return; /* #### handle errors */ if (resume_thread(sBAppThreadID) < B_OK) return; } nsbeos_update_system_ui_colors(); fetch_rsrc_register(); check_homedir(); // make sure the cache dir exists create_directory(TEMP_FILENAME_PREFIX, 0700); //nsbeos_completion_init(); /* This is an ugly hack to just get the new-style throbber going. * It, along with the PNG throbber loader, need making more generic. */ { #define STROF(n) #n #define FIND_THROB(n) filenames[(n)] = \ "throbber/throbber" STROF(n) ".png"; char *filenames[9]; FIND_THROB(0); FIND_THROB(1); FIND_THROB(2); FIND_THROB(3); FIND_THROB(4); FIND_THROB(5); FIND_THROB(6); FIND_THROB(7); FIND_THROB(8); nsbeos_throbber_initialise_from_png(9, filenames[0], filenames[1], filenames[2], filenames[3], filenames[4], filenames[5], filenames[6], filenames[7], filenames[8]); #undef FIND_THROB #undef STROF } if (nsbeos_throbber == NULL) die("Unable to load throbber image.\n"); find_resource(buf, "Choices", "%/Choices"); LOG(("Using '%s' as Preferences file", buf)); options_file_location = strdup(buf); nsoption_read(buf, NULL); /* check what the font settings are, setting them to a default font * if they're not set - stops Pango whinging */ #define SETFONTDEFAULT(OPTION,y) if (nsoption_charp(OPTION) == NULL) nsoption_set_charp(OPTION, 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(font_sans, family); SETFONTDEFAULT(font_serif, family); SETFONTDEFAULT(font_mono, family); SETFONTDEFAULT(font_cursive, family); SETFONTDEFAULT(font_fantasy, family); */ #ifdef __HAIKU__ SETFONTDEFAULT(font_sans, "DejaVu Sans"); SETFONTDEFAULT(font_serif, "DejaVu Serif"); SETFONTDEFAULT(font_mono, "DejaVu Mono"); SETFONTDEFAULT(font_cursive, "DejaVu Sans"); SETFONTDEFAULT(font_fantasy, "DejaVu Sans"); #else SETFONTDEFAULT(font_sans, "Bitstream Vera Sans"); SETFONTDEFAULT(font_serif, "Bitstream Vera Serif"); SETFONTDEFAULT(font_mono, "Bitstream Vera Sans Mono"); SETFONTDEFAULT(font_cursive, "Bitstream Vera Serif"); SETFONTDEFAULT(font_fantasy, "Bitstream Vera Serif"); #endif nsbeos_options_init(); if (nsoption_charp(cookie_file) == NULL) { find_resource(buf, "Cookies", "%/Cookies"); LOG(("Using '%s' as Cookies file", buf)); nsoption_set_charp(cookie_file, strdup(buf)); } if (nsoption_charp(cookie_jar) == NULL) { find_resource(buf, "Cookies", "%/Cookies"); LOG(("Using '%s' as Cookie Jar file", buf)); nsoption_set_charp(cookie_jar, strdup(buf)); } if ((nsoption_charp(cookie_file) == NULL) || (nsoption_charp(cookie_jar) == NULL)) die("Failed initialising cookie options"); if (nsoption_charp(url_file) == NULL) { find_resource(buf, "URLs", "%/URLs"); LOG(("Using '%s' as URL file", buf)); nsoption_set_charp(url_file, strdup(buf)); } if (nsoption_charp(ca_path) == NULL) { find_resource(buf, "certs", "/etc/ssl/certs"); LOG(("Using '%s' as certificate path", buf)); nsoption_set_charp(ca_path, strdup(buf)); } //find_resource(buf, "mime.types", "/etc/mime.types"); beos_fetch_filetype_init(); urldb_load(nsoption_charp(url_file)); urldb_load_cookies(nsoption_charp(cookie_file)); //nsbeos_download_initialise(); if (!replicated) be_app->Unlock(); if (argc > 1) { addr = argv[1]; } else if (nsoption_charp(homepage_url) != NULL) { addr = nsoption_charp(homepage_url); } else { addr = NETSURF_HOMEPAGE; } /* create an initial browser window */ error = nsurl_create(addr, &url); if (error == NSERROR_OK) { error = browser_window_create( BW_CREATE_HISTORY, url, NULL, NULL, NULL); nsurl_unref(url); } if (error != NSERROR_OK) { warn_user(messages_get_errorcode(error), 0); } if (gFirstRefsReceived) { // resend the refs we got before having a window to send them to be_app_messenger.SendMessage(gFirstRefsReceived); delete gFirstRefsReceived; gFirstRefsReceived = NULL; } }
static void check_options(char **respath) { char *hdir = getenv("HOME"); char buf[PATH_MAX]; 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 * status bar width option by using it for an absolute value in px. * 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 (nsoption_int(toolbar_status_width) < 1500) { nsoption_set_int(toolbar_status_width, 6667); } /* user options should be stored in the users home directory */ snprintf(buf, PATH_MAX, "%s/.netsurf/Choices", hdir); options_file_location = strdup(buf); /* VRS - I do not beleive these setting should search the * resource path, they should just be set to the default * values! */ if (nsoption_charp(cookie_file) == NULL) { filepath_sfinddef(respath, buf, "Cookies", "~/.netsurf/"); LOG(("Using '%s' as Cookies file", buf)); nsoption_set_charp(cookie_file, strdup(buf)); } if (nsoption_charp(cookie_jar) == NULL) { filepath_sfinddef(respath, buf, "Cookies", "~/.netsurf/"); LOG(("Using '%s' as Cookie Jar file", buf)); nsoption_set_charp(cookie_jar, strdup(buf)); } if (nsoption_charp(cookie_file) == NULL || nsoption_charp(cookie_jar) == NULL) die("Failed initialising cookie options"); if (nsoption_charp(url_file) == NULL) { filepath_sfinddef(respath, buf, "URLs", "~/.netsurf/"); LOG(("Using '%s' as URL file", buf)); nsoption_set_charp(url_file, strdup(buf)); } if (nsoption_charp(ca_path) == NULL) { filepath_sfinddef(respath, buf, "certs", "/etc/ssl/"); LOG(("Using '%s' as certificate path", buf)); nsoption_set_charp(ca_path, strdup(buf)); } if (nsoption_charp(downloads_directory) == NULL) { LOG(("Using '%s' as download directory", hdir)); nsoption_set_charp(downloads_directory, strdup(hdir)); } filepath_sfinddef(respath, buf, "icons/", "~/.netsurf/"); LOG(("Using '%s' as Tree icons dir", buf)); tree_set_icon_dir(strdup(buf)); if (nsoption_charp(hotlist_path) == NULL) { filepath_sfinddef(respath, buf, "Hotlist", "~/.netsurf/"); LOG(("Using '%s' as Hotlist file", buf)); nsoption_set_charp(hotlist_path, strdup(buf)); } if (nsoption_charp(hotlist_path) == NULL) die("Failed initialising hotlist option"); filepath_sfinddef(respath, buf, "Print", "~/.netsurf/"); LOG(("Using '%s' as Print Settings file", buf)); print_options_file_location = strdup(buf); /* check what the font settings are, setting them to a default font * if they're not set - stops Pango whinging */ #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"); }
void gui_init(int argc, char** argv) { char buf[PATH_MAX]; if (pipe(sEventPipe) < 0) return; if (!replicated) { sBAppThreadID = spawn_thread(bapp_thread, "BApplication(NetSurf)", B_NORMAL_PRIORITY, (void *)find_thread(NULL)); if (sBAppThreadID < B_OK) return; /* #### handle errors */ if (resume_thread(sBAppThreadID) < B_OK) return; } // ui_color() gives hardcoded values before BApplication is created. nsbeos_update_system_ui_colors(); fetch_rsrc_register(); check_homedir(); // make sure the cache dir exists create_directory(TEMP_FILENAME_PREFIX, 0600); //nsbeos_completion_init(); /* This is an ugly hack to just get the new-style throbber going. * It, along with the PNG throbber loader, need making more generic. */ { #define STROF(n) #n #define FIND_THROB(n) filenames[(n)] = \ "throbber" STROF(n) ".png"; char *filenames[9]; FIND_THROB(0); FIND_THROB(1); FIND_THROB(2); FIND_THROB(3); FIND_THROB(4); FIND_THROB(5); FIND_THROB(6); FIND_THROB(7); FIND_THROB(8); nsbeos_throbber_initialise_from_png(9, filenames[0], filenames[1], filenames[2], filenames[3], filenames[4], filenames[5], filenames[6], filenames[7], filenames[8]); #undef FIND_THROB #undef STROF } if (nsbeos_throbber == NULL) die("Unable to load throbber image.\n"); find_resource(buf, "Choices", "%/Choices"); LOG(("Using '%s' as Preferences file", buf)); options_file_location = strdup(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(OPTION,y) if (nsoption_charp(OPTION) == NULL) nsoption_set_charp(OPTION, 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(font_sans, family); SETFONTDEFAULT(font_serif, family); SETFONTDEFAULT(font_mono, family); SETFONTDEFAULT(font_cursive, family); SETFONTDEFAULT(font_fantasy, family); */ #ifdef __HAIKU__ SETFONTDEFAULT(font_sans, "DejaVu Sans"); SETFONTDEFAULT(font_serif, "DejaVu Serif"); SETFONTDEFAULT(font_mono, "DejaVu Mono"); SETFONTDEFAULT(font_cursive, "DejaVu Sans"); SETFONTDEFAULT(font_fantasy, "DejaVu Sans"); #else SETFONTDEFAULT(font_sans, "Bitstream Vera Sans"); SETFONTDEFAULT(font_serif, "Bitstream Vera Serif"); SETFONTDEFAULT(font_mono, "Bitstream Vera Sans Mono"); SETFONTDEFAULT(font_cursive, "Bitstream Vera Serif"); SETFONTDEFAULT(font_fantasy, "Bitstream Vera Serif"); #endif nsbeos_options_init(); if (nsoption_charp(cookie_file) == NULL) { find_resource(buf, "Cookies", "%/Cookies"); LOG(("Using '%s' as Cookies file", buf)); nsoption_set_charp(cookie_file, strdup(buf)); } if (nsoption_charp(cookie_jar) == NULL) { find_resource(buf, "Cookies", "%/Cookies"); LOG(("Using '%s' as Cookie Jar file", buf)); nsoption_set_charp(cookie_jar, strdup(buf)); } if ((nsoption_charp(cookie_file) == NULL) || (nsoption_charp(cookie_jar) == NULL)) die("Failed initialising cookie options"); if (nsoption_charp(url_file) == NULL) { find_resource(buf, "URLs", "%/URLs"); LOG(("Using '%s' as URL file", buf)); nsoption_set_charp(url_file, strdup(buf)); } if (nsoption_charp(ca_path) == NULL) { find_resource(buf, "certs", "/etc/ssl/certs"); LOG(("Using '%s' as certificate path", buf)); nsoption_set_charp(ca_path, strdup(buf)); } //find_resource(buf, "mime.types", "/etc/mime.types"); beos_fetch_filetype_init(); urldb_load(nsoption_charp(url_file)); urldb_load_cookies(nsoption_charp(cookie_file)); //nsbeos_download_initialise(); if (!replicated) be_app->Unlock(); }