summaryrefslogtreecommitdiffstats
path: root/src/extension/dbus/application-interface.cpp
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-07-17 05:13:49 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-07-17 05:13:49 +0000
commitdd59aa3bb2cab030296a4622e5166f0e3f8d5445 (patch)
treea86612c94d3ddce3edf696ea17fefb58b0accccf /src/extension/dbus/application-interface.cpp
parentTemporary fixes/kludges. (diff)
parentShape calculations. re-introduce grid of a smaller size. (http://article.gman... (diff)
downloadinkscape-dd59aa3bb2cab030296a4622e5166f0e3f8d5445.tar.gz
inkscape-dd59aa3bb2cab030296a4622e5166f0e3f8d5445.zip
Merge from trunk.
(bzr r12380.1.17)
Diffstat (limited to 'src/extension/dbus/application-interface.cpp')
-rw-r--r--src/extension/dbus/application-interface.cpp59
1 files changed, 47 insertions, 12 deletions
diff --git a/src/extension/dbus/application-interface.cpp b/src/extension/dbus/application-interface.cpp
index 8ee7bd12f..c0bc19d90 100644
--- a/src/extension/dbus/application-interface.cpp
+++ b/src/extension/dbus/application-interface.cpp
@@ -18,6 +18,8 @@
#include "application-interface.h"
#include <string.h>
#include "dbus-init.h"
+#include "file.h"
+#include "inkscape.h"
G_DEFINE_TYPE(ApplicationInterface, application_interface, G_TYPE_OBJECT)
@@ -37,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)
@@ -94,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)
{
@@ -122,15 +144,16 @@ 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;
}
@@ -138,20 +161,32 @@ 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 *app_interface,
+ GError **error)
+{
+ 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**
-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;