summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e982a01)
raw | patch | inline | side by side (parent: e982a01)
author | kidproto <kidproto@users.sourceforge.net> | |
Tue, 22 Aug 2006 08:01:11 +0000 (08:01 +0000) | ||
committer | kidproto <kidproto@users.sourceforge.net> | |
Tue, 22 Aug 2006 08:01:11 +0000 (08:01 +0000) |
AUTHORS | patch | blob | history | |
src/extension/output.cpp | patch | blob | history | |
src/extension/system.cpp | patch | blob | history | |
src/file.cpp | patch | blob | history | |
src/file.h | patch | blob | history | |
src/menus-skeleton.h | patch | blob | history | |
src/verbs.cpp | patch | blob | history | |
src/verbs.h | patch | blob | history |
index 90c96ac0f88e2d7b48909e6420e5162287faf4a7..d65e9dd2af8423f39bcc3746a68a5db50c888155 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
David Yip
Masatake Yamato
Jos Hirth
+Alan Horkan
index eb3f85ed8a60708adba492176e4b6765c8815079..b0f254a9c07afbacd205bcb2f99f8c1fa5a8a4dc 100644 (file)
--- a/src/extension/output.cpp
+++ b/src/extension/output.cpp
gboolean saved = sp_document_get_undo_sensitive(doc);
sp_document_set_undo_sensitive (doc, FALSE);
- repr->setAttribute("inkscape:output_extension", NULL);
+ //repr->setAttribute("inkscape:output_extension", NULL);
repr->setAttribute("inkscape:dataloss", NULL);
if (repr->attribute("sodipodi:modified") != NULL)
modified = true;
saved = sp_document_get_undo_sensitive(doc);
sp_document_set_undo_sensitive (doc, FALSE);
- repr->setAttribute("inkscape:output_extension", get_id());
+ //repr->setAttribute("inkscape:output_extension", get_id());
if (dataloss) {
repr->setAttribute("inkscape:dataloss", "true");
}
index 81bf3075e2cf204a315f0c116331876a465004de..3a8a54214091593958ebae8df05eeca66e91af1d 100644 (file)
--- a/src/extension/system.cpp
+++ b/src/extension/system.cpp
@@ -244,10 +244,15 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
throw Output::no_overwrite();
}
+ // if 'official' save the filename and extension for future saves.
if (official) {
+ // save the filename for next use
sp_document_set_uri(doc, fileName);
+ // also save the extension for next use
+ Inkscape::XML::Node *repr = sp_document_repr_root(doc);
+ repr->setAttribute("inkscape:output_extension", omod->get_id());
}
-
+
omod->save(doc, fileName);
g_free(fileName);
diff --git a/src/file.cpp b/src/file.cpp
index 6154fb97daac9cf22ae78066802d824927cfbffb..b350ce97b6e7756d8bf3cbc01276b095ee21efcc 100644 (file)
--- a/src/file.cpp
+++ b/src/file.cpp
/**
* 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 bAsCopy)
{
Inkscape::XML::Node *repr = sp_document_repr_root(doc);
Inkscape::UI::Dialog::FileSaveDialog::create(
save_loc,
Inkscape::UI::Dialog::SVG_TYPES,
- (char const *) _("Select file to save to"),
+ bAsCopy ? (char const *) _("Select file to save copy to") : (char const *) _("Select file to save to"),
default_extension
);
else
g_warning( "Error converting save filename to UTF-8." );
- success = file_save(doc, fileName, selectionType, TRUE);
+ success = file_save(doc, fileName, selectionType, TRUE, !bAsCopy);
if (success)
prefs_set_recent_file(SP_DOCUMENT_URI(doc), SP_DOCUMENT_NAME(doc));
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
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));
diff --git a/src/file.h b/src/file.h
index f86dc5a21be0bff21e1aa1f2b65bd4686f1eb699..4e128f16132c107b4ea414fcd14789a84b3f050b 100644 (file)
--- a/src/file.h
+++ b/src/file.h
*/
bool sp_file_save_as (gpointer object, gpointer data);
+/**
+ * Saves a copy of the given document. Displays a file select dialog
+ * to choose a name for the copy.
+ */
+bool sp_file_save_a_copy (gpointer object, gpointer data);
+
+
/**
* Saves the given document. Displays a file select dialog
* if needed.
bool sp_file_save_document (SPDocument *document);
/* Do the saveas dialog with a document as the parameter */
-bool sp_file_save_dialog (SPDocument *doc);
+bool sp_file_save_dialog (SPDocument *doc, bool bAsCopy = FALSE);
/*######################
diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h
index f25ca742c4da80b79a7af13ed671a319ab71682d..7d97967d662c43051b5cd07b2b6585695bbabfb9 100644 (file)
--- a/src/menus-skeleton.h
+++ b/src/menus-skeleton.h
" <verb verb-id=\"FileRevert\" />\n"
" <verb verb-id=\"FileSave\" />\n"
" <verb verb-id=\"FileSaveAs\" />\n"
+" <verb verb-id=\"FileSaveACopy\" />\n"
" <separator/>\n"
" <verb verb-id=\"FileImport\" />\n"
" <verb verb-id=\"FileExport\" />\n"
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 409a332b990d2ddd7667dae5c53a17873f513cec..d30cba2b933be841868a5225fb7834c764202955 100644 (file)
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
case SP_VERB_FILE_SAVE_AS:
sp_file_save_as(NULL, NULL);
break;
+ case SP_VERB_FILE_SAVE_A_COPY:
+ sp_file_save_a_copy(NULL, NULL);
+ break;
case SP_VERB_FILE_PRINT:
sp_file_print();
break;
GTK_STOCK_SAVE ),
new FileVerb(SP_VERB_FILE_SAVE_AS, "FileSaveAs", N_("Save _As..."),
N_("Save document under a new name"), GTK_STOCK_SAVE_AS ),
+ new FileVerb(SP_VERB_FILE_SAVE_A_COPY, "FileSaveACopy", N_("Save a Cop_y..."),
+ N_("Save a copy of the document under a new name"), NULL ),
new FileVerb(SP_VERB_FILE_PRINT, "FilePrint", N_("_Print..."), N_("Print document"),
GTK_STOCK_PRINT ),
// TRANSLATORS: "Vacuum Defs" means "Clean up defs" (so as to remove unused definitions)
diff --git a/src/verbs.h b/src/verbs.h
index fa232280b6b3ce914fa1e1534299fdf77d6db8c6..dacb3ec515b824bbf1c19ae17965a0daa3cbf4e6 100644 (file)
--- a/src/verbs.h
+++ b/src/verbs.h
SP_VERB_FILE_REVERT, /**< Revert this file to its original state. */
SP_VERB_FILE_SAVE, /**< Save the current file with its saved filename */
SP_VERB_FILE_SAVE_AS, /**< Save the current file with a new filename */
+ SP_VERB_FILE_SAVE_A_COPY, /**< Save a copy of the current file */
SP_VERB_FILE_PRINT,
SP_VERB_FILE_VACUUM,
SP_VERB_FILE_PRINT_DIRECT,