summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-07-17 05:13:49 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-07-17 05:13:49 +0000
commitdd59aa3bb2cab030296a4622e5166f0e3f8d5445 (patch)
treea86612c94d3ddce3edf696ea17fefb58b0accccf /src/extension
parentTemporary fixes/kludges. (diff)
parentShape calculations. re-introduce grid of a smaller size. (http://article.gman... (diff)
downloadinkscape-dd59aa3bb2cab030296a4622e5166f0e3f8d5445.tar.gz
inkscape-dd59aa3bb2cab030296a4622e5166f0e3f8d5445.zip
Merge from trunk.
(bzr r12380.1.17)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/dbus/application-interface.cpp59
-rw-r--r--src/extension/dbus/application-interface.h22
-rw-r--r--src/extension/dbus/application-interface.xml23
-rw-r--r--src/extension/dbus/dbus-init.cpp118
-rw-r--r--src/extension/dbus/dbus-init.h15
-rw-r--r--src/extension/dbus/document-interface.cpp663
-rw-r--r--src/extension/dbus/document-interface.h180
-rw-r--r--src/extension/dbus/document-interface.xml32
-rw-r--r--src/extension/dbus/wrapper/inkscape-dbus-wrapper.c18
-rw-r--r--src/extension/dbus/wrapper/inkscape-dbus-wrapper.h8
-rw-r--r--src/extension/effect.cpp8
-rw-r--r--src/extension/effect.h2
-rw-r--r--src/extension/internal/bluredge.cpp5
-rw-r--r--[-rwxr-xr-x]src/extension/internal/filter/filter-all.cpp0
14 files changed, 622 insertions, 531 deletions
diff --git a/src/extension/dbus/application-interface.cpp b/src/extension/dbus/application-interface.cpp
index 8ee7bd12f..c0bc19d90 100644
--- a/src/extension/dbus/application-interface.cpp
+++ b/src/extension/dbus/application-interface.cpp
@@ -18,6 +18,8 @@
#include "application-interface.h"
#include <string.h>
#include "dbus-init.h"
+#include "file.h"
+#include "inkscape.h"
G_DEFINE_TYPE(ApplicationInterface, application_interface, G_TYPE_OBJECT)
@@ -37,13 +39,32 @@ application_interface_class_init (ApplicationInterfaceClass *klass)
}
static void
-application_interface_init (ApplicationInterface *object)
+application_interface_init (ApplicationInterface *app_interface)
{
dbus_g_error_domain_register (INKSCAPE_ERROR,
NULL,
INKSCAPE_TYPE_ERROR);
}
+static bool
+ensure_desktop_valid(GError **error)
+{
+ if (!inkscape_use_gui()) {
+ g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Application interface action requires a GUI");
+ return false;
+ }
+ return true;
+}
+
+static bool
+ensure_desktop_not_present(GError **error)
+{
+ if (inkscape_use_gui()) {
+ g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Application interface action requires non-GUI (command line) mode");
+ return false;
+ }
+ return true;
+}
ApplicationInterface *
application_interface_new (void)
@@ -94,27 +115,28 @@ GType inkscape_error_get_type(void)
****************************************************************************/
gchar*
-application_interface_desktop_new (ApplicationInterface *object,
+application_interface_desktop_new (ApplicationInterface *app_interface,
GError **error)
{
- return (gchar*)Inkscape::Extension::Dbus::init_desktop();
+ g_return_val_if_fail(ensure_desktop_valid(error), NULL);
+ return (gchar*)Inkscape::Extension::Dbus::init_desktop();
}
gchar**
-application_interface_get_desktop_list (ApplicationInterface *object)
+application_interface_get_desktop_list (ApplicationInterface *app_interface)
{
return NULL;
}
gchar*
-application_interface_get_active_desktop (ApplicationInterface *object,
+application_interface_get_active_desktop (ApplicationInterface *app_interface,
GError **error)
{
return NULL;
}
gboolean
-application_interface_set_active_desktop (ApplicationInterface *object,
+application_interface_set_active_desktop (ApplicationInterface *app_interface,
gchar* document_name,
GError **error)
{
@@ -122,15 +144,16 @@ application_interface_set_active_desktop (ApplicationInterface *object,
}
gboolean
-application_interface_desktop_close_all (ApplicationInterface *object,
+application_interface_desktop_close_all (ApplicationInterface *app_interface,
GError **error)
{
return TRUE;
}
gboolean
-application_interface_exit (ApplicationInterface *object, GError **error)
+application_interface_exit (ApplicationInterface *app_interface, GError **error)
{
+ sp_file_exit();
return TRUE;
}
@@ -138,20 +161,32 @@ application_interface_exit (ApplicationInterface *object, GError **error)
DOCUMENT FUNCTIONS
****************************************************************************/
-gchar* application_interface_document_new (ApplicationInterface *object,
+gchar* application_interface_document_new (ApplicationInterface *app_interface,
GError **error)
{
- return (gchar*)Inkscape::Extension::Dbus::init_document();
+ g_return_val_if_fail(ensure_desktop_not_present(error), NULL);
+ return (gchar*)Inkscape::Extension::Dbus::init_document();
+}
+
+gchar*
+application_interface_get_active_document(ApplicationInterface *app_interface,
+ GError **error)
+{
+ gchar *result = (gchar*)Inkscape::Extension::Dbus::init_active_document();
+ if (!result) {
+ g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "No active document");
+ }
+ return result;
}
gchar**
-application_interface_get_document_list (ApplicationInterface *object)
+application_interface_get_document_list (ApplicationInterface *app_interface)
{
return NULL;
}
gboolean
-application_interface_document_close_all (ApplicationInterface *object,
+application_interface_document_close_all (ApplicationInterface *app_interface,
GError **error)
{
return TRUE;
diff --git a/src/extension/dbus/application-interface.h b/src/extension/dbus/application-interface.h
index 88219a6b0..c108402cb 100644
--- a/src/extension/dbus/application-interface.h
+++ b/src/extension/dbus/application-interface.h
@@ -67,41 +67,45 @@ GType inkscape_error_get_type (void);
****************************************************************************/
gchar*
-application_interface_desktop_new (ApplicationInterface *object,
+application_interface_desktop_new (ApplicationInterface *app_interface,
GError **error);
gchar**
-application_interface_get_desktop_list (ApplicationInterface *object);
+application_interface_get_desktop_list (ApplicationInterface *app_interface);
gchar*
-application_interface_get_active_desktop (ApplicationInterface *object,
+application_interface_get_active_desktop (ApplicationInterface *app_interface,
GError **error);
gboolean
-application_interface_set_active_desktop (ApplicationInterface *object,
+application_interface_set_active_desktop (ApplicationInterface *app_interface,
gchar* document_name,
GError **error);
gboolean
-application_interface_desktop_close_all (ApplicationInterface *object,
+application_interface_desktop_close_all (ApplicationInterface *app_interface,
GError **error);
gboolean
-application_interface_exit (ApplicationInterface *object, GError **error);
+application_interface_exit (ApplicationInterface *app_interface, GError **error);
/****************************************************************************
DOCUMENT FUNCTIONS
****************************************************************************/
gchar*
-application_interface_document_new (ApplicationInterface *object,
+application_interface_document_new (ApplicationInterface *app_interface,
GError **error);
+gchar*
+application_interface_get_active_document(ApplicationInterface *app_interface,
+ GError **error);
+
gchar**
-application_interface_get_document_list (ApplicationInterface *object);
+application_interface_get_document_list (ApplicationInterface *app_interface);
gboolean
-application_interface_document_close_all (ApplicationInterface *object,
+application_interface_document_close_all (ApplicationInterface *app_interface,
GError **error);
diff --git a/src/extension/dbus/application-interface.xml b/src/extension/dbus/application-interface.xml
index ee2c4837b..1553971cc 100644
--- a/src/extension/dbus/application-interface.xml
+++ b/src/extension/dbus/application-interface.xml
@@ -32,7 +32,7 @@
</arg>
<doc:doc>
<doc:description>
- <doc:para>Create a new document interface and return it's location.</doc:para>
+ <doc:para>Create a new document interface and return its location. Only call this when Inkscape is running in GUI mode.</doc:para>
</doc:description>
</doc:doc>
</method>
@@ -45,21 +45,21 @@
</arg>
<doc:doc>
<doc:description>
- <doc:para>List all the interfaces that it is possible to connect to.</doc:para>
+ <doc:para>List all the interfaces that it is possible to connect to. TODO: not implemented.</doc:para>
</doc:description>
</doc:doc>
</method>
<method name="desktop_close_all">
<doc:doc>
<doc:description>
- <doc:para>Close all document interfaces without saving.</doc:para>
+ <doc:para>Close all document interfaces without saving. TODO: not implemented.</doc:para>
</doc:description>
</doc:doc>
</method>
<method name="exit">
<doc:doc>
<doc:description>
- <doc:para>Exit Inkscape without saving. Fairly straightforward. </doc:para>
+ <doc:para>Exit Inkscape without saving. Fairly straightforward.</doc:para>
</doc:description>
</doc:doc>
</method>
@@ -76,6 +76,21 @@
<doc:description>
<doc:para>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.</doc:para>
<doc:para>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.</doc:para>
+ <doc:para>UPDATE: 3rd July 2013, Eric Greveson: After having done some initial work to attempt to decouple Inkscape "verbs" from desktops, it is now possible to run a limited subset of actions in command-line mode (with a selection model and document, but no desktop). I believe that the "single document interface" approach, with some functions that may require a GUI, is the better path, and so document interfaces without a desktop are now possible. Most functions still require the desktop to work, though, with the notable exception of selection methods and Boolean operations.</doc:para>
+ <doc:para>As a result, this function should ONLY be called when using Inkscape in command-line mode. Use "desktop_new" instead if running in GUI mode.</doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
+ <method name="get_active_document">
+ <arg type="s" name="document_name" direction="out" >
+ <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/>
+ <doc:doc>
+ <doc:summary>This string can be used to connect to the current active document.</doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>Get the location of the current active document (e.g. when running in console mode, when desktops are not available).</doc:para>
</doc:description>
</doc:doc>
</method>
diff --git a/src/extension/dbus/dbus-init.cpp b/src/extension/dbus/dbus-init.cpp
index 9ff6897e5..19b48e10d 100644
--- a/src/extension/dbus/dbus-init.cpp
+++ b/src/extension/dbus/dbus-init.cpp
@@ -36,7 +36,14 @@
#include <sstream>
-
+namespace
+{
+ // This stores the bus name to use for this app instance. By default, it
+ // will be set to org.inkscape. However, users may provide other names by
+ // setting command-line parameters when starting Inkscape, so that more
+ // than one instance of Inkscape may be used by external scripts.
+ gchar *instance_bus_name = NULL;
+}
namespace Inkscape {
namespace Extension {
@@ -78,10 +85,53 @@ dbus_register_object (DBusGConnection *connection,
return object;
}
+/*
+ * PRIVATE register a document interface for the document in the given ActionContext, if none exists.
+ * Return the DBus path to the interface (something like /org/inkscape/document_0).
+ * Note that while a DocumentInterface could be used either for a document with no desktop, or a
+ * document with a desktop, this function is only used for creating interfaces in the former case.
+ * Desktop-associated DocumentInterfaces are named /org/inkscape/desktop_0, etc.
+ * FIXME: This state of affairs probably needs tidying up at some point in the future.
+ */
+static gchar *
+dbus_register_document(Inkscape::ActionContext const & target)
+{
+ SPDocument *doc = target.getDocument();
+ g_assert(doc != NULL);
+
+ // Document name is not suitable for DBus name, as it might contain invalid chars
+ std::string name("/org/inkscape/document_");
+ std::stringstream ss;
+ ss << doc->serial();
+ name.append(ss.str());
+
+ DBusGConnection *connection = dbus_get_connection();
+ DBusGProxy *proxy = dbus_get_proxy(connection);
+
+ // Has the document already been registered?
+ if (!dbus_g_connection_lookup_g_object(connection, name.c_str())) {
+ // No - register it
+ DocumentInterface *doc_interface = (DocumentInterface*) dbus_register_object (connection,
+ proxy,
+ TYPE_DOCUMENT_INTERFACE,
+ &dbus_glib_document_interface_object_info,
+ name.c_str());
+
+ // Set the document info for this interface
+ doc_interface->target = target;
+ }
+ return strdup(name.c_str());
+}
+
/* Initialize a Dbus service */
void
init (void)
{
+ if (instance_bus_name == NULL) {
+ // Set the bus name to the default
+ instance_bus_name = strdup("org.inkscape");
+ }
+
guint result;
GError *error = NULL;
DBusGConnection *connection;
@@ -89,7 +139,7 @@ init (void)
connection = dbus_get_connection();
proxy = dbus_get_proxy(connection);
org_freedesktop_DBus_request_name (proxy,
- "org.inkscape",
+ instance_bus_name,
DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error);
//create interface for application
dbus_register_object (connection,
@@ -97,37 +147,36 @@ init (void)
TYPE_APPLICATION_INTERFACE,
&dbus_glib_application_interface_object_info,
DBUS_APPLICATION_INTERFACE_PATH);
-} //init
+}
gchar *
-init_document (void) {
- DBusGConnection *connection;
- DBusGProxy *proxy;
- SPDocument *doc;
-
- doc = SPDocument::createNewDoc(NULL, 1, TRUE);
-
- std::string name("/org/inkscape/");
- name.append(doc->getName());
- std::replace(name.begin(), name.end(), ' ', '_');
+init_document (void)
+{
+ // This is for command-line use only
+ g_assert(!inkscape_use_gui());
- connection = dbus_get_connection();
- proxy = dbus_get_proxy(connection);
+ // Create a blank document and get its selection model etc in an ActionContext
+ SPDocument *doc = SPDocument::createNewDoc(NULL, 1, TRUE);
+ inkscape_add_document(doc);
+ return dbus_register_document(inkscape_action_context_for_document(doc));
+}
- 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 *
+init_active_document()
+{
+ SPDocument *doc = inkscape_active_document();
+ if (!doc) {
+ return NULL;
+ }
+
+ return dbus_register_document(inkscape_active_action_context());
+}
gchar *
dbus_init_desktop_interface (SPDesktop * dt)
{
DBusGConnection *connection;
DBusGProxy *proxy;
- DocumentInterface *obj;
std::string name("/org/inkscape/desktop_");
std::stringstream out;
@@ -139,12 +188,12 @@ dbus_init_desktop_interface (SPDesktop * dt)
connection = dbus_get_connection();
proxy = dbus_get_proxy(connection);
- obj = (DocumentInterface*) dbus_register_object (connection,
+ DocumentInterface *doc_interface = (DocumentInterface*) dbus_register_object (connection,
proxy, TYPE_DOCUMENT_INTERFACE,
&dbus_glib_document_interface_object_info, name.c_str());
- obj->desk = dt;
- obj->updates = TRUE;
- dt->dbus_document_interface=obj;
+ doc_interface->target = Inkscape::ActionContext(dt);
+ doc_interface->updates = TRUE;
+ dt->dbus_document_interface=doc_interface;
return strdup(name.c_str());
}
@@ -159,8 +208,21 @@ init_desktop (void) {
out << dt->dkey;
name.append(out.str());
return strdup(name.c_str());
-} //init_desktop
+}
+void
+dbus_set_bus_name(gchar * bus_name)
+{
+ g_assert(bus_name != NULL);
+ g_assert(instance_bus_name == NULL);
+ instance_bus_name = strdup(bus_name);
+}
+gchar *
+dbus_get_bus_name()
+{
+ g_assert(instance_bus_name != NULL);
+ return instance_bus_name;
+}
} } } /* namespace Inkscape::Extension::Dbus */
diff --git a/src/extension/dbus/dbus-init.h b/src/extension/dbus/dbus-init.h
index 025011f28..7862ad3c3 100644
--- a/src/extension/dbus/dbus-init.h
+++ b/src/extension/dbus/dbus-init.h
@@ -10,8 +10,7 @@
#ifndef INKSCAPE_EXTENSION_DBUS_INIT_H__
#define INKSCAPE_EXTENSION_DBUS_INIT_H__
-#include "desktop.h"
-
+class SPDesktop;
namespace Inkscape {
namespace Extension {
@@ -23,10 +22,22 @@ void init (void);
gchar * init_document (void);
+gchar * init_active_document ();
+
gchar * init_desktop (void);
gchar * dbus_init_desktop_interface (SPDesktop * dt);
+/** Set the bus name to use. Default is "org.inkscape".
+ This function should only be called once, before init(), if a non-default
+ bus name is required. */
+void dbus_set_bus_name(gchar * bus_name);
+
+/** Get the bus name for this instance. Default is "org.inkscape".
+ This function should only be called after init().
+ The returned gchar * is owned by this module and should not be freed. */
+gchar * dbus_get_bus_name();
+
} } } /* namespace Dbus, Extension, Inkscape */
#endif /* INKSCAPE_EXTENSION_DBUS_INIT_H__ */
diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp
index 56d1dfdbd..3cb03646a 100644
--- a/src/extension/dbus/document-interface.cpp
+++ b/src/extension/dbus/document-interface.cpp
@@ -20,6 +20,7 @@
#include "application-interface.h"
#include <string.h>
#include <dbus/dbus-glib.h>
+#include "desktop.h"
#include "desktop-handles.h" //sp_desktop_document()
#include "desktop-style.h" //sp_desktop_get_style
#include "display/canvas-text.h" //text
@@ -30,8 +31,10 @@
#include "extension/system.h" //IO
#include "file.h" //IO
#include "helper/action.h" //sp_action_perform
+#include "helper/action-context.h"
#include "inkscape.h" //inkscape_find_desktop_by_dkey, activate desktops
#include "layer-fns.h" //LPOS_BELOW
+#include "layer-model.h"
#include "live_effects/parameter/text.h" //text
#include "print.h" //IO
#include "selection-chemistry.h"// lots of selection functions
@@ -91,12 +94,12 @@
* place to adjust things.
*/
Inkscape::XML::Node *
-get_repr_by_name (SPDesktop *desk, gchar *name, GError **error)
+get_repr_by_name (SPDocument *doc, gchar *name, GError **error)
{
/* ALTERNATIVE (is this faster if only repr is needed?)
Inkscape::XML::Node *node = sp_repr_lookup_name((doc->root)->repr, name);
*/
- SPObject * obj = sp_desktop_document(desk)->getObjectById(name);
+ SPObject * obj = doc->getObjectById(name);
if (!obj)
{
g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OBJECT, "Object '%s' not found in document.", name);
@@ -109,9 +112,9 @@ get_repr_by_name (SPDesktop *desk, gchar *name, GError **error)
* See comment for get_repr_by_name, above.
*/
SPObject *
-get_object_by_name (SPDesktop *desk, gchar *name, GError **error)
+get_object_by_name (SPDocument *doc, gchar *name, GError **error)
{
- SPObject * obj = sp_desktop_document(desk)->getObjectById(name);
+ SPObject * obj = doc->getObjectById(name);
if (!obj)
{
g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OBJECT, "Object '%s' not found in document.", name);
@@ -183,12 +186,11 @@ selection_get_center_y (Inkscape::Selection *sel){
* they might see the selection box flicker if used in a loop.
*/
const GSList *
-selection_swap(SPDesktop *desk, gchar *name, GError **error)
+selection_swap(Inkscape::Selection *sel, gchar *name, GError **error)
{
- Inkscape::Selection *sel = sp_desktop_selection(desk);
const GSList *oldsel = g_slist_copy((GSList *)sel->list());
- sel->set(get_object_by_name(desk, name, error));
+ sel->set(get_object_by_name(sel->layers()->getDocument(), name, error));
return oldsel;
}
@@ -196,9 +198,8 @@ selection_swap(SPDesktop *desk, gchar *name, GError **error)
* See selection_swap, above
*/
void
-selection_restore(SPDesktop *desk, const GSList * oldsel)
+selection_restore(Inkscape::Selection *sel, const GSList * oldsel)
{
- Inkscape::Selection *sel = sp_desktop_selection(desk);
sel->setList(oldsel);
}
@@ -206,9 +207,8 @@ selection_restore(SPDesktop *desk, const GSList * oldsel)
* Shortcut for creating a Node.
*/
Inkscape::XML::Node *
-dbus_create_node (SPDesktop *desk, const gchar *type)
+dbus_create_node (SPDocument *doc, const gchar *type)
{
- SPDocument * doc = sp_desktop_document (desk);
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
return xml_doc->createElement(type);
@@ -221,10 +221,12 @@ dbus_create_node (SPDesktop *desk, const gchar *type)
* There is probably a better way to do this (use the shape tools default styles)
* but I'm not sure how.
*/
-gchar *finish_create_shape (DocumentInterface *object, GError ** /*error*/, Inkscape::XML::Node *newNode, gchar *desc)
+gchar *finish_create_shape (DocumentInterface *doc_interface, GError ** /*error*/, Inkscape::XML::Node *newNode, gchar *desc)
{
- SPCSSAttr *style = sp_desktop_get_style(object->desk, TRUE);
-
+ SPCSSAttr *style = NULL;
+ if (doc_interface->target.getDesktop()) {
+ style = sp_desktop_get_style(doc_interface->target.getDesktop(), TRUE);
+ }
if (style) {
Glib::ustring str;
sp_repr_css_write_string(style, str);
@@ -234,13 +236,11 @@ gchar *finish_create_shape (DocumentInterface *object, GError ** /*error*/, Inks
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();
+ doc_interface->target.getSelection()->layers()->currentLayer()->appendChildRepr(newNode);
+ doc_interface->target.getSelection()->layers()->currentLayer()->updateRepr();
- if (object->updates) {
- Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), 0, (gchar *)desc);
- //} else {
- //document_interface_pause_updates(object, error);
+ if (doc_interface->updates) {
+ Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), 0, (gchar *)desc);
}
return strdup(newNode->attribute("id"));
@@ -255,31 +255,40 @@ gchar *finish_create_shape (DocumentInterface *object, GError ** /*error*/, Inks
* document_interface_call_verb is similar but is called by the user.
*/
gboolean
-dbus_call_verb (DocumentInterface *object, int verbid, GError **error)
+dbus_call_verb (DocumentInterface *doc_interface, int verbid, GError **error)
{
- SPDesktop *desk2 = object->desk;
- desktop_ensure_active (desk2);
-
- if ( desk2 ) {
- Inkscape::Verb *verb = Inkscape::Verb::get( verbid );
- if ( verb ) {
- SPAction *action = verb->get_action(desk2);
- if ( action ) {
- //if (!object->updates)
- //document_interface_pause_updates (object, error);
- sp_action_perform( action, NULL );
- if (object->updates)
- Inkscape::DocumentUndo::done(sp_desktop_document(desk2), verb->get_code(), g_strdup(verb->get_tip()));
- //if (!object->updates)
- //document_interface_pause_updates (object, error);
- return TRUE;
- }
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ if ( desk ) {
+ desktop_ensure_active (desk);
+ }
+ Inkscape::Verb *verb = Inkscape::Verb::get( verbid );
+ if ( verb ) {
+ SPAction *action = verb->get_action(doc_interface->target);
+ if ( action ) {
+ sp_action_perform( action, NULL );
+ if (doc_interface->updates)
+ Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), verb->get_code(), g_strdup(verb->get_tip()));
+ return TRUE;
}
}
g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_VERB, "Verb failed to execute");
return FALSE;
}
+/*
+ * Check that the desktop is not NULL. If it is NULL, set the error to a useful message.
+ */
+bool
+ensure_desktop_valid(SPDesktop* desk, GError **error)
+{
+ if (desk) {
+ return true;
+ }
+
+ g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Document interface action requires a GUI");
+ return false;
+}
+
/****************************************************************************
DOCUMENT INTERFACE CLASS STUFF
****************************************************************************/
@@ -310,9 +319,9 @@ document_interface_class_init (DocumentInterfaceClass *klass)
}
static void
-document_interface_init (DocumentInterface *object)
+document_interface_init (DocumentInterface *doc_interface)
{
- object->desk = NULL;
+ doc_interface->target = Inkscape::ActionContext();
}
@@ -328,28 +337,28 @@ document_interface_new (void)
MISC FUNCTIONS
****************************************************************************/
-gboolean document_interface_delete_all(DocumentInterface *object, GError ** /*error*/)
+gboolean document_interface_delete_all(DocumentInterface *doc_interface, GError ** /*error*/)
{
- sp_edit_clear_all(object->desk);
+ sp_edit_clear_all(doc_interface->target.getSelection());
return TRUE;
}
gboolean
-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) {
- Inkscape::DocumentUndo::done(sp_desktop_document(desk2), verb->get_code(), g_strdup(verb->get_tip()));
- }
- return TRUE;
+document_interface_call_verb (DocumentInterface *doc_interface, gchar *verbid, GError **error)
+{
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ if ( desk ) {
+ desktop_ensure_active (desk);
+ }
+ Inkscape::Verb *verb = Inkscape::Verb::getbyid( verbid );
+ if ( verb ) {
+ SPAction *action = verb->get_action(doc_interface->target);
+ if ( action ) {
+ sp_action_perform( action, NULL );
+ if (doc_interface->updates) {
+ Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), verb->get_code(), g_strdup(verb->get_tip()));
}
+ return TRUE;
}
}
g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_VERB, "Verb '%s' failed to execute or was not found.", verbid);
@@ -362,39 +371,39 @@ document_interface_call_verb (DocumentInterface *object, gchar *verbid, GError *
****************************************************************************/
gchar*
-document_interface_rectangle (DocumentInterface *object, int x, int y,
+document_interface_rectangle (DocumentInterface *doc_interface, int x, int y,
int width, int height, GError **error)
{
- Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:rect");
+ Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "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);
sp_repr_set_int(newNode, "height", height);
- return finish_create_shape (object, error, newNode, (gchar *)"create rectangle");
+ return finish_create_shape (doc_interface, error, newNode, (gchar *)"create rectangle");
}
gchar*
-document_interface_ellipse_center (DocumentInterface *object, int cx, int cy,
+document_interface_ellipse_center (DocumentInterface *doc_interface, int cx, int cy,
int rx, int ry, GError **error)
{
- Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path");
+ Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "svg:path");
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");
+ return finish_create_shape (doc_interface, error, newNode, (gchar *)"create circle");
}
gchar*
-document_interface_polygon (DocumentInterface *object, int cx, int cy,
+document_interface_polygon (DocumentInterface *doc_interface, 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, "svg:path");
+ Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "svg:path");
newNode->setAttribute("inkscape:flatsided", "true");
newNode->setAttribute("sodipodi:type", "star");
sp_repr_set_int(newNode, "sodipodi:cx", cx);
@@ -407,15 +416,15 @@ document_interface_polygon (DocumentInterface *object, int cx, int cy,
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");
+ return finish_create_shape (doc_interface, error, newNode, (gchar *)"create polygon");
}
gchar*
-document_interface_star (DocumentInterface *object, int cx, int cy,
+document_interface_star (DocumentInterface *doc_interface, 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, "svg:path");
+ Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "svg:path");
newNode->setAttribute("inkscape:flatsided", "false");
newNode->setAttribute("sodipodi:type", "star");
sp_repr_set_int(newNode, "sodipodi:cx", cx);
@@ -428,35 +437,35 @@ document_interface_star (DocumentInterface *object, int cx, int cy,
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");
+ return finish_create_shape (doc_interface, error, newNode, (gchar *)"create star");
}
gchar*
-document_interface_ellipse (DocumentInterface *object, int x, int y,
+document_interface_ellipse (DocumentInterface *doc_interface, 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);
+ return document_interface_ellipse_center (doc_interface, x+rx, y+ry, rx, ry, error);
}
gchar*
-document_interface_line (DocumentInterface *object, int x, int y,
+document_interface_line (DocumentInterface *doc_interface, int x, int y,
int x2, int y2, GError **error)
{
- Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path");
+ Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "svg:path");
std::stringstream out;
// Not sure why this works.
out << "m " << x << "," << y << " " << x2 - x << "," << y2 - y;
newNode->setAttribute("d", out.str().c_str());
- return finish_create_shape (object, error, newNode, (gchar *)"create line");
+ return finish_create_shape (doc_interface, error, newNode, (gchar *)"create line");
}
gchar*
-document_interface_spiral (DocumentInterface *object, int cx, int cy,
+document_interface_spiral (DocumentInterface *doc_interface, int cx, int cy,
int r, int revolutions, GError **error)
{
- Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path");
+ Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "svg:path");
newNode->setAttribute("sodipodi:type", "spiral");
sp_repr_set_int(newNode, "sodipodi:cx", cx);
sp_repr_set_int(newNode, "sodipodi:cy", cy);
@@ -465,7 +474,7 @@ document_interface_spiral (DocumentInterface *object, int cx, int cy,
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");
+ gchar * retval = finish_create_shape (doc_interface, error, newNode, (gchar *)"create spiral");
//Makes sure there is no fill for spirals by default.
gchar* newString = g_strconcat(newNode->attribute("style"), ";fill:none", NULL);
newNode->setAttribute("style", newString);
@@ -474,57 +483,55 @@ document_interface_spiral (DocumentInterface *object, int cx, int cy,
}
gchar*
-document_interface_text (DocumentInterface *object, int x, int y, gchar *text, GError **error)
+document_interface_text (DocumentInterface *doc_interface, int x, int y, gchar *text, GError **error)
{
- Inkscape::XML::Node *text_node = dbus_create_node(object->desk, "svg:text");
+ Inkscape::XML::Node *text_node = dbus_create_node(doc_interface->target.getDocument(), "svg:text");
sp_repr_set_int(text_node, "x", x);
sp_repr_set_int(text_node, "y", y);
//just a workaround so i can get an spitem from the name
- gchar *name = finish_create_shape (object, error, text_node, (gchar *)"create text");
+ gchar *name = finish_create_shape (doc_interface, error, text_node, (gchar *)"create text");
- SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error);
+ SPItem* text_obj=(SPItem* )get_object_by_name(doc_interface->target.getDocument(), name, error);
sp_te_set_repr_text_multiline(text_obj, text);
return name;
}
gchar *
-document_interface_image (DocumentInterface *object, int x, int y, gchar *filename, GError **error)
+document_interface_image (DocumentInterface *doc_interface, 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");
+ Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "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();
+ doc_interface->target.getSelection()->layers()->currentLayer()->appendChildRepr(newNode);
+ doc_interface->target.getSelection()->layers()->currentLayer()->updateRepr();
- if (object->updates)
- Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), 0, "Imported bitmap.");
+ if (doc_interface->updates)
+ Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), 0, "Imported bitmap.");
//g_free(uri);
return strdup(newNode->attribute("id"));
}
-gchar *document_interface_node(DocumentInterface *object, gchar *type, GError ** /*error*/)
+gchar *document_interface_node(DocumentInterface *doc_interface, gchar *type, GError ** /*error*/)
{
- SPDocument * doc = sp_desktop_document (object->desk);
+ SPDocument * doc = doc_interface->target.getDocument();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
Inkscape::XML::Node *newNode = xml_doc->createElement(type);
- object->desk->currentLayer()->appendChildRepr(newNode);
- object->desk->currentLayer()->updateRepr();
+ doc_interface->target.getSelection()->layers()->currentLayer()->appendChildRepr(newNode);
+ doc_interface->target.getSelection()->layers()->currentLayer()->updateRepr();
- if (object->updates) {
- Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), 0, (gchar *)"created empty node");
- //} else {
- //document_interface_pause_updates(object, error);
+ if (doc_interface->updates) {
+ Inkscape::DocumentUndo::done(doc, 0, (gchar *)"created empty node");
}
return strdup(newNode->attribute("id"));
@@ -534,53 +541,59 @@ gchar *document_interface_node(DocumentInterface *object, gchar *type, GError **
ENVIRONMENT FUNCTIONS
****************************************************************************/
gdouble
-document_interface_document_get_width (DocumentInterface *object)
+document_interface_document_get_width (DocumentInterface *doc_interface)
{
- return sp_desktop_document(object->desk)->getWidth();
+ return doc_interface->target.getDocument()->getWidth();
}
gdouble
-document_interface_document_get_height (DocumentInterface *object)
+document_interface_document_get_height (DocumentInterface *doc_interface)
{
- return sp_desktop_document(object->desk)->getHeight();
+ return doc_interface->target.getDocument()->getHeight();
}
-gchar *document_interface_document_get_css(DocumentInterface *object, GError ** /*error*/)
+gchar *document_interface_document_get_css(DocumentInterface *doc_interface, GError ** error)
{
- SPCSSAttr *current = (object->desk)->current;
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ g_return_val_if_fail(ensure_desktop_valid(desk, error), NULL);
+ SPCSSAttr *current = desk->current;
Glib::ustring str;
sp_repr_css_write_string(current, str);
return (str.empty() ? NULL : g_strdup (str.c_str()));
}
-gboolean document_interface_document_merge_css(DocumentInterface *object,
- gchar *stylestring, GError ** /*error*/)
+gboolean document_interface_document_merge_css(DocumentInterface *doc_interface,
+ gchar *stylestring, GError ** error)
{
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ g_return_val_if_fail(ensure_desktop_valid(desk, error), FALSE);
SPCSSAttr * style = sp_repr_css_attr_new();
sp_repr_css_attr_add_from_string(style, stylestring);
- sp_desktop_set_style(object->desk, style);
+ sp_desktop_set_style(desk, style);
return TRUE;
}
-gboolean document_interface_document_set_css(DocumentInterface *object,
- gchar *stylestring, GError ** /*error*/)
+gboolean document_interface_document_set_css(DocumentInterface *doc_interface,
+ gchar *stylestring, GError ** error)
{
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ g_return_val_if_fail(ensure_desktop_valid(desk, error), FALSE);
SPCSSAttr * style = sp_repr_css_attr_new();
sp_repr_css_attr_add_from_string (style, stylestring);
//Memory leak?
- object->desk->current = style;
+ desk->current = style;
return TRUE;
}
gboolean
-document_interface_document_resize_to_fit_selection (DocumentInterface *object,
+document_interface_document_resize_to_fit_selection (DocumentInterface *doc_interface,
GError **error)
{
- return dbus_call_verb (object, SP_VERB_FIT_CANVAS_TO_SELECTION, error);
+ return dbus_call_verb (doc_interface, SP_VERB_FIT_CANVAS_TO_SELECTION, error);
}
gboolean
-document_interface_document_set_display_area (DocumentInterface *object,
+document_interface_document_set_display_area (DocumentInterface *doc_interface,
double x0,
double y0,
double x1,
@@ -588,19 +601,25 @@ document_interface_document_set_display_area (DocumentInterface *object,
double border,
GError **error)
{
- object->desk->set_display_area (x0,
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ g_return_val_if_fail(ensure_desktop_valid(desk, error), FALSE);
+ desk->set_display_area (x0,
y0,
x1,
y1,
border, false);
- return TRUE;
+ return TRUE;
}
GArray *
-document_interface_document_get_display_area (DocumentInterface *object)
+document_interface_document_get_display_area (DocumentInterface *doc_interface)
{
- Geom::Rect const d = object->desk->get_display_area();
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ if (!desk) {
+ return NULL;
+ }
+ Geom::Rect const d = desk->get_display_area();
GArray * dArr = g_array_new (TRUE, TRUE, sizeof(double));
@@ -622,10 +641,10 @@ document_interface_document_get_display_area (DocumentInterface *object)
****************************************************************************/
gboolean
-document_interface_set_attribute (DocumentInterface *object, char *shape,
+document_interface_set_attribute (DocumentInterface *doc_interface, char *shape,
char *attribute, char *newval, GError **error)
{
- Inkscape::XML::Node *newNode = get_repr_by_name(object->desk, shape, error);
+ Inkscape::XML::Node *newNode = get_repr_by_name(doc_interface->target.getDocument(), shape, error);
/* ALTERNATIVE (is this faster?)
Inkscape::XML::Node *newnode = sp_repr_lookup_name((doc->root)->repr, name);
@@ -641,11 +660,11 @@ document_interface_set_attribute (DocumentInterface *object, char *shape,
}
gboolean
-document_interface_set_int_attribute (DocumentInterface *object,
+document_interface_set_int_attribute (DocumentInterface *doc_interface,
char *shape, char *attribute,
int newval, GError **error)
{
- Inkscape::XML::Node *newNode = get_repr_by_name (object->desk, shape, error);
+ Inkscape::XML::Node *newNode = get_repr_by_name (doc_interface->target.getDocument(), shape, error);
if (!newNode)
return FALSE;
@@ -655,11 +674,11 @@ document_interface_set_int_attribute (DocumentInterface *object,
gboolean
-document_interface_set_double_attribute (DocumentInterface *object,
+document_interface_set_double_attribute (DocumentInterface *doc_interface,
char *shape, char *attribute,
double newval, GError **error)
{
- Inkscape::XML::Node *newNode = get_repr_by_name (object->desk, shape, error);
+ Inkscape::XML::Node *newNode = get_repr_by_name (doc_interface->target.getDocument(), shape, error);
if (!dbus_check_string (attribute, error, "New value string was empty."))
return FALSE;
@@ -671,10 +690,10 @@ document_interface_set_double_attribute (DocumentInterface *object,
}
gchar *
-document_interface_get_attribute (DocumentInterface *object, char *shape,
+document_interface_get_attribute (DocumentInterface *doc_interface, char *shape,
char *attribute, GError **error)
{
- Inkscape::XML::Node *newNode = get_repr_by_name(object->desk, shape, error);
+ Inkscape::XML::Node *newNode = get_repr_by_name(doc_interface->target.getDocument(), shape, error);
if (!dbus_check_string (attribute, error, "Attribute name empty."))
return NULL;
@@ -685,47 +704,47 @@ document_interface_get_attribute (DocumentInterface *object, char *shape,
}
gboolean
-document_interface_move (DocumentInterface *object, gchar *name, gdouble x,
+document_interface_move (DocumentInterface *doc_interface, gchar *name, gdouble x,
gdouble y, GError **error)
{
- const GSList *oldsel = selection_swap(object->desk, name, error);
+ const GSList *oldsel = selection_swap(doc_interface->target.getSelection(), name, error);
if (!oldsel)
return FALSE;
- sp_selection_move (object->desk, x, 0 - y);
- selection_restore(object->desk, oldsel);
+ sp_selection_move (doc_interface->target.getSelection(), x, 0 - y);
+ selection_restore(doc_interface->target.getSelection(), oldsel);
return TRUE;
}
gboolean
-document_interface_move_to (DocumentInterface *object, gchar *name, gdouble x,
+document_interface_move_to (DocumentInterface *doc_interface, gchar *name, gdouble x,
gdouble y, GError **error)
{
- const GSList *oldsel = selection_swap(object->desk, name, error);
+ const GSList *oldsel = selection_swap(doc_interface->target.getSelection(), name, error);
if (!oldsel)
return FALSE;
- Inkscape::Selection * sel = sp_desktop_selection(object->desk);
- sp_selection_move (object->desk, x - selection_get_center_x(sel),
+ Inkscape::Selection * sel = doc_interface->target.getSelection();
+ sp_selection_move (doc_interface->target.getSelection(), x - selection_get_center_x(sel),
0 - (y - selection_get_center_y(sel)));
- selection_restore(object->desk, oldsel);
+ selection_restore(doc_interface->target.getSelection(), oldsel);
return TRUE;
}
gboolean
-document_interface_object_to_path (DocumentInterface *object,
+document_interface_object_to_path (DocumentInterface *doc_interface,
char *shape, GError **error)
{
- const GSList *oldsel = selection_swap(object->desk, shape, error);
+ const GSList *oldsel = selection_swap(doc_interface->target.getSelection(), shape, error);
if (!oldsel)
return FALSE;
- dbus_call_verb (object, SP_VERB_OBJECT_TO_CURVE, error);
- selection_restore(object->desk, oldsel);
+ dbus_call_verb (doc_interface, SP_VERB_OBJECT_TO_CURVE, error);
+ selection_restore(doc_interface->target.getSelection(), oldsel);
return TRUE;
}
gchar *
-document_interface_get_path (DocumentInterface *object, char *pathname, GError **error)
+document_interface_get_path (DocumentInterface *doc_interface, char *pathname, GError **error)
{
- Inkscape::XML::Node *node = get_repr_by_name(object->desk, pathname, error);
+ Inkscape::XML::Node *node = get_repr_by_name(doc_interface->target.getDocument(), pathname, error);
if (!node)
return NULL;
@@ -739,30 +758,30 @@ document_interface_get_path (DocumentInterface *object, char *pathname, GError *
}
gboolean
-document_interface_transform (DocumentInterface *object, gchar *shape,
+document_interface_transform (DocumentInterface *doc_interface, gchar *shape,
gchar *transformstr, GError **error)
{
//FIXME: This should merge transformations.
gchar trans[] = "transform";
- document_interface_set_attribute (object, shape, trans, transformstr, error);
+ document_interface_set_attribute (doc_interface, shape, trans, transformstr, error);
return TRUE;
}
gchar *
-document_interface_get_css (DocumentInterface *object, gchar *shape,
+document_interface_get_css (DocumentInterface *doc_interface, gchar *shape,
GError **error)
{
gchar style[] = "style";
- return document_interface_get_attribute (object, shape, style, error);
+ return document_interface_get_attribute (doc_interface, shape, style, error);
}
gboolean
-document_interface_modify_css (DocumentInterface *object, gchar *shape,
+document_interface_modify_css (DocumentInterface *doc_interface, gchar *shape,
gchar *cssattrb, gchar *newval, GError **error)
{
// Doesn't like non-variable strings for some reason.
gchar style[] = "style";
- Inkscape::XML::Node *node = get_repr_by_name(object->desk, shape, error);
+ Inkscape::XML::Node *node = get_repr_by_name(doc_interface->target.getDocument(), shape, error);
if (!dbus_check_string (cssattrb, error, "Attribute string empty."))
return FALSE;
@@ -778,12 +797,12 @@ document_interface_modify_css (DocumentInterface *object, gchar *shape,
}
gboolean
-document_interface_merge_css (DocumentInterface *object, gchar *shape,
+document_interface_merge_css (DocumentInterface *doc_interface, gchar *shape,
gchar *stylestring, GError **error)
{
gchar style[] = "style";
- Inkscape::XML::Node *node = get_repr_by_name(object->desk, shape, error);
+ Inkscape::XML::Node *node = get_repr_by_name(doc_interface->target.getDocument(), shape, error);
if (!dbus_check_string (stylestring, error, "Style string empty."))
return FALSE;
@@ -804,7 +823,7 @@ document_interface_merge_css (DocumentInterface *object, gchar *shape,
}
gboolean
-document_interface_set_color (DocumentInterface *object, gchar *shape,
+document_interface_set_color (DocumentInterface *doc_interface, gchar *shape,
int r, int g, int b, gboolean fill, GError **error)
{
gchar style[15];
@@ -820,29 +839,29 @@ document_interface_set_color (DocumentInterface *object, gchar *shape,
snprintf(style, 15, "stroke:#%.2x%.2x%.2x", r, g, b);
if (strcmp(shape, "document") == 0)
- return document_interface_document_merge_css (object, style, error);
+ return document_interface_document_merge_css (doc_interface, style, error);
- return document_interface_merge_css (object, shape, style, error);
+ return document_interface_merge_css (doc_interface, shape, style, error);
}
gboolean
-document_interface_move_to_layer (DocumentInterface *object, gchar *shape,
+document_interface_move_to_layer (DocumentInterface *doc_interface, gchar *shape,
gchar *layerstr, GError **error)
{
- const GSList *oldsel = selection_swap(object->desk, shape, error);
+ const GSList *oldsel = selection_swap(doc_interface->target.getSelection(), shape, error);
if (!oldsel)
return FALSE;
- document_interface_selection_move_to_layer(object, layerstr, error);
- selection_restore(object->desk, oldsel);
+ document_interface_selection_move_to_layer(doc_interface, layerstr, error);
+ selection_restore(doc_interface->target.getSelection(), oldsel);
return TRUE;
}
-GArray *document_interface_get_node_coordinates(DocumentInterface * /*object*/, gchar * /*shape*/)
+GArray *document_interface_get_node_coordinates(DocumentInterface * /*doc_interface*/, gchar * /*shape*/)
{
//FIXME: Needs lot's of work.
/*
- Inkscape::XML::Node *shapenode = get_repr_by_name (object->desk, shape, error);
+ Inkscape::XML::Node *shapenode = get_repr_by_name (doc_interface->target.getDocument(), shape, error);
if (shapenode == NULL || shapenode->attribute("d") == NULL) {
return FALSE;
}
@@ -857,10 +876,10 @@ GArray *document_interface_get_node_coordinates(DocumentInterface * /*object*/,
gboolean
-document_interface_set_text (DocumentInterface *object, gchar *name, gchar *text, GError **error)
+document_interface_set_text (DocumentInterface *doc_interface, gchar *name, gchar *text, GError **error)
{
- SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error);
+ SPItem* text_obj=(SPItem* )get_object_by_name(doc_interface->target.getDocument(), name, error);
//TODO verify object type
if (!text_obj)
return FALSE;
@@ -872,12 +891,12 @@ document_interface_set_text (DocumentInterface *object, gchar *name, gchar *text
gboolean
-document_interface_text_apply_style (DocumentInterface *object, gchar *name,
+document_interface_text_apply_style (DocumentInterface *doc_interface, gchar *name,
int start_pos, int end_pos, gchar *style, gchar *styleval,
GError **error)
{
- SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error);
+ SPItem* text_obj=(SPItem* )get_object_by_name(doc_interface->target.getDocument(), name, error);
//void sp_te_apply_style(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPCSSAttr const *css)
//TODO verify object type
@@ -904,34 +923,40 @@ document_interface_text_apply_style (DocumentInterface *object, gchar *name,
****************************************************************************/
gboolean
-document_interface_save (DocumentInterface *object, GError **error)
+document_interface_save (DocumentInterface *doc_interface, GError **error)
{
- SPDocument * doc = sp_desktop_document(object->desk);
+ SPDocument * doc = doc_interface->target.getDocument();
printf("1: %s\n2: %s\n3: %s\n", doc->getURI(), doc->getBase(), doc->getName());
if (doc->getURI())
- return document_interface_save_as (object, doc->getURI(), error);
+ return document_interface_save_as (doc_interface, doc->getURI(), error);
return FALSE;
}
-gboolean document_interface_load(DocumentInterface *object,
+gboolean document_interface_load(DocumentInterface *doc_interface,
gchar *filename, GError ** /*error*/)
{
- desktop_ensure_active(object->desk);
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ if (desk) {
+ desktop_ensure_active(desk);
+ }
const Glib::ustring file(filename);
sp_file_open(file, NULL, TRUE, TRUE);
- if (object->updates) {
- Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), SP_VERB_FILE_OPEN, "Opened File");
+ if (doc_interface->updates) {
+ Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), SP_VERB_FILE_OPEN, "Opened File");
}
return TRUE;
}
gchar *
-document_interface_import (DocumentInterface *object,
+document_interface_import (DocumentInterface *doc_interface,
gchar *filename, GError **error)
{
- desktop_ensure_active (object->desk);
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ if (desk) {
+ desktop_ensure_active(desk);
+ }
const Glib::ustring file(filename);
- SPDocument * doc = sp_desktop_document(object->desk);
+ SPDocument * doc = doc_interface->target.getDocument();
SPObject *new_obj = NULL;
new_obj = file_import(doc, file, NULL);
@@ -939,10 +964,11 @@ document_interface_import (DocumentInterface *object,
}
gboolean
-document_interface_save_as (DocumentInterface *object,
+document_interface_save_as (DocumentInterface *doc_interface,
const gchar *filename, GError **error)
{
- SPDocument * doc = sp_desktop_document(object->desk);
+ // FIXME: Isn't there a verb we can use for this instead?
+ SPDocument * doc = doc_interface->target.getDocument();
#ifdef WITH_GNOME_VFS
const Glib::ustring file(filename);
return file_save_remote(doc, file, NULL, TRUE, TRUE);
@@ -955,18 +981,16 @@ document_interface_save_as (DocumentInterface *object,
Inkscape::Extension::save(NULL, doc, filename,
false, false, true, Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS);
} catch (...) {
- //SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved."));
+ // FIXME: catch ... is not usually a great idea, why is it needed here?
return false;
}
- //SP_ACTIVE_DESKTOP->event_log->rememberFileSave();
- //SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::NORMAL_MESSAGE, "Document saved.");
return true;
}
-gboolean document_interface_mark_as_unmodified(DocumentInterface *object, GError ** /*error*/)
+gboolean document_interface_mark_as_unmodified(DocumentInterface *doc_interface, GError ** /*error*/)
{
- SPDocument * doc = sp_desktop_document(object->desk);
+ SPDocument * doc = doc_interface->target.getDocument();
if (doc) {
doc->modified_since_save = FALSE;
}
@@ -975,9 +999,9 @@ gboolean document_interface_mark_as_unmodified(DocumentInterface *object, GError
/*
gboolean
-document_interface_print_to_file (DocumentInterface *object, GError **error)
+document_interface_print_to_file (DocumentInterface *doc_interface, GError **error)
{
- SPDocument * doc = sp_desktop_document(object->desk);
+ SPDocument * doc = doc_interface->target.getDocument();
sp_print_document_to_file (doc, g_strdup("/home/soren/test.pdf"));
return TRUE;
@@ -988,27 +1012,27 @@ document_interface_print_to_file (DocumentInterface *object, GError **error)
****************************************************************************/
gboolean
-document_interface_close (DocumentInterface *object, GError **error)
+document_interface_close (DocumentInterface *doc_interface, GError **error)
{
- return dbus_call_verb (object, SP_VERB_FILE_CLOSE_VIEW, error);
+ return dbus_call_verb (doc_interface, SP_VERB_FILE_CLOSE_VIEW, error);
}
gboolean
-document_interface_exit (DocumentInterface *object, GError **error)
+document_interface_exit (DocumentInterface *doc_interface, GError **error)
{
- return dbus_call_verb (object, SP_VERB_FILE_QUIT, error);
+ return dbus_call_verb (doc_interface, SP_VERB_FILE_QUIT, error);
}
gboolean
-document_interface_undo (DocumentInterface *object, GError **error)
+document_interface_undo (DocumentInterface *doc_interface, GError **error)
{
- return dbus_call_verb (object, SP_VERB_EDIT_UNDO, error);
+ return dbus_call_verb (doc_interface, SP_VERB_EDIT_UNDO, error);
}
gboolean
-document_interface_redo (DocumentInterface *object, GError **error)
+document_interface_redo (DocumentInterface *doc_interface, GError **error)
{
- return dbus_call_verb (object, SP_VERB_EDIT_REDO, error);
+ return dbus_call_verb (doc_interface, SP_VERB_EDIT_REDO, error);
}
@@ -1020,48 +1044,46 @@ document_interface_redo (DocumentInterface *object, GError **error)
Need to make sure it plays well with verbs because they are used so much.
****************************************************************************/
-void document_interface_pause_updates(DocumentInterface *object, GError ** /*error*/)
+void document_interface_pause_updates(DocumentInterface *doc_interface, GError ** error)
{
- object->updates = FALSE;
- object->desk->canvas->drawing_disabled = 1;
- //object->desk->canvas->need_redraw = 0;
- //object->desk->canvas->need_repick = 0;
- //sp_desktop_document(object->desk)->root->uflags = FALSE;
- //sp_desktop_document(object->desk)->root->mflags = FALSE;
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ g_return_if_fail(ensure_desktop_valid(desk, error));
+ doc_interface->updates = FALSE;
+ desk->canvas->drawing_disabled = 1;
}
-void document_interface_resume_updates(DocumentInterface *object, GError ** /*error*/)
+void document_interface_resume_updates(DocumentInterface *doc_interface, GError ** error)
{
- object->updates = TRUE;
- object->desk->canvas->drawing_disabled = 0;
- //object->desk->canvas->need_redraw = 1;
- //object->desk->canvas->need_repick = 1;
- //sp_desktop_document(object->desk)->root->uflags = TRUE;
- //sp_desktop_document(object->desk)->root->mflags = TRUE;
- //sp_desktop_document(object->desk)->_updateDocument();
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ g_return_if_fail(ensure_desktop_valid(desk, error));
+ doc_interface->updates = TRUE;
+ desk->canvas->drawing_disabled = 0;
//FIXME: use better verb than rect.
- Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), SP_VERB_CONTEXT_RECT, "Multiple actions");
+ Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), SP_VERB_CONTEXT_RECT, "Multiple actions");
}
-void document_interface_update(DocumentInterface *object, GError ** /*error*/)
+void document_interface_update(DocumentInterface *doc_interface, GError ** error)
{
- sp_desktop_document(object->desk)->getRoot()->uflags = TRUE;
- sp_desktop_document(object->desk)->getRoot()->mflags = TRUE;
- object->desk->enableInteraction();
- sp_desktop_document(object->desk)->_updateDocument();
- object->desk->disableInteraction();
- sp_desktop_document(object->desk)->getRoot()->uflags = FALSE;
- sp_desktop_document(object->desk)->getRoot()->mflags = FALSE;
- //Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), SP_VERB_CONTEXT_RECT, "Multiple actions");
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ g_return_if_fail(ensure_desktop_valid(desk, error));
+ SPDocument *doc = doc_interface->target.getDocument();
+ doc->getRoot()->uflags = TRUE;
+ doc->getRoot()->mflags = TRUE;
+ desk->enableInteraction();
+ doc->_updateDocument();
+ desk->disableInteraction();
+ doc->getRoot()->uflags = FALSE;
+ doc->getRoot()->mflags = FALSE;
+ //Inkscape::DocumentUndo::done(doc, SP_VERB_CONTEXT_RECT, "Multiple actions");
}
/****************************************************************************
SELECTION FUNCTIONS FIXME: use call_verb where appropriate (once update system is tested.)
****************************************************************************/
-gboolean document_interface_selection_get(DocumentInterface *object, char ***out, GError ** /*error*/)
+gboolean document_interface_selection_get(DocumentInterface *doc_interface, char ***out, GError ** /*error*/)
{
- Inkscape::Selection * sel = sp_desktop_selection(object->desk);
+ Inkscape::Selection * sel = doc_interface->target.getSelection();
GSList const *oldsel = sel->list();
int size = g_slist_length((GSList *) oldsel);
@@ -1079,85 +1101,82 @@ gboolean document_interface_selection_get(DocumentInterface *object, char ***out
}
gboolean
-document_interface_selection_add (DocumentInterface *object, char *name, GError **error)
+document_interface_selection_add (DocumentInterface *doc_interface, char *name, GError **error)
{
- SPObject * obj = get_object_by_name(object->desk, name, error);
+ SPObject * obj = get_object_by_name(doc_interface->target.getDocument(), name, error);
if (!obj)
return FALSE;
- Inkscape::Selection *selection = sp_desktop_selection(object->desk);
+ Inkscape::Selection *selection = doc_interface->target.getSelection();
selection->add(obj);
return TRUE;
}
gboolean
-document_interface_selection_add_list (DocumentInterface *object,
+document_interface_selection_add_list (DocumentInterface *doc_interface,
char **names, GError **error)
{
int i;
for (i=0;names[i] != NULL;i++) {
- document_interface_selection_add(object, names[i], error);
+ document_interface_selection_add(doc_interface, names[i], error);
}
return TRUE;
}
-gboolean document_interface_selection_set(DocumentInterface *object, char *name, GError ** /*error*/)
+gboolean document_interface_selection_set(DocumentInterface *doc_interface, char *name, GError ** /*error*/)
{
- SPDocument * doc = sp_desktop_document(object->desk);
- Inkscape::Selection *selection = sp_desktop_selection(object->desk);
+ SPDocument * doc = doc_interface->target.getDocument();
+ Inkscape::Selection *selection = doc_interface->target.getSelection();
selection->set(doc->getObjectById(name));
return TRUE;
}
gboolean
-document_interface_selection_set_list (DocumentInterface *object,
+document_interface_selection_set_list (DocumentInterface *doc_interface,
gchar **names, GError **error)
{
- sp_desktop_selection(object->desk)->clear();
+ doc_interface->target.getSelection()->clear();
int i;
for (i=0;names[i] != NULL;i++) {
- document_interface_selection_add(object, names[i], error);
+ document_interface_selection_add(doc_interface, names[i], error);
}
return TRUE;
}
-gboolean document_interface_selection_rotate(DocumentInterface *object, int angle, GError ** /*error*/)
+gboolean document_interface_selection_rotate(DocumentInterface *doc_interface, int angle, GError ** /*error*/)
{
- Inkscape::Selection *selection = sp_desktop_selection(object->desk);
+ Inkscape::Selection *selection = doc_interface->target.getSelection();
sp_selection_rotate(selection, angle);
return TRUE;
}
gboolean
-document_interface_selection_delete (DocumentInterface *object, GError **error)
+document_interface_selection_delete (DocumentInterface *doc_interface, GError **error)
{
- //sp_selection_delete (object->desk);
- return dbus_call_verb (object, SP_VERB_EDIT_DELETE, error);
+ return dbus_call_verb (doc_interface, SP_VERB_EDIT_DELETE, error);
}
-gboolean document_interface_selection_clear(DocumentInterface *object, GError ** /*error*/)
+gboolean document_interface_selection_clear(DocumentInterface *doc_interface, GError ** /*error*/)
{
- sp_desktop_selection(object->desk)->clear();
+ doc_interface->target.getSelection()->clear();
return TRUE;
}
gboolean
-document_interface_select_all (DocumentInterface *object, GError **error)
+document_interface_select_all (DocumentInterface *doc_interface, GError **error)
{
- //sp_edit_select_all (object->desk);
- return dbus_call_verb (object, SP_VERB_EDIT_SELECT_ALL, error);
+ return dbus_call_verb (doc_interface, SP_VERB_EDIT_SELECT_ALL, error);
}
gboolean
-document_interface_select_all_in_all_layers(DocumentInterface *object,
+document_interface_select_all_in_all_layers(DocumentInterface *doc_interface,
GError **error)
{
- //sp_edit_select_all_in_all_layers (object->desk);
- return dbus_call_verb (object, SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, error);
+ return dbus_call_verb (doc_interface, SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, error);
}
-gboolean document_interface_selection_box(DocumentInterface * /*object*/, int /*x*/, int /*y*/,
+gboolean document_interface_selection_box(DocumentInterface * /*doc_interface*/, int /*x*/, int /*y*/,
int /*x2*/, int /*y2*/, gboolean /*replace*/,
GError ** /*error*/)
{
@@ -1166,63 +1185,49 @@ gboolean document_interface_selection_box(DocumentInterface * /*object*/, int /*
}
gboolean
-document_interface_selection_invert (DocumentInterface *object, GError **error)
+document_interface_selection_invert (DocumentInterface *doc_interface, GError **error)
{
- //sp_edit_invert (object->desk);
- return dbus_call_verb (object, SP_VERB_EDIT_INVERT, error);
+ return dbus_call_verb (doc_interface, SP_VERB_EDIT_INVERT, error);
}
gboolean
-document_interface_selection_group (DocumentInterface *object, GError **error)
+document_interface_selection_group (DocumentInterface *doc_interface, GError **error)
{
- //sp_selection_group (object->desk);
- return dbus_call_verb (object, SP_VERB_SELECTION_GROUP, error);
+ return dbus_call_verb (doc_interface, SP_VERB_SELECTION_GROUP, error);
}
gboolean
-document_interface_selection_ungroup (DocumentInterface *object, GError **error)
+document_interface_selection_ungroup (DocumentInterface *doc_interface, GError **error)
{
- //sp_selection_ungroup (object->desk);
- return dbus_call_verb (object, SP_VERB_SELECTION_UNGROUP, error);
+ return dbus_call_verb (doc_interface, SP_VERB_SELECTION_UNGROUP, error);
}
gboolean
-document_interface_selection_cut (DocumentInterface *object, GError **error)
+document_interface_selection_cut (DocumentInterface *doc_interface, GError **error)
{
- //desktop_ensure_active (object->desk);
- //sp_selection_cut (object->desk);
- return dbus_call_verb (object, SP_VERB_EDIT_CUT, error);
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ g_return_val_if_fail(ensure_desktop_valid(desk, error), FALSE);
+ return dbus_call_verb (doc_interface, SP_VERB_EDIT_CUT, error);
}
gboolean
-document_interface_selection_copy (DocumentInterface *object, GError **error)
+document_interface_selection_copy (DocumentInterface *doc_interface, GError **error)
{
- //desktop_ensure_active (object->desk);
- //sp_selection_copy ();
- return dbus_call_verb (object, SP_VERB_EDIT_COPY, error);
-}
-/*
-gboolean
-document_interface_selection_paste (DocumentInterface *object, GError **error)
-{
- desktop_ensure_active (object->desk);
- if (!object->updates)
- document_interface_pause_updates (object, error);
- sp_selection_paste (object->desk, TRUE);
- if (!object->updates)
- document_interface_pause_updates (object, error);
- return TRUE;
- //return dbus_call_verb (object, SP_VERB_EDIT_PASTE, error);
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ g_return_val_if_fail(ensure_desktop_valid(desk, error), FALSE);
+ return dbus_call_verb (doc_interface, SP_VERB_EDIT_COPY, error);
}
-*/
+
gboolean
-document_interface_selection_paste (DocumentInterface *object, GError **error)
+document_interface_selection_paste (DocumentInterface *doc_interface, GError **error)
{
- return dbus_call_verb (object, SP_VERB_EDIT_PASTE, error);
+ SPDesktop *desk = doc_interface->target.getDesktop();
+ g_return_val_if_fail(ensure_desktop_valid(desk, error), FALSE);
+ return dbus_call_verb (doc_interface, SP_VERB_EDIT_PASTE, error);
}
-gboolean document_interface_selection_scale(DocumentInterface *object, gdouble grow, GError ** /*error*/)
+gboolean document_interface_selection_scale(DocumentInterface *doc_interface, gdouble grow, GError ** /*error*/)
{
- Inkscape::Selection *selection = sp_desktop_selection(object->desk);
+ Inkscape::Selection *selection = doc_interface->target.getSelection();
if (!selection)
{
return FALSE;
@@ -1231,15 +1236,15 @@ gboolean document_interface_selection_scale(DocumentInterface *object, gdouble g
return TRUE;
}
-gboolean document_interface_selection_move(DocumentInterface *object, gdouble x, gdouble y, GError ** /*error*/)
+gboolean document_interface_selection_move(DocumentInterface *doc_interface, gdouble x, gdouble y, GError ** /*error*/)
{
- sp_selection_move(object->desk, x, 0 - y); //switching coordinate systems.
+ sp_selection_move(doc_interface->target.getSelection(), x, 0 - y); //switching coordinate systems.
return TRUE;
}
-gboolean document_interface_selection_move_to(DocumentInterface *object, gdouble x, gdouble y, GError ** /*error*/)
+gboolean document_interface_selection_move_to(DocumentInterface *doc_interface, gdouble x, gdouble y, GError ** /*error*/)
{
- Inkscape::Selection * sel = sp_desktop_selection(object->desk);
+ Inkscape::Selection * sel = doc_interface->target.getSelection();
Geom::OptRect sel_bbox = sel->visualBounds();
if (sel_bbox) {
@@ -1253,18 +1258,19 @@ gboolean document_interface_selection_move_to(DocumentInterface *object, gdouble
// This needs to use lower level cut_impl and paste_impl (messy)
// See the built-in sp_selection_to_next_layer and duplicate.
gboolean
-document_interface_selection_move_to_layer (DocumentInterface *object,
+document_interface_selection_move_to_layer (DocumentInterface *doc_interface,
gchar *layerstr, GError **error)
{
- SPDesktop * dt = object->desk;
+ SPDesktop *dt = doc_interface->target.getDesktop();
+ g_return_val_if_fail(ensure_desktop_valid(dt, error), FALSE);
- Inkscape::Selection *selection = sp_desktop_selection(dt);
+ Inkscape::Selection *selection = doc_interface->target.getSelection();
// check if something is selected
if (selection->isEmpty())
return FALSE;
- SPObject *next = get_object_by_name(object->desk, layerstr, error);
+ SPObject *next = get_object_by_name(doc_interface->target.getDocument(), layerstr, error);
if (!next)
return FALSE;
@@ -1273,7 +1279,7 @@ document_interface_selection_move_to_layer (DocumentInterface *object,
sp_selection_cut(dt);
- dt->setCurrentLayer(next);
+ doc_interface->target.getSelection()->layers()->setCurrentLayer(next);
sp_selection_paste(dt, TRUE);
}
@@ -1281,9 +1287,9 @@ document_interface_selection_move_to_layer (DocumentInterface *object,
}
GArray *
-document_interface_selection_get_center (DocumentInterface *object)
+document_interface_selection_get_center (DocumentInterface *doc_interface)
{
- Inkscape::Selection * sel = sp_desktop_selection(object->desk);
+ Inkscape::Selection * sel = doc_interface->target.getSelection();
if (sel)
{
@@ -1300,52 +1306,46 @@ document_interface_selection_get_center (DocumentInterface *object)
}
gboolean
-document_interface_selection_to_path (DocumentInterface *object, GError **error)
+document_interface_selection_to_path (DocumentInterface *doc_interface, GError **error)
{
- return dbus_call_verb (object, SP_VERB_OBJECT_TO_CURVE, error);
+ return dbus_call_verb (doc_interface, SP_VERB_OBJECT_TO_CURVE, error);
}
-gchar *
-document_interface_selection_combine (DocumentInterface *object, gchar *cmd,
+gboolean
+document_interface_selection_combine (DocumentInterface *doc_interface, gchar *cmd, char ***newpaths,
GError **error)
{
if (strcmp(cmd, "union") == 0)
- dbus_call_verb (object, SP_VERB_SELECTION_UNION, error);
+ dbus_call_verb (doc_interface, SP_VERB_SELECTION_UNION, error);
else if (strcmp(cmd, "intersection") == 0)
- dbus_call_verb (object, SP_VERB_SELECTION_INTERSECT, error);
+ dbus_call_verb (doc_interface, SP_VERB_SELECTION_INTERSECT, error);
else if (strcmp(cmd, "difference") == 0)
- dbus_call_verb (object, SP_VERB_SELECTION_DIFF, error);
+ dbus_call_verb (doc_interface, SP_VERB_SELECTION_DIFF, error);
else if (strcmp(cmd, "exclusion") == 0)
- dbus_call_verb (object, SP_VERB_SELECTION_SYMDIFF, error);
- else
- return NULL;
-
- if (sp_desktop_selection(object->desk)->singleRepr() != NULL)
- return g_strdup((sp_desktop_selection(object->desk)->singleRepr())->attribute("id"));
- return NULL;
-}
-
-gboolean
-document_interface_selection_divide (DocumentInterface *object, char ***out, GError **error)
-{
- dbus_call_verb (object, SP_VERB_SELECTION_CUT, error);
+ dbus_call_verb (doc_interface, SP_VERB_SELECTION_SYMDIFF, error);
+ else if (strcmp(cmd, "division") == 0)
+ dbus_call_verb (doc_interface, SP_VERB_SELECTION_CUT, error);
+ else {
+ g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Operation command not recognised");
+ return FALSE;
+ }
- return document_interface_selection_get (object, out, error);
+ return document_interface_selection_get (doc_interface, newpaths, error);
}
gboolean
-document_interface_selection_change_level (DocumentInterface *object, gchar *cmd,
+document_interface_selection_change_level (DocumentInterface *doc_interface, gchar *cmd,
GError **error)
{
if (strcmp(cmd, "raise") == 0)
- return dbus_call_verb (object, SP_VERB_SELECTION_RAISE, error);
+ return dbus_call_verb (doc_interface, SP_VERB_SELECTION_RAISE, error);
if (strcmp(cmd, "lower") == 0)
- return dbus_call_verb (object, SP_VERB_SELECTION_LOWER, error);
+ return dbus_call_verb (doc_interface, 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);
+ return dbus_call_verb (doc_interface, 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 dbus_call_verb (doc_interface, SP_VERB_SELECTION_TO_BACK, error);
return TRUE;
}
@@ -1353,58 +1353,58 @@ document_interface_selection_change_level (DocumentInterface *object, gchar *cmd
LAYER FUNCTIONS
****************************************************************************/
-gchar *document_interface_layer_new(DocumentInterface *object, GError ** /*error*/)
+gchar *document_interface_layer_new(DocumentInterface *doc_interface, GError ** /*error*/)
{
- SPDesktop * dt = object->desk;
- SPObject *new_layer = Inkscape::create_layer(dt->currentRoot(), dt->currentLayer(), Inkscape::LPOS_BELOW);
- dt->setCurrentLayer(new_layer);
+ Inkscape::LayerModel * layers = doc_interface->target.getSelection()->layers();
+ SPObject *new_layer = Inkscape::create_layer(layers->currentRoot(), layers->currentLayer(), Inkscape::LPOS_BELOW);
+ layers->setCurrentLayer(new_layer);
return g_strdup(get_name_from_object(new_layer));
}
gboolean
-document_interface_layer_set (DocumentInterface *object,
+document_interface_layer_set (DocumentInterface *doc_interface,
gchar *layerstr, GError **error)
{
- SPObject * obj = get_object_by_name (object->desk, layerstr, error);
+ SPObject * obj = get_object_by_name (doc_interface->target.getDocument(), layerstr, error);
if (!obj)
return FALSE;
- object->desk->setCurrentLayer (obj);
+ doc_interface->target.getSelection()->layers()->setCurrentLayer (obj);
return TRUE;
}
-gchar **document_interface_layer_get_all(DocumentInterface * /*object*/)
+gchar **document_interface_layer_get_all(DocumentInterface * /*doc_interface*/)
{
//FIXME: implement.
return NULL;
}
gboolean
-document_interface_layer_change_level (DocumentInterface *object,
+document_interface_layer_change_level (DocumentInterface *doc_interface,
gchar *cmd, GError **error)
{
if (strcmp(cmd, "raise") == 0)
- return dbus_call_verb (object, SP_VERB_LAYER_RAISE, error);
+ return dbus_call_verb (doc_interface, SP_VERB_LAYER_RAISE, error);
if (strcmp(cmd, "lower") == 0)
- return dbus_call_verb (object, SP_VERB_LAYER_LOWER, error);
+ return dbus_call_verb (doc_interface, 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);
+ return dbus_call_verb (doc_interface, 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 dbus_call_verb (doc_interface, SP_VERB_LAYER_TO_BOTTOM, error);
return TRUE;
}
gboolean
-document_interface_layer_next (DocumentInterface *object, GError **error)
+document_interface_layer_next (DocumentInterface *doc_interface, GError **error)
{
- return dbus_call_verb (object, SP_VERB_LAYER_NEXT, error);
+ return dbus_call_verb (doc_interface, SP_VERB_LAYER_NEXT, error);
}
gboolean
-document_interface_layer_previous (DocumentInterface *object, GError **error)
+document_interface_layer_previous (DocumentInterface *doc_interface, GError **error)
{
- return dbus_call_verb (object, SP_VERB_LAYER_PREV, error);
+ return dbus_call_verb (doc_interface, SP_VERB_LAYER_PREV, error);
}
@@ -1414,7 +1414,6 @@ document_interface_layer_previous (DocumentInterface *object, GError **error)
DocumentInterface *fugly;
gboolean dbus_send_ping (SPDesktop* desk, SPItem *item)
{
- //DocumentInterface *obj;
if (!item) return TRUE;
g_signal_emit (desk->dbus_document_interface, signals[OBJECT_MOVED_SIGNAL], 0, item->getId());
return TRUE;
@@ -1424,9 +1423,9 @@ gboolean dbus_send_ping (SPDesktop* desk, SPItem *item)
gboolean
-document_interface_get_children (DocumentInterface *object, char *name, char ***out, GError **error)
+document_interface_get_children (DocumentInterface *doc_interface, char *name, char ***out, GError **error)
{
- SPItem* parent=(SPItem* )get_object_by_name(object->desk, name, error);
+ SPItem* parent=(SPItem* )get_object_by_name(doc_interface->target.getDocument(), name, error);
GSList const *children = parent->childList(false);
@@ -1447,9 +1446,9 @@ document_interface_get_children (DocumentInterface *object, char *name, char **
gchar*
-document_interface_get_parent (DocumentInterface *object, char *name, GError **error)
+document_interface_get_parent (DocumentInterface *doc_interface, char *name, GError **error)
{
- SPItem* node=(SPItem* )get_object_by_name(object->desk, name, error);
+ SPItem* node=(SPItem* )get_object_by_name(doc_interface->target.getDocument(), name, error);
SPObject* parent=node->parent;
@@ -1460,8 +1459,8 @@ document_interface_get_parent (DocumentInterface *object, char *name, GError **
#if 0
//just pseudo code
gboolean
-document_interface_get_xpath (DocumentInterface *object, char *xpath_expression, char ***out, GError **error){
- SPDocument * doc = sp_desktop_document (object->desk);
+document_interface_get_xpath (DocumentInterface *doc_interface, char *xpath_expression, char ***out, GError **error){
+ SPDocument * doc = doc_interface->target.getDocument();
Inkscape::XML::Document *repr = doc->getReprDoc();
xmlXPathObjectPtr xpathObj;
diff --git a/src/extension/dbus/document-interface.h b/src/extension/dbus/document-interface.h
index 5fcbb919b..27460de52 100644
--- a/src/extension/dbus/document-interface.h
+++ b/src/extension/dbus/document-interface.h
@@ -30,9 +30,10 @@
#undef DBUS_MESSAGE_TYPE_ERROR
#undef DBUS_MESSAGE_TYPE_SIGNAL
-#include "desktop.h"
+#include "helper/action-context.h"
-#define DBUS_DOCUMENT_INTERFACE_PATH "/org/inkscape/document"
+class SPDesktop;
+class SPItem;
#define TYPE_DOCUMENT_INTERFACE (document_interface_get_type ())
#define DOCUMENT_INTERFACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_DOCUMENT_INTERFACE, DocumentInterface))
@@ -47,8 +48,8 @@ typedef struct _DocumentInterface DocumentInterface;
typedef struct _DocumentInterfaceClass DocumentInterfaceClass;
struct _DocumentInterface {
- GObject parent;
- SPDesktop *desk;
+ GObject parent;
+ Inkscape::ActionContext target; ///< stores information about which document, selection, desktop etc this interface is linked to
gboolean updates;
};
@@ -67,10 +68,10 @@ struct DBUSPoint {
****************************************************************************/
gboolean
-document_interface_delete_all (DocumentInterface *object, GError **error);
+document_interface_delete_all (DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_call_verb (DocumentInterface *object,
+document_interface_call_verb (DocumentInterface *doc_interface,
gchar *verbid, GError **error);
/****************************************************************************
@@ -78,48 +79,48 @@ document_interface_call_verb (DocumentInterface *object,
****************************************************************************/
gchar*
-document_interface_rectangle (DocumentInterface *object, int x, int y,
+document_interface_rectangle (DocumentInterface *doc_interface, int x, int y,
int width, int height, GError **error);
gchar*
-document_interface_ellipse (DocumentInterface *object, int x, int y,
+document_interface_ellipse (DocumentInterface *doc_interface, int x, int y,
int width, int height, GError **error);
gchar*
-document_interface_polygon (DocumentInterface *object, int cx, int cy,
+document_interface_polygon (DocumentInterface *doc_interface, int cx, int cy,
int radius, int rotation, int sides,
GError **error);
gchar*
-document_interface_star (DocumentInterface *object, int cx, int cy,
+document_interface_star (DocumentInterface *doc_interface, int cx, int cy,
int r1, int r2, int sides, gdouble rounded,
gdouble arg1, gdouble arg2, GError **error);
gchar*
-document_interface_spiral (DocumentInterface *object, int cx, int cy,
+document_interface_spiral (DocumentInterface *doc_interface, int cx, int cy,
int r, int revolutions, GError **error);
gchar*
-document_interface_line (DocumentInterface *object, int x, int y,
+document_interface_line (DocumentInterface *doc_interface, int x, int y,
int x2, int y2, GError **error);
gchar*
-document_interface_text (DocumentInterface *object, int x, int y,
+document_interface_text (DocumentInterface *doc_interface, int x, int y,
gchar *text, GError **error);
gboolean
-document_interface_set_text (DocumentInterface *object, gchar *name,
+document_interface_set_text (DocumentInterface *doc_interface, gchar *name,
gchar *text, GError **error);
gboolean
-document_interface_text_apply_style (DocumentInterface *object, gchar *name,
+document_interface_text_apply_style (DocumentInterface *doc_interface, gchar *name,
int start_pos, int end_pos, gchar *style, gchar *styleval,
GError **error);
gchar *
-document_interface_image (DocumentInterface *object, int x, int y,
+document_interface_image (DocumentInterface *doc_interface, int x, int y,
gchar *filename, GError **error);
gchar*
-document_interface_node (DocumentInterface *object, gchar *svgtype,
+document_interface_node (DocumentInterface *doc_interface, gchar *svgtype,
GError **error);
@@ -127,27 +128,27 @@ document_interface_node (DocumentInterface *object, gchar *svgtype,
ENVIORNMENT FUNCTIONS
****************************************************************************/
gdouble
-document_interface_document_get_width (DocumentInterface *object);
+document_interface_document_get_width (DocumentInterface *doc_interface);
gdouble
-document_interface_document_get_height (DocumentInterface *object);
+document_interface_document_get_height (DocumentInterface *doc_interface);
gchar *
-document_interface_document_get_css (DocumentInterface *object, GError **error);
+document_interface_document_get_css (DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_document_merge_css (DocumentInterface *object,
+document_interface_document_merge_css (DocumentInterface *doc_interface,
gchar *stylestring, GError **error);
gboolean
-document_interface_document_set_css (DocumentInterface *object,
+document_interface_document_set_css (DocumentInterface *doc_interface,
gchar *stylestring, GError **error);
gboolean
-document_interface_document_resize_to_fit_selection (DocumentInterface *object,
+document_interface_document_resize_to_fit_selection (DocumentInterface *doc_interface,
GError **error);
gboolean
-document_interface_document_set_display_area (DocumentInterface *object,
+document_interface_document_set_display_area (DocumentInterface *doc_interface,
double x0,
double y0,
double x1,
@@ -155,95 +156,95 @@ document_interface_document_set_display_area (DocumentInterface *object,
double border,
GError **error);
GArray *
-document_interface_document_get_display_area (DocumentInterface *object);
+document_interface_document_get_display_area (DocumentInterface *doc_interface);
/****************************************************************************
OBJECT FUNCTIONS
****************************************************************************/
gboolean
-document_interface_set_attribute (DocumentInterface *object,
+document_interface_set_attribute (DocumentInterface *doc_interface,
char *shape, char *attribute,
char *newval, GError **error);
gboolean
-document_interface_set_int_attribute (DocumentInterface *object,
+document_interface_set_int_attribute (DocumentInterface *doc_interface,
char *shape, char *attribute,
int newval, GError **error);
gboolean
-document_interface_set_double_attribute (DocumentInterface *object,
+document_interface_set_double_attribute (DocumentInterface *doc_interface,
char *shape, char *attribute,
double newval, GError **error);
gchar *
-document_interface_get_attribute (DocumentInterface *object,
+document_interface_get_attribute (DocumentInterface *doc_interface,
char *shape, char *attribute, GError **error);
gboolean
-document_interface_move (DocumentInterface *object, gchar *name,
+document_interface_move (DocumentInterface *doc_interface, gchar *name,
gdouble x, gdouble y, GError **error);
gboolean
-document_interface_move_to (DocumentInterface *object, gchar *name,
+document_interface_move_to (DocumentInterface *doc_interface, gchar *name,
gdouble x, gdouble y, GError **error);
gboolean
-document_interface_object_to_path (DocumentInterface *object,
+document_interface_object_to_path (DocumentInterface *doc_interface,
char *shape, GError **error);
gchar *
-document_interface_get_path (DocumentInterface *object,
+document_interface_get_path (DocumentInterface *doc_interface,
char *pathname, GError **error);
gboolean
-document_interface_transform (DocumentInterface *object, gchar *shape,
+document_interface_transform (DocumentInterface *doc_interface, gchar *shape,
gchar *transformstr, GError **error);
gchar *
-document_interface_get_css (DocumentInterface *object, gchar *shape,
+document_interface_get_css (DocumentInterface *doc_interface, gchar *shape,
GError **error);
gboolean
-document_interface_modify_css (DocumentInterface *object, gchar *shape,
+document_interface_modify_css (DocumentInterface *doc_interface, gchar *shape,
gchar *cssattrb, gchar *newval, GError **error);
gboolean
-document_interface_merge_css (DocumentInterface *object, gchar *shape,
+document_interface_merge_css (DocumentInterface *doc_interface, gchar *shape,
gchar *stylestring, GError **error);
gboolean
-document_interface_set_color (DocumentInterface *object, gchar *shape,
+document_interface_set_color (DocumentInterface *doc_interface, gchar *shape,
int r, int g, int b, gboolean fill, GError **error);
gboolean
-document_interface_move_to_layer (DocumentInterface *object, gchar *shape,
+document_interface_move_to_layer (DocumentInterface *doc_interface, gchar *shape,
gchar *layerstr, GError **error);
GArray *
-document_interface_get_node_coordinates (DocumentInterface *object, gchar *shape);
+document_interface_get_node_coordinates (DocumentInterface *doc_interface, gchar *shape);
/****************************************************************************
FILE I/O FUNCTIONS
****************************************************************************/
gboolean
-document_interface_save (DocumentInterface *object, GError **error);
+document_interface_save (DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_load (DocumentInterface *object,
+document_interface_load (DocumentInterface *doc_interface,
gchar *filename, GError **error);
gboolean
-document_interface_save_as (DocumentInterface *object,
+document_interface_save_as (DocumentInterface *doc_interface,
const gchar *filename, GError **error);
gboolean
-document_interface_mark_as_unmodified (DocumentInterface *object, GError **error);
+document_interface_mark_as_unmodified (DocumentInterface *doc_interface, GError **error);
/*
gboolean
-document_interface_print_to_file (DocumentInterface *object, GError **error);
+document_interface_print_to_file (DocumentInterface *doc_interface, GError **error);
*/
/****************************************************************************
@@ -251,125 +252,120 @@ document_interface_print_to_file (DocumentInterface *object, GError **error);
****************************************************************************/
gboolean
-document_interface_close (DocumentInterface *object, GError **error);
+document_interface_close (DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_exit (DocumentInterface *object, GError **error);
+document_interface_exit (DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_undo (DocumentInterface *object, GError **error);
+document_interface_undo (DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_redo (DocumentInterface *object, GError **error);
+document_interface_redo (DocumentInterface *doc_interface, GError **error);
/****************************************************************************
UPDATE FUNCTIONS
****************************************************************************/
void
-document_interface_pause_updates (DocumentInterface *object, GError **error);
+document_interface_pause_updates (DocumentInterface *doc_interface, GError **error);
void
-document_interface_resume_updates (DocumentInterface *object, GError **error);
+document_interface_resume_updates (DocumentInterface *doc_interface, GError **error);
void
-document_interface_update (DocumentInterface *object, GError **error);
+document_interface_update (DocumentInterface *doc_interface, GError **error);
/****************************************************************************
SELECTION FUNCTIONS
****************************************************************************/
gboolean
-document_interface_selection_get (DocumentInterface *object, char ***out, GError **error);
+document_interface_selection_get (DocumentInterface *doc_interface, char ***out, GError **error);
gboolean
-document_interface_selection_add (DocumentInterface *object,
+document_interface_selection_add (DocumentInterface *doc_interface,
char *name, GError **error);
gboolean
-document_interface_selection_add_list (DocumentInterface *object,
+document_interface_selection_add_list (DocumentInterface *doc_interface,
char **names, GError **error);
gboolean
-document_interface_selection_set (DocumentInterface *object,
+document_interface_selection_set (DocumentInterface *doc_interface,
char *name, GError **error);
gboolean
-document_interface_selection_set_list (DocumentInterface *object,
+document_interface_selection_set_list (DocumentInterface *doc_interface,
gchar **names, GError **error);
gboolean
-document_interface_selection_rotate (DocumentInterface *object,
+document_interface_selection_rotate (DocumentInterface *doc_interface,
int angle, GError **error);
gboolean
-document_interface_selection_delete(DocumentInterface *object, GError **error);
+document_interface_selection_delete(DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_selection_clear(DocumentInterface *object, GError **error);
+document_interface_selection_clear(DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_select_all(DocumentInterface *object, GError **error);
+document_interface_select_all(DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_select_all_in_all_layers(DocumentInterface *object,
+document_interface_select_all_in_all_layers(DocumentInterface *doc_interface,
GError **error);
gboolean
-document_interface_selection_box (DocumentInterface *object, int x, int y,
+document_interface_selection_box (DocumentInterface *doc_interface, int x, int y,
int x2, int y2, gboolean replace,
GError **error);
gboolean
-document_interface_selection_invert (DocumentInterface *object, GError **error);
+document_interface_selection_invert (DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_selection_group(DocumentInterface *object, GError **error);
+document_interface_selection_group(DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_selection_ungroup(DocumentInterface *object, GError **error);
+document_interface_selection_ungroup(DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_selection_cut(DocumentInterface *object, GError **error);
+document_interface_selection_cut(DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_selection_copy(DocumentInterface *object, GError **error);
+document_interface_selection_copy(DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_selection_paste(DocumentInterface *object, GError **error);
+document_interface_selection_paste(DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_selection_scale (DocumentInterface *object,
+document_interface_selection_scale (DocumentInterface *doc_interface,
gdouble grow, GError **error);
gboolean
-document_interface_selection_move (DocumentInterface *object, gdouble x,
+document_interface_selection_move (DocumentInterface *doc_interface, gdouble x,
gdouble y, GError **error);
gboolean
-document_interface_selection_move_to (DocumentInterface *object, gdouble x,
+document_interface_selection_move_to (DocumentInterface *doc_interface, gdouble x,
gdouble y, GError **error);
gboolean
-document_interface_selection_move_to_layer (DocumentInterface *object,
+document_interface_selection_move_to_layer (DocumentInterface *doc_interface,
gchar *layerstr, GError **error);
GArray *
-document_interface_selection_get_center (DocumentInterface *object);
+document_interface_selection_get_center (DocumentInterface *doc_interface);
gboolean
-document_interface_selection_to_path (DocumentInterface *object, GError **error);
-
-gchar *
-document_interface_selection_combine (DocumentInterface *object, gchar *cmd,
- GError **error);
+document_interface_selection_to_path (DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_selection_divide (DocumentInterface *object,
- char ***out, GError **error);
-
+document_interface_selection_combine (DocumentInterface *doc_interface, gchar *cmd, char ***newpaths,
+ GError **error);
gboolean
-document_interface_selection_change_level (DocumentInterface *object, gchar *cmd,
+document_interface_selection_change_level (DocumentInterface *doc_interface, gchar *cmd,
GError **error);
/****************************************************************************
@@ -377,24 +373,24 @@ document_interface_selection_change_level (DocumentInterface *object, gchar *cmd
****************************************************************************/
gchar *
-document_interface_layer_new (DocumentInterface *object, GError **error);
+document_interface_layer_new (DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_layer_set (DocumentInterface *object,
+document_interface_layer_set (DocumentInterface *doc_interface,
gchar *layerstr, GError **error);
gchar **
-document_interface_layer_get_all (DocumentInterface *object);
+document_interface_layer_get_all (DocumentInterface *doc_interface);
gboolean
-document_interface_layer_change_level (DocumentInterface *object,
+document_interface_layer_change_level (DocumentInterface *doc_interface,
gchar *cmd, GError **error);
gboolean
-document_interface_layer_next (DocumentInterface *object, GError **error);
+document_interface_layer_next (DocumentInterface *doc_interface, GError **error);
gboolean
-document_interface_layer_previous (DocumentInterface *object, GError **error);
+document_interface_layer_previous (DocumentInterface *doc_interface, GError **error);
@@ -410,13 +406,13 @@ extern DocumentInterface *fugly;
gboolean dbus_send_ping (SPDesktop* desk, SPItem *item);
gboolean
-document_interface_get_children (DocumentInterface *object, char *name, char ***out, GError **error);
+document_interface_get_children (DocumentInterface *doc_interface, char *name, char ***out, GError **error);
gchar*
-document_interface_get_parent (DocumentInterface *object, char *name, GError **error);
+document_interface_get_parent (DocumentInterface *doc_interface, char *name, GError **error);
gchar*
-document_interface_import (DocumentInterface *object,
+document_interface_import (DocumentInterface *doc_interface,
gchar *filename, GError **error);
G_END_DECLS
diff --git a/src/extension/dbus/document-interface.xml b/src/extension/dbus/document-interface.xml
index aeacfae44..7481c0893 100644
--- a/src/extension/dbus/document-interface.xml
+++ b/src/extension/dbus/document-interface.xml
@@ -21,7 +21,7 @@
<node name="/org/inkscape/document"
xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"
>
-
+c
<interface name="org.inkscape.document">
<!-- MISC FUNCTIONS -->
@@ -1348,36 +1348,20 @@
<doc:summary>Type of combination.</doc:summary>
</doc:doc>
</arg>
- <arg type="s" name="newpath" direction="out" >
- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/>
+ <arg type="as" name="newpaths" direction="out" >
<doc:doc>
- <doc:summary>The new path created, if there is one. NULL otherwise.</doc:summary>
+ <doc:summary>List of the ids of resulting paths after applying the operation.</doc:summary>
</doc:doc>
</arg>
<doc:doc>
<doc:description>
<doc:para>Will erase all objects in the selection and replace with a single aggregate path.</doc:para>
<doc:para>There are 5 types that can be passed in:</doc:para>
- <doc:para>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.)</doc:para>
- <doc:para>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.</doc:para>
- <doc:para>Difference: The area of the second shape is subtracted from the first, only works with two objects.</doc:para>
- <doc:para>Exclusion: The new shape is the area(s) where none of the objects in the selection overlaped. Only works with two objects.</doc:para>
- <doc:para>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.</doc:para>
- </doc:description>
- </doc:doc>
- </method>
-
- <method name="selection_divide">
- <arg type="as" name="pieces" direction="out" >
- <!-- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> -->
- <doc:doc>
- <doc:summary>List of the ids of resulting paths.</doc:summary>
- </doc:doc>
- </arg>
- <doc:doc>
- <doc:description>
- <doc:para>Returns the result of cutting the bottom object by all other intersecting paths.</doc:para>
- <doc:para>This may make many seperate layers.</doc:para>
+ <doc:para>'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.)</doc:para>
+ <doc:para>'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.</doc:para>
+ <doc:para>'difference': The area of the second shape is subtracted from the first, only works with two objects.</doc:para>
+ <doc:para>'exclusion': The new shape is the area(s) where none of the objects in the selection overlaped. Only works with two objects.</doc:para>
+ <doc:para>'division': the first object is split into multiple segments by the second object. Only works with two objects.</doc:para>
</doc:description>
</doc:doc>
</method>
diff --git a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c
index 0be1be42e..c7e453593 100644
--- a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c
+++ b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c
@@ -688,23 +688,13 @@ inkscape_selection_to_path (DocumentInterface *doc, GError **error)
}
//static
-char *
-inkscape_selection_combine (DocumentInterface *doc, const char * IN_type, GError **error)
-{
- char * OUT_newpath;
- DBusGProxy *proxy = doc->proxy;
- org_inkscape_document_selection_combine (proxy, IN_type, &OUT_newpath, error);
- return OUT_newpath;
-}
-
-//static
char **
-inkscape_selection_divide (DocumentInterface *doc, GError **error)
+inkscape_selection_combine (DocumentInterface *doc, const char * IN_type, GError **error)
{
- char ** OUT_pieces;
+ char ** OUT_newpaths;
DBusGProxy *proxy = doc->proxy;
- org_inkscape_document_selection_divide (proxy, &OUT_pieces, error);
- return OUT_pieces;
+ org_inkscape_document_selection_combine (proxy, IN_type, &OUT_newpaths, error);
+ return OUT_newpaths;
}
//static
diff --git a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h
index 684f1b142..20830bd65 100644
--- a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h
+++ b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h
@@ -8,8 +8,6 @@
//#include <dbus/dbus-glib-bindings.h>
//#include <dbus/dbus-glib-lowlevel.h>
-
-#define DBUS_DOCUMENT_INTERFACE_PATH "/org/inkscape/document"
#define TYPE_DOCUMENT_INTERFACE (document_interface_get_type ())
#define DOCUMENT_INTERFACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_DOCUMENT_INTERFACE, DocumentInterface))
@@ -304,12 +302,8 @@ gboolean
inkscape_selection_to_path (DocumentInterface *doc, GError **error);
//static
-char *
-inkscape_selection_combine (DocumentInterface *doc, const char * IN_type, GError **error);
-
-//static
char **
-inkscape_selection_divide (DocumentInterface *doc, GError **error);
+inkscape_selection_combine (DocumentInterface *doc, const char * IN_type, GError **error);
//static
gboolean
diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp
index 1df8002ad..dcccf3d7d 100644
--- a/src/extension/effect.cpp
+++ b/src/extension/effect.cpp
@@ -359,22 +359,22 @@ Effect::set_pref_dialog (PrefDialog * prefdialog)
}
SPAction *
-Effect::EffectVerb::make_action (Inkscape::UI::View::View * view)
+Effect::EffectVerb::make_action (Inkscape::ActionContext const & context)
{
- return make_action_helper(view, &perform, static_cast<void *>(this));
+ return make_action_helper(context, &perform, static_cast<void *>(this));
}
/** \brief Decode the verb code and take appropriate action */
void
Effect::EffectVerb::perform( SPAction *action, void * data )
{
+ g_return_if_fail(ensure_desktop_valid(action));
Inkscape::UI::View::View * current_view = sp_action_get_view(action);
-// SPDocument * current_document = current_view->doc;
+
Effect::EffectVerb * ev = reinterpret_cast<Effect::EffectVerb *>(data);
Effect * effect = ev->_effect;
if (effect == NULL) return;
- if (current_view == NULL) return;
if (ev->_showPrefs) {
effect->prefs(current_view);
diff --git a/src/extension/effect.h b/src/extension/effect.h
index 193b90a97..a14cc6e7d 100644
--- a/src/extension/effect.h
+++ b/src/extension/effect.h
@@ -58,7 +58,7 @@ class Effect : public Extension {
/** \brief Name with elipses if that makes sense */
gchar * _elip_name;
protected:
- virtual SPAction * make_action (Inkscape::UI::View::View * view);
+ virtual SPAction * make_action (Inkscape::ActionContext const & context);
public:
/** \brief Use the Verb initializer with the same parameters. */
EffectVerb(gchar const * id,
diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp
index 8f1e07211..a3d2fd6e5 100644
--- a/src/extension/internal/bluredge.cpp
+++ b/src/extension/internal/bluredge.cpp
@@ -17,6 +17,7 @@
#include "document.h"
#include "selection.h"
#include "helper/action.h"
+#include "helper/action-context.h"
#include "preferences.h"
#include "path-chemistry.h"
#include "sp-item.h"
@@ -99,10 +100,10 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
/* Doing an inset here folks */
offset *= -1.0;
prefs->setDoubleUnit("/options/defaultoffsetwidth/value", offset, "px");
- sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_INSET)->get_action(desktop), NULL);
+ sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_INSET)->get_action(Inkscape::ActionContext(desktop)), NULL);
} else if (offset > 0.0) {
prefs->setDoubleUnit("/options/defaultoffsetwidth/value", offset, "px");
- sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_OFFSET)->get_action(desktop), NULL);
+ sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_OFFSET)->get_action(Inkscape::ActionContext(desktop)), NULL);
}
selection->clear();
diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp
index 0273d1669..0273d1669 100755..100644
--- a/src/extension/internal/filter/filter-all.cpp
+++ b/src/extension/internal/filter/filter-all.cpp