Add default filename and divelist font to prefs structure

.. and add the usual logic to not save the default values.

This also simplifies the initial system-specific setup of both of these:
since we have defaults for all the preferences that get set up at
startup, we can just initialize those defaults to the system-specific
fonts then and there.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2013-01-11 17:07:22 -08:00 committed by Dirk Hohndel
parent 954290c70b
commit 6a10700ca5
11 changed files with 84 additions and 89 deletions

11
main.c
View file

@ -268,8 +268,12 @@ void renumber_dives(int nr)
*/
static void setup_system_prefs(void)
{
const char *env = getenv("LC_MEASUREMENT");
const char *env;
default_prefs.divelist_font = strdup(system_divelist_default_font);
default_prefs.default_filename = strdup(system_default_filename());
env = getenv("LC_MEASUREMENT");
if (!env)
env = getenv("LC_ALL");
if (!env)
@ -307,7 +311,7 @@ int main(int argc, char **argv)
#if DEBUGFILE > 1
debugfile = stderr;
#elif defined(DEBUGFILE)
debugfilename = (char *)subsurface_default_filename();
debugfilename = strdup(prefs.default_filename);
strncpy(debugfilename + strlen(debugfilename) - 3, "log", 3);
if (g_mkdir_with_parents(g_path_get_dirname(debugfilename), 0664) != 0 ||
(debugfile = g_fopen(debugfilename, "w")) == NULL)
@ -339,12 +343,11 @@ int main(int argc, char **argv)
}
if (no_filenames) {
GError *error = NULL;
const char *filename = subsurface_default_filename();
const char *filename = prefs.default_filename;
parse_file(filename, &error, TRUE);
/* don't report errors - this file may not exist, but make
sure we remember this as the filename in use */
set_filename(filename, FALSE);
free((void *)filename);
}
report_dives(imported, FALSE);
if (dive_table.nr == 0)