summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorraphael0202 <raphael0202@yahoo.fr>2016-03-20 16:19:56 +0000
committerJazzyNico <nicoduf@yahoo.fr>2016-03-20 16:19:56 +0000
commit504be8ba421045a16c60bd11dbe9e334a1576f0b (patch)
tree578912d5b02f602c0549a4393ee6a258d5452d7d /src/extension
parent[Bug #1559679] Make inkex.py PEP8 compliant. (diff)
downloadinkscape-504be8ba421045a16c60bd11dbe9e334a1576f0b.tar.gz
inkscape-504be8ba421045a16c60bd11dbe9e334a1576f0b.zip
[Bug #1558160] Move Script::file_listener methods to script.cpp source file.
Fixed bugs: - https://launchpad.net/bugs/1558160 (bzr r14727)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/implementation/script.cpp38
-rw-r--r--src/extension/implementation/script.h45
2 files changed, 41 insertions, 42 deletions
diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp
index 2ec17f947..9aaf4b952 100644
--- a/src/extension/implementation/script.cpp
+++ b/src/extension/implementation/script.cpp
@@ -1119,7 +1119,45 @@ int Script::execute (const std::list<std::string> &in_command,
}
+void Script::file_listener::init(int fd, Glib::RefPtr<Glib::MainLoop> 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<Glib::IOChannel> 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
diff --git a/src/extension/implementation/script.h b/src/extension/implementation/script.h
index 4cf33c989..684719895 100644
--- a/src/extension/implementation/script.h
+++ b/src/extension/implementation/script.h
@@ -85,49 +85,10 @@ private:
};
bool isDead () { return _dead; }
-
- // TODO move these definitions into script.cpp
- void init (int fd, Glib::RefPtr<Glib::MainLoop> 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<Glib::MainLoop> main);
+ bool read(Glib::IOCondition condition);
Glib::ustring string (void) { return _string; };
-
- bool toFile (const Glib::ustring &name) {
- try {
- Glib::RefPtr<Glib::IOChannel> 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<std::string> &in_command,