summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorEric Greveson <eric@greveson.co.uk>2013-07-03 22:00:06 +0000
committerEric Greveson <eric@greveson.co.uk>2013-07-03 22:00:06 +0000
commit1c75594f5c37e86dec195ec1975254315ef180e9 (patch)
treea2ef00ceb7bd72b60c61c61ece4dcfe413fac9f5 /src/extension
parentModified dbus interface so that it works in console mode (--dbus-listen) (diff)
downloadinkscape-1c75594f5c37e86dec195ec1975254315ef180e9.tar.gz
inkscape-1c75594f5c37e86dec195ec1975254315ef180e9.zip
Changed dbus interface to treat 'division' like other boolops, with a new
return type for selection_combine to support this (array of string). This also fixes a bug with not setting the error flag when returning NULL from this method. Refactored some more selection verbs to allow use in no-GUI mode. (bzr r12387.1.5)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/dbus/application-interface.cpp6
-rw-r--r--src/extension/dbus/document-interface.cpp26
-rw-r--r--src/extension/dbus/document-interface.h9
-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.h6
6 files changed, 29 insertions, 68 deletions
diff --git a/src/extension/dbus/application-interface.cpp b/src/extension/dbus/application-interface.cpp
index 399e1b244..1b1dbf0f5 100644
--- a/src/extension/dbus/application-interface.cpp
+++ b/src/extension/dbus/application-interface.cpp
@@ -150,7 +150,11 @@ gchar*
application_interface_get_active_document(ApplicationInterface *object,
GError **error)
{
- return (gchar*)Inkscape::Extension::Dbus::init_active_document();
+ 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**
diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp
index f0cc71de1..87b769e26 100644
--- a/src/extension/dbus/document-interface.cpp
+++ b/src/extension/dbus/document-interface.cpp
@@ -1222,13 +1222,11 @@ document_interface_selection_invert (DocumentInterface *object, GError **error)
gboolean
document_interface_selection_group (DocumentInterface *object, GError **error)
{
- //sp_selection_group (object->desk);
return dbus_call_verb (object, SP_VERB_SELECTION_GROUP, error);
}
gboolean
document_interface_selection_ungroup (DocumentInterface *object, GError **error)
{
- //sp_selection_ungroup (object->desk);
return dbus_call_verb (object, SP_VERB_SELECTION_UNGROUP, error);
}
@@ -1362,8 +1360,8 @@ document_interface_selection_to_path (DocumentInterface *object, GError **error)
}
-gchar *
-document_interface_selection_combine (DocumentInterface *object, gchar *cmd,
+gboolean
+document_interface_selection_combine (DocumentInterface *object, gchar *cmd, char ***newpaths,
GError **error)
{
if (strcmp(cmd, "union") == 0)
@@ -1374,20 +1372,14 @@ document_interface_selection_combine (DocumentInterface *object, gchar *cmd,
dbus_call_verb (object, SP_VERB_SELECTION_DIFF, error);
else if (strcmp(cmd, "exclusion") == 0)
dbus_call_verb (object, SP_VERB_SELECTION_SYMDIFF, error);
- else
- return NULL;
-
- if (object->context.getSelection()->singleRepr() != NULL)
- return g_strdup(object->context.getSelection()->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);
+ else if (strcmp(cmd, "division") == 0)
+ dbus_call_verb (object, 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 (object, newpaths, error);
}
gboolean
diff --git a/src/extension/dbus/document-interface.h b/src/extension/dbus/document-interface.h
index 9b8d34dd3..5eef3d0c0 100644
--- a/src/extension/dbus/document-interface.h
+++ b/src/extension/dbus/document-interface.h
@@ -363,14 +363,9 @@ document_interface_selection_get_center (DocumentInterface *object);
gboolean
document_interface_selection_to_path (DocumentInterface *object, GError **error);
-gchar *
-document_interface_selection_combine (DocumentInterface *object, gchar *cmd,
- GError **error);
-
gboolean
-document_interface_selection_divide (DocumentInterface *object,
- char ***out, GError **error);
-
+document_interface_selection_combine (DocumentInterface *object, gchar *cmd, char ***newpaths,
+ GError **error);
gboolean
document_interface_selection_change_level (DocumentInterface *object, gchar *cmd,
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..79f8188d4 100644
--- a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h
+++ b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h
@@ -304,12 +304,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