summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 078cd33)
raw | patch | inline | side by side (parent: 078cd33)
author | gouldtj <gouldtj@users.sourceforge.net> | |
Wed, 27 Jun 2007 06:25:23 +0000 (06:25 +0000) | ||
committer | gouldtj <gouldtj@users.sourceforge.net> | |
Wed, 27 Jun 2007 06:25:23 +0000 (06:25 +0000) |
The basics are all working, no call back from the preferences yet.
That's the next step. But the dialogs appear correctly, and it works in
the background.
That's the next step. But the dialogs appear correctly, and it works in
the background.
12 files changed:
index f33ff5154d2d6230867e9952e22293b787303098..d18599d62bea3ab10e358a3935bc70419d933fd2 100644 (file)
--- a/src/extension/effect.cpp
+++ b/src/extension/effect.cpp
_name_noprefs(Glib::ustring(get_name()) + _(" (No preferences)")),
_verb(get_id(), get_name(), NULL, NULL, this, true),
_verb_nopref(_id_noprefs.c_str(), _name_noprefs.c_str(), NULL, NULL, this, false),
- _menu_node(NULL)
+ _menu_node(NULL), _workingDialog(true)
{
Inkscape::XML::Node * local_effects_menu = NULL;
return true;
}
+class ExecutionEnv {
+private:
+ Effect * _effect;
+ Gtk::Dialog * _visibleDialog;
+ bool _prefsVisible;
+ bool _finished;
+ bool _humanWait;
+ bool _canceled;
+ Glib::RefPtr<Glib::MainLoop> _mainloop;
+ Inkscape::UI::View::View * _doc;
+
+public:
+ void run (void);
+
+ ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk::Widget * controls = NULL) :
+ _effect(effect),
+ _visibleDialog(NULL),
+ _prefsVisible(false),
+ _finished(false),
+ _humanWait(false),
+ _canceled(false),
+ _doc(doc) {
+
+ _mainloop = Glib::MainLoop::create(false);
+
+ if (controls != NULL) {
+ createPrefsDialog(controls);
+ } else {
+ createWorkingDialog();
+ }
+
+ return;
+ }
+
+ ~ExecutionEnv (void) {
+ if (_visibleDialog != NULL) {
+ delete _visibleDialog;
+ }
+ return;
+ }
+
+ void preferencesChange (void) {
+ if (_humanWait) {
+ _mainloop->quit();
+ documentCancel();
+ _humanWait = false;
+ } else {
+ processingCancel();
+ documentCancel();
+ }
+ return;
+ }
+
+private:
+ void createPrefsDialog (Gtk::Widget * controls) {
+ if (_visibleDialog != NULL) {
+ delete _visibleDialog;
+ }
+
+ _visibleDialog = new PrefDialog(_effect->get_name(), _effect->get_help(), controls);
+ _visibleDialog->signal_response().connect(sigc::mem_fun(this, &ExecutionEnv::preferencesResponse));
+ _visibleDialog->show();
+
+ _prefsVisible = true;
+ return;
+ }
+
+ void createWorkingDialog (void) {
+ if (_visibleDialog != NULL) {
+ delete _visibleDialog;
+ }
+
+ gchar * dlgmessage = g_strdup_printf(_("The effect '%s' is working on your document. Please wait."), _effect->get_name());
+ _visibleDialog = new Gtk::MessageDialog(dlgmessage,
+ false, // use markup
+ Gtk::MESSAGE_INFO,
+ Gtk::BUTTONS_CANCEL,
+ true); // modal
+ _visibleDialog->signal_response().connect(sigc::mem_fun(this, &ExecutionEnv::workingCanceled));
+ g_free(dlgmessage);
+ _visibleDialog->show();
+
+ _prefsVisible = false;
+ return;
+ }
+
+ void workingCanceled (const int resp) {
+ processingCancel();
+ documentCancel();
+ _finished = true;
+ return;
+ }
+
+ void preferencesResponse (const int resp) {
+ if (resp == Gtk::RESPONSE_OK) {
+ if (_humanWait) {
+ documentCommit();
+ _mainloop->quit();
+ _finished = true;
+ } else {
+ createWorkingDialog();
+ }
+ } else {
+ if (_humanWait) {
+ _mainloop->quit();
+ } else {
+ processingCancel();
+ }
+ documentCancel();
+ _finished = true;
+ }
+ return;
+ }
+
+ void processingComplete(void) {
+ if (_prefsVisible) {
+ _humanWait = true;
+ } else {
+ documentCommit();
+ _finished = true;
+ }
+ return;
+ }
+
+ void processingCancel (void) {
+ _effect->get_imp()->cancelProcessing();
+ return;
+ }
+
+ void documentCancel (void) {
+ _canceled = true;
+ return;
+ }
+
+ void documentCommit (void) {
+ sp_document_done(_doc->doc(), SP_VERB_NONE, _(_effect->get_name()));
+ Effect::set_last_effect(_effect);
+ return;
+ }
+};
+
+void
+ExecutionEnv::run (void) {
+ while (!_finished) {
+ _canceled = false;
+ if (_humanWait) {
+ _mainloop->run();
+ } else {
+ _effect->get_imp()->effect(_effect, _doc);
+ processingComplete();
+ }
+ if (_canceled) {
+ sp_document_cancel(_doc->doc());
+ }
+ }
+ return;
+}
+
bool
Effect::prefs (Inkscape::UI::View::View * doc)
{
set_state(Extension::STATE_LOADED);
if (!loaded()) return false;
+ Glib::SignalProxyInfo changeSignalInfo = {signal_name: "Effect Preference Changed",
+ callback: NULL, notify_callback: NULL};
+ Glib::SignalProxy0<void> changeSignal(NULL, &changeSignalInfo);
+
Gtk::Widget * controls;
- controls = imp->prefs_effect(this, doc);
+ controls = imp->prefs_effect(this, doc, &changeSignal);
if (controls == NULL) {
// std::cout << "No preferences for Effect" << std::endl;
return true;
}
- PrefDialog * dialog = new PrefDialog(this->get_name(), this->get_help(), controls);
- int response = dialog->run();
- dialog->hide();
-
- delete dialog;
-
- if (response == Gtk::RESPONSE_OK) return true;
+ ExecutionEnv executionEnv(this, doc, controls);
+ //changeSignal.connect(sigc::mem_fun(executionEnv, &ExecutionEnv::preferencesChange));
+ executionEnv.run();
- return false;
+ return true;
}
/**
set_state(Extension::STATE_LOADED);
if (!loaded()) return;
- gchar * dlgmessage = g_strdup_printf(_("The effect '%s' is working on your document. Please wait."), get_name());
- Gtk::MessageDialog working(dlgmessage,
- false, // use markup
- Gtk::MESSAGE_INFO,
- Gtk::BUTTONS_CANCEL,
- true); // modal
- working.signal_response().connect(sigc::mem_fun(this, &Effect::workingCanceled));
- g_free(dlgmessage);
- _canceled = false;
- working.show();
-
- set_last_effect(this);
- imp->effect(this, doc);
-
- if (!_canceled) {
- sp_document_done(doc->doc(), SP_VERB_NONE, _(this->get_name()));
- } else {
- sp_document_cancel(doc->doc());
- }
-
- working.hide();
-
- return;
-}
-/** \internal
- \brief A function used by the working dialog to recieve the cancel
- button press
- \param resp The key that was pressed (should always be cancel)
+ ExecutionEnv executionEnv(this, doc, NULL);
+ executionEnv.run();
- This function recieves the key event and marks the effect as being
- canceled. It calls the function in the implementation that would
- cancel the implementation.
-*/
-void
-Effect::workingCanceled (const int resp) {
- if (resp == Gtk::RESPONSE_CANCEL) {
- std::cout << "Canceling Effect" << std::endl;
- _canceled = true;
- imp->cancelProcessing();
- }
return;
}
if (effect == NULL) return;
if (current_view == NULL) return;
- // std::cout << "Executing: " << effect->get_name() << std::endl;
- bool execute = true;
-
- if (ev->_showPrefs)
- execute = effect->prefs(current_view);
- if (execute)
+ if (ev->_showPrefs) {
+ effect->prefs(current_view);
+ } else {
effect->effect(current_view);
+ }
return;
}
diff --git a/src/extension/effect.h b/src/extension/effect.h
index 53d31cf0620feffb4b7effaf367326201350ac47..bebdb1c4f8c544cdc65e9e73d70fe40392dd555c 100644 (file)
--- a/src/extension/effect.h
+++ b/src/extension/effect.h
EffectVerb _verb_nopref;
/** \brief Menu node created for this effect */
Inkscape::XML::Node * _menu_node;
+ /** \brief Whehter a working dialog should be shown */
+ bool _workingDialog;
public:
Effect (Inkscape::XML::Node * in_repr,
Implementation::Implementation * in_imp);
private:
static gchar * remove_ (gchar * instr);
-
- bool _canceled;
- void workingCanceled (const int resp);
};
} } /* namespace Inkscape, Extension */
index 553b05583c5579c2b4e88834bff6d2c8fc471b77..ffb533eda4fe2044eb2a3ca6500509bc0834e541 100644 (file)
If there are no parameters, this function just returns NULL.
*/
Gtk::Widget *
-Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node)
+Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node, Glib::SignalProxy0<void> * changeSignal)
{
if (g_slist_length(parameters) == 0) return NULL;
index f22c1a476109fc87ea6ba16559afd067afebb1ad..d1613e71103dc098236e9049fbb97cd8905090a4 100644 (file)
void deactivate (void);
bool deactivated (void);
void printFailure (Glib::ustring reason);
-
+ Implementation::Implementation * get_imp (void) { return imp; };
/* Parameter Stuff */
private:
static void error_file_close (void);
public:
- Gtk::Widget * autogui (SPDocument * doc, Inkscape::XML::Node * node);
+ Gtk::Widget * autogui (SPDocument * doc, Inkscape::XML::Node * node, Glib::SignalProxy0<void> * changeSignal = NULL);
void paramListString (std::list <std::string> & retlist);
/* Extension editor dialog stuff */
diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp
index d01f52cb425bfa6346e4672ce2f36046d8a4124c..e28dbcba6b74cb0216fb394e1ce7d0072d5f3dcc 100644 (file)
} /* Implementation::save */
Gtk::Widget *
-Implementation::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *view) {
+Implementation::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *view, Glib::SignalProxy0<void> * changeSignal) {
return module->autogui(NULL, NULL);
} /* Implementation::prefs_effect */
diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h
index fbe84249ccded7f6525b8742f1af999b6fd479af..cfffecad9b757146504ee163df0225eec6975a56 100644 (file)
/* ----- Effect functions ----- */
/** Find out information about the file. */
- virtual Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view);
+ virtual Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, Glib::SignalProxy0<void> * changeSignal);
/* TODO: need to figure out what we need here */
virtual void effect(Inkscape::Extension::Effect *module,
index b5e995b65af13c935caf17599207586dc622064e..857c36bc35d784386d32e6e36b0a1ee60ffef53f 100644 (file)
*/
Gtk::Widget *
Script::prefs_effect(Inkscape::Extension::Effect *module,
- Inkscape::UI::View::View *view)
+ Inkscape::UI::View::View *view,
+ Glib::SignalProxy0<void> * changeSignal)
{
-
SPDocument * current_document = view->doc();
using Inkscape::Util::GSListConstIterator;
index bac1f7ccb9059dd1fdc26ba08c6f8888b9d0fb41..155abf7354748628dd2eb247a4da164a140aa65b 100644 (file)
*
*/
virtual Gtk::Widget *prefs_effect(Inkscape::Extension::Effect *module,
- Inkscape::UI::View::View * view);
+ Inkscape::UI::View::View * view,
+ Glib::SignalProxy0<void> * changeSignal);
/**
*
index 3989f9427c52ac6f0fd56bfdc85b79ad30d21747..248cf1c7dccedd91109ee173ce458c8ea036975b 100644 (file)
}
Gtk::Widget *
-BlurEdge::prefs_effect(Inkscape::Extension::Effect * module, Inkscape::UI::View::View * view)
+BlurEdge::prefs_effect(Inkscape::Extension::Effect * module, Inkscape::UI::View::View * view, Glib::SignalProxy0<void> * changeSignal)
{
- return module->autogui(NULL, NULL);
+ return module->autogui(NULL, NULL, changeSignal);
}
#include "clear-n_.h"
index a442f570e6bb98aca48508243969ebeb5af1c572..c84d16e96f74767ead1d4e65ac10fb240879d413 100644 (file)
public:
bool load(Inkscape::Extension::Extension *module);
void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document);
- Gtk::Widget * prefs_effect(Inkscape::Extension::Effect * module, Inkscape::UI::View::View * view);
+ Gtk::Widget * prefs_effect(Inkscape::Extension::Effect * module, Inkscape::UI::View::View * view, Glib::SignalProxy0<void> * changeSignal);
static void init (void);
};
index 47034dd2be48f4c030230db680bfee3b035acc7a..0992681766e9b38320d51251cc432e892356ae53 100644 (file)
Uses AutoGUI for creating the GUI.
*/
Gtk::Widget *
-Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view)
+Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, Glib::SignalProxy0<void> * changeSignal)
{
SPDocument * current_document = view->doc();
@@ -179,7 +179,7 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View
if (selected != NULL)
first_select = SP_OBJECT_REPR(*selected);
- return module->autogui(current_document, first_select);
+ return module->autogui(current_document, first_select, changeSignal);
}
#include "clear-n_.h"
index 41ac563567463adda8788fcf39f0ef25ba80cf11..1fedbb177f5e00683aff69bf2b31ad9fb4028546 100644 (file)
public:
bool load(Inkscape::Extension::Extension *module);
void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document);
- Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view);
+ Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, Glib::SignalProxy0<void> * changeSignal);
static void init (void);
};