static void compose_attach_parts (Compose *compose,
MsgInfo *msginfo);
-static void compose_wrap_paragraph (Compose *compose,
+static void compose_beautify_paragraph (Compose *compose,
GtkTextIter *par_iter,
gboolean force);
static void compose_wrap_all (Compose *compose);
strcrchomp(buf);
gtk_text_buffer_insert(textbuf, &iter, buf, -1);
}
+ compose_wrap_all_full(compose, FALSE);
compose->autowrap = prev_autowrap;
fclose(fp);
}
!g_utf8_collate(gtk_entry_get_text(entry), mailto)) {
gtk_widget_ensure_style(GTK_WIDGET(entry));
if (!bold_style) {
- PangoFontDescription *font_desc = NULL;
gtkut_convert_int_to_gdk_color
(prefs_common.color_new, &bold_color);
bold_style = gtk_style_copy(gtk_widget_get_style
compose_ext_editor_cb(compose, 0, NULL);
break;
case A_LINEWRAP_CURRENT:
- compose_wrap_paragraph(compose, NULL, TRUE);
+ compose_beautify_paragraph(compose, NULL, TRUE);
break;
case A_LINEWRAP_ALL:
compose_wrap_all_full(compose, TRUE);
g_warning("alloc error scanning URIs\n"); \
}
-static void compose_wrap_paragraph(Compose *compose, GtkTextIter *par_iter, gboolean force)
+static void compose_beautify_paragraph(Compose *compose, GtkTextIter *par_iter, gboolean force)
{
GtkTextView *text = GTK_TEXT_VIEW(compose->text);
GtkTextBuffer *buffer;
}
goto colorize;
}
- debug_print("compose_wrap_paragraph(): quote_str = '%s'\n", quote_str);
- startq_offset = gtk_text_iter_get_offset(&iter);
+ debug_print("compose_beautify_paragraph(): quote_str = '%s'\n", quote_str);
+ if (startq_offset == -1)
+ startq_offset = gtk_text_iter_get_offset(&iter);
} else {
if (startq_offset == -1)
noq_offset = gtk_text_iter_get_offset(&iter);
}
- if (prev_autowrap == FALSE && !force) {
+ if (prev_autowrap == FALSE && !force && !wrap_quote) {
goto colorize;
}
if (compose_get_line_break_pos(buffer, &iter, &break_pos,
prefs_common.linewrap_len,
quote_len)) {
GtkTextIter prev, next, cur;
-
- gtk_text_buffer_insert(buffer, &break_pos, "\n", 1);
+ if (prev_autowrap != FALSE || force)
+ gtk_text_buffer_insert(buffer, &break_pos, "\n", 1);
+ else if (quote_str && wrap_quote)
+ gtk_text_buffer_insert(buffer, &break_pos, "\n", 1);
+ else
+ goto colorize;
/* remove trailing spaces */
cur = break_pos;
gtk_text_iter_backward_char(&cur);
gtk_text_buffer_get_start_iter(buffer, &iter);
while (!gtk_text_iter_is_end(&iter))
- compose_wrap_paragraph(compose, &iter, force);
+ compose_beautify_paragraph(compose, &iter, force);
undo_unblock(compose->undostruct);
}
}
/* check for line length limit */
- if (encoding != ENC_QUOTED_PRINTABLE && encoding != ENC_BASE64 &&
+ if (action == COMPOSE_WRITE_FOR_SEND &&
+ encoding != ENC_QUOTED_PRINTABLE && encoding != ENC_BASE64 &&
check_line_length(buf, 1000, &line) < 0) {
AlertValue aval;
gchar *msg;
"\n"
"Send it anyway?"), line + 1);
aval = alertpanel(_("Warning"), msg, GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
+ g_free(msg);
if (aval != G_ALERTDEFAULT) {
- g_free(msg);
- fclose(fp);
- g_free(buf);
return -1;
}
}
if (compose->privacy_system != NULL) {
fprintf(fp, "X-Sylpheed-Privacy-System:%s\n", compose->privacy_system);
fprintf(fp, "X-Sylpheed-Sign:%d\n", compose->use_signing);
- fprintf(fp, "X-Sylpheed-Encrypt:%d\n", compose->use_encryption);
if (compose->use_encryption) {
gchar *encdata;
encdata = privacy_get_encrypt_data(compose->privacy_system, compose->to_list);
- if (encdata != NULL)
- fprintf(fp, "X-Sylpheed-Encrypt-Data:%s\n",
- encdata);
+ if (encdata != NULL) {
+ if (strcmp(encdata, "_DONT_ENCRYPT_")) {
+ fprintf(fp, "X-Sylpheed-Encrypt:%d\n", compose->use_encryption);
+ fprintf(fp, "X-Sylpheed-Encrypt-Data:%s\n",
+ encdata);
+ } /* else we finally dont want to encrypt */
+ } else {
+ fprintf(fp, "X-Sylpheed-Encrypt:%d\n", compose->use_encryption);
+ /* and if encdata was null, it means there's been a problem in
+ * key selection */
+ }
g_free(encdata);
}
}
g_free(path);
}
+static void entry_paste_clipboard(Compose *compose, GtkWidget *entry, gboolean wrap,
+ GdkAtom clip);
+static gboolean text_clicked(GtkWidget *text, GdkEventButton *event,
+ Compose *compose)
+{
+ if (event->button == 2) {
+ entry_paste_clipboard(compose, compose->focused_editable,
+ prefs_common.linewrap_pastes,
+ GDK_SELECTION_PRIMARY);
+ return TRUE;
+ }
+ return FALSE;
+}
+
static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
{
Compose *compose;
G_CALLBACK(compose_grab_focus_cb), compose);
g_signal_connect(G_OBJECT(buffer), "insert_text",
G_CALLBACK(text_inserted), compose);
+ g_signal_connect(G_OBJECT(text), "button_press_event",
+ G_CALLBACK(text_clicked), compose);
/* drag and drop */
gtk_drag_dest_set(text, GTK_DEST_DEFAULT_ALL, compose_mime_types,
GtkTextIter iter;
gchar *qmark;
gchar *parsed_str;
-
+ gint cursor_pos = 0;
if (!tmpl || !tmpl->value) return;
text = GTK_TEXT_VIEW(compose->text);
gtk_text_buffer_get_start_iter(buffer, &iter);
gtk_text_buffer_place_cursor(buffer, &iter);
}
+
+ if (parsed_str) {
+ cursor_pos = quote_fmt_get_cursor_pos();
+ gtk_text_buffer_get_start_iter(buffer, &iter);
+ gtk_text_buffer_get_iter_at_offset(buffer, &iter, cursor_pos);
+ gtk_text_buffer_place_cursor(buffer, &iter);
+ }
if (parsed_str)
compose_changed_cb(NULL, compose);
g_unlink(tmp);
g_free(tmp);
lock = FALSE;
+ if (action != COMPOSE_AUTO_SAVE)
+ alertpanel_error(_("Could not save draft."));
return;
}
g_free(tmp);
if (action == COMPOSE_AUTO_SAVE) {
compose->autosaved_draft = compose->targetinfo;
}
+ compose->modified = FALSE;
+ compose_set_title(compose);
}
}
gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
}
-static void entry_paste_clipboard(GtkWidget *entry, gboolean wrap)
+static void entry_paste_clipboard(Compose *compose, GtkWidget *entry,
+ gboolean wrap, GdkAtom clip)
{
- if (GTK_IS_EDITABLE(entry))
- gtk_editable_paste_clipboard (GTK_EDITABLE(entry));
- else if (GTK_IS_TEXT_VIEW(entry)) {
+ if (GTK_IS_TEXT_VIEW(entry)) {
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry));
GtkTextMark *mark_start = gtk_text_buffer_get_insert(buffer);
GtkTextIter start_iter, end_iter;
gint start, end;
- gchar *contents = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
+ gchar *contents = gtk_clipboard_wait_for_text(gtk_clipboard_get(clip));
if (contents == NULL)
return;
gtk_text_buffer_get_iter_at_offset(buffer, &start_iter, start);
gtk_text_buffer_get_iter_at_offset(buffer, &end_iter, end);
gtk_text_buffer_apply_tag_by_name(buffer, "no_wrap", &start_iter, &end_iter);
+ } else if (wrap && clip == GDK_SELECTION_PRIMARY) {
+ mark_start = gtk_text_buffer_get_insert(buffer);
+ gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark_start);
+ gtk_text_iter_backward_char(&start_iter);
+ compose_beautify_paragraph(compose, &start_iter, TRUE);
}
- }
+ } else if (GTK_IS_EDITABLE(entry))
+ gtk_editable_paste_clipboard (GTK_EDITABLE(entry));
+
}
static void entry_allsel(GtkWidget *entry)
BLOCK_WRAP();
if (compose->focused_editable &&
GTK_WIDGET_HAS_FOCUS(compose->focused_editable))
- entry_paste_clipboard(compose->focused_editable, prefs_common.linewrap_pastes);
+ entry_paste_clipboard(compose, compose->focused_editable,
+ prefs_common.linewrap_pastes,
+ GDK_SELECTION_CLIPBOARD);
UNBLOCK_WRAP();
}
"paste_as_quotation",
GINT_TO_POINTER(paste_as_quotation + 1));
prefs_common.linewrap_quote = prefs_common.linewrap_pastes;
- entry_paste_clipboard(compose->focused_editable, prefs_common.linewrap_pastes);
+ entry_paste_clipboard(compose, compose->focused_editable,
+ prefs_common.linewrap_pastes,
+ GDK_SELECTION_CLIPBOARD);
prefs_common.linewrap_quote = wrap_quote;
}
}
BLOCK_WRAP();
if (compose->focused_editable &&
GTK_WIDGET_HAS_FOCUS(compose->focused_editable))
- entry_paste_clipboard(compose->focused_editable, FALSE);
+ entry_paste_clipboard(compose, compose->focused_editable, FALSE,
+ GDK_SELECTION_CLIPBOARD);
UNBLOCK_WRAP();
}
BLOCK_WRAP();
if (compose->focused_editable &&
GTK_WIDGET_HAS_FOCUS(compose->focused_editable))
- entry_paste_clipboard(compose->focused_editable, TRUE);
+ entry_paste_clipboard(compose, compose->focused_editable, TRUE,
+ GDK_SELECTION_CLIPBOARD);
UNBLOCK_WRAP();
}
if (action == 1)
compose_wrap_all_full(compose, TRUE);
else
- compose_wrap_paragraph(compose, NULL, TRUE);
+ compose_beautify_paragraph(compose, NULL, TRUE);
}
static void compose_toggle_autowrap_cb(gpointer data, guint action,
mark = gtk_text_buffer_create_mark(buffer, NULL, iter, FALSE);
-/* compose_wrap_all_full(compose, FALSE); */
- compose_wrap_paragraph(compose, iter, FALSE);
+ compose_beautify_paragraph(compose, iter, FALSE);
gtk_text_buffer_get_iter_at_mark(buffer, iter, mark);
gtk_text_buffer_delete_mark(buffer, mark);