Commit 2de761f0 authored by Nicolas Dufour's avatar Nicolas Dufour Committed by Nicolas Dufour

D-Bus. Merging branch lp:~joakim-verona/inkscape/dbus-fixes (Bug #666986, Bug...

D-Bus. Merging branch lp:~joakim-verona/inkscape/dbus-fixes (Bug #666986, Bug #707054 and Bug #707364).

(bzr r10114)
parent 8c030bde
......@@ -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++
......
......@@ -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,
......
......@@ -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;
......
......@@ -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
****************************************************************************/
......
......@@ -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);
......
......@@ -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>
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment