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

Public Attributes

SPDocumentdocument = nullptr
 

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.
 
Implementation::ImplementationDocumentCache_docCache
 A document cache if we were passed one.
 
std::unique_ptr< Inkscape::SelectionState_selectionState
 Saved selection state before running the effect.
 
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 34 of file execution-env.h.

Member Enumeration Documentation

◆ state_t

Enumerator
INIT 
COMPLETE 
RUNNING 

Definition at line 36 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 42 of file execution-env.cpp.

References _desktop, desktop, SPDesktop::doc(), document, 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 68 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 112 of file execution-env.cpp.

References _desktop, _effect, _visibleDialog, Inkscape::Extension::Extension::get_name(), Inkscape::Extension::Effect::get_pref_dialog(), SPDesktop::getCanvas(), SPDesktop::getInkscapeWindow(), 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 84 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 98 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 97 of file execution-env.cpp.

References _docCache.

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

◆ reselect()

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

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

References _desktop, _selectionState, and SPDesktop::getSelection().

◆ run()

void Inkscape::Extension::ExecutionEnv::run ( )

◆ runComplete()

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

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

References _mainloop.

Referenced by wait().

◆ undo()

void Inkscape::Extension::ExecutionEnv::undo ( )

Undoes what the effect completed.

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

References Inkscape::DocumentUndo::cancel(), and document.

Referenced by workingCanceled().

◆ wait()

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

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

Definition at line 219 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 147 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 53 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 55 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 61 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 51 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 48 of file execution-env.h.

Referenced by wait().

◆ _selectionState

std::unique_ptr<Inkscape::SelectionState> Inkscape::Extension::ExecutionEnv::_selectionState
private

Saved selection state before running the effect.

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

Referenced by reselect(), and run().

◆ _show_working

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

Show the working dialog when the effect is executing.

Definition at line 64 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 42 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 46 of file execution-env.h.

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

◆ document

SPDocument* Inkscape::Extension::ExecutionEnv::document = nullptr

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

Referenced by commit(), Inkscape::Extension::Effect::effect(), ExecutionEnv(), run(), and undo().


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