Code

fix 1633451: mark the help commands as not needing the document and avoid saving...
authorbuliabyak <buliabyak@users.sourceforge.net>
Fri, 12 Jan 2007 16:19:05 +0000 (16:19 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Fri, 12 Jan 2007 16:19:05 +0000 (16:19 +0000)
share/extensions/inkscape_help_commandline.inx
share/extensions/inkscape_help_faq.inx
share/extensions/inkscape_help_manual.inx
share/extensions/inkscape_help_relnotes.inx
share/extensions/inkscape_help_reportabug.inx
share/extensions/inkscape_help_svgspec.inx
src/extension/effect.cpp
src/extension/effect.h
src/extension/implementation/script.cpp

index 9fe1171c50b3aca52917689dd346a8351ad9053a..23771f857403ea5d22adf43e14ddbc93104d1611 100644 (file)
@@ -2,7 +2,7 @@
     <_name>Command Line Options</_name>
     <id>org.inkscape.help.commandline</id>
        <dependency type="executable" location="extensions">webbrowser_commandline.py</dependency>
-    <effect>
+    <effect needs-document="no">
                <object-type>all</object-type>
                <effects-menu hidden="yes"/>
     </effect>
index 58491b43db19fa80004cdb343d349e85c1c0136a..dae3700a6fc18aae2b664a502309090df9ba8578 100644 (file)
@@ -2,7 +2,7 @@
     <_name>FAQ</_name>
     <id>org.inkscape.help.faq</id>
        <dependency type="executable" location="extensions">webbrowser_faq.py</dependency>
-    <effect>
+    <effect needs-document="no">
                <object-type>all</object-type>
                <effects-menu hidden="yes"/>
     </effect>
index 5fd0e914196675415e26a4cf7b6d35db7a9e7811..1224f48c937524a156fbdcc806ac68d00ea45252 100644 (file)
@@ -2,7 +2,7 @@
     <_name>Inkscape Manual</_name>
     <id>org.inkscape.help.manual</id>
        <dependency type="executable" location="extensions">webbrowser_manual.py</dependency>
-    <effect>
+    <effect needs-document="no">
                <object-type>all</object-type>
                <effects-menu hidden="yes"/>
     </effect>
index 8fc3ff120d4265b4f1cd35a26cf7cef98dd6a06a..c01f5b35c287948e9ba0ba10c702e550a3450ee7 100644 (file)
@@ -2,7 +2,7 @@
     <_name>New in This Version</_name>
     <id>org.inkscape.help.relnotes</id>
        <dependency type="executable" location="extensions">webbrowser_relnotes.py</dependency>
-    <effect>
+    <effect needs-document="no">
                <object-type>all</object-type>
                <effects-menu hidden="yes"/>
     </effect>
index 47cc19cc50d30dd42e7452ba581839f555cad4fa..4bd4387b9a61663f5a087731186b8a07ac24a19e 100644 (file)
@@ -2,7 +2,7 @@
     <_name>Report a Bug</_name>
     <id>org.inkscape.help.reportabug</id>
        <dependency type="executable" location="extensions">webbrowser_reportabug.py</dependency>
-    <effect>
+    <effect needs-document="no">
                <object-type>all</object-type>
                <effects-menu hidden="yes"/>
     </effect>
index 1da3288e30e5d356c4ba09766b2cbd4bf823fa94..2757c69da79096a6d04b64c485d905b6bde89a04 100644 (file)
@@ -2,7 +2,7 @@
     <_name>SVG 1.1 Specification</_name>
     <id>org.inkscape.help.svgspec</id>
        <dependency type="executable" location="extensions">webbrowser_svgspec.py</dependency>
-    <effect>
+    <effect needs-document="no">
                <object-type>all</object-type>
                <effects-menu hidden="yes"/>
     </effect>
index 4e6c6fd79522af4730a7182a6ecf0350a9b828c0..93928d77e619376831625858478a45791a0a2209 100644 (file)
@@ -34,28 +34,32 @@ Effect::Effect (Inkscape::XML::Node * in_repr, Implementation::Implementation *
 
     bool hidden = false;
 
+    no_doc = false;
+
     if (repr != NULL) {
-        Inkscape::XML::Node * child_repr;
 
-        for (child_repr = sp_repr_children(repr); child_repr != NULL; child_repr = child_repr->next()) {
-            if (!strcmp(child_repr->name(), "effect")) {
-                for (child_repr = sp_repr_children(child_repr); child_repr != NULL; child_repr = child_repr->next()) {
-                    if (!strcmp(child_repr->name(), "effects-menu")) {
+        for (Inkscape::XML::Node *child = sp_repr_children(repr); child != NULL; child = child->next()) {
+            if (!strcmp(child->name(), "effect")) {
+                if (child->attribute("needs-document") && !strcmp(child->attribute("needs-document"), "no")) {
+                  no_doc = true;
+                }
+                for (Inkscape::XML::Node *effect_child = sp_repr_children(child); effect_child != NULL; effect_child = effect_child->next()) {
+                    if (!strcmp(effect_child->name(), "effects-menu")) {
                         // printf("Found local effects menu in %s\n", this->get_name());
-                        local_effects_menu = sp_repr_children(child_repr);
-                        if (child_repr->attribute("hidden") && !strcmp(child_repr->attribute("hidden"), "yes")) {
+                        local_effects_menu = sp_repr_children(effect_child);
+                        if (effect_child->attribute("hidden") && !strcmp(effect_child->attribute("hidden"), "yes")) {
                             hidden = true;
                         }
                     }
-                    if (!strcmp(child_repr->name(), "menu-name") ||
-                            !strcmp(child_repr->name(), "_menu-name")) {
+                    if (!strcmp(effect_child->name(), "menu-name") ||
+                            !strcmp(effect_child->name(), "_menu-name")) {
                         // printf("Found local effects menu in %s\n", this->get_name());
-                        _verb.set_name(sp_repr_children(child_repr)->content());
+                        _verb.set_name(sp_repr_children(effect_child)->content());
                     }
-                    if (!strcmp(child_repr->name(), "menu-tip") ||
-                            !strcmp(child_repr->name(), "_menu-tip")) {
+                    if (!strcmp(effect_child->name(), "menu-tip") ||
+                            !strcmp(effect_child->name(), "_menu-tip")) {
                         // printf("Found local effects menu in %s\n", this->get_name());
-                        _verb.set_tip(sp_repr_children(child_repr)->content());
+                        _verb.set_tip(sp_repr_children(effect_child)->content());
                     }
                 } // children of "effect"
                 break; // there can only be one effect
index 493af142b653e398a9ad66ac83f18510540c603b..c0231eac40f5ed89ee2b42e8b9c565418b88b41c 100644 (file)
@@ -94,6 +94,8 @@ public:
 
     Gtk::VBox *    get_info_widget(void);
 
+    bool no_doc; // if true, the effect does not process SVG document at all, so no need to save, read, and watch for errors
+
 private:
     static gchar *   remove_ (gchar * instr);
 };
index 1de6504f150ad94b2c327e8bf06521d6f5f6078d..dbfd685dd0319c943e6bf08bfabb03220ef5da37 100644 (file)
@@ -33,6 +33,7 @@
 #include "extension/output.h"
 #include "extension/db.h"
 #include "script.h"
+#include "dialogs/dialog-events.h"
 
 #include "util/glib-list-iterators.h"
 
@@ -696,7 +697,18 @@ Script::save(Inkscape::Extension::Output *module,
 void
 Script::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc)
 {
-    SPDocument * mydoc = NULL;
+    if (module->no_doc) { 
+        // this is a no-doc extension, e.g. a Help menu command; 
+        // just run the command without any files, ignoring errors
+        Glib::ustring local_command(command);
+        Glib::ustring paramString = *module->paramString();
+        local_command.append(paramString);
+
+        Glib::ustring empty;
+        execute(local_command, empty, empty);
+
+        return;
+    }
 
     gchar *tmpname;
     // FIXME: process the GError instead of passing NULL
@@ -769,6 +781,7 @@ Script::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *do
 
     int data_read = execute(local_command, tempfilename_in, tempfilename_out);
 
+    SPDocument * mydoc = NULL;
     if (data_read > 10)
         mydoc = Inkscape::Extension::open(
               Inkscape::Extension::db.get(SP_MODULE_KEY_INPUT_SVG),
@@ -874,7 +887,6 @@ private:
 
 
 /**
-    \return   none
     \brief    This is the core of the extension file as it actually does
               the execution of the extension.
     \param    in_command  The command to be executed
@@ -923,9 +935,12 @@ Script::execute (const Glib::ustring &in_command,
     g_free(tmpname);
 
     Glib::ustring localCommand = in_command;
-    localCommand .append(" \"");
-    localCommand .append(filein);
-    localCommand .append("\"");
+
+    if (!(filein.empty())) {
+        localCommand .append(" \"");
+        localCommand .append(filein);
+        localCommand .append("\"");
+    }
 
     // std::cout << "Command to run: " << command << std::endl;
 
@@ -947,6 +962,15 @@ Script::execute (const Glib::ustring &in_command,
         return 0;
     }
 
+    if (fileout.empty()) { // no output file to create; just close everything and return 0
+        if (errorFile.size()>0) {
+            unlink(errorFile.c_str());
+        }
+        pipe.close();
+        return 0;
+    }
+
+    /* Copy pipe output to fileout (temporary file) */
     Inkscape::IO::dump_fopen_call(fileout.c_str(), "J");
     FILE *pfile = Inkscape::IO::fopen_utf8name(fileout.c_str(), "w");
 
@@ -960,7 +984,6 @@ Script::execute (const Glib::ustring &in_command,
         return 0;
     }
 
-    /* Copy pipe output to a temporary file */
     int amount_read = 0;
     char buf[BUFSIZE];
     int num_read;
@@ -1039,6 +1062,8 @@ Script::checkStderr (const Glib::ustring &filename,
 
     Gtk::MessageDialog warning(message, false, type, Gtk::BUTTONS_OK, true);
     warning.set_resizable(true);
+    GtkWidget *dlg = GTK_WIDGET(warning.gobj());
+    sp_transientize(dlg);
 
     Gtk::VBox * vbox = warning.get_vbox();