Inkscape
Vector Graphics Editor
|
#include <execution-env.h>
Public Member Functions | |
ExecutionEnv (Effect *effect, SPDesktop *desktop, Implementation::ImplementationDocumentCache *docCache=nullptr, bool show_working=true, bool show_errors=true) | |
Create a new context for execution of an effect. | |
virtual | ~ExecutionEnv () |
Destroy an execution environment. | |
void | set_document (SPDocument *document) |
void | run () |
Starts the execution of the effect. | |
void | cancel () |
Cancel the execution of the effect. | |
void | commit () |
Commit the changes to the document. | |
void | undo () |
Undoes what the effect completed. | |
bool | wait () |
Wait for the effect to complete if it hasn't. | |
void | reselect () |
Gtk::Dialog * | get_working_dialog () |
Return reference to working dialog (if any) | |
Private Types | |
enum | state_t { INIT , COMPLETE , RUNNING } |
Private Member Functions | |
void | runComplete () |
void | createWorkingDialog () |
Create the working dialog. | |
void | workingCanceled (const int resp) |
void | genDocCache () |
Generate a document cache if needed. | |
void | killDocCache () |
Destroy a document cache. | |
Private Attributes | |
state_t | _state |
What state the execution engine is in. | |
Gtk::Dialog * | _visibleDialog = nullptr |
If there is a working dialog it'll be referenced right here. | |
sigc::signal< void()> | _runComplete |
Signal that the run is complete. | |
Glib::RefPtr< Glib::MainLoop > | _mainloop |
In some cases we need a mainLoop, when we do, this is a pointer to it. | |
SPDesktop * | _desktop = nullptr |
The desktop containing the document that we're working on. | |
SPDocument * | _document = nullptr |
Implementation::ImplementationDocumentCache * | _docCache |
A document cache if we were passed one. | |
Effect * | _effect |
The effect that we're executing in this context. | |
bool | _show_working |
Show the working dialog when the effect is executing. | |
Definition at line 32 of file execution-env.h.
|
private |
Enumerator | |
---|---|
INIT | |
COMPLETE | |
RUNNING |
Definition at line 34 of file execution-env.h.
Inkscape::Extension::ExecutionEnv::ExecutionEnv | ( | Effect * | effect, |
SPDesktop * | desktop, | ||
Implementation::ImplementationDocumentCache * | docCache = nullptr , |
||
bool | show_working = true , |
||
bool | show_errors = true |
||
) |
Create a new context for execution of an effect.
Create an execution environment that will allow the effect to execute independently.
effect | The effect to execute |
desktop | The desktop containing the document to execute the effect on |
docCache | The implementation cache of the document. May be NULL in which case it'll be created by the execution environment. \prarm show_working Show a small dialog signaling the effect is working. Allows for user canceling. |
show_errors | If the effect has an error, show it or not. |
effect | The effect that we should execute |
desktop | The Desktop with the document to work on |
docCache | The cache created for that document |
show_working | Show the working dialog |
show_error | Show the error dialog (not working) |
Grabs the selection of the current document so that it can get restored. Will generate a document cache if one isn't provided.
Definition at line 41 of file execution-env.cpp.
References _desktop, _document, desktop, SPDesktop::doc(), Inkscape::ObjectSet::enforceIds(), genDocCache(), and SPDesktop::getSelection().
|
virtual |
Destroy an execution environment.
Destroys the dialog if created and the document cache.
Definition at line 67 of file execution-env.cpp.
References _visibleDialog, and killDocCache().
void Inkscape::Extension::ExecutionEnv::cancel | ( | ) |
Cancel the execution of the effect.
Definition at line 155 of file execution-env.cpp.
References _desktop, _effect, Inkscape::Extension::Implementation::Implementation::cancelProcessing(), SPDesktop::clearWaitingCursor(), and Inkscape::Extension::Extension::get_imp().
Referenced by Inkscape::Extension::Effect::effect(), and workingCanceled().
void Inkscape::Extension::ExecutionEnv::commit | ( | ) |
Commit the changes to the document.
Definition at line 168 of file execution-env.cpp.
References _document, _effect, Inkscape::Extension::Implementation::Implementation::commitDocument(), Inkscape::DocumentUndo::done(), Inkscape::Extension::Extension::get_imp(), Inkscape::Extension::Extension::get_name(), killDocCache(), and Inkscape::Extension::Effect::set_last_effect().
Referenced by Inkscape::Extension::Effect::effect().
|
private |
Create the working dialog.
Builds the dialog with a message saying that the effect is working. And make sure to connect to the cancel.
Definition at line 111 of file execution-env.cpp.
References _desktop, _effect, _visibleDialog, Inkscape::Extension::Extension::get_name(), Inkscape::Extension::Effect::get_pref_dialog(), SPDesktop::getCanvas(), root, and workingCanceled().
Referenced by run().
|
private |
Generate a document cache if needed.
If there isn't one we create a new one from the implementation from the effect's implementation.
Definition at line 83 of file execution-env.cpp.
References _desktop, _docCache, _effect, Inkscape::Extension::Extension::get_imp(), and Inkscape::Extension::Implementation::Implementation::newDocCache().
Referenced by ExecutionEnv().
|
inline |
Return reference to working dialog (if any)
Definition at line 96 of file execution-env.h.
References _visibleDialog.
Referenced by Inkscape::Extension::Implementation::Script::_change_extension().
|
private |
Destroy a document cache.
Just delete it.
Definition at line 96 of file execution-env.cpp.
References _docCache.
Referenced by commit(), and ~ExecutionEnv().
void Inkscape::Extension::ExecutionEnv::reselect | ( | ) |
Definition at line 177 of file execution-env.cpp.
References _desktop, SPDesktop::getSelection(), and Inkscape::Selection::restoreBackup().
void Inkscape::Extension::ExecutionEnv::run | ( | ) |
Starts the execution of the effect.
Definition at line 188 of file execution-env.cpp.
References _desktop, _docCache, _document, _effect, _show_working, _state, SPDesktop::clearWaitingCursor(), COMPLETE, createWorkingDialog(), Inkscape::Extension::Implementation::Implementation::effect(), Inkscape::Extension::Extension::get_imp(), SPDesktop::getSelection(), Inkscape::Selection::restoreBackup(), RUNNING, Inkscape::Selection::setBackup(), and SPDesktop::setWaitingCursor().
Referenced by Inkscape::Extension::Effect::effect().
|
private |
|
inline |
Definition at line 80 of file execution-env.h.
References _document.
Referenced by Inkscape::Extension::Effect::effect().
void Inkscape::Extension::ExecutionEnv::undo | ( | ) |
Undoes what the effect completed.
Definition at line 162 of file execution-env.cpp.
References _document, and Inkscape::DocumentUndo::cancel().
Referenced by workingCanceled().
bool Inkscape::Extension::ExecutionEnv::wait | ( | ) |
Wait for the effect to complete if it hasn't.
Definition at line 218 of file execution-env.cpp.
References _mainloop, _runComplete, _state, COMPLETE, and runComplete().
Referenced by Inkscape::Extension::Effect::effect().
|
private |
Definition at line 148 of file execution-env.cpp.
References cancel(), and undo().
Referenced by createWorkingDialog().
|
private |
The desktop containing the document that we're working on.
Definition at line 51 of file execution-env.h.
Referenced by cancel(), createWorkingDialog(), ExecutionEnv(), genDocCache(), reselect(), and run().
|
private |
A document cache if we were passed one.
Definition at line 54 of file execution-env.h.
Referenced by genDocCache(), killDocCache(), and run().
|
private |
Definition at line 52 of file execution-env.h.
Referenced by commit(), ExecutionEnv(), run(), set_document(), and undo().
|
private |
The effect that we're executing in this context.
Definition at line 57 of file execution-env.h.
Referenced by cancel(), commit(), createWorkingDialog(), genDocCache(), and run().
|
private |
In some cases we need a mainLoop, when we do, this is a pointer to it.
Definition at line 49 of file execution-env.h.
Referenced by runComplete(), and wait().
|
private |
Signal that the run is complete.
Definition at line 46 of file execution-env.h.
Referenced by wait().
|
private |
Show the working dialog when the effect is executing.
Definition at line 60 of file execution-env.h.
Referenced by run().
|
private |
What state the execution engine is in.
Definition at line 40 of file execution-env.h.
|
private |
If there is a working dialog it'll be referenced right here.
Definition at line 44 of file execution-env.h.
Referenced by createWorkingDialog(), get_working_dialog(), and ~ExecutionEnv().