Code

fix crash bug: PDF export: crash in 'CairoRenderContext::_showGlyphs'
[inkscape.git] / src / extension / execution-env.h
index 7b35f33a23b297967ec78dd492eab5b11de2d811..c2d4e7e4aaffb07998cc0f4caf517962969137f1 100644 (file)
@@ -26,53 +26,80 @@ namespace Extension {
 
 class ExecutionEnv {
 private:
+    enum state_t {
+        INIT,     //< The context has been initialized
+        COMPLETE, //< We've completed atleast once
+        RUNNING   //< The effect is currently running
+    };
+    /** \brief  What state the execution engine is in. */
+    state_t _state;
+
+    /** \brief If there is a working dialog it'll be referenced
+               right here. */
     Gtk::Dialog * _visibleDialog;
-    bool _prefsVisible;
-    bool _finished;
-    bool _humanWait;
-    bool _canceled;
-    bool _prefsChanged;
-    bool _livePreview;
-    bool _shutdown;
-    bool _selfdelete;
-    sigc::signal<void> * _changeSignal;
+    /** \brief Signal that the run is complete. */
+    sigc::signal<void> _runComplete;
+    /** \brief  In some cases we need a mainLoop, when we do, this is
+                a pointer to it. */
     Glib::RefPtr<Glib::MainLoop> _mainloop;
+    /** \brief  The document that we're working on. */
     Inkscape::UI::View::View * _doc;
+    /** \brief  A list of the IDs of all the selected objects before
+                we started to work on this document. */
     std::list<Glib::ustring> _selected;
-    sigc::connection _dialogsig;
-    sigc::connection _changesig;
-    sigc::connection _timersig;
-       Implementation::ImplementationDocumentCache * _docCache;
+    /** \brief  A document cache if we were passed one. */
+    Implementation::ImplementationDocumentCache * _docCache;
 
-public:
+    /** \brief  The effect that we're executing in this context. */
     Effect * _effect;
 
+    /** \brief  Show the working dialog when the effect is executing. */
+    bool _show_working;
+    /** \brief  Display errors if they occur. */
+    bool _show_errors;
+public:
+
+    /** \brief  Create a new context for exection of an effect
+        \param effect  The effect to execute
+        \param doc     The document to execute the effect on
+        \param 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.
+        \param show_errors   If the effect has an error, show it or not.
+    */
     ExecutionEnv (Effect * effect,
-                     Inkscape::UI::View::View * doc,
-                                 Gtk::Widget * controls = NULL,
-                                 sigc::signal<void> * changeSignal = NULL,
-                                 Gtk::Dialog * prefDialog = NULL,
-                                 Implementation::ImplementationDocumentCache * docCache = NULL);
-    ~ExecutionEnv (void);
+                  Inkscape::UI::View::View * doc,
+                  Implementation::ImplementationDocumentCache * docCache = NULL,
+                  bool show_working = true,
+                  bool show_errors = true);
+    virtual ~ExecutionEnv (void);
 
+    /** \brief Starts the execution of the effect
+        \return Returns whether the effect was executed to completion */
     void run (void);
-    void livePreview (bool state = true);
-    void shutdown (bool del = false);
+    /** \brief Cancel the execution of the effect */
+    void cancel (void);
+    /** \brief Commit the changes to the document */
+    void commit (void);
+    /** \brief Undoes what the effect completed. */
+    void undo (void);
+    /** \brief Wait for the effect to complete if it hasn't. */
+    bool wait (void);
 
 private:
+    void runComplete (void);
     void createPrefsDialog (Gtk::Widget * controls);
     void createWorkingDialog (void);
     void workingCanceled (const int resp);
-    void preferencesResponse (const int resp);
-    void preferencesChange (void);
-    bool preferencesTimer (void);
     void processingCancel (void);
     void processingComplete(void);
     void documentCancel (void);
     void documentCommit (void);
     void reselect (void);
-       void genDocCache (void);
-       void killDocCache (void);
+    void genDocCache (void);
+    void killDocCache (void);
 };
 
 } }  /* namespace Inkscape, Extension */