From f6f2d72eb62b4bf5b79dc19ccdcbf532d8cab784 Mon Sep 17 00:00:00 2001 From: hiro Date: Tue, 14 Nov 2006 05:26:15 +0000 Subject: made the default directory of file selection dialog document folder. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1300 ee746299-78ed-0310-b773-934348b2243d --- libsylph/utils.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'libsylph/utils.c') diff --git a/libsylph/utils.c b/libsylph/utils.c index 9992de51..5e21fa60 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c @@ -46,6 +46,7 @@ # include # include # include +# include #endif #include "utils.h" @@ -1832,6 +1833,40 @@ const gchar *get_home_dir(void) #endif } +const gchar *get_document_dir(void) +{ +#ifdef G_OS_WIN32 + static const gchar *document_dir = NULL; + HRESULT hr; + + if (!document_dir) { + if (G_WIN32_HAVE_WIDECHAR_API()) { + wchar_t path[MAX_PATH + 1]; + hr = SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, 0, + path); + if (hr == S_OK) { + document_dir = g_utf16_to_utf8 + (path, -1, NULL, NULL, NULL); + } + } else { + gchar path[MAX_PATH + 1]; + hr = SHGetFolderPathA(NULL, CSIDL_PERSONAL, NULL, 0, + path); + if (hr == S_OK) { + document_dir = g_locale_to_utf8 + (path, -1, NULL, NULL, NULL); + } + } + if (!document_dir) + document_dir = get_home_dir(); + } + + return document_dir; +#else + return get_home_dir(); +#endif +} + const gchar *get_rc_dir(void) { if (!rc_dir) { -- cgit v1.2.3