summaryrefslogtreecommitdiffstats
path: root/src/file.cpp
diff options
context:
space:
mode:
authorJoel Holdsworth <joel@airwebreathe.org.uk>2008-03-06 18:22:31 +0000
committerjoelholdsworth <joelholdsworth@users.sourceforge.net>2008-03-06 18:22:31 +0000
commit9081565a29e423262976da9c347ad6ec4b41abf2 (patch)
tree9906e061a8eb5879e9acd5249190aa4abbf7d7c7 /src/file.cpp
parentadding russian about screen for (0.46 and 0.46-devel) Needs (diff)
downloadinkscape-9081565a29e423262976da9c347ad6ec4b41abf2.tar.gz
inkscape-9081565a29e423262976da9c347ad6ec4b41abf2.zip
Fix for bug #167364 - "Win2k: file dialog uses wrong home directory"
(bzr r4976)
Diffstat (limited to 'src/file.cpp')
-rw-r--r--src/file.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/file.cpp b/src/file.cpp
index 4a10bb4c9..8e26bdfc9 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -74,6 +74,9 @@
#include "jabber_whiteboard/session-manager.h"
#endif
+#ifdef WIN32
+#include <windows.h>
+#endif
//#define INK_DUMP_FILENAME_CONV 1
#undef INK_DUMP_FILENAME_CONV
@@ -388,7 +391,38 @@ sp_file_open_dialog(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*d
if (!Inkscape::IO::file_test(open_path.c_str(),
(GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
open_path = "";
-
+
+#ifdef WIN32
+ //# If no open path, default to our win32 documents folder
+ if (open_path.empty())
+ {
+ // The path to the My Documents folder is read from the
+ // value "HKEY_CURRENT_USER\Software\Windows\CurrentVersion\
+ // Explorer\Shell Folders\Personal"
+ HKEY key = NULL;
+ if(RegOpenKeyExA(HKEY_CURRENT_USER,
+ "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
+ 0, KEY_QUERY_VALUE, &key) == ERROR_SUCCESS)
+ {
+ WCHAR utf16path[_MAX_PATH];
+ DWORD value_type;
+ DWORD data_size = sizeof(utf16path);
+ if(RegQueryValueExW(key, L"Personal", NULL, &value_type,
+ (BYTE*)utf16path, &data_size) == ERROR_SUCCESS)
+ {
+ g_assert(value_type == REG_SZ);
+ gchar *utf8path = g_utf16_to_utf8(
+ (const gunichar2*)utf16path, -1, NULL, NULL, NULL);
+ if(utf8path)
+ {
+ open_path = Glib::ustring(utf8path);
+ g_free(utf8path);
+ }
+ }
+ }
+ }
+#endif
+
//# If no open path, default to our home directory
if (open_path.empty())
{