diff options
| author | Nicolas Dufour <nicoduf@yahoo.fr> | 2011-03-18 20:29:06 +0000 |
|---|---|---|
| committer | JazzyNico <nicoduf@yahoo.fr> | 2011-03-18 20:29:06 +0000 |
| commit | 2de761f0c46b4f3164d0dc008320da3ad0f35316 (patch) | |
| tree | fbf8c57ade340c7e2b639adc2269e5063d90c6e4 /src | |
| parent | Layers. Fix for Bug #249035: Undo crash when executing extensions. (diff) | |
| download | inkscape-2de761f0c46b4f3164d0dc008320da3ad0f35316.tar.gz inkscape-2de761f0c46b4f3164d0dc008320da3ad0f35316.zip | |
D-Bus. Merging branch lp:~joakim-verona/inkscape/dbus-fixes (Bug #666986, Bug #707054 and Bug #707364).
(bzr r10114)
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/canvas-text.h | 1 | ||||
| -rw-r--r-- | src/document.cpp | 6 | ||||
| -rw-r--r-- | src/extension/dbus/dbus-init.cpp | 3 | ||||
| -rw-r--r-- | src/extension/dbus/document-interface.cpp | 52 | ||||
| -rw-r--r-- | src/extension/dbus/document-interface.h | 7 | ||||
| -rw-r--r-- | src/extension/dbus/document-interface.xml | 29 | ||||
| -rw-r--r-- | src/extension/dbus/wrapper/inkscape-dbus-wrapper.c | 6 | ||||
| -rw-r--r-- | src/extension/dbus/wrapper/inkscape-dbus-wrapper.h | 2 |
8 files changed, 87 insertions, 19 deletions
diff --git a/src/display/canvas-text.h b/src/display/canvas-text.h index d8bd86b7d..9a6a93eb4 100644 --- a/src/display/canvas-text.h +++ b/src/display/canvas-text.h @@ -53,6 +53,7 @@ void sp_canvastext_set_anchor (SPCanvasText *ct, double anchor_x, double anchor_ #endif // SEEN_SP_CANVASTEXT_H + /* Local Variables: mode:c++ diff --git a/src/document.cpp b/src/document.cpp index 2a9ad9144..67ce3e26a 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -848,7 +848,11 @@ SPObject *SPDocument::getObjectById(gchar const *id) const g_return_val_if_fail(id != NULL, NULL); GQuark idq = g_quark_from_string(id); - return (SPObject*)g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)); + gpointer rv = g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)); + if(rv != NULL) + return (SPObject*)rv; + else + return NULL; } sigc::connection SPDocument::connectIdChanged(gchar const *id, diff --git a/src/extension/dbus/dbus-init.cpp b/src/extension/dbus/dbus-init.cpp index 9c562d169..3e453d048 100644 --- a/src/extension/dbus/dbus-init.cpp +++ b/src/extension/dbus/dbus-init.cpp @@ -86,7 +86,6 @@ init (void) GError *error = NULL; DBusGConnection *connection; DBusGProxy *proxy; - DocumentInterface *obj; connection = dbus_get_connection(); proxy = dbus_get_proxy(connection); org_freedesktop_DBus_request_name (proxy, @@ -102,8 +101,6 @@ init (void) gchar * init_document (void) { - guint result; - GError *error = NULL; DBusGConnection *connection; DBusGProxy *proxy; SPDocument *doc; diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 0e5d8de50..8e22849b5 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -36,6 +36,20 @@ #include "sp-ellipse.h" #include "sp-object.h" #include "style.h" //style_write + +#include "file.h" //IO + +#include "extension/system.h" //IO + +#include "extension/output.h" //IO + +#include "print.h" //IO + +#include "live_effects/parameter/text.h" //text +#include "display/canvas-text.h" //text + +#include "display/sp-canvas.h" //text +#include "text-editing.h" #include "verbs.h" #include "xml/repr.h" //sp_repr_document_new @@ -61,13 +75,13 @@ get_repr_by_name (SPDesktop *desk, 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); */ - Inkscape::XML::Node * node = sp_desktop_document(desk)->getObjectById(name)->getRepr(); - if (!node) + SPObject * obj = sp_desktop_document(desk)->getObjectById(name); + if (!obj) { g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OBJECT, "Object '%s' not found in document.", name); return NULL; } - return node; + return obj->getRepr(); } /* @@ -346,6 +360,7 @@ document_interface_call_verb (DocumentInterface *object, gchar *verbid, GError * if (object->updates) { Inkscape::DocumentUndo::done(sp_desktop_document(desk2), verb->get_code(), g_strdup(verb->get_tip())); } + return TRUE; } } } @@ -470,17 +485,20 @@ document_interface_spiral (DocumentInterface *object, int cx, int cy, return retval; } -gboolean +gchar* document_interface_text (DocumentInterface *object, int x, int y, gchar *text, GError **error) { - //FIXME: Not selectable (aka broken). Needs to be rewritten completely. - SPDesktop *desktop = object->desk; - SPCanvasText * canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, Geom::Point(0,0), ""); - sp_canvastext_set_text (canvas_text, text); - sp_canvastext_set_coords (canvas_text, x, y); + Inkscape::XML::Node *text_node = dbus_create_node(object->desk, "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"); + + SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error); + sp_te_set_repr_text_multiline(text_obj, text); - return TRUE; + return name; } gchar * @@ -809,6 +827,20 @@ document_interface_get_node_coordinates (DocumentInterface *object, gchar *shape } +gboolean +document_interface_set_text (DocumentInterface *object, gchar *name, gchar *text, GError **error) +{ + + SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error); + //TODO verify object type + if (!text_obj) + return FALSE; + sp_te_set_repr_text_multiline(text_obj, text); + return TRUE; + +} + + /**************************************************************************** FILE I/O FUNCTIONS ****************************************************************************/ diff --git a/src/extension/dbus/document-interface.h b/src/extension/dbus/document-interface.h index 12e033918..0283d987e 100644 --- a/src/extension/dbus/document-interface.h +++ b/src/extension/dbus/document-interface.h @@ -115,10 +115,13 @@ gchar* document_interface_line (DocumentInterface *object, int x, int y, int x2, int y2, GError **error); -gboolean +gchar* document_interface_text (DocumentInterface *object, int x, int y, gchar *text, GError **error); - +gboolean +document_interface_set_text (DocumentInterface *object, gchar *name, + gchar *text, GError **error); + gchar * document_interface_image (DocumentInterface *object, int x, int y, gchar *filename, GError **error); diff --git a/src/extension/dbus/document-interface.xml b/src/extension/dbus/document-interface.xml index 8b0252765..94f39ae7e 100644 --- a/src/extension/dbus/document-interface.xml +++ b/src/extension/dbus/document-interface.xml @@ -310,6 +310,12 @@ <doc:summary>The text you want.</doc:summary> </doc:doc> </arg> + <arg type="s" name="object_name" direction="out" > + <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/> + <doc:doc> + <doc:summary>The name of the new text.</doc:summary> + </doc:doc> + </arg> <doc:doc> <doc:description> <doc:para>This method creates some text in the current layer.</doc:para> @@ -472,6 +478,29 @@ </doc:doc> </method> + + <method name="set_text"> + <arg type="s" name="shape" direction="in" > + <doc:doc> + <doc:summary>The id of an object.</doc:summary> + </doc:doc> + </arg> + + <arg type="s" name="text" direction="in" > + <doc:doc> + <doc:summary>The text you want.</doc:summary> + </doc:doc> + </arg> + <doc:doc> + <doc:description> + <doc:para>set text of text object.</doc:para> + </doc:description> + </doc:doc> + </method> + + + + <method name="set_int_attribute"> <arg type="s" name="shape" direction="in" > <doc:doc> diff --git a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c index b59ee746b..7a33d4f38 100644 --- a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c +++ b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c @@ -198,11 +198,13 @@ inkscape_line (DocumentInterface *doc, const gint IN_x, const gint IN_y, const g } //static -gboolean +char * inkscape_text (DocumentInterface *doc, const gint IN_x, const gint IN_y, const char * IN_text, GError **error) { + char * OUT_object_name; DBusGProxy *proxy = doc->proxy; - return org_inkscape_document_text (proxy, IN_x, IN_y, IN_text, error); + org_inkscape_document_text (proxy, IN_x, IN_y, IN_text, &OUT_object_name, error); + return OUT_object_name; } //static diff --git a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h index c314bf6f8..684f1b142 100644 --- a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h +++ b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h @@ -72,7 +72,7 @@ char * inkscape_line (DocumentInterface *doc, const gint IN_x, const gint IN_y, const gint IN_x2, const gint IN_y2, GError **error); //static -gboolean +char * inkscape_text (DocumentInterface *doc, const gint IN_x, const gint IN_y, const char * IN_text, GError **error); //static |
