summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 77f2a5f)
raw | patch | inline | side by side (parent: 77f2a5f)
author | gouldtj <gouldtj@users.sourceforge.net> | |
Tue, 30 Oct 2007 19:30:32 +0000 (19:30 +0000) | ||
committer | gouldtj <gouldtj@users.sourceforge.net> | |
Tue, 30 Oct 2007 19:30:32 +0000 (19:30 +0000) |
Caching the input file for effects.
src/extension/implementation/script.cpp | patch | blob | history | |
src/extension/implementation/script.h | patch | blob | history |
index bec24f165dfd78310eb1c71d77e6d658519677a9..16ab66dc0f9e96aacb9c7214a4822e8aa1256b93 100644 (file)
return true;
}
+class ScriptDocCache : public ImplementationDocumentCache {
+ friend class Script;
+protected:
+ std::string _filename;
+ int _tempfd;
+public:
+ ScriptDocCache (Inkscape::UI::View::View * view);
+ ~ScriptDocCache ( );
+};
+
+ScriptDocCache::ScriptDocCache (Inkscape::UI::View::View * view) :
+ ImplementationDocumentCache(view),
+ _filename(""),
+ _tempfd(0)
+{
+ try {
+ _tempfd = Glib::file_open_tmp(_filename, "ink_ext_XXXXXX.svg");
+ } catch (...) {
+ /// \todo Popup dialog here
+ return;
+ }
+
+ SPDesktop *desktop = (SPDesktop *) view;
+ sp_namedview_document_from_window(desktop);
+
+ Inkscape::Extension::save(
+ Inkscape::Extension::db.get(SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE),
+ view->doc(), _filename.c_str(), FALSE, FALSE, FALSE);
+
+ return;
+}
+
+ScriptDocCache::~ScriptDocCache ( )
+{
+ close(_tempfd);
+ unlink(_filename.c_str());
+}
+
+ImplementationDocumentCache *
+Script::newDocCache (Inkscape::Extension::Extension * ext, Inkscape::UI::View::View * view) {
+ return new ScriptDocCache(view);
+}
/**
Inkscape::UI::View::View *doc,
ImplementationDocumentCache * docCache)
{
+ if (docCache == NULL) {
+ docCache = newDocCache(module, doc);
+ }
+ ScriptDocCache * dc = dynamic_cast<ScriptDocCache *>(docCache);
+ if (dc == NULL) {
+ printf("TOO BAD TO LIVE!!!");
+ exit(1);
+ }
+
std::list<std::string> params;
module->paramListString(params);
return;
}
- std::string tempfilename_in;
- int tempfd_in = 0;
- try {
- tempfd_in = Glib::file_open_tmp(tempfilename_in, "ink_ext_XXXXXX.svg");
- } catch (...) {
- /// \todo Popup dialog here
- return;
- }
-
std::string tempfilename_out;
int tempfd_out = 0;
try {
SPDesktop *desktop = (SPDesktop *) doc;
sp_namedview_document_from_window(desktop);
- Inkscape::Extension::save(
- Inkscape::Extension::db.get(SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE),
- doc->doc(), tempfilename_in.c_str(), FALSE, FALSE, FALSE);
-
- pump_events();
-
if (desktop != NULL) {
Inkscape::Util::GSListConstIterator<SPItem *> selected =
sp_desktop_selection(desktop)->itemList();
}
file_listener fileout;
- int data_read = execute(command, params, tempfilename_in, fileout);
+ int data_read = execute(command, params, dc->_filename, fileout);
fileout.toFile(tempfilename_out);
pump_events();
pump_events();
// make sure we don't leak file descriptors from g_file_open_tmp
- close(tempfd_in);
close(tempfd_out);
// FIXME: convert to utf8 (from "filename encoding") and unlink_utf8name
- unlink(tempfilename_in.c_str());
unlink(tempfilename_out.c_str());
/* Do something with mydoc.... */
index 6a6256f3c4a7f93f078cf9fb8a1b516b7f9f625b..bb3516232213a8ea6bad838d1510f54e1a4b3a66 100644 (file)
*/
virtual bool check(Inkscape::Extension::Extension *module);
+ ImplementationDocumentCache * newDocCache (Inkscape::Extension::Extension * ext, Inkscape::UI::View::View * view);
+
/**
*
*/