Code

I added Johan's badass patch for save a copy with the features I requested.
authorkidproto <kidproto@users.sourceforge.net>
Tue, 22 Aug 2006 21:24:21 +0000 (21:24 +0000)
committerkidproto <kidproto@users.sourceforge.net>
Tue, 22 Aug 2006 21:24:21 +0000 (21:24 +0000)
Now it all works quite well! Great!

src/extension/output.cpp
src/extension/output.h
src/extension/system.cpp
src/file.cpp
src/file.h
src/ui/dialog/filedialog.cpp
src/ui/dialog/filedialog.h
src/verbs.cpp
src/verbs.h

index b0f254a9c07afbacd205bcb2f99f8c1fa5a8a4dc..3f8c17fb1c51867bb739c98f6a8e6bfc615dea0d 100644 (file)
@@ -2,6 +2,7 @@
  * Authors:
  *   Ted Gould <ted@gould.cx>
  *
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
  * Copyright (C) 2002-2004 Authors
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
@@ -206,45 +207,17 @@ Output::prefs (void)
        only used at runtime and shouldn't be saved.  One that may surprise
        people is the output extension.  This is not saved so that the IDs
        could be changed, and old files will still work properly.
-
-       After the file is saved by the implmentation the output_extension
-       and dataloss variables are recreated.  The output_extension is set
-       to this extension so that future saves use this extension.  Dataloss
-       is set so that a warning will occur on closing the document that
-       there may be some dataloss from this extension.
 */
 void
 Output::save (SPDocument * doc, const gchar * uri)
 {
-       bool modified = false;
-       Inkscape::XML::Node * repr = sp_document_repr_root(doc);
-
-        gboolean saved = sp_document_get_undo_sensitive(doc);
-       sp_document_set_undo_sensitive (doc, FALSE);
-       //repr->setAttribute("inkscape:output_extension", NULL);
-       repr->setAttribute("inkscape:dataloss", NULL);
-       if (repr->attribute("sodipodi:modified") != NULL)
-               modified = true;
-       repr->setAttribute("sodipodi:modified", NULL);
-       sp_document_set_undo_sensitive (doc, saved);
-
         try {
             imp->save(this, doc, uri);
         }
         catch (...) {
-            if (modified)
-                repr->setAttribute("sodipodi:modified", "true");
             throw;
         }
 
-        saved = sp_document_get_undo_sensitive(doc);
-       sp_document_set_undo_sensitive (doc, FALSE);
-       //repr->setAttribute("inkscape:output_extension", get_id());
-       if (dataloss) {
-               repr->setAttribute("inkscape:dataloss", "true");
-       }
-       sp_document_set_undo_sensitive (doc, saved);
-
        return;
 }
 
index 41bca6a7b3cb0d3bd708eff81f457192ecd5afa3..f6f16fb85167a299f494d1463d3195044dae1187 100644 (file)
@@ -2,6 +2,7 @@
  * Authors:
  *   Ted Gould <ted@gould.cx>
  *
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
  * Copyright (C) 2002-2004 Authors
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
@@ -41,6 +42,7 @@ public:
     gchar *      get_extension(void);
     gchar *      get_filetypename(void);
     gchar *      get_filetypetooltip(void);
+    bool         causes_dataloss(void) { return dataloss; };
 };
 
 } }  /* namespace Inkscape, Extension */
index 3a8a54214091593958ebae8df05eeca66e91af1d..41d6e7513666a94e1f75166e02e974f2ff0c3e24 100644 (file)
@@ -7,6 +7,7 @@
  * Authors:
  *   Ted Gould <ted@gould.cx>
  *
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
  * Copyright (C) 2002-2004 Authors
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
@@ -244,17 +245,25 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
         throw Output::no_overwrite();
     }
 
-    // if 'official' save the filename and extension for future saves.
+    omod->save(doc, fileName);
+
     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());
+        gboolean saved = sp_document_get_undo_sensitive(doc);
+            // also save the extension for next use
+            Inkscape::XML::Node *repr = sp_document_repr_root(doc);
+               sp_document_set_undo_sensitive (doc, FALSE);
+            repr->setAttribute("inkscape:output_extension", omod->get_id());
+            // set the "dataloss" attribute if the chosen extension is lossy
+           repr->setAttribute("inkscape:dataloss", NULL);
+            if ( omod->causes_dataloss() ) {
+                   repr->setAttribute("inkscape:dataloss", "true");
+            }
+            repr->setAttribute("sodipodi:modified", NULL);
+       sp_document_set_undo_sensitive (doc, saved);
     }
     
-    omod->save(doc, fileName);
-
     g_free(fileName);
     return;
 }
index 4bb5763b6f74a831c5f6e48bd468fef000977094..de8ab2b5dca10285da5f7dc6a333c7da185d8d36 100644 (file)
@@ -8,9 +8,10 @@
  *   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
  */
@@ -600,15 +601,22 @@ sp_file_save_dialog(SPDocument *doc, bool is_copy)
         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(
                  save_loc,
                  Inkscape::UI::Dialog::SVG_TYPES,
-                 is_copy ? (char const *) _("Select file to save copy to") : (char const *) _("Select file to save to"),
+                 (char const *) _("Select file to save to"),
                  default_extension
             );
-
+    saveDialogInstance->change_title(dialog_title);
+    
     bool success = saveDialogInstance->show();
     if (!success)
         return success;
index 4e128f16132c107b4ea414fcd14789a84b3f050b..18e4068a1535819cee2562e1acce68ce31c68cdd 100644 (file)
@@ -8,8 +8,9 @@
  *   Lauris Kaplinski <lauris@kaplinski.com>
  *   Chema Celorio <chema@celorio.com>
  *
- * Copyright (C) 1999-2002 Authors
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
  * Copyright (C) 2001-2002 Ximian, Inc.
+ * Copyright (C) 1999-2002 Authors
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
index 0e8a8a07b33b11077d3279100521cbe3ba22820a..3417ba06c929fd09d0369b2f1e317c084c43abf5 100644 (file)
@@ -5,6 +5,7 @@
  *   Bob Jamison
  *   Other dudes from The Inkscape Organization
  *
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
  * Copyright (C) 2004-2006 The Inkscape Organization
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
@@ -1136,6 +1137,8 @@ public:
 
     Glib::ustring getFilename();
 
+    void change_title(const Glib::ustring& title);
+
 
 private:
 
@@ -1510,6 +1513,12 @@ FileSaveDialogImpl::getFilename()
 }
 
 
+void 
+FileSaveDialogImpl::change_title(const Glib::ustring& title)
+{
+    this->set_title(title);
+}
+
 
 
 
index ace3361776068993c82751f3dbbc0d4a229dae0c..daefc9387c9c9ac74dca442a5be9fb6f4c3ec410 100644 (file)
@@ -8,6 +8,7 @@
  *   Bob Jamison <rwjj@earthlink.net>
  *   Inkscape Guys
  *
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
  * Copyright (C) 2004-2006, Inkscape Authors
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
@@ -166,6 +167,11 @@ public:
 
     virtual Glib::ustring getFilename () =0;
 
+    /**
+     * Change the window title.
+     */
+    virtual void change_title(const Glib::ustring& title) =0;
+
 
 }; //FileSaveDialog
 
index d30cba2b933be841868a5225fb7834c764202955..e32727d2d9a9895adce4c7554da131fc1e7ff44a 100644 (file)
@@ -17,6 +17,8 @@
  *   David Turner <novalis@gnu.org>
  *   bulia byak <buliabyak@users.sf.net>
  *
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
+ * Copyright (C) (date unspecified) Authors
  * This code is in public domain.
  */
 
index dacb3ec515b824bbf1c19ae17965a0daa3cbf4e6..2055ac2eee82ae84e0b4fefbf7f302621c599d28 100644 (file)
@@ -9,6 +9,9 @@
  *   Ted Gould <ted@gould.cx>
  *   David Yip <yipdw@rose-hulman.edu>
  *
+ *  Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
+ *  Copyright (C) (date unspecified) Authors
  * This code is in public domain if done by Lauris
  * This code is GPL if done by Ted or David
  */