? go ? inkscape Index: src/inkscape.cpp =================================================================== RCS file: /cvsroot/inkscape/inkscape/src/inkscape.cpp,v retrieving revision 1.71 diff -u -p -u -p -r1.71 inkscape.cpp --- src/inkscape.cpp 1 Feb 2005 07:09:06 -0000 1.71 +++ src/inkscape.cpp 6 Feb 2005 19:39:02 -0000 @@ -441,7 +441,7 @@ inkscape_segv_handler (int signum) if (!docname || !*docname) docname = "emergency"; // try saving to the profile location g_snprintf (c, 1024, "%.256s.%s.%d", docname, sptstr, count); - gchar * location = profile_path(c); + gchar * location = homedir_path(c); Inkscape::IO::dump_fopen_call(location, "E"); file = Inkscape::IO::fopen_utf8name(location, "w"); g_free(location); @@ -1238,6 +1238,36 @@ inkscape_exit (Inkscape::Application *in gtk_main_quit (); } +gchar * +homedir_path(const char *filename) +{ + static const gchar *homedir = NULL; + if (!homedir) { + homedir = g_get_home_dir(); + gchar* utf8Path = g_filename_to_utf8( homedir, -1, NULL, NULL, NULL ); + if ( utf8Path ) + { + homedir = utf8Path; + if (!g_utf8_validate(homedir, -1, NULL)) { + g_warning( "g_get_home_dir() post A IS NOT UTF-8" ); + } + } + } + if (!homedir) { + gchar * path = g_path_get_dirname(INKSCAPE->argv0); + gchar* utf8Path = g_filename_to_utf8( path, -1, NULL, NULL, NULL ); + g_free(path); + if ( utf8Path ) + { + homedir = utf8Path; + if (!g_utf8_validate(homedir, -1, NULL)) { + g_warning( "g_get_home_dir() post B IS NOT UTF-8" ); + } + } + } + return g_build_filename(homedir, filename, NULL); +} + /** * Get, or guess, or decide the location where the preferences.xml @@ -1246,13 +1276,13 @@ inkscape_exit (Inkscape::Application *in gchar * profile_path(const char *filename) { - static const gchar *homedir = NULL; - if (!homedir) { + static const gchar *prefdir = NULL; + if (!prefdir) { #ifdef HAS_SHGetSpecialFolderPath // prefer c:\Documents and Settings\UserName\Application Data\ to // c:\Documents and Settings\userName\; this // closes bug #933461 - if (!homedir) { + if (!prefdir) { gchar * utf8Path = NULL; if ( PrintWin32::is_os_wide() ) { @@ -1273,41 +1303,15 @@ profile_path(const char *filename) } if ( utf8Path ) { - homedir = utf8Path; + prefdir = utf8Path; } } #endif - if (!homedir) { - homedir = g_get_home_dir(); - if (!g_utf8_validate(homedir, -1, NULL)) { - g_warning( "g_get_home_dir() IS NOT UTF-8" ); - } - gchar* utf8Path = g_filename_to_utf8( homedir, -1, NULL, NULL, NULL ); - if ( utf8Path ) - { - homedir = utf8Path; - if (!g_utf8_validate(homedir, -1, NULL)) { - g_warning( "g_get_home_dir() post A IS NOT UTF-8" ); - } - } - } - if (!homedir) { - gchar * path = g_path_get_dirname(INKSCAPE->argv0); - if (!g_utf8_validate(path, -1, NULL)) { - g_warning( "g_path_get_dirname() IS NOT UTF-8" ); - } - gchar* utf8Path = g_filename_to_utf8( path, -1, NULL, NULL, NULL ); - g_free(path); - if ( utf8Path ) - { - homedir = utf8Path; - if (!g_utf8_validate(homedir, -1, NULL)) { - g_warning( "g_get_home_dir() post B IS NOT UTF-8" ); - } - } + if (!prefdir) { + prefdir = homedir_path(NULL); } } - return g_build_filename(homedir, INKSCAPE_PROFILE_DIR, filename, NULL); + return g_build_filename(prefdir, INKSCAPE_PROFILE_DIR, filename, NULL); } Index: src/inkscape.h =================================================================== RCS file: /cvsroot/inkscape/inkscape/src/inkscape.h,v retrieving revision 1.22 diff -u -p -u -p -r1.22 inkscape.h --- src/inkscape.h 18 Jan 2005 08:42:39 -0000 1.22 +++ src/inkscape.h 6 Feb 2005 19:39:02 -0000 @@ -35,6 +35,7 @@ SPDocument * inkscape_active_document (v #define SP_ACTIVE_DESKTOP inkscape_active_desktop () SPDesktop * inkscape_active_desktop (void); +gchar *homedir_path(const char *filename); gchar *profile_path(const char *filename); void inkscape_switch_desktops_next (); Index: src/dialogs/export.cpp =================================================================== RCS file: /cvsroot/inkscape/inkscape/src/dialogs/export.cpp,v retrieving revision 1.53 diff -u -p -u -p -r1.53 export.cpp --- src/dialogs/export.cpp 1 Feb 2005 07:13:20 -0000 1.53 +++ src/dialogs/export.cpp 6 Feb 2005 19:39:02 -0000 @@ -859,7 +859,7 @@ sp_export_area_toggled (GtkToggleButton if (directory == NULL) { // std::cout << "Home Directory" << std::endl; - directory = g_strdup(g_get_home_dir()); + directory = homedir_path(NULL); } gchar * id_ext = g_strconcat(id, ".png", NULL); @@ -1136,7 +1136,7 @@ sp_export_browse_clicked (GtkButton *but filename = gtk_entry_get_text (GTK_ENTRY (fe)); if(strlen(filename) == 0) { - filename = g_build_filename (g_get_home_dir(), G_DIR_SEPARATOR_S, NULL); + filename = homedir_path(NULL); } gtk_file_selection_set_filename (GTK_FILE_SELECTION (fs), filename); @@ -1172,8 +1172,9 @@ sp_export_browse_store (GtkButton *butto fe = (GtkWidget *)g_object_get_data (G_OBJECT (dlg), "filename"); file = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); - - gtk_entry_set_text (GTK_ENTRY (fe), file); + gchar * utf8file = g_filename_to_utf8( file, -1, NULL, NULL, NULL ); + gtk_entry_set_text (GTK_ENTRY (fe), utf8file); + g_free(utf8file); g_object_set_data (G_OBJECT (dlg), "filename", fe);