1
#include "inkscape-dbus-wrapper.h"
8
#include "document-client-glue.h"
9
#include <dbus/dbus-glib.h>
10
#include <dbus/dbus.h>
12
// (static.*(\n[^}]*)*(async)+.*(\n[^}]*)*})|typedef void .*;
13
// http://www.josephkahn.com/music/index.xml
15
/* PRIVATE get a connection to the session bus */
17
dbus_get_connection() {
19
DBusGConnection *connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
21
fprintf(stderr, "Failed to get connection");
28
/* PRIVATE create a proxy object for a bus.*/
30
dbus_get_proxy(DBusGConnection *connection) {
31
return dbus_g_proxy_new_for_name (connection,
38
/* PRIVATE register an object on a bus */
40
dbus_register_object (DBusGConnection *connection,
43
const DBusGObjectInfo *info,
46
GObject *object = (GObject*)g_object_new (object_type, NULL);
47
dbus_g_object_type_install_info (object_type, info);
48
dbus_g_connection_register_g_object (connection, path, object);
53
/****************************************************************************
54
DOCUMENT INTERFACE CLASS STUFF
55
****************************************************************************/
57
struct _DocumentInterface {
62
G_DEFINE_TYPE(DocumentInterface, document_interface, G_TYPE_OBJECT)
65
document_interface_finalize (GObject *object)
67
G_OBJECT_CLASS (document_interface_parent_class)->finalize (object);
72
document_interface_class_init (DocumentInterfaceClass *klass)
74
GObjectClass *object_class;
75
object_class = G_OBJECT_CLASS (klass);
76
object_class->finalize = document_interface_finalize;
80
document_interface_init (DocumentInterface *object)
87
document_interface_new (void)
89
return (DocumentInterface*)g_object_new (TYPE_DOCUMENT_INTERFACE, NULL);
93
inkscape_desktop_init_dbus ()
95
DBusGConnection *connection;
102
connection = dbus_g_bus_get (DBUS_BUS_SESSION,
104
if (connection == NULL)
106
g_printerr ("Failed to open connection to bus: %s\n",
108
g_error_free (error);
112
proxy = dbus_g_proxy_new_for_name (connection,
114
"/org/inkscape/desktop_0",
115
"org.inkscape.document");
117
DocumentInterface * inkdesk = (DocumentInterface *)g_object_new (TYPE_DOCUMENT_INTERFACE, NULL);
118
inkdesk->proxy = proxy;
125
inkscape_delete_all (DocumentInterface *doc, GError **error)
127
DBusGProxy *proxy = doc->proxy;
128
return org_inkscape_document_delete_all (proxy, error);
133
inkscape_call_verb (DocumentInterface *doc, const char * IN_verbid, GError **error)
135
DBusGProxy *proxy = doc->proxy;
136
return org_inkscape_document_call_verb(proxy, IN_verbid, error);
142
inkscape_rectangle (DocumentInterface *doc, const gint IN_x, const gint IN_y, const gint IN_width, const gint IN_height, GError **error)
144
char * OUT_object_name;
145
DBusGProxy *proxy = doc->proxy;
146
org_inkscape_document_rectangle (proxy, IN_x, IN_y, IN_width, IN_height, &OUT_object_name, error);
147
return OUT_object_name;
152
inkscape_ellipse (DocumentInterface *doc, const gint IN_x, const gint IN_y, const gint IN_width, const gint IN_height, GError **error)
154
char * OUT_object_name;
155
DBusGProxy *proxy = doc->proxy;
156
org_inkscape_document_ellipse (proxy, IN_x, IN_y, IN_width, IN_height, &OUT_object_name, error);
157
return OUT_object_name;
162
inkscape_polygon (DocumentInterface *doc, const gint IN_cx, const gint IN_cy, const gint IN_radius, const gint IN_rotation, const gint IN_sides, GError **error)
164
char * OUT_object_name;
165
DBusGProxy *proxy = doc->proxy;
166
org_inkscape_document_polygon (proxy, IN_cx, IN_cy, IN_radius, IN_rotation, IN_sides, &OUT_object_name, error);
167
return OUT_object_name;
172
inkscape_star (DocumentInterface *doc, const gint IN_cx, const gint IN_cy, const gint IN_r1, const gint IN_r2, const gdouble IN_arg1, const gdouble IN_arg2, const gint IN_sides, const gdouble IN_rounded, GError **error)
174
char * OUT_object_name;
175
DBusGProxy *proxy = doc->proxy;
176
org_inkscape_document_star (proxy, IN_cx, IN_cy, IN_r1, IN_r2, IN_arg1, IN_arg2, IN_sides, IN_rounded, &OUT_object_name, error);
177
return OUT_object_name;
182
inkscape_spiral (DocumentInterface *doc, const gint IN_cx, const gint IN_cy, const gint IN_r, const gint IN_revolutions, GError **error)
184
char * OUT_object_name;
185
DBusGProxy *proxy = doc->proxy;
186
org_inkscape_document_spiral (proxy, IN_cx, IN_cy, IN_r, IN_revolutions, &OUT_object_name, error);
187
return OUT_object_name;
192
inkscape_line (DocumentInterface *doc, const gint IN_x, const gint IN_y, const gint IN_x2, const gint IN_y2, GError **error)
194
char * OUT_object_name;
195
DBusGProxy *proxy = doc->proxy;
196
org_inkscape_document_line (proxy, IN_x, IN_y, IN_x2, IN_y2, &OUT_object_name, error);
197
return OUT_object_name;
202
inkscape_text (DocumentInterface *doc, const gint IN_x, const gint IN_y, const char * IN_text, GError **error)
204
char * OUT_object_name;
205
DBusGProxy *proxy = doc->proxy;
206
org_inkscape_document_text (proxy, IN_x, IN_y, IN_text, &OUT_object_name, error);
207
return OUT_object_name;
212
inkscape_image (DocumentInterface *doc, const gint IN_x, const gint IN_y, const char * IN_text, GError **error)
214
char * OUT_object_name;
215
DBusGProxy *proxy = doc->proxy;
216
org_inkscape_document_image (proxy, IN_x, IN_y, IN_text, &OUT_object_name, error);
217
return OUT_object_name;
222
inkscape_node (DocumentInterface *doc, const char * IN_svgtype, GError **error)
225
DBusGProxy *proxy = doc->proxy;
226
org_inkscape_document_node (proxy, IN_svgtype, &OUT_node_name, error);
227
return OUT_node_name;
232
inkscape_document_get_width (DocumentInterface *doc, GError **error)
235
DBusGProxy *proxy = doc->proxy;
236
org_inkscape_document_document_get_width (proxy, &OUT_val, error);
242
inkscape_document_get_height (DocumentInterface *doc, GError **error)
245
DBusGProxy *proxy = doc->proxy;
246
org_inkscape_document_document_get_height (proxy, &OUT_val, error);
252
inkscape_document_get_css (DocumentInterface *doc, GError **error)
255
DBusGProxy *proxy = doc->proxy;
256
org_inkscape_document_document_get_css (proxy, &OUT_css, error);
262
inkscape_document_set_css (DocumentInterface *doc, const char * IN_stylestring, GError **error)
264
DBusGProxy *proxy = doc->proxy;
265
return org_inkscape_document_document_set_css (proxy, IN_stylestring, error);
270
inkscape_document_merge_css (DocumentInterface *doc, const char * IN_stylestring, GError **error)
272
DBusGProxy *proxy = doc->proxy;
273
return org_inkscape_document_document_merge_css (proxy, IN_stylestring, error);
278
inkscape_document_resize_to_fit_selection (DocumentInterface *doc, GError **error)
280
DBusGProxy *proxy = doc->proxy;
281
return org_inkscape_document_document_resize_to_fit_selection (proxy, error);
286
inkscape_set_attribute (DocumentInterface *doc, const char * IN_shape, const char * IN_attribute, const char * IN_newval, GError **error)
288
DBusGProxy *proxy = doc->proxy;
289
return org_inkscape_document_set_attribute (proxy, IN_shape, IN_attribute, IN_newval, error);
294
inkscape_set_int_attribute (DocumentInterface *doc, const char * IN_shape, const char * IN_attribute, const gint IN_newval, GError **error)
296
DBusGProxy *proxy = doc->proxy;
297
return org_inkscape_document_set_int_attribute (proxy, IN_shape, IN_attribute, IN_newval, error);
302
inkscape_set_double_attribute (DocumentInterface *doc, const char * IN_shape, const char * IN_attribute, const gdouble IN_newval, GError **error)
304
DBusGProxy *proxy = doc->proxy;
305
return org_inkscape_document_set_double_attribute (proxy, IN_shape, IN_attribute, IN_newval, error);
310
inkscape_get_attribute (DocumentInterface *doc, const char * IN_shape, const char * IN_attribute, GError **error)
313
DBusGProxy *proxy = doc->proxy;
314
org_inkscape_document_get_attribute (proxy, IN_shape, IN_attribute, &OUT_val, error);
320
inkscape_move (DocumentInterface *doc, const char * IN_shape, const gdouble IN_x, const gdouble IN_y, GError **error)
322
DBusGProxy *proxy = doc->proxy;
323
return org_inkscape_document_move (proxy, IN_shape, IN_x, IN_y, error);
328
inkscape_move_to (DocumentInterface *doc, const char * IN_shape, const gdouble IN_x, const gdouble IN_y, GError **error)
330
DBusGProxy *proxy = doc->proxy;
331
return org_inkscape_document_move_to (proxy, IN_shape, IN_x, IN_y, error);
336
inkscape_object_to_path (DocumentInterface *doc, const char * IN_objectname, GError **error)
338
DBusGProxy *proxy = doc->proxy;
339
return org_inkscape_document_object_to_path (proxy, IN_objectname, error);
344
inkscape_get_path (DocumentInterface *doc, const char * IN_shape, GError **error)
347
DBusGProxy *proxy = doc->proxy;
348
org_inkscape_document_get_path (proxy, IN_shape, &OUT_val, error);
354
inkscape_transform (DocumentInterface *doc, const char * IN_shape, const char * IN_transformstr, GError **error)
356
DBusGProxy *proxy = doc->proxy;
357
return org_inkscape_document_transform (proxy, IN_shape, IN_transformstr, error);
362
inkscape_get_css (DocumentInterface *doc, const char * IN_shape, GError **error)
365
DBusGProxy *proxy = doc->proxy;
366
org_inkscape_document_get_css (proxy, IN_shape, &OUT_css, error);
372
inkscape_modify_css (DocumentInterface *doc, const char * IN_shape, const char * IN_cssattrib, const char * IN_newval, GError **error)
374
DBusGProxy *proxy = doc->proxy;
375
return org_inkscape_document_modify_css (proxy, IN_shape, IN_cssattrib, IN_newval, error);
380
inkscape_merge_css (DocumentInterface *doc, const char * IN_shape, const char * IN_stylestring, GError **error)
382
DBusGProxy *proxy = doc->proxy;
383
return org_inkscape_document_merge_css (proxy, IN_shape, IN_stylestring, error);
388
inkscape_set_color (DocumentInterface *doc, const char * IN_shape, const gint IN_red, const gint IN_green, const gint IN_blue, const gboolean IN_fill, GError **error)
390
DBusGProxy *proxy = doc->proxy;
391
return org_inkscape_document_set_color (proxy, IN_shape, IN_red, IN_green, IN_blue, IN_fill, error);
396
inkscape_move_to_layer (DocumentInterface *doc, const char * IN_objectname, const char * IN_layername, GError **error)
398
DBusGProxy *proxy = doc->proxy;
399
return org_inkscape_document_move_to_layer (proxy, IN_objectname, IN_layername, error);
404
inkscape_get_node_coordinates (DocumentInterface *doc, const char * IN_shape, GError **error)
407
DBusGProxy *proxy = doc->proxy;
408
org_inkscape_document_get_node_coordinates (proxy, IN_shape, &OUT_points, error);
414
inkscape_save (DocumentInterface *doc, GError **error)
416
DBusGProxy *proxy = doc->proxy;
417
return org_inkscape_document_save (proxy, error);
422
inkscape_save_as (DocumentInterface *doc, const char * IN_pathname, GError **error)
424
DBusGProxy *proxy = doc->proxy;
425
return org_inkscape_document_save_as (proxy, IN_pathname, error);
430
inkscape_load (DocumentInterface *doc, const char * IN_pathname, GError **error)
432
DBusGProxy *proxy = doc->proxy;
433
return org_inkscape_document_load (proxy, IN_pathname, error);
438
inkscape_mark_as_unmodified (DocumentInterface *doc, GError **error)
440
DBusGProxy *proxy = doc->proxy;
441
return org_inkscape_document_mark_as_unmodified (proxy, error);
446
inkscape_close (DocumentInterface *doc, GError **error)
448
DBusGProxy *proxy = doc->proxy;
449
return org_inkscape_document_close (proxy, error);
454
inkscape_inkscape_exit (DocumentInterface *doc, GError **error)
456
DBusGProxy *proxy = doc->proxy;
457
return org_inkscape_document_exit (proxy, error);
462
inkscape_undo (DocumentInterface *doc, GError **error)
464
DBusGProxy *proxy = doc->proxy;
465
return org_inkscape_document_undo (proxy, error);
470
inkscape_redo (DocumentInterface *doc, GError **error)
472
DBusGProxy *proxy = doc->proxy;
473
return org_inkscape_document_redo (proxy, error);
478
inkscape_pause_updates (DocumentInterface *doc, GError **error)
480
DBusGProxy *proxy = doc->proxy;
481
return org_inkscape_document_pause_updates (proxy, error);
486
inkscape_resume_updates (DocumentInterface *doc, GError **error)
488
DBusGProxy *proxy = doc->proxy;
489
return org_inkscape_document_resume_updates (proxy, error);
494
inkscape_update (DocumentInterface *doc, GError **error)
496
DBusGProxy *proxy = doc->proxy;
497
return org_inkscape_document_update (proxy, error);
502
inkscape_selection_get (DocumentInterface *doc, GError **error)
505
DBusGProxy *proxy = doc->proxy;
506
org_inkscape_document_selection_get (proxy, &OUT_listy, error);
512
inkscape_selection_add (DocumentInterface *doc, const char * IN_name, GError **error)
514
DBusGProxy *proxy = doc->proxy;
515
return org_inkscape_document_selection_add (proxy, IN_name, error);
520
inkscape_selection_add_list (DocumentInterface *doc, const char ** IN_name, GError **error)
522
DBusGProxy *proxy = doc->proxy;
523
return org_inkscape_document_selection_add_list (proxy, IN_name, error);
528
inkscape_selection_set (DocumentInterface *doc, const char * IN_name, GError **error)
530
DBusGProxy *proxy = doc->proxy;
531
return org_inkscape_document_selection_set (proxy, IN_name, error);
536
inkscape_selection_set_list (DocumentInterface *doc, const char ** IN_name, GError **error)
538
DBusGProxy *proxy = doc->proxy;
539
return org_inkscape_document_selection_set_list (proxy, IN_name, error);
544
inkscape_selection_rotate (DocumentInterface *doc, const gint IN_angle, GError **error)
546
DBusGProxy *proxy = doc->proxy;
547
return org_inkscape_document_selection_rotate (proxy, IN_angle, error);
552
inkscape_selection_delete (DocumentInterface *doc, GError **error)
554
DBusGProxy *proxy = doc->proxy;
555
return org_inkscape_document_selection_delete (proxy, error);
560
inkscape_selection_clear (DocumentInterface *doc, GError **error)
562
DBusGProxy *proxy = doc->proxy;
563
return org_inkscape_document_selection_clear (proxy, error);
568
inkscape_select_all (DocumentInterface *doc, GError **error)
570
DBusGProxy *proxy = doc->proxy;
571
return org_inkscape_document_select_all (proxy, error);
576
inkscape_select_all_in_all_layers (DocumentInterface *doc, GError **error)
578
DBusGProxy *proxy = doc->proxy;
579
return org_inkscape_document_select_all_in_all_layers (proxy, error);
584
inkscape_selection_box (DocumentInterface *doc, const gint IN_x, const gint IN_y, const gint IN_x2, const gint IN_y2, const gboolean IN_replace, GError **error)
586
DBusGProxy *proxy = doc->proxy;
587
return org_inkscape_document_selection_box (proxy, IN_x, IN_y, IN_x2, IN_y2, IN_replace, error);
592
inkscape_selection_invert (DocumentInterface *doc, GError **error)
594
DBusGProxy *proxy = doc->proxy;
595
return org_inkscape_document_selection_invert (proxy, error);
600
inkscape_selection_group (DocumentInterface *doc, GError **error)
602
DBusGProxy *proxy = doc->proxy;
603
return org_inkscape_document_selection_group (proxy, error);
608
inkscape_selection_ungroup (DocumentInterface *doc, GError **error)
610
DBusGProxy *proxy = doc->proxy;
611
return org_inkscape_document_selection_ungroup (proxy, error);
616
inkscape_selection_cut (DocumentInterface *doc, GError **error)
618
DBusGProxy *proxy = doc->proxy;
619
return org_inkscape_document_selection_cut (proxy, error);
624
inkscape_selection_copy (DocumentInterface *doc, GError **error)
626
DBusGProxy *proxy = doc->proxy;
627
return org_inkscape_document_selection_copy (proxy, error);
632
inkscape_selection_paste (DocumentInterface *doc, GError **error)
634
DBusGProxy *proxy = doc->proxy;
635
return org_inkscape_document_selection_paste (proxy, error);
640
inkscape_selection_scale (DocumentInterface *doc, const gdouble IN_grow, GError **error)
642
DBusGProxy *proxy = doc->proxy;
643
return org_inkscape_document_selection_scale (proxy, IN_grow, error);
648
inkscape_selection_move (DocumentInterface *doc, const gdouble IN_x, const gdouble IN_y, GError **error)
650
DBusGProxy *proxy = doc->proxy;
651
return org_inkscape_document_selection_move (proxy, IN_x, IN_y, error);
656
inkscape_selection_move_to (DocumentInterface *doc, const gdouble IN_x, const gdouble IN_y, GError **error)
658
DBusGProxy *proxy = doc->proxy;
659
return org_inkscape_document_selection_move_to (proxy, IN_x, IN_y, error);
664
inkscape_selection_move_to_layer (DocumentInterface *doc, const char * IN_layer, GError **error)
666
DBusGProxy *proxy = doc->proxy;
667
return org_inkscape_document_selection_move_to_layer (proxy, IN_layer, error);
672
inkscape_selection_get_center (DocumentInterface *doc, GError **error)
674
GArray* OUT_centerpoint;
675
DBusGProxy *proxy = doc->proxy;
676
org_inkscape_document_selection_get_center (proxy, &OUT_centerpoint, error);
677
return OUT_centerpoint;
682
inkscape_selection_to_path (DocumentInterface *doc, GError **error)
684
DBusGProxy *proxy = doc->proxy;
685
return org_inkscape_document_selection_to_path (proxy, error);
690
inkscape_selection_combine (DocumentInterface *doc, const char * IN_type, GError **error)
693
DBusGProxy *proxy = doc->proxy;
694
org_inkscape_document_selection_combine (proxy, IN_type, &OUT_newpath, error);
700
inkscape_selection_divide (DocumentInterface *doc, GError **error)
703
DBusGProxy *proxy = doc->proxy;
704
org_inkscape_document_selection_divide (proxy, &OUT_pieces, error);
710
inkscape_selection_change_level (DocumentInterface *doc, const char * IN_command, GError **error)
712
gboolean OUT_objectsmoved;
713
DBusGProxy *proxy = doc->proxy;
714
org_inkscape_document_selection_change_level (proxy, IN_command, &OUT_objectsmoved, error);
715
return OUT_objectsmoved;
720
inkscape_layer_new (DocumentInterface *doc, GError **error)
722
char * OUT_layername;
723
DBusGProxy *proxy = doc->proxy;
724
org_inkscape_document_layer_new (proxy, &OUT_layername, error);
725
return OUT_layername;
730
inkscape_layer_set (DocumentInterface *doc, const char * IN_layer, GError **error)
732
DBusGProxy *proxy = doc->proxy;
733
return org_inkscape_document_layer_set (proxy, IN_layer, error);
738
inkscape_layer_get_all (DocumentInterface *doc, GError **error)
741
DBusGProxy *proxy = doc->proxy;
742
org_inkscape_document_layer_get_all (proxy, &OUT_layers, error);
748
inkscape_layer_change_level (DocumentInterface *doc, const char * IN_command, GError **error)
750
gboolean OUT_layermoved;
751
DBusGProxy *proxy = doc->proxy;
752
org_inkscape_document_layer_change_level (proxy, IN_command, &OUT_layermoved, error);
753
return OUT_layermoved;
758
inkscape_layer_next (DocumentInterface *doc, GError **error)
760
DBusGProxy *proxy = doc->proxy;
761
return org_inkscape_document_layer_next (proxy, error);
766
inkscape_layer_previous (DocumentInterface *doc, GError **error)
768
DBusGProxy *proxy = doc->proxy;
769
return org_inkscape_document_layer_previous (proxy, error);
774
main (int argc, char** argv)
777
GError *error = NULL;
778
DocumentInterface * doc = inkscape_desktop_init_dbus ();
779
result = rectangle (doc->proxy, 10, 10, 100, 100, &error);
780
printf("RESULT: %s\n", result);
782
//dbus_g_proxy_call(doc->proxy, "rectangle", &error, G_TYPE_INT, 100, G_TYPE_INT, 100, G_TYPE_INT, 100, G_TYPE_INT, 100, G_TYPE_INVALID, G_TYPE_INVALID);