From: glimmer07 Date: Sun, 12 Jul 2009 16:02:09 +0000 (+0000) Subject: Core Dbus files. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c596be6d145df956e779f427dde5aabc8559dd6c;p=inkscape.git Core Dbus files. Init creates interfaces on Inkscape startup. Application and document interface provide API functions over Dbus. service.in file makes sure Inkscape starts automatically when someone connects to it over Dbus. --- diff --git a/src/extension/dbus/Makefile_insert b/src/extension/dbus/Makefile_insert new file mode 100644 index 000000000..c8bee0ca6 --- /dev/null +++ b/src/extension/dbus/Makefile_insert @@ -0,0 +1,31 @@ +## Makefile.am fragment sourced by src/Makefile.am. + +ink_common_sources += \ + extension/dbus/dbus-init.cpp \ + extension/dbus/dbus-init.h \ + extension/dbus/application-interface.cpp \ + extension/dbus/application-interface.h \ + extension/dbus/document-interface.cpp \ + extension/dbus/document-interface.h + +## Slightly concerned about this. +## Would use += but it has to be set first. +BUILT_SOURCES = \ + extension/dbus/application-server-glue.h \ + extension/dbus/document-server-glue.h + +extension/dbus/application-server-glue.h: extension/dbus/application-interface.xml + dbus-binding-tool --mode=glib-server --output=$@ --prefix=application_interface $^ + +extension/dbus/document-server-glue.h: extension/dbus/document-interface.xml + dbus-binding-tool --mode=glib-server --output=$@ --prefix=document_interface $^ + +# Dbus service file +servicedir = "/usr/share/dbus-1/services" +service_in_files = extension/dbus/org.inkscape.service.in +service_DATA = $(service_in_files:.service.in=.service) + +# Rule to make the service file with bindir expanded +$(service_DATA): $(service_in_files) Makefile + @sed -e "s|@bindir@|$(bindir)|" $<> $@ + diff --git a/src/extension/dbus/application-interface.cpp b/src/extension/dbus/application-interface.cpp new file mode 100644 index 000000000..06e41ecf3 --- /dev/null +++ b/src/extension/dbus/application-interface.cpp @@ -0,0 +1,112 @@ +#include "application-interface.h" +#include +#include "dbus-init.h" + +G_DEFINE_TYPE(ApplicationInterface, application_interface, G_TYPE_OBJECT) + +static void +application_interface_finalize (GObject *object) +{ + G_OBJECT_CLASS (application_interface_parent_class)->finalize (object); +} + + +static void +application_interface_class_init (ApplicationInterfaceClass *klass) +{ + GObjectClass *object_class; + object_class = G_OBJECT_CLASS (klass); + object_class->finalize = application_interface_finalize; +} + +static void +application_interface_init (ApplicationInterface *object) +{ +} + + +ApplicationInterface * +application_interface_new (void) +{ + return (ApplicationInterface*)g_object_new (TYPE_APPLICATION_INTERFACE, NULL); +} + +/**************************************************************************** + DESKTOP FUNCTIONS +****************************************************************************/ + +gchar* +application_interface_desktop_new (ApplicationInterface *object, + GError **error) +{ + return (gchar*)Inkscape::Extension::Dbus::init_desktop(); +} + +gchar** +application_interface_get_desktop_list (ApplicationInterface *object) +{ + return NULL; +} + +gchar* +application_interface_get_active_desktop (ApplicationInterface *object, + GError **error) +{ + return NULL; +} + +gboolean +application_interface_set_active_desktop (ApplicationInterface *object, + gchar* document_name, + GError **error) +{ + return TRUE; +} + +gboolean +application_interface_desktop_close_all (ApplicationInterface *object, + GError **error) +{ + return TRUE; +} + +gboolean +application_interface_exit (ApplicationInterface *object, GError **error) +{ + return TRUE; +} + +/**************************************************************************** + DOCUMENT FUNCTIONS +****************************************************************************/ + +gchar* application_interface_document_new (ApplicationInterface *object, + GError **error) +{ + return (gchar*)Inkscape::Extension::Dbus::init_document(); +} + +gchar** +application_interface_get_document_list (ApplicationInterface *object) +{ + return NULL; +} + +gboolean +application_interface_document_close_all (ApplicationInterface *object, + GError **error) +{ + return TRUE; +} + +/* INTERESTING FUNCTIONS + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + g_assert(desktop != NULL); + + SPDocument *doc = sp_desktop_document(desktop); + g_assert(doc != NULL); + + Inkscape::XML::Node *repr = sp_document_repr_root(doc); + g_assert(repr != NULL); +*/ + diff --git a/src/extension/dbus/application-interface.h b/src/extension/dbus/application-interface.h new file mode 100644 index 000000000..a04c992c3 --- /dev/null +++ b/src/extension/dbus/application-interface.h @@ -0,0 +1,84 @@ +#ifndef INKSCAPE_EXTENSION_APPLICATION_INTERFACE_H_ +#define INKSCAPE_EXTENSION_APPLICATION_INTERFACE_H_ + +#include +#include +#include +#include + +#define DBUS_APPLICATION_INTERFACE_PATH "/org/inkscape/application" + +#define TYPE_APPLICATION_INTERFACE (application_interface_get_type ()) +#define APPLICATION_INTERFACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_APPLICATION_INTERFACE, ApplicationInterface)) +#define APPLICATION_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_APPLICATION_INTERFACE, ApplicationInterfaceClass)) +#define IS_APPLICATION_INTERFACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), TYPE_APPLICATION_INTERFACE)) +#define IS_APPLICATION_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_APPLICATION_INTERFACE)) +#define APPLICATION_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_APPLICATION_INTERFACE, ApplicationInterfaceClass)) + +G_BEGIN_DECLS + +typedef struct _ApplicationInterface ApplicationInterface; +typedef struct _ApplicationInterfaceClass ApplicationInterfaceClass; + +struct _ApplicationInterface { + GObject parent; +}; + +struct _ApplicationInterfaceClass { + GObjectClass parent; +}; + +/**************************************************************************** + DESKTOP FUNCTIONS +****************************************************************************/ + +gchar* +application_interface_desktop_new (ApplicationInterface *object, + GError **error); + +gchar** +application_interface_get_desktop_list (ApplicationInterface *object); + +gchar* +application_interface_get_active_desktop (ApplicationInterface *object, + GError **error); + +gboolean +application_interface_set_active_desktop (ApplicationInterface *object, + gchar* document_name, + GError **error); + +gboolean +application_interface_desktop_close_all (ApplicationInterface *object, + GError **error); + +gboolean +application_interface_exit (ApplicationInterface *object, GError **error); + +/**************************************************************************** + DOCUMENT FUNCTIONS +****************************************************************************/ + +gchar* +application_interface_document_new (ApplicationInterface *object, + GError **error); + +gchar** +application_interface_get_document_list (ApplicationInterface *object); + +gboolean +application_interface_document_close_all (ApplicationInterface *object, + GError **error); + + +/**************************************************************************** + SETUP +****************************************************************************/ + +ApplicationInterface *application_interface_new (void); +GType application_interface_get_type (void); + + +G_END_DECLS + +#endif // INKSCAPE_EXTENSION_APPLICATION_INTERFACE_H_ diff --git a/src/extension/dbus/application-interface.xml b/src/extension/dbus/application-interface.xml new file mode 100644 index 000000000..9b55a9b2b --- /dev/null +++ b/src/extension/dbus/application-interface.xml @@ -0,0 +1,65 @@ + + + + + + + + + + This string can be used to connect to the new interface that was created. + + + + + Create a new document interface and return it's location. + + + + + + + + A list of interfaces being provided by Inkscape. + + + + + List all the interfaces that it is possible to connect to. + + + + + + + Close all document interfaces without saving. + + + + + + + Exit Inkscape without saving. Fairly straightforward. + + + + + + + + + + This string can be used to connect to the new interface that was created. + + + + + Originally, there were going to be two interfaces. A desktop and a document. Desktops would be used when the user wanted to see the result of their code and documents would be used when less overhead was desired. Unfortunately as more and more of the code can to rely on the desktop and it's associated support code (including selections and verbs) the document interface was looking more and more limited. Ultimately I decided to just go with the desktop interface since I didn't have a compelling reason for keeping the other one and having two similar interfaces could be very confusing. The desktop interface inherited the document name because I believe it's more familiar to people. + Perhaps it would be best to have an option as to whether or not to create a window and fail with a good error message when they call a function that requires one. Or have a second interface for different use cases but have it be completely different, rather than a subset of the first if there are use cases that support it. + + + + + diff --git a/src/extension/dbus/dbus-init.cpp b/src/extension/dbus/dbus-init.cpp new file mode 100644 index 000000000..a30bb8fda --- /dev/null +++ b/src/extension/dbus/dbus-init.cpp @@ -0,0 +1,153 @@ + +#include +#include "dbus-init.h" + +#include "application-interface.h" +#include "application-server-glue.h" + +#include "document-interface.h" +#include "document-server-glue.h" + +#include "inkscape.h" +#include "document.h" +#include "desktop.h" +#include "file.h" +#include "verbs.h" +#include "helper/action.h" + +#include +#include +#include + + + + +namespace Inkscape { +namespace Extension { +namespace Dbus { + +/* PRIVATE get a connection to the session bus */ +DBusGConnection * +dbus_get_connection() { + GError *error = NULL; + DBusGConnection *connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (error) { + fprintf(stderr, "Failed to get connection"); + return NULL; + } + else + return connection; +} + +/* PRIVATE create a proxy object for a bus.*/ +DBusGProxy * +dbus_get_proxy(DBusGConnection *connection) { + return dbus_g_proxy_new_for_name (connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); +} + +/* PRIVATE register an object on a bus */ +static gpointer +dbus_register_object (DBusGConnection *connection, + DBusGProxy *proxy, + GType object_type, + const DBusGObjectInfo *info, + const gchar *path) +{ + GObject *object = (GObject*)g_object_new (object_type, NULL); + dbus_g_object_type_install_info (object_type, info); + dbus_g_connection_register_g_object (connection, path, object); + return object; +} + +/* Initialize a Dbus service */ +void +init (void) +{ + guint result; + GError *error = NULL; + DBusGConnection *connection; + DBusGProxy *proxy; + DocumentInterface *obj; + connection = dbus_get_connection(); + proxy = dbus_get_proxy(connection); + org_freedesktop_DBus_request_name (proxy, + "org.inkscape", + DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); + //create interface for application + dbus_register_object (connection, + proxy, + TYPE_APPLICATION_INTERFACE, + &dbus_glib_application_interface_object_info, + DBUS_APPLICATION_INTERFACE_PATH); +} //init + +gchar * +init_document (void) { + guint result; + GError *error = NULL; + DBusGConnection *connection; + DBusGProxy *proxy; + SPDocument *doc; + + doc = sp_document_new(NULL, 1, TRUE); + + std::string name("/org/inkscape/"); + name.append(doc->name); + std::replace(name.begin(), name.end(), ' ', '_'); + + connection = dbus_get_connection(); + proxy = dbus_get_proxy(connection); + + dbus_register_object (connection, + proxy, + TYPE_DOCUMENT_INTERFACE, + &dbus_glib_document_interface_object_info, + name.c_str()); + return strdup(name.c_str()); +} //init_document + +gchar * +dbus_init_desktop_interface (SPDesktop * dt) +{ + DBusGConnection *connection; + DBusGProxy *proxy; + DocumentInterface *obj; + + std::string name("/org/inkscape/desktop_"); + std::stringstream out; + out << dt->dkey; + name.append(out.str()); + + //printf("DKEY: %d\n, NUMBER %d\n NAME: %s\n", dt->dkey, dt->number, name.c_str()); + + connection = dbus_get_connection(); + proxy = dbus_get_proxy(connection); + + obj = (DocumentInterface*) dbus_register_object (connection, + proxy, TYPE_DOCUMENT_INTERFACE, + &dbus_glib_document_interface_object_info, name.c_str()); + obj->desk = dt; + obj->updates = TRUE; + + return strdup(name.c_str()); +} + +gchar * +init_desktop (void) { + //this function will create a new desktop and call + //dbus_init_desktop_interface. + SPDesktop * dt = sp_file_new_default(); + + std::string name("/org/inkscape/desktop_"); + std::stringstream out; + out << dt->dkey; + name.append(out.str()); + return strdup(name.c_str()); +} //init_desktop + + + +} } } /* namespace Inkscape::Extension::Dbus */ diff --git a/src/extension/dbus/dbus-init.h b/src/extension/dbus/dbus-init.h new file mode 100644 index 000000000..f76483170 --- /dev/null +++ b/src/extension/dbus/dbus-init.h @@ -0,0 +1,42 @@ +/* + * Authors: + * Soren Berg + * + * Copyright (C) 2004 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_EXTENSION_DBUS_INIT_H__ +#define INKSCAPE_EXTENSION_DBUS_INIT_H__ + +#include "desktop.h" + +namespace Inkscape { +namespace Extension { +namespace Dbus { + +/** \brief Dbus stuff. For registering objects on the bus. */ + +void init (void); + +gchar * init_document (void); + +gchar * init_desktop (void); + +gchar * dbus_init_desktop_interface (SPDesktop * dt); + +} } } /* namespace Dbus, Extension, Inkscape */ + +#endif /* INKSCAPE_EXTENSION_DBUS_INIT_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 : diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp new file mode 100644 index 000000000..94f442865 --- /dev/null +++ b/src/extension/dbus/document-interface.cpp @@ -0,0 +1,936 @@ +#include "document-interface.h" +#include + +#include "verbs.h" +#include "helper/action.h" //sp_action_perform + +#include "inkscape.h" //inkscape_find_desktop_by_dkey, activate desktops + +#include "desktop-handles.h" //sp_desktop_document() +#include "xml/repr.h" //sp_repr_document_new + +#include "sp-object.h" + +#include "document.h" // sp_document_repr_doc + +#include "desktop-style.h" //sp_desktop_get_style + +#include "selection.h" //selection struct +#include "selection-chemistry.h"// lots of selection functions + +#include "sp-ellipse.h" + +#include "layer-fns.h" //LPOS_BELOW + +#include "style.h" //style_write + +/**************************************************************************** + HELPER / SHORTCUT FUNCTIONS +****************************************************************************/ + +const gchar* intToCString(int i) +{ + std::stringstream ss; + ss << i; + return ss.str().c_str(); +} + +SPObject * +get_object_by_name (SPDesktop *desk, gchar *name) +{ + return sp_desktop_document(desk)->getObjectById(name); +} + +const gchar * +get_name_from_object (SPObject * obj) +{ + return obj->repr->attribute("id"); +} + +void +desktop_ensure_active (SPDesktop* desk) { + if (desk != SP_ACTIVE_DESKTOP) + inkscape_activate_desktop (desk); + return; +} + +Inkscape::XML::Node * +document_retrive_node (SPDocument *doc, gchar *name) { + return (doc->getObjectById(name))->repr; +} + +gdouble +selection_get_center_x (Inkscape::Selection *sel){ + NRRect *box = g_new(NRRect, 1);; + box = sel->boundsInDocument(box); + return box->x0 + ((box->x1 - box->x0)/2); +} + +gdouble +selection_get_center_y (Inkscape::Selection *sel){ + NRRect *box = g_new(NRRect, 1);; + box = sel->boundsInDocument(box); + return box->y0 + ((box->y1 - box->y0)/2); +} +//move_to etc +const GSList * +selection_swap(SPDesktop *desk, gchar *name) +{ + Inkscape::Selection *sel = sp_desktop_selection(desk); + const GSList *oldsel = g_slist_copy((GSList *)sel->list()); + + sel->set(get_object_by_name(desk, name)); + return oldsel; +} + +void +selection_restore(SPDesktop *desk, const GSList * oldsel) +{ + Inkscape::Selection *sel = sp_desktop_selection(desk); + sel->setList(oldsel); +} + +Inkscape::XML::Node * +dbus_create_node (SPDesktop *desk, gboolean isrect) +{ + 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); +} + +gchar * +finish_create_shape (DocumentInterface *object, GError **error, Inkscape::XML::Node *newNode, gchar *desc) +{ + + SPCSSAttr *style = sp_desktop_get_style(object->desk, TRUE); + + if (style) { + newNode->setAttribute("style", sp_repr_css_write_string(style), TRUE); + } + else { + newNode->setAttribute("style", "fill:#0000ff;fill-opacity:1;stroke:#c900b9;stroke-width:0;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none", TRUE); + } + + object->desk->currentLayer()->appendChildRepr(newNode); + object->desk->currentLayer()->updateRepr(); + + if (object->updates) + sp_document_done(sp_desktop_document(object->desk), 0, (gchar *)desc); + else + document_interface_pause_updates(object, error); + + return strdup(newNode->attribute("id")); +} + +gboolean +dbus_call_verb (DocumentInterface *object, int verbid, GError **error) +{ + SPDesktop *desk2 = object->desk; + + if ( desk2 ) { + Inkscape::Verb *verb = Inkscape::Verb::get( verbid ); + if ( verb ) { + SPAction *action = verb->get_action(desk2); + if ( action ) { + sp_action_perform( action, NULL ); + if (object->updates) { + sp_document_done(sp_desktop_document(desk2), verb->get_code(), g_strdup(verb->get_tip())); + } + return TRUE; + } + } + } + return FALSE; +} + +/**************************************************************************** + DOCUMENT INTERFACE CLASS STUFF +****************************************************************************/ + +G_DEFINE_TYPE(DocumentInterface, document_interface, G_TYPE_OBJECT) + +static void +document_interface_finalize (GObject *object) +{ + G_OBJECT_CLASS (document_interface_parent_class)->finalize (object); +} + + +static void +document_interface_class_init (DocumentInterfaceClass *klass) +{ + GObjectClass *object_class; + object_class = G_OBJECT_CLASS (klass); + object_class->finalize = document_interface_finalize; +} + +static void +document_interface_init (DocumentInterface *object) +{ + object->desk = NULL; +} + + +DocumentInterface * +document_interface_new (void) +{ + return (DocumentInterface*)g_object_new (TYPE_DOCUMENT_INTERFACE, NULL); +} + +/**************************************************************************** + MISC FUNCTIONS +****************************************************************************/ + +gboolean +document_interface_delete_all (DocumentInterface *object, GError **error) +{ + sp_edit_clear_all (object->desk); + return TRUE; +} + +void +document_interface_call_verb (DocumentInterface *object, gchar *verbid, GError **error) +{ + SPDesktop *desk2 = object->desk; + desktop_ensure_active (object->desk); + if ( desk2 ) { + Inkscape::Verb *verb = Inkscape::Verb::getbyid( verbid ); + if ( verb ) { + SPAction *action = verb->get_action(desk2); + if ( action ) { + sp_action_perform( action, NULL ); + if (object->updates) { + sp_document_done(sp_desktop_document(desk2), verb->get_code(), g_strdup(verb->get_tip())); + } + } + } + } +} + + +/**************************************************************************** + CREATION FUNCTIONS +****************************************************************************/ + +gchar* +document_interface_rectangle (DocumentInterface *object, int x, int y, + int width, int height, GError **error) +{ + + + Inkscape::XML::Node *newNode = dbus_create_node(object->desk, TRUE); + 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); + sp_repr_set_int(newNode, "height", height); + return finish_create_shape (object, error, newNode, (gchar *)"create rectangle"); +} + +gchar* +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); + newNode->setAttribute("sodipodi:type", "arc"); + sp_repr_set_int(newNode, "sodipodi:cx", cx); + sp_repr_set_int(newNode, "sodipodi:cy", cy); + sp_repr_set_int(newNode, "sodipodi:rx", rx); + sp_repr_set_int(newNode, "sodipodi:ry", ry); + return finish_create_shape (object, error, newNode, (gchar *)"create circle"); +} + +gchar* +document_interface_polygon (DocumentInterface *object, int cx, int cy, + int radius, int rotation, int sides, + GError **error) +{ + gdouble rot = ((rotation / 180.0) * 3.14159265) - ( 3.14159265 / 2.0); + Inkscape::XML::Node *newNode = dbus_create_node(object->desk, FALSE); + newNode->setAttribute("inkscape:flatsided", "true"); + newNode->setAttribute("sodipodi:type", "star"); + sp_repr_set_int(newNode, "sodipodi:cx", cx); + sp_repr_set_int(newNode, "sodipodi:cy", cy); + sp_repr_set_int(newNode, "sodipodi:r1", radius); + sp_repr_set_int(newNode, "sodipodi:r2", radius); + sp_repr_set_int(newNode, "sodipodi:sides", sides); + sp_repr_set_int(newNode, "inkscape:randomized", 0); + sp_repr_set_svg_double(newNode, "sodipodi:arg1", rot); + sp_repr_set_svg_double(newNode, "sodipodi:arg2", rot); + sp_repr_set_svg_double(newNode, "inkscape:rounded", 0); + + return finish_create_shape (object, error, newNode, (gchar *)"create polygon"); +} + +gchar* +document_interface_star (DocumentInterface *object, int cx, int cy, + int r1, int r2, int sides, gdouble rounded, + gdouble arg1, gdouble arg2, GError **error) +{ + Inkscape::XML::Node *newNode = dbus_create_node(object->desk, FALSE); + newNode->setAttribute("inkscape:flatsided", "false"); + newNode->setAttribute("sodipodi:type", "star"); + sp_repr_set_int(newNode, "sodipodi:cx", cx); + sp_repr_set_int(newNode, "sodipodi:cy", cy); + sp_repr_set_int(newNode, "sodipodi:r1", r1); + sp_repr_set_int(newNode, "sodipodi:r2", r2); + sp_repr_set_int(newNode, "sodipodi:sides", sides); + sp_repr_set_int(newNode, "inkscape:randomized", 0); + sp_repr_set_svg_double(newNode, "sodipodi:arg1", arg1); + sp_repr_set_svg_double(newNode, "sodipodi:arg2", arg2); + sp_repr_set_svg_double(newNode, "inkscape:rounded", rounded); + + return finish_create_shape (object, error, newNode, (gchar *)"create star"); +} + +gchar* +document_interface_ellipse (DocumentInterface *object, int x, int y, + int width, int height, GError **error) +{ + int rx = width/2; + int ry = height/2; + return document_interface_ellipse_center (object, x+rx, y+ry, rx, ry, error); +} + +gchar* +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); + std::stringstream out; + printf("X2: %d\nY2 %d\n", x2, y2); + out << "m " << x << "," << y << " " << x2 << "," << y2; + printf ("PATH: %s\n", out.str().c_str()); + newNode->setAttribute("d", out.str().c_str()); + return finish_create_shape (object, error, newNode, (gchar *)"create line"); +} + +gchar* +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); + newNode->setAttribute("sodipodi:type", "spiral"); + sp_repr_set_int(newNode, "sodipodi:cx", cx); + sp_repr_set_int(newNode, "sodipodi:cy", cy); + sp_repr_set_int(newNode, "sodipodi:radius", r); + sp_repr_set_int(newNode, "sodipodi:revolution", revolutions); + sp_repr_set_int(newNode, "sodipodi:t0", 0); + sp_repr_set_int(newNode, "sodipodi:argument", 0); + sp_repr_set_int(newNode, "sodipodi:expansion", 1); + gchar * retval = finish_create_shape (object, error, newNode, (gchar *)"create spiral"); + newNode->setAttribute("style", "fill:none"); + return retval; +} + +gchar* +document_interface_text (DocumentInterface *object, gchar *text, GError **error) +{ + return NULL; +} + +gchar* +document_interface_node (DocumentInterface *object, gchar *type, GError **error) +{ + return NULL; +} + +/**************************************************************************** + ENVIORNMENT FUNCTIONS +****************************************************************************/ +gdouble +document_interface_document_get_width (DocumentInterface *object) +{ + return sp_document_width(sp_desktop_document(object->desk)); +} + +gdouble +document_interface_document_get_height (DocumentInterface *object) +{ + return sp_document_height(sp_desktop_document(object->desk)); +} + +gchar * +document_interface_document_get_css (DocumentInterface *object, GError **error) +{ + SPCSSAttr *current = (object->desk)->current; + return sp_repr_css_write_string(current); +} + +gboolean +document_interface_document_merge_css (DocumentInterface *object, + gchar *stylestring, GError **error) +{ + return FALSE; +} + +gboolean +document_interface_document_set_css (DocumentInterface *object, + gchar *stylestring, GError **error) +{ + return FALSE; +} + +gboolean +document_interface_document_resize_to_fit_selection (DocumentInterface *object, + GError **error) +{ + return FALSE; +} + +/**************************************************************************** + OBJECT FUNCTIONS +****************************************************************************/ + +gboolean +document_interface_set_attribute (DocumentInterface *object, char *shape, + char *attribute, char *newval, GError **error) +{ + Inkscape::XML::Node *newNode = get_object_by_name(object->desk, shape)->repr; + + /* ALTERNATIVE + Inkscape::XML::Node *repr2 = sp_repr_lookup_name((doc->root)->repr, name); + */ + if (newNode) + { + newNode->setAttribute(attribute, newval, TRUE); + return TRUE; + } + return FALSE; +} + +void +document_interface_set_int_attribute (DocumentInterface *object, + char *shape, char *attribute, + int newval, GError **error) +{ + Inkscape::XML::Node *newNode = get_object_by_name (object->desk, shape)->repr; + if (newNode) + sp_repr_set_int (newNode, attribute, newval); +} + + +void +document_interface_set_double_attribute (DocumentInterface *object, + char *shape, char *attribute, + double newval, GError **error) +{ + Inkscape::XML::Node *newNode = get_object_by_name (object->desk, shape)->repr; + if (newNode) + sp_repr_set_svg_double (newNode, attribute, newval); +} + +gchar * +document_interface_get_attribute (DocumentInterface *object, char *shape, + char *attribute, GError **error) +{ + SPDesktop *desk2 = object->desk; + SPDocument * doc = sp_desktop_document (desk2); + + // FIXME: Not sure if this is the most efficient way. + Inkscape::XML::Node *newNode = doc->getObjectById(shape)->repr; + + /* WORKS + Inkscape::XML::Node *repr2 = sp_repr_lookup_name((doc->root)->repr, name); + */ + if (newNode) + return g_strdup(newNode->attribute(attribute)); + return FALSE; +} + +gboolean +document_interface_move (DocumentInterface *object, gchar *name, gdouble x, + gdouble y, GError **error) +{ + const GSList *oldsel = selection_swap(object->desk, name); + sp_selection_move (object->desk, x, 0 - y); + selection_restore(object->desk, oldsel); + return TRUE; +} + +gboolean +document_interface_move_to (DocumentInterface *object, gchar *name, gdouble x, + gdouble y, GError **error) +{ + const GSList *oldsel = selection_swap(object->desk, name); + Inkscape::Selection * sel = sp_desktop_selection(object->desk); + sp_selection_move (object->desk, x - selection_get_center_x(sel), + 0 - (y - selection_get_center_y(sel))); + selection_restore(object->desk, oldsel); + return TRUE; +} + +void +document_interface_object_to_path (DocumentInterface *object, + char *shape, GError **error) +{ + const GSList *oldsel = selection_swap(object->desk, shape); + dbus_call_verb (object, SP_VERB_OBJECT_TO_CURVE, error); + selection_restore(object->desk, oldsel); +} + +gboolean +document_interface_get_path (DocumentInterface *object, char *pathname, GError **error) +{ + Inkscape::XML::Node *node = document_retrive_node (sp_desktop_document (object->desk), pathname); + if (node == NULL || node->attribute("d") == NULL) { + g_set_error(error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION, "Object is not a path or does not exist."); + return FALSE; + } + gchar *pathstr = strdup(node->attribute("d")); + printf("PATH: %s\n", pathstr); + //gfree (pathstr); + std::istringstream iss(pathstr); + std::copy(std::istream_iterator(iss), + std::istream_iterator(), + std::ostream_iterator(std::cout, "\n")); + + return TRUE; +} + +gboolean +document_interface_transform (DocumentInterface *object, gchar *shape, + gchar *transformstr, GError **error) +{ + //FIXME: This should merge transformations. + gchar trans[] = "transform"; + document_interface_set_attribute (object, shape, trans, transformstr, error); + return TRUE; +} + +gchar * +document_interface_get_css (DocumentInterface *object, gchar *shape, + GError **error) +{ +return NULL; +} + +gboolean +document_interface_modify_css (DocumentInterface *object, gchar *shape, + gchar *cssattrb, gchar *newval, GError **error) +{ + return FALSE; +} + +gboolean +document_interface_merge_css (DocumentInterface *object, gchar *shape, + gchar *stylestring, GError **error) +{ + return FALSE; +} + +gboolean +document_interface_move_to_layer (DocumentInterface *object, gchar *shape, + gchar *layerstr, GError **error) +{ + return FALSE; +} + +DBUSPoint ** +document_interface_get_node_coordinates (DocumentInterface *object, gchar *shape) +{ + return NULL; +} + + +/**************************************************************************** + FILE I/O FUNCTIONS +****************************************************************************/ + +gboolean +document_interface_save (DocumentInterface *object, GError **error){ + return FALSE; +} + +gboolean +document_interface_load (DocumentInterface *object, + gchar *filename, GError **error){ + return FALSE; +} + +gboolean +document_interface_save_as (DocumentInterface *object, + gchar *filename, GError **error){ + return FALSE; +} + +gboolean +document_interface_print (DocumentInterface *object, GError **error){ + return FALSE; +} + +/**************************************************************************** + PROGRAM CONTROL FUNCTIONS +****************************************************************************/ + +gboolean +document_interface_close (DocumentInterface *object, GError **error){ + return dbus_call_verb (object, SP_VERB_FILE_CLOSE_VIEW, error); +} + +gboolean +document_interface_exit (DocumentInterface *object, GError **error){ + return dbus_call_verb (object, SP_VERB_FILE_QUIT, error); +} + +gboolean +document_interface_undo (DocumentInterface *object, GError **error){ + return dbus_call_verb (object, SP_VERB_EDIT_UNDO, error); +} + +gboolean +document_interface_redo (DocumentInterface *object, GError **error){ + return dbus_call_verb (object, SP_VERB_EDIT_REDO, error); +} + + + +/**************************************************************************** + UPDATE FUNCTIONS +****************************************************************************/ + +void +document_interface_pause_updates (DocumentInterface *object, GError **error) +{ + object->updates = FALSE; + sp_desktop_document(object->desk)->root->uflags = FALSE; + sp_desktop_document(object->desk)->root->mflags = FALSE; +} + +void +document_interface_resume_updates (DocumentInterface *object, GError **error) +{ + object->updates = TRUE; + sp_desktop_document(object->desk)->root->uflags = TRUE; + sp_desktop_document(object->desk)->root->mflags = TRUE; + //sp_desktop_document(object->desk)->_updateDocument(); + sp_document_done(sp_desktop_document(object->desk), SP_VERB_CONTEXT_RECT, "Multiple actions"); +} + +void +document_interface_update (DocumentInterface *object, GError **error) +{ + sp_desktop_document(object->desk)->root->uflags = TRUE; + sp_desktop_document(object->desk)->root->mflags = TRUE; + sp_desktop_document(object->desk)->_updateDocument(); + sp_desktop_document(object->desk)->root->uflags = FALSE; + sp_desktop_document(object->desk)->root->mflags = FALSE; + //sp_document_done(sp_desktop_document(object->desk), SP_VERB_CONTEXT_RECT, "Multiple actions"); +} + +/**************************************************************************** + SELECTION FUNCTIONS FIXME: use call_verb where appropriate. +****************************************************************************/ + +gchar ** +document_interface_selection_get (DocumentInterface *object) +{ + Inkscape::Selection * sel = sp_desktop_selection(object->desk); + GSList const *oldsel = sel->list(); + + int size = g_slist_length((GSList *) oldsel); + int i; + printf("premalloc\n"); + gchar **list = (gchar **)malloc(size); + printf("postmalloc\n"); + for(i = 0; i < size; i++) + list[i] = (gchar *)malloc(sizeof(gchar) * 10); + printf("postmalloc2\n"); + i=0; + printf("prealloc\n"); + for (GSList const *iter = oldsel; iter != NULL; iter = iter->next) { + strcpy (list[i], SP_OBJECT(iter->data)->repr->attribute("id")); + i++; + } + printf("postalloc\n"); + for (i=0; idesk); + Inkscape::Selection *selection = sp_desktop_selection(object->desk); + /* WORKS + Inkscape::XML::Node *repr2 = sp_repr_lookup_name((doc->root)->repr, name); + selection->add(repr2, TRUE); + */ + selection->add(doc->getObjectById(name)); + return TRUE; +} + +gboolean +document_interface_selection_add_list (DocumentInterface *object, + char **names, GError **error) +{ + return FALSE; +} + +gboolean +document_interface_selection_set (DocumentInterface *object, char *name, GError **error) +{ + SPDocument * doc = sp_desktop_document (object->desk); + Inkscape::Selection *selection = sp_desktop_selection(object->desk); + selection->set(doc->getObjectById(name)); + return TRUE; +} + +gboolean +document_interface_selection_set_list (DocumentInterface *object, + gchar **names, GError **error) +{ + sp_desktop_selection(object->desk)->clear(); + int i; + for (i=0;((i<30000) && (names[i] != NULL));i++) { + printf("NAME: %s\n", names[i]); + document_interface_selection_add(object, names[i], error); + } + return TRUE; +} + +gboolean +document_interface_selection_rotate (DocumentInterface *object, int angle, GError **error) +{ + Inkscape::Selection *selection = sp_desktop_selection(object->desk); + sp_selection_rotate(selection, angle); + return TRUE; +} + +gboolean +document_interface_selection_delete (DocumentInterface *object, GError **error) +{ + sp_selection_delete (object->desk); + return TRUE; +} + +gboolean +document_interface_selection_clear (DocumentInterface *object, GError **error) +{ + sp_desktop_selection(object->desk)->clear(); + return TRUE; +} + +gboolean +document_interface_select_all (DocumentInterface *object, GError **error) +{ + sp_edit_select_all (object->desk); + return TRUE; +} + +gboolean +document_interface_select_all_in_all_layers(DocumentInterface *object, + GError **error) +{ + sp_edit_select_all_in_all_layers (object->desk); +} + +gboolean +document_interface_selection_box (DocumentInterface *object, int x, int y, + int x2, int y2, gboolean replace, + GError **error) +{ + return FALSE; +} + +gboolean +document_interface_selection_invert (DocumentInterface *object, GError **error) +{ + sp_edit_invert (object->desk); + return TRUE; +} + +gboolean +document_interface_selection_group (DocumentInterface *object, GError **error) +{ + sp_selection_group (object->desk); + return TRUE; +} +gboolean +document_interface_selection_ungroup (DocumentInterface *object, GError **error) +{ + sp_selection_ungroup (object->desk); + return TRUE; +} + +gboolean +document_interface_selection_cut (DocumentInterface *object, GError **error) +{ + sp_selection_cut (object->desk); + return TRUE; +} +gboolean +document_interface_selection_copy (DocumentInterface *object, GError **error) +{ + desktop_ensure_active (object->desk); + sp_selection_copy (); + return TRUE; +} +gboolean +document_interface_selection_paste (DocumentInterface *object, GError **error) +{ + desktop_ensure_active (object->desk); + sp_selection_paste (object->desk, TRUE); + return TRUE; +} + +gboolean +document_interface_selection_scale (DocumentInterface *object, gdouble grow, GError **error) +{ + Inkscape::Selection *selection = sp_desktop_selection(object->desk); + sp_selection_scale (selection, grow); + return TRUE; +} + +gboolean +document_interface_selection_move (DocumentInterface *object, gdouble x, gdouble y, GError **error) +{ + sp_selection_move (object->desk, x, 0 - y); //switching coordinate systems. + return TRUE; +} + +gboolean +document_interface_selection_move_to (DocumentInterface *object, gdouble x, gdouble y, GError **error) +{ + Inkscape::Selection * sel = sp_desktop_selection(object->desk); + + Geom::OptRect sel_bbox = sel->bounds(); + if (sel_bbox) { + //Geom::Point m( (object->desk)->point() - sel_bbox->midpoint() ); + Geom::Point m( x - selection_get_center_x(sel) , 0 - (y - selection_get_center_y(sel)) ); + sp_selection_move_relative(sel, m, true); + + } + + //FIXME: dosn't work with transformations + //sp_selection_move (object->desk, x - selection_get_center_x(sel), + // 0 - (y - selection_get_center_y(sel))); + return TRUE; +} + +gboolean +document_interface_selection_move_to_layer (DocumentInterface *object, + gchar *layerstr, GError **error) +{ + return FALSE; +} + +gboolean +document_interface_selection_get_center (DocumentInterface *object) +{ + return FALSE; +} + +gboolean +document_interface_selection_to_path (DocumentInterface *object, GError **error) +{ + return dbus_call_verb (object, SP_VERB_OBJECT_TO_CURVE, error); +} + + +gchar * +document_interface_selection_combine (DocumentInterface *object, gchar *cmd, + GError **error) +{ + + if (strcmp(cmd, "union") == 0) + dbus_call_verb (object, SP_VERB_SELECTION_UNION, error); + else if (strcmp(cmd, "intersection") == 0) + dbus_call_verb (object, SP_VERB_SELECTION_INTERSECT, error); + else if (strcmp(cmd, "difference") == 0) + dbus_call_verb (object, SP_VERB_SELECTION_DIFF, error); + else if (strcmp(cmd, "exclusion") == 0) + dbus_call_verb (object, SP_VERB_SELECTION_SYMDIFF, error); + else if (strcmp(cmd, "division") == 0) + dbus_call_verb (object, SP_VERB_SELECTION_CUT, error); + else + return NULL; + + //FIXME: this WILL cause problems with division + return g_strdup((sp_desktop_selection(object->desk)->singleRepr())->attribute("id")); +} + +gboolean +document_interface_selection_change_level (DocumentInterface *object, gchar *cmd, + GError **error) +{ + if (strcmp(cmd, "raise") == 0) + return dbus_call_verb (object, SP_VERB_SELECTION_RAISE, error); + if (strcmp(cmd, "lower") == 0) + return dbus_call_verb (object, SP_VERB_SELECTION_LOWER, error); + if ((strcmp(cmd, "to_top") == 0) || (strcmp(cmd, "to_front") == 0)) + return dbus_call_verb (object, SP_VERB_SELECTION_TO_FRONT, error); + if ((strcmp(cmd, "to_bottom") == 0) || (strcmp(cmd, "to_back") == 0)) + return dbus_call_verb (object, SP_VERB_SELECTION_TO_BACK, error); + return TRUE; +} + +/**************************************************************************** + LAYER FUNCTIONS +****************************************************************************/ + +gchar * +document_interface_layer_new (DocumentInterface *object, GError **error) +{ + SPDesktop * dt = object->desk; + SPObject *new_layer = Inkscape::create_layer(dt->currentRoot(), dt->currentLayer(), Inkscape::LPOS_BELOW); + dt->setCurrentLayer(new_layer); + return g_strdup(get_name_from_object (new_layer)); +} + +gboolean +document_interface_layer_set (DocumentInterface *object, + gchar *layerstr, GError **error) +{ + object->desk->setCurrentLayer (get_object_by_name (object->desk, layerstr)); + return TRUE; +} + +gchar ** +document_interface_layer_get_all (DocumentInterface *object) +{ + return NULL; +} + +gboolean +document_interface_layer_change_level (DocumentInterface *object, + gchar *cmd, GError **error) +{ + if (strcmp(cmd, "raise") == 0) + return dbus_call_verb (object, SP_VERB_LAYER_RAISE, error); + if (strcmp(cmd, "lower") == 0) + return dbus_call_verb (object, SP_VERB_LAYER_LOWER, error); + if ((strcmp(cmd, "to_top") == 0) || (strcmp(cmd, "to_front") == 0)) + return dbus_call_verb (object, SP_VERB_LAYER_TO_TOP, error); + if ((strcmp(cmd, "to_bottom") == 0) || (strcmp(cmd, "to_back") == 0)) + return dbus_call_verb (object, SP_VERB_LAYER_TO_BOTTOM, error); + return TRUE; +} + +gboolean +document_interface_layer_next (DocumentInterface *object, GError **error) +{ + return dbus_call_verb (object, SP_VERB_LAYER_NEXT, error); +} + +gboolean +document_interface_layer_previous (DocumentInterface *object, GError **error) +{ + return dbus_call_verb (object, SP_VERB_LAYER_PREV, error); +} + + + + + + diff --git a/src/extension/dbus/document-interface.xml b/src/extension/dbus/document-interface.xml new file mode 100644 index 000000000..ba8c7e2b3 --- /dev/null +++ b/src/extension/dbus/document-interface.xml @@ -0,0 +1,1223 @@ + + + + + + + + + + + + + + The string id of a verb. For example: "EditSelectAll". + + + + + This method allows you to call any Inkscape verb using it's associated string. Every button and menu item has an associated verb, so this allows access to some extra functionality if one is willing to do the prerequisite research. The list of verbs can be found at: + + + + + + + + + + X coordinate for the top left corner of the rectangle. + + + + + Y coordinate for the top left corner of the rectangle. + + + + + Width of the rectangle. + + + + + Height of the rectangle. + + + + + + The name of the new rectangle. + + + + + This method creates a rectangle in the current layer using the current document style. + It is recommended that you save the return value if you will want to modify this particular shape later. + Additional variables include: + cx and cy: set these anywhere from zero to half the width or height respectively of the rectangle to give it rounded corners. + + Coordinate System + + + + + + + X coordinate for the top left corner of the ellipse. + + + + + Y coordinate for the top left corner of the ellipse. + + + + + Width of the ellipse. + + + + + Height of the ellipse. + + + + + + The name of the new ellipse. + + + + + This method creates a ellipse in the current layer using the current document style. + It is recommended that you save the return value if you will want to modify this particular shape later. + Additional variables include: + "sodipodi:start" and "sodipodi:end": set these between 0 and Pi to create wedges or Pacman like shapes. + + Coordinate System + + + + + + + X coordinate for the center of the polygon. + + + + + Y coordinate for the center of the polygon. + + + + + Radius from the center to one of the points. + + + + + Angle in degrees to rotate. 0 will have the first point pointing straight up. + + + + + Number of sides of the polygon. + + + + + + The name of the new polygon. + + + + + This method creates a polygon in the current layer using the current document style. + It is recommended that you save the return value if you will want to modify this particular shape later. + Note: this is actually a star with "sodipodi:flatsided" set to true, which causes it to ignore the arg2 and r2 values. + + Coordinate System + + + + + + + X coordinate for the center of the star. + + + + + Y coordinate for the center of the star. + + + + + distance from the center for the first point. + + + + + distance from the center for the second point. + + + + + Angle in radians for the first point. 0 is 90 degrees to the right of straight up. + + + + + Angle in radians for the second point. 0 is 90 degrees to the right of straight up. + + + + + Number of times to repeat the points around the star. + + + + + How rounded to make the star. 0 to 1 recommended for moderate to medium curves. 10 for extreme curves. + + + + + + The name of the new star. + + + + + This method creates a star in the current layer using the current document style. + It is recommended that you save the return value if you will want to modify this particular shape later. + Stars are quite complicated. Here is how they are represented: There are two points, represented by sodipodi:arg1 and sodipodi:arg2 for angle in radians and sodipodi:r1 and sodipodi:r2 for respective radius from the center point. The further one is a point of the star, the shorter one one of the valleys. This point and valley are repeated according to sodipodi:sides. sodipodi:rounded controls their control handles. + + Coordinate System + + + + + + + X coordinate for the center of the spiral. + + + + + Y coordinate for the center of the spiral. + + + + + Radius of the spiral. + + + + + Number of revolutions. + + + + + + The name of the new spiral. + + + + + This method creates a spiral in the current layer using the current document style. However, fill is automatically set to "none". Stroke is unmodified. + It is recommended that you save the return value if you will want to modify this particular shape later. + Additional variables include: + "sodipodi:expansion": at 1 the spiral gets bigger at a constant rate. Less than one and the loops get tighter and tighter as it goes. More than one and they get looser and looser. This affects the number of revolutions so that it might not actually match the "sodipodi:revolutions" argument. + "sodipodi:t0": at 0 the entire spiral is drawn, at 0.5 it is only drawn %50 of the way (starting from the outside) etc. + "sodipodi:argument": Rotates the spiral. In radians. + + Coordinate System + + + + + + + X coordinate for the first point. + + + + + Y coordinate for the first point. + + + + + X coordinate for the second point. + + + + + Y coordinate for the second point. + + + + + + The name of the new line. + + + + + This method creates a line in the current layer using the current document style. It's a path, so the only attribute it will pay any attention to is "transform". + + Coordinate System + + + + + + + The text you want. + + + + + + The name of the new text object. + + + + + This method creates some text in the current layer. + + + + + + + + The type of node, probably "svg:path" + + + + + + The name of the new node. + + + + + Make any kind of node you want. Mostly for making paths. (May need to allow updateRepr to be called for it to show up.) + + + + + + + + + + + Document width. + + + + + Retrieve the width of the current document. anything outside the boundary will not be printed or exported but will be saved. + + + + + + + + + Document height. + + + + + Retrieve the height of the current document. anything outside the boundary will not be printed or exported but will be saved. + + + + + + + + + CSS attribute string for the document. + + + + + Get the current style for the document. All new shapes will use this style if it exists. + + Style Strings + + + + + + + A new CSS attribute string for the document. + + + + + Set the current style for the document. All new shapes will use this style if it exists. + + Style Strings + + + + + + + A new CSS attribute string for the document. + + + + + Merge this this string with the current style for the document. All new shapes will use this style if it exists. + + Style Strings, merge_css() + + + + + + + Resize the document to contain all of the currently selected objects. + This ensures that the image is not clipped when printing or exporting. + + + + + + + + + + The id of an object. + + + + + The name of the attribute. + + + + + The new value of the attribute. This will overwrite anything already set. To merge styles, see merge_css(). + + + + + Set any attribute, the available attributes depend on what kind of shape the object node represents. See shape creation functions for more details. + + + + + + + + The id of an object. + + + + + The name of the attribute. + + + + + The new value of the attribute. This will overwrite anything already set. + + + + + Set any attribute, the available attributes depend on what kind of shape the object node represents. See shape creation functions for more details. + This is a convenience function for set_attribute(). + + + + + + + + The id of an object. + + + + + The name of the attribute. + + + + + The new value of the attribute. This will overwrite anything already set. + + + + + Set any attribute, the available attributes depend on what kind of shape the node represents. See shape creation functions for more details. + This is a convenience function for set_attribute(). + + + + + + + + The id of an object. + + + + + The name of the attribute. + + + + + + The current value of the attribute. String is a copy and must be freed. + + + + + Get the value of any attribute. Not all objects will have every attribute their type supports, some are optional. See shape creation functions for more details. + + + + + + + + The id of an object. + + + + + Distance to move along the x axis. + + + + + Distance to move along the y axis. + + + + + This will move a shape (or any object) relative to it's current location. + This may be accomplished with transformation attributes or by changing x and y attributes depending on the state of the object. + + Coordinate System + + + + + + + The id of an object. + + + + + the x coordinate of the desired location. + + + + + the y coordinate of the desired location. + + + + + This will move a shape (or any object) to an absolute location. The point moved is the center of the bounding box, which is usually similar to the center of the shape. + Note that creating a rectangle or ellipse at 100,100 and calling move_to to move it to 100,100 will not produce the same results. + This may be accomplished with transformation attributes or by changing x and y attributes depending on the state of the object. + + Coordinate System + + + + + + + The id of an object. + + + + + Turns an object into a path. Most objects contain paths (except rectangles) but are not paths themselves. + This will remove every attribute except d (the path attribute) style and id. id will not change. The appearance will be the same as well, it essentially encodes all information about the shape into the path. + After doing this you will no longer be able to modify the shape using shape specific attributes (cx, radius etc.) except transform + Required for certain functions that work on paths (not yet present in this API.) + + + + + + + + The id of any node or object. + + + + + A string that represents a transformation. + + + + + Takes a transformation string ("matrix(0.96629885,0.25742286,-0.25742286,0.96629885,0,0)" or "rotate(45)") and applies it to any shape or path. + Will merge with existing transformations. + + + + + + + + Any object with a style attribute. + + + + + + A CSS Style string + + + + + Retrieve the style of a object. Equivalent to calling get_attribute() for "style". + + Style Strings + + + + + + + Any object with a style attribute. + + + + + An attribute such as "fill" or "stroke-width". + + + + + The new value. + + + + + Set a particular attribute of a style string. Overwrites just that part of the style. + + Style Strings + + + + + + + Any object with a style attribute. + + + + + A full or partial CSS Style string. + + + + + Takes a CSS Style string and merges it with the objects current style, overwriting only the elements present in stylestring. + + Style Strings + + + + + + + The id of an object. + + + + + A layer name. + + + + + Moves an object to a different layer. + Will error if layer does not exist. + + layer_new() + + + + + + + A object that contains a path ("d") attribute. + + + + + + An array of points. + + + + + Returns an array of all of the X,Y coordinates of the points in the objects path. + If the path is a closed loop the first point is repeated at the end. + + + + + + + + + + Saves the current document with current name or a default name if has not been saved before. + Will overwrite without confirmation. + + + + + + + + The path for the file to be saved as. + + + + + Saves the current document as pathname. + Will overwrite without confirmation. + + + + + + + + The path to a valid svg file. + + + + + Loads the file at pathname. + Will lose all unsaved work in current document. + + + + + + + + Prints the current document with default settings. + Will only print things visible within the document boundaries. + + document_resize_to_fit_selection() + + + + + + + + + Close this document. + You will not be able to send any more commands on this interface. + + + + + + + + Exit Inkscape. + You will not be able to send any more commands on any interface. + + + + + + + + Undo the last action. + + + + + + + + Redo the last undone action. + + + + + + + + + + When updates are paused Inkscape will not draw every change as it is made. Also you will not be able to undo individual actions made while updates were paused and will only be able to undo them in a group. Inkscape may refresh the screen every couple of seconds even with updates off. + The advantage is a 2-5x speed increase, depending on the type of functions being called. This is most useful when creating large numbers of shapes. + + + + + + + + Resume updates after they have been paused. If undo is called at this point it will undo everything that happened since pause_updates() was called. + This will update the display to show any changes that happened while updates were paused, a separate call to update() is not necessary. + + + + + + + + This will update the document once if updates are paused but it will not resume updates. + This could be used to check on the progress of a complex drawing function, or to add in undo steps at certain points in a render. + + + + + + + + + + + List of the ids of currently selected objects. + + + + + Returns the current selection in the form of a list of ids of selected objects. + Manipulating this list will not affect the selection. + + + + + + + + A object to add to the selection. + + + + + Adds a single object to the selection. + + + + + + + + An array of object ids to add to the selection. + + + + + Adds a list of objects to the selection. + + + + + + + + A object to select. + + + + + Replaces the selection with one containing just this object. + + + + + + + + A list of objects to select. + + + + + Replaces the selection with one containing just these objects. + + + + + + + + Angle in degrees to rotate. + + + + + Rotates the selection around the center of it's bounding box. + + + + + + + + Delete all objects in the selection. + + + + + + + + Deselect everything. Selection will be empty. + + + + + + + + Select all objects in current layer. + + + + + + + + Select all objects in every layer. + + + + + + + + X coordinate for the first point. + + + + + Y coordinate for the first point. + + + + + X coordinate for the second point. + + + + + Y coordinate for the second point. + + + + + True to replace selection, false to add to selection. + + + + + This method finds all of the objects inside the box and adds them to the current selection. If replace is true it will clear the old selection first. + + + + + + + + Invert the selection in the current layer. + + + + + + + + Group the selection. + + Groups + + + + + + + Ungroup the selection. + + Groups + + + + + + + Cut the current selection. + + + + + + + + Copy the current selection. + + + + + + + + Paste the current selection at the same location it was cut from. + To paste to a particular location, simply use selection_paste() followed by selection_move_to(). + + + + + + + + The amount to scale the selection, 1 has no effect. Between 0 and 1 will shrink it proportionally. Greater than one will grow it proportionally. + + + + + Scale the selection relative to it's current size. + + + + + + + + Amount to move in the x direction. + + + + + Amount to move in the y direction. + + + + + This will move the selection relative to it's current location. + This may be accomplished with transformation attributes or by changing x and y attributes depending on the state of the objects in the selection. + + Coordinate System + + + + + + + X coordinate to move to. + + + + + Y coordinate to move to. + + + + + This will move the center of the selection to a specific location. + This may be accomplished with transformation attributes or by changing x and y attributes depending on the state of the objects in the selection. + + Coordinate System + + + + + + + layer to move the selection to. + + + + + Move every item in the selection to a different layer. + Will error if layer does not exist. + + Layers and Levels + + + + + + + + Center of the selection. + + + + + Gets the center of the selections bounding box in X,Y coordinates. + + Coordinate System + + + + + + + Turns all the objects in the selection into paths. + + object_to_path() + + + + + + + Type of combination. + + + + + + The new path created, if there is one. NULL otherwise. + + + + + Will erase all objects in the selection and replace with a single aggregate path. + There are 5 types that can be passed in: + Union: The new shape is all of the other shapes put together, even if they don't overlap (paths can have multiple non-contiguous areas.) + Intersection: The new shape is composed of the area where ALL the objects in the selection overlap. If there is no area where all shapes overlap the new shape will be empty. + Difference: The area of the second shape is subtracted from the first, only works with two objects. + Exclusion: The new shape is the area(s) where none of the objects in the selection overlaped. Only works with two objects. + Division: the first object is split into multiple segments by the second object. Only works with two objects and if multiple paths result they are grouped and the group id is returned. + + + + + + + + How to change the level + + + + + + True if the objects changed levels. False if they don't(if they were already on top when being raised for example.) + + + + + Will change the level of a selection, respective of other objects in the same layer. Will not affect the overlap of objects in different layers. Will do nothing if the selection contains objects in multiple layers. + There are 4 commands that can be passed in: + "raise" or "lower": Move the selection one level up, or one level down. + "to_top" of "to_bottom": Move the selection above all other objects or below all other objects. + + + + + + + + + + + The name of the new layer. + + + + + Turns all the objects in the selection into paths. + + Layers and Levels + + + + + + + The name of any layer. + + + + + Sets the layer given as the current layer + + Layers and Levels + + + + + + + + list of layers. + + + + + Get a list of all the layers in this document. + + Layers and Levels + + + + + + + How to change the level + + + + + + True if the layer was moved. False if it was not (if it was already on top when being raised for example.) + + + + + Will change the level of a layer, respective of other layers. Will not affect the relative level of objects within the layer. + There are 4 commands that can be passed in: + "raise" or "lower": Move the layer one level up, or one level down. + "to_top" of "to_bottom": Move the layer above all other layers or below all other layers. + + + + + + + + Sets the next (or higher) layer as active. + + Layers and Levels + + + + + + + Sets the previous (or lower) layer as active. + + Layers and Levels + + + + + + diff --git a/src/extension/dbus/org.inkscape.service.in b/src/extension/dbus/org.inkscape.service.in new file mode 100644 index 000000000..401d2d38e --- /dev/null +++ b/src/extension/dbus/org.inkscape.service.in @@ -0,0 +1,4 @@ +[D-BUS Service] +Name=org.inkscape +Exec=/usr/local/bin/inkscape +