summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2017-12-25 23:46:18 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2017-12-25 23:46:18 +0000
commit60efec48f2861fba5e02ca4fff61bfdcef33f56f (patch)
tree2dbcec0c9c8d1453c422c10a53d691203f18e965 /src/extension
parentFix start anchors (diff)
parentMerge about-box Gtkmm changes (diff)
downloadinkscape-60efec48f2861fba5e02ca4fff61bfdcef33f56f.tar.gz
inkscape-60efec48f2861fba5e02ca4fff61bfdcef33f56f.zip
Merge branch 'master' into powerpencilII
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/effect.cpp7
-rw-r--r--src/extension/effect.h1
-rw-r--r--src/extension/execution-env.cpp13
-rw-r--r--src/extension/execution-env.h8
-rw-r--r--src/extension/extension.cpp1
-rw-r--r--src/extension/extension.h4
-rw-r--r--src/extension/implementation/script.cpp18
-rw-r--r--src/extension/implementation/script.h9
-rw-r--r--src/extension/internal/cairo-ps-out.cpp3
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.cpp3
-rw-r--r--src/extension/internal/latex-text-renderer.cpp5
-rw-r--r--src/extension/output.cpp7
-rw-r--r--src/extension/output.h5
-rw-r--r--src/extension/param/float.cpp5
-rw-r--r--src/extension/param/int.cpp5
-rw-r--r--src/extension/prefdialog.cpp4
-rw-r--r--src/extension/system.cpp2
17 files changed, 78 insertions, 22 deletions
diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp
index ef254f623..93b940732 100644
--- a/src/extension/effect.cpp
+++ b/src/extension/effect.cpp
@@ -274,6 +274,7 @@ Effect::effect (Inkscape::UI::View::View * doc)
ExecutionEnv executionEnv(this, doc);
+ execution_env = &executionEnv;
timer->lock();
executionEnv.run();
if (executionEnv.wait()) {
@@ -352,6 +353,12 @@ Effect::get_info_widget(void)
return Extension::get_info_widget();
}
+PrefDialog *
+Effect::get_pref_dialog (void)
+{
+ return _prefDialog;
+}
+
void
Effect::set_pref_dialog (PrefDialog * prefdialog)
{
diff --git a/src/extension/effect.h b/src/extension/effect.h
index a14cc6e7d..143243a2e 100644
--- a/src/extension/effect.h
+++ b/src/extension/effect.h
@@ -125,6 +125,7 @@ public:
bool no_doc; // if true, the effect does not process SVG document at all, so no need to save, read, and watch for errors
bool no_live_preview; // if true, the effect does not need "live preview" checkbox in its dialog
+ PrefDialog *get_pref_dialog (void);
void set_pref_dialog (PrefDialog * prefdialog);
private:
static gchar * remove_ (gchar * instr);
diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp
index f75b06937..588543a76 100644
--- a/src/extension/execution-env.cpp
+++ b/src/extension/execution-env.cpp
@@ -12,7 +12,8 @@
#include <config.h>
#endif
-#include "gtkmm/messagedialog.h"
+#include <gtkmm/dialog.h>
+#include <gtkmm/messagedialog.h>
#include "execution-env.h"
#include "prefdialog.h"
@@ -141,7 +142,15 @@ ExecutionEnv::createWorkingDialog (void) {
g_free(dlgmessage);
if (!_effect->is_silent()){
- _visibleDialog->show();
+ Gtk::Dialog *dlg = _effect->get_pref_dialog();
+ if (dlg) {
+ _visibleDialog->set_transient_for(*dlg);
+ } else {
+ // ToDo: Do we need to make the window transient for the main window here?
+ // Currently imossible to test because of GUI freezing during save,
+ // see https://bugs.launchpad.net/inkscape/+bug/967416
+ }
+ _visibleDialog->show_now();
}
return;
diff --git a/src/extension/execution-env.h b/src/extension/execution-env.h
index a57c7b8c9..b1a3a8ea2 100644
--- a/src/extension/execution-env.h
+++ b/src/extension/execution-env.h
@@ -98,15 +98,13 @@ public:
/** \brief Wait for the effect to complete if it hasn't. */
bool wait (void);
+ /** \brief Return reference to working dialog (if any) */
+ Gtk::Dialog *get_working_dialog (void) { return _visibleDialog; };
+
private:
void runComplete (void);
- void createPrefsDialog (Gtk::Widget * controls);
void createWorkingDialog (void);
void workingCanceled (const int resp);
- void processingCancel (void);
- void processingComplete(void);
- void documentCancel (void);
- void documentCommit (void);
void reselect (void);
void genDocCache (void);
void killDocCache (void);
diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp
index 240d28a59..49ae0075c 100644
--- a/src/extension/extension.cpp
+++ b/src/extension/extension.cpp
@@ -57,6 +57,7 @@ Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementat
: _help(NULL)
, silent(false)
, _gui(true)
+ , execution_env(NULL)
{
repr = in_repr;
Inkscape::GC::anchor(in_repr);
diff --git a/src/extension/extension.h b/src/extension/extension.h
index 9ccc9869b..a00eca21f 100644
--- a/src/extension/extension.h
+++ b/src/extension/extension.h
@@ -71,6 +71,7 @@ class SPDocument;
namespace Inkscape {
namespace Extension {
+class ExecutionEnv;
class Dependency;
class ExpirationTimer;
class ExpirationTimer;
@@ -109,6 +110,7 @@ private:
protected:
Inkscape::XML::Node *repr; /**< The XML description of the Extension */
Implementation::Implementation * imp; /**< An object that holds all the functions for making this work */
+ ExecutionEnv * execution_env; /**< Execution environment of the extension (currently only used by Effects) */
ExpirationTimer * timer; /**< Timeout to unload after a given time */
public:
@@ -130,6 +132,8 @@ public:
bool deactivated (void);
void printFailure (Glib::ustring reason);
Implementation::Implementation * get_imp (void) { return imp; };
+ void set_execution_env (ExecutionEnv * env) { execution_env = env; };
+ ExecutionEnv *get_execution_env (void) { return execution_env; };
/* Parameter Stuff */
private:
diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp
index 0f0a79bfb..260204cb0 100644
--- a/src/extension/implementation/script.cpp
+++ b/src/extension/implementation/script.cpp
@@ -28,6 +28,7 @@
#include "desktop.h"
#include "ui/dialog-events.h"
#include "extension/effect.h"
+#include "extension/execution-env.h"
#include "extension/output.h"
#include "extension/input.h"
#include "extension/db.h"
@@ -145,9 +146,10 @@ std::string Script::resolveInterpreterExecutable(const Glib::ustring &interpName
officially in the load function. This allows for less allocation
of memory in the unloaded state.
*/
-Script::Script() :
- Implementation(),
- _canceled(false)
+Script::Script()
+ : Implementation()
+ , _canceled(false)
+ , parent_window(NULL)
{
}
@@ -652,6 +654,8 @@ void Script::effect(Inkscape::Extension::Effect *module,
std::list<std::string> params;
module->paramListString(params);
+ parent_window = module->get_execution_env()->get_working_dialog();
+
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
@@ -741,7 +745,7 @@ void Script::effect(Inkscape::Extension::Effect *module,
Gtk::MessageDialog warning(
_("The output from the extension could not be parsed."),
false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
- warning.set_transient_for( *(INKSCAPE.active_desktop()->getToplevel()) );
+ warning.set_transient_for( parent_window ? *parent_window : *(INKSCAPE.active_desktop()->getToplevel()) );
warning.run();
}
} // data_read
@@ -932,7 +936,11 @@ void Script::checkStderr (const Glib::ustring &data,
Gtk::MessageDialog warning(message, false, type, Gtk::BUTTONS_OK, true);
warning.set_resizable(true);
GtkWidget *dlg = GTK_WIDGET(warning.gobj());
- sp_transientize(dlg);
+ if (parent_window) {
+ warning.set_transient_for(*parent_window);
+ } else {
+ sp_transientize(dlg);
+ }
auto vbox = warning.get_content_area();
diff --git a/src/extension/implementation/script.h b/src/extension/implementation/script.h
index 684719895..c6ae117c7 100644
--- a/src/extension/implementation/script.h
+++ b/src/extension/implementation/script.h
@@ -15,6 +15,7 @@
#include "implementation.h"
#include <gtkmm/enums.h>
+#include <gtkmm/window.h>
#include <glibmm/main.h>
#include <glibmm/spawn.h>
#include <glibmm/fileutils.h>
@@ -66,6 +67,14 @@ private:
*/
Glib::ustring helper_extension;
+ /**
+ * The window which should be considered as "parent window" of the script execution,
+ * e.g. when showin warning messages
+ *
+ * If set to NULL the main window of the currently active document is used.
+ */
+ Gtk::Window *parent_window;
+
std::string solve_reldir(Inkscape::XML::Node *repr_in);
bool check_existence (std::string const& command);
void copy_doc(Inkscape::XML::Node * olddoc, Inkscape::XML::Node * newdoc);
diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp
index e8f47e79e..57169ed45 100644
--- a/src/extension/internal/cairo-ps-out.cpp
+++ b/src/extension/internal/cairo-ps-out.cpp
@@ -76,6 +76,9 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
if (exportId && strcmp(exportId, "")) {
// we want to export the given item only
base = SP_ITEM(doc->getObjectById(exportId));
+ if (!base) {
+ throw Inkscape::Extension::Output::export_id_not_found(exportId);
+ }
pageBoundingBox = exportCanvas;
}
else {
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index 5576676b2..865de1a07 100644
--- a/src/extension/internal/cairo-renderer-pdf-out.cpp
+++ b/src/extension/internal/cairo-renderer-pdf-out.cpp
@@ -71,6 +71,9 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
if (exportId && strcmp(exportId, "")) {
// we want to export the given item only
base = SP_ITEM(doc->getObjectById(exportId));
+ if (!base) {
+ throw Inkscape::Extension::Output::export_id_not_found(exportId);
+ }
pageBoundingBox = exportCanvas;
}
else {
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp
index 7a1cacbf2..960aec7a9 100644
--- a/src/extension/internal/latex-text-renderer.cpp
+++ b/src/extension/internal/latex-text-renderer.cpp
@@ -41,6 +41,7 @@
#include "util/units.h"
+#include "extension/output.h"
#include "extension/system.h"
#include "inkscape-version.h"
@@ -68,7 +69,9 @@ latex_render_document_text_to_file( SPDocument *doc, gchar const *filename,
if (exportId && strcmp(exportId, "")) {
// we want to export the given item only
base = dynamic_cast<SPItem *>(doc->getObjectById(exportId));
- g_assert(base != NULL);
+ if (!base) {
+ throw Inkscape::Extension::Output::export_id_not_found(exportId);
+ }
pageBoundingBox = exportCanvas;
}
else {
diff --git a/src/extension/output.cpp b/src/extension/output.cpp
index 83f0fed2f..ccfee2c14 100644
--- a/src/extension/output.cpp
+++ b/src/extension/output.cpp
@@ -213,12 +213,7 @@ Output::prefs (void)
void
Output::save(SPDocument *doc, gchar const *filename)
{
- try {
- imp->save(this, doc, filename);
- }
- catch (...) {
- throw Inkscape::Extension::Output::save_failed();
- }
+ imp->save(this, doc, filename);
return;
}
diff --git a/src/extension/output.h b/src/extension/output.h
index 44a731ca0..420eb9245 100644
--- a/src/extension/output.h
+++ b/src/extension/output.h
@@ -31,6 +31,11 @@ public:
class save_cancelled {}; /**< Saving was cancelled */
class no_extension_found {}; /**< Failed because we couldn't find an extension to match the filename */
class file_read_only {}; /**< The existing file can not be opened for writing */
+ class export_id_not_found { /**< The object ID requested for export could not be found in the document */
+ public:
+ const gchar * const id;
+ export_id_not_found(const gchar * const id = NULL) : id{id} {};
+ };
Output (Inkscape::XML::Node * in_repr,
Implementation::Implementation * in_imp);
diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp
index 69283a572..1dd3f073b 100644
--- a/src/extension/param/float.cpp
+++ b/src/extension/param/float.cpp
@@ -178,7 +178,10 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod
if (_mode == FULL) {
- UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_text, fadjust, _precision);
+ Glib::ustring text;
+ if (_text != NULL)
+ text = _text;
+ UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(text, fadjust, _precision);
scale->set_size_request(400, -1);
scale->show();
hbox->pack_start(*scale, true, true);
diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp
index 357f98590..9ad9b591c 100644
--- a/src/extension/param/int.cpp
+++ b/src/extension/param/int.cpp
@@ -159,7 +159,10 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal
if (_mode == FULL) {
- UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_text, fadjust, 0);
+ Glib::ustring text;
+ if (_text != NULL)
+ text = _text;
+ UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(text, fadjust, 0);
scale->set_size_request(400, -1);
scale->show();
hbox->pack_start(*scale, true, true);
diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp
index 92ddd3050..0247e18e9 100644
--- a/src/extension/prefdialog.cpp
+++ b/src/extension/prefdialog.cpp
@@ -131,6 +131,7 @@ PrefDialog::~PrefDialog ( )
_exEnv->cancel();
delete _exEnv;
_exEnv = NULL;
+ _effect->set_execution_env(_exEnv);
}
if (_effect != NULL) {
@@ -173,6 +174,7 @@ PrefDialog::preview_toggle (void) {
set_modal(true);
if (_exEnv == NULL) {
_exEnv = new ExecutionEnv(_effect, SP_ACTIVE_DESKTOP, NULL, false, false);
+ _effect->set_execution_env(_exEnv);
_exEnv->run();
}
} else {
@@ -182,6 +184,7 @@ PrefDialog::preview_toggle (void) {
_exEnv->undo();
delete _exEnv;
_exEnv = NULL;
+ _effect->set_execution_env(_exEnv);
}
}
}
@@ -230,6 +233,7 @@ PrefDialog::on_response (int signal) {
}
delete _exEnv;
_exEnv = NULL;
+ _effect->set_execution_env(_exEnv);
}
}
diff --git a/src/extension/system.cpp b/src/extension/system.cpp
index e5b83cd20..888a1076a 100644
--- a/src/extension/system.cpp
+++ b/src/extension/system.cpp
@@ -330,7 +330,7 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
g_free(fileName);
- throw Inkscape::Extension::Output::save_failed();
+ throw;
}
// If it is an unofficial save, set the modified attributes back to what they were.