aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2013-04-03 09:34:40 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2013-04-03 09:34:40 +0000
commit541afd326f6bd4f0a130e9fdce9a82b7350d37dc (patch)
treeabb574a55cb40014feaf9f465f18175ad7fa54ed /src
parentee249804d592b44897008e17b3108ba9a2c1325d (diff)
added the feature to save message as plain text (locale or UTF-8 encoding).
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3245 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r--src/filesel.c76
-rw-r--r--src/filesel.h6
-rw-r--r--src/summaryview.c30
3 files changed, 100 insertions, 12 deletions
diff --git a/src/filesel.c b/src/filesel.c
index abf6ad1f..593b54f6 100644
--- a/src/filesel.c
+++ b/src/filesel.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2013 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@
#include <gtk/gtkversion.h>
#include <gtk/gtkfilechooserdialog.h>
#include <gtk/gtkexpander.h>
+#include <gtk/gtkcombobox.h>
#include <gtk/gtkstock.h>
#ifdef G_OS_WIN32
@@ -45,7 +46,10 @@
static GSList *filesel_select_file_full (const gchar *title,
const gchar *file,
GtkFileChooserAction action,
- gboolean multiple);
+ gboolean multiple,
+ GSList *types,
+ gint default_type,
+ gint *selected_type);
static GtkWidget *filesel_create (const gchar *title,
GtkFileChooserAction action);
@@ -74,7 +78,7 @@ gchar *filesel_select_file(const gchar *title, const gchar *file,
GSList *list;
gchar *selected = NULL;
- list = filesel_select_file_full(title, file, action, FALSE);
+ list = filesel_select_file_full(title, file, action, FALSE, NULL, 0, NULL);
if (list) {
selected = (gchar *)list->data;
slist_free_strings(list->next);
@@ -87,7 +91,7 @@ gchar *filesel_select_file(const gchar *title, const gchar *file,
GSList *filesel_select_files(const gchar *title, const gchar *file,
GtkFileChooserAction action)
{
- return filesel_select_file_full(title, file, action, TRUE);
+ return filesel_select_file_full(title, file, action, TRUE, NULL, 0, NULL);
}
static void filesel_change_dir_for_action(GtkFileChooserAction action)
@@ -155,13 +159,16 @@ static void filesel_save_dir_for_action(GtkFileChooserAction action,
static GSList *filesel_select_file_full(const gchar *title, const gchar *file,
GtkFileChooserAction action,
- gboolean multiple)
+ gboolean multiple,
+ GSList *types,
+ gint default_type, gint *selected_type)
{
gchar *cwd;
GtkWidget *dialog;
gchar *prev_dir;
static gboolean save_expander_expanded = FALSE;
GSList *list = NULL;
+ GtkWidget *combo = NULL;
prev_dir = g_get_current_dir();
@@ -193,6 +200,27 @@ static GSList *filesel_select_file_full(const gchar *title, const gchar *file,
}
#endif
+ /* create types combo box */
+ if (types) {
+ GSList *cur;
+ GtkWidget *hbox;
+ GtkWidget *label;
+
+ hbox = gtk_hbox_new(FALSE, 12);
+ label = gtk_label_new(_("File type:"));
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+
+ combo = gtk_combo_box_new_text();
+ for (cur = types; cur != NULL; cur = cur->next) {
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), (const gchar *)cur->data);
+ }
+ gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0);
+
+ gtk_widget_show_all(hbox);
+ gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(dialog), hbox);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combo), default_type);
+ }
+
gtk_widget_show(dialog);
change_dir(prev_dir);
@@ -230,6 +258,10 @@ again:
inc_unlock();
+ if (combo && selected_type) {
+ *selected_type = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
+ }
+
if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
save_expander_expanded =
filesel_save_expander_get_expanded(dialog);
@@ -264,6 +296,38 @@ gchar *filesel_save_as(const gchar *file)
return filename;
}
+gchar *filesel_save_as_type(const gchar *file, GSList *types,
+ gint default_type, gint *selected_type)
+{
+ GSList *list;
+ gchar *filename = NULL;
+
+ list = filesel_select_file_full(_("Save as"), file,
+ GTK_FILE_CHOOSER_ACTION_SAVE, FALSE,
+ types, default_type, selected_type);
+ if (list) {
+ filename = (gchar *)list->data;
+ slist_free_strings(list->next);
+ }
+ g_slist_free(list);
+
+#if !GTK_CHECK_VERSION(2, 8, 0)
+ if (filename && is_file_exist(filename)) {
+ AlertValue aval;
+
+ aval = alertpanel(_("Overwrite existing file"),
+ _("The file already exists. Do you want to replace it?"),
+ GTK_STOCK_YES, GTK_STOCK_NO, NULL);
+ if (G_ALERTDEFAULT != aval) {
+ g_free(filename);
+ filename = NULL;
+ }
+ }
+#endif
+
+ return filename;
+}
+
gchar *filesel_select_dir(const gchar *dir)
{
GSList *list;
@@ -271,7 +335,7 @@ gchar *filesel_select_dir(const gchar *dir)
list = filesel_select_file_full(_("Select folder"), dir,
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- FALSE);
+ FALSE, NULL, 0, NULL);
if (list) {
selected = (gchar *)list->data;
slist_free_strings(list->next);
diff --git a/src/filesel.h b/src/filesel.h
index b089a89a..c694ef24 100644
--- a/src/filesel.h
+++ b/src/filesel.h
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2013 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,6 +31,10 @@ GSList *filesel_select_files (const gchar *title,
GtkFileChooserAction action);
gchar *filesel_save_as (const gchar *file);
+gchar *filesel_save_as_type (const gchar *file,
+ GSList *types,
+ gint default_type,
+ gint *selected_type);
gchar *filesel_select_dir (const gchar *dir);
#endif /* __FILESEL_H__ */
diff --git a/src/summaryview.c b/src/summaryview.c
index d0f35735..c22a431c 100644
--- a/src/summaryview.c
+++ b/src/summaryview.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2013 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -3891,6 +3891,10 @@ void summary_save_as(SummaryView *summaryview)
MsgInfo *msginfo = NULL;
gchar *filename;
gchar *src, *dest;
+ GSList *types;
+ gint selected_type = 0;
+ gint result;
+ gboolean all_headers;
if (!summaryview->selected) return;
if (!gtkut_tree_row_reference_get_iter
@@ -3908,14 +3912,31 @@ void summary_save_as(SummaryView *summaryview)
}
subst_for_filename(filename);
- dest = filesel_save_as(filename);
+ types = g_slist_append(NULL, _("Original (EML/RFC 822)"));
+ types = g_slist_append(types, _("Text"));
+ types = g_slist_append(types, _("Text (UTF-8)"));
+ dest = filesel_save_as_type(filename, types, 0, &selected_type);
+ g_slist_free(types);
g_free(filename);
if (!dest)
return;
- src = procmsg_get_message_file(msginfo);
- if (copy_file(src, dest, TRUE) < 0) {
+ debug_print("summary_save_as: selected_type: %d\n", selected_type);
+
+ all_headers = summaryview->messageview->textview->show_all_headers;
+
+ if (selected_type == 1) {
+ result = procmsg_save_message_as_text(msginfo, dest, conv_get_locale_charset_str(), all_headers);
+ } else if (selected_type == 2) {
+ result = procmsg_save_message_as_text(msginfo, dest, NULL, all_headers);
+ } else {
+ src = procmsg_get_message_file(msginfo);
+ result = copy_file(src, dest, TRUE);
+ g_free(src);
+ }
+
+ if (result < 0) {
gchar *utf8_dest;
utf8_dest = conv_filename_to_utf8(dest);
@@ -3923,7 +3944,6 @@ void summary_save_as(SummaryView *summaryview)
g_basename(utf8_dest));
g_free(utf8_dest);
}
- g_free(src);
g_free(dest);
}