From bea3d29ac007d6c8faca786538fafb0d7d789ffc Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Wed, 10 Jul 2013 11:50:45 +0100 Subject: Added "dbus-name" command line option to allow a D-Bus bus name other than "org.inkscape" to be specified. This allows multiple Inkscape instances to be controlled over D-Bus in a single user session. (bzr r12402.1.1) --- src/extension/dbus/dbus-init.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/extension/dbus/dbus-init.cpp') diff --git a/src/extension/dbus/dbus-init.cpp b/src/extension/dbus/dbus-init.cpp index eb62f4b3a..19b48e10d 100644 --- a/src/extension/dbus/dbus-init.cpp +++ b/src/extension/dbus/dbus-init.cpp @@ -36,7 +36,14 @@ #include - +namespace +{ + // This stores the bus name to use for this app instance. By default, it + // will be set to org.inkscape. However, users may provide other names by + // setting command-line parameters when starting Inkscape, so that more + // than one instance of Inkscape may be used by external scripts. + gchar *instance_bus_name = NULL; +} namespace Inkscape { namespace Extension { @@ -120,6 +127,11 @@ dbus_register_document(Inkscape::ActionContext const & target) void init (void) { + if (instance_bus_name == NULL) { + // Set the bus name to the default + instance_bus_name = strdup("org.inkscape"); + } + guint result; GError *error = NULL; DBusGConnection *connection; @@ -127,7 +139,7 @@ init (void) connection = dbus_get_connection(); proxy = dbus_get_proxy(connection); org_freedesktop_DBus_request_name (proxy, - "org.inkscape", + instance_bus_name, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); //create interface for application dbus_register_object (connection, @@ -198,6 +210,19 @@ init_desktop (void) { return strdup(name.c_str()); } +void +dbus_set_bus_name(gchar * bus_name) +{ + g_assert(bus_name != NULL); + g_assert(instance_bus_name == NULL); + instance_bus_name = strdup(bus_name); +} +gchar * +dbus_get_bus_name() +{ + g_assert(instance_bus_name != NULL); + return instance_bus_name; +} } } } /* namespace Inkscape::Extension::Dbus */ -- cgit v1.2.3