From 8462bb8a93d432c675b316679d4dc184f340ab5a Mon Sep 17 00:00:00 2001 From: gouldtj Date: Sat, 1 Sep 2007 04:32:10 +0000 Subject: [PATCH] r16340@tres: ted | 2007-08-20 19:02:50 -0700 Pinned is still not working, somewhat usable state. Worth checking in. --- src/extension/execution-env.cpp | 23 ++++++++++++++++++----- src/extension/execution-env.h | 3 ++- src/extension/prefdialog.cpp | 15 +++++++++++++++ src/extension/prefdialog.h | 2 ++ 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index adcd2a3d7..be3abcd41 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -28,7 +28,7 @@ namespace Inkscape { namespace Extension { -ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk::Widget * controls) : +ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk::Widget * controls, Gtk::Dialog * prefDialog) : _effect(effect), _visibleDialog(NULL), _prefsVisible(false), @@ -56,10 +56,15 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk _mainloop = Glib::MainLoop::create(false); - if (controls != NULL) { - createPrefsDialog(controls); + if (prefDialog == NULL) { + if (controls != NULL) { + createPrefsDialog(controls); + } else { + createWorkingDialog(); + } } else { - createWorkingDialog(); + _visibleDialog = prefDialog; + _prefsVisible = true; } return; @@ -224,7 +229,7 @@ void ExecutionEnv::livePreview (bool state) { _mainloop->quit(); if (_livePreview && !state) { - _canceled = true; + documentCancel(); } if (!_livePreview && state) { _humanWait = false; @@ -233,6 +238,14 @@ ExecutionEnv::livePreview (bool state) { return; } +void +ExecutionEnv::shutdown (void) { + _mainloop->quit(); + processingCancel(); + documentCancel(); + _finished = true; + _visibleDialog = NULL; +} } } /* namespace Inkscape, Extension */ diff --git a/src/extension/execution-env.h b/src/extension/execution-env.h index 3c4b13198..e46aafc07 100644 --- a/src/extension/execution-env.h +++ b/src/extension/execution-env.h @@ -39,12 +39,13 @@ private: public: Effect * _effect; - ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk::Widget * controls = NULL); + ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk::Widget * controls = NULL, Gtk::Dialog * prefDialog = NULL); ~ExecutionEnv (void); void run (void); void preferencesChange (void); void livePreview (bool state = true); + void shutdown (void); private: void createPrefsDialog (Gtk::Widget * controls); diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp index eb6cbf6fa..62e6b9ff8 100644 --- a/src/extension/prefdialog.cpp +++ b/src/extension/prefdialog.cpp @@ -43,6 +43,7 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co _help(help), _name(name), _exEnv(exEnv), + _createdExEnv(false), _button_ok(NULL), _button_cancel(NULL), _button_preview(NULL), @@ -168,12 +169,26 @@ PrefDialog::pinned_toggle (void) { _button_ok->set_label(Gtk::Stock::EXECUTE.id); _button_cancel->set_label(Gtk::Stock::CLOSE.id); + + if (_exEnv != NULL) { + _exEnv->shutdown(); + if (_createdExEnv) { + delete _exEnv; + } + _exEnv = NULL; + } } else { _button_preview->set_sensitive(true); set_modal(true); _button_ok->set_label(Gtk::Stock::OK.id); _button_cancel->set_label(Gtk::Stock::CANCEL.id); + + if (_exEnv == NULL) { + _exEnv = new ExecutionEnv(_effect, SP_ACTIVE_DESKTOP, NULL, this); + _createdExEnv = true; + _exEnv->run(); + } } } diff --git a/src/extension/prefdialog.h b/src/extension/prefdialog.h index 059cfce45..0f385922f 100644 --- a/src/extension/prefdialog.h +++ b/src/extension/prefdialog.h @@ -32,6 +32,8 @@ class PrefDialog : public Gtk::Dialog { Glib::ustring _name; /** \brief An execution environment if there is one */ ExecutionEnv * _exEnv; + /** \brief Whether we created the \a _exEnv variable */ + bool _createdExEnv; /** \brief A pointer to the OK button */ Gtk::Button * _button_ok; -- 2.30.2