COMPOSE_CALL_GTK_STEXT_DELETE_TO_LINE_END
} ComposeCallGtkSTextAction;
+typedef enum
+{
+ PRIORITY_HIGHEST = 1,
+ PRIORITY_HIGH,
+ PRIORITY_NORMAL,
+ PRIORITY_LOW,
+ PRIORITY_LOWEST
+} PriorityLevel;
+
#define B64_LINE_SIZE 57
#define B64_BUFFSIZE 77
(Compose *compose);
static void compose_set_template_menu (Compose *compose);
static void compose_template_apply (Compose *compose,
- Template *tmpl);
+ Template *tmpl,
+ gboolean replace);
static void compose_destroy (Compose *compose);
static void compose_entries_set (Compose *compose,
static PrefsAccount *compose_current_mail_account(void);
/* static gint compose_send (Compose *compose); */
+static gboolean compose_check_for_valid_recipient
+ (Compose *compose);
+static gboolean compose_check_entries (Compose *compose,
+ gboolean check_subject);
static gint compose_write_to_file (Compose *compose,
const gchar *file,
gboolean is_draft);
static gint compose_write_body_to_file (Compose *compose,
const gchar *file);
-static gint compose_save_to_outbox (Compose *compose,
- const gchar *file);
static gint compose_remove_reedit_target (Compose *compose);
static gint compose_queue (Compose *compose,
gint *msgnum,
FolderItem **item);
+static gint compose_queue_sub (Compose *compose,
+ gint *msgnum,
+ FolderItem **item,
+ gboolean check_subject);
static void compose_write_attach (Compose *compose,
FILE *fp);
static gint compose_write_headers (Compose *compose,
static void compose_create_header_entry (Compose *compose);
static void compose_add_header_entry (Compose *compose, gchar *header, gchar *text);
+static void compose_update_priority_menu_item(Compose * compose);
/* callback functions */
static void compose_cut_cb (Compose *compose);
static void compose_copy_cb (Compose *compose);
static void compose_paste_cb (Compose *compose);
+static void compose_paste_as_quote_cb (Compose *compose);
static void compose_allsel_cb (Compose *compose);
static void compose_gtk_stext_action_cb (Compose *compose,
#endif
static void compose_toggle_return_receipt_cb(gpointer data, guint action,
GtkWidget *widget);
+static void compose_set_priority_cb (gpointer data,
+ guint action,
+ GtkWidget *widget);
static void compose_attach_drag_received_cb (GtkWidget *widget,
GdkDragContext *drag_context,
Compose *compose);
static void newsgroups_activated (GtkWidget *widget,
Compose *compose);
-static void subject_activated (GtkWidget *widget,
- Compose *compose);
static void cc_activated (GtkWidget *widget,
Compose *compose);
static void bcc_activated (GtkWidget *widget,
Compose *compose);
static void followupto_activated (GtkWidget *widget,
Compose *compose);
+static void subject_activated (GtkWidget *widget,
+ Compose *compose);
#endif
+static void text_activated (GtkWidget *widget,
+ Compose *compose);
+static void text_inserted (GtkWidget *widget,
+ const gchar *text,
+ gint length,
+ gint *position,
+ Compose *compose);
static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
gboolean to_all,
gboolean ignore_replyto,
static void compose_check_forwards_go (Compose *compose);
#endif
-static gboolean compose_send_control_enter (Compose *compose);
-static void text_activated (GtkWidget *widget,
- Compose *compose);
+static gboolean compose_send_control_enter (Compose *compose);
static GtkItemFactoryEntry compose_popup_entries[] =
{
{N_("/_Edit/Cu_t"), "<control>X", compose_cut_cb, 0, NULL},
{N_("/_Edit/_Copy"), "<control>C", compose_copy_cb, 0, NULL},
{N_("/_Edit/_Paste"), "<control>V", compose_paste_cb, 0, NULL},
+ {N_("/_Edit/Paste as _quotation"),
+ NULL, compose_paste_as_quote_cb, 0, NULL},
{N_("/_Edit/Select _all"), "<control>A", compose_allsel_cb, 0, NULL},
{N_("/_Edit/A_dvanced"), NULL, NULL, 0, "<Branch>"},
{N_("/_Edit/A_dvanced/Move a character backward"),
"<control><alt>L", compose_wrap_line_all, 0, NULL},
{N_("/_Edit/Edit with e_xternal editor"),
"<shift><control>X", compose_ext_editor_cb, 0, NULL},
- {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Edit/Actio_ns"), NULL, NULL, 0, "<Branch>"},
#if USE_PSPELL
{N_("/_Spelling"), NULL, NULL, 0, "<Branch>"},
{N_("/_Spelling/_Check all or check selection"),
{N_("/_Message/Si_gn"), NULL, compose_toggle_sign_cb , 0, "<ToggleItem>"},
{N_("/_Message/_Encrypt"), NULL, compose_toggle_encrypt_cb, 0, "<ToggleItem>"},
#endif /* USE_GPGME */
+ {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
+ {N_("/_Message/Priority"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Message/Priority/Highest"), NULL, compose_set_priority_cb, PRIORITY_HIGHEST, "<RadioItem>"},
+ {N_("/_Message/Priority/High"), NULL, compose_set_priority_cb, PRIORITY_HIGH, "/Message/Priority/Highest"},
+ {N_("/_Message/Priority/Normal"), NULL, compose_set_priority_cb, PRIORITY_NORMAL, "/Message/Priority/Highest"},
+ {N_("/_Message/Priority/Low"), NULL, compose_set_priority_cb, PRIORITY_LOW, "/Message/Priority/Highest"},
+ {N_("/_Message/Priority/Lowest"), NULL, compose_set_priority_cb, PRIORITY_LOWEST, "/Message/Priority/Highest"},
{N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Message/_Request Return Receipt"), NULL, compose_toggle_return_receipt_cb, 0, "<ToggleItem>"},
- {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
- {N_("/_Tool/Show _ruler"), NULL, compose_toggle_ruler_cb, 0, "<ToggleItem>"},
- {N_("/_Tool/_Address book"), "<shift><control>A", compose_address_cb , 0, NULL},
- {N_("/_Tool/_Template"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Tools/Show _ruler"), NULL, compose_toggle_ruler_cb, 0, "<ToggleItem>"},
+ {N_("/_Tools/_Address book"), "<shift><control>A", compose_address_cb , 0, NULL},
+ {N_("/_Tools/_Template"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
{N_("/_Help"), NULL, NULL, 0, "<Branch>"},
{N_("/_Help/_About"), NULL, about_show, 0, NULL}
};
return compose_generic_new(account, NULL, NULL);
}
-Compose *compose_bounce(PrefsAccount *account, MsgInfo *msginfo)
+Compose *compose_redirect(PrefsAccount *account, MsgInfo *msginfo)
{
Compose *c;
gchar *filename;
if (filename == NULL)
return NULL;
- c->bounce_filename = filename;
+ c->redirect_filename = filename;
if (msginfo->subject)
gtk_entry_set_text(GTK_ENTRY(c->subject_entry),
menu_set_sensitive(ifactory, "/Message/Encrypt", FALSE);
#endif
menu_set_sensitive(ifactory, "/Message/Request Return Receipt", FALSE);
- menu_set_sensitive(ifactory, "/Tool/Template", FALSE);
+ menu_set_sensitive(ifactory, "/Tools/Template", FALSE);
gtk_widget_set_sensitive(c->insert_btn, FALSE);
gtk_widget_set_sensitive(c->attach_btn, FALSE);
Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderItem *item)
{
Compose *compose;
+ GtkSText *text;
+ GtkItemFactory *ifactory;
+ gboolean grab_focus_on_last = TRUE;
if (item && item->prefs && item->prefs->enable_default_account)
account = account_find_from_id(item->prefs->default_account);
g_return_val_if_fail(account != NULL, NULL);
compose = compose_create(account, COMPOSE_NEW);
+ ifactory = gtk_item_factory_from_widget(compose->menubar);
+
compose->replyinfo = NULL;
+ text = GTK_STEXT(compose->text);
+ gtk_stext_freeze(text);
+
if (prefs_common.auto_sig)
compose_insert_sig(compose);
- gtk_editable_set_position(GTK_EDITABLE(compose->text), 0);
- gtk_stext_set_point(GTK_STEXT(compose->text), 0);
+ gtk_editable_set_position(GTK_EDITABLE(text), 0);
+ gtk_stext_set_point(text, 0);
+
+ gtk_stext_thaw(text);
+
+ /* workaround for initial XIM problem */
+ gtk_widget_grab_focus(compose->text);
+ gtkut_widget_wait_for_draw(compose->text);
+
if (account->protocol != A_NNTP) {
if (mailto) {
} else if(item && item->prefs->enable_default_to) {
compose_entry_append(compose, item->prefs->default_to, COMPOSE_TO);
+ compose_entry_select(compose, item->prefs->default_to);
+ grab_focus_on_last = FALSE;
}
if (item && item->ret_rcpt) {
- GtkItemFactory *ifactory;
-
- ifactory = gtk_item_factory_from_widget(compose->menubar);
menu_set_toggle(ifactory, "/Message/Request Return Receipt", TRUE);
}
} else {
if (mailto) {
compose_entry_append(compose, mailto, COMPOSE_NEWSGROUPS);
}
+ /*
+ * CLAWS: just don't allow return receipt request, even if the user
+ * may want to send an email. simple but foolproof.
+ */
+ menu_set_sensitive(ifactory, "/Message/Request Return Receipt", FALSE);
}
compose_show_first_last_header(compose, TRUE);
gtk_entry_set_text(GTK_ENTRY(compose->savemsg_entry), folderidentifier);
g_free(folderidentifier);
}
-
- gtk_widget_grab_focus(compose->header_last->entry);
+
+ /* Grab focus on last header only if no default_to was set */
+ if(grab_focus_on_last)
+ gtk_widget_grab_focus(compose->header_last->entry);
if (prefs_common.auto_exteditor)
compose_exec_ext_editor(compose);
compose_add_header_entry(compose, header, (gchar *)address);
}
+void compose_entry_select (Compose *compose, const gchar *mailto)
+{
+ GSList *header_list;
+
+ for (header_list = compose->header_list; header_list != NULL; header_list = header_list->next) {
+ GtkEntry * entry = GTK_ENTRY(((ComposeHeaderEntry *)header_list->data)->entry);
+
+ if (gtk_entry_get_text(entry) && !g_strcasecmp(gtk_entry_get_text(entry), mailto)) {
+ gtk_entry_select_region(entry, 0, -1);
+ gtk_widget_grab_focus(GTK_WIDGET(entry));
+ }
+ }
+}
+
static void compose_entries_set(Compose *compose, const gchar *mailto)
{
gchar *subject = NULL;
{"Followup-To:", NULL, FALSE},
{"X-Mailing-List:", NULL, FALSE},
{"X-BeenThere:", NULL, FALSE},
+ {"X-Priority:", NULL, FALSE},
{NULL, NULL, FALSE}};
enum
H_NEWSGROUPS = 4,
H_FOLLOWUP_TO = 5,
H_X_MAILING_LIST = 6,
- H_X_BEENTHERE = 7
+ H_X_BEENTHERE = 7,
+ H_X_PRIORITY = 8
};
FILE *fp;
hentry[H_FOLLOWUP_TO].body = NULL;
}
+ if (compose->mode == COMPOSE_REEDIT)
+ if (hentry[H_X_PRIORITY].body != NULL) {
+ gint priority;
+
+ priority = atoi(hentry[H_X_PRIORITY].body);
+ g_free(hentry[H_X_PRIORITY].body);
+
+ hentry[H_X_PRIORITY].body = NULL;
+
+ if (priority < PRIORITY_HIGHEST ||
+ priority > PRIORITY_LOWEST)
+ priority = PRIORITY_NORMAL;
+
+ compose->priority = priority;
+ }
+
if (compose->mode == COMPOSE_REEDIT && msginfo->inreplyto)
compose->inreplyto = g_strdup(msginfo->inreplyto);
else if (compose->mode != COMPOSE_REEDIT &&
const gchar *body)
{
GtkSText *text = GTK_STEXT(compose->text);
+ static MsgInfo dummyinfo;
gchar *quote_str = NULL;
gchar *buf;
gchar *p, *lastp;
gint len;
+ if (!msginfo)
+ msginfo = &dummyinfo;
+
if (qmark != NULL) {
quote_fmt_init(msginfo, NULL, NULL);
quote_fmt_scan_string(qmark);
SET_ADDRESS(COMPOSE_BCC, compose->bcc);
SET_ADDRESS(COMPOSE_REPLYTO, compose->replyto);
+ compose_update_priority_menu_item(compose);
+
compose_show_first_last_header(compose, TRUE);
#if 0 /* NEW COMPOSE GUI */
g_return_if_fail(file != NULL);
- if ((fp = fopen(file, "r")) == NULL) {
+ if ((fp = fopen(file, "rb")) == NULL) {
FILE_OP_ERROR(file, "fopen");
return;
}
alertpanel_notice(_("File %s is empty."), file);
return;
}
- if ((fp = fopen(file, "r")) == NULL) {
+ if ((fp = fopen(file, "rb")) == NULL) {
alertpanel_error(_("Can't read %s."), file);
return;
}
(_("Message: %s"),
g_basename(filename ? filename : file));
} else {
- ainfo->encoding = ENC_BASE64;
+ if (!g_strncasecmp(content_type, "text", 4))
+ ainfo->encoding =
+ procmime_get_encoding_for_file(file);
+ else
+ ainfo->encoding = ENC_BASE64;
ainfo->name = g_strdup
(g_basename(filename ? filename : file));
}
} else {
ainfo->content_type = procmime_get_mime_type(file);
- if (!ainfo->content_type)
+ if (!ainfo->content_type) {
ainfo->content_type =
g_strdup("application/octet-stream");
- ainfo->encoding = ENC_BASE64;
+ ainfo->encoding = ENC_BASE64;
+ } else if (!g_strncasecmp(ainfo->content_type, "text", 4))
+ ainfo->encoding = procmime_get_encoding_for_file(file);
+ else
+ ainfo->encoding = ENC_BASE64;
ainfo->name = g_strdup(g_basename(filename ? filename : file));
}
ainfo->size = size;
} \
}
+#define INDENT_CHARS ">|#"
+#define SPACE_CHARS " \t"
+
static void compose_wrap_line(Compose *compose)
{
GtkSText *text = GTK_STEXT(compose->text);
}
line_end = 1;
} else {
- if (ch_len == 1 && strchr(">:#", *cbuf))
+ if (ch_len == 1
+ && strchr(prefs_common.quote_chars, *cbuf))
quoted = 1;
else if (ch_len != 1 || !isspace(*cbuf))
quoted = 0;
}
line_end = 1;
} else {
- if (line_end && ch_len == 1 && strchr(">:#", *cbuf))
+ if (line_end && ch_len == 1 &&
+ strchr(prefs_common.quote_chars, *cbuf))
goto compose_end; /* quoted part */
line_end = 0;
gtk_stext_thaw(text);
}
+#undef WRAP_DEBUG
+#ifdef WRAP_DEBUG
+/* Darko: used when I debug wrapping */
+void dump_text(GtkSText *text, int pos, int tlen, int breakoncr)
+{
+ gint i;
+ gchar ch;
+
+ printf("%d [", pos);
+ for (i = pos; i < tlen; i++) {
+ ch = GTK_STEXT_INDEX(text, i);
+ if (breakoncr && ch == '\n')
+ break;
+ printf("%c", ch);
+ }
+ printf("]\n");
+}
+#endif
+
+typedef enum {
+ WAIT_FOR_SPACE,
+ WAIT_FOR_INDENT_CHAR,
+ WAIT_FOR_INDENT_CHAR_OR_SPACE
+} IndentState;
+
+/* return indent length, we allow:
+ > followed by spaces/tabs
+ | followed by spaces/tabs
+ uppercase characters immediately followed by >,
+ and the repeating sequences of the above */
/* return indent length */
static guint get_indent_length(GtkSText *text, guint start_pos, guint text_len)
{
- gint indent_len = 0;
- gint i, ch_len;
+ guint i_len = 0;
+ guint i, ch_len, alnum_cnt = 0;
+ IndentState state = WAIT_FOR_INDENT_CHAR;
gchar cbuf[MB_LEN_MAX];
+ gboolean is_space;
+ gboolean is_indent;
for (i = start_pos; i < text_len; i++) {
GET_CHAR(i, cbuf, ch_len);
if (ch_len > 1)
break;
- /* allow space, tab, > or | */
- if (cbuf[0] != ' ' && cbuf[0] != '\t' &&
- cbuf[0] != '>' && cbuf[0] != '|')
+
+ if (cbuf[0] == '\n')
+ break;
+
+ is_indent = strchr(prefs_common.quote_chars, cbuf[0]) ? TRUE : FALSE;
+ is_space = strchr(SPACE_CHARS, cbuf[0]) ? TRUE : FALSE;
+
+ switch (state) {
+ case WAIT_FOR_SPACE:
+ if (is_space == FALSE)
+ goto out;
+ state = WAIT_FOR_INDENT_CHAR_OR_SPACE;
+ break;
+ case WAIT_FOR_INDENT_CHAR_OR_SPACE:
+ if (is_indent == FALSE && is_space == FALSE &&
+ !isupper(cbuf[0]))
+ goto out;
+ if (is_space == TRUE) {
+ alnum_cnt = 0;
+ state = WAIT_FOR_INDENT_CHAR_OR_SPACE;
+ } else if (is_indent == TRUE) {
+ alnum_cnt = 0;
+ state = WAIT_FOR_SPACE;
+ } else {
+ alnum_cnt++;
+ state = WAIT_FOR_INDENT_CHAR;
+ }
+ break;
+ case WAIT_FOR_INDENT_CHAR:
+ if (is_indent == FALSE && !isupper(cbuf[0]))
+ goto out;
+ if (is_indent == TRUE) {
+ if (alnum_cnt > 0
+ && !strchr(prefs_common.quote_chars, cbuf[0]))
+ goto out;
+ alnum_cnt = 0;
+ state = WAIT_FOR_SPACE;
+ } else {
+ alnum_cnt++;
+ }
break;
- indent_len++;
+ }
+
+ i_len++;
}
- return indent_len;
+out:
+ if ((i_len > 0) && (state == WAIT_FOR_INDENT_CHAR))
+ i_len -= alnum_cnt;
+
+ return i_len;
}
/* insert quotation string when line was wrapped */
-static guint ins_quote(GtkSText *text, guint quote_len, guint indent_len,
+static guint ins_quote(GtkSText *text, guint indent_len,
guint prev_line_pos, guint text_len,
gchar *quote_fmt)
{
gtk_stext_insert(text, NULL, NULL, NULL, &ch, 1);
}
ins_len = indent_len;
- } else {
- gtk_stext_insert(text, NULL, NULL, NULL, quote_fmt, quote_len);
- ins_len = quote_len;
}
return ins_len;
}
-#undef WRAP_DEBUG
-#ifdef WRAP_DEBUG
-/* Darko: used when I debug wrapping */
-void dump_text(GtkSText *text, int pos, int tlen, int breakoncr)
+/* check if we should join the next line */
+static gboolean join_next_line(GtkSText *text, guint start_pos, guint tlen,
+ guint prev_ilen)
{
- gint i;
- gchar ch;
+ guint indent_len, ch_len;
+ gboolean do_join = FALSE;
+ gchar cbuf[MB_LEN_MAX];
- printf("%d [", pos);
- for (i = pos; i < tlen; i++) {
- ch = GTK_STEXT_INDEX(text, i);
- if (breakoncr && ch == '\n')
- break;
- printf("%c", ch);
+ indent_len = get_indent_length(text, start_pos, tlen);
+
+ if ((indent_len > 0) && (indent_len == prev_ilen)) {
+ GET_CHAR(start_pos + indent_len, cbuf, ch_len);
+ if (ch_len > 0 && (cbuf[0] != '\n'))
+ do_join = TRUE;
}
- printf("]\n");
+
+ return do_join;
}
-#endif
static void compose_wrap_line_all(Compose *compose)
{
gint line_len = 0, cur_len = 0;
gint ch_len;
gboolean is_new_line = TRUE, do_delete = FALSE;
- guint qlen = 0, i_len = 0;
+ guint i_len = 0;
gboolean linewrap_quote = TRUE;
guint linewrap_len = prefs_common.linewrap_len;
gchar *qfmt = prefs_common.quotemark;
for (; cur_pos < tlen; cur_pos++) {
/* mark position of new line - needed for quotation wrap */
if (is_new_line) {
- if (linewrap_quote) {
- qlen = gtkut_stext_str_compare
- (text, cur_pos, tlen, qfmt);
- if (qlen)
- i_len = get_indent_length
- (text, cur_pos, tlen);
- else
- i_len = 0;
- }
+ if (linewrap_quote)
+ i_len = get_indent_length(text, cur_pos, tlen);
+
is_new_line = FALSE;
p_pos = cur_pos;
#ifdef WRAP_DEBUG
- printf("new line i_len=%d qlen=%d p_pos=", i_len, qlen);
+ printf("new line i_len=%d p_pos=", i_len);
dump_text(text, p_pos, tlen, 1);
#endif
}
/* we have encountered line break */
if (ch_len == 1 && *cbuf == '\n') {
gint clen;
- guint ilen;
gchar cb[MB_CUR_MAX];
+ /* should we join the next line */
+ if ((i_len != cur_len) && do_delete &&
+ join_next_line(text, cur_pos + 1, tlen, i_len))
+ do_delete = TRUE;
+ else
+ do_delete = FALSE;
+
#ifdef WRAP_DEBUG
- printf("found CR at %d next line is ", cur_pos);
+ printf("found CR at %d do_del is %d next line is ",
+ cur_pos, do_delete);
dump_text(text, cur_pos + 1, tlen, 1);
#endif
- /* if it's just quotation + newline skip it */
- if (i_len && (cur_pos + 1 < tlen)) {
- /* check if text at new line matches indent */
- ilen = gtkut_stext_str_compare_n
- (text, cur_pos + 1, p_pos, i_len, tlen);
- if (cur_pos + ilen < tlen) {
- GET_CHAR(cur_pos + ilen + 1, cb, clen);
- /* no need to join the lines */
- if (clen == 1 && cb[0] == '\n')
- do_delete = FALSE;
- }
- /* if it's just newline skip it */
- } else if (do_delete && (cur_pos + 1 < tlen)) {
- GET_CHAR(cur_pos + 1, cb, clen);
- /* no need to join the lines */
- if (clen == 1 && cb[0] == '\n')
- do_delete = FALSE;
- }
/* skip delete if it is continuous URL */
if (do_delete && (line_pos - p_pos <= i_len) &&
do_delete = FALSE;
#ifdef WRAP_DEBUG
- printf("qlen=%d l_len=%d wrap_len=%d do_del=%d\n",
- qlen, line_len, linewrap_len, do_delete);
+ printf("l_len=%d wrap_len=%d do_del=%d\n",
+ line_len, linewrap_len, do_delete);
#endif
/* should we delete to perform smart wrapping */
if (line_len < linewrap_len && do_delete) {
/* if text starts with quote fmt or with
indent string, delete them */
if (i_len) {
+ guint ilen;
ilen = gtkut_stext_str_compare_n
(text, cur_pos, p_pos, i_len,
tlen);
(text, ilen);
tlen -= ilen;
}
- } else if (qlen) {
- if (gtkut_stext_str_compare
- (text, cur_pos, tlen, qfmt)) {
- gtk_stext_forward_delete
- (text, qlen);
- tlen -= qlen;
- }
}
GET_CHAR(cur_pos, cb, clen);
cur_pos = p_pos - 1;
line_pos = cur_pos;
line_len = cur_len = 0;
- qlen = 0;
do_delete = FALSE;
is_new_line = TRUE;
#ifdef WRAP_DEBUG
/* mark new line beginning */
line_pos = cur_pos + 1;
line_len = cur_len = 0;
- qlen = 0;
do_delete = FALSE;
is_new_line = TRUE;
continue;
is_new_line = TRUE;
line_len = 0;
cur_len = 0;
- do_delete = TRUE;
+ if (i_len)
+ do_delete = TRUE;
+ else
+ do_delete = FALSE;
#ifdef WRAP_DEBUG
printf("after CR insert ");
dump_text(text, line_pos, tlen, 1);
#endif
/* should we insert quotation ? */
- if (linewrap_quote && qlen) {
+ if (linewrap_quote && i_len) {
/* only if line is not already quoted */
if (!gtkut_stext_str_compare
(text, line_pos, tlen, qfmt)) {
if (line_pos - p_pos > i_len) {
ins_len = ins_quote
- (text, qlen, i_len,
- p_pos, tlen, qfmt);
+ (text, i_len, p_pos,
+ tlen, qfmt);
/* gtk_stext_compact_buffer(text); */
tlen += ins_len;
return recipient_found;
}
+static gboolean compose_check_entries(Compose *compose, gboolean check_subject)
+{
+ gchar *str;
+
+ if (compose_check_for_valid_recipient(compose) == FALSE) {
+ alertpanel_error(_("Recipient is not specified."));
+ return FALSE;
+ }
+
+ str = gtk_entry_get_text(GTK_ENTRY(compose->subject_entry));
+ if (*str == '\0' && check_subject == TRUE) {
+ AlertValue aval;
+
+ aval = alertpanel(_("Send"),
+ _("Subject is empty. Send it anyway?"),
+ _("Yes"), _("No"), NULL);
+ if (aval != G_ALERTDEFAULT)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
gint compose_send(Compose *compose)
{
gint msgnum;
FolderItem *folder;
gint val;
+ if (compose_check_entries(compose, TRUE) == FALSE)
+ return -1;
+
val = compose_queue(compose, &msgnum, &folder);
if (val) {
alertpanel_error(_("Could not queue message for sending"));
lock = TRUE;
- if(!compose_check_for_valid_recipient(compose)) {
- alertpanel_error(_("Recipient is not specified."));
+ if (compose_check_entries(compose, TRUE) == FALSE) {
lock = FALSE;
return 1;
}
folderview_update_item
(compose->targetinfo->folder, TRUE);
}
- }
+ /* save message to outbox */
+ if (prefs_common.savemsg) {
+ FolderItem *outbox;
- /* save message to outbox */
- if (ok == 0 && prefs_common.savemsg) {
- if (compose_save_to_outbox(compose, tmp) < 0)
- alertpanel_error
- (_("Can't save the message to outbox."));
+ outbox = account_get_special_folder
+ (compose->account, F_OUTBOX);
+ if (procmsg_save_to_outbox(outbox, tmp, FALSE) < 0)
+ alertpanel_error
+ (_("Can't save the message to Sent."));
+ else
+ folderview_update_item(outbox, TRUE);
+ }
}
unlink(tmp);
return(gtk_clist_get_row_data(GTK_CLIST(compose->attach_clist), 0) != NULL);
}
-static gint compose_bounce_write_headers_from_headerlist(Compose *compose,
- FILE *fp)
+static gint compose_redirect_write_headers_from_headerlist(Compose *compose,
+ FILE *fp)
{
gchar buf[BUFFSIZE];
gchar *str;
GSList *list;
ComposeHeaderEntry *headerentry;
gchar *headerentryname;
- gchar *header_w_colon;
gchar *cc_hdr;
gchar *to_hdr;
- debug_print(_("Writing bounce header\n"));
+ debug_print(_("Writing redirect header\n"));
+
+ cc_hdr = prefs_common.trans_hdr ? _("Cc:") : "Cc:";
+ to_hdr = prefs_common.trans_hdr ? _("To:") : "To:";
- header_w_colon = g_strconcat("To:", NULL);
- to_hdr = (prefs_common.trans_hdr ? gettext(header_w_colon) : header_w_colon);
- header_w_colon = g_strconcat("Cc:", NULL);
- cc_hdr = (prefs_common.trans_hdr ? gettext(header_w_colon) : header_w_colon);
-
first_address = TRUE;
for(list = compose->header_list; list; list = list->next) {
headerentry = ((ComposeHeaderEntry *)list->data);
return(0);
}
-static gint compose_bounce_write_headers(Compose *compose, FILE *fp)
+static gint compose_redirect_write_headers(Compose *compose, FILE *fp)
{
gchar buf[BUFFSIZE];
gchar *str;
g_return_val_if_fail(compose->account != NULL, -1);
g_return_val_if_fail(compose->account->address != NULL, -1);
- /* Date */
+ /* Resent-Date */
get_rfc822_date(buf, sizeof(buf));
fprintf(fp, "Resent-Date: %s\n", buf);
- /* From */
+ /* Resent-From */
if (compose->account->name && *compose->account->name) {
compose_convert_header
(buf, sizeof(buf), compose->account->name,
} else
fprintf(fp, "Resent-From: %s\n", compose->account->address);
- /* To */
- compose_bounce_write_headers_from_headerlist(compose, fp);
+ /* Subject */
+ str = gtk_entry_get_text(GTK_ENTRY(compose->subject_entry));
+ if (*str != '\0') {
+ Xstrdup_a(str, str, return -1);
+ g_strstrip(str);
+ if (*str != '\0') {
+ compose_convert_header(buf, sizeof(buf), str,
+ strlen("Subject: "));
+ fprintf(fp, "Subject: %s\n", buf);
+ }
+ }
+
+ /* Resent-Message-ID */
+ if (compose->account->gen_msgid) {
+ compose_generate_msgid(compose, buf, sizeof(buf));
+ fprintf(fp, "Resent-Message-Id: <%s>\n", buf);
+ compose->msgid = g_strdup(buf);
+ }
+
+ compose_redirect_write_headers_from_headerlist(compose, fp);
/* separator between header and body */
fputs("\n", fp);
return 0;
}
-static gint compose_bounce_write_to_file(Compose *compose, const gchar *file)
+static gint compose_redirect_write_to_file(Compose *compose, const gchar *file)
{
FILE *fp;
FILE *fdest;
size_t len;
gchar buf[BUFFSIZE];
- if ((fp = fopen(compose->bounce_filename, "r")) == NULL) {
+ if ((fp = fopen(compose->redirect_filename, "rb")) == NULL) {
FILE_OP_ERROR(file, "fopen");
return -1;
}
- if ((fdest = fopen(file, "w")) == NULL) {
+ if ((fdest = fopen(file, "wb")) == NULL) {
FILE_OP_ERROR(file, "fopen");
fclose(fp);
return -1;
while (procheader_get_unfolded_line(buf, sizeof(buf), fp)) {
/* should filter returnpath, delivered-to */
- if ((g_strncasecmp(buf, "Return-Path:",
- strlen("Return-Path:")) == 0)
- || (g_strncasecmp(buf, "Delivered-To:",
- strlen("Delivered-To:")) == 0))
+ if (g_strncasecmp(buf, "Return-Path:",
+ strlen("Return-Path:")) == 0 ||
+ g_strncasecmp(buf, "Delivered-To:",
+ strlen("Delivered-To:")) == 0 ||
+ g_strncasecmp(buf, "Received:",
+ strlen("Received:")) == 0 ||
+ g_strncasecmp(buf, "Subject:",
+ strlen("Subject:")) == 0 ||
+ g_strncasecmp(buf, "X-UIDL:",
+ strlen("X-UIDL:")) == 0)
continue;
if (fputs(buf, fdest) == -1)
goto error;
- if (g_strncasecmp(buf, "From:", strlen("From:")) == 0) {
- fputs(" (by way of ", fdest);
- if (compose->account->name
- && *compose->account->name) {
- compose_convert_header
- (buf, sizeof(buf),
- compose->account->name,
- strlen("From: "));
- fprintf(fdest, "%s <%s>",
- buf, compose->account->address);
- } else
- fprintf(fdest, "%s",
- compose->account->address);
- fputs(")", fdest);
+ if (!prefs_common.redirect_keep_from) {
+ if (g_strncasecmp(buf, "From:",
+ strlen("From:")) == 0) {
+ fputs(" (by way of ", fdest);
+ if (compose->account->name
+ && *compose->account->name) {
+ compose_convert_header
+ (buf, sizeof(buf),
+ compose->account->name,
+ strlen("From: "));
+ fprintf(fdest, "%s <%s>",
+ buf,
+ compose->account->address);
+ } else
+ fprintf(fdest, "%s",
+ compose->account->address);
+ fputs(")", fdest);
+ }
}
if (fputs("\n", fdest) == -1)
goto error;
}
- compose_bounce_write_headers(compose, fdest);
+ compose_redirect_write_headers(compose, fdest);
- while ((len = fread(buf, sizeof(gchar), BUFFSIZE, fp)) > 0) {
- if (fwrite(buf, sizeof(gchar), len, fdest) == -1)
+ while ((len = fread(buf, sizeof(gchar), sizeof(buf), fp)) > 0) {
+ if (fwrite(buf, sizeof(gchar), len, fdest) != len) {
+ FILE_OP_ERROR(file, "fwrite");
goto error;
+ }
}
- fclose(fdest);
fclose(fp);
+ if (fclose(fdest) == EOF) {
+ FILE_OP_ERROR(file, "fclose");
+ unlink(file);
+ return -1;
+ }
return 0;
error:
- fclose(fdest);
fclose(fp);
+ fclose(fdest);
+ unlink(file);
return -1;
}
const gchar *out_codeset;
EncodingType encoding;
- if ((fp = fopen(file, "w")) == NULL) {
+ if ((fp = fopen(file, "wb")) == NULL) {
FILE_OP_ERROR(file, "fopen");
return -1;
}
buf = conv_codeset_strdup(chars, src_codeset, out_codeset);
if (!buf) {
- g_free(chars);
- fclose(fp);
- unlink(file);
- alertpanel_error(_("Can't convert the codeset of the message."));
- return -1;
+ AlertValue aval;
+
+ aval = alertpanel
+ (_("Error"),
+ _("Can't convert the character encoding of the message.\n"
+ "Send it anyway?"), _("Yes"), _("+No"), NULL);
+ if (aval != G_ALERTDEFAULT) {
+ g_free(chars);
+ fclose(fp);
+ unlink(file);
+ return -1;
+ } else {
+ buf = g_strdup(chars);
+ }
}
}
g_free(chars);
size_t len;
gchar *chars;
- if ((fp = fopen(file, "w")) == NULL) {
+ if ((fp = fopen(file, "wb")) == NULL) {
FILE_OP_ERROR(file, "fopen");
return -1;
}
return 0;
}
-static gint compose_save_to_outbox(Compose *compose, const gchar *file)
-{
- FolderItem *outbox;
- gchar *path;
- gint num;
- FILE *fp;
-
- debug_print(_("saving sent message...\n"));
-
- outbox = folder_get_default_outbox();
- path = folder_item_get_path(outbox);
- if (!is_dir_exist(path))
- make_dir_hier(path);
-
- folder_item_scan(outbox);
- if ((num = folder_item_add_msg(outbox, file, FALSE)) < 0) {
- g_free(path);
- g_warning(_("can't save message\n"));
- return -1;
- }
-
- if ((fp = procmsg_open_mark_file(path, TRUE)) == NULL)
- g_warning(_("can't open mark file\n"));
- else {
- MsgInfo newmsginfo;
-
- newmsginfo.msgnum = num;
- newmsginfo.flags.perm_flags = 0;
- newmsginfo.flags.tmp_flags = 0;
- procmsg_write_flags(&newmsginfo, fp);
- fclose(fp);
- }
- g_free(path);
-
- return 0;
-}
-
static gint compose_remove_reedit_target(Compose *compose)
{
FolderItem *item;
return 0;
}
-
static gint compose_queue(Compose *compose, gint *msgnum, FolderItem **item)
+{
+ return compose_queue_sub (compose, msgnum, item, FALSE);
+}
+static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item, gboolean check_subject)
{
FolderItem *queue;
- gchar *tmp, *tmp2, *queue_path;
+ gchar *tmp, *tmp2;
FILE *fp, *src_fp;
GSList *cur;
gchar buf[BUFFSIZE];
gint num;
+ MsgFlags flag = {0, 0};
static gboolean lock = FALSE;
PrefsAccount *mailac = NULL, *newsac = NULL;
lock = TRUE;
- if(!compose_check_for_valid_recipient(compose)) {
- alertpanel_error(_("Recipient is not specified."));
+ if (compose_check_entries(compose, check_subject) == FALSE) {
lock = FALSE;
return -1;
- }
-
+ }
+
if (!compose->to_list && !compose->newsgroup_list) {
g_warning(_("can't get recipient list."));
lock = FALSE;
tmp2 = g_strdup_printf("%s%ctmp%d", g_get_tmp_dir(),
G_DIR_SEPARATOR, (gint)compose);
- if (compose->bounce_filename != NULL) {
- if (compose_bounce_write_to_file(compose, tmp2) < 0) {
+ if (compose->redirect_filename != NULL) {
+ if (compose_redirect_write_to_file(compose, tmp2) < 0) {
unlink(tmp2);
lock = FALSE;
return -1;
/* add queue header */
tmp = g_strdup_printf("%s%cqueue.%d", g_get_tmp_dir(),
- G_DIR_SEPARATOR, (gint)compose);
- if ((fp = fopen(tmp, "w")) == NULL) {
+ G_DIR_SEPARATOR, (gint)compose);
+ if ((fp = fopen(tmp, "wb")) == NULL) {
FILE_OP_ERROR(tmp, "fopen");
g_free(tmp);
return -1;
}
- if ((src_fp = fopen(tmp2, "r")) == NULL) {
+ if ((src_fp = fopen(tmp2, "rb")) == NULL) {
FILE_OP_ERROR(tmp2, "fopen");
fclose(fp);
unlink(tmp);
g_free(tmp2);
return -1;
}
-
- /* queue message */
- queue = folder_get_default_queue();
+ queue = account_get_special_folder(compose->account, F_QUEUE);
+ if (!queue) {
+ g_warning(_("can't find queue folder\n"));
+ unlink(tmp);
+ g_free(tmp);
+ return -1;
+ }
folder_item_scan(queue);
- queue_path = folder_item_get_path(queue);
- if (!is_dir_exist(queue_path))
- make_dir_hier(queue_path);
if ((num = folder_item_add_msg(queue, tmp, TRUE)) < 0) {
g_warning(_("can't queue the message\n"));
unlink(tmp);
g_free(tmp);
- g_free(queue_path);
return -1;
}
unlink(tmp);
(compose->targetinfo->folder, TRUE);
}
- if ((fp = procmsg_open_mark_file(queue_path, TRUE)) == NULL)
- g_warning(_("can't open mark file\n"));
- else {
- MsgInfo newmsginfo;
-
- newmsginfo.msgnum = num;
- newmsginfo.flags.perm_flags = 0;
- newmsginfo.flags.tmp_flags = 0;
- procmsg_write_flags(&newmsginfo, fp);
- fclose(fp);
- }
- g_free(queue_path);
-
+ procmsg_add_flags(queue, num, flag);
folder_item_scan(queue);
folderview_update_item(queue, TRUE);
for (row = 0; (ainfo = gtk_clist_get_row_data(clist, row)) != NULL;
row++) {
- if ((attach_fp = fopen(ainfo->file, "r")) == NULL) {
+ gchar buf[BUFFSIZE];
+ gchar inbuf[B64_LINE_SIZE], outbuf[B64_BUFFSIZE];
+
+ if ((attach_fp = fopen(ainfo->file, "rb")) == NULL) {
g_warning(_("Can't open file %s\n"), ainfo->file);
continue;
}
fprintf(fp, "Content-Transfer-Encoding: %s\n\n",
procmime_get_encoding_str(ainfo->encoding));
- if (ainfo->encoding == ENC_7BIT) {
- gchar buf[BUFFSIZE];
+ switch (ainfo->encoding) {
+
+ case ENC_7BIT:
+ case ENC_8BIT:
+ /* if (ainfo->encoding == ENC_7BIT) { */
while (fgets(buf, sizeof(buf), attach_fp) != NULL) {
strcrchomp(buf);
fputs(buf, fp);
}
- } else {
- gchar inbuf[B64_LINE_SIZE], outbuf[B64_BUFFSIZE];
+ break;
+ /* } else { */
+ case ENC_BASE64:
while ((len = fread(inbuf, sizeof(gchar),
B64_LINE_SIZE, attach_fp))
fputs(outbuf, fp);
fputc('\n', fp);
}
+ break;
}
fclose(attach_fp);
fprintf(fp, "\n--%s--\n", compose->boundary);
}
+#define QUOTE_IF_REQUIRED(out, str) \
+{ \
+ if (*str != '"' && strchr(str, ',')) { \
+ gchar *__tmp; \
+ gint len; \
+ \
+ len = strlen(str) + 3; \
+ Xalloca(__tmp, len, return -1); \
+ g_snprintf(__tmp, len, "\"%s\"", str); \
+ out = __tmp; \
+ } else { \
+ Xstrdup_a(out, str, return -1); \
+ } \
+}
+
+#define PUT_RECIPIENT_HEADER(header, str) \
+{ \
+ if (*str != '\0') { \
+ Xstrdup_a(str, str, return -1); \
+ g_strstrip(str); \
+ if (*str != '\0') { \
+ compose->to_list = address_list_append \
+ (compose->to_list, str); \
+ compose_convert_header \
+ (buf, sizeof(buf), str, strlen(header) + 2); \
+ fprintf(fp, "%s: %s\n", header, buf); \
+ } \
+ } \
+}
+
#define IS_IN_CUSTOM_HEADER(header) \
(compose->account->add_customhdr && \
custom_header_find(compose->account->customhdr_list, header) != NULL)
{
gchar buf[BUFFSIZE];
gchar *str;
+ gchar *name;
/* struct utsname utsbuf; */
g_return_val_if_fail(fp != NULL, -1);
compose_convert_header
(buf, sizeof(buf), compose->account->name,
strlen("From: "));
+ QUOTE_IF_REQUIRED(name, buf);
fprintf(fp, "From: %s <%s>\n",
- buf, compose->account->address);
+ name, compose->account->address);
} else
fprintf(fp, "From: %s\n", compose->account->address);
}
#if 0 /* NEW COMPOSE GUI */
if (compose->use_to) {
str = gtk_entry_get_text(GTK_ENTRY(compose->to_entry));
- if (*str != '\0') {
- Xstrdup_a(str, str, return -1);
- g_strstrip(str);
- if (*str != '\0') {
- compose->to_list = address_list_append
- (compose->to_list, str);
- if (!IS_IN_CUSTOM_HEADER("To")) {
- compose_convert_header
- (buf, sizeof(buf), str,
- strlen("To: "));
- fprintf(fp, "To: %s\n", buf);
- }
- }
- }
+ PUT_RECIPIENT_HEADER("To", str);
}
#endif
compose->newsgroup_list =
newsgroup_list_append(compose->newsgroup_list,
str);
- if (!IS_IN_CUSTOM_HEADER("Newsgroups")) {
- compose_convert_header(buf, sizeof(buf), str,
- strlen("Newsgroups: "));
- fprintf(fp, "Newsgroups: %s\n", buf);
- }
+ compose_convert_header(buf, sizeof(buf), str,
+ strlen("Newsgroups: "));
+ fprintf(fp, "Newsgroups: %s\n", buf);
}
}
#endif
#if 0 /* NEW COMPOSE GUI */
if (compose->use_cc) {
str = gtk_entry_get_text(GTK_ENTRY(compose->cc_entry));
- if (*str != '\0') {
- Xstrdup_a(str, str, return -1);
- g_strstrip(str);
- if (*str != '\0') {
- compose->to_list = address_list_append
- (compose->to_list, str);
- if (!IS_IN_CUSTOM_HEADER("Cc")) {
- compose_convert_header
- (buf, sizeof(buf), str,
- strlen("Cc: "));
- fprintf(fp, "Cc: %s\n", buf);
- }
- }
- }
+ PUT_RECIPIENT_HEADER("Cc", str);
}
#endif
/* Bcc */
#if 0 /* NEW COMPOSE GUI */
if (compose->use_bcc) {
str = gtk_entry_get_text(GTK_ENTRY(compose->bcc_entry));
- if (*str != '\0') {
- Xstrdup_a(str, str, return -1);
- g_strstrip(str);
- if (*str != '\0') {
- compose->to_list = address_list_append
- (compose->to_list, str);
- compose_convert_header(buf, sizeof(buf), str,
- strlen("Bcc: "));
- fprintf(fp, "Bcc: %s\n", buf);
- }
- }
+ PUT_RECIPIENT_HEADER("Bcc", str);
}
#endif
procmime_get_encoding_str(encoding));
}
+ /* PRIORITY */
+ switch (compose->priority) {
+ case PRIORITY_HIGHEST: fprintf(fp, "Importance: high\n"
+ "X-Priority: 1 (Highest)\n");
+ break;
+ case PRIORITY_HIGH: fprintf(fp, "Importance: high\n"
+ "X-Priority: 2 (High)\n");
+ break;
+ case PRIORITY_NORMAL: break;
+ case PRIORITY_LOW: fprintf(fp, "Importance: low\n"
+ "X-Priority: 4 (Low)\n");
+ break;
+ case PRIORITY_LOWEST: fprintf(fp, "Importance: low\n"
+ "X-Priority: 5 (Lowest)\n");
+ break;
+ default: debug_print(_("compose: priority unknown : %d\n"),
+ compose->priority);
+ }
+
/* Request Return Receipt */
if (!IS_IN_CUSTOM_HEADER("Disposition-Notification-To")) {
if (compose->return_receipt) {
savemsg_checkbtn = gtk_check_button_new_with_label(_("Save Message to "));
gtk_widget_show(savemsg_checkbtn);
gtk_table_attach(GTK_TABLE(table), savemsg_checkbtn, 0, 1, rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
- if(folder_get_default_outbox()) {
+ if(account_get_special_folder(compose->account, F_OUTBOX)) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(savemsg_checkbtn), prefs_common.savemsg);
}
gtk_signal_connect(GTK_OBJECT(savemsg_checkbtn), "toggled",
gtk_widget_show(savemsg_entry);
gtk_table_attach_defaults(GTK_TABLE(table), savemsg_entry, 1, 2, rowcount, rowcount + 1);
gtk_editable_set_editable(GTK_EDITABLE(savemsg_entry), prefs_common.savemsg);
- if(folder_get_default_outbox()) {
- folderidentifier = folder_item_get_identifier(folder_get_default_outbox());
+ if(account_get_special_folder(compose->account, F_OUTBOX)) {
+ folderidentifier = folder_item_get_identifier(account_get_special_folder
+ (compose->account, F_OUTBOX));
gtk_entry_set_text(GTK_ENTRY(savemsg_entry), folderidentifier);
g_free(folderidentifier);
}
GtkPspell * gtkpspell = NULL;
#endif
+ static GdkGeometry geometry;
+
g_return_val_if_fail(account != NULL, NULL);
debug_print(_("Creating compose window...\n"));
gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
gtk_widget_set_usize(window, -1, prefs_common.compose_height);
gtk_window_set_wmclass(GTK_WINDOW(window), "compose window", "Sylpheed");
+
+ if (!geometry.max_width) {
+ geometry.max_width = gdk_screen_width();
+ geometry.max_height = gdk_screen_height();
+ }
+ gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL,
+ &geometry, GDK_HINT_MAX_SIZE);
+
gtk_signal_connect(GTK_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(compose_delete_cb), compose);
gtk_signal_connect(GTK_OBJECT(window), "destroy",
GTK_SIGNAL_FUNC(compose_destroy_cb), compose);
- gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
- GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
- gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
- GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
+ MANAGE_WINDOW_SIGNALS_CONNECT(window);
gtk_widget_realize(window);
gtkut_widget_set_composer_icon(window);
GTK_SIGNAL_FUNC(compose_grab_focus_cb), compose);
gtk_signal_connect(GTK_OBJECT(text), "activate",
GTK_SIGNAL_FUNC(text_activated), compose);
+ gtk_signal_connect(GTK_OBJECT(text), "insert_text",
+ GTK_SIGNAL_FUNC(text_inserted), compose);
gtk_signal_connect_after(GTK_OBJECT(text), "button_press_event",
GTK_SIGNAL_FUNC(compose_button_press_cb),
edit_vbox);
new_style = gtk_style_copy(style);
if (prefs_common.textfont) {
- CharSet charset;
-
- charset = conv_get_current_charset();
if (MB_CUR_MAX == 1) {
gchar *fontstr, *p;
menu_set_sensitive(ifactory, "/Edit/Undo", FALSE);
menu_set_sensitive(ifactory, "/Edit/Redo", FALSE);
- tmpl_menu = gtk_item_factory_get_item(ifactory, "/Tool/Template");
+ tmpl_menu = gtk_item_factory_get_item(ifactory, "/Tools/Template");
#if 0 /* NEW COMPOSE GUI */
gtk_widget_hide(bcc_hbox);
gtk_widget_hide(bcc_entry);
}
#endif
- update_compose_actions_menu(ifactory, "/Edit/Actions", compose);
+ update_compose_actions_menu(ifactory, "/Tools/Actions", compose);
undostruct = undo_init(text);
compose->modified = FALSE;
compose->return_receipt = FALSE;
+ compose->paste_as_quotation = FALSE;
compose->to_list = NULL;
compose->newsgroup_list = NULL;
compose->exteditor_readdes = -1;
compose->exteditor_tag = -1;
- compose->bounce_filename = NULL;
+ compose->redirect_filename = NULL;
compose->undostruct = undostruct;
#if USE_PSPELL
if (!prefs_common.show_ruler)
gtk_widget_hide(ruler_hbox);
+ /* Priority */
+ compose->priority = PRIORITY_NORMAL;
+ compose_update_priority_menu_item(compose);
+
select_account(compose, account);
set_toolbar_style(compose);
if (ac == compose->account) def_menu = num;
- name = g_strdup_printf("%s: %s <%s>",
- ac->account_name, ac->name, ac->address);
+ if (ac->name)
+ name = g_strdup_printf("%s: %s <%s>",
+ ac->account_name,
+ ac->name, ac->address);
+ else
+ name = g_strdup_printf("%s: %s",
+ ac->account_name, ac->address);
MENUITEM_ADD(menu, menuitem, name, ac);
g_free(name);
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
return hbox;
}
+static void compose_set_priority_cb(gpointer data,
+ guint action,
+ GtkWidget *widget)
+{
+ Compose *compose = (Compose *) data;
+ compose->priority = action;
+}
+
+static void compose_update_priority_menu_item(Compose * compose)
+{
+ GtkItemFactory *ifactory;
+ GtkWidget *menuitem;
+
+ ifactory = gtk_item_factory_from_widget(compose->menubar);
+
+ switch (compose->priority) {
+ case PRIORITY_HIGHEST:
+ menuitem = gtk_item_factory_get_item
+ (ifactory, "/Message/Priority/Highest");
+ break;
+ case PRIORITY_HIGH:
+ menuitem = gtk_item_factory_get_item
+ (ifactory, "/Message/Priority/High");
+ break;
+ case PRIORITY_NORMAL:
+ menuitem = gtk_item_factory_get_item
+ (ifactory, "/Message/Priority/Normal");
+ break;
+ case PRIORITY_LOW:
+ menuitem = gtk_item_factory_get_item
+ (ifactory, "/Message/Priority/Low");
+ break;
+ case PRIORITY_LOWEST:
+ menuitem = gtk_item_factory_get_item
+ (ifactory, "/Message/Priority/Lowest");
+ break;
+ }
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
+}
+
static void compose_set_template_menu(Compose *compose)
{
GSList *tmpl_list, *cur;
}
}
-
-static void compose_template_apply(Compose *compose, Template *tmpl)
+static void compose_template_apply(Compose *compose, Template *tmpl,
+ gboolean replace)
{
gchar *qmark;
gchar *parsed_str;
if (tmpl->to && *tmpl->to != '\0')
compose_entry_append(compose, tmpl->to, COMPOSE_TO);
- gtk_stext_clear(GTK_STEXT(compose->text));
+ if (replace)
+ gtk_stext_clear(GTK_STEXT(compose->text));
if (compose->replyinfo == NULL) {
- MsgInfo dummyinfo;
-
- memset(&dummyinfo, 0, sizeof(MsgInfo));
- parsed_str = compose_quote_fmt(compose, &dummyinfo,
- tmpl->value, NULL, NULL);
+ parsed_str = compose_quote_fmt(compose, NULL, tmpl->value,
+ NULL, NULL);
} else {
if (prefs_common.quotemark && *prefs_common.quotemark)
qmark = prefs_common.quotemark;
tmpl->value, qmark, NULL);
}
- if (parsed_str && prefs_common.auto_sig)
+ if (replace && parsed_str && prefs_common.auto_sig)
compose_insert_sig(compose);
+ if (replace && parsed_str) {
+ gtk_editable_set_position(GTK_EDITABLE(compose->text), 0);
+ gtk_stext_set_point(GTK_STEXT(compose->text), 0);
+ }
+
+ if (parsed_str)
+ compose_changed_cb(NULL, compose);
+
gtk_stext_thaw(GTK_STEXT(compose->text));
}
g_free(compose->msgid);
g_free(compose->boundary);
- if (compose->bounce_filename)
- g_free(compose->bounce_filename);
+ if (compose->redirect_filename)
+ g_free(compose->redirect_filename);
g_free(compose->exteditor_file);
GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
optmenu = gtk_option_menu_new();
- gtk_box_pack_start(GTK_BOX(hbox), optmenu, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), optmenu, TRUE, TRUE, 0);
optmenu_menu = gtk_menu_new();
MENUITEM_ADD(optmenu_menu, menuitem, "7bit", ENC_7BIT);
+ gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), optmenu_menu);
+#if 0
gtk_widget_set_sensitive(menuitem, FALSE);
+#endif
MENUITEM_ADD(optmenu_menu, menuitem, "8bit", ENC_8BIT);
+ gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), optmenu_menu);
+#if 0
gtk_widget_set_sensitive(menuitem, FALSE);
+#endif
MENUITEM_ADD(optmenu_menu, menuitem, "quoted-printable", ENC_QUOTED_PRINTABLE);
gtk_widget_set_sensitive(menuitem, FALSE);
MENUITEM_ADD(optmenu_menu, menuitem, "base64", ENC_BASE64);
static void select_account(Compose * compose, PrefsAccount * ac)
{
+#if USE_GPGME
+ GtkItemFactory *ifactory;
+ GtkWidget *menuitem;
+#endif /* USE_GPGME */
compose->account = ac;
compose_set_title(compose);
}
gtk_widget_queue_resize(compose->table_vbox);
#endif
+#if USE_GPGME
+ ifactory = gtk_item_factory_from_widget(compose->menubar);
+ menu_set_sensitive(ifactory,
+ "/Message/Sign", TRUE);
+ menu_set_sensitive(ifactory,
+ "/Message/Encrypt", TRUE);
+
+ menuitem = gtk_item_factory_get_item(ifactory, "/Message/Sign");
+ if (ac->default_sign)
+ gtk_check_menu_item_set_active
+ (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
+ else
+ gtk_check_menu_item_set_active
+ (GTK_CHECK_MENU_ITEM(menuitem), FALSE);
+
+ menuitem = gtk_item_factory_get_item(ifactory, "/Message/Encrypt");
+ if (ac->default_encrypt)
+ gtk_check_menu_item_set_active
+ (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
+ else
+ gtk_check_menu_item_set_active
+ (GTK_CHECK_MENU_ITEM(menuitem), FALSE);
+#endif /* USE_GPGME */
+
}
static void account_activated(GtkMenuItem *menuitem, gpointer data)
{
Compose *compose = (Compose *)data;
gint val;
+
+ if (prefs_common.work_offline)
+ if (alertpanel(_("Offline warning"),
+ _("You're working offline. Override?"),
+ _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
+ return;
val = compose_send(compose);
Compose *compose = (Compose *)data;
gint val;
- val = compose_queue(compose, NULL, NULL);
+ val = compose_queue_sub(compose, NULL, NULL, TRUE);
if (!val) gtk_widget_destroy(compose->window);
}
FolderItem *draft;
gchar *tmp;
gint msgnum;
+ MsgFlags flag = {0, 0};
static gboolean lock = FALSE;
if (lock) return;
- draft = folder_get_default_draft();
+ draft = account_get_special_folder(compose->account, F_DRAFT);
g_return_if_fail(draft != NULL);
lock = TRUE;
}
folder_item_scan(draft);
- if ((msgnum = folder_item_add_msg(draft, tmp, TRUE)) <= 0) {
+ if ((msgnum = folder_item_add_msg(draft, tmp, TRUE)) < 0) {
unlink(tmp);
g_free(tmp);
lock = FALSE;
TRUE);
}
+ procmsg_add_flags(draft, msgnum, flag);
folder_item_scan(draft);
folderview_update_item(draft, TRUE);
Compose *compose = (Compose *)data;
GList *file_list;
- if (compose->bounce_filename != NULL)
+ if (compose->redirect_filename != NULL)
return;
file_list = filesel_select_multiple_files(_("Select file"), NULL);
{
Compose *compose = (Compose *)data;
Template *tmpl;
+ gchar *msg;
+ AlertValue val;
tmpl = gtk_object_get_data(GTK_OBJECT(widget), "template");
g_return_if_fail(tmpl != NULL);
- compose_template_apply(compose, tmpl);
+ msg = g_strdup_printf(_("Do you want to apply the template `%s' ?"),
+ tmpl->name);
+ val = alertpanel(_("Apply template"), msg,
+ _("Replace"), _("Insert"), _("Cancel"));
+ g_free(msg);
+
+ if (val == G_ALERTDEFAULT)
+ compose_template_apply(compose, tmpl, TRUE);
+ else if (val == G_ALERTALTERNATE)
+ compose_template_apply(compose, tmpl, FALSE);
}
static void compose_ext_editor_cb(gpointer data, guint action,
(GTK_EDITABLE(compose->focused_editable));
}
+static void compose_paste_as_quote_cb(Compose *compose)
+{
+ if (compose->focused_editable &&
+ GTK_WIDGET_HAS_FOCUS(compose->focused_editable)) {
+ compose->paste_as_quotation = TRUE;
+ gtk_editable_paste_clipboard
+ (GTK_EDITABLE(compose->focused_editable));
+ compose->paste_as_quotation = FALSE;
+ }
+}
+
static void compose_allsel_cb(Compose *compose)
{
if (compose->focused_editable &&
compose_send_control_enter(compose);
}
+static void text_inserted(GtkWidget *widget, const gchar *text,
+ gint length, gint *position, Compose *compose)
+{
+ GtkEditable *editable = GTK_EDITABLE(widget);
+
+ gtk_signal_handler_block_by_func(GTK_OBJECT(widget),
+ GTK_SIGNAL_FUNC(text_inserted),
+ compose);
+ if (compose->paste_as_quotation) {
+ gchar *new_text;
+ gchar *qmark;
+ gint pos;
+
+ new_text = g_strndup(text, length);
+ if (prefs_common.quotemark && *prefs_common.quotemark)
+ qmark = prefs_common.quotemark;
+ else
+ qmark = "> ";
+ gtk_stext_set_point(GTK_STEXT(widget), *position);
+ compose_quote_fmt(compose, NULL, "%Q", qmark, new_text);
+ pos = gtk_stext_get_point(GTK_STEXT(widget));
+ gtk_editable_set_position(editable, pos);
+ *position = pos;
+ g_free(new_text);
+ } else
+ gtk_editable_insert_text(editable, text, length, position);
+
+ if (prefs_common.autowrap)
+ compose_wrap_line_all(compose);
+
+ gtk_signal_handler_unblock_by_func(GTK_OBJECT(widget),
+ GTK_SIGNAL_FUNC(text_inserted),
+ compose);
+ gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text");
+}
+
static gboolean compose_send_control_enter(Compose *compose)
{
GdkEvent *ev;
GtkAccelEntry *accel;
GtkWidget *send_menu;
GSList *list;
+ GdkModifierType ignored_mods =
+ (GDK_LOCK_MASK | GDK_MOD2_MASK | GDK_MOD3_MASK |
+ GDK_MOD4_MASK | GDK_MOD5_MASK);
ev = gtk_get_current_event();
if (ev->type != GDK_KEY_PRESS) return FALSE;
list = gtk_accel_group_entries_from_object(GTK_OBJECT(send_menu));
accel = (GtkAccelEntry *)list->data;
if (accel->accelerator_key == kev->keyval &&
- accel->accelerator_mods == kev->state) {
+ (accel->accelerator_mods & ~ignored_mods) ==
+ (kev->state & ~ignored_mods)) {
compose_send_cb(compose, 0, NULL);
return TRUE;
}