diff --git a/src/file.cpp b/src/file.cpp
index a9c9184f69f7f165211d4eda9f6c0aa9e7808cc4..568d32572874d523c83b69445f4ed41917d5c7b0 100644 (file)
--- a/src/file.cpp
+++ b/src/file.cpp
* Chema Celorio <chema@celorio.com>
* bulia byak <buliabyak@users.sf.net>
*
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
* Copyright (C) 1999-2005 Authors
- * Copyright (C) 2001-2002 Ximian, Inc.
* Copyright (C) 2004 David Turner
+ * Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
SPDesktop*
sp_file_new(const Glib::ustring &templ)
{
- SPDocument *doc = sp_document_new(templ.c_str(), TRUE, true);
+ char *templName = NULL;
+ if (templ.size()>0)
+ templName = (char *)templ.c_str();
+ SPDocument *doc = sp_document_new(templName, TRUE, true);
g_return_val_if_fail(doc != NULL, NULL);
SPDesktop *dt;
sp_create_window(dtw, TRUE);
dt = static_cast<SPDesktop*>(dtw->view);
sp_namedview_window_from_document(dt);
+ sp_namedview_update_layers_from_document(dt);
}
return dt;
}
sources.pop_front();
}
- return sp_file_new(NULL);
+ return sp_file_new("");
}
// everyone who cares now has a reference, get rid of ours
sp_document_unref(doc);
// resize the window to match the document properties
- // (this may be redundant for new windows... if so, move to the "virgin"
- // section above)
sp_namedview_window_from_document(desktop);
+ sp_namedview_update_layers_from_document(desktop);
if (add_to_recent) {
prefs_set_recent_file(SP_DOCUMENT_URI(doc), SP_DOCUMENT_NAME(doc));
unsigned int diff = vacuum_document (doc);
sp_document_done(doc, SP_VERB_FILE_VACUUM,
- /* TODO: annotate */ "file.cpp:515");
+ _("Vacuum <defs>"));
SPDesktop *dt = SP_ACTIVE_DESKTOP;
if (diff > 0) {
/**
* This 'save' function called by the others below
+ *
+ * \param official whether to set :output_module and :modified in the
+ * document; is true for normal save, false for temporary saves
*/
static bool
file_save(SPDocument *doc, const Glib::ustring &uri,
- Inkscape::Extension::Extension *key, bool saveas)
+ Inkscape::Extension::Extension *key, bool saveas, bool official)
{
if (!doc || uri.size()<1) //Safety check
return false;
try {
Inkscape::Extension::save(key, doc, uri.c_str(),
saveas && prefs_get_int_attribute("dialogs.save_as", "append_extension", 1),
- saveas, TRUE); // save officially, with inkscape: attributes set
+ saveas, official);
} catch (Inkscape::Extension::Output::no_extension_found &e) {
gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str());
gchar *text = g_strdup_printf(_("No Inkscape extension found to save document (%s). This may have been caused by an unknown filename extension."), safeUri);
/**
* Display a SaveAs dialog. Save the document if OK pressed.
+ *
+ * \param ascopy (optional) wether to set the documents->uri to the new filename or not
*/
bool
-sp_file_save_dialog(SPDocument *doc)
+sp_file_save_dialog(SPDocument *doc, bool is_copy)
{
Inkscape::XML::Node *repr = sp_document_repr_root(doc);
save_loc.append(formatBuf);
}
} else {
- save_loc = Glib::path_get_dirname(doc->uri);
+ save_loc = Glib::build_filename(Glib::path_get_dirname(doc->uri),
+ Glib::path_get_basename(doc->uri));
}
// convert save_loc from utf-8 to locale
save_loc = save_loc_local;
//# Show the SaveAs dialog
+ char const * dialog_title;
+ if (is_copy) {
+ dialog_title = (char const *) _("Select file to save a copy to");
+ } else {
+ dialog_title = (char const *) _("Select file to save to");
+ }
if (!saveDialogInstance)
saveDialogInstance =
Inkscape::UI::Dialog::FileSaveDialog::create(
(char const *) _("Select file to save to"),
default_extension
);
-
+ else
+ saveDialogInstance->change_path(save_loc);
+ saveDialogInstance->change_title(dialog_title);
+
bool success = saveDialogInstance->show();
if (!success)
return success;
else
g_warning( "Error converting save filename to UTF-8." );
- success = file_save(doc, fileName, selectionType, TRUE);
+ success = file_save(doc, fileName, selectionType, TRUE, !is_copy);
if (success)
prefs_set_recent_file(SP_DOCUMENT_URI(doc), SP_DOCUMENT_NAME(doc));
- save_path = fileName;
+ save_path = Glib::path_get_dirname(fileName);
prefs_set_string_attribute("dialogs.save_as", "path", save_path.c_str());
return success;
gchar const *fn = repr->attribute("sodipodi:modified");
if (fn != NULL) {
- if (doc->uri == NULL
- || repr->attribute("inkscape:output_extension") == NULL)
+ if ( doc->uri == NULL
+ || repr->attribute("inkscape:output_extension") == NULL )
{
- return sp_file_save_dialog(doc);
+ return sp_file_save_dialog(doc, FALSE);
} else {
fn = g_strdup(doc->uri);
gchar const *ext = repr->attribute("inkscape:output_extension");
- success = file_save(doc, fn, Inkscape::Extension::db.get(ext), FALSE);
+ success = file_save(doc, fn, Inkscape::Extension::db.get(ext), FALSE, TRUE);
g_free((void *) fn);
}
} else {
if (!SP_ACTIVE_DOCUMENT)
return false;
sp_namedview_document_from_window(SP_ACTIVE_DESKTOP);
- return sp_file_save_dialog(SP_ACTIVE_DOCUMENT);
+ return sp_file_save_dialog(SP_ACTIVE_DOCUMENT, FALSE);
}
+/**
+ * Save a copy of a document, always displaying a sort of SaveAs dialog.
+ */
+bool
+sp_file_save_a_copy(gpointer object, gpointer data)
+{
+ if (!SP_ACTIVE_DOCUMENT)
+ return false;
+ sp_namedview_document_from_window(SP_ACTIVE_DESKTOP);
+ return sp_file_save_dialog(SP_ACTIVE_DOCUMENT, TRUE);
+}
+
/*######################
## I M P O R T
sp_document_unref(doc);
sp_document_done(in_doc, SP_VERB_FILE_IMPORT,
- /* TODO: annotate */ "file.cpp:900");
+ _("Import"));
} else {
gchar *text = g_strdup_printf(_("Failed to load the requested file %s"), uri.c_str());
else
g_warning( "Error converting save filename to UTF-8." );
- success = file_save(doc, fileName, selectionType, TRUE);
+ success = file_save(doc, fileName, selectionType, TRUE, FALSE);
if (success)
prefs_set_recent_file(SP_DOCUMENT_URI(doc), SP_DOCUMENT_NAME(doc));