From 09ce234c1fc367a2607936e6cf106cb24c60e94f Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Wed, 3 Jul 2013 20:06:11 +0100 Subject: Modified dbus interface so that it works in console mode (--dbus-listen) Modified action context setup so that in console mode, when a document is added to the main inkscape app instance, it gets a selection model and layer model automatically set up for it Made a couple more verbs work in console mode (bzr r12387.1.4) --- src/extension/dbus/application-interface.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/extension/dbus/application-interface.cpp') diff --git a/src/extension/dbus/application-interface.cpp b/src/extension/dbus/application-interface.cpp index 8ee7bd12f..399e1b244 100644 --- a/src/extension/dbus/application-interface.cpp +++ b/src/extension/dbus/application-interface.cpp @@ -18,6 +18,7 @@ #include "application-interface.h" #include #include "dbus-init.h" +#include "file.h" G_DEFINE_TYPE(ApplicationInterface, application_interface, G_TYPE_OBJECT) @@ -131,6 +132,7 @@ application_interface_desktop_close_all (ApplicationInterface *object, gboolean application_interface_exit (ApplicationInterface *object, GError **error) { + sp_file_exit(); return TRUE; } @@ -144,6 +146,13 @@ gchar* application_interface_document_new (ApplicationInterface *object, return (gchar*)Inkscape::Extension::Dbus::init_document(); } +gchar* +application_interface_get_active_document(ApplicationInterface *object, + GError **error) +{ + return (gchar*)Inkscape::Extension::Dbus::init_active_document(); +} + gchar** application_interface_get_document_list (ApplicationInterface *object) { -- cgit v1.2.3 From 1c75594f5c37e86dec195ec1975254315ef180e9 Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Wed, 3 Jul 2013 23:00:06 +0100 Subject: Changed dbus interface to treat 'division' like other boolops, with a new return type for selection_combine to support this (array of string). This also fixes a bug with not setting the error flag when returning NULL from this method. Refactored some more selection verbs to allow use in no-GUI mode. (bzr r12387.1.5) --- src/extension/dbus/application-interface.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/extension/dbus/application-interface.cpp') diff --git a/src/extension/dbus/application-interface.cpp b/src/extension/dbus/application-interface.cpp index 399e1b244..1b1dbf0f5 100644 --- a/src/extension/dbus/application-interface.cpp +++ b/src/extension/dbus/application-interface.cpp @@ -150,7 +150,11 @@ gchar* application_interface_get_active_document(ApplicationInterface *object, GError **error) { - return (gchar*)Inkscape::Extension::Dbus::init_active_document(); + gchar *result = (gchar*)Inkscape::Extension::Dbus::init_active_document(); + if (!result) { + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "No active document"); + } + return result; } gchar** -- cgit v1.2.3 From 036013caefc09f34ef9b418e1ca148a821c777d6 Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Thu, 4 Jul 2013 23:51:56 +0100 Subject: Further renaming of DBus variables (object -> app_interface/doc_interface and doc_context -> target) Fixes to application interface for document_new (now only works in console mode, and behaves as expected) (bzr r12387.1.8) --- src/extension/dbus/application-interface.cpp | 48 ++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 13 deletions(-) (limited to 'src/extension/dbus/application-interface.cpp') diff --git a/src/extension/dbus/application-interface.cpp b/src/extension/dbus/application-interface.cpp index 1b1dbf0f5..c0bc19d90 100644 --- a/src/extension/dbus/application-interface.cpp +++ b/src/extension/dbus/application-interface.cpp @@ -19,6 +19,7 @@ #include #include "dbus-init.h" #include "file.h" +#include "inkscape.h" G_DEFINE_TYPE(ApplicationInterface, application_interface, G_TYPE_OBJECT) @@ -38,13 +39,32 @@ application_interface_class_init (ApplicationInterfaceClass *klass) } static void -application_interface_init (ApplicationInterface *object) +application_interface_init (ApplicationInterface *app_interface) { dbus_g_error_domain_register (INKSCAPE_ERROR, NULL, INKSCAPE_TYPE_ERROR); } +static bool +ensure_desktop_valid(GError **error) +{ + if (!inkscape_use_gui()) { + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Application interface action requires a GUI"); + return false; + } + return true; +} + +static bool +ensure_desktop_not_present(GError **error) +{ + if (inkscape_use_gui()) { + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Application interface action requires non-GUI (command line) mode"); + return false; + } + return true; +} ApplicationInterface * application_interface_new (void) @@ -95,27 +115,28 @@ GType inkscape_error_get_type(void) ****************************************************************************/ gchar* -application_interface_desktop_new (ApplicationInterface *object, +application_interface_desktop_new (ApplicationInterface *app_interface, GError **error) { - return (gchar*)Inkscape::Extension::Dbus::init_desktop(); + g_return_val_if_fail(ensure_desktop_valid(error), NULL); + return (gchar*)Inkscape::Extension::Dbus::init_desktop(); } gchar** -application_interface_get_desktop_list (ApplicationInterface *object) +application_interface_get_desktop_list (ApplicationInterface *app_interface) { return NULL; } gchar* -application_interface_get_active_desktop (ApplicationInterface *object, +application_interface_get_active_desktop (ApplicationInterface *app_interface, GError **error) { return NULL; } gboolean -application_interface_set_active_desktop (ApplicationInterface *object, +application_interface_set_active_desktop (ApplicationInterface *app_interface, gchar* document_name, GError **error) { @@ -123,14 +144,14 @@ application_interface_set_active_desktop (ApplicationInterface *object, } gboolean -application_interface_desktop_close_all (ApplicationInterface *object, +application_interface_desktop_close_all (ApplicationInterface *app_interface, GError **error) { return TRUE; } gboolean -application_interface_exit (ApplicationInterface *object, GError **error) +application_interface_exit (ApplicationInterface *app_interface, GError **error) { sp_file_exit(); return TRUE; @@ -140,14 +161,15 @@ application_interface_exit (ApplicationInterface *object, GError **error) DOCUMENT FUNCTIONS ****************************************************************************/ -gchar* application_interface_document_new (ApplicationInterface *object, +gchar* application_interface_document_new (ApplicationInterface *app_interface, GError **error) { - return (gchar*)Inkscape::Extension::Dbus::init_document(); + g_return_val_if_fail(ensure_desktop_not_present(error), NULL); + return (gchar*)Inkscape::Extension::Dbus::init_document(); } gchar* -application_interface_get_active_document(ApplicationInterface *object, +application_interface_get_active_document(ApplicationInterface *app_interface, GError **error) { gchar *result = (gchar*)Inkscape::Extension::Dbus::init_active_document(); @@ -158,13 +180,13 @@ application_interface_get_active_document(ApplicationInterface *object, } gchar** -application_interface_get_document_list (ApplicationInterface *object) +application_interface_get_document_list (ApplicationInterface *app_interface) { return NULL; } gboolean -application_interface_document_close_all (ApplicationInterface *object, +application_interface_document_close_all (ApplicationInterface *app_interface, GError **error) { return TRUE; -- cgit v1.2.3