COMPOSE_INSERT_NO_FILE
} ComposeInsertResult;
-typedef enum
-{
- COMPOSE_QUIT_EDITING,
- COMPOSE_KEEP_EDITING,
- COMPOSE_AUTO_SAVE
-} ComposeDraftAction;
-
typedef enum
{
COMPOSE_WRITE_FOR_SEND,
static GList *compose_list = NULL;
-Compose *compose_generic_new (PrefsAccount *account,
+static Compose *compose_generic_new (PrefsAccount *account,
const gchar *to,
FolderItem *item,
GPtrArray *attach_files,
ComposeMode mode,
gboolean batch);
+static void compose_entry_mark_default_to (Compose *compose,
+ const gchar *address);
+static Compose *compose_followup_and_reply_to (MsgInfo *msginfo,
+ gboolean quote,
+ gboolean to_all,
+ gboolean to_sender,
+ const gchar *body);
+static Compose *compose_forward_multiple (PrefsAccount *account,
+ GSList *msginfo_list);
+static Compose *compose_reply (MsgInfo *msginfo,
+ gboolean quote,
+ gboolean to_all,
+ gboolean to_ml,
+ gboolean to_sender,
+ const gchar *body);
+static Compose *compose_reply_mode (ComposeMode mode,
+ GSList *msginfo_list,
+ gchar *body);
+static void compose_template_apply_fields(Compose *compose, Template *tmpl);
+static void compose_update_privacy_systems_menu(Compose *compose);
+
static GtkWidget *compose_account_option_menu_create
(Compose *compose);
static void compose_set_out_encoding (Compose *compose);
const gchar *file);
static gint compose_remove_reedit_target (Compose *compose,
gboolean force);
-void compose_remove_draft (Compose *compose);
+static void compose_remove_draft (Compose *compose);
static gint compose_queue_sub (Compose *compose,
gint *msgnum,
FolderItem **item,
gboolean followup_and_reply_to,
const gchar *body);
-gboolean compose_headerentry_changed_cb (GtkWidget *entry,
+static gboolean compose_headerentry_changed_cb (GtkWidget *entry,
ComposeHeaderEntry *headerentry);
-gboolean compose_headerentry_key_press_event_cb(GtkWidget *entry,
+static gboolean compose_headerentry_key_press_event_cb(GtkWidget *entry,
GdkEventKey *event,
ComposeHeaderEntry *headerentry);
static GtkItemFactoryEntry compose_entries[] =
{
{N_("/_Message"), NULL, NULL, 0, "<Branch>"},
- {N_("/_Message/_Send"), "<control>Return",
+ {N_("/_Message/S_end"), "<control>Return",
compose_send_cb, 0, NULL},
{N_("/_Message/Send _later"), "<shift><control>S",
compose_send_later_cb, 0, NULL},
}
}
-Compose *compose_reply_mode(ComposeMode mode, GSList *msginfo_list, gchar *body)
+static Compose *compose_reply_mode(ComposeMode mode, GSList *msginfo_list, gchar *body)
{
MsgInfo *msginfo;
guint list_len;
return compose;
}
-Compose *compose_reply(MsgInfo *msginfo, gboolean quote, gboolean to_all,
+static Compose *compose_reply(MsgInfo *msginfo, gboolean quote, gboolean to_all,
gboolean to_ml, gboolean to_sender,
const gchar *body)
{
to_sender, FALSE, body);
}
-Compose *compose_followup_and_reply_to(MsgInfo *msginfo, gboolean quote,
+static Compose *compose_followup_and_reply_to(MsgInfo *msginfo, gboolean quote,
gboolean to_all,
gboolean to_sender,
const gchar *body)
#undef INSERT_FW_HEADER
-Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_list)
+static Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_list)
{
Compose *compose;
GtkTextView *textview;
}
}
-void compose_entry_mark_default_to(Compose *compose, const gchar *mailto)
+static void compose_entry_mark_default_to(Compose *compose, const gchar *mailto)
{
static GdkColor yellow;
static GdkColor black;
gboolean has_binary = FALSE;
if (!is_file_exist(file)) {
+ gchar *file_from_uri = g_filename_from_uri(file, NULL, NULL);
+ gboolean result = FALSE;
+ if (file_from_uri && is_file_exist(file_from_uri)) {
+ result = compose_attach_append(
+ compose, file_from_uri,
+ filename,
+ content_type);
+ }
+ g_free(file_from_uri);
+ if (result)
+ return TRUE;
alertpanel_error("File %s doesn't exist\n", filename);
return FALSE;
}
quote_str = compose_get_quote_str(buffer, &iter, "e_len);
if (quote_str) {
- if (!wrap_quote) {
- if (startq_offset == -1) {
- startq_offset = gtk_text_iter_get_offset(&iter);
- }
- goto colorize;
- }
debug_print("compose_beautify_paragraph(): quote_str = '%s'\n", quote_str);
if (startq_offset == -1)
startq_offset = gtk_text_iter_get_offset(&iter);
else
quotelevel = 2;
}
+ if (!wrap_quote) {
+ goto colorize;
+ }
} else {
if (startq_offset == -1)
noq_offset = gtk_text_iter_get_offset(&iter);
gtk_text_buffer_get_iter_at_offset(
buffer, &startquote, startq_offset);
endquote = iter;
+
switch (quotelevel) {
case 0: gtk_text_buffer_apply_tag_by_name(
buffer, "quote0", &startquote, &endquote);
return 0;
}
-void compose_remove_draft(Compose *compose)
+static void compose_remove_draft(Compose *compose)
{
FolderItem *drafts;
MsgInfo *msginfo = compose->targetinfo;
return header_scrolledwin ;
}
-GtkWidget *compose_create_attach(Compose *compose)
+static GtkWidget *compose_create_attach(Compose *compose)
{
GtkWidget *attach_scrwin;
GtkWidget *attach_clist;
compose->tooltips = gtk_tooltips_new();
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "compose");
gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
gtk_widget_set_size_request(window, -1, prefs_common.compose_height);
action_update_compose_menu(ifactory, "/Tools/Actions", compose);
}
-void compose_update_privacy_systems_menu(Compose *compose)
+static void compose_update_privacy_systems_menu(Compose *compose)
{
static gchar *branch_path = "/Options/Privacy System";
GtkItemFactory *ifactory;
compose_changed_cb(NULL, compose);
}
-void compose_template_apply_fields(Compose *compose, Template *tmpl)
+static void compose_template_apply_fields(Compose *compose, Template *tmpl)
{
MsgInfo* dummyinfo = NULL;
MsgInfo *msginfo = NULL;
debug_print("Creating attach_property window...\n");
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "compose_attach_property");
gtk_widget_set_size_request(window, 480, -1);
gtk_container_set_border_width(GTK_CONTAINER(window), 8);
gtk_window_set_title(GTK_WINDOW(window), _("Properties"));
toolbar_main_set_sensitive(mainwindow_get_mainwindow());
}
-void compose_draft (gpointer data)
+void compose_draft (gpointer data, guint action)
{
- compose_draft_cb(data, COMPOSE_QUIT_EDITING, NULL);
+ compose_draft_cb(data, action, NULL);
+}
+
+#define DRAFTED_AT_EXIT "drafted_at_exit"
+void compose_clear_exit_drafts(void)
+{
+ gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+ DRAFTED_AT_EXIT, NULL);
+ if (is_file_exist(filepath))
+ g_unlink(filepath);
+
+ g_free(filepath);
+}
+
+static void compose_register_draft(MsgInfo *info)
+{
+ gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+ DRAFTED_AT_EXIT, NULL);
+ FILE *fp = fopen(filepath, "ab");
+
+ if (fp) {
+ fprintf(fp, "%s\t%d\n", folder_item_get_identifier(info->folder),
+ info->msgnum);
+ fclose(fp);
+ }
+
+ g_free(filepath);
+}
+
+void compose_reopen_exit_drafts(void)
+{
+ gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+ DRAFTED_AT_EXIT, NULL);
+ FILE *fp = fopen(filepath, "rb");
+ gchar buf[1024];
+
+ if (fp) {
+ while (fgets(buf, sizeof(buf), fp)) {
+ gchar **parts = g_strsplit(buf, "\t", 2);
+ const gchar *folder = parts[0];
+ int msgnum = parts[1] ? atoi(parts[1]):-1;
+
+ if (folder && *folder && msgnum > -1) {
+ FolderItem *item = folder_find_item_from_identifier(folder);
+ MsgInfo *info = folder_item_get_msginfo(item, msgnum);
+ if (info)
+ compose_reedit(info, FALSE);
+ }
+ g_strfreev(parts);
+ }
+ fclose(fp);
+ }
+ g_free(filepath);
+ compose_clear_exit_drafts();
}
static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
procmsg_msginfo_set_flags(newmsginfo, 0,
MSG_HAS_ATTACHMENT);
+ if (action == COMPOSE_DRAFT_FOR_EXIT) {
+ compose_register_draft(newmsginfo);
+ }
procmsg_msginfo_free(newmsginfo);
}
folder_item_scan(draft);
- if (action == COMPOSE_QUIT_EDITING) {
+ if (action == COMPOSE_QUIT_EDITING || action == COMPOSE_DRAFT_FOR_EXIT) {
lock = FALSE;
g_mutex_unlock(compose->mutex); /* must be done before closing */
compose_close(compose);
&& gtk_drag_get_source_widget(context) !=
summary_get_main_widget(mainwindow_get_mainwindow()->summaryview)) {
list = uri_list_extract_filenames((const gchar *)data->data);
- for (tmp = list; tmp != NULL; tmp = tmp->next)
+ for (tmp = list; tmp != NULL; tmp = tmp->next) {
+ gchar *utf8_filename = conv_filename_to_utf8((const gchar *)tmp->data);
compose_attach_append
(compose, (const gchar *)tmp->data,
- (const gchar *)tmp->data, NULL);
+ utf8_filename, NULL);
+ g_free(utf8_filename);
+ }
if (list) compose_changed_cb(NULL, compose);
list_free_strings(list);
g_list_free(list);
compose->remove_references = FALSE;
}
-gboolean compose_headerentry_key_press_event_cb(GtkWidget *entry,
+static gboolean compose_headerentry_key_press_event_cb(GtkWidget *entry,
GdkEventKey *event,
ComposeHeaderEntry *headerentry)
{
return FALSE;
}
-gboolean compose_headerentry_changed_cb(GtkWidget *entry,
+static gboolean compose_headerentry_changed_cb(GtkWidget *entry,
ComposeHeaderEntry *headerentry)
{
if (strlen(gtk_entry_get_text(GTK_ENTRY(entry))) != 0) {