static GtkWidget *compose_account_option_menu_create
(Compose *compose);
+static void compose_set_out_encoding (Compose *compose);
static void compose_set_template_menu (Compose *compose);
static void compose_template_apply (Compose *compose,
Template *tmpl,
MimeInfo *parent);
static gchar *compose_get_header (Compose *compose);
-static void compose_convert_header (gchar *dest,
+static void compose_convert_header (Compose *compose,
+ gchar *dest,
gint len,
gchar *src,
gint header_len,
guint action,
GtkWidget *widget);
+static void compose_set_encoding_cb (gpointer data,
+ guint action,
+ GtkWidget *widget);
+
static void compose_address_cb (gpointer data,
guint action,
GtkWidget *widget);
static gint compose_delete_cb (GtkWidget *widget,
GdkEventAny *event,
gpointer data);
-static void compose_destroy_cb (GtkWidget *widget,
- Compose *compose);
static void compose_undo_cb (Compose *compose);
static void compose_redo_cb (Compose *compose);
static void compose_grab_focus_cb (GtkWidget *widget,
Compose *compose);
-static void compose_grab_focus_before_cb(GtkWidget *widget,
- Compose *compose);
static void compose_changed_cb (GtkTextBuffer *textbuf,
Compose *compose);
{N_("/_Options/Priority/_Lowest"), NULL, compose_set_priority_cb, PRIORITY_LOWEST, "/Options/Priority/Highest"},
{N_("/_Options/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Options/_Request Return Receipt"), NULL, compose_toggle_return_receipt_cb, 0, "<ToggleItem>"},
+ {N_("/_Options/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Options/Remo_ve references"), NULL, compose_toggle_remove_refs_cb, 0, "<ToggleItem>"},
+ {N_("/_Options/---"), NULL, NULL, 0, "<Separator>"},
+
+#define ENC_ACTION(action) \
+ NULL, compose_set_encoding_cb, action, \
+ "/Options/Character encoding/Automatic"
+
+ {N_("/_Options/Character _encoding"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/_Automatic"),
+ NULL, compose_set_encoding_cb, C_AUTO, "<RadioItem>"},
+ {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
+
+ {N_("/_Options/Character _encoding/7bit ascii (US-ASC_II)"),
+ ENC_ACTION(C_US_ASCII)},
+ {N_("/_Options/Character _encoding/Unicode (_UTF-8)"),
+ ENC_ACTION(C_UTF_8)},
+ {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
+
+ {N_("/_Options/Character _encoding/Western European (ISO-8859-_1)"),
+ ENC_ACTION(C_ISO_8859_1)},
+ {N_("/_Options/Character _encoding/Western European (ISO-8859-15)"),
+ ENC_ACTION(C_ISO_8859_15)},
+ {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
+
+ {N_("/_Options/Character _encoding/Central European (ISO-8859-_2)"),
+ ENC_ACTION(C_ISO_8859_2)},
+ {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
+
+ {N_("/_Options/Character _encoding/_Baltic (ISO-8859-13)"),
+ ENC_ACTION(C_ISO_8859_13)},
+ {N_("/_Options/Character _encoding/Baltic (ISO-8859-_4)"),
+ ENC_ACTION(C_ISO_8859_4)},
+ {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
+
+ {N_("/_Options/Character _encoding/Greek (ISO-8859-_7)"),
+ ENC_ACTION(C_ISO_8859_7)},
+ {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
+
+ {N_("/_Options/Character _encoding/Hebrew (ISO-8859-_8)"),
+ ENC_ACTION(C_ISO_8859_8)},
+ {N_("/_Options/Character _encoding/Hebrew (Windows-1255)"),
+ ENC_ACTION(C_WINDOWS_1255)},
+ {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
+
+ {N_("/_Options/Character _encoding/Turkish (ISO-8859-_9)"),
+ ENC_ACTION(C_ISO_8859_9)},
+ {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
+
+ {N_("/_Options/Character _encoding/Cyrillic (ISO-8859-_5)"),
+ ENC_ACTION(C_ISO_8859_5)},
+ {N_("/_Options/Character _encoding/Cyrillic (KOI8-_R)"),
+ ENC_ACTION(C_KOI8_R)},
+ {N_("/_Options/Character _encoding/Cyrillic (KOI8-U)"),
+ ENC_ACTION(C_KOI8_U)},
+ {N_("/_Options/Character _encoding/Cyrillic (Windows-1251)"),
+ ENC_ACTION(C_WINDOWS_1251)},
+ {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
+
+ {N_("/_Options/Character _encoding/Japanese (ISO-2022-_JP)"),
+ ENC_ACTION(C_ISO_2022_JP)},
+ {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
+
+ {N_("/_Options/Character _encoding/Simplified Chinese (_GB2312)"),
+ ENC_ACTION(C_GB2312)},
+ {N_("/_Options/Character _encoding/Simplified Chinese (GBK)"),
+ ENC_ACTION(C_GBK)},
+ {N_("/_Options/Character _encoding/Traditional Chinese (_Big5)"),
+ ENC_ACTION(C_BIG5)},
+ {N_("/_Options/Character _encoding/Traditional Chinese (EUC-_TW)"),
+ ENC_ACTION(C_EUC_TW)},
+ {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
+
+ {N_("/_Options/Character _encoding/Korean (EUC-_KR)"),
+ ENC_ACTION(C_EUC_KR)},
+ {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
+
+ {N_("/_Options/Character _encoding/Thai (TIS-620)"),
+ ENC_ACTION(C_TIS_620)},
+ {N_("/_Options/Character _encoding/Thai (Windows-874)"),
+ ENC_ACTION(C_WINDOWS_874)},
+
{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},
return compose;
}
-/*
-Compose *compose_new_followup_and_replyto(PrefsAccount *account,
- const gchar *followupto, gchar * to)
-{
- Compose *compose;
-
- if (!account) account = cur_account;
- g_return_val_if_fail(account != NULL, NULL);
- g_return_val_if_fail(account->protocol != A_NNTP, NULL);
-
- compose = compose_create(account, COMPOSE_NEW);
-
- 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);
-
- compose_entry_append(compose, to, COMPOSE_TO);
- compose_entry_append(compose, followupto, COMPOSE_NEWSGROUPS);
- gtk_widget_grab_focus(compose->subject_entry);
-
- return compose;
-}
-*/
-
void compose_reply_mode(ComposeMode mode, GSList *msginfo_list, gchar *body)
{
MsgInfo *msginfo;
void compose_reedit(MsgInfo *msginfo)
{
- Compose *compose;
+ Compose *compose = NULL;
PrefsAccount *account = NULL;
GtkTextView *textview;
GtkTextBuffer *textbuf;
ComposeEntryType type)
{
gchar *header;
-
+ gchar *cur, *begin;
+ gboolean in_quote = FALSE;
if (!address || *address == '\0') return;
-#if 0 /* NEW COMPOSE GUI */
- switch (type) {
- case COMPOSE_CC:
- entry = GTK_ENTRY(compose->cc_entry);
- break;
- case COMPOSE_BCC:
- entry = GTK_ENTRY(compose->bcc_entry);
- break;
- case COMPOSE_NEWSGROUPS:
- entry = GTK_ENTRY(compose->newsgroups_entry);
- break;
- case COMPOSE_TO:
- default:
- entry = GTK_ENTRY(compose->to_entry);
- break;
- }
-
- text = gtk_entry_get_text(entry);
- if (*text != '\0')
- gtk_entry_append_text(entry, ", ");
- gtk_entry_append_text(entry, address);
-#endif
-
switch (type) {
case COMPOSE_CC:
header = N_("Cc:");
break;
}
header = prefs_common.trans_hdr ? gettext(header) : header;
-
- compose_add_header_entry(compose, header, (gchar *)address);
+
+ cur = begin = (gchar *)address;
+
+ /* we separate the line by commas, but not if we're inside a quoted
+ * string */
+ while (*cur != '\0') {
+ if (*cur == '"')
+ in_quote = !in_quote;
+ if (*cur == ',' && !in_quote) {
+ gchar *tmp = g_strdup(begin);
+ gchar *o_tmp = tmp;
+ tmp[cur-begin]='\0';
+ cur++;
+ begin = cur;
+ while (*tmp == ' ')
+ tmp++;
+ compose_add_header_entry(compose, header, tmp);
+ g_free(o_tmp);
+ continue;
+ }
+ cur++;
+ }
+ if (begin < cur) {
+ gchar *tmp = g_strdup(begin);
+ gchar *o_tmp = tmp;
+ tmp[cur-begin]='\0';
+ cur++;
+ begin = cur;
+ while (*tmp == ' ')
+ tmp++;
+ compose_add_header_entry(compose, header, tmp);
+ g_free(o_tmp);
+ }
}
void compose_entry_mark_default_to(Compose *compose, const gchar *mailto)
{
gchar *to = NULL;
gchar *cc = NULL;
- gchar *bcc = NULL;
gchar *subject = NULL;
gchar *body = NULL;
gchar *temp = NULL;
gint len = 0;
- scan_mailto_url(mailto, &to, &cc, &bcc, &subject, &body);
+ scan_mailto_url(mailto, &to, &cc, NULL, &subject, &body);
if (to)
compose_entry_append(compose, to, COMPOSE_TO);
if (cc)
compose_entry_append(compose, cc, COMPOSE_CC);
- if (bcc)
- compose_entry_append(compose, bcc, COMPOSE_BCC);
- if (subject)
+ if (subject) {
if (!g_utf8_validate (subject, -1, NULL)) {
temp = g_locale_to_utf8 (subject, -1, NULL, &len, NULL);
gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), temp);
} else {
gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), subject);
}
+ }
if (body) {
GtkTextView *text = GTK_TEXT_VIEW(compose->text);
GtkTextBuffer *buffer = gtk_text_view_get_buffer(text);
g_free(to);
g_free(cc);
- g_free(bcc);
g_free(subject);
g_free(body);
}
g_signal_handlers_unblock_by_func(G_OBJECT(buffer),
G_CALLBACK(compose_changed_cb),
compose);
-
+
compose->autowrap = prev_autowrap;
if (compose->autowrap)
compose_wrap_all(compose);
gchar *name;
if (!is_file_exist(file)) {
- g_warning("File %s doesn't exist\n", file);
+ g_warning("File %s doesn't exist\n", filename);
return;
}
if ((size = get_file_size(file)) < 0) {
- g_warning("Can't get file size of %s\n", file);
+ g_warning("Can't get file size of %s\n", filename);
return;
}
if (size == 0) {
- alertpanel_notice(_("File %s is empty."), file);
+ alertpanel_notice(_("File %s is empty."), filename);
return;
}
if ((fp = fopen(file, "rb")) == NULL) {
- alertpanel_error(_("Can't read %s."), file);
+ alertpanel_error(_("Can't read %s."), filename);
return;
}
fclose(fp);
gint pos = 0;
gboolean can_break = FALSE;
gboolean do_break = FALSE;
+ gboolean was_white = FALSE;
gtk_text_iter_forward_to_line_end(&line_end);
str = gtk_text_buffer_get_text(buffer, &iter, &line_end, FALSE);
gunichar wc;
gint uri_len;
- if (attr->is_line_break && can_break)
+ if (attr->is_line_break && can_break && was_white)
pos = i;
+
+ was_white = attr->is_white;
/* don't wrap URI */
if ((uri_len = get_uri_len(p)) > 0) {
static gboolean compose_is_sig_separator(Compose *compose, GtkTextBuffer *textbuf, GtkTextIter *iter)
{
- char *text = NULL;
GtkTextIter start = *iter;
GtkTextIter end_iter;
int start_pos = gtk_text_iter_get_offset(&start);
buffer = gtk_text_view_get_buffer(text);
+ undo_block(compose->undostruct);
+
if (par_iter) {
iter = *par_iter;
} else {
if (par_iter)
*par_iter = iter;
+ undo_unblock(compose->undostruct);
compose->autowrap = prev_autowrap;
}
buffer = gtk_text_view_get_buffer(text);
+ undo_block(compose->undostruct);
+
gtk_text_buffer_get_start_iter(buffer, &iter);
while (!gtk_text_iter_is_end(&iter))
compose_wrap_paragraph(compose, &iter);
+
+ undo_unblock(compose->undostruct);
}
static void compose_set_title(Compose *compose)
val = compose_queue(compose, &msgnum, &folder);
if (val) {
- alertpanel_error(_("Could not queue message for sending"));
+ alertpanel_error(_("Could not queue message for sending."));
goto bail;
}
compose_close(compose);
/* No more compose access in the normal codepath
* after this point! */
+ compose = NULL;
}
if (msgnum == 0) {
to_hdr = prefs_common.trans_hdr ? _("To:") : "To:";
first_to_address = TRUE;
- first_cc_address = TRUE;
for (list = compose->header_list; list; list = list->next) {
headerentry = ((ComposeHeaderEntry *)list->data);
headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry));
- if (g_utf8_collate(headerentryname, cc_hdr) == 0
- || g_utf8_collate(headerentryname, to_hdr) == 0) {
+ if (g_utf8_collate(headerentryname, to_hdr) == 0) {
const gchar *entstr = gtk_entry_get_text(GTK_ENTRY(headerentry->entry));
Xstrdup_a(str, entstr, return -1);
g_strstrip(str);
if (str[0] != '\0') {
compose_convert_header
- (buf, sizeof(buf), str,
+ (compose, buf, sizeof(buf), str,
strlen("Resent-To") + 2, TRUE);
- if (g_utf8_collate(headerentryname, to_hdr) == 0) {
- if (first_to_address) {
- fprintf(fp, "Resent-To: ");
- first_to_address = FALSE;
- } else {
- fprintf(fp, ",");
- }
- }
- if (g_utf8_collate(headerentryname, cc_hdr) == 0) {
- if (first_cc_address) {
- fprintf(fp, "\n");
- fprintf(fp, "Resent-Cc: ");
- first_cc_address = FALSE;
- } else {
- fprintf(fp, ",");
- }
- }
-
+
+ if (first_to_address) {
+ fprintf(fp, "Resent-To: ");
+ first_to_address = FALSE;
+ } else {
+ fprintf(fp, ",");
+ }
fprintf(fp, "%s", buf);
}
}
}
- /* if (!first_address) { */
- fprintf(fp, "\n");
- /* } */
+ if (!first_to_address) {
+ fprintf(fp, "\n");
+ }
+ first_cc_address = TRUE;
+ for (list = compose->header_list; list; list = list->next) {
+ headerentry = ((ComposeHeaderEntry *)list->data);
+ headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry));
+
+ if (g_utf8_collate(headerentryname, cc_hdr) == 0) {
+ const gchar *strg = gtk_entry_get_text(GTK_ENTRY(headerentry->entry));
+ Xstrdup_a(str, strg, return -1);
+ g_strstrip(str);
+ if (str[0] != '\0') {
+ compose_convert_header
+ (compose, buf, sizeof(buf), str,
+ strlen("Resent-Cc") + 2, TRUE);
+
+ if (first_cc_address) {
+ fprintf(fp, "Resent-Cc: ");
+ first_cc_address = FALSE;
+ } else {
+ fprintf(fp, ",");
+ }
+ fprintf(fp, "%s", buf);
+ }
+ }
+ }
+ if (!first_cc_address) {
+ fprintf(fp, "\n");
+ }
+
return(0);
}
/* Resent-From */
if (compose->account->name && *compose->account->name) {
compose_convert_header
- (buf, sizeof(buf), compose->account->name,
+ (compose, buf, sizeof(buf), compose->account->name,
strlen("From: "), TRUE);
fprintf(fp, "Resent-From: %s <%s>\n",
buf, compose->account->address);
Xstrdup_a(str, entstr, return -1);
g_strstrip(str);
if (*str != '\0') {
- compose_convert_header(buf, sizeof(buf), str,
+ compose_convert_header(compose, buf, sizeof(buf), str,
strlen("Subject: "), FALSE);
fprintf(fp, "Subject: %s\n", buf);
}
if (compose->account->name
&& *compose->account->name) {
compose_convert_header
- (buf, sizeof(buf),
+ (compose, buf, sizeof(buf),
compose->account->name,
strlen("From: "),
FALSE);
} else {
const gchar *src_codeset;
- out_codeset = conv_get_outgoing_charset_str();
+ out_codeset = conv_get_charset_str(compose->out_encoding);
+ if (!out_codeset)
+ out_codeset = conv_get_outgoing_charset_str();
+
if (!g_ascii_strcasecmp(out_codeset, CS_US_ASCII))
out_codeset = CS_ISO_8859_1;
g_strdup(out_codeset));
/* protect trailing spaces when signing message */
if (action == COMPOSE_WRITE_FOR_SEND && compose->use_signing &&
- privacy_system_can_sign(compose->privacy_system))
+ privacy_system_can_sign(compose->privacy_system)) {
if (encoding == ENC_7BIT)
encoding = ENC_QUOTED_PRINTABLE;
else if (encoding == ENC_8BIT)
encoding = ENC_BASE64;
+ }
if (encoding != ENC_UNKNOWN)
procmime_encode_content(mimetext, encoding);
FILE *fp;
size_t len;
gchar *chars, *tmp;
- const gchar *src_codeset, *dest_codeset;
if ((fp = fopen(file, "wb")) == NULL) {
FILE_OP_ERROR(file, "fopen");
buf = g_new0(gchar, fieldstr->len * 4 + 256);
compose_convert_header
- (buf, fieldstr->len * 4 + 256, fieldstr->str,
+ (compose, buf, fieldstr->len * 4 + 256, fieldstr->str,
strlen(fieldname) + 2, TRUE);
g_string_append_printf(header, "%s: %s\n", fieldname, buf);
g_free(buf);
/* From */
if (compose->account->name && *compose->account->name) {
compose_convert_header
- (buf, sizeof(buf), compose->account->name,
+ (compose, buf, sizeof(buf), compose->account->name,
strlen("From: "), TRUE);
QUOTE_IF_REQUIRED(name, buf);
g_string_append_printf(header, "From: %s <%s>\n",
if (*str != '\0' && !IS_IN_CUSTOM_HEADER("Subject")) {
g_strstrip(str);
if (*str != '\0') {
- compose_convert_header(buf, sizeof(buf), str,
+ compose_convert_header(compose, buf, sizeof(buf), str,
strlen("Subject: "), FALSE);
g_string_append_printf(header, "Subject: %s\n", buf);
}
if (compose->account->organization &&
strlen(compose->account->organization) &&
!IS_IN_CUSTOM_HEADER("Organization")) {
- compose_convert_header(buf, sizeof(buf),
+ compose_convert_header(compose, buf, sizeof(buf),
compose->account->organization,
strlen("Organization: "), FALSE);
g_string_append_printf(header, "Organization: %s\n", buf);
if (custom_header_is_allowed(chdr->name)) {
compose_convert_header
- (buf, sizeof(buf),
+ (compose, buf, sizeof(buf),
chdr->value ? chdr->value : "",
strlen(chdr->name) + 2, FALSE);
g_string_append_printf(header, "%s: %s\n", chdr->name, buf);
if (compose->return_receipt) {
if (compose->account->name
&& *compose->account->name) {
- compose_convert_header(buf, sizeof(buf),
+ compose_convert_header(compose, buf, sizeof(buf),
compose->account->name,
strlen("Disposition-Notification-To: "),
TRUE);
#undef IS_IN_CUSTOM_HEADER
-static void compose_convert_header(gchar *dest, gint len, gchar *src,
+static void compose_convert_header(Compose *compose, gchar *dest, gint len, gchar *src,
gint header_len, gboolean addr_field)
{
gchar *tmpstr = NULL;
subst_char(tmpstr, '\r', ' ');
g_strchomp(tmpstr);
- conv_encode_header(dest, len, tmpstr, header_len, addr_field);
+ conv_encode_header_full(dest, len, tmpstr, header_len, addr_field,
+ conv_get_charset_str(compose->out_encoding));
g_free(tmpstr);
}
if (header)
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), header);
- g_signal_connect(G_OBJECT(GTK_COMBO(combo)->entry), "grab_focus",
- G_CALLBACK(compose_grab_focus_before_cb), compose);
g_signal_connect_after(G_OBJECT(GTK_COMBO(combo)->entry), "grab_focus",
G_CALLBACK(compose_grab_focus_cb), compose);
g_signal_connect(G_OBJECT(entry), "changed",
G_CALLBACK(compose_headerentry_changed_cb),
headerentry);
- g_signal_connect(G_OBJECT(entry), "grab_focus",
- G_CALLBACK(compose_grab_focus_before_cb), compose);
g_signal_connect_after(G_OBJECT(entry), "grab_focus",
G_CALLBACK(compose_grab_focus_cb), compose);
COL_NAME, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(attach_clist), column);
- gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(attach_clist), TRUE);
+ gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(attach_clist),
+ prefs_common.enable_rules_hint);
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(attach_clist));
gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
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);
- g_signal_connect(G_OBJECT(savemsg_entry), "grab_focus",
- G_CALLBACK(compose_grab_focus_before_cb), compose);
g_signal_connect_after(G_OBJECT(savemsg_entry), "grab_focus",
G_CALLBACK(compose_grab_focus_cb), compose);
if (account_get_special_folder(compose->account, F_OUTBOX)) {
g_signal_connect(G_OBJECT(window), "delete_event",
G_CALLBACK(compose_delete_cb), compose);
- g_signal_connect(G_OBJECT(window), "destroy",
- G_CALLBACK(compose_destroy_cb), compose);
MANAGE_WINDOW_SIGNALS_CONNECT(window);
gtk_widget_realize(window);
handlebox = gtk_handle_box_new();
gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
+ gtk_widget_realize(handlebox);
compose->toolbar = toolbar_create(TOOLBAR_COMPOSE, handlebox,
(gpointer)compose);
subject_entry = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(subject), subject_entry, TRUE, TRUE, 2);
- g_signal_connect(G_OBJECT(subject_entry), "grab_focus",
- G_CALLBACK(compose_grab_focus_before_cb), compose);
g_signal_connect_after(G_OBJECT(subject_entry), "grab_focus",
G_CALLBACK(compose_grab_focus_cb), compose);
gtk_widget_show(subject_entry);
compose->priority = PRIORITY_NORMAL;
compose_update_priority_menu_item(compose);
+ compose_set_out_encoding(compose);
+
/* Actions menu */
compose_update_actions_menu(compose);
menu_set_sensitive(ifactory, "/Options/Encrypt", can_encrypt);
}
+static void compose_set_out_encoding(Compose *compose)
+{
+ GtkItemFactoryEntry *entry;
+ GtkItemFactory *ifactory;
+ CharSet out_encoding;
+ gchar *path, *p, *q;
+ GtkWidget *item;
+
+ out_encoding = conv_get_charset_from_str(prefs_common.outgoing_charset);
+ ifactory = gtk_item_factory_from_widget(compose->menubar);
+
+ for (entry = compose_entries; entry->callback != compose_address_cb;
+ entry++) {
+ if (entry->callback == compose_set_encoding_cb &&
+ (CharSet)entry->callback_action == out_encoding) {
+ p = q = path = g_strdup(entry->path);
+ while (*p) {
+ if (*p == '_') {
+ if (p[1] == '_') {
+ p++;
+ *q++ = '_';
+ }
+ } else
+ *q++ = *p;
+ p++;
+ }
+ *q = '\0';
+ item = gtk_item_factory_get_item(ifactory, path);
+ gtk_widget_activate(item);
+ g_free(path);
+ break;
+ }
+ }
+}
+
static void compose_set_template_menu(Compose *compose)
{
GSList *tmpl_list, *cur;
static void compose_destroy(Compose *compose)
{
+ compose_list = g_list_remove(compose_list, compose);
+
/* NOTE: address_completion_end() does nothing with the window
* however this may change. */
address_completion_end(compose->window);
#if USE_ASPELL
if (compose->gtkaspell) {
gtkaspell_delete(compose->gtkaspell);
+ compose->gtkaspell = NULL;
}
#endif
gtk_widget_destroy(compose->paned);
gtk_widget_destroy(compose->popupmenu);
+ gtk_widget_destroy(compose->window);
toolbar_destroy(compose->toolbar);
g_free(compose->toolbar);
g_free(compose);
-
- compose_list = g_list_remove(compose_list, compose);
}
static void compose_attach_info_free(AttachInfo *ainfo)
static void compose_attach_remove_selected(Compose *compose)
{
GtkTreeView *tree_view = GTK_TREE_VIEW(compose->attach_clist);
- AttachInfo *ainfo;
GtkTreeSelection *selection;
GList *sel, *cur;
GtkTreeModel *model;
gpointer data)
{
Compose *compose = (Compose *)data;
- GtkTreeView *tree_view = GTK_TREE_VIEW(compose->attach_clist);
- GtkTreeIter iter;
if (!event) return FALSE;
menu_set_sensitive(ifactory, "/Options", allow);
menu_set_sensitive(ifactory, "/Tools", allow);
menu_set_sensitive(ifactory, "/Help", allow);
+
+ gtk_text_view_set_editable(GTK_TEXT_VIEW(compose->text), allow);
+
}
static void compose_send_cb(gpointer data, guint action, GtkWidget *widget)
compose_close(compose);
}
+static void compose_set_encoding_cb(gpointer data, guint action,
+ GtkWidget *widget)
+{
+ Compose *compose = (Compose *)data;
+
+ if (GTK_CHECK_MENU_ITEM(widget)->active)
+ compose->out_encoding = (CharSet)action;
+}
+
static void compose_address_cb(gpointer data, guint action, GtkWidget *widget)
{
Compose *compose = (Compose *)data;
compose_exec_ext_editor(compose);
}
-static void compose_destroy_cb(GtkWidget *widget, Compose *compose)
-{
- if (compose->sending)
- return;
- compose_destroy(compose);
-}
-
static void compose_undo_cb(Compose *compose)
{
gboolean prev_autowrap = compose->autowrap;
else if (GTK_IS_TEXT_VIEW(entry))
gtk_text_buffer_cut_clipboard(
gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry)),
- gtk_clipboard_get(GDK_NONE),
+ gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),
TRUE);
}
else if (GTK_IS_TEXT_VIEW(entry))
gtk_text_buffer_copy_clipboard(
gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry)),
- gtk_clipboard_get(GDK_NONE));
+ gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
}
static void entry_paste_clipboard(GtkWidget *entry)
else if (GTK_IS_TEXT_VIEW(entry))
gtk_text_buffer_paste_clipboard(
gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry)),
- gtk_clipboard_get(GDK_NONE),
+ gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),
NULL, TRUE);
}
}
}
-static gchar *cliptext = NULL;
-
-static void compose_grab_focus_before_cb(GtkWidget *widget, Compose *compose)
-{
- gchar *str = NULL;
- GtkClipboard *clip = gtk_clipboard_get(gdk_atom_intern("PRIMARY", FALSE));
- if (cliptext) {
- g_free(cliptext);
- cliptext = NULL;
- }
-
- if (gtk_clipboard_wait_is_text_available(clip))
- cliptext = gtk_clipboard_wait_for_text(clip);
-}
-
static void compose_grab_focus_cb(GtkWidget *widget, Compose *compose)
{
gchar *str = NULL;
- GtkClipboard *clip = gtk_clipboard_get(gdk_atom_intern("PRIMARY", FALSE));
if (GTK_IS_EDITABLE(widget)) {
str = gtk_editable_get_chars(GTK_EDITABLE(widget), 0, -1);
strlen(str));
g_free(str);
}
- if (cliptext)
- gtk_clipboard_set_text(clip, cliptext, -1);
if (GTK_IS_EDITABLE(widget) || GTK_IS_TEXT_VIEW(widget))
compose->focused_editable = widget;
gtkut_widget_get_uposition(compose->window, &x, &y);
prefs_common.compose_x = x;
prefs_common.compose_y = y;
- gtk_widget_destroy(compose->window);
+ compose_destroy(compose);
}
/**