+#define APPLICATION_SERVICE_NAME "org.gnome.evince.ApplicationService"
+
+#ifdef ENABLE_DBUS
+gboolean
+ev_application_register_service (EvApplication *application)
+{
+ DBusGConnection *connection;
+ DBusGProxy *driver_proxy;
+ GError *err = NULL;
+ guint request_name_result;
+
+ connection = dbus_g_bus_get (DBUS_BUS_STARTER, &err);
+ if (connection == NULL) {
+ g_warning ("Service registration failed.");
+ g_error_free (err);
+
+ return FALSE;
+ }
+
+ driver_proxy = dbus_g_proxy_new_for_name (connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+
+ if (!org_freedesktop_DBus_request_name (driver_proxy,
+ APPLICATION_SERVICE_NAME,
+ 0, &request_name_result, &err)) {
+ g_warning ("Service registration failed.");
+ g_clear_error (&err);
+ }
+
+ if (request_name_result == DBUS_REQUEST_NAME_REPLY_EXISTS) {
+ return FALSE;
+ }
+
+#if DBUS_VERSION == 33
+ dbus_g_object_class_install_info (G_OBJECT_GET_CLASS (application),
+ &dbus_glib_ev_application_object_info);
+#else
+ dbus_g_object_type_install_info (EV_TYPE_APPLICATION,
+ &dbus_glib_ev_application_object_info);
+#endif
+#ifdef ENABLE_COMICS
+ GtkFileFilter *comics_filter;
+#endif
+
+ dbus_g_connection_register_g_object (connection,
+ "/org/gnome/evince/Evince",
+ G_OBJECT (application));
+
+ return TRUE;
+}
+#endif /* ENABLE_DBUS */
+