summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/dbus/dbus-init.cpp29
-rw-r--r--src/extension/dbus/dbus-init.h10
-rw-r--r--src/extension/dbus/document-interface.h3
-rw-r--r--src/extension/dbus/wrapper/inkscape-dbus-wrapper.h2
4 files changed, 37 insertions, 7 deletions
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 <sstream>
-
+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 */
diff --git a/src/extension/dbus/dbus-init.h b/src/extension/dbus/dbus-init.h
index 486e55b86..7862ad3c3 100644
--- a/src/extension/dbus/dbus-init.h
+++ b/src/extension/dbus/dbus-init.h
@@ -28,6 +28,16 @@ gchar * init_desktop (void);
gchar * dbus_init_desktop_interface (SPDesktop * dt);
+/** Set the bus name to use. Default is "org.inkscape".
+ This function should only be called once, before init(), if a non-default
+ bus name is required. */
+void dbus_set_bus_name(gchar * bus_name);
+
+/** Get the bus name for this instance. Default is "org.inkscape".
+ This function should only be called after init().
+ The returned gchar * is owned by this module and should not be freed. */
+gchar * dbus_get_bus_name();
+
} } } /* namespace Dbus, Extension, Inkscape */
#endif /* INKSCAPE_EXTENSION_DBUS_INIT_H__ */
diff --git a/src/extension/dbus/document-interface.h b/src/extension/dbus/document-interface.h
index 00d964f36..27460de52 100644
--- a/src/extension/dbus/document-interface.h
+++ b/src/extension/dbus/document-interface.h
@@ -34,9 +34,6 @@
class SPDesktop;
class SPItem;
-
-// TODO: this define doesn't seem to be used... although the path itself is also hardcoded in dbus-init.cpp
-#define DBUS_DOCUMENT_INTERFACE_PATH "/org/inkscape/document"
#define TYPE_DOCUMENT_INTERFACE (document_interface_get_type ())
#define DOCUMENT_INTERFACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_DOCUMENT_INTERFACE, DocumentInterface))
diff --git a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h
index 79f8188d4..20830bd65 100644
--- a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h
+++ b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h
@@ -8,8 +8,6 @@
//#include <dbus/dbus-glib-bindings.h>
//#include <dbus/dbus-glib-lowlevel.h>
-
-#define DBUS_DOCUMENT_INTERFACE_PATH "/org/inkscape/document"
#define TYPE_DOCUMENT_INTERFACE (document_interface_get_type ())
#define DOCUMENT_INTERFACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_DOCUMENT_INTERFACE, DocumentInterface))