summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorRichard White <rwhite8282@gmail.com>2016-05-19 01:17:29 +0000
committerRichard White <rwhite8282@gmail.com>2016-05-19 01:17:29 +0000
commit1fe9c2603c33fddcd9f2688b30e843f91e1a86fa (patch)
tree13289cbe033a46a40eb829437e115b5393e2ca84 /src/extension
parentCorrected frame extension stroke and fill values on 64 bit machine. (diff)
parentGTK3: Another widget named. (diff)
downloadinkscape-1fe9c2603c33fddcd9f2688b30e843f91e1a86fa.tar.gz
inkscape-1fe9c2603c33fddcd9f2688b30e843f91e1a86fa.zip
Merge from Inkscape trunk.
(bzr r14668.1.3)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/CMakeLists.txt19
-rw-r--r--src/extension/Makefile_insert2
-rw-r--r--src/extension/dbus/CMakeLists.txt29
-rw-r--r--src/extension/dbus/document-interface.cpp6
-rw-r--r--src/extension/dependency.cpp12
-rw-r--r--src/extension/dependency.h1
-rw-r--r--src/extension/execution-env.cpp2
-rw-r--r--src/extension/implementation/implementation.h24
-rw-r--r--src/extension/implementation/script.cpp62
-rw-r--r--src/extension/implementation/script.h45
-rw-r--r--src/extension/init.cpp2
-rw-r--r--src/extension/internal/cairo-render-context.cpp90
-rw-r--r--src/extension/internal/cairo-render-context.h9
-rw-r--r--src/extension/internal/cairo-renderer.cpp30
-rw-r--r--src/extension/internal/cdr-input.cpp179
-rw-r--r--src/extension/internal/emf-print.cpp2
-rw-r--r--src/extension/internal/image-resolution.cpp78
-rw-r--r--src/extension/internal/text_reassemble.c82
-rw-r--r--src/extension/internal/vsd-input.cpp183
-rw-r--r--src/extension/loader.cpp137
-rw-r--r--src/extension/loader.h73
-rw-r--r--src/extension/output.cpp3
-rw-r--r--src/extension/plugins/CMakeLists.txt1
-rw-r--r--src/extension/plugins/grid2/CMakeLists.txt8
-rw-r--r--src/extension/plugins/grid2/grid.cpp220
-rw-r--r--src/extension/plugins/grid2/grid.h58
-rw-r--r--src/extension/plugins/grid2/libgrid2.inx20
-rw-r--r--src/extension/system.cpp26
28 files changed, 1044 insertions, 359 deletions
diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt
index 21e652563..a5352d0ba 100644
--- a/src/extension/CMakeLists.txt
+++ b/src/extension/CMakeLists.txt
@@ -14,6 +14,7 @@ set(extension_SRC
print.cpp
system.cpp
timer.cpp
+ loader.cpp
implementation/implementation.cpp
implementation/xslt.cpp
@@ -90,6 +91,7 @@ set(extension_SRC
print.h
system.h
timer.h
+ loader.h
implementation/implementation.h
implementation/script.h
@@ -244,21 +246,10 @@ if(WITH_IMAGE_MAGICK)
endif()
if(WITH_DBUS)
- list(APPEND extension_SRC
- dbus/application-interface.cpp
- dbus/dbus-init.cpp
- dbus/document-interface.cpp
-
- # ------
- # Header
- dbus/application-interface.h
- dbus/dbus-init.h
- dbus/document-interface.h
- dbus/wrapper/inkscape-dbus-wrapper.h
- )
-
- include_directories(dbus)
+ add_subdirectory(dbus)
endif()
# add_inkscape_lib(extension_LIB "${extension_SRC}")
add_inkscape_source("${extension_SRC}")
+
+add_subdirectory( plugins )
diff --git a/src/extension/Makefile_insert b/src/extension/Makefile_insert
index 4e75de13a..fb9713904 100644
--- a/src/extension/Makefile_insert
+++ b/src/extension/Makefile_insert
@@ -13,6 +13,8 @@ ink_common_sources += \
extension/execution-env.h \
extension/init.cpp \
extension/init.h \
+ extension/loader.h \
+ extension/loader.cpp \
extension/param/parameter.h \
extension/param/parameter.cpp \
extension/param/notebook.h \
diff --git a/src/extension/dbus/CMakeLists.txt b/src/extension/dbus/CMakeLists.txt
new file mode 100644
index 000000000..ad9e1fd7d
--- /dev/null
+++ b/src/extension/dbus/CMakeLists.txt
@@ -0,0 +1,29 @@
+if(WITH_DBUS)
+include_directories(${CMAKE_BINARY_DIR}/src/extension/dbus)
+set(dbus_SRC "")
+ list(APPEND dbus_SRC
+ application-interface.cpp
+ dbus-init.cpp
+ document-interface.cpp
+ )
+ add_custom_target(inkscape_dbus
+ DEPENDS ${CMAKE_BINARY_DIR}/src/extension/dbus/application-server-glue.h ${CMAKE_BINARY_DIR}/src/extension/dbus/document-server-glue.h ${CMAKE_BINARY_DIR}/src/extension/dbus/document-client-glue.h
+ )
+ add_custom_command(
+ OUTPUT ${CMAKE_BINARY_DIR}/src/extension/dbus/application-server-glue.h ${CMAKE_BINARY_DIR}/src/extension/dbus/document-server-glue.h ${CMAKE_BINARY_DIR}/src/extension/dbus/document-client-glue.h
+ DEPENDS ${CMAKE_SOURCE_DIR}/src/extension/dbus/application-interface.xml ${CMAKE_SOURCE_DIR}/src/extension/dbus/document-interface.xml
+ COMMAND dbus-binding-tool --mode=glib-server --output=${CMAKE_BINARY_DIR}/src/extension/dbus/application-server-glue.h --prefix=application_interface ${CMAKE_SOURCE_DIR}/src/extension/dbus/application-interface.xml
+ COMMAND dbus-binding-tool --mode=glib-server --output=${CMAKE_BINARY_DIR}/src/extension/dbus/document-server-glue.h --prefix=document_interface ${CMAKE_SOURCE_DIR}/src/extension/dbus/document-interface.xml
+ COMMAND dbus-binding-tool --mode=glib-client --output=${CMAKE_BINARY_DIR}/src/extension/dbus/document-client-glue.h --prefix=document_interface ${CMAKE_SOURCE_DIR}/src/extension/dbus/document-interface.xml
+ )
+ set_source_files_properties(
+ ${CMAKE_BINARY_DIR}/src/extension/dbus/application-server-glue.h
+ PROPERTIES GENERATED TRUE)
+ set_source_files_properties(
+ ${CMAKE_BINARY_DIR}/src/extension/dbus/document-server-glue.h
+ PROPERTIES GENERATED TRUE)
+ set_source_files_properties(
+ ${CMAKE_BINARY_DIR}/src/extension/dbus/document-client-glue.h
+ PROPERTIES GENERATED TRUE)
+add_inkscape_source("${dbus_SRC}")
+endif()
diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp
index d64bdbc5c..d0a2e81aa 100644
--- a/src/extension/dbus/document-interface.cpp
+++ b/src/extension/dbus/document-interface.cpp
@@ -1,7 +1,7 @@
/*
* This is where the implementation of the DBus based document API lives.
* All the methods in here (except in the helper section) are
- * designed to be called remotly via DBus. application-interface.cpp
+ * designed to be called remotely via DBus. application-interface.cpp
* has the methods used to connect to the bus and get a document instance.
*
* Documentation for these methods is in document-interface.xml
@@ -1052,7 +1052,7 @@ void document_interface_pause_updates(DocumentInterface *doc_interface, GError *
SPDesktop *desk = doc_interface->target.getDesktop();
g_return_if_fail(ensure_desktop_valid(desk, error));
doc_interface->updates = FALSE;
- desk->canvas->drawing_disabled = 1;
+ desk->canvas->_drawing_disabled = 1;
}
void document_interface_resume_updates(DocumentInterface *doc_interface, GError ** error)
@@ -1060,7 +1060,7 @@ void document_interface_resume_updates(DocumentInterface *doc_interface, GError
SPDesktop *desk = doc_interface->target.getDesktop();
g_return_if_fail(ensure_desktop_valid(desk, error));
doc_interface->updates = TRUE;
- desk->canvas->drawing_disabled = 0;
+ desk->canvas->_drawing_disabled = 0;
//FIXME: use better verb than rect.
Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), SP_VERB_CONTEXT_RECT, "Multiple actions");
}
diff --git a/src/extension/dependency.cpp b/src/extension/dependency.cpp
index e46b6fbd2..624be12f9 100644
--- a/src/extension/dependency.cpp
+++ b/src/extension/dependency.cpp
@@ -235,6 +235,18 @@ bool Dependency::check (void) const
}
/**
+ \brief Accessor to the name attribute.
+ \return A string containing the name of the dependency.
+
+ Returns the name of the dependency as found in the configuration file.
+
+*/
+const gchar* Dependency::get_name()
+{
+ return _string;
+}
+
+/**
\brief Print out a dependency to a string.
*/
std::ostream &
diff --git a/src/extension/dependency.h b/src/extension/dependency.h
index 829912dc3..8f5dcc0c8 100644
--- a/src/extension/dependency.h
+++ b/src/extension/dependency.h
@@ -58,6 +58,7 @@ public:
Dependency (Inkscape::XML::Node * in_repr);
virtual ~Dependency (void);
bool check (void) const;
+ const gchar* get_name();
Glib::ustring &get_help (void) const;
Glib::ustring &get_link (void) const;
diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp
index 31491605b..d5c80f26e 100644
--- a/src/extension/execution-env.cpp
+++ b/src/extension/execution-env.cpp
@@ -128,7 +128,7 @@ ExecutionEnv::createWorkingDialog (void) {
}
SPDesktop *desktop = (SPDesktop *)_doc;
- GtkWidget *toplevel = gtk_widget_get_toplevel(&(desktop->canvas->widget));
+ GtkWidget *toplevel = gtk_widget_get_toplevel(GTK_WIDGET(desktop->canvas));
if (!toplevel || !gtk_widget_is_toplevel (toplevel))
return;
Gtk::Window *window = Glib::wrap(GTK_WINDOW(toplevel), false);
diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h
index f6f933aaf..1232ae0c8 100644
--- a/src/extension/implementation/implementation.h
+++ b/src/extension/implementation/implementation.h
@@ -18,7 +18,7 @@
#include <2geom/forward.h>
namespace Gtk {
- class Widget;
+ class Widget;
}
class SPDocument;
@@ -33,7 +33,7 @@ class View;
} // namespace UI
namespace XML {
- class Node;
+ class Node;
} // namespace XML
namespace Extension {
@@ -51,18 +51,18 @@ namespace Implementation {
*/
class ImplementationDocumentCache {
- /**
+ /**
* The document that this instance is working on.
*/
- Inkscape::UI::View::View * _view;
+ Inkscape::UI::View::View * _view;
public:
- ImplementationDocumentCache (Inkscape::UI::View::View * view) :
- _view(view)
- {
- return;
- };
- virtual ~ImplementationDocumentCache ( ) { return; };
- Inkscape::UI::View::View const * view ( ) { return _view; };
+ ImplementationDocumentCache (Inkscape::UI::View::View * view) :
+ _view(view)
+ {
+ return;
+ };
+ virtual ~ImplementationDocumentCache ( ) { return; };
+ Inkscape::UI::View::View const * view ( ) { return _view; };
};
/**
@@ -116,7 +116,7 @@ public:
// ----- Effect functions -----
/** Find out information about the file. */
virtual Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module,
- Inkscape::UI::View::View *view,
+ Inkscape::UI::View::View *view,
sigc::signal<void> *changeSignal,
ImplementationDocumentCache *docCache);
virtual void effect(Inkscape::Extension::Effect * /*module*/,
diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp
index 4cb0c9b73..9aaf4b952 100644
--- a/src/extension/implementation/script.cpp
+++ b/src/extension/implementation/script.cpp
@@ -152,7 +152,7 @@ Script::Script() :
}
/**
- * brief Destructor
+ * \brief Destructor
*/
Script::~Script()
{
@@ -232,11 +232,7 @@ bool Script::check_existence(const std::string &command)
//Don't search when it is an absolute path. */
if (Glib::path_is_absolute(command)) {
- if (Glib::file_test(command, Glib::FILE_TEST_EXISTS)) {
- return true;
- } else {
- return false;
- }
+ return Glib::file_test(command, Glib::FILE_TEST_EXISTS);
}
// First search in the current directory
@@ -280,9 +276,9 @@ bool Script::check_existence(const std::string &command)
/**
\return none
- \brief This function 'loads' an extention, basically it determines
- the full command for the extention and stores that.
- \param module The extention to be loaded.
+ \brief This function 'loads' an extension, basically it determines
+ the full command for the extension and stores that.
+ \param module The extension to be loaded.
The most difficult part about this function is finding the actual
command through all of the Reprs. Basically it is hidden down a
@@ -292,7 +288,7 @@ bool Script::check_existence(const std::string &command)
At that point all of the loops are exited, and there is an
if statement to make sure they didn't exit because of not finding
- the command. If that's the case, the extention doesn't get loaded
+ the command. If that's the case, the extension doesn't get loaded
and should error out at a higher level.
*/
@@ -545,17 +541,17 @@ SPDocument *Script::open(Inkscape::Extension::Input *module,
/**
\return none
- \brief This function uses an extention to save a document. It first
+ \brief This function uses an extension to save a document. It first
creates an SVG file of the document, and then runs it through
the script.
- \param module Extention to be used
+ \param module Extension to be used
\param doc Document to be saved
\param filename The name to save the final file as
\return false in case of any failure writing the file, otherwise true
Well, at some point people need to save - it is really what makes
the entire application useful. And, it is possible that someone
- would want to use an extetion for this, so we need a function to
+ would want to use an extension for this, so we need a function to
do that eh?
First things first, the document is saved to a temporary file that
@@ -563,7 +559,7 @@ SPDocument *Script::open(Inkscape::Extension::Input *module,
ink_ext_ as a prefix. Don't worry, this file gets deleted at the
end of the function.
- After we have the SVG file, then extention_execute is called with
+ After we have the SVG file, then Script::execute is called with
the temporary file name and the final output filename. This should
put the output of the script into the final output file. We then
delete the temporary file.
@@ -1123,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,
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index c16a5a899..af7af2cb1 100644
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
@@ -1,6 +1,6 @@
/*
* This is what gets executed to initialize all of the modules. For
- * the internal modules this invovles executing their initialization
+ * the internal modules this involves executing their initialization
* functions, for external ones it involves reading their .spmodule
* files and bringing them into Sodipodi.
*
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index f811f00ad..5d8b0e076 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -1453,8 +1453,11 @@ CairoRenderContext::_prepareRenderText()
}
}
+/* We need CairoPaintOrder as markers are rendered in a separate step and may be rendered
+ * inbetween fill and stroke.
+ */
bool
-CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, Geom::OptRect const &pbox)
+CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, Geom::OptRect const &pbox, CairoPaintOrder order)
{
g_assert( _is_valid );
@@ -1476,9 +1479,10 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
return true;
}
- bool no_fill = style->fill.isNone() || style->fill_opacity.value == 0;
+ bool no_fill = style->fill.isNone() || style->fill_opacity.value == 0 ||
+ order == STROKE_ONLY;
bool no_stroke = style->stroke.isNone() || style->stroke_width.computed < 1e-9 ||
- style->stroke_opacity.value == 0;
+ style->stroke_opacity.value == 0 || order == FILL_ONLY;
if (no_fill && no_stroke)
return true;
@@ -1492,14 +1496,17 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
pushLayer();
if (!no_fill) {
- _setFillStyle(style, pbox);
- setPathVector(pathv);
-
if (style->fill_rule.computed == SP_WIND_RULE_EVENODD) {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_EVEN_ODD);
} else {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_WINDING);
}
+ }
+
+ setPathVector(pathv);
+
+ if (!no_fill && (order == STROKE_OVER_FILL || order == FILL_ONLY)) {
+ _setFillStyle(style, pbox);
if (no_stroke)
cairo_fill(_cr);
@@ -1509,10 +1516,17 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
if (!no_stroke) {
_setStrokeStyle(style, pbox);
- if (no_fill)
- setPathVector(pathv);
- cairo_stroke(_cr);
+ if (no_fill || order == STROKE_OVER_FILL)
+ cairo_stroke(_cr);
+ else
+ cairo_stroke_preserve(_cr);
+ }
+
+ if (!no_fill && order == FILL_OVER_STROKE) {
+ _setFillStyle(style, pbox);
+
+ cairo_fill(_cr);
}
if (need_layer)
@@ -1642,7 +1656,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const &font_ma
return true;
// create a cairo_font_face from PangoFont
- double size = style->font_size.computed; /// \fixme why is this variable never used?
+ // double size = style->font_size.computed; /// \fixme why is this variable never used?
gpointer fonthash = (gpointer)font;
cairo_font_face_t *font_face = NULL;
if(font_table.find(fonthash)!=font_table.end())
@@ -1699,30 +1713,72 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const &font_ma
_showGlyphs(_cr, font, glyphtext, TRUE);
}
} else {
- bool fill = false, stroke = false, have_path = false;
+
+ bool fill = false;
if (style->fill.isColor() || style->fill.isPaintserver()) {
fill = true;
}
+ bool stroke = false;
if (style->stroke.isColor() || style->stroke.isPaintserver()) {
stroke = true;
}
- if (fill) {
+
+ // Text never has markers
+ bool stroke_over_fill = true;
+ if ( (style->paint_order.layer[0] == SP_CSS_PAINT_ORDER_STROKE &&
+ style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_FILL) ||
+
+ (style->paint_order.layer[0] == SP_CSS_PAINT_ORDER_STROKE &&
+ style->paint_order.layer[2] == SP_CSS_PAINT_ORDER_FILL) ||
+
+ (style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_STROKE &&
+ style->paint_order.layer[2] == SP_CSS_PAINT_ORDER_FILL) ) {
+ stroke_over_fill = false;
+ }
+
+ bool have_path = false;
+ if (fill && stroke_over_fill) {
_setFillStyle(style, Geom::OptRect());
if (_is_texttopath) {
_showGlyphs(_cr, font, glyphtext, true);
- have_path = true;
- if (stroke) cairo_fill_preserve(_cr);
- else cairo_fill(_cr);
+ if (stroke) {
+ cairo_fill_preserve(_cr);
+ have_path = true;
+ } else {
+ cairo_fill(_cr);
+ }
} else {
_showGlyphs(_cr, font, glyphtext, false);
}
}
+
if (stroke) {
_setStrokeStyle(style, Geom::OptRect());
- if (!have_path) _showGlyphs(_cr, font, glyphtext, true);
- cairo_stroke(_cr);
+ if (!have_path) {
+ _showGlyphs(_cr, font, glyphtext, true);
+ }
+ if (fill && _is_texttopath && !stroke_over_fill) {
+ cairo_stroke_preserve(_cr);
+ have_path = true;
+ } else {
+ cairo_stroke(_cr);
+ }
+ }
+
+ if (fill && !stroke_over_fill) {
+ _setFillStyle(style, Geom::OptRect());
+ if (_is_texttopath) {
+ if (!have_path) {
+ // Could happen if both 'stroke' and 'stroke_over_fill' are false
+ _showGlyphs(_cr, font, glyphtext, true);
+ }
+ cairo_fill(_cr);
+ } else {
+ _showGlyphs(_cr, font, glyphtext, false);
+ }
}
+
}
cairo_restore(_cr);
diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h
index b3ab3655a..dfa6084d1 100644
--- a/src/extension/internal/cairo-render-context.h
+++ b/src/extension/internal/cairo-render-context.h
@@ -148,7 +148,14 @@ public:
void addClippingRect(double x, double y, double width, double height);
/* Rendering methods */
- bool renderPathVector(Geom::PathVector const &pathv, SPStyle const *style, Geom::OptRect const &pbox);
+ enum CairoPaintOrder {
+ STROKE_OVER_FILL,
+ FILL_OVER_STROKE,
+ FILL_ONLY,
+ STROKE_ONLY
+ };
+
+ bool renderPathVector(Geom::PathVector const &pathv, SPStyle const *style, Geom::OptRect const &pbox, CairoPaintOrder order = STROKE_OVER_FILL);
bool renderImage(Inkscape::Pixbuf *pb,
Geom::Affine const &image_transform, SPStyle const *style);
bool renderGlyphtext(PangoFont *font, Geom::Affine const &font_matrix,
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index a4561fd11..5dc20ab06 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -194,7 +194,20 @@ static void sp_shape_render(SPShape *shape, CairoRenderContext *ctx)
return;
}
- ctx->renderPathVector(pathv, style, pbox);
+ if (style->paint_order.layer[0] == SP_CSS_PAINT_ORDER_NORMAL ||
+ (style->paint_order.layer[0] == SP_CSS_PAINT_ORDER_FILL &&
+ style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_STROKE)) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::STROKE_OVER_FILL);
+ } else if (style->paint_order.layer[0] == SP_CSS_PAINT_ORDER_STROKE &&
+ style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_FILL ) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::FILL_OVER_STROKE);
+ } else if (style->paint_order.layer[0] == SP_CSS_PAINT_ORDER_STROKE &&
+ style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_MARKER ) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::STROKE_ONLY);
+ } else if (style->paint_order.layer[0] == SP_CSS_PAINT_ORDER_FILL &&
+ style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_MARKER ) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::FILL_ONLY);
+ }
// START marker
for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START
@@ -287,6 +300,21 @@ static void sp_shape_render(SPShape *shape, CairoRenderContext *ctx)
sp_shape_render_invoke_marker_rendering(marker, tr, style, ctx);
}
}
+
+ if (style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_FILL &&
+ style->paint_order.layer[2] == SP_CSS_PAINT_ORDER_STROKE) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::STROKE_OVER_FILL);
+ } else if (style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_STROKE &&
+ style->paint_order.layer[2] == SP_CSS_PAINT_ORDER_FILL ) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::FILL_OVER_STROKE);
+ } else if (style->paint_order.layer[2] == SP_CSS_PAINT_ORDER_STROKE &&
+ style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_MARKER ) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::STROKE_ONLY);
+ } else if (style->paint_order.layer[2] == SP_CSS_PAINT_ORDER_FILL &&
+ style->paint_order.layer[1] == SP_CSS_PAINT_ORDER_MARKER ) {
+ ctx->renderPathVector(pathv, style, pbox, CairoRenderContext::FILL_ONLY);
+ }
+
}
static void sp_group_render(SPGroup *group, CairoRenderContext *ctx)
diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp
index a4e26e224..a26af2078 100644
--- a/src/extension/internal/cdr-input.cpp
+++ b/src/extension/internal/cdr-input.cpp
@@ -22,7 +22,6 @@
#include <string>
#include <cstring>
-#include <glibmm/regex.h>
#include <libcdr/libcdr.h>
@@ -42,28 +41,18 @@
#endif
#include <gtkmm/alignment.h>
-#include <gtkmm/comboboxtext.h>
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/scale.h>
+#include <gtkmm/spinbutton.h>
#include "extension/system.h"
#include "extension/input.h"
-#include "document.h"
+#include "document.h"
#include "document-private.h"
-#include "document-undo.h"
#include "inkscape.h"
#include "ui/dialog-events.h"
-#include <gtk/gtk.h>
-#include "ui/widget/spinbutton.h"
-#include "ui/widget/frame.h"
#include <glibmm/i18n.h>
-#include <gdkmm/general.h>
-
-#include "svg-view.h"
#include "svg-view-widget.h"
#include "util/units.h"
@@ -83,108 +72,99 @@ public:
void getImportSettings(Inkscape::XML::Node *prefs);
private:
- void _setPreviewPage(unsigned page);
+ void _setPreviewPage();
// Signal handlers
-#if !WITH_GTKMM_3_0
- bool _onExposePreview(GdkEventExpose *event);
-#endif
-
void _onPageNumberChanged();
+ void _onSpinButtonPress(GdkEventButton* button_event);
+ void _onSpinButtonRelease(GdkEventButton* button_event);
+ class Gtk::VBox * vbox1;
+ class Gtk::Widget * _previewArea;
class Gtk::Button * cancelbutton;
class Gtk::Button * okbutton;
class Gtk::Label * _labelSelect;
- class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
class Gtk::Label * _labelTotalPages;
- class Gtk::VBox * vbox1;
- class Gtk::VBox * vbox2;
- class Gtk::Widget * _previewArea;
+ class Gtk::SpinButton * _pageNumberSpin;
- const std::vector<RVNGString> &_vec; // Document to be imported
- unsigned _current_page; // Current selected page
- int _preview_width, _preview_height; // Size of the preview area
+ const std::vector<RVNGString> &_vec; // Document to be imported
+ unsigned _current_page; // Current selected page
+ bool _spinning; // whether SpinButton is pressed (i.e. we're "spinning")
};
CdrImportDialog::CdrImportDialog(const std::vector<RVNGString> &vec)
- : _vec(vec), _current_page(1)
+ : _vec(vec), _current_page(1), _spinning(false)
{
int num_pages = _vec.size();
if ( num_pages <= 1 )
return;
- cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
- okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
- _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
- // Page number
+ // Dialog settings
+ this->set_title(_("Page Selector"));
+ this->set_modal(true);
+ sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
+ this->property_window_position().set_value(Gtk::WIN_POS_NONE);
+ this->set_resizable(true);
+ this->property_destroy_with_parent().set_value(false);
+
+ // Preview area
+ _previewArea = Gtk::manage(new class Gtk::VBox());
+ vbox1 = Gtk::manage(new class Gtk::VBox());
+ vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0);
#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
- _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
+ this->get_content_area()->pack_start(*vbox1);
#else
- Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
- new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
- _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
+ this->get_vbox()->pack_start(*vbox1);
#endif
- _labelTotalPages = Gtk::manage(new class Gtk::Label());
- gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
- _labelTotalPages->set_label(label_text);
- g_free(label_text);
- vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
- SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
- _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
-
- vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
- cancelbutton->set_can_focus();
- cancelbutton->set_can_default();
- cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
- okbutton->set_can_focus();
- okbutton->set_can_default();
- okbutton->set_relief(Gtk::RELIEF_NORMAL);
- this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
+ // CONTROLS
+
+ // Buttons
+ cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
+ okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
+
+ // Labels
+ _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
+ _labelTotalPages = Gtk::manage(new class Gtk::Label());
_labelSelect->set_line_wrap(false);
_labelSelect->set_use_markup(false);
_labelSelect->set_selectable(false);
- _pageNumberSpin->set_can_focus();
- _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
- _pageNumberSpin->set_numeric(true);
- _pageNumberSpin->set_digits(0);
- _pageNumberSpin->set_wrap(false);
_labelTotalPages->set_line_wrap(false);
_labelTotalPages->set_use_markup(false);
_labelTotalPages->set_selectable(false);
- vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
+ _labelTotalPages->set_label(label_text);
+ g_free(label_text);
+
+ // Adjustment + spinner
#if WITH_GTKMM_3_0
- this->get_content_area()->set_homogeneous(false);
- this->get_content_area()->set_spacing(0);
- this->get_content_area()->pack_start(*vbox2);
+ Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
+ _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(_pageNumberSpin_adj, 1, 0));
#else
- this->get_vbox()->set_homogeneous(false);
- this->get_vbox()->set_spacing(0);
- this->get_vbox()->pack_start(*vbox2);
+ Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
+ _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(*_pageNumberSpin_adj, 1, 0));
#endif
- this->set_title(_("Page Selector"));
- this->set_modal(true);
- sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
- this->property_window_position().set_value(Gtk::WIN_POS_NONE);
- this->set_resizable(true);
- this->property_destroy_with_parent().set_value(false);
+ _pageNumberSpin->set_can_focus();
+ _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
+ _pageNumberSpin->set_numeric(true);
+ _pageNumberSpin->set_wrap(false);
+
+ this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
this->get_action_area()->add(*_labelSelect);
- this->add_action_widget(*_pageNumberSpin, -7);
+ this->add_action_widget(*_pageNumberSpin, Gtk::RESPONSE_ACCEPT);
this->get_action_area()->add(*_labelTotalPages);
- this->add_action_widget(*cancelbutton, -6);
- this->add_action_widget(*okbutton, -5);
- cancelbutton->show();
- okbutton->show();
- _labelSelect->show();
- _pageNumberSpin->show();
- _labelTotalPages->show();
- vbox1->show();
- _previewArea->show();
- vbox2->show();
+ this->add_action_widget(*cancelbutton, Gtk::RESPONSE_CANCEL);
+ this->add_action_widget(*okbutton, Gtk::RESPONSE_OK);
+
+ // Show all widgets in dialog
+ this->show_all();
// Connect signals
- _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &CdrImportDialog::_onPageNumberChanged));
+ _pageNumberSpin->signal_value_changed().connect(sigc::mem_fun(*this, &CdrImportDialog::_onPageNumberChanged));
+ _pageNumberSpin->signal_button_press_event().connect_notify(sigc::mem_fun(*this, &CdrImportDialog::_onSpinButtonPress));
+ _pageNumberSpin->signal_button_release_event().connect_notify(sigc::mem_fun(*this, &CdrImportDialog::_onSpinButtonRelease));
+
+ _setPreviewPage();
}
CdrImportDialog::~CdrImportDialog() {}
@@ -194,7 +174,7 @@ bool CdrImportDialog::showDialog()
show();
gint b = run();
hide();
- if ( b == Gtk::RESPONSE_OK ) {
+ if (b == Gtk::RESPONSE_OK || b == Gtk::RESPONSE_ACCEPT) {
return TRUE;
} else {
return FALSE;
@@ -210,22 +190,34 @@ void CdrImportDialog::_onPageNumberChanged()
{
unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int());
_current_page = CLAMP(page, 1U, _vec.size());
- _setPreviewPage(_current_page);
+ _setPreviewPage();
+}
+
+void CdrImportDialog::_onSpinButtonPress(GdkEventButton* /*button_event*/)
+{
+ _spinning = true;
+}
+
+void CdrImportDialog::_onSpinButtonRelease(GdkEventButton* /*button_event*/)
+{
+ _spinning = false;
+ _setPreviewPage();
}
/**
* \brief Renders the given page's thumbnail
*/
-void CdrImportDialog::_setPreviewPage(unsigned page)
+void CdrImportDialog::_setPreviewPage()
{
- SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
+ if (_spinning) {
+ return;
+ }
+
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[_current_page-1].cstr(), strlen(_vec[_current_page-1].cstr()), 0);
Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
std::swap(_previewArea, tmpPreviewArea);
- if (tmpPreviewArea) {
- _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
- delete tmpPreviewArea;
- }
- vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ delete tmpPreviewArea;
+ vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0);
_previewArea->show_now();
}
@@ -282,12 +274,7 @@ SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
}
}
- // remove consecutive closepath commands (see bug 1492153)
- Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create("(Z(?:\\s+Z)+)(?=[^<]+\")");
- Glib::ustring outString1 = Glib::ustring(tmpSVGOutput[page_num-1].cstr());
- Glib::ustring outString2 = regex->replace(outString1, 0, "Z", Glib::REGEX_MATCH_NEWLINE_ANY);
-
- SPDocument * doc = SPDocument::createNewDocFromMem(outString2.c_str(), outString2.bytes(), TRUE);
+ SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
// Set viewBox if it doesn't exist
if (doc && !doc->getRoot()->viewBox_set) {
diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp
index 3dfa5cb23..1c85182ae 100644
--- a/src/extension/internal/emf-print.cpp
+++ b/src/extension/internal/emf-print.cpp
@@ -253,7 +253,7 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc)
char *oldlocale = g_strdup(setlocale(LC_NUMERIC, NULL));
setlocale(LC_NUMERIC, "C");
- snprintf(buff, sizeof(buff) - 1, "Drawing=%.1lfx%.1lfpx, %.1lfx%.1lfmm", _width, _height, Inkscape::Util::Quantity::convert(dwInchesX, "in", "mm"), Inkscape::Util::Quantity::convert(dwInchesY, "in", "mm"));
+ snprintf(buff, sizeof(buff) - 1, "Drawing=%.1fx%.1fpx, %.1fx%.1fmm", _width, _height, Inkscape::Util::Quantity::convert(dwInchesX, "in", "mm"), Inkscape::Util::Quantity::convert(dwInchesY, "in", "mm"));
setlocale(LC_NUMERIC, oldlocale);
g_free(oldlocale);
rec = textcomment_set(buff);
diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp
index e96fd6437..57142bbdd 100644
--- a/src/extension/internal/image-resolution.cpp
+++ b/src/extension/internal/image-resolution.cpp
@@ -34,6 +34,18 @@
#include <Magick++.h>
#endif
+#define noIMAGE_RESOLUTION_DEBUG
+
+#ifdef IMAGE_RESOLUTION_DEBUG
+# define debug(f, a...) { g_print("%s(%d) %s:", \
+ __FILE__,__LINE__,__FUNCTION__); \
+ g_print(f, ## a); \
+ g_print("\n"); \
+ }
+#else
+# define debug(f, a...) /* */
+#endif
+
namespace Inkscape {
namespace Extension {
namespace Internal {
@@ -118,17 +130,38 @@ void ImageResolution::readpng(char const *fn) {
png_read_info(png_ptr, info_ptr);
png_uint_32 res_x, res_y;
+#ifdef PNG_INCH_CONVERSIONS_SUPPORTED
+ debug("PNG_INCH_CONVERSIONS_SUPPORTED");
+ res_x = png_get_x_pixels_per_inch(png_ptr, info_ptr);
+ res_y = png_get_y_pixels_per_inch(png_ptr, info_ptr);
+ if (res_x != 0 && res_y != 0) {
+ ok_ = true;
+ x_ = res_x * 1.0; // FIXME: implicit conversion of png_uint_32 to double ok?
+ y_ = res_y * 1.0; // FIXME: implicit conversion of png_uint_32 to double ok?
+ }
+#else
+ debug("PNG_RESOLUTION_METER");
int unit_type;
+ // FIXME: png_get_pHYs() fails to return expected values
+ // with clang (based on LLVM 3.2svn) from Xcode 4.6.3 (OS X 10.7.5)
png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, &unit_type);
- png_destroy_read_struct(&png_ptr, &info_ptr, 0);
- fclose(fp);
-
if (unit_type == PNG_RESOLUTION_METER) {
ok_ = true;
x_ = res_x * 2.54 / 100;
y_ = res_y * 2.54 / 100;
}
+#endif
+
+ png_destroy_read_struct(&png_ptr, &info_ptr, 0);
+ fclose(fp);
+
+ if (ok_) {
+ debug("xdpi: %f", x_);
+ debug("ydpi: %f", y_);
+ } else {
+ debug("FAILED");
+ }
}
#else
@@ -206,6 +239,13 @@ void ImageResolution::readexif(char const *fn) {
ok_ = true;
}
exif_data_free(ed);
+
+ if (ok_) {
+ debug("xdpi: %f", x_);
+ debug("ydpi: %f", y_);
+ } else {
+ debug("FAILED");
+ }
}
#else
@@ -256,6 +296,13 @@ void ImageResolution::readexiv(char const *fn) {
}
}
ok_ = havex && havey;
+
+ if (ok_) {
+ debug("xdpi: %f", x_);
+ debug("ydpi: %f", y_);
+ } else {
+ debug("FAILED");
+ }
}
#else
@@ -312,6 +359,7 @@ void ImageResolution::readjfif(char const *fn) {
jpeg_stdio_src(&cinfo, ifd);
jpeg_read_header(&cinfo, TRUE);
+ debug("cinfo.[XY]_density");
if (cinfo.saw_JFIF_marker) { // JFIF APP0 marker was seen
if ( cinfo.density_unit == 1 ) { // dots/inch
x_ = cinfo.X_density;
@@ -331,6 +379,13 @@ void ImageResolution::readjfif(char const *fn) {
}
jpeg_destroy_decompress(&cinfo);
fclose(ifd);
+
+ if (ok_) {
+ debug("xdpi: %f", x_);
+ debug("ydpi: %f", y_);
+ } else {
+ debug("FAILED");
+ }
}
#else
@@ -344,16 +399,17 @@ void ImageResolution::readjfif(char const *) {
#ifdef WITH_IMAGE_MAGICK
void ImageResolution::readmagick(char const *fn) {
Magick::Image image;
+ debug("Trying image.read");
try {
image.read(fn);
} catch (Magick::Error & err) {
- g_warning("ImageMagick error: %s", err.what());
+ debug("ImageMagick error: %s", err.what());
return;
- } catch (...) {
- g_warning("ImageResolution::readmagick: Unknown error");
+ } catch (std::exception & err) {
+ debug("ImageResolution::readmagick: %s", err.what());
return;
}
-
+ debug("image.[xy]Resolution");
std::string const type = image.magick();
x_ = image.xResolution();
y_ = image.yResolution();
@@ -367,6 +423,14 @@ void ImageResolution::readmagick(char const *fn) {
if (x_ != 0 && y_ != 0) {
ok_ = true;
}
+
+ if (ok_) {
+ debug("xdpi: %f", x_);
+ debug("ydpi: %f", y_);
+ } else {
+ debug("FAILED");
+ debug("Using default Inkscape import resolution");
+ }
}
#else
diff --git a/src/extension/internal/text_reassemble.c b/src/extension/internal/text_reassemble.c
index fa983b83d..b23176ed5 100644
--- a/src/extension/internal/text_reassemble.c
+++ b/src/extension/internal/text_reassemble.c
@@ -67,11 +67,11 @@ Optional compiler switches for development:
File: text_reassemble.c
-Version: 0.0.17
-Date: 21-MAY-2015
+Version: 0.0.18
+Date: 11-MAR-2016
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
-Copyright: 2015 David Mathog and California Institute of Technology (Caltech)
+Copyright: 2016 David Mathog and California Institute of Technology (Caltech)
*/
#ifdef __cplusplus
@@ -223,7 +223,7 @@ char *TR_construct_fontspec(const TCHUNK_SPECS *tsp, const char *fontname){
int newlen = 128 + strlen(fontname); /* too big, but not by much */
char *newfs = NULL;
newfs = (char *) malloc(newlen);
- sprintf(newfs,"%s:slant=%d:weight=%d:size=%lf:width=%d",fontname,tsp->italics,tsp->weight,tsp->fs,(tsp->co ? 75 : tsp->condensed));
+ sprintf(newfs,"%s:slant=%d:weight=%d:size=%f:width=%d",fontname,tsp->italics,tsp->weight,tsp->fs,(tsp->co ? 75 : tsp->condensed));
return(newfs);
}
@@ -804,7 +804,7 @@ int ftinfo_load_fontname(FT_INFO *fti, const char *fontspec){
int fb;
if(FcPatternGetBool( fpat, FC_OUTLINE, 0, &fb)== FcResultMatch){ printf("outline: %d\n",fb);fflush(stdout); }
if(FcPatternGetBool( fpat, FC_SCALABLE, 0, &fb)== FcResultMatch){ printf("scalable: %d\n",fb);fflush(stdout); }
- if(FcPatternGetDouble( fpat, FC_DPI, 0, &fd)== FcResultMatch){ printf("DPI: %lf\n",fd);fflush(stdout); }
+ if(FcPatternGetDouble( fpat, FC_DPI, 0, &fd)== FcResultMatch){ printf("DPI: %f\n",fd);fflush(stdout); }
if(FcPatternGetInteger( fpat, FC_FONTVERSION, 0, &fb)== FcResultMatch){ printf("fontversion: %d\n",fb);fflush(stdout); }
if(FcPatternGetString( fpat, FC_FULLNAME , 0, (FcChar8 **)&fs)== FcResultMatch){ printf("FULLNAME : %s\n",fs);fflush(stdout); }
if(FcPatternGetString( fpat, FC_FAMILY , 0, (FcChar8 **)&fs)== FcResultMatch){ printf("FAMILY : %s\n",fs);fflush(stdout); }
@@ -831,7 +831,7 @@ void ftinfo_dump(const FT_INFO *fti){
printf("fti used: %d\n",fti->used);
for(i=0; i< fti->used; i++){
fsp = &(fti->fonts[i]);
- printf("fti font: %6d space: %6d used: %6d spcadv %8lf fsize %8lf \n",i,fsp->space,fsp->used,fsp->spcadv,fsp->fsize);
+ printf("fti font: %6d space: %6d used: %6d spcadv %8f fsize %8f \n",i,fsp->space,fsp->used,fsp->spcadv,fsp->fsize);
printf(" file: %s\n",fsp->file);
printf(" fspc: %s\n",fsp->fontspec);
for(j=0;j<fsp->used;j++){
@@ -1123,18 +1123,18 @@ void cxinfo_dump(const TR_INFO *tri){
printf("cxi phase1: %d\n",cxi->phase1);
printf("cxi lines: %d\n",cxi->lines);
printf("cxi paras: %d\n",cxi->paras);
- printf("cxi xy: %lf , %lf\n",tri->x,tri->y);
+ printf("cxi xy: %f , %f\n",tri->x,tri->y);
for(i=0;i<cxi->used;i++){
csp = &(cxi->cx[i]);
bsp = &(bri->rects[csp->rt_cidx]);
printf("cxi cx[%d] type:%d rt_tidx:%d kids_used:%d kids_space:%d\n",i, csp->type, csp->rt_cidx, csp->kids.used, csp->kids.space);
- printf("cxi cx[%d] br (LL,UR) (%lf,%lf),(%lf,%lf)\n",i,bsp->xll,bsp->yll,bsp->xur,bsp->yur);
+ printf("cxi cx[%d] br (LL,UR) (%f,%f),(%f,%f)\n",i,bsp->xll,bsp->yll,bsp->xur,bsp->yur);
for(j=0;j<csp->kids.used;j++){
k = csp->kids.members[j];
bsp = &(bri->rects[k]);
if(csp->type == TR_TEXT || csp->type == TR_LINE){
- printf("cxi cx[%d] member:%3d tp_idx:%3d ldir:%d rt_tidx:%3d br (LL,UR) (%8.3lf,%8.3lf),(%8.3lf,%8.3lf) xy (%8.3lf,%8.3lf) kern (%8.3lf,%8.3lf) text:<%s> decor:%5.5x\n",
+ printf("cxi cx[%d] member:%3d tp_idx:%3d ldir:%d rt_tidx:%3d br (LL,UR) (%8.3f,%8.3f),(%8.3f,%8.3f) xy (%8.3f,%8.3f) kern (%8.3f,%8.3f) text:<%s> decor:%5.5x\n",
i, j, k, tpi->chunks[k].ldir, tpi->chunks[k].rt_tidx,
bsp->xll,bsp->yll,bsp->xur,bsp->yur,
tpi->chunks[k].x, tpi->chunks[k].y,
@@ -1311,7 +1311,7 @@ int brinfo_merge(BR_INFO *bri, int dst, int src){
bri->rects[dst].xur = TEREMAX(bri->rects[dst].xur, bri->rects[src].xur);
bri->rects[dst].yur = TEREMIN(bri->rects[dst].yur, bri->rects[src].yur); /* MIN because Y is positive DOWN */
/*
-printf("bri_Merge into rect:%d (LL,UR) dst:(%lf,%lf),(%lf,%lf) src:(%lf,%lf),(%lf,%lf)\n",dst,
+printf("bri_Merge into rect:%d (LL,UR) dst:(%f,%f),(%f,%f) src:(%f,%f),(%f,%f)\n",dst,
(bri->rects[dst].xll),
(bri->rects[dst].yll),
(bri->rects[dst].xur),
@@ -1374,7 +1374,7 @@ int brinfo_overlap(const BR_INFO *bri, int dst, int src, RT_PAD *rp_dst, RT_PAD
}
}
/*
-printf("Overlap status:%d\nOverlap trects (LL,UR) dst:(%lf,%lf),(%lf,%lf) src:(%lf,%lf),(%lf,%lf)\n",
+printf("Overlap status:%d\nOverlap trects (LL,UR) dst:(%f,%f),(%f,%f) src:(%f,%f),(%f,%f)\n",
status,
(br_dst->xll - rp_dst->left ),
(br_dst->yll - rp_dst->down ),
@@ -1384,7 +1384,7 @@ status,
(br_src->yll - rp_src->down ),
(br_src->xur + rp_src->right),
(br_src->yur + rp_src->up ));
-printf("Overlap brects (LL,UR) dst:(%lf,%lf),(%lf,%lf) src:(%lf,%lf),(%lf,%lf)\n",
+printf("Overlap brects (LL,UR) dst:(%f,%f),(%f,%f) src:(%f,%f),(%f,%f)\n",
(br_dst->xll),
(br_dst->yll),
(br_dst->xur),
@@ -1393,7 +1393,7 @@ printf("Overlap brects (LL,UR) dst:(%lf,%lf),(%lf,%lf) src:(%lf,%lf),(%lf,%lf)\n
(br_src->yll),
(br_src->xur),
(br_src->yur));
-printf("Overlap rprect (LL,UR) dst:(%lf,%lf),(%lf,%lf) src:(%lf,%lf),(%lf,%lf)\n",
+printf("Overlap rprect (LL,UR) dst:(%f,%f),(%f,%f) src:(%f,%f),(%f,%f)\n",
(rp_dst->left),
(rp_dst->down),
(rp_dst->right),
@@ -1481,7 +1481,7 @@ enum tr_classes brinfo_pp_alignment(const BR_INFO *bri, int dst, int src, double
newtype = TR_PARA_UJ;
}
/*
-printf("pp_align newtype:%d brects (LL,UR) dst:(%lf,%lf),(%lf,%lf) src:(%lf,%lf),(%lf,%lf)\n",
+printf("pp_align newtype:%d brects (LL,UR) dst:(%f,%f),(%f,%f) src:(%f,%f),(%f,%f)\n",
newtype,
(br_dst->xll),
(br_dst->yll),
@@ -1779,7 +1779,7 @@ int trinfo_load_textrec(TR_INFO *tri, const TCHUNK_SPECS *tsp, double escapement
tpi->chunks[current].y = x * sin(escapement) + y * cos(escapement);
/* Careful! face bbox does NOT scale with FT_Set_Char_Size
-printf("Face idx:%d bbox: xMax/Min:%ld,%ld yMax/Min:%ld,%ld UpEM:%d asc/des:%d,%d height:%d size:%lf\n",
+printf("Face idx:%d bbox: xMax/Min:%ld,%ld yMax/Min:%ld,%ld UpEM:%d asc/des:%d,%d height:%d size:%f\n",
idx,
fsp->face->bbox.xMax,fsp->face->bbox.xMin,
fsp->face->bbox.yMax,fsp->face->bbox.yMin,
@@ -1955,7 +1955,7 @@ void TR_layout_2_svg(TR_INFO *tri){
/* put rectangles down for each text string - debugging!!! This will not work properly for any Narrow fonts */
esc = tri->esc;
esc *= 2.0 * M_PI / 360.0; /* degrees to radians and change direction of rotation */
- sprintf(stransform,"transform=\"matrix(%lf,%lf,%lf,%lf,%lf,%lf)\"\n",cos(esc),-sin(esc),sin(esc),cos(esc), 1.25*x,1.25*y);
+ sprintf(stransform,"transform=\"matrix(%f,%f,%f,%f,%f,%f)\"\n",cos(esc),-sin(esc),sin(esc),cos(esc), 1.25*x,1.25*y);
for(i=cxi->phase1; i<cxi->used;i++){ /* over all complex members from phase2 == TR_PARA_* complexes */
csp = &(cxi->cx[i]);
for(j=0; j<csp->kids.used; j++){ /* over all members of these complexes, which are phase1 complexes */
@@ -1968,11 +1968,11 @@ void TR_layout_2_svg(TR_INFO *tri){
#if DBG_TR_PARA
TRPRINT(tri, "<rect\n");
TRPRINT(tri, "style=\"color:#0000FF;color-interpolation:sRGB;color-interpolation-filters:linearRGB;fill:none;stroke:#000000;stroke-width:0.8;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;clip-rule:nonzero\"\n");
- sprintf(obuf,"width=\"%lf\"\n", 1.25*(bri->rects[csp->rt_cidx].xur - bri->rects[csp->rt_cidx].xll));
+ sprintf(obuf,"width=\"%f\"\n", 1.25*(bri->rects[csp->rt_cidx].xur - bri->rects[csp->rt_cidx].xll));
TRPRINT(tri, obuf);
- sprintf(obuf,"height=\"%lf\"\n",1.25*(bri->rects[csp->rt_cidx].yll - bri->rects[csp->rt_cidx].yur));
+ sprintf(obuf,"height=\"%f\"\n",1.25*(bri->rects[csp->rt_cidx].yll - bri->rects[csp->rt_cidx].yur));
TRPRINT(tri, obuf);
- sprintf(obuf,"x=\"%lf\" y=\"%lf\"\n",1.25*(bri->rects[csp->rt_cidx].xll),1.25*(bri->rects[csp->rt_cidx].yur));
+ sprintf(obuf,"x=\"%f\" y=\"%f\"\n",1.25*(bri->rects[csp->rt_cidx].xll),1.25*(bri->rects[csp->rt_cidx].yur));
TRPRINT(tri, obuf);
TRPRINT(tri, stransform);
TRPRINT(tri, "/>\n");
@@ -1983,23 +1983,23 @@ void TR_layout_2_svg(TR_INFO *tri){
newy = 1.25*(bri->rects[tsp->rt_tidx].yur);
TRPRINT(tri, "<rect\n");
TRPRINT(tri, "style=\"color:#000000;color-interpolation:sRGB;color-interpolation-filters:linearRGB;fill:none;stroke:#00FF00;stroke-width:0.3;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;clip-rule:nonzero\"\n");
- sprintf(obuf,"width=\"%lf\"\n", 1.25*(bri->rects[tsp->rt_tidx].xur - bri->rects[tsp->rt_tidx].xll));
+ sprintf(obuf,"width=\"%f\"\n", 1.25*(bri->rects[tsp->rt_tidx].xur - bri->rects[tsp->rt_tidx].xll));
TRPRINT(tri, obuf);
- sprintf(obuf,"height=\"%lf\"\n",1.25*(bri->rects[tsp->rt_tidx].yll - bri->rects[tsp->rt_tidx].yur));
+ sprintf(obuf,"height=\"%f\"\n",1.25*(bri->rects[tsp->rt_tidx].yll - bri->rects[tsp->rt_tidx].yur));
TRPRINT(tri, obuf);
- sprintf(obuf,"x=\"%lf\" y=\"%lf\"\n",1.25*(bri->rects[tsp->rt_tidx].xll),newy);
+ sprintf(obuf,"x=\"%f\" y=\"%f\"\n",1.25*(bri->rects[tsp->rt_tidx].xll),newy);
TRPRINT(tri, obuf);
TRPRINT(tri, stransform);
TRPRINT(tri, "/>\n");
newy = 1.25*(bri->rects[tsp->rt_tidx].yll - tsp->boff);
- sprintf(obuf,"<text x=\"%lf\" y=\"%lf\"\n",newx, newy );
+ sprintf(obuf,"<text x=\"%f\" y=\"%f\"\n",newx, newy );
TRPRINT(tri, obuf);
sprintf(obuf,"xml:space=\"preserve\"\n");
TRPRINT(tri, obuf);
TRPRINT(tri, stransform);
TRPRINT(tri, "style=\"fill:#FF0000;");
- sprintf(obuf,"font-size:%lfpx;",tsp->fs*1.25); /*IMPORTANT, if the FS is given in pt it looks like crap in browsers. As if px != 1.25 pt, maybe 96 dpi not 90?*/
+ sprintf(obuf,"font-size:%fpx;",tsp->fs*1.25); /*IMPORTANT, if the FS is given in pt it looks like crap in browsers. As if px != 1.25 pt, maybe 96 dpi not 90?*/
TRPRINT(tri, obuf);
sprintf(obuf,"font-style:%s;",(tsp->italics ? "italic" : "normal"));
TRPRINT(tri, obuf);
@@ -2025,7 +2025,7 @@ void TR_layout_2_svg(TR_INFO *tri){
if(tri->usebk){
esc = tri->esc;
esc *= 2.0 * M_PI / 360.0; /* degrees to radians and change direction of rotation */
- sprintf(stransform,"transform=\"matrix(%lf,%lf,%lf,%lf,%lf,%lf)\"\n",cos(esc),-sin(esc),sin(esc),cos(esc), 1.25*x,1.25*y);
+ sprintf(stransform,"transform=\"matrix(%f,%f,%f,%f,%f,%f)\"\n",cos(esc),-sin(esc),sin(esc),cos(esc), 1.25*x,1.25*y);
for(i=cxi->phase1; i<cxi->used;i++){ /* over all complex members from phase2 == TR_PARA_* complexes */
TRPRINT(tri, "<g>\n"); /* group backgrounds for each <text> object in the SVG */
@@ -2037,11 +2037,11 @@ void TR_layout_2_svg(TR_INFO *tri){
TRPRINT(tri, "<rect\n");
sprintf(obuf,"style=\"color-interpolation:sRGB;color-interpolation-filters:linearRGB;fill:#%2.2X%2.2X%2.2X;;stroke:none;;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;clip-rule:nonzero\"\n",tri->bkcolor.Red,tri->bkcolor.Green,tri->bkcolor.Blue);
TRPRINT(tri, obuf);
- sprintf(obuf,"width=\"%lf\"\n", 1.25*(bri->rects[cline_sp->rt_cidx].xur - bri->rects[cline_sp->rt_cidx].xll));
+ sprintf(obuf,"width=\"%f\"\n", 1.25*(bri->rects[cline_sp->rt_cidx].xur - bri->rects[cline_sp->rt_cidx].xll));
TRPRINT(tri, obuf);
- sprintf(obuf,"height=\"%lf\"\n",1.25*(bri->rects[cline_sp->rt_cidx].yll - bri->rects[cline_sp->rt_cidx].yur));
+ sprintf(obuf,"height=\"%f\"\n",1.25*(bri->rects[cline_sp->rt_cidx].yll - bri->rects[cline_sp->rt_cidx].yur));
TRPRINT(tri, obuf);
- sprintf(obuf,"x=\"%lf\" y=\"%lf\"\n",1.25*(bri->rects[cline_sp->rt_cidx].xll),1.25*(bri->rects[cline_sp->rt_cidx].yur));
+ sprintf(obuf,"x=\"%f\" y=\"%f\"\n",1.25*(bri->rects[cline_sp->rt_cidx].xll),1.25*(bri->rects[cline_sp->rt_cidx].yur));
TRPRINT(tri, obuf);
TRPRINT(tri, stransform);
TRPRINT(tri, "/>\n");
@@ -2056,11 +2056,11 @@ void TR_layout_2_svg(TR_INFO *tri){
TRPRINT(tri, "<rect\n");
sprintf(obuf,"style=\"color-interpolation:sRGB;color-interpolation-filters:linearRGB;fill:#%2.2X%2.2X%2.2X;;stroke:none;;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;clip-rule:nonzero\"\n",tri->bkcolor.Red,tri->bkcolor.Green,tri->bkcolor.Blue);
TRPRINT(tri, obuf);
- sprintf(obuf,"width=\"%lf\"\n", 1.25*(bri->rects[csp->rt_cidx].xur - bri->rects[csp->rt_cidx].xll));
+ sprintf(obuf,"width=\"%f\"\n", 1.25*(bri->rects[csp->rt_cidx].xur - bri->rects[csp->rt_cidx].xll));
TRPRINT(tri, obuf);
- sprintf(obuf,"height=\"%lf\"\n",1.25*(bri->rects[csp->rt_cidx].yll - bri->rects[csp->rt_cidx].yur));
+ sprintf(obuf,"height=\"%f\"\n",1.25*(bri->rects[csp->rt_cidx].yll - bri->rects[csp->rt_cidx].yur));
TRPRINT(tri, obuf);
- sprintf(obuf,"x=\"%lf\" y=\"%lf\"\n",1.25*(bri->rects[csp->rt_cidx].xll),1.25*(bri->rects[csp->rt_cidx].yur));
+ sprintf(obuf,"x=\"%f\" y=\"%f\"\n",1.25*(bri->rects[csp->rt_cidx].xll),1.25*(bri->rects[csp->rt_cidx].yur));
TRPRINT(tri, obuf);
TRPRINT(tri, stransform);
TRPRINT(tri, "/>\n");
@@ -2072,11 +2072,11 @@ void TR_layout_2_svg(TR_INFO *tri){
TRPRINT(tri, "<rect\n");
sprintf(obuf,"style=\"color-interpolation:sRGB;color-interpolation-filters:linearRGB;fill:#%2.2X%2.2X%2.2X;;stroke:none;;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;clip-rule:nonzero\"\n",tri->bkcolor.Red,tri->bkcolor.Green,tri->bkcolor.Blue);
TRPRINT(tri, obuf);
- sprintf(obuf,"width=\"%lf\"\n", 1.25*(bri->rects[tsp->rt_tidx].xur - bri->rects[tsp->rt_tidx].xll));
+ sprintf(obuf,"width=\"%f\"\n", 1.25*(bri->rects[tsp->rt_tidx].xur - bri->rects[tsp->rt_tidx].xll));
TRPRINT(tri, obuf);
- sprintf(obuf,"height=\"%lf\"\n",1.25*(bri->rects[tsp->rt_tidx].yll - bri->rects[tsp->rt_tidx].yur));
+ sprintf(obuf,"height=\"%f\"\n",1.25*(bri->rects[tsp->rt_tidx].yll - bri->rects[tsp->rt_tidx].yur));
TRPRINT(tri, obuf);
- sprintf(obuf,"x=\"%lf\" y=\"%lf\"\n",newx,newy);
+ sprintf(obuf,"x=\"%f\" y=\"%f\"\n",newx,newy);
TRPRINT(tri, obuf);
TRPRINT(tri, stransform);
TRPRINT(tri, "/>\n");
@@ -2135,7 +2135,7 @@ void TR_layout_2_svg(TR_INFO *tri){
TRPRINT(tri, "<text\n");
TRPRINT(tri, "xml:space=\"preserve\"\n");
TRPRINT(tri, "style=\"");
- sprintf(obuf,"font-size:%lfpx;",tsp->fs*1.25); /*IMPORTANT, if the FS is given in pt it looks like crap in browsers. As if px != 1.25 pt, maybe 96 dpi not 90?*/
+ sprintf(obuf,"font-size:%fpx;",tsp->fs*1.25); /*IMPORTANT, if the FS is given in pt it looks like crap in browsers. As if px != 1.25 pt, maybe 96 dpi not 90?*/
TRPRINT(tri, obuf);
sprintf(obuf,"font-style:%s;",(tsp->italics ? "italic" : "normal"));
TRPRINT(tri, obuf);
@@ -2146,7 +2146,7 @@ void TR_layout_2_svg(TR_INFO *tri){
TRPRINT(tri, obuf);
if(tsp->vadvance){ lineheight = tsp->vadvance *100.0; }
else { lineheight = 125.0; }
- sprintf(obuf,"line-height:%lf%%;",lineheight);
+ sprintf(obuf,"line-height:%f%%;",lineheight);
TRPRINT(tri, obuf);
TRPRINT(tri, "letter-spacing:0px;");
TRPRINT(tri, "word-spacing:0px;");
@@ -2174,14 +2174,14 @@ void TR_layout_2_svg(TR_INFO *tri){
}
TRPRINT(tri, obuf);
TRPRINT(tri, "\"\n"); /* End of style specification */
- sprintf(obuf,"transform=\"matrix(%lf,%lf,%lf,%lf,%lf,%lf)\"\n",cos(esc),-sin(esc),sin(esc),cos(esc),1.25*x,1.25*y);
+ sprintf(obuf,"transform=\"matrix(%f,%f,%f,%f,%f,%f)\"\n",cos(esc),-sin(esc),sin(esc),cos(esc),1.25*x,1.25*y);
TRPRINT(tri, obuf);
tmpx = 1.25*((ldir == LDIR_RL ? bri->rects[kdx].xur : bri->rects[kdx].xll) + recenter);
- sprintf(obuf,"x=\"%lf\" y=\"%lf\"\n>",tmpx,1.25*(bri->rects[kdx].yll - tsp->boff));
+ sprintf(obuf,"x=\"%f\" y=\"%f\"\n>",tmpx,1.25*(bri->rects[kdx].yll - tsp->boff));
TRPRINT(tri, obuf);
}
tmpx = 1.25*((ldir == LDIR_RL ? bri->rects[kdx].xur : bri->rects[kdx].xll) + recenter);
- sprintf(obuf,"<tspan sodipodi:role=\"line\"\nx=\"%lf\" y=\"%lf\"\n>",tmpx,1.25*(bri->rects[kdx].yll - tsp->boff));
+ sprintf(obuf,"<tspan sodipodi:role=\"line\"\nx=\"%f\" y=\"%f\"\n>",tmpx,1.25*(bri->rects[kdx].yll - tsp->boff));
TRPRINT(tri, obuf);
}
TRPRINT(tri, "<tspan\n");
@@ -2192,11 +2192,11 @@ void TR_layout_2_svg(TR_INFO *tri){
dx = 1.25 * tsp->xkern;
dy = 1.25 * tsp->ykern;
- sprintf(obuf,"dx=\"%lf\" dy=\"%lf\" ",dx, dy);
+ sprintf(obuf,"dx=\"%f\" dy=\"%f\" ",dx, dy);
TRPRINT(tri, obuf);
sprintf(obuf,"style=\"fill:#%2.2X%2.2X%2.2X;",tsp->color.Red,tsp->color.Green,tsp->color.Blue);
TRPRINT(tri, obuf);
- sprintf(obuf,"font-size:%lfpx;",tsp->fs*1.25); /*IMPORTANT, if the FS is given in pt it looks like crap in browsers. As if px != 1.25 pt, maybe 96 dpi not 90?*/
+ sprintf(obuf,"font-size:%fpx;",tsp->fs*1.25); /*IMPORTANT, if the FS is given in pt it looks like crap in browsers. As if px != 1.25 pt, maybe 96 dpi not 90?*/
TRPRINT(tri, obuf);
sprintf(obuf,"font-style:%s;",(tsp->italics ? "italic" : "normal"));
TRPRINT(tri, obuf);
diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp
index 7fd0d363b..a3d4aad37 100644
--- a/src/extension/internal/vsd-input.cpp
+++ b/src/extension/internal/vsd-input.cpp
@@ -40,33 +40,24 @@
typedef libvisio::VSDStringVector RVNGStringVector;
#endif
-
#include <gtkmm/alignment.h>
-#include <gtkmm/comboboxtext.h>
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/scale.h>
+#include <gtkmm/spinbutton.h>
#include "extension/system.h"
#include "extension/input.h"
-#include "document.h"
+#include "document.h"
#include "document-private.h"
-#include "document-undo.h"
#include "inkscape.h"
-#include "util/units.h"
#include "ui/dialog-events.h"
-#include <gtk/gtk.h>
-#include "ui/widget/spinbutton.h"
-#include "ui/widget/frame.h"
#include <glibmm/i18n.h>
-#include <gdkmm/general.h>
-
-#include "svg-view.h"
#include "svg-view-widget.h"
+
+#include "util/units.h"
+
namespace Inkscape {
namespace Extension {
namespace Internal {
@@ -82,108 +73,101 @@ public:
void getImportSettings(Inkscape::XML::Node *prefs);
private:
- void _setPreviewPage(unsigned page);
+ void _setPreviewPage();
// Signal handlers
-#if !WITH_GTKMM_3_0
- bool _onExposePreview(GdkEventExpose *event);
-#endif
-
void _onPageNumberChanged();
+ void _onSpinButtonPress(GdkEventButton* button_event);
+ void _onSpinButtonRelease(GdkEventButton* button_event);
+ class Gtk::VBox * vbox1;
+ class Gtk::Widget * _previewArea;
class Gtk::Button * cancelbutton;
class Gtk::Button * okbutton;
class Gtk::Label * _labelSelect;
- class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
class Gtk::Label * _labelTotalPages;
- class Gtk::VBox * vbox1;
- class Gtk::VBox * vbox2;
- class Gtk::Widget * _previewArea;
+ class Gtk::SpinButton * _pageNumberSpin;
- const std::vector<RVNGString> &_vec; // Document to be imported
- unsigned _current_page; // Current selected page
- int _preview_width, _preview_height; // Size of the preview area
+ const std::vector<RVNGString> &_vec; // Document to be imported
+ unsigned _current_page; // Current selected page
+ bool _spinning; // whether SpinButton is pressed (i.e. we're "spinning")
};
VsdImportDialog::VsdImportDialog(const std::vector<RVNGString> &vec)
- : _vec(vec), _current_page(1)
+ : _vec(vec), _current_page(1), _spinning(false)
{
int num_pages = _vec.size();
if ( num_pages <= 1 )
return;
- cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
- okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
- _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
- // Page number
+
+ // Dialog settings
+ this->set_title(_("Page Selector"));
+ this->set_modal(true);
+ sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
+ this->property_window_position().set_value(Gtk::WIN_POS_NONE);
+ this->set_resizable(true);
+ this->property_destroy_with_parent().set_value(false);
+
+ // Preview area
+ _previewArea = Gtk::manage(new class Gtk::VBox());
+ vbox1 = Gtk::manage(new class Gtk::VBox());
+ vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0);
#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
- _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
+ this->get_content_area()->pack_start(*vbox1);
#else
- Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
- new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
- _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
+ this->get_vbox()->pack_start(*vbox1);
#endif
- _labelTotalPages = Gtk::manage(new class Gtk::Label());
- gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
- _labelTotalPages->set_label(label_text);
- g_free(label_text);
- vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
- SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
- _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
-
- vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
- cancelbutton->set_can_focus();
- cancelbutton->set_can_default();
- cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
- okbutton->set_can_focus();
- okbutton->set_can_default();
- okbutton->set_relief(Gtk::RELIEF_NORMAL);
- this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
+
+ // CONTROLS
+
+ // Buttons
+ cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
+ okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
+
+ // Labels
+ _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
+ _labelTotalPages = Gtk::manage(new class Gtk::Label());
_labelSelect->set_line_wrap(false);
_labelSelect->set_use_markup(false);
_labelSelect->set_selectable(false);
- _pageNumberSpin->set_can_focus();
- _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
- _pageNumberSpin->set_numeric(true);
- _pageNumberSpin->set_digits(0);
- _pageNumberSpin->set_wrap(false);
_labelTotalPages->set_line_wrap(false);
_labelTotalPages->set_use_markup(false);
_labelTotalPages->set_selectable(false);
- vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
+ _labelTotalPages->set_label(label_text);
+ g_free(label_text);
+
+ // Adjustment + spinner
#if WITH_GTKMM_3_0
- this->get_content_area()->set_homogeneous(false);
- this->get_content_area()->set_spacing(0);
- this->get_content_area()->pack_start(*vbox2);
+ Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
+ _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(_pageNumberSpin_adj, 1, 0));
#else
- this->get_vbox()->set_homogeneous(false);
- this->get_vbox()->set_spacing(0);
- this->get_vbox()->pack_start(*vbox2);
+ Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
+ _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(*_pageNumberSpin_adj, 1, 0));
#endif
- this->set_title(_("Page Selector"));
- this->set_modal(true);
- sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
- this->property_window_position().set_value(Gtk::WIN_POS_NONE);
- this->set_resizable(true);
- this->property_destroy_with_parent().set_value(false);
+ _pageNumberSpin->set_can_focus();
+ _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
+ _pageNumberSpin->set_numeric(true);
+ _pageNumberSpin->set_wrap(false);
+
+ this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
this->get_action_area()->add(*_labelSelect);
- this->add_action_widget(*_pageNumberSpin, -7);
+ this->add_action_widget(*_pageNumberSpin, Gtk::RESPONSE_ACCEPT);
this->get_action_area()->add(*_labelTotalPages);
- this->add_action_widget(*cancelbutton, -6);
- this->add_action_widget(*okbutton, -5);
- cancelbutton->show();
- okbutton->show();
- _labelSelect->show();
- _pageNumberSpin->show();
- _labelTotalPages->show();
- vbox1->show();
- _previewArea->show();
- vbox2->show();
+ this->add_action_widget(*cancelbutton, Gtk::RESPONSE_CANCEL);
+ this->add_action_widget(*okbutton, Gtk::RESPONSE_OK);
+
+ // Show all widgets in dialog
+ this->show_all();
// Connect signals
- _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged));
+ _pageNumberSpin->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged));
+ _pageNumberSpin->signal_button_press_event().connect_notify(sigc::mem_fun(*this, &VsdImportDialog::_onSpinButtonPress));
+ _pageNumberSpin->signal_button_release_event().connect_notify(sigc::mem_fun(*this, &VsdImportDialog::_onSpinButtonRelease));
+
+ _setPreviewPage();
}
VsdImportDialog::~VsdImportDialog() {}
@@ -193,7 +177,7 @@ bool VsdImportDialog::showDialog()
show();
gint b = run();
hide();
- if ( b == Gtk::RESPONSE_OK ) {
+ if (b == Gtk::RESPONSE_OK || b == Gtk::RESPONSE_ACCEPT) {
return TRUE;
} else {
return FALSE;
@@ -209,22 +193,34 @@ void VsdImportDialog::_onPageNumberChanged()
{
unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int());
_current_page = CLAMP(page, 1U, _vec.size());
- _setPreviewPage(_current_page);
+ _setPreviewPage();
+}
+
+void VsdImportDialog::_onSpinButtonPress(GdkEventButton* /*button_event*/)
+{
+ _spinning = true;
+}
+
+void VsdImportDialog::_onSpinButtonRelease(GdkEventButton* /*button_event*/)
+{
+ _spinning = false;
+ _setPreviewPage();
}
/**
* \brief Renders the given page's thumbnail
*/
-void VsdImportDialog::_setPreviewPage(unsigned page)
+void VsdImportDialog::_setPreviewPage()
{
- SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
+ if (_spinning) {
+ return;
+ }
+
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[_current_page-1].cstr(), strlen(_vec[_current_page-1].cstr()), 0);
Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
std::swap(_previewArea, tmpPreviewArea);
- if (tmpPreviewArea) {
- _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
- delete tmpPreviewArea;
- }
- vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ delete tmpPreviewArea;
+ vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0);
_previewArea->show_now();
}
@@ -282,12 +278,11 @@ SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
}
SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
-
+
// Set viewBox if it doesn't exist
- if (!doc->getRoot()->viewBox_set) {
+ if (doc && !doc->getRoot()->viewBox_set) {
doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDisplayUnit()), doc->getHeight().value(doc->getDisplayUnit())));
}
-
return doc;
}
diff --git a/src/extension/loader.cpp b/src/extension/loader.cpp
new file mode 100644
index 000000000..863a176ca
--- /dev/null
+++ b/src/extension/loader.cpp
@@ -0,0 +1,137 @@
+/*
+ * Loader for external plug-ins.
+ *
+ * Authors:
+ * Moritz Eberl <moritz@semiodesk.com>
+ *
+ * Copyright (C) 2016 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "loader.h"
+#include "system.h"
+#include <exception>
+#include <string.h>
+#include "dependency.h"
+#include "inkscape-version.h"
+
+namespace Inkscape {
+namespace Extension {
+
+typedef Implementation::Implementation *(*_getImplementation)(void);
+typedef const gchar *(*_getInkscapeVersion)(void);
+
+bool Loader::load_dependency(Dependency *dep)
+{
+ GModule *module = NULL;
+ module = g_module_open(dep->get_name(), (GModuleFlags)0);
+ if (module == NULL) {
+ return false;
+ }
+ return true;
+}
+
+/**
+ * @brief Load the actual implementation of a plugin supplied by the plugin.
+ * @param doc The xml representation of the INX extension configuration.
+ * @return The implementation of the extension loaded from the plugin.
+ */
+Implementation::Implementation *Loader::load_implementation(Inkscape::XML::Document *doc)
+{
+ try {
+
+ Inkscape::XML::Node *repr = doc->root();
+ Inkscape::XML::Node *child_repr = repr->firstChild();
+
+ // Iterate over the xml content
+ while (child_repr != NULL) {
+ char const *chname = child_repr->name();
+ if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) {
+ chname += strlen(INKSCAPE_EXTENSION_NS);
+ }
+
+ // Deal with dependencies if we have them
+ if (!strcmp(chname, "dependency")) {
+ Dependency dep = Dependency(child_repr);
+ // try to load it
+ bool success = load_dependency(&dep);
+ if( !success ){
+ // Could not load dependency, we abort
+ const char *res = g_module_error();
+ g_warning("Unable to load dependency %s of plugin %s.\nDetails: %s\n", dep.get_name(), "<todo>", res);
+ return NULL;
+ }
+ }
+
+ // Found a plugin to load
+ if (!strcmp(chname, "plugin")) {
+
+ // The name of the plugin is actually the library file we want to load
+ if (const gchar *name = child_repr->attribute("name")) {
+ GModule *module = NULL;
+ _getImplementation GetImplementation = NULL;
+ _getInkscapeVersion GetInkscapeVersion = NULL;
+
+ // build the path where to look for the plugin
+ gchar *path = g_build_filename(_baseDirectory.c_str(), name, (char *) NULL);
+ module = g_module_open(path, G_MODULE_BIND_LOCAL);
+ g_free(path);
+
+ if (module == NULL) {
+ // we were not able to load the plugin, write warning and abort
+ const char *res = g_module_error();
+ g_warning("Unable to load extension %s.\nDetails: %s\n", name, res);
+ return NULL;
+ }
+
+ // Get a handle to the version function of the module
+ if (g_module_symbol(module, "GetInkscapeVersion", (gpointer *) &GetInkscapeVersion) == FALSE) {
+ // This didn't work, write warning and abort
+ const char *res = g_module_error();
+ g_warning("Unable to load extension %s.\nDetails: %s\n", name, res);
+ return NULL;
+ }
+
+ // Get a handle to the function that delivers the implementation
+ if (g_module_symbol(module, "GetImplementation", (gpointer *) &GetImplementation) == FALSE) {
+ // This didn't work, write warning and abort
+ const char *res = g_module_error();
+ g_warning("Unable to load extension %s.\nDetails: %s\n", name, res);
+ return NULL;
+ }
+
+ // Get version and test against this version
+ const gchar* version = GetInkscapeVersion();
+ if( strcmp(version, version_string) != 0) {
+ // The versions are different, display warning.
+ g_warning("Plugin was built against Inkscape version %s, this is %s. The plugin might not be compatible.", version, version_string);
+ }
+
+
+ Implementation::Implementation *i = GetImplementation();
+ return i;
+ }
+ }
+
+ child_repr = child_repr->next();
+ }
+ } catch (std::exception &e) {
+ g_warning("Unable to load extension.");
+ }
+ return NULL;
+}
+
+} // namespace Extension
+} // namespace Inkscape
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace .0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99:
diff --git a/src/extension/loader.h b/src/extension/loader.h
new file mode 100644
index 000000000..0d3a69061
--- /dev/null
+++ b/src/extension/loader.h
@@ -0,0 +1,73 @@
+/** @file
+ * Loader for external plug-ins.
+ *//*
+ *
+ * Authors:
+ * Moritz Eberl <moritz@semiodesk.com>
+ *
+ * Copyright (C) 2016 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef INKSCAPE_EXTENSION_LOADER_H_
+#define INKSCAPE_EXTENSION_LOADER_H_
+
+#include "extension.h"
+#include "implementation/implementation.h"
+#include <gmodule.h>
+
+
+namespace Inkscape {
+namespace Extension {
+
+/** This class contains the mechanism to load c++ plugins dynamically.
+*/
+class Loader {
+
+public:
+ /**
+ * Sets a base directory where to look for the actual plugin to load.
+ *
+ * @param dir is the path where the plugin should be loaded from.
+ */
+ void set_base_directory(std::string dir) {
+ _baseDirectory = dir;
+ }
+
+ /**
+ * Loads plugin dependencies which are needed for the plugin to load.
+ *
+ * @param dep
+ */
+ bool load_dependency(Dependency *dep);
+
+ /**
+ * Load the actual implementation of a plugin supplied by the plugin.
+ *
+ * @param doc The xml representation of the INX extension configuration.
+ * @return The implementation of the extension loaded from the plugin.
+ */
+ Implementation::Implementation *load_implementation(Inkscape::XML::Document *doc);
+
+private:
+ std::string _baseDirectory; /**< The base directory to load a plugin from */
+
+
+};
+
+} // namespace Extension
+} // namespace Inkscape */
+
+#endif // _LOADER_H_
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace .0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99:
diff --git a/src/extension/output.cpp b/src/extension/output.cpp
index 8de5583c7..83f0fed2f 100644
--- a/src/extension/output.cpp
+++ b/src/extension/output.cpp
@@ -192,8 +192,7 @@ Output::prefs (void)
delete dialog;
- if (response == Gtk::RESPONSE_OK) return true;
- return false;
+ return (response == Gtk::RESPONSE_OK);
}
/**
diff --git a/src/extension/plugins/CMakeLists.txt b/src/extension/plugins/CMakeLists.txt
new file mode 100644
index 000000000..78f268c6b
--- /dev/null
+++ b/src/extension/plugins/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(grid2)
diff --git a/src/extension/plugins/grid2/CMakeLists.txt b/src/extension/plugins/grid2/CMakeLists.txt
new file mode 100644
index 000000000..f39e259de
--- /dev/null
+++ b/src/extension/plugins/grid2/CMakeLists.txt
@@ -0,0 +1,8 @@
+set(grid_PART_SRCS grid.cpp)
+
+include_directories( ${CMAKE_BINARY_DIR}/src )
+
+add_library(grid2 SHARED ${grid_PART_SRCS})
+
+target_link_libraries(grid2 inkscape_base)
+
diff --git a/src/extension/plugins/grid2/grid.cpp b/src/extension/plugins/grid2/grid.cpp
new file mode 100644
index 000000000..3a2ed7867
--- /dev/null
+++ b/src/extension/plugins/grid2/grid.cpp
@@ -0,0 +1,220 @@
+/**
+ \file grid.cpp
+
+ A plug-in to add a grid creation effect into Inkscape.
+*/
+/*
+ * Copyright (C) 2004-2005 Ted Gould <ted@gould.cx>
+ * Copyright (C) 2007 MenTaLguY <mental@rydia.net>
+ * Abhishek Sharma
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gtkmm/box.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/spinbutton.h>
+
+#include "desktop.h"
+
+#include "document.h"
+#include "selection.h"
+#include "sp-object.h"
+#include "2geom/geom.h"
+
+#include "svg/path-string.h"
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "util/units.h"
+
+#include "grid.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+/**
+ \brief A function to allocated anything -- just an example here
+ \param module Unused
+ \return Whether the load was sucessful
+*/
+bool
+Grid::load (Inkscape::Extension::Extension */*module*/)
+{
+ // std::cout << "Hey, I'm Grid, I'm loading!" << std::endl;
+ return TRUE;
+}
+
+namespace {
+
+Glib::ustring build_lines(Geom::Rect bounding_area,
+ Geom::Point const &offset, Geom::Point const &spacing)
+{
+
+ std::cout << "Building lines" << std::endl;
+
+ Geom::Point point_offset(0.0, 0.0);
+
+ SVG::PathString path_data;
+
+ for ( int axis = Geom::X ; axis <= Geom::Y ; ++axis ) {
+ point_offset[axis] = offset[axis];
+
+ for (Geom::Point start_point = bounding_area.min();
+ start_point[axis] + offset[axis] <= (bounding_area.max())[axis];
+ start_point[axis] += spacing[axis]) {
+ Geom::Point end_point = start_point;
+ end_point[1-axis] = (bounding_area.max())[1-axis];
+
+ path_data.moveTo(start_point + point_offset)
+ .lineTo(end_point + point_offset);
+ }
+ }
+ std::cout << "Path data:" << path_data.c_str() << std::endl;
+ return path_data;
+}
+
+} // namespace
+
+/**
+ \brief This actually draws the grid.
+ \param module The effect that was called (unused)
+ \param document What should be edited.
+*/
+void
+Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * /*docCache*/)
+{
+
+ std::cout << "Executing effect" << std::endl;
+
+ Inkscape::Selection * selection = ((SPDesktop *)document)->selection;
+
+ Geom::Rect bounding_area = Geom::Rect(Geom::Point(0,0), Geom::Point(100,100));
+ if (selection->isEmpty()) {
+ /* get page size */
+ SPDocument * doc = document->doc();
+ bounding_area = Geom::Rect( Geom::Point(0,0),
+ Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px")) );
+ } else {
+ Geom::OptRect bounds = selection->visualBounds();
+ if (bounds) {
+ bounding_area = *bounds;
+ }
+
+ gdouble doc_height = (document->doc())->getHeight().value("px");
+ Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]),
+ Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y]));
+
+ bounding_area = temprec;
+ }
+
+ gdouble scale = Inkscape::Util::Quantity::convert(1, "px", &document->doc()->getSVGUnit());
+ bounding_area *= Geom::Scale(scale);
+ Geom::Point spacings( scale * module->get_param_float("xspacing"),
+ scale * module->get_param_float("yspacing") );
+ gdouble line_width = scale * module->get_param_float("lineWidth");
+ Geom::Point offsets( scale * module->get_param_float("xoffset"),
+ scale * module->get_param_float("yoffset") );
+
+ Glib::ustring path_data("");
+
+ path_data = build_lines(bounding_area, offsets, spacings);
+ Inkscape::XML::Document * xml_doc = document->doc()->getReprDoc();
+
+ //XML Tree being used directly here while it shouldn't be.
+ Inkscape::XML::Node * current_layer = static_cast<SPDesktop *>(document)->currentLayer()->getRepr();
+ Inkscape::XML::Node * path = xml_doc->createElement("svg:path");
+
+ path->setAttribute("d", path_data.c_str());
+
+ Glib::ustring style("fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000");
+ style += ";stroke-width:";
+ gchar floatstring[64];
+ std::ostringstream stringstream;
+ stringstream << line_width;
+ sprintf(floatstring, "%s", stringstream.str().c_str());
+ style += floatstring;
+ style += "pt";
+ path->setAttribute("style", style.c_str());
+
+ current_layer->appendChild(path);
+ Inkscape::GC::release(path);
+}
+
+/** \brief A class to make an adjustment that uses Extension params */
+class PrefAdjustment : public Gtk::Adjustment {
+ /** Extension that this relates to */
+ Inkscape::Extension::Extension * _ext;
+ /** The string which represents the parameter */
+ char * _pref;
+public:
+ /** \brief Make the adjustment using an extension and the string
+ describing the parameter. */
+ PrefAdjustment(Inkscape::Extension::Extension * ext, char * pref) :
+ Gtk::Adjustment(0.0, 0.0, 10.0, 0.1), _ext(ext), _pref(pref) {
+ this->set_value(_ext->get_param_float(_pref));
+ this->signal_value_changed().connect(sigc::mem_fun(this, &PrefAdjustment::val_changed));
+ return;
+ };
+
+ void val_changed (void);
+}; /* class PrefAdjustment */
+
+/** \brief A function to respond to the value_changed signal from the
+ adjustment.
+
+ This function just grabs the value from the adjustment and writes
+ it to the parameter. Very simple, but yet beautiful.
+*/
+void
+PrefAdjustment::val_changed (void)
+{
+ // std::cout << "Value Changed to: " << this->get_value() << std::endl;
+ _ext->set_param_float(_pref, this->get_value());
+ return;
+}
+
+/** \brief A function to get the prefences for the grid
+ \param moudule Module which holds the params
+ \param view Unused today - may get style information in the future.
+
+ Uses AutoGUI for creating the GUI.
+*/
+Gtk::Widget *
+Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal, Inkscape::Extension::Implementation::ImplementationDocumentCache * /*docCache*/)
+{
+ SPDocument * current_document = view->doc();
+
+ std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList();
+ Inkscape::XML::Node * first_select = NULL;
+ if (!selected.empty()) {
+ first_select = selected[0]->getRepr();
+ }
+
+ return module->autogui(current_document, first_select, changeSignal);
+}
+
+
+
+
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
+
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/plugins/grid2/grid.h b/src/extension/plugins/grid2/grid.h
new file mode 100644
index 000000000..b4997bb18
--- /dev/null
+++ b/src/extension/plugins/grid2/grid.h
@@ -0,0 +1,58 @@
+/*
+ * Authors:
+ * Ted Gould <ted@gould.cx>
+ *
+ * Copyright (C) 2004-2005 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef __GRID_H
+
+#include "extension/implementation/implementation.h"
+
+
+#include <glib.h>
+#include <gmodule.h>
+#include "inkscape-version.cpp"
+
+
+
+namespace Inkscape {
+namespace Extension {
+
+class Effect;
+class Extension;
+
+namespace Internal {
+
+/** \brief Implementation class of the GIMP gradient plugin. This mostly
+ just creates a namespace for the GIMP gradient plugin today.
+*/
+class Grid : public Inkscape::Extension::Implementation::Implementation {
+
+public:
+ bool load(Inkscape::Extension::Extension *module);
+ void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache);
+ Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache);
+
+};
+
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
+
+extern "C" G_MODULE_EXPORT Inkscape::Extension::Implementation::Implementation* GetImplementation() { return new Inkscape::Extension::Internal::Grid(); }
+extern "C" G_MODULE_EXPORT const gchar* GetInkscapeVersion() { return Inkscape::version_string; }
+#endif
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/plugins/grid2/libgrid2.inx b/src/extension/plugins/grid2/libgrid2.inx
new file mode 100644
index 000000000..0360d37e3
--- /dev/null
+++ b/src/extension/plugins/grid2/libgrid2.inx
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+<_name>Grid2</_name>
+<id>org.inkscape.effect.grid2</id>
+<param name="lineWidth" _gui-text="Line Width:" type="float">1.0</param>
+<param name="xspacing" _gui-text="Horizontal Spacing:" type="float" min="0.1" max="1000">10.0</param>
+<param name="yspacing" _gui-text="Vertical Spacing:" type="float" min="0.1" max="1000">10.0</param>
+<param name="xoffset" _gui-text="Horizontal Offset:" type="float" min="0.0" max="1000">0.0</param>
+<param name="yoffset" _gui-text="Vertical Offset:" type="float" min="0.0" max="1000">0.0</param>
+<effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Render" >
+ <submenu _name="Grids" />
+ </submenu>
+ </effects-menu>
+<_menu-tip>Draw a path which is a grid</_menu-tip>
+</effect>
+<plugin name="libgrid2" />
+</inkscape-extension>
diff --git a/src/extension/system.cpp b/src/extension/system.cpp
index 6a95717f2..3c623455a 100644
--- a/src/extension/system.cpp
+++ b/src/extension/system.cpp
@@ -39,6 +39,7 @@
#include "io/sys.h"
#include "inkscape.h"
#include "document-undo.h"
+#include "loader.h"
namespace Inkscape {
@@ -46,7 +47,7 @@ namespace Extension {
static void open_internal(Inkscape::Extension::Extension *in_plug, gpointer in_data);
static void save_internal(Inkscape::Extension::Extension *in_plug, gpointer in_data);
-static Extension *build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation *in_imp);
+static Extension *build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation *in_imp, std::string* baseDir);
/**
* \return A new document created from the filename passed in
@@ -421,12 +422,12 @@ get_print(gchar const *key)
* case could apply to modules that are built in (like the SVG load/save functions).
*/
static Extension *
-build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation *in_imp)
+build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation *in_imp, std::string* baseDir)
{
enum {
MODULE_EXTENSION,
MODULE_XSLT,
- /* MODULE_PLUGIN, */
+ MODULE_PLUGIN,
MODULE_UNKNOWN_IMP
} module_implementation_type = MODULE_UNKNOWN_IMP;
enum {
@@ -465,10 +466,8 @@ build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation
module_implementation_type = MODULE_EXTENSION;
} else if (!strcmp(element_name, INKSCAPE_EXTENSION_NS "xslt")) {
module_implementation_type = MODULE_XSLT;
-#if 0
- } else if (!strcmp(element_name, "plugin")) {
+ } else if (!strcmp(element_name, INKSCAPE_EXTENSION_NS "plugin")) {
module_implementation_type = MODULE_PLUGIN;
-#endif
}
//Inkscape::XML::Node *old_repr = child_repr;
@@ -489,13 +488,14 @@ build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation
imp = static_cast<Implementation::Implementation *>(xslt);
break;
}
-#if 0
case MODULE_PLUGIN: {
- Implementation::Plugin *plugin = new Implementation::Plugin();
- imp = static_cast<Implementation::Implementation *>(plugin);
+ Inkscape::Extension::Loader loader = Inkscape::Extension::Loader();
+ if( baseDir != NULL){
+ loader.set_base_directory ( *baseDir );
+ }
+ imp = loader.load_implementation(doc);
break;
}
-#endif
default: {
imp = NULL;
break;
@@ -528,6 +528,7 @@ build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation
break;
}
default: {
+ module = new Extension(repr, imp);
break;
}
}
@@ -547,7 +548,8 @@ Extension *
build_from_file(gchar const *filename)
{
Inkscape::XML::Document *doc = sp_repr_read_file(filename, INKSCAPE_EXTENSION_URI);
- Extension *ext = build_from_reprdoc(doc, NULL);
+ std::string dir = Glib::path_get_dirname(filename);
+ Extension *ext = build_from_reprdoc(doc, NULL, &dir);
if (ext != NULL)
Inkscape::GC::release(doc);
else
@@ -569,7 +571,7 @@ build_from_mem(gchar const *buffer, Implementation::Implementation *in_imp)
{
Inkscape::XML::Document *doc = sp_repr_read_mem(buffer, strlen(buffer), INKSCAPE_EXTENSION_URI);
g_return_val_if_fail(doc != NULL, NULL);
- Extension *ext = build_from_reprdoc(doc, in_imp);
+ Extension *ext = build_from_reprdoc(doc, in_imp, NULL);
Inkscape::GC::release(doc);
return ext;
}