#define MAX_REFERENCES_LEN 999
+#define COMPOSE_DRAFT_TIMEOUT_UNSET -1
+#define COMPOSE_DRAFT_TIMEOUT_FORBIDEN -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))
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;
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);
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;