diff options
| author | Eduard Braun <eduard.braun2@gmx.de> | 2017-12-20 23:11:30 +0000 |
|---|---|---|
| committer | Eduard Braun <eduard.braun2@gmx.de> | 2017-12-20 23:11:30 +0000 |
| commit | cabdde6554a95e6d0fee5ab39f850f7645df3cbb (patch) | |
| tree | f85847d899169d369929df0f570e40c871c5c361 /src/extension/implementation | |
| parent | Effects: make "Working..." dialog transient for preferences dialog (diff) | |
| download | inkscape-cabdde6554a95e6d0fee5ab39f850f7645df3cbb.tar.gz inkscape-cabdde6554a95e6d0fee5ab39f850f7645df3cbb.zip | |
Make script warnings transient for "Working..." dialog
This turned out to be a bit of a mess due to the interplay between
the classes Script / ExecutionEnv / Effect / PrefDialog.
(Basically they don't talk to each other much but all want to
contribute to the GUI)
Likely "Script" (and possibly "ExecutionEnv") should be refactored
to let the other classes handle UI exclusively and throw errors
where suitable.
Diffstat (limited to 'src/extension/implementation')
| -rw-r--r-- | src/extension/implementation/script.cpp | 18 | ||||
| -rw-r--r-- | src/extension/implementation/script.h | 9 |
2 files changed, 22 insertions, 5 deletions
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); |
