Logo Search packages:      
Sourcecode: inkscape version File versions

bool sp_file_save_document ( Gtk::Window &  parentWindow,
SPDocument doc 
)

Save a document, displaying a SaveAs dialog if necessary.

Definition at line 833 of file file.cpp.

References Inkscape::Extension::db, file_save(), Inkscape::Extension::get_file_save_extension(), SPDocument::isModifiedSinceSave(), sp_file_save_dialog(), and SPDocument::uri.

Referenced by SPDesktopWidget::shutdown(), and sp_file_save().

{
    bool success = true;

    if (doc->isModifiedSinceSave()) {
        if ( doc->uri == NULL )
        {
            // Hier sollte in Argument mitgegeben werden, das anzeigt, daß das Dokument das erste
            // Mal gespeichert wird, so daß als default .svg ausgewählt wird und nicht die zuletzt
            // benutzte "Save as ..."-Endung
            return sp_file_save_dialog(parentWindow, doc, Inkscape::Extension::FILE_SAVE_METHOD_INKSCAPE_SVG);
        } else {
            Glib::ustring extension = Inkscape::Extension::get_file_save_extension(Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS);
            Glib::ustring fn = g_strdup(doc->uri);
            // Try to determine the extension from the uri; this may not lead to a valid extension,
            // but this case is caught in the file_save method below (or rather in Extension::save()
            // further down the line).
            Glib::ustring ext = "";
            Glib::ustring::size_type pos = fn.rfind('.');
            if (pos != Glib::ustring::npos) {
                // FIXME: this could/should be more sophisticated (see FileSaveDialog::appendExtension()),
                // but hopefully it's a reasonable workaround for now
                ext = fn.substr( pos );
            }
            success = file_save(parentWindow, doc, fn, Inkscape::Extension::db.get(ext.c_str()), FALSE, TRUE, Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS);
        }
    } else {
        SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No changes need to be saved."));
        success = TRUE;
    }

    return success;
}


Generated by  Doxygen 1.6.0   Back to index