示例#1
0
文件: gui.c 项目: mmuman/NetSurf
/**
 * Set option defaults for gtk frontend.
 *
 * @param defaults The option table to update.
 * @return error status.
 */
static nserror set_defaults(struct nsoption_s *defaults)
{
	char *fname;

	/* cookie file default */
	fname = NULL;
	netsurf_mkpath(&fname, NULL, 2, nsgtk_config_home, "Cookies");
	if (fname != NULL) {
		nsoption_setnull_charp(cookie_file, fname);
	}

	/* cookie jar default */
	fname = NULL;
	netsurf_mkpath(&fname, NULL, 2, nsgtk_config_home, "Cookies");
	if (fname != NULL) {
		nsoption_setnull_charp(cookie_jar, fname);
	}

	/* url database default */
	fname = NULL;
	netsurf_mkpath(&fname, NULL, 2, nsgtk_config_home, "URLs");
	if (fname != NULL) {
		nsoption_setnull_charp(url_file, fname);
	}

	/* bookmark database default */
	fname = NULL;
	netsurf_mkpath(&fname, NULL, 2, nsgtk_config_home, "Hotlist");
	if (fname != NULL) {
		nsoption_setnull_charp(hotlist_path, fname);
	}

	/* download directory default */
	fname = getenv("HOME");
	if (fname != NULL) {
		nsoption_setnull_charp(downloads_directory, strdup(fname));
	}

	/* default path to certificates */
	nsoption_setnull_charp(ca_path, strdup("/etc/ssl/certs"));

	if ((nsoption_charp(cookie_file) == NULL) ||
	    (nsoption_charp(cookie_jar) == NULL) ||
	    (nsoption_charp(url_file) == NULL) ||
	    (nsoption_charp(hotlist_path) == NULL) ||
	    (nsoption_charp(downloads_directory) == NULL) ||
	    (nsoption_charp(ca_path) == NULL)) {
		LOG("Failed initialising default resource paths");
		return NSERROR_BAD_PARAMETER;
	}

	/* set default font names */
	nsoption_set_charp(font_sans, strdup("Sans"));
	nsoption_set_charp(font_serif, strdup("Serif"));
	nsoption_set_charp(font_mono, strdup("Monospace"));
	nsoption_set_charp(font_cursive, strdup("Serif"));
	nsoption_set_charp(font_fantasy, strdup("Serif"));

	return NSERROR_OK;
}
示例#2
0
bool ro_gui_options_theme_ok(wimp_w w)
{
	struct toolbar_display *toolbar;
	struct theme_descriptor *theme_new = NULL;

	/* find the current selection */
	for (toolbar = toolbars; toolbar; toolbar = toolbar->next) {
		if (ro_gui_get_icon_selected_state(theme_pane, toolbar->icon_number)) {
			theme_new = toolbar->descriptor;
		  	break;
		}
	}

	/* set the options */
	if (theme_new) {
		nsoption_set_charp(theme, strdup(theme_new->leafname));
		ro_gui_theme_apply(theme_new);
	} else {
		nsoption_set_charp(theme, NULL);
        }
	ro_gui_save_options();

	/* store the pane status */
	ro_gui_wimp_event_memorise(theme_pane);
	return true;
}
示例#3
0
nserror gui_options_init_defaults(struct nsoption_s *defaults)
{
#if defined(riscos)
	/* Set defaults for absent option strings */
	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"));

	if (nsoption_charp(ca_bundle) == NULL ||
	    nsoption_charp(cookie_file) == NULL ||
	    nsoption_charp(cookie_jar) == NULL) {
		return NSERROR_BAD_PARAMETER;
	}
#elif defined(nsgtk)
	char *hdir = getenv("HOME");
	char buf[PATH_MAX];

	/* Set defaults for absent option strings */
	snprintf(buf, PATH_MAX, "%s/.netsurf/Cookies", hdir);
	nsoption_setnull_charp(cookie_file, strdup(buf));
	nsoption_setnull_charp(cookie_jar, strdup(buf));
	if (nsoption_charp(cookie_file) == NULL ||
	    nsoption_charp(cookie_jar) == NULL) {
		return NSERROR_BAD_PARAMETER;
	}

	if (nsoption_charp(downloads_directory) == NULL) {
		snprintf(buf, PATH_MAX, "%s/", hdir);
		nsoption_set_charp(downloads_directory, strdup(buf));
	}

	if (nsoption_charp(url_file) == NULL) {
		snprintf(buf, PATH_MAX, "%s/.netsurf/URLs", hdir);
		nsoption_set_charp(url_file, strdup(buf));
	}

	if (nsoption_charp(hotlist_path) == NULL) {
		snprintf(buf, PATH_MAX, "%s/.netsurf/Hotlist", hdir);
		nsoption_set_charp(hotlist_path, strdup(buf));
	}

	nsoption_setnull_charp(ca_path, strdup("/etc/ssl/certs"));

	if (nsoption_charp(url_file) == NULL ||
	    nsoption_charp(ca_path) == NULL ||
	    nsoption_charp(downloads_directory) == NULL ||
	    nsoption_charp(hotlist_path) == NULL) {
		return NSERROR_BAD_PARAMETER;
	}

#endif
	return NSERROR_OK;
}
示例#4
0
bool ro_gui_options_interface_ok(wimp_w w)
{
	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;
}
示例#5
0
void ami_theme_init(void)
{
	char themefile[1024];
	char searchico[1024];
	BPTR lock = 0;

	strcpy(themefile,nsoption_charp(theme));
	AddPart(themefile,"Theme",100);

	lock = Lock(themefile,ACCESS_READ);

	if(!lock)
	{
		warn_user("ThemeApplyErr",nsoption_charp(theme));
		strcpy(themefile,"PROGDIR:Resources/Themes/Default/Theme");
		nsoption_set_charp(theme, (char *)strdup("PROGDIR:Resources/Themes/Default"));
	}
	else
	{
		UnLock(lock);
	}

	lock = Lock(themefile,ACCESS_READ);
	if(lock)
	{
		UnLock(lock);
		messages_load(themefile);
	}

	ami_get_theme_filename(searchico, "theme_search", false);
	search_default_ico_location = (char *)strdup(searchico);
}
示例#6
0
END_HANDLER

BUTTON_CLICKED(setDefaultPage)
{
	gtk_entry_set_text(GTK_ENTRY(entryHomePageURL), NETSURF_HOMEPAGE);
	nsoption_set_charp(homepage_url, 
			   strdup(gtk_entry_get_text(GTK_ENTRY(entryHomePageURL))));
}
示例#7
0
bool ro_gui_options_fonts_ok(wimp_w w)
{
	unsigned int i;

	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,
				FONT_DEFAULT_FIELD)))
			break;
	}
	if (i == 5)
		/* this should never happen, but still */
		i = 0;

	nsoption_set_int(font_default, i);

	ro_gui_save_options();
	return true;
}
示例#8
0
bool ro_gui_theme_install_apply(wimp_w w)
{
	char theme_save[256];
	char *theme_file;
	struct theme_descriptor *theme_install;
	os_error *error;
	char *fix;
	const char *source_data;
	unsigned long source_size;

	assert(theme_install_content);

	/* convert spaces to hard spaces */
	theme_file = strdup(theme_install_descriptor.name);
	if (!theme_file) {
	  	LOG(("malloc failed"));
	  	warn_user("NoMemory", 0);
		return false;
	}
	for (fix = theme_file; *fix != '\0'; fix++)
		if (*fix == ' ')
			*fix = 160;	/* hard space */

	/* simply overwrite previous theme versions */
	snprintf(theme_save, sizeof theme_save, "%s.%s",
                 nsoption_charp(theme_save), theme_file);

	theme_save[sizeof theme_save - 1] = '\0';

	source_data = content_get_source_data(theme_install_content, 
			&source_size);

	error = xosfile_save_stamped(theme_save, 0xffd,
			(byte *) source_data,
			(byte *) source_data + source_size);
	if (error) {
		LOG(("xosfile_save_stamped: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("ThemeInstallErr", 0);
		free(theme_file);
		return false;
	}

	/* apply the new theme */
	ro_gui_theme_get_available();
	theme_install = ro_gui_theme_find(theme_file);
	if (!theme_install || !ro_gui_theme_apply(theme_install)) {
		warn_user("ThemeApplyErr", 0);
	} else {
            nsoption_set_charp(theme, strdup(theme_install->leafname));
	}
	free(theme_file);
	ro_gui_save_options();
	return true;
}
示例#9
0
bool ro_gui_options_home_ok(wimp_w w)
{
	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;
}
示例#10
0
END_HANDLER

static gboolean on_fileChooserDownloads_changed(GtkWidget *widget, gpointer data) 
{
	gchar *dir;
	LOG(("Signal emitted on '%s'", "fileChooserDownloads"));

	dir = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER((widget)));
	nsoption_set_charp(downloads_directory, strdup(dir));
	g_free(dir);
	return FALSE;
} 
示例#11
0
bool ro_gui_options_language_ok(wimp_w w)
{
	const char *code;
	char *temp;

	code = ro_gui_menu_find_menu_entry_key(languages_menu,
			ro_gui_get_icon_string(w, LANGUAGE_INTERFACE_FIELD));
	if (code) {
		code += 5;	/* skip 'lang_' */
		if ((!nsoption_charp(language)) || 
                    (strcmp(nsoption_charp(language), code))) {
			temp = strdup(code);
			if (temp) {
				nsoption_set_charp(language, temp);
			} else {
				LOG("No memory to duplicate language code");
				warn_user("NoMemory", 0);
			}
		}
	}
	code = ro_gui_menu_find_menu_entry_key(languages_menu,
			ro_gui_get_icon_string(w, LANGUAGE_WEB_PAGES_FIELD));
	if (code) {
		code += 5;	/* skip 'lang_' */
		if ((!nsoption_charp(accept_language)) ||
                    (strcmp(nsoption_charp(accept_language), code))) {
			temp = strdup(code);
			if (temp) {
				nsoption_set_charp(accept_language,temp);
			} else {
				LOG("No memory to duplicate language code");
				warn_user("NoMemory", 0);
			}
		}
	}
	ro_gui_save_options();
	return true;
}
示例#12
0
static gboolean on_comboLanguage_changed(GtkWidget *widget, gpointer data)
{
	gchar *lang; 

	lang = nsgtk_combo_box_text_get_active_text(comboLanguage);
	if (lang == NULL)
		return FALSE;

	nsoption_set_charp(accept_language, strdup(lang));

	g_free(lang);
	
	return FALSE;
}
示例#13
0
static BOOL CALLBACK options_appearance_dialog_handler(HWND hwnd,
		UINT msg, WPARAM wparam, LPARAM lParam)
{
	int len;
	char *temp, number[6];
	HWND sub;

	LOG_WIN_MSG(hwnd, msg, wparam, lParam);

	switch (msg) {
	case WM_INITDIALOG:
		sub = GetDlgItem(hwnd, IDC_PREFS_FONTDEF);
		SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Sans serif");
		SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Serif");
		SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Monospace");
		SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Cursive");
		SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Fantasy");
		SendMessage(sub, CB_SETCURSEL,
			    (WPARAM) (nsoption_int(font_default) - 1), 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)nsoption_charp(font_sans));
		}
		if ((nsoption_charp(font_serif) != NULL) &&
		    (nsoption_charp(font_serif)[0] != '\0')) {
			sub = GetDlgItem(hwnd, IDC_PREFS_SERIF);
			SendMessage(sub, WM_SETTEXT, 0,
				    (LPARAM)nsoption_charp(font_serif));
		}
		if ((nsoption_charp(font_mono) != NULL) &&
		    (nsoption_charp(font_mono)[0] != '\0')) {
			sub = GetDlgItem(hwnd, IDC_PREFS_MONO);
			SendMessage(sub, WM_SETTEXT, 0,
				    (LPARAM)nsoption_charp(font_mono));
		}
		if ((nsoption_charp(font_cursive) != NULL) &&
		    (nsoption_charp(font_cursive)[0] != '\0')) {
			sub = GetDlgItem(hwnd, IDC_PREFS_CURSIVE);
			SendMessage(sub, WM_SETTEXT, 0,
				    (LPARAM)nsoption_charp(font_cursive));
		}
		if ((nsoption_charp(font_fantasy) != NULL) &&
		    (nsoption_charp(font_fantasy)[0] != '\0')) {
			sub = GetDlgItem(hwnd, IDC_PREFS_FANTASY);
			SendMessage(sub, WM_SETTEXT, 0,
				    (LPARAM)nsoption_charp(font_fantasy));
		}
		if (nsoption_int(font_min_size) != 0) {
			sub = GetDlgItem(hwnd, IDC_PREFS_FONT_MINSIZE);
			snprintf(number, 6, "%.1f", nsoption_int(font_min_size) / 10.0);
			SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
		}
		if (nsoption_int(font_size) != 0) {
			sub = GetDlgItem(hwnd, IDC_PREFS_FONT_SIZE);
			snprintf(number, 6, "%.1f", nsoption_int(font_size) / 10.0);
			SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
		}
		if (nsoption_int(max_fetchers) != 0) {
			sub = GetDlgItem(hwnd, IDC_PREFS_FETCHERS);
			snprintf(number, 6, "%d", nsoption_int(max_fetchers));
			SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
		}
		if (nsoption_int(max_fetchers_per_host) != 0) {
			sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HOST);
			snprintf(number, 6, "%d",
				 nsoption_int(max_fetchers_per_host));
			SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
		}
		if (nsoption_int(max_cached_fetch_handles) != 0) {
			sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HANDLES);
			snprintf(number, 6, "%d",
				 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)((nsoption_bool(animate_images))
				       ? BST_UNCHECKED : BST_CHECKED),	0);

		if (nsoption_int(minimum_gif_delay) != 0) {
			sub = GetDlgItem(hwnd, IDC_PREFS_ANIMATIONDELAY);
			snprintf(number, 6, "%.1f", nsoption_int(minimum_gif_delay) /
				 100.0);
			SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
		}
		break;

	case WM_NOTIFY:
		switch (((NMHDR FAR *)lParam)->code) {
		case PSN_APPLY:
			sub = GetDlgItem(hwnd, IDC_PREFS_FONT_SIZE);
			len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
			temp = malloc(len + 1);
			if (temp != NULL) {
				SendMessage(sub, WM_GETTEXT, (WPARAM)
					    (len + 1), (LPARAM) temp);
				nsoption_int(font_size) = (int)
					(10 * strtod(temp, NULL));
				free(temp);
			}

			sub = GetDlgItem(hwnd, IDC_PREFS_FONT_MINSIZE);
			len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
			temp = malloc(len + 1);
			if (temp != NULL) {
				SendMessage(sub, WM_GETTEXT, (WPARAM)
					    (len + 1), (LPARAM) temp);
				nsoption_set_int(font_min_size, 
						 (int)(10 * strtod(temp, NULL)));
				free(temp);
			}

			/* animation */
			nsoption_set_bool(animate_images, 
					  (IsDlgButtonChecked(hwnd, IDC_PREFS_NOANIMATION) == BST_CHECKED) ? true : false);


			sub = GetDlgItem(hwnd, IDC_PREFS_ANIMATIONDELAY);
			len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
			temp = malloc(len + 1);
			if (temp != NULL) {
				SendMessage(sub, WM_GETTEXT, (WPARAM)
					    (len + 1), (LPARAM) temp);
				nsoption_set_int(minimum_gif_delay,
						 (int)(100 * strtod(temp, NULL)));
				free(temp);
			}

			break;

		case UDN_DELTAPOS: {
			NMUPDOWN *ud = (NMUPDOWN *)lParam;
			switch(((NMHDR *)lParam)->idFrom) {
			case IDC_PREFS_FONT_SIZE_SPIN:
				change_spinner(GetDlgItem(hwnd, IDC_PREFS_FONT_SIZE), 0.1  * ud->iDelta, 1.0, 50.0);
				return TRUE;

			case IDC_PREFS_FONT_MINSIZE_SPIN:
				change_spinner(GetDlgItem(hwnd, IDC_PREFS_FONT_MINSIZE), 0.1  * ud->iDelta, 1.0, 50.0);
				return TRUE;

			case IDC_PREFS_ANIMATIONDELAY_SPIN:
				change_spinner(GetDlgItem(hwnd, IDC_PREFS_ANIMATIONDELAY), 0.1  * ud->iDelta, 0.1, 100.0);
				return TRUE;
				
			}
		}
			break;
		}


	case WM_COMMAND:
		LOG(("WM_COMMAND Identifier 0x%x",LOWORD(wparam)));

		switch(LOWORD(wparam)) {
		case IDC_PREFS_PROXYTYPE:
			sub = GetDlgItem(hwnd, IDC_PREFS_PROXYTYPE);
			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) {
				break;
			}

			if (ChooseFont(cf) == TRUE) {
				nsoption_set_charp(font_sans, 
						   strdup(cf->lpLogFont->lfFaceName));
			}

			free(cf->lpLogFont);
			free(cf);
			if ((nsoption_charp(font_sans) != NULL) &&
			    (nsoption_charp(font_sans)[0] != '\0')) {
				sub = GetDlgItem(hwnd, IDC_PREFS_SANS);
				SendMessage(sub, WM_SETTEXT, 0,
					    (LPARAM)nsoption_charp(font_sans));
			}
			break;
		}

		case IDC_PREFS_SERIF: {
			CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_ROMAN, hwnd);
			if (cf == NULL) {
				break;
			}

			if (ChooseFont(cf) == TRUE) {
				nsoption_set_charp(font_serif,
						   strdup(cf->lpLogFont->lfFaceName));
			}

			free(cf->lpLogFont);
			free(cf);
			if ((nsoption_charp(font_serif) != NULL) &&
			    (nsoption_charp(font_serif)[0] != '\0')) {
				sub = GetDlgItem(hwnd, IDC_PREFS_SERIF);
				SendMessage(sub, WM_SETTEXT, 0,
					    (LPARAM)nsoption_charp(font_serif));
			}
			break;
		}

		case IDC_PREFS_MONO: {
			CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_MODERN, hwnd);
			if (cf == NULL) {
				break;
			}

			if (ChooseFont(cf) == TRUE) {
				nsoption_set_charp(font_mono,
						   strdup(cf->lpLogFont->lfFaceName));
			}

			free(cf->lpLogFont);
			free(cf);

			if ((nsoption_charp(font_mono) != NULL) &&
			    (nsoption_charp(font_mono)[0] != '\0')) {
				sub = GetDlgItem(hwnd, IDC_PREFS_MONO);
				SendMessage(sub, WM_SETTEXT, 0,
					    (LPARAM)nsoption_charp(font_mono));
			}
			break;
		}

		case IDC_PREFS_CURSIVE: {
			CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_SCRIPT, hwnd);
			if (cf == NULL) {
				break;
			}

			if (ChooseFont(cf) == TRUE) {
				nsoption_set_charp(font_cursive,
						   strdup(cf->lpLogFont->lfFaceName));
			}
			free(cf->lpLogFont);
			free(cf);
			if ((nsoption_charp(font_cursive) != NULL) &&
			    (nsoption_charp(font_cursive)[0] != '\0')) {
				sub = GetDlgItem(hwnd, IDC_PREFS_CURSIVE);
				SendMessage(sub, WM_SETTEXT, 0,
					    (LPARAM)nsoption_charp(font_cursive));
			}
			break;
		}

		case IDC_PREFS_FANTASY: {
			CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_DECORATIVE, hwnd);
			if (cf == NULL) {
				break;
			}

			if (ChooseFont(cf) == TRUE) {
				nsoption_set_charp(font_fantasy,
						   strdup(cf->lpLogFont->lfFaceName));
			}
			free(cf->lpLogFont);
			free(cf);
			if ((nsoption_charp(font_fantasy) != NULL) &&
			    (nsoption_charp(font_fantasy)[0] != '\0')) {
				sub = GetDlgItem(hwnd, IDC_PREFS_FANTASY);
				SendMessage(sub, WM_SETTEXT, 0,
					    (LPARAM)nsoption_charp(font_fantasy));
			}
			break;
		}

		case IDC_PREFS_FONTDEF: 
			sub = GetDlgItem(hwnd, IDC_PREFS_FONTDEF);
			nsoption_set_int(font_default,
					 SendMessage(sub, CB_GETCURSEL, 0, 0) + 1);
			break;
		
		}
		break;

	}
	return FALSE;
}
示例#14
0
void ro_gui_global_history_toolbar_save_buttons(char *config)
{
	nsoption_set_charp(toolbar_history, config);
	ro_gui_save_options();
}
示例#15
0
static BOOL CALLBACK options_connections_dialog_handler(HWND hwnd,
		UINT msg, WPARAM wparam, LPARAM lParam)
{
	int len;
	char *temp, number[6];
	HWND sub;

	LOG_WIN_MSG(hwnd, msg, wparam, lParam);

	switch (msg) {
	case WM_INITDIALOG:
		sub = GetDlgItem(hwnd, IDC_PREFS_PROXYTYPE);
		SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"None");
		SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Simple");
		SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Basic Auth");
		SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"NTLM Auth");
		if (nsoption_bool(http_proxy)) {
			SendMessage(sub, CB_SETCURSEL, (WPARAM)
				    (nsoption_int(http_proxy_auth) + 1), 0);
		} else {
			SendMessage(sub, CB_SETCURSEL, 0, 0);
		}

		sub = GetDlgItem(hwnd, IDC_PREFS_PROXYHOST);
		if ((nsoption_charp(http_proxy_host) != NULL) &&
		    (nsoption_charp(http_proxy_host)[0] != '\0'))
			SendMessage(sub, WM_SETTEXT, 0,
				    (LPARAM)nsoption_charp(http_proxy_host));

		sub = GetDlgItem(hwnd, IDC_PREFS_PROXYPORT);
		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 ((nsoption_charp(http_proxy_auth_user) != NULL) &&
		    (nsoption_charp(http_proxy_auth_user)[0] != '\0'))
			SendMessage(sub, WM_SETTEXT, 0,
				    (LPARAM)nsoption_charp(http_proxy_auth_user));

		sub = GetDlgItem(hwnd, IDC_PREFS_PROXYPASS);
		if ((nsoption_charp(http_proxy_auth_pass) != NULL) &&
		    (nsoption_charp(http_proxy_auth_pass)[0] != '\0'))
			SendMessage(sub, WM_SETTEXT, 0,
				    (LPARAM)nsoption_charp(http_proxy_auth_pass));

		sub = GetDlgItem(hwnd, IDC_PREFS_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", nsoption_int(max_fetchers_per_host));
		SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);

		sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HANDLES);
		snprintf(number, 6, "%d", nsoption_int(max_cached_fetch_handles));
		SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);

		break;

	case WM_NOTIFY:
		switch (((NMHDR FAR *)lParam)->code) {
		case PSN_APPLY:
			sub = GetDlgItem(hwnd, IDC_PREFS_PROXYHOST);
			len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
			temp = malloc(len + 1);
			if (temp != NULL) {
				SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1),
					    (LPARAM)temp);
				nsoption_set_charp(http_proxy_host, strdup(temp));
				free(temp);
			}

			sub = GetDlgItem(hwnd, IDC_PREFS_PROXYPORT);
			len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
			temp = malloc(len + 1);
			if (temp != NULL) {
				SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1),
					    (LPARAM)temp);
				nsoption_set_int(http_proxy_port, atoi(temp));
				free(temp);
			}

			sub = GetDlgItem(hwnd, IDC_PREFS_PROXYNAME);
			len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
			temp = malloc(len + 1);
			if (temp != NULL) {
				SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1),
					    (LPARAM)temp);
				nsoption_set_charp(http_proxy_auth_user, strdup(temp));
				free(temp);
			}

			sub = GetDlgItem(hwnd, IDC_PREFS_PROXYPASS);
			len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
			temp = malloc(len + 1);
			if (temp != NULL) {
				SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1),
					    (LPARAM)temp);
				nsoption_set_charp(http_proxy_auth_pass, strdup(temp));
				free(temp);
			}

			/* fetchers */
			sub = GetDlgItem(hwnd, IDC_PREFS_FETCHERS);
			len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
			temp = malloc(len + 1);
			if (temp != NULL) {
				SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1),
					    (LPARAM)temp);
				nsoption_set_int(max_fetchers, atoi(temp));
				free(temp);
			}

			sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HOST);
			len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
			temp = malloc(len + 1);
			if (temp != NULL) {
				SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1),
					    (LPARAM)temp);
				nsoption_set_int(max_fetchers_per_host, atoi(temp));
				free(temp);
			}

			sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HANDLES);
			len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
			temp = malloc(len + 1);
			if (temp != NULL) {
				SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1),
					    (LPARAM)temp);
				nsoption_set_int(max_cached_fetch_handles, atoi(temp));
				free(temp);
			}
			break;

		case UDN_DELTAPOS: {
			NMUPDOWN *ud = (NMUPDOWN *)lParam;
			switch(((NMHDR *)lParam)->idFrom) {
			case IDC_PREFS_FETCHERS_SPIN:
				change_spinner(GetDlgItem(hwnd, IDC_PREFS_FETCHERS), 1.0  * ud->iDelta, 1.0, 100.0);
				return TRUE;

			case IDC_PREFS_FETCH_HOST_SPIN:
				change_spinner(GetDlgItem(hwnd, IDC_PREFS_FETCH_HOST), 1.0  * ud->iDelta, 1.0, 100.0);
				return TRUE;

			case IDC_PREFS_FETCH_HANDLES_SPIN:
				change_spinner(GetDlgItem(hwnd, IDC_PREFS_FETCH_HANDLES), 1.0  * ud->iDelta, 1.0, 100.0);
				return TRUE;

			}
		}
			break;
		}
	}
	return FALSE;
}
示例#16
0
文件: gui.c 项目: pcwalton/NetSurf
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");

}
示例#17
0
void ro_gui_cookies_toolbar_save_buttons(char *config)
{
	nsoption_set_charp(toolbar_cookies, config);
	ro_gui_save_options();
}
示例#18
0
static BOOL CALLBACK options_general_dialog_handler(HWND hwnd,
		UINT msg, WPARAM wparam, LPARAM lParam)
{
	HWND sub;

	LOG_WIN_MSG(hwnd, msg, wparam, lParam);

	switch (msg) {
	case WM_INITDIALOG:
		/* homepage url */
		sub = GetDlgItem(hwnd, IDC_PREFS_HOMEPAGE);
		SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(homepage_url));

		/* Display images */
		sub = GetDlgItem(hwnd, IDC_PREFS_IMAGES);
		SendMessage(sub, BM_SETCHECK, 
			    (WPARAM) ((nsoption_bool(suppress_images)) ? 
				  BST_CHECKED : BST_UNCHECKED), 0);

		/* advert blocking */
		sub = GetDlgItem(hwnd, IDC_PREFS_ADVERTS);
		SendMessage(sub, BM_SETCHECK, 
			    (WPARAM) ((nsoption_bool(block_ads)) ? 
				  BST_CHECKED : BST_UNCHECKED), 0);

		/* Referrer sending */
		sub = GetDlgItem(hwnd, IDC_PREFS_REFERER);
		SendMessage(sub, BM_SETCHECK, 
			    (WPARAM)((nsoption_bool(send_referer)) ?
				 BST_CHECKED : BST_UNCHECKED), 0);
		break;

	case WM_NOTIFY:
		switch (((NMHDR FAR *)lParam)->code) {
		case PSN_APPLY:
			/* homepage */
			sub = GetDlgItem(hwnd, IDC_PREFS_HOMEPAGE);
			if (sub != NULL) {
				int text_length;
				char *text;
				text_length = SendMessage(sub, 
						  WM_GETTEXTLENGTH, 0, 0);
				text = malloc(text_length + 1);
				if (text != NULL) {
					SendMessage(sub, WM_GETTEXT,
						    (WPARAM)text_length + 1,
						    (LPARAM)text);
					nsoption_set_charp(homepage_url, text);
				}
			}

			nsoption_set_bool(suppress_images,
					  (IsDlgButtonChecked(hwnd, IDC_PREFS_IMAGES) == BST_CHECKED) ? true : false);

			nsoption_set_bool(block_ads, (IsDlgButtonChecked(hwnd, 
									 IDC_PREFS_ADVERTS) == BST_CHECKED) ? true : false);

			nsoption_set_bool(send_referer, (IsDlgButtonChecked(hwnd, 
									    IDC_PREFS_REFERER) == BST_CHECKED) ? true : false);

			break;
			
		}
	}
	return FALSE;
}
示例#19
0
static void apply_settings(void)
{
    /* "Network" tab: */
    nsoption_set_bool(http_proxy, OBJ_SELECTED(SETTINGS_CB_USE_PROXY));
    if ( OBJ_SELECTED(SETTINGS_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,
                       gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_PROXY_PASSWORD));
    nsoption_set_charp(http_proxy_auth_user,
                       gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_PROXY_USERNAME));
    nsoption_set_charp(http_proxy_host,
                       gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_PROXY_HOST));
    nsoption_set_int(http_proxy_port,
                     atoi( gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_PROXY_PORT) ));
    nsoption_set_int(max_fetchers_per_host,
                     atoi( gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_MAX_FETCHERS_PER_HOST)));
    nsoption_set_int(max_cached_fetch_handles,
                     atoi( gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_MAX_CACHED_CONNECTIONS)));
    nsoption_set_int(max_fetchers,
                     atoi( gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_MAX_FETCHERS) ));
    nsoption_set_bool(foreground_images,
                      OBJ_SELECTED( SETTINGS_CB_FG_IMAGES ));
    nsoption_set_bool(background_images,
                      OBJ_SELECTED( SETTINGS_CB_BG_IMAGES ));

    /* "Style" tab: */
    nsoption_set_int(font_min_size, tmp_option_font_min_size);
    nsoption_set_int(font_size, tmp_option_font_size);

    /* "Rendering" tab: */
    nsoption_set_charp(atari_font_driver,
                       gemtk_obj_get_text(dlgtree, SETTINGS_BT_SEL_FONT_RENDERER));
    nsoption_set_bool(atari_transparency,
                      OBJ_SELECTED(SETTINGS_CB_TRANSPARENCY));
    nsoption_set_bool(animate_images,
                      OBJ_SELECTED(SETTINGS_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(SETTINGS_CB_INCREMENTAL_REFLOW));*/
    nsoption_set_int(min_reflow_period, tmp_option_min_reflow_period);
    nsoption_set_int(atari_font_monochrom,
                     !OBJ_SELECTED( SETTINGS_CB_ANTI_ALIASING ));

    /* "Paths" tabs: */
    nsoption_set_charp(ca_bundle,
                       gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_CA_BUNDLE));
    nsoption_set_charp(ca_path,
                       gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_CA_CERTS_PATH));
    nsoption_set_charp(homepage_url,
                       gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_CA_CERTS_PATH));
    nsoption_set_charp(hotlist_file,
                       gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_HOTLIST_FILE));
    nsoption_set_charp(atari_editor,
                       gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_EDITOR));
    nsoption_set_charp(downloads_path,
                       gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_DOWNLOAD_PATH));

    /* "Cache" tab: */
    nsoption_set_int(memory_cache_size,
                     tmp_option_memory_cache_size * 1000000);

    /* "Browser" tab: */
    nsoption_set_bool(target_blank,
                      !OBJ_SELECTED(SETTINGS_CB_DISABLE_POPUP_WINDOWS));
    nsoption_set_bool(block_ads,
                      OBJ_SELECTED(SETTINGS_CB_HIDE_ADVERTISEMENT));
    nsoption_set_charp(accept_language,
                       gemtk_obj_get_text(dlgtree, SETTINGS_BT_SEL_LOCALE));
    nsoption_set_int(expire_url,
                     atoi(gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_HISTORY_AGE)));
    nsoption_set_bool(send_referer,
                      OBJ_SELECTED(SETTINGS_CB_SEND_HTTP_REFERRER));
    nsoption_set_bool(do_not_track,
                      OBJ_SELECTED(SETTINGS_CB_SEND_DO_NOT_TRACK));
    nsoption_set_charp(homepage_url,
                       gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_HOMEPAGE));
}
示例#20
0
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;
	}

}
示例#21
0
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();

}