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