Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::Extension::ExecutionEnv Class Reference

#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.
 

Detailed Description

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

Member Enumeration Documentation

◆ state_t

Enumerator
INIT 
COMPLETE 
RUNNING 

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

Constructor & Destructor Documentation

◆ ExecutionEnv()

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.

Parameters
effectThe effect to execute
desktopThe desktop containing the 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
desktopThe Desktop with the document to work 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 41 of file execution-env.cpp.

References _desktop, _document, desktop, SPDesktop::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 67 of file execution-env.cpp.

References _visibleDialog, and killDocCache().

Member Function Documentation

◆ cancel()

void Inkscape::Extension::ExecutionEnv::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 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().

◆ 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 83 of file execution-env.cpp.

References _desktop, _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 96 of file execution-env.h.

References _visibleDialog.

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

◆ killDocCache()

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

Destroy a document cache.

Just delete it.

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

References _docCache.

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

◆ reselect()

void Inkscape::Extension::ExecutionEnv::reselect ( )

◆ run()

◆ runComplete()

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

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

References _mainloop.

Referenced by wait().

◆ set_document()

void Inkscape::Extension::ExecutionEnv::set_document ( SPDocument document)
inline

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

References _document.

Referenced by Inkscape::Extension::Effect::effect().

◆ undo()

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().

◆ wait()

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().

◆ workingCanceled()

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

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

References cancel(), and undo().

Referenced by createWorkingDialog().

Member Data Documentation

◆ _desktop

SPDesktop* Inkscape::Extension::ExecutionEnv::_desktop = nullptr
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().

◆ _docCache

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

A document cache if we were passed one.

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

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

◆ _document

SPDocument* Inkscape::Extension::ExecutionEnv::_document = nullptr
private

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

Referenced by commit(), ExecutionEnv(), run(), set_document(), and undo().

◆ _effect

Effect* Inkscape::Extension::ExecutionEnv::_effect
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().

◆ _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 49 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 46 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 60 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 40 of file execution-env.h.

Referenced by run(), and wait().

◆ _visibleDialog

Gtk::Dialog* Inkscape::Extension::ExecutionEnv::_visibleDialog = nullptr
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().


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