[dbus] text objects created with dbus are weird

Bug #666986 reported by joakim@verona.se on 2010-10-26
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Undecided
joakim@verona.se

Bug Description

text objects created with dbus doesnt seem to be proper inkscape objects.

 - the text shows up, but its not possible to move it with inkscape tools
 - there is no way send line feeds bacslash n becomes a box
 - there is no way to change the text through dbus after its created

Related branches

- the xml editor view does not show the newly created text object either
- the text object does not survive save/load.

su_v (suv-lp) on 2010-10-27
summary: - [dbus] text objects createed with dbus are weird
+ [dbus] text objects created with dbus are weird
tags: added: text

I have a patch that improves the issue. The created text now behaves much more like text created through the UI.
Bugs certainly remain though.

gboolean
document_interface_text (DocumentInterface *object, int x, int y, gchar *text, GError **error)
{

  Inkscape::XML::Node *text_node = dbus_create_node(object->desk, "svg:text");
    Inkscape::XML::Node *tspan_node = NULL;

    tspan_node = dbus_create_node(object->desk, "svg:tspan");
    sp_repr_set_svg_double(tspan_node, "x", x);
    sp_repr_set_svg_double(tspan_node, "y", y);

    // Add text content node to tspan
    SPDocument * doc = sp_desktop_document (object->desk);
    Inkscape::XML::Document *xml_doc = doc->getReprDoc();

    Inkscape::XML::Node *text_content = xml_doc->createTextNode(text);
    tspan_node->appendChild(text_content);
    text_node->appendChild(tspan_node);
    // Inkscape::GC::release(text_content);
     finish_create_shape (object, error, text_node, (gchar *)"create text");
    return TRUE;
}

Solves most of the issues in this bug.

Please note that I changed the interface to return the object id.
I think this correct and the previous behaviour a bug.

I have a much better patch now below. It is simpler and supports linefeeds.

gchar*
document_interface_text (DocumentInterface *object, int x, int y, gchar *text, GError **error)
{

  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 name;
}

I will instead publish my dbus fixes in a branch:
https://code.launchpad.net/~joakim-verona/inkscape/dbus-fixes

su_v (suv-lp) wrote :

<off-topic>
Sorry for yet another off-topic comment. Your work on testing and improving the dbus API and sharing your patches is highly appreciated!

> I have a much better patch now below. It is simpler and supports linefeeds.

Could you attach the patch as unified diffs? (e.g. created with 'bzr diff [FILE…]')?

See also
<http://thread.gmane.org/gmane.comp.graphics.inkscape.devel/32992/focus=32998>
<http://doc.bazaar.canonical.com/latest/en/user-reference/diff-help.html>
</off-topic>

su_v (suv-lp) wrote :

oops - I definitely need to reload a page before posting a comment... ;)

Please disregard my previous off-topic comment!

jazzynico (jazzynico) on 2011-01-31
Changed in inkscape:
assignee: nobody → joakim@verona.se (joakim-verona)
status: New → In Progress
jazzynico (jazzynico) wrote :

Fix committed in the trunk, revision 10114.
Thanks Joakim!

Changed in inkscape:
status: In Progress → Fix Released
su_v (suv-lp) on 2014-05-06
tags: added: dbusapi
removed: dbus
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers