#define MAX_REFERENCES_LEN 999
+#define COMPOSE_DRAFT_TIMEOUT_UNSET -1
+#define COMPOSE_DRAFT_TIMEOUT_FORBIDDEN -2
+
static GList *compose_list = NULL;
static GSList *extra_headers = NULL;
if (prefs_common.auto_exteditor)
compose_exec_ext_editor(compose);
- compose->draft_timeout_tag = -1;
+ compose->draft_timeout_tag = COMPOSE_DRAFT_TIMEOUT_UNSET;
+
SCROLL_TO_CURSOR(compose);
compose->modified = FALSE;
compose_set_title(compose);
compose->updating = FALSE;
- compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
+ compose->draft_timeout_tag = COMPOSE_DRAFT_TIMEOUT_UNSET; /* desinhibit auto-drafting after loading */
SCROLL_TO_CURSOR(compose);
if (compose->deferred_destroy) {
compose_set_title(compose);
compose->updating = FALSE;
- compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
+ compose->draft_timeout_tag = COMPOSE_DRAFT_TIMEOUT_UNSET; /* desinhibit auto-drafting after loading */
SCROLL_TO_CURSOR(compose);
if (compose->deferred_destroy) {
compose_set_title(compose);
compose->updating = FALSE;
- compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
+ compose->draft_timeout_tag = COMPOSE_DRAFT_TIMEOUT_UNSET; /* desinhibit auto-drafting after loading */
SCROLL_TO_CURSOR(compose);
if (compose->deferred_destroy) {
G_CALLBACK(text_inserted), \
compose); \
}
-#define UNBLOCK_WRAP() { \
- compose->autowrap = prev_autowrap; \
- if (compose->autowrap) { \
- gint old = compose->draft_timeout_tag; \
- compose->draft_timeout_tag = -2; \
- compose_wrap_all(compose); \
- compose->draft_timeout_tag = old; \
- } \
- \
- g_signal_handlers_unblock_by_func(G_OBJECT(buffer), \
- G_CALLBACK(compose_changed_cb), \
- compose); \
- g_signal_handlers_unblock_by_func(G_OBJECT(buffer), \
- G_CALLBACK(text_inserted), \
- compose); \
+#define UNBLOCK_WRAP() { \
+ compose->autowrap = prev_autowrap; \
+ if (compose->autowrap) { \
+ gint old = compose->draft_timeout_tag; \
+ compose->draft_timeout_tag = COMPOSE_DRAFT_TIMEOUT_FORBIDDEN; \
+ compose_wrap_all(compose); \
+ compose->draft_timeout_tag = old; \
+ } \
+ \
+ g_signal_handlers_unblock_by_func(G_OBJECT(buffer), \
+ G_CALLBACK(compose_changed_cb), \
+ compose); \
+ g_signal_handlers_unblock_by_func(G_OBJECT(buffer), \
+ G_CALLBACK(text_inserted), \
+ compose); \
}
Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
compose_set_title(compose);
compose->updating = FALSE;
- compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
+ compose->draft_timeout_tag = COMPOSE_DRAFT_TIMEOUT_UNSET; /* desinhibit auto-drafting after loading */
SCROLL_TO_CURSOR(compose);
if (compose->deferred_destroy) {
compose->modified = FALSE;
compose_set_title(compose);
compose->updating = FALSE;
- compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
+ compose->draft_timeout_tag = COMPOSE_DRAFT_TIMEOUT_UNSET; /* desinhibit auto-drafting after loading */
SCROLL_TO_CURSOR(compose);
if (compose->deferred_destroy) {
if (force) {
modified = TRUE;
}
- if (compose->draft_timeout_tag == -2) {
+ if (compose->draft_timeout_tag == COMPOSE_DRAFT_TIMEOUT_FORBIDDEN) {
modified = TRUE;
}
}
- if (compose->draft_timeout_tag == -2) {
+ if (compose->draft_timeout_tag == COMPOSE_DRAFT_TIMEOUT_FORBIDDEN) {
if (gtk_text_iter_ends_line(&iter)) {
while (gtk_text_iter_ends_line(&iter) &&
gtk_text_iter_forward_line(&iter))
}
generate_msgid(buf, sizeof(buf), addr);
err |= (fprintf(fp, "Resent-Message-ID: <%s>\n", buf) < 0);
+ if (compose->msgid)
+ g_free(compose->msgid);
compose->msgid = g_strdup(buf);
} else {
compose->msgid = NULL;
}
generate_msgid(buf, sizeof(buf), addr);
g_string_append_printf(header, "Message-ID: <%s>\n", buf);
+ if (compose->msgid)
+ g_free(compose->msgid);
compose->msgid = g_strdup(buf);
} else {
compose->msgid = NULL;
gtk_table_attach(GTK_TABLE(compose->header_table), combo, 0, 1,
compose->header_nextrow, compose->header_nextrow+1,
GTK_SHRINK, GTK_FILL, 0, 0);
- if (compose->header_last && (compose->draft_timeout_tag != -2)) {
+ if (compose->header_last && (compose->draft_timeout_tag != COMPOSE_DRAFT_TIMEOUT_FORBIDDEN)) {
const gchar *last_header_entry = gtk_entry_get_text(
GTK_ENTRY(gtk_bin_get_child(GTK_BIN((compose->header_last->combo)))));
string = headers;
/* Notebook */
notebook = gtk_notebook_new();
- gtk_widget_set_size_request(notebook, -1, prefs_common.compose_notebook_height);
gtk_widget_show(notebook);
/* header labels and entries */
gtk_container_set_border_width(GTK_CONTAINER(subject), 0);
gtk_widget_show(subject);
- label = gtk_label_new(_("Subject:"));
+ label = gtk_label_new_with_mnemonic(_("Subject:"));
gtk_box_pack_start(GTK_BOX(subject), label, FALSE, FALSE, 0);
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(subject), subject_entry, TRUE, TRUE, 0);
g_signal_connect_after(G_OBJECT(subject_entry), "grab_focus",
G_CALLBACK(compose_grab_focus_cb), compose);
+ gtk_label_set_mnemonic_widget(GTK_LABEL(label), subject_entry);
gtk_widget_show(subject_entry);
compose->subject_entry = subject_entry;
gtk_container_add(GTK_CONTAINER(subject_frame), subject);
/* pane between attach clist and text */
paned = gtk_vpaned_new();
gtk_container_add(GTK_CONTAINER(vbox2), paned);
- gtk_paned_add1(GTK_PANED(paned), notebook);
- gtk_paned_add2(GTK_PANED(paned), edit_vbox);
+ gtk_paned_pack1(GTK_PANED(paned), notebook, FALSE, FALSE);
+ gtk_paned_pack2(GTK_PANED(paned), edit_vbox, TRUE, FALSE);
+ gtk_paned_set_position(GTK_PANED(paned), prefs_common.compose_notebook_height);
gtk_widget_show_all(paned);
compose->exteditor_file = NULL;
compose->exteditor_pid = -1;
compose->exteditor_tag = -1;
- compose->draft_timeout_tag = -2; /* inhibit auto-drafting while loading */
+ compose->draft_timeout_tag = COMPOSE_DRAFT_TIMEOUT_FORBIDDEN; /* inhibit auto-drafting while loading */
#if USE_ENCHANT
cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", FALSE);
if (compose->draft_timeout_tag >= 0) { /* CLAWS: disable draft timeout */
g_source_remove(compose->draft_timeout_tag);
- compose->draft_timeout_tag = -1;
+ compose->draft_timeout_tag = COMPOSE_DRAFT_TIMEOUT_UNSET;
}
compose_send(compose);
GdkEventKey *event,
Compose *compose)
{
+ GtkTextBuffer *buffer;
+ GtkTextMark *mark;
+ GtkTextIter iter;
+
cm_return_val_if_fail(compose != NULL, FALSE);
/* make backtab move to subject field */
gtk_widget_grab_focus(compose->subject_entry);
return TRUE;
}
+
+ // Up key should also move the focus to subject field, if the cursor
+ // is on the first line.
+ if (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_KP_Up) {
+ buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
+ g_return_val_if_fail(buffer != NULL, FALSE);
+
+ mark = gtk_text_buffer_get_mark(buffer, "insert");
+ g_return_val_if_fail(mark != NULL, FALSE);
+
+ gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
+
+ if (gtk_text_iter_get_line(&iter) == 0) {
+ gtk_widget_grab_focus(compose->subject_entry);
+ return TRUE;
+ }
+ }
+
return FALSE;
}
static gboolean compose_defer_auto_save_draft(Compose *compose)
{
- compose->draft_timeout_tag = -1;
+ compose->draft_timeout_tag = COMPOSE_DRAFT_TIMEOUT_UNSET;
compose_draft((gpointer)compose, COMPOSE_AUTO_SAVE);
return FALSE;
}
if (compose_can_autosave(compose) &&
gtk_text_buffer_get_char_count(buffer) % prefs_common.autosave_length == 0 &&
- compose->draft_timeout_tag != -2 /* disabled while loading */)
+ compose->draft_timeout_tag != COMPOSE_DRAFT_TIMEOUT_FORBIDDEN /* disabled while loading */)
compose->draft_timeout_tag = g_timeout_add
(500, (GSourceFunc) compose_defer_auto_save_draft, compose);
}
{
gint x, y;
+ cm_return_val_if_fail(compose, FALSE);
+
if (!g_mutex_trylock(compose->mutex)) {
/* we have to wait for the (possibly deferred by auto-save)
* drafting to be done, before destroying the compose under
* it. */
debug_print("waiting for drafting to finish...\n");
compose_allow_user_actions(compose, FALSE);
- g_timeout_add (500, (GSourceFunc) compose_close, compose);
+ if (compose->close_timeout_tag == 0) {
+ compose->close_timeout_tag =
+ g_timeout_add (500, (GSourceFunc) compose_close,
+ compose);
+ }
return FALSE;
}
- cm_return_val_if_fail(compose, FALSE);
+
+ if (compose->close_timeout_tag) {
+ /* let the close be done by the deferred callback */
+ g_mutex_unlock(compose->mutex);
+ return FALSE;
+ }
+
gtkut_widget_get_uposition(compose->window, &x, &y);
if (!compose->batch) {
prefs_common.compose_x = x;