+ uri = ev_link_action_get_uri (action);
+ escaped = gnome_vfs_escape_host_and_path_string (uri);
+
+ gnome_vfs_url_show (escaped);
+ g_free (escaped);
+}
+
+static void
+open_remote_link (EvWindow *window, EvLinkAction *action)
+{
+ gchar *uri;
+ gchar *dir;
+
+ dir = g_path_get_dirname (window->priv->uri);
+
+ uri = g_build_filename (dir, ev_link_action_get_filename (action),
+ NULL);
+ g_free (dir);
+
+ ev_application_open_uri_at_dest (EV_APP, uri,
+ ev_link_action_get_dest (action),
+ GDK_CURRENT_TIME);
+
+ g_free (uri);
+}
+
+static void
+do_action_named (EvWindow *window, EvLinkAction *action)
+{
+ const gchar *name = ev_link_action_get_name (action);
+
+ if (g_ascii_strcasecmp (name, "FirstPage") == 0) {
+ ev_window_cmd_go_first_page (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "PrevPage") == 0) {
+ ev_window_cmd_go_previous_page (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "NextPage") == 0) {
+ ev_window_cmd_go_next_page (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "LastPage") == 0) {
+ ev_window_cmd_go_last_page (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "GoToPage") == 0) {
+ ev_window_cmd_focus_page_selector (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "Find") == 0) {
+ ev_window_cmd_edit_find (NULL, window);
+ } else {
+ g_warning ("Unimplemented named action: %s, please post a bug report with a testcase.",
+ name);
+ }
+}
+
+static void
+view_external_link_cb (EvView *view, EvLinkAction *action, EvWindow *window)
+{
+ switch (ev_link_action_get_action_type (action)) {
+ case EV_LINK_ACTION_TYPE_EXTERNAL_URI:
+ launch_external_uri (window, action);
+ break;
+ case EV_LINK_ACTION_TYPE_LAUNCH:
+ launch_action (window, action);
+ break;
+ case EV_LINK_ACTION_TYPE_GOTO_REMOTE:
+ open_remote_link (window, action);
+ break;
+ case EV_LINK_ACTION_TYPE_NAMED:
+ do_action_named (window, action);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static void
+ev_view_popup_cmd_open_link (GtkAction *action, EvWindow *window)
+{
+ ev_view_handle_link (EV_VIEW (window->priv->view), window->priv->link);
+}
+
+static void
+ev_view_popup_cmd_copy_link_address (GtkAction *action, EvWindow *window)
+{
+ GtkClipboard *clipboard;
+ EvLinkAction *ev_action;
+ const gchar *uri;
+
+ ev_action = ev_link_get_action (window->priv->link);
+ if (!ev_action)
+ return;
+
+ uri = ev_link_action_get_uri (ev_action);
+
+ clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window),
+ GDK_SELECTION_CLIPBOARD);
+ gtk_clipboard_set_text (clipboard, uri, -1);
+}
+
+static void
+ev_attachment_popup_cmd_open_attachment (GtkAction *action, EvWindow *window)
+{
+ GList *l;
+
+ if (!window->priv->attach_list)
+ return;
+
+ for (l = window->priv->attach_list; l && l->data; l = g_list_next (l)) {
+ EvAttachment *attachment;
+ GError *error = NULL;
+
+ attachment = (EvAttachment *) l->data;
+
+ ev_attachment_open (attachment, &error);
+
+ if (error) {
+ ev_window_error_dialog (GTK_WINDOW (window),
+ _("Unable to open attachment"),
+ error);
+ g_error_free (error);
+ }
+ }
+}
+
+static void
+attachment_save_dialog_response_cb (GtkWidget *fc,
+ gint response_id,
+ EvWindow *ev_window)
+{
+ gchar *uri;
+ GList *l;
+ GtkFileChooserAction fc_action;
+ gboolean is_dir;
+
+ if (response_id != GTK_RESPONSE_OK) {
+ gtk_widget_destroy (fc);
+ return;
+ }
+
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
+
+ g_object_get (G_OBJECT (fc), "action", &fc_action, NULL);
+ is_dir = (fc_action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+
+ for (l = ev_window->priv->attach_list; l && l->data; l = g_list_next (l)) {
+ EvAttachment *attachment;
+ gchar *filename;
+ GError *error = NULL;
+
+ attachment = (EvAttachment *) l->data;
+
+ if (is_dir) {
+ filename = g_strjoin ("/", uri,
+ ev_attachment_get_name (attachment),
+ NULL);
+ } else {
+ filename = g_strdup (uri);
+ }
+
+ ev_attachment_save (attachment, filename, &error);
+ g_free (filename);
+
+ if (error) {
+ ev_window_error_dialog (GTK_WINDOW (fc),
+ _("The attachment could not be saved."),
+ error);
+ g_error_free (error);
+ }