From: glimmer07 Date: Mon, 20 Jul 2009 22:55:35 +0000 (+0000) Subject: Fixed selection_get_center and selection_combine. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=08222373c158bd9932ececfa0131dfe8b1a5b746;p=inkscape.git Fixed selection_get_center and selection_combine. Added selection_divide. --- diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index b9d8848cc..a939064e1 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -745,7 +745,6 @@ document_interface_selection_add_list (DocumentInterface *object, { int i; for (i=0;names[i] != NULL;i++) { - //printf("NAME: %s\n", names[i]); document_interface_selection_add(object, names[i], error); } return TRUE; @@ -767,7 +766,6 @@ document_interface_selection_set_list (DocumentInterface *object, sp_desktop_selection(object->desk)->clear(); int i; for (i=0;names[i] != NULL;i++) { - //printf("NAME: %s\n", names[i]); document_interface_selection_add(object, names[i], error); } return TRUE; @@ -882,7 +880,6 @@ document_interface_selection_move_to (DocumentInterface *object, gdouble x, gdou Geom::OptRect sel_bbox = sel->bounds(); if (sel_bbox) { - //Geom::Point m( (object->desk)->point() - sel_bbox->midpoint() ); Geom::Point m( x - selection_get_center_x(sel) , 0 - (y - selection_get_center_y(sel)) ); sp_selection_move_relative(sel, m, true); } @@ -915,11 +912,23 @@ document_interface_selection_move_to_layer (DocumentInterface *object, return TRUE; } -gboolean +GArray * document_interface_selection_get_center (DocumentInterface *object) { - //FIXME: implement: pass struct. - return FALSE; + Inkscape::Selection * sel = sp_desktop_selection(object->desk); + + if (sel) + { + gdouble x = selection_get_center_x(sel); + gdouble y = selection_get_center_y(sel); + GArray * intArr = g_array_new (TRUE, TRUE, sizeof(double)); + + g_array_append_val (intArr, x); + g_array_append_val (intArr, y); + return intArr; + } + + return NULL; } gboolean @@ -933,7 +942,6 @@ gchar * document_interface_selection_combine (DocumentInterface *object, gchar *cmd, GError **error) { - if (strcmp(cmd, "union") == 0) dbus_call_verb (object, SP_VERB_SELECTION_UNION, error); else if (strcmp(cmd, "intersection") == 0) @@ -947,8 +955,19 @@ document_interface_selection_combine (DocumentInterface *object, gchar *cmd, else return NULL; - //FIXME: this WILL cause problems with division - return g_strdup((sp_desktop_selection(object->desk)->singleRepr())->attribute("id")); + if (sp_desktop_selection(object->desk)->singleRepr() != NULL) + return g_strdup((sp_desktop_selection(object->desk)->singleRepr())->attribute("id")); + + //Division will have a list of things selected, should have it's own function. + return NULL; +} + +gboolean +document_interface_selection_divide (DocumentInterface *object, char ***out, GError **error) +{ + dbus_call_verb (object, SP_VERB_SELECTION_CUT, error); + + return document_interface_selection_get (object, out, error); } gboolean diff --git a/src/extension/dbus/document-interface.h b/src/extension/dbus/document-interface.h index 53fcacaaa..afad56f59 100644 --- a/src/extension/dbus/document-interface.h +++ b/src/extension/dbus/document-interface.h @@ -298,7 +298,7 @@ gboolean document_interface_selection_move_to_layer (DocumentInterface *object, gchar *layerstr, GError **error); -gboolean +GArray * document_interface_selection_get_center (DocumentInterface *object); gboolean @@ -308,6 +308,10 @@ gchar * document_interface_selection_combine (DocumentInterface *object, gchar *cmd, GError **error); +gboolean +document_interface_selection_divide (DocumentInterface *object, + char ***out, 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 5db3de763..171508dcd 100644 --- a/src/extension/dbus/document-interface.xml +++ b/src/extension/dbus/document-interface.xml @@ -1084,7 +1084,7 @@ - + Center of the selection. @@ -1132,6 +1132,21 @@ + + + + + List of the ids of resulting paths. + + + + + Returns the result of cutting the bottom object by all other intersecting paths. + This may make many seperate layers. + + + +