=== modified file 'src/extension/implementation/script.cpp' --- src/extension/implementation/script.cpp 2016-02-09 02:13:32 +0000 +++ src/extension/implementation/script.cpp 2016-03-12 20:25:25 +0000 @@ -1123,8 +1119,45 @@ } - - + void Script::file_listener::init(int fd, Glib::RefPtr main) { + _channel = Glib::IOChannel::create_from_fd(fd); + _channel->set_encoding(); + _conn = main->get_context()->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 Script::file_listener::read(Glib::IOCondition condition) { + if (condition != Glib::IO_IN) { + _main_loop->quit(); + return false; + } + + Glib::IOStatus status; + Glib::ustring out; + status = _channel->read_line(out); + _string += out; + + if (status != Glib::IO_STATUS_NORMAL) { + _main_loop->quit(); + _dead = true; + return false; + } + + return true; + } + + bool Script::file_listener::toFile(const Glib::ustring &name) { + try { + Glib::RefPtr stdout_file = Glib::IOChannel::create_from_file(name, "w"); + stdout_file->set_encoding(); + stdout_file->write(_string); + } catch (Glib::FileError &e) { + return false; + } + return true; + } } // namespace Implementation } // namespace Extension } // namespace Inkscape === modified file 'src/extension/implementation/script.h' --- src/extension/implementation/script.h 2015-04-27 16:01:19 +0000 +++ src/extension/implementation/script.h 2016-03-12 20:25:25 +0000 @@ -86,48 +86,13 @@ bool isDead () { return _dead; } - // TODO move these definitions into script.cpp - void init (int fd, Glib::RefPtr main) { - _channel = Glib::IOChannel::create_from_fd(fd); - _channel->set_encoding(); - _conn = main->get_context()->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_line(out); - _string += out; - - if (status != Glib::IO_STATUS_NORMAL) { - _main_loop->quit(); - _dead = true; - return false; - } - - return true; - }; + void init(int fd, Glib::RefPtr main); + + bool read(Glib::IOCondition condition); Glib::ustring string (void) { return _string; }; - bool toFile (const Glib::ustring &name) { - try { - Glib::RefPtr stdout_file = Glib::IOChannel::create_from_file(name, "w"); - stdout_file->set_encoding(); - stdout_file->write(_string); - } catch (Glib::FileError &e) { - return false; - } - return true; - }; + bool toFile(const Glib::ustring &name); }; int execute (const std::list &in_command,