summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f74e68b)
raw | patch | inline | side by side (parent: f74e68b)
author | glimmer07 <glimmer07@users.sourceforge.net> | |
Thu, 23 Jul 2009 20:01:26 +0000 (20:01 +0000) | ||
committer | glimmer07 <glimmer07@users.sourceforge.net> | |
Thu, 23 Jul 2009 20:01:26 +0000 (20:01 +0000) |
src/extension/dbus/document-interface.cpp | patch | blob | history | |
src/extension/dbus/document-interface.h | patch | blob | history | |
src/extension/dbus/document-interface.xml | patch | blob | history |
index 53674790a28a3d251500a4c58bdb6273e2fbd3a0..e0cf6a38b901e0e49bc986d2d391dd9d7c2d190c 100644 (file)
}
Inkscape::XML::Node *
-dbus_create_node (SPDesktop *desk, gboolean isrect)
+dbus_create_node (SPDesktop *desk, const gchar *type)
{
SPDocument * doc = sp_desktop_document (desk);
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
- gchar *type;
- if (isrect)
- type = (gchar *)"svg:rect";
- else
- type = (gchar *)"svg:path";
+
return xml_doc->createElement(type);
}
{
- Inkscape::XML::Node *newNode = dbus_create_node(object->desk, TRUE);
+ Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:rect");
sp_repr_set_int(newNode, "x", x); //could also use newNode->setAttribute()
sp_repr_set_int(newNode, "y", y);
sp_repr_set_int(newNode, "width", width);
document_interface_ellipse_center (DocumentInterface *object, int cx, int cy,
int rx, int ry, GError **error)
{
- Inkscape::XML::Node *newNode = dbus_create_node(object->desk, FALSE);
+ Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path");
newNode->setAttribute("sodipodi:type", "arc");
sp_repr_set_int(newNode, "sodipodi:cx", cx);
sp_repr_set_int(newNode, "sodipodi:cy", cy);
GError **error)
{
gdouble rot = ((rotation / 180.0) * 3.14159265) - ( 3.14159265 / 2.0);
- Inkscape::XML::Node *newNode = dbus_create_node(object->desk, FALSE);
+ Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path");
newNode->setAttribute("inkscape:flatsided", "true");
newNode->setAttribute("sodipodi:type", "star");
sp_repr_set_int(newNode, "sodipodi:cx", cx);
int r1, int r2, int sides, gdouble rounded,
gdouble arg1, gdouble arg2, GError **error)
{
- Inkscape::XML::Node *newNode = dbus_create_node(object->desk, FALSE);
+ Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path");
newNode->setAttribute("inkscape:flatsided", "false");
newNode->setAttribute("sodipodi:type", "star");
sp_repr_set_int(newNode, "sodipodi:cx", cx);
document_interface_line (DocumentInterface *object, int x, int y,
int x2, int y2, GError **error)
{
- Inkscape::XML::Node *newNode = dbus_create_node(object->desk, FALSE);
+ Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path");
std::stringstream out;
printf("X2: %d\nY2 %d\n", x2, y2);
out << "m " << x << "," << y << " " << x2 << "," << y2;
document_interface_spiral (DocumentInterface *object, int cx, int cy,
int r, int revolutions, GError **error)
{
- Inkscape::XML::Node *newNode = dbus_create_node(object->desk, FALSE);
+ Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path");
newNode->setAttribute("sodipodi:type", "spiral");
sp_repr_set_int(newNode, "sodipodi:cx", cx);
sp_repr_set_int(newNode, "sodipodi:cy", cy);
@@ -423,6 +419,28 @@ document_interface_text (DocumentInterface *object, int x, int y, gchar *text, G
return TRUE;
}
+gchar *
+document_interface_image (DocumentInterface *object, int x, int y, gchar *filename, GError **error)
+{
+ gchar * uri = g_filename_to_uri (filename, FALSE, error);
+ if (!uri)
+ return FALSE;
+
+ Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:image");
+ sp_repr_set_int(newNode, "x", x);
+ sp_repr_set_int(newNode, "y", y);
+ newNode->setAttribute("xlink:href", uri);
+
+ object->desk->currentLayer()->appendChildRepr(newNode);
+ object->desk->currentLayer()->updateRepr();
+
+ if (object->updates)
+ sp_document_done(sp_desktop_document(object->desk), 0, "Imported bitmap.");
+
+ //g_free(uri);
+ return strdup(newNode->attribute("id"));
+}
+
gchar*
document_interface_node (DocumentInterface *object, gchar *type, GError **error)
{
index 413673862dc27036c2179cd508a3844db5d79f98..436f6b118c6d953580b480e4959e8a1c37dba4b8 100644 (file)
gboolean
document_interface_text (DocumentInterface *object, int x, int y,
gchar *text, GError **error);
+
+gchar *
+document_interface_image (DocumentInterface *object, int x, int y,
+ gchar *filename, GError **error);
gchar*
document_interface_node (DocumentInterface *object, gchar *svgtype,
index 3ccae9556d2482d0f1b909fda589b4e0d6ec262a..c9cd8aa69c009345d39dbbec0896f2ffdd440d66 100644 (file)
</doc:description>
</doc:doc>
</method>
+
+ <method name="image">
+ <arg type="i" name="x" direction="in" >
+ <doc:doc>
+ <doc:summary>The x coordinate to put the image at.</doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="i" name="y" direction="in" >
+ <doc:doc>
+ <doc:summary>The y coordinate to put the image at.</doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="s" name="text" direction="in" >
+ <doc:doc>
+ <doc:summary>The full path of the image you want.</doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="s" name="object_name" direction="out" >
+ <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/>
+ <doc:doc>
+ <doc:summary>The name of the new image.</doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>This method imports a non-vector image (such as a jpeg, png, etc.) and places it at the given coordinates. The resulting shape has no style or path but can be treated like a rectangle. With and height can be set explicitly (will deform image) or transform strings or <doc:ref type="method" to="document.selection_scale">selection_scale()</doc:ref> can scale it relatively.</doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
<method name="node">
<arg type="s" name="svgtype" direction="in" >