Code

Added missing (and very important) file.
[inkscape.git] / src / extension / output.cpp
index 5f740bbff0727e14a99e6c2937cc4cd37553620e..e1481d0002e7cdce122b6ed81f4d5a69a58139b0 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
@@ -48,10 +49,13 @@ Output::Output (Inkscape::XML::Node * in_repr, Implementation::Implementation *
         child_repr = sp_repr_children(repr);
 
         while (child_repr != NULL) {
-            if (!strcmp(child_repr->name(), "output")) {
+            if (!strcmp(child_repr->name(), INKSCAPE_EXTENSION_NS "output")) {
                 child_repr = sp_repr_children(child_repr);
                 while (child_repr != NULL) {
                     char const * chname = child_repr->name();
+                                       if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) {
+                                               chname += strlen(INKSCAPE_EXTENSION_NS);
+                                       }
                     if (chname[0] == '_') /* Allow _ for translation of tags */
                         chname++;
                     if (!strcmp(chname, "extension")) {
@@ -71,7 +75,7 @@ Output::Output (Inkscape::XML::Node * in_repr, Implementation::Implementation *
                         filetypetooltip = g_strdup(sp_repr_children(child_repr)->content());
                     }
                     if (!strcmp(chname, "dataloss")) {
-                        if (!strcmp(sp_repr_children(child_repr)->content(), "FALSE")) {
+                        if (!strcmp(sp_repr_children(child_repr)->content(), "false")) {
                                                        dataloss = FALSE;
                                                }
                                        }
@@ -182,7 +186,7 @@ Output::prefs (void)
         return true;
     }
 
-    PrefDialog * dialog = new PrefDialog(this->get_name(), controls);
+    PrefDialog * dialog = new PrefDialog(this->get_name(), this->get_help(), controls);
     int response = dialog->run();
     dialog->hide();
 
@@ -196,55 +200,27 @@ Output::prefs (void)
     \return  None
        \brief   Save a document as a file
        \param   doc  Document to save
-       \param   uri  File to save the document as
+       \param   filename  File to save the document as
 
        This function does a little of the dirty work involved in saving
        a document so that the implementation only has to worry about geting
        bits on the disk.
 
-       The big thing that it does is remove and readd the fields that are
+       The big thing that it does is remove and read the fields that are
        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)
+Output::save(SPDocument *doc, gchar const *filename)
 {
-       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);
+            imp->save(this, doc, filename);
         }
         catch (...) {
-            if (modified)
-                repr->setAttribute("sodipodi:modified", "true");
-            throw;
+            g_warning("There was an error saving the file.");
         }
 
-        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;
 }