+ GError *error = NULL;
+
+ userdir = g_getenv ("GNOME22_USER_DIR");
+ if (userdir)
+ ev_application->dot_dir = g_build_filename (userdir, "evince", NULL);
+ else
+ ev_application->dot_dir = g_build_filename (g_get_home_dir (),
+ ".gnome2",
+ "evince",
+ NULL);
+
+#ifdef G_OS_WIN32
+{
+ gchar *dir;
+
+ dir = g_win32_get_package_installation_directory_of_module (NULL);
+ ev_application->data_dir = g_build_filename (dir, "share", "evince", NULL);
+ g_free (dir);
+}
+#else
+ ev_application->data_dir = g_strdup (DATADIR);
+#endif
+
+ ev_application_init_session (ev_application);
+
+ ev_application_accel_map_load (ev_application);
+
+#ifdef ENABLE_DBUS
+{
+ static const char introspection_xml[] =
+ "<node>"
+ "<interface name='org.gnome.evince.Daemon'>"
+ "<method name='OpenURI'>"
+ "<arg type='s' name='uri' direction='in'/>"
+ "<arg type='a{sv}' name='args' direction='in'/>"
+ "<arg type='u' name='timestamp' direction='in'/>"
+ "</method>"
+ "</interface>"
+ "</node>";
+
+ static const GDBusInterfaceVTable interface_vtable = {
+ method_call_cb,
+ NULL,
+ NULL
+ };
+
+ GDBusNodeInfo *introspection_data;
+
+ ev_application->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+ if (ev_application->connection != NULL) {
+ introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
+ g_assert (introspection_data != NULL);
+
+
+ ev_application->registration_id =
+ g_dbus_connection_register_object (ev_application->connection,
+ APPLICATION_DBUS_OBJECT_PATH,
+ APPLICATION_DBUS_INTERFACE,
+ introspection_data->interfaces[0],
+ &interface_vtable,
+ ev_application, NULL,
+ &error);
+ if (ev_application->registration_id == 0) {
+ g_printerr ("Failed to register bus object: %s\n", error->message);
+ g_error_free (error);
+ }
+
+ } else {
+ g_printerr ("Failed to get bus connection: %s\n", error->message);
+ g_error_free (error);
+ }
+
+ ev_application->keys = ev_media_player_keys_new (ev_application->connection);
+
+ ev_application->scr_saver = totem_scrsaver_new (ev_application->connection);
+}
+#else
+ ev_application->scr_saver = totem_scrsaver_new ();
+#endif /* ENABLE_DBUS */
+}
+
+gboolean
+ev_application_has_window (EvApplication *application)
+{
+ GList *windows = ev_application_get_windows (application);
+ gboolean retval = windows != NULL;
+
+ g_list_free (windows);
+
+ return retval;
+}
+
+const gchar *
+ev_application_get_uri (EvApplication *application)
+{
+ return application->uri;
+}
+
+/**
+ * ev_application_get_media_keys:
+ * @application: The instance of the application.
+ *
+ * It gives you access to the media player keys handler object.
+ *
+ * Returns: A #EvMediaPlayerKeys.
+ */
+GObject *
+ev_application_get_media_keys (EvApplication *application)
+{
+#ifdef ENABLE_DBUS
+ return G_OBJECT (application->keys);
+#else
+ return NULL;
+#endif /* ENABLE_DBUS */