+static void mimeview_save_all(MimeView *mimeview)
+{
+ gchar *dirname;
+ gchar *defname = NULL;
+ MimeInfo *partinfo;
+ MimeInfo *attachment;
+ gchar buf[1024];
+
+ if (!mimeview->opened) return;
+ if (!mimeview->file) return;
+
+ partinfo = gtk_ctree_node_get_row_data
+ (GTK_CTREE(mimeview->ctree), mimeview->opened);
+
+ g_return_if_fail(partinfo != NULL);
+
+ dirname = filesel_select_file(_("Save as"), defname);
+
+ if (!dirname) return;
+
+ /* return to first children */
+ attachment = partinfo->parent->children->next;
+
+ /* for each attachment, extract it in the selected dir. */
+ while(attachment != NULL)
+ {
+ if(attachment->filename)
+ {
+ gchar *attachname = g_strdup(attachment->filename);
+
+ subst_chars(attachname, "/\\", G_DIR_SEPARATOR);
+ subst_chars(attachname, ":?*&|<>\t\r\n", '_');
+ g_snprintf(buf, sizeof(buf), "%s%s",
+ dirname,
+ (attachname[0] == G_DIR_SEPARATOR)
+ ? &attachname[1]
+ : attachname );
+ g_free(attachname);
+ make_dir_hier(g_dirname(buf));
+
+ if (is_file_exist(buf))
+ {
+ AlertValue aval;
+
+ aval = alertpanel(_("Overwrite"),
+ _("Overwrite existing file?"),
+ _("OK"), _("Cancel"), NULL);
+
+ if (G_ALERTDEFAULT != aval) return;
+ }
+
+ if (procmime_get_part(buf, mimeview->file, attachment) < 0)
+ alertpanel_error
+ (_("Can't save the part of multipart message."));
+ }
+
+ attachment = attachment->next;
+ }
+}
+