+
+#ifdef ENABLE_DBUS
+static gboolean
+ev_application_register_uri (EvApplication *application,
+ const gchar *uri,
+ GHashTable *args,
+ guint timestamp)
+{
+ DBusGProxy *proxy;
+ gchar *owner;
+ gboolean retval = TRUE;
+ GError *error = NULL;
+
+ if (!application->connection)
+ return TRUE;
+
+ proxy = dbus_g_proxy_new_for_name (application->connection,
+ "org.gnome.evince.Daemon",
+ "/org/gnome/evince/Daemon",
+ "org.gnome.evince.Daemon");
+ if (!dbus_g_proxy_call (proxy, "RegisterDocument", &error,
+ G_TYPE_STRING, uri,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &owner,
+ G_TYPE_INVALID)) {
+ g_warning ("Error registering document: %s\n", error->message);
+ g_error_free (error);
+ g_object_unref (proxy);
+
+ return TRUE;
+ }
+ g_object_unref (proxy);
+
+ if (*owner == ':') {
+ /* Already registered */
+ proxy = dbus_g_proxy_new_for_name_owner (application->connection,
+ owner,
+ APPLICATION_DBUS_OBJECT_PATH,
+ APPLICATION_DBUS_INTERFACE,
+ &error);
+ if (proxy) {
+ if (!dbus_g_proxy_call (proxy, "OpenURI", &error,
+ G_TYPE_STRING, uri,
+ dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), args,
+ G_TYPE_UINT, timestamp,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID)) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+ g_object_unref (proxy);
+ } else {
+ g_warning ("Error creating proxy: %s\n", error->message);
+ g_error_free (error);
+ }
+
+ /* Do not continue opening this document */
+ retval = FALSE;
+ }
+
+ g_free (owner);
+
+ return retval;
+}
+
+static void
+ev_application_unregister_uri (EvApplication *application,
+ const gchar *uri)
+{
+ DBusGProxy *proxy;
+ GError *error = NULL;
+
+ if (!application->connection)
+ return;
+
+ proxy = dbus_g_proxy_new_for_name (application->connection,
+ "org.gnome.evince.Daemon",
+ "/org/gnome/evince/Daemon",
+ "org.gnome.evince.Daemon");
+ if (!dbus_g_proxy_call (proxy, "UnregisterDocument", &error,
+ G_TYPE_STRING, uri,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID)) {
+ g_warning ("Error unregistering document: %s\n", error->message);
+ g_error_free (error);
+ }
+
+ g_object_unref (proxy);
+}
+#endif /* ENABLE_DBUS */
+
+static void
+ev_application_open_uri_in_window (EvApplication *application,
+ const char *uri,
+ EvWindow *ev_window,
+ GdkScreen *screen,
+ EvLinkDest *dest,
+ EvWindowRunMode mode,
+ const gchar *search_string,
+ guint timestamp)
+{
+ if (screen) {
+ ev_stock_icons_set_screen (screen);
+ gtk_window_set_screen (GTK_WINDOW (ev_window), screen);
+ }
+
+ /* We need to load uri before showing the window, so
+ we can restore window size without flickering */
+ ev_window_open_uri (ev_window, uri, dest, mode, search_string);
+
+ if (!GTK_WIDGET_REALIZED (GTK_WIDGET (ev_window)))
+ gtk_widget_realize (GTK_WIDGET (ev_window));
+
+#ifdef GDK_WINDOWING_X11
+ if (timestamp <= 0)
+ timestamp = gdk_x11_get_server_time (GTK_WIDGET (ev_window)->window);
+ gdk_x11_window_set_user_time (GTK_WIDGET (ev_window)->window, timestamp);
+
+ ev_document_fc_mutex_lock ();
+ gtk_window_present (GTK_WINDOW (ev_window));
+ ev_document_fc_mutex_unlock ();
+#else
+ ev_document_fc_mutex_lock ();
+ gtk_window_present_with_time (GTK_WINDOW (ev_window), timestamp);
+ ev_document_fc_mutex_unlock ();
+#endif /* GDK_WINDOWING_X11 */
+}
+
+/**
+ * ev_application_open_uri_at_dest:
+ * @application: The instance of the application.
+ * @uri: The uri to be opened.
+ * @screen: Thee screen where the link will be shown.
+ * @dest: The #EvLinkDest of the document.
+ * @mode: The run mode of the window.
+ * @timestamp: Current time value.
+ */