From: buliabyak Date: Fri, 12 Jan 2007 16:19:05 +0000 (+0000) Subject: fix 1633451: mark the help commands as not needing the document and avoid saving... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1c9da5b87484b8b0ae5b6bce141ee9c4ff8d14ad;p=inkscape.git fix 1633451: mark the help commands as not needing the document and avoid saving/reading/parsing errors when running them --- diff --git a/share/extensions/inkscape_help_commandline.inx b/share/extensions/inkscape_help_commandline.inx index 9fe1171c5..23771f857 100644 --- a/share/extensions/inkscape_help_commandline.inx +++ b/share/extensions/inkscape_help_commandline.inx @@ -2,7 +2,7 @@ <_name>Command Line Options org.inkscape.help.commandline webbrowser_commandline.py - + all diff --git a/share/extensions/inkscape_help_faq.inx b/share/extensions/inkscape_help_faq.inx index 58491b43d..dae3700a6 100644 --- a/share/extensions/inkscape_help_faq.inx +++ b/share/extensions/inkscape_help_faq.inx @@ -2,7 +2,7 @@ <_name>FAQ org.inkscape.help.faq webbrowser_faq.py - + all diff --git a/share/extensions/inkscape_help_manual.inx b/share/extensions/inkscape_help_manual.inx index 5fd0e9141..1224f48c9 100644 --- a/share/extensions/inkscape_help_manual.inx +++ b/share/extensions/inkscape_help_manual.inx @@ -2,7 +2,7 @@ <_name>Inkscape Manual org.inkscape.help.manual webbrowser_manual.py - + all diff --git a/share/extensions/inkscape_help_relnotes.inx b/share/extensions/inkscape_help_relnotes.inx index 8fc3ff120..c01f5b35c 100644 --- a/share/extensions/inkscape_help_relnotes.inx +++ b/share/extensions/inkscape_help_relnotes.inx @@ -2,7 +2,7 @@ <_name>New in This Version org.inkscape.help.relnotes webbrowser_relnotes.py - + all diff --git a/share/extensions/inkscape_help_reportabug.inx b/share/extensions/inkscape_help_reportabug.inx index 47cc19cc5..4bd4387b9 100644 --- a/share/extensions/inkscape_help_reportabug.inx +++ b/share/extensions/inkscape_help_reportabug.inx @@ -2,7 +2,7 @@ <_name>Report a Bug org.inkscape.help.reportabug webbrowser_reportabug.py - + all diff --git a/share/extensions/inkscape_help_svgspec.inx b/share/extensions/inkscape_help_svgspec.inx index 1da3288e3..2757c69da 100644 --- a/share/extensions/inkscape_help_svgspec.inx +++ b/share/extensions/inkscape_help_svgspec.inx @@ -2,7 +2,7 @@ <_name>SVG 1.1 Specification org.inkscape.help.svgspec webbrowser_svgspec.py - + all diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index 4e6c6fd79..93928d77e 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -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 diff --git a/src/extension/effect.h b/src/extension/effect.h index 493af142b..c0231eac4 100644 --- a/src/extension/effect.h +++ b/src/extension/effect.h @@ -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); }; diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 1de6504f1..dbfd685dd 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -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();