diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-09-09 09:06:44 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-09-09 17:38:01 -0700 |
commit | b73f29fea3ae88a06d8f773a6d48510520c127f0 (patch) | |
tree | d04166fd6e2fde7d716fe69cbfe35330e79cd1b9 /windows.c | |
parent | b6812946319080699f6071656f09d402d23d3e46 (diff) | |
download | subsurface-b73f29fea3ae88a06d8f773a6d48510520c127f0.tar.gz |
First cut of adding a default file name
The default file name is OS specific and tries to follow the customs on
each of the OSs. It can be configured through the preferences dialog.
On MacOS we get a strange warning which appears to be a well documented
Gtk bug on MacOS.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'windows.c')
-rw-r--r-- | windows.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -1,7 +1,9 @@ /* windows.c */ /* implements Windows specific functions */ +#include "dive.h" #include "display-gtk.h" #include <windows.h> +#include <shlobj.h> #define DIVELIST_DEFAULT_FONT "Sans 8" static HKEY hkey; @@ -93,6 +95,28 @@ const char *subsurface_icon_name() return "subsurface.ico"; } +const char *subsurface_default_filename() +{ + if (default_filename) { + return default_filename; + } else { + char datapath[MAX_PATH]; + const char *user; + char *buffer; + int len; + + user = g_get_user_name(); + if (! SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, datapath))) { + datapath[0] = '.'; + datapath[1] = '\0'; + } + len = strlen(datapath) + strlen(user) + 17; + buffer = malloc(len); + snprintf(buffer, len, "%s\\Subsurface\\%s.xml", datapath, user); + return buffer; + } +} + void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar, GtkWidget *vbox, GtkUIManager *ui_manager) { |