summaryrefslogtreecommitdiffstats
path: root/src/extension/dbus/application-interface.cpp
diff options
context:
space:
mode:
authorEric Greveson <eric@greveson.co.uk>2013-07-04 22:51:56 +0000
committerEric Greveson <eric@greveson.co.uk>2013-07-04 22:51:56 +0000
commit036013caefc09f34ef9b418e1ca148a821c777d6 (patch)
tree75c64b01ea3d650b820b926d091e42a737d6be56 /src/extension/dbus/application-interface.cpp
parentCode readability improvements and licence changes for action-context.* (diff)
downloadinkscape-036013caefc09f34ef9b418e1ca148a821c777d6.tar.gz
inkscape-036013caefc09f34ef9b418e1ca148a821c777d6.zip
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)
Diffstat (limited to 'src/extension/dbus/application-interface.cpp')
-rw-r--r--src/extension/dbus/application-interface.cpp48
1 files changed, 35 insertions, 13 deletions
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 <string.h>
#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;