summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon Phillips <jon@fabricatorz.com>2006-08-22 08:01:11 +0000
committerkidproto <kidproto@users.sourceforge.net>2006-08-22 08:01:11 +0000
commite776d44fd7a3035665e622f71a135c1f275b3708 (patch)
tree27de3f9fbc77d2cc73c87deb98aed2d9bb2f398a /src
parentI renamed the adobe-illustrator-cs2.xml and macromedia-freehand-mx.xml to better (diff)
downloadinkscape-e776d44fd7a3035665e622f71a135c1f275b3708.tar.gz
inkscape-e776d44fd7a3035665e622f71a135c1f275b3708.zip
Committed a great patch which adds a Save A Copy menu function. This is the first gloss of this patch...I will add more stuff to it shortly...
(bzr r1628)
Diffstat (limited to 'src')
-rw-r--r--src/extension/output.cpp4
-rw-r--r--src/extension/system.cpp7
-rw-r--r--src/file.cpp39
-rw-r--r--src/file.h9
-rw-r--r--src/menus-skeleton.h1
-rw-r--r--src/verbs.cpp5
-rw-r--r--src/verbs.h1
7 files changed, 51 insertions, 15 deletions
diff --git a/src/extension/output.cpp b/src/extension/output.cpp
index eb3f85ed8..b0f254a9c 100644
--- a/src/extension/output.cpp
+++ b/src/extension/output.cpp
@@ -221,7 +221,7 @@ Output::save (SPDocument * doc, const gchar * uri)
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;
@@ -239,7 +239,7 @@ Output::save (SPDocument * doc, const gchar * uri)
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");
}
diff --git a/src/extension/system.cpp b/src/extension/system.cpp
index 81bf3075e..3a8a54214 100644
--- 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 6154fb97d..b350ce97b 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -484,10 +484,13 @@ sp_file_vacuum()
/**
* 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;
@@ -495,7 +498,7 @@ file_save(SPDocument *doc, const Glib::ustring &uri,
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);
@@ -528,9 +531,11 @@ static Inkscape::UI::Dialog::FileSaveDialog *saveDialogInstance = NULL;
/**
* 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);
@@ -600,7 +605,7 @@ sp_file_save_dialog(SPDocument *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
);
@@ -622,7 +627,7 @@ sp_file_save_dialog(SPDocument *doc)
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));
@@ -650,14 +655,14 @@ sp_file_save_document(SPDocument *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 {
@@ -691,11 +696,23 @@ sp_file_save_as(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);
+ 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
@@ -991,7 +1008,7 @@ sp_file_export_dialog(void *widget)
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 f86dc5a21..4e128f161 100644
--- a/src/file.h
+++ b/src/file.h
@@ -90,13 +90,20 @@ bool sp_file_save (gpointer object, gpointer data);
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 f25ca742c..7d97967d6 100644
--- a/src/menus-skeleton.h
+++ b/src/menus-skeleton.h
@@ -25,6 +25,7 @@ static char const menus_skeleton[] =
" <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 409a332b9..d30cba2b9 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -798,6 +798,9 @@ FileVerb::perform(SPAction *action, void *data, void *pdata)
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;
@@ -1943,6 +1946,8 @@ Verb *Verb::_base_verbs[] = {
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 fa232280b..dacb3ec51 100644
--- a/src/verbs.h
+++ b/src/verbs.h
@@ -31,6 +31,7 @@ enum {
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,