summaryrefslogtreecommitdiffstats
path: root/src/extension/implementation/script.h
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2007-06-27 06:24:50 +0000
committergouldtj <gouldtj@users.sourceforge.net>2007-06-27 06:24:50 +0000
commit64d92f8ff47bccefa894d24250f66bd91da09c3e (patch)
treeaf972204c8377fe68f1765d9e59746c0f0a70fda /src/extension/implementation/script.h
parentr15380@tres: ted | 2007-05-10 19:24:35 -0700 (diff)
downloadinkscape-64d92f8ff47bccefa894d24250f66bd91da09c3e.tar.gz
inkscape-64d92f8ff47bccefa894d24250f66bd91da09c3e.zip
r15432@tres: ted | 2007-05-12 21:24:09 -0700
Cleaning up so that canceling works. (bzr r3123)
Diffstat (limited to 'src/extension/implementation/script.h')
-rw-r--r--src/extension/implementation/script.h59
1 files changed, 58 insertions, 1 deletions
diff --git a/src/extension/implementation/script.h b/src/extension/implementation/script.h
index 0e9708926..bac1f7ccb 100644
--- a/src/extension/implementation/script.h
+++ b/src/extension/implementation/script.h
@@ -97,9 +97,12 @@ public:
virtual void effect(Inkscape::Extension::Effect *module,
Inkscape::UI::View::View *doc);
-
+ virtual bool cancelProcessing (void);
private:
+ bool _canceled;
+ Glib::Pid _pid;
+ Glib::RefPtr<Glib::MainLoop> _main_loop;
/**
* The command that has been dirived from
@@ -139,6 +142,60 @@ private:
const Glib::ustring &message);
+ class file_listener {
+ Glib::ustring _string;
+ sigc::connection _conn;
+ Glib::RefPtr<Glib::IOChannel> _channel;
+ Glib::RefPtr<Glib::MainLoop> _main_loop;
+
+ public:
+ file_listener () { };
+ ~file_listener () {
+ _conn.disconnect();
+ };
+
+ void init (int fd, Glib::RefPtr<Glib::MainLoop> main) {
+ _channel = Glib::IOChannel::create_from_fd(fd);
+ _channel->set_encoding();
+ _conn = Glib::signal_io().connect(sigc::mem_fun(*this, &file_listener::read), _channel, Glib::IO_IN | Glib::IO_HUP | Glib::IO_ERR);
+ _main_loop = main;
+
+ return;
+ };
+
+ bool read (Glib::IOCondition condition) {
+ if (condition != Glib::IO_IN) {
+ _main_loop->quit();
+ return false;
+ }
+
+ Glib::IOStatus status;
+ Glib::ustring out;
+ status = _channel->read_to_end(out);
+
+ if (status != Glib::IO_STATUS_NORMAL) {
+ _main_loop->quit();
+ return false;
+ }
+
+ _string += out;
+ return true;
+ };
+
+ // Note, doing a copy here, on purpose
+ Glib::ustring string (void) { return _string; };
+
+ void toFile (const Glib::ustring &name) {
+ Glib::RefPtr<Glib::IOChannel> stdout_file = Glib::IOChannel::create_from_file(name, "w");
+ stdout_file->write(_string);
+ return;
+ };
+ };
+
+ int execute (const std::list<std::string> &in_command,
+ const std::list<std::string> &in_params,
+ const Glib::ustring &filein,
+ file_listener &fileout);
}; // class Script