diff options
| author | bulia byak <buliabyak@gmail.com> | 2009-06-28 21:40:37 +0000 |
|---|---|---|
| committer | buliabyak <buliabyak@users.sourceforge.net> | 2009-06-28 21:40:37 +0000 |
| commit | 09034719d1b45dd0d2b6c55d9933b556da282d23 (patch) | |
| tree | 020d385b5d80d95bed4d0c14496e5e7aa81cd2f4 /src/file.cpp | |
| parent | update (diff) | |
| download | inkscape-09034719d1b45dd0d2b6c55d9933b556da282d23.tar.gz inkscape-09034719d1b45dd0d2b6c55d9933b556da282d23.zip | |
save/restore initial dir when importing
(bzr r8180)
Diffstat (limited to 'src/file.cpp')
| -rw-r--r-- | src/file.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/file.cpp b/src/file.cpp index 136d946b9..049c1acb4 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1054,6 +1054,26 @@ sp_file_import(Gtk::Window &parentWindow) if (!doc) return; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + + if(import_path.empty()) + { + Glib::ustring attr = prefs->getString("/dialogs/import/path"); + if (!attr.empty()) import_path = attr; + } + + //# Test if the import_path directory exists + if (!Inkscape::IO::file_test(import_path.c_str(), + (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) + import_path = ""; + + //# If no open path, default to our home directory + if (import_path.empty()) + { + import_path = g_get_home_dir(); + import_path.append(G_DIR_SEPARATOR_S); + } + // Create new dialog (don't use an old one, because parentWindow has probably changed) Inkscape::UI::Dialog::FileOpenDialog *importDialogInstance = Inkscape::UI::Dialog::FileOpenDialog::create( @@ -1084,10 +1104,9 @@ sp_file_import(Gtk::Window &parentWindow) else g_warning( "ERROR CONVERTING OPEN FILENAME TO UTF-8" ); - - import_path = fileName; - if (import_path.size()>0) - import_path.append(G_DIR_SEPARATOR_S); + import_path = Glib::path_get_dirname (fileName); + import_path.append(G_DIR_SEPARATOR_S); + prefs->setString("/dialogs/import/path", import_path); file_import(doc, fileName, selection); } |
