summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2007-01-12 16:19:05 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2007-01-12 16:19:05 +0000
commit6c1b4f1bf3d31fde6158f1c040088b47055f97d0 (patch)
treeca0d9350681377e08f420d0ef4d7a29a700601f6 /src
parentadded new perspective script's inx file to POTFILES.in (diff)
downloadinkscape-6c1b4f1bf3d31fde6158f1c040088b47055f97d0.tar.gz
inkscape-6c1b4f1bf3d31fde6158f1c040088b47055f97d0.zip
fix 1633451: mark the help commands as not needing the document and avoid saving/reading/parsing errors when running them
(bzr r2194)
Diffstat (limited to 'src')
-rw-r--r--src/extension/effect.cpp30
-rw-r--r--src/extension/effect.h2
-rw-r--r--src/extension/implementation/script.cpp37
3 files changed, 50 insertions, 19 deletions
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();