Merge lp:~joakim-verona/inkscape/dbus-fixes into lp:~inkscape.dev/inkscape/trunk

Proposed by joakim@verona.se
Status: Merged
Approved by: jazzynico
Approved revision: 10016
Merged at revision: 10114
Proposed branch: lp:~joakim-verona/inkscape/dbus-fixes
Merge into: lp:~inkscape.dev/inkscape/trunk
Diff against target: 250 lines (+89/-21)
8 files modified
src/display/canvas-text.h (+1/-0)
src/document.cpp (+5/-1)
src/extension/dbus/dbus-init.cpp (+0/-3)
src/extension/dbus/document-interface.cpp (+44/-12)
src/extension/dbus/document-interface.h (+5/-2)
src/extension/dbus/document-interface.xml (+29/-0)
src/extension/dbus/wrapper/inkscape-dbus-wrapper.c (+4/-2)
src/extension/dbus/wrapper/inkscape-dbus-wrapper.h (+1/-1)
To merge this branch: bzr merge lp:~joakim-verona/inkscape/dbus-fixes
Reviewer Review Type Date Requested Status
jazzynico (community) Approve
Yury V. Zaytsev supeficial Needs Fixing
Review via email: mp+50526@code.launchpad.net

Description of the change

fixes some dbus bugs. ive used this branch for a while and it seems ok.

To post a comment you must log in.
Revision history for this message
Yury V. Zaytsev (zyv) wrote :

The branch contains an unclean merge in file:

=== modified file 'src/extension/dbus/document-interface.cpp'

review: Needs Fixing (supeficial)
10016. By joakim@verona.se

merge upstream

Revision history for this message
joakim@verona.se (joakim-verona) wrote :

> The branch contains an unclean merge in file:
>
> === modified file 'src/extension/dbus/document-interface.cpp'

new try.

Revision history for this message
jazzynico (jazzynico) wrote :

Branch tested successfully on Ubuntu 10.10, Inkscape revision 10113.
All the bugs listed here are fixed.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/display/canvas-text.h'
2--- src/display/canvas-text.h 2011-02-02 21:24:36 +0000
3+++ src/display/canvas-text.h 2011-02-20 22:27:52 +0000
4@@ -53,6 +53,7 @@
5 #endif // SEEN_SP_CANVASTEXT_H
6
7
8+
9 /*
10 Local Variables:
11 mode:c++
12
13=== modified file 'src/document.cpp'
14--- src/document.cpp 2011-02-20 10:37:24 +0000
15+++ src/document.cpp 2011-02-20 22:27:52 +0000
16@@ -848,7 +848,11 @@
17 g_return_val_if_fail(id != NULL, NULL);
18
19 GQuark idq = g_quark_from_string(id);
20- return (SPObject*)g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq));
21+ gpointer rv = g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq));
22+ if(rv != NULL)
23+ return (SPObject*)rv;
24+ else
25+ return NULL;
26 }
27
28 sigc::connection SPDocument::connectIdChanged(gchar const *id,
29
30=== modified file 'src/extension/dbus/dbus-init.cpp'
31--- src/extension/dbus/dbus-init.cpp 2011-02-03 23:13:20 +0000
32+++ src/extension/dbus/dbus-init.cpp 2011-02-20 22:27:52 +0000
33@@ -86,7 +86,6 @@
34 GError *error = NULL;
35 DBusGConnection *connection;
36 DBusGProxy *proxy;
37- DocumentInterface *obj;
38 connection = dbus_get_connection();
39 proxy = dbus_get_proxy(connection);
40 org_freedesktop_DBus_request_name (proxy,
41@@ -102,8 +101,6 @@
42
43 gchar *
44 init_document (void) {
45- guint result;
46- GError *error = NULL;
47 DBusGConnection *connection;
48 DBusGProxy *proxy;
49 SPDocument *doc;
50
51=== modified file 'src/extension/dbus/document-interface.cpp'
52--- src/extension/dbus/document-interface.cpp 2011-02-03 23:13:20 +0000
53+++ src/extension/dbus/document-interface.cpp 2011-02-20 22:27:52 +0000
54@@ -36,6 +36,20 @@
55 #include "sp-ellipse.h"
56 #include "sp-object.h"
57 #include "style.h" //style_write
58+
59+#include "file.h" //IO
60+
61+#include "extension/system.h" //IO
62+
63+#include "extension/output.h" //IO
64+
65+#include "print.h" //IO
66+
67+#include "live_effects/parameter/text.h" //text
68+#include "display/canvas-text.h" //text
69+
70+#include "display/sp-canvas.h" //text
71+#include "text-editing.h"
72 #include "verbs.h"
73 #include "xml/repr.h" //sp_repr_document_new
74
75@@ -61,13 +75,13 @@
76 /* ALTERNATIVE (is this faster if only repr is needed?)
77 Inkscape::XML::Node *node = sp_repr_lookup_name((doc->root)->repr, name);
78 */
79- Inkscape::XML::Node * node = sp_desktop_document(desk)->getObjectById(name)->getRepr();
80- if (!node)
81+ SPObject * obj = sp_desktop_document(desk)->getObjectById(name);
82+ if (!obj)
83 {
84 g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OBJECT, "Object '%s' not found in document.", name);
85 return NULL;
86 }
87- return node;
88+ return obj->getRepr();
89 }
90
91 /*
92@@ -346,6 +360,7 @@
93 if (object->updates) {
94 Inkscape::DocumentUndo::done(sp_desktop_document(desk2), verb->get_code(), g_strdup(verb->get_tip()));
95 }
96+ return TRUE;
97 }
98 }
99 }
100@@ -470,17 +485,20 @@
101 return retval;
102 }
103
104-gboolean
105+gchar*
106 document_interface_text (DocumentInterface *object, int x, int y, gchar *text, GError **error)
107 {
108- //FIXME: Not selectable (aka broken). Needs to be rewritten completely.
109-
110- SPDesktop *desktop = object->desk;
111- SPCanvasText * canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, Geom::Point(0,0), "");
112- sp_canvastext_set_text (canvas_text, text);
113- sp_canvastext_set_coords (canvas_text, x, y);
114-
115- return TRUE;
116+
117+ Inkscape::XML::Node *text_node = dbus_create_node(object->desk, "svg:text");
118+ sp_repr_set_int(text_node, "x", x);
119+ sp_repr_set_int(text_node, "y", y);
120+ //just a workaround so i can get an spitem from the name
121+ gchar *name = finish_create_shape (object, error, text_node, (gchar *)"create text");
122+
123+ SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error);
124+ sp_te_set_repr_text_multiline(text_obj, text);
125+
126+ return name;
127 }
128
129 gchar *
130@@ -809,6 +827,20 @@
131 }
132
133
134+gboolean
135+document_interface_set_text (DocumentInterface *object, gchar *name, gchar *text, GError **error)
136+{
137+
138+ SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error);
139+ //TODO verify object type
140+ if (!text_obj)
141+ return FALSE;
142+ sp_te_set_repr_text_multiline(text_obj, text);
143+ return TRUE;
144+
145+}
146+
147+
148 /****************************************************************************
149 FILE I/O FUNCTIONS
150 ****************************************************************************/
151
152=== modified file 'src/extension/dbus/document-interface.h'
153--- src/extension/dbus/document-interface.h 2011-02-03 23:13:20 +0000
154+++ src/extension/dbus/document-interface.h 2011-02-20 22:27:52 +0000
155@@ -115,10 +115,13 @@
156 document_interface_line (DocumentInterface *object, int x, int y,
157 int x2, int y2, GError **error);
158
159-gboolean
160+gchar*
161 document_interface_text (DocumentInterface *object, int x, int y,
162 gchar *text, GError **error);
163-
164+gboolean
165+document_interface_set_text (DocumentInterface *object, gchar *name,
166+ gchar *text, GError **error);
167+
168 gchar *
169 document_interface_image (DocumentInterface *object, int x, int y,
170 gchar *filename, GError **error);
171
172=== modified file 'src/extension/dbus/document-interface.xml'
173--- src/extension/dbus/document-interface.xml 2009-08-15 18:26:08 +0000
174+++ src/extension/dbus/document-interface.xml 2011-02-20 22:27:52 +0000
175@@ -310,6 +310,12 @@
176 <doc:summary>The text you want.</doc:summary>
177 </doc:doc>
178 </arg>
179+ <arg type="s" name="object_name" direction="out" >
180+ <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/>
181+ <doc:doc>
182+ <doc:summary>The name of the new text.</doc:summary>
183+ </doc:doc>
184+ </arg>
185 <doc:doc>
186 <doc:description>
187 <doc:para>This method creates some text in the current layer.</doc:para>
188@@ -472,6 +478,29 @@
189 </doc:doc>
190 </method>
191
192+
193+ <method name="set_text">
194+ <arg type="s" name="shape" direction="in" >
195+ <doc:doc>
196+ <doc:summary>The id of an object.</doc:summary>
197+ </doc:doc>
198+ </arg>
199+
200+ <arg type="s" name="text" direction="in" >
201+ <doc:doc>
202+ <doc:summary>The text you want.</doc:summary>
203+ </doc:doc>
204+ </arg>
205+ <doc:doc>
206+ <doc:description>
207+ <doc:para>set text of text object.</doc:para>
208+ </doc:description>
209+ </doc:doc>
210+ </method>
211+
212+
213+
214+
215 <method name="set_int_attribute">
216 <arg type="s" name="shape" direction="in" >
217 <doc:doc>
218
219=== modified file 'src/extension/dbus/wrapper/inkscape-dbus-wrapper.c'
220--- src/extension/dbus/wrapper/inkscape-dbus-wrapper.c 2010-01-01 04:38:19 +0000
221+++ src/extension/dbus/wrapper/inkscape-dbus-wrapper.c 2011-02-20 22:27:52 +0000
222@@ -198,11 +198,13 @@
223 }
224
225 //static
226-gboolean
227+char *
228 inkscape_text (DocumentInterface *doc, const gint IN_x, const gint IN_y, const char * IN_text, GError **error)
229 {
230+ char * OUT_object_name;
231 DBusGProxy *proxy = doc->proxy;
232- return org_inkscape_document_text (proxy, IN_x, IN_y, IN_text, error);
233+ org_inkscape_document_text (proxy, IN_x, IN_y, IN_text, &OUT_object_name, error);
234+ return OUT_object_name;
235 }
236
237 //static
238
239=== modified file 'src/extension/dbus/wrapper/inkscape-dbus-wrapper.h'
240--- src/extension/dbus/wrapper/inkscape-dbus-wrapper.h 2009-08-13 20:53:03 +0000
241+++ src/extension/dbus/wrapper/inkscape-dbus-wrapper.h 2011-02-20 22:27:52 +0000
242@@ -72,7 +72,7 @@
243 inkscape_line (DocumentInterface *doc, const gint IN_x, const gint IN_y, const gint IN_x2, const gint IN_y2, GError **error);
244
245 //static
246-gboolean
247+char *
248 inkscape_text (DocumentInterface *doc, const gint IN_x, const gint IN_y, const char * IN_text, GError **error);
249
250 //static