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

29
macos.c
View file

@ -19,7 +19,8 @@ static GtkOSXApplication *osx_app;
#define SUBSURFACE_PREFERENCES CFSTR("org.hohndel.subsurface")
#define ICON_NAME "Subsurface.icns"
#define UI_FONT "Arial Unicode MS 12"
#define DIVELIST_MAC_DEFAULT_FONT "Arial Unicode MS 9"
const char system_divelist_default_font[] = "Arial Unicode MS 9";
void subsurface_open_conf(void)
{
@ -134,22 +135,18 @@ const char *subsurface_icon_name()
return path;
}
const char *subsurface_default_filename()
const char *system_default_filename(void)
{
if (default_filename) {
return strdup(default_filename);
} else {
const char *home, *user;
char *buffer;
int len;
const char *home, *user;
char *buffer;
int len;
home = g_get_home_dir();
user = g_get_user_name();
len = strlen(home) + strlen(user) + 45;
buffer = malloc(len);
snprintf(buffer, len, "%s/Library/Application Support/Subsurface/%s.xml", home, user);
return buffer;
}
home = g_get_home_dir();
user = g_get_user_name();
len = strlen(home) + strlen(user) + 45;
buffer = malloc(len);
snprintf(buffer, len, "%s/Library/Application Support/Subsurface/%s.xml", home, user);
return buffer;
}
const char *subsurface_gettext_domainpath(char *argv0)
@ -176,8 +173,6 @@ void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar,
{
GtkWidget *menu_item, *sep;
if (!divelist_font)
divelist_font = strdup(DIVELIST_MAC_DEFAULT_FONT);
g_object_set(G_OBJECT(settings), "gtk-font-name", UI_FONT, NULL);
osx_app = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);