Inkscape
Vector Graphics Editor
Inkscape::Extension::ExecutionEnv Class Reference

#include <execution-env.h>

Public Member Functions

 ExecutionEnv (Effect *effect, Inkscape::UI::View::View *doc, Implementation::ImplementationDocumentCache *docCache=nullptr, bool show_working=true, bool show_errors=true)
 Create a new context for execution of an effect. More...
 
virtual ~ExecutionEnv ()
 Destroy an execution environment. More...
 
void run ()
 Starts the execution of the effect. More...
 
void cancel ()
 Cancel the execution of the effect. More...
 
void commit ()
 Commit the changes to the document. More...
 
void undo ()
 Undoes what the effect completed. More...
 
bool wait ()
 Wait for the effect to complete if it hasn't. More...
 
void reselect ()
 
Gtk::Dialog * get_working_dialog ()
 Return reference to working dialog (if any) More...
 

Private Types

enum  state_t { INIT, COMPLETE, RUNNING }
 

Private Member Functions

void runComplete ()
 
void createWorkingDialog ()
 Create the working dialog. More...
 
void workingCanceled (const int resp)
 
void genDocCache ()
 Generate a document cache if needed. More...
 
void killDocCache ()
 Destroy a document cache. More...
 

Private Attributes

state_t _state
 What state the execution engine is in. More...
 
Gtk::Dialog * _visibleDialog
 If there is a working dialog it'll be referenced right here. More...
 
sigc::signal< void > _runComplete
 Signal that the run is complete. More...
 
Glib::RefPtr< Glib::MainLoop > _mainloop
 In some cases we need a mainLoop, when we do, this is a pointer to it. More...
 
Inkscape::UI::View::View_doc
 The document that we're working on. More...
 
Implementation::ImplementationDocumentCache_docCache
 A document cache if we were passed one. More...
 
Effect_effect
 The effect that we're executing in this context. More...
 
bool _show_working
 Show the working dialog when the effect is executing. More...
 

Detailed Description

Definition at line 36 of file execution-env.h.

Member Enumeration Documentation

◆ state_t

Enumerator
INIT 
COMPLETE 
RUNNING 

Definition at line 38 of file execution-env.h.

Constructor & Destructor Documentation

◆ ExecutionEnv()

Inkscape::Extension::ExecutionEnv::ExecutionEnv ( Effect effect,
Inkscape::UI::View::View doc,
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.

Parameters
effectThe effect to execute
docThe document to execute the effect on
docCacheThe 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_errorsIf the effect has an error, show it or not.
effectThe effect that we should execute
docThe Document to execute on
docCacheThe cache created for that document
show_workingShow the working dialog
show_errorShow 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 44 of file execution-env.cpp.

References _doc, Inkscape::UI::View::View::doc(), Inkscape::ObjectSet::enforceIds(), genDocCache(), and SPDesktop::getSelection().

◆ ~ExecutionEnv()

Inkscape::Extension::ExecutionEnv::~ExecutionEnv ( )
virtual

Destroy an execution environment.

Destroys the dialog if created and the document cache.

Definition at line 74 of file execution-env.cpp.

References _visibleDialog, and killDocCache().

Member Function Documentation

◆ cancel()

◆ commit()

◆ createWorkingDialog()

void Inkscape::Extension::ExecutionEnv::createWorkingDialog ( )
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 118 of file execution-env.cpp.

References _doc, _effect, _visibleDialog, Inkscape::Extension::Extension::get_name(), Inkscape::Extension::Effect::get_pref_dialog(), SPDesktop::getCanvas(), Inkscape::UI::Dialog::window, and workingCanceled().

Referenced by run().

◆ genDocCache()

void Inkscape::Extension::ExecutionEnv::genDocCache ( )
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 90 of file execution-env.cpp.

References _doc, _docCache, _effect, Inkscape::Extension::Extension::get_imp(), and Inkscape::Extension::Implementation::Implementation::newDocCache().

Referenced by ExecutionEnv().

◆ get_working_dialog()

Gtk::Dialog* Inkscape::Extension::ExecutionEnv::get_working_dialog ( )
inline

Return reference to working dialog (if any)

Definition at line 97 of file execution-env.h.

References _visibleDialog.

Referenced by Inkscape::Extension::Implementation::Script::effect().

◆ killDocCache()

void Inkscape::Extension::ExecutionEnv::killDocCache ( )
private

Destroy a document cache.

Just delete it.

Definition at line 103 of file execution-env.cpp.

References _docCache.

Referenced by commit(), and ~ExecutionEnv().

◆ reselect()

◆ run()

◆ runComplete()

void Inkscape::Extension::ExecutionEnv::runComplete ( )
private

Definition at line 216 of file execution-env.cpp.

References _mainloop.

Referenced by wait().

◆ undo()

◆ wait()

bool Inkscape::Extension::ExecutionEnv::wait ( )

Wait for the effect to complete if it hasn't.

Definition at line 221 of file execution-env.cpp.

References _mainloop, _runComplete, _state, COMPLETE, and runComplete().

Referenced by Inkscape::Extension::Effect::effect(), and Inkscape::Extension::PrefDialog::on_response().

◆ workingCanceled()

void Inkscape::Extension::ExecutionEnv::workingCanceled ( const int  resp)
private

Definition at line 156 of file execution-env.cpp.

References cancel(), and undo().

Referenced by createWorkingDialog().

Member Data Documentation

◆ _doc

Inkscape::UI::View::View* Inkscape::Extension::ExecutionEnv::_doc
private

The document that we're working on.

Definition at line 55 of file execution-env.h.

Referenced by cancel(), commit(), createWorkingDialog(), ExecutionEnv(), genDocCache(), run(), and undo().

◆ _docCache

Implementation::ImplementationDocumentCache* Inkscape::Extension::ExecutionEnv::_docCache
private

A document cache if we were passed one.

Definition at line 57 of file execution-env.h.

Referenced by genDocCache(), killDocCache(), and run().

◆ _effect

Effect* Inkscape::Extension::ExecutionEnv::_effect
private

The effect that we're executing in this context.

Definition at line 60 of file execution-env.h.

Referenced by cancel(), commit(), createWorkingDialog(), genDocCache(), and run().

◆ _mainloop

Glib::RefPtr<Glib::MainLoop> Inkscape::Extension::ExecutionEnv::_mainloop
private

In some cases we need a mainLoop, when we do, this is a pointer to it.

Definition at line 53 of file execution-env.h.

Referenced by runComplete(), and wait().

◆ _runComplete

sigc::signal<void> Inkscape::Extension::ExecutionEnv::_runComplete
private

Signal that the run is complete.

Definition at line 50 of file execution-env.h.

Referenced by wait().

◆ _show_working

bool Inkscape::Extension::ExecutionEnv::_show_working
private

Show the working dialog when the effect is executing.

Definition at line 63 of file execution-env.h.

Referenced by run().

◆ _state

state_t Inkscape::Extension::ExecutionEnv::_state
private

What state the execution engine is in.

Definition at line 44 of file execution-env.h.

Referenced by run(), and wait().

◆ _visibleDialog

Gtk::Dialog* Inkscape::Extension::ExecutionEnv::_visibleDialog
private

If there is a working dialog it'll be referenced right here.

Definition at line 48 of file execution-env.h.

Referenced by createWorkingDialog(), get_working_dialog(), and ~ExecutionEnv().


The documentation for this class was generated from the following files: