summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2012-10-17 14:20:18 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2012-10-17 14:20:18 +0100
commit35eb251244ee360cedef6ec1143e65b59da604a8 (patch)
treeb1f508161b6d7502abd534d786650ca7507373a5 /gtk
parent26ac642ef9f6bb439f10a7fc3188823ba1f7bffd (diff)
downloadnetsurf-35eb251244ee360cedef6ec1143e65b59da604a8.tar.gz
netsurf-35eb251244ee360cedef6ec1143e65b59da604a8.tar.bz2
Fix "error setting certificate verify locations" problem when the Choices file doesn't exist. Now there's a single place for front ends to set options overrides. Fix nsoption_setnull_charp leak.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gui.c86
1 files changed, 40 insertions, 46 deletions
diff --git a/gtk/gui.c b/gtk/gui.c
index b24fecfb8..891910407 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -241,11 +241,49 @@ nsgtk_init_glade(char **respath)
widWarning = GTK_WIDGET(gtk_builder_get_object(gladeWarning, "labelWarning"));
}
-static void check_options(char **respath)
+/* Documented in desktop/options.h */
+void gui_options_init_defaults(void)
{
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)
+ die("Failed initialising cookie options");
+
+ 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) {
+ die("Failed initialising string options");
+ }
+}
+
+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
@@ -259,57 +297,13 @@ static void check_options(char **respath)
}
/* user options should be stored in the users home directory */
- snprintf(buf, PATH_MAX, "%s/.netsurf/Choices", hdir);
+ 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);