2006-08-16 [colin] 2.4.0cvs54
[claws.git] / src / compose.c
index 0fb679ca70507e979455a2997ab930053ccfafd0..b584fc2ae7cec3c3ebb27a77384b86b6ca577108 100644 (file)
@@ -765,8 +765,8 @@ static GtkItemFactoryEntry compose_entries[] =
 static GtkTargetEntry compose_mime_types[] =
 {
        {"text/uri-list", 0, 0},
-       {"text/plain", 0, 0},
-       {"STRING", 0, 0}
+       {"UTF8_STRING", 0, 0},
+       {"text/plain", 0, 0}
 };
 
 static gboolean compose_put_existing_to_front(MsgInfo *info)
@@ -1641,6 +1641,7 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
        gboolean use_signing = FALSE;
        gboolean use_encryption = FALSE;
        gchar *privacy_system = NULL;
+       int priority = PRIORITY_NORMAL;
 
        g_return_val_if_fail(msginfo != NULL, NULL);
        g_return_val_if_fail(msginfo->folder != NULL, NULL);
@@ -1692,7 +1693,7 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
                if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
                                             sizeof(queueheader_buf), "X-Priority: ")) {
                        param = atoi(&queueheader_buf[strlen("X-Priority: ")]); /* mind the space */
-                       compose->priority = param;
+                       priority = param;
                }
        } else {
                account = msginfo->folder->folder->account;
@@ -1713,7 +1714,8 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
        compose = compose_create(account, COMPOSE_REEDIT, batch);
        
        compose->updating = TRUE;
-       
+       compose->priority = priority;
+
        if (privacy_system != NULL) {
                compose->privacy_system = privacy_system;
                compose_use_signing(compose, use_signing);
@@ -2083,7 +2085,7 @@ static void compose_entries_set(Compose *compose, const gchar *mailto)
        gchar *subject = NULL;
        gchar *body = NULL;
        gchar *temp = NULL;
-       gint  len = 0;
+       guint  len = 0;
 
        scan_mailto_url(mailto, &to, &cc, NULL, &subject, &body);
 
@@ -2579,7 +2581,7 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
 
        if (msginfo->subject && *msginfo->subject) {
                gchar *buf, *buf2;
-               guchar *p;
+               gchar *p;
 
                buf = p = g_strdup(msginfo->subject);
                p += subject_get_prefix_length(p);
@@ -4057,6 +4059,8 @@ gint compose_send(Compose *compose)
        gchar *msgpath = NULL;
        gboolean discard_window = FALSE;
        gchar *errstr = NULL;
+       MainWindow *mainwin = mainwindow_get_mainwindow();
+
        if (prefs_common.send_dialog_mode != SEND_DIALOG_ALWAYS
                        || compose->batch == TRUE)
                discard_window = TRUE;
@@ -4151,12 +4155,16 @@ gint compose_send(Compose *compose)
                return -1;
        }
 
+       toolbar_main_set_sensitive(mainwin);
+       main_window_set_menu_sensitive(mainwin);
        return 0;
 
 bail:
        compose_allow_user_actions (compose, TRUE);
        compose->sending = FALSE;
        compose->modified = TRUE; 
+       toolbar_main_set_sensitive(mainwin);
+       main_window_set_menu_sensitive(mainwin);
 
        return -1;
 }
@@ -4497,12 +4505,16 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
        mimetext->subtype = g_strdup("plain");
        g_hash_table_insert(mimetext->typeparameters, g_strdup("charset"),
                            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)) {
                encoding = ENC_QUOTED_PRINTABLE;
        }
        
+       debug_print("main text: %d bytes encoded as %s in %d\n",
+               strlen(buf), out_codeset, encoding);
+
        /* check for line length limit */
        if (action == COMPOSE_WRITE_FOR_SEND &&
            encoding != ENC_QUOTED_PRINTABLE && encoding != ENC_BASE64 &&
@@ -7535,9 +7547,9 @@ static void compose_send_later_cb(gpointer data, guint action,
        gint val;
 
        val = compose_queue_sub(compose, NULL, NULL, NULL, TRUE, TRUE);
-       if (!val) 
+       if (!val) {
                compose_close(compose);
-       else if (val == -1) {
+       else if (val == -1) {
                alertpanel_error(_("Could not queue message."));
        } else if (val == -2) {
                alertpanel_error(_("Could not queue message:\n\n%s."), strerror(errno));
@@ -7549,6 +7561,7 @@ static void compose_send_later_cb(gpointer data, guint action,
                alertpanel_error(_("Could not queue message for sending:\n\n"
                                   "Charset conversion failed."));
        }
+       toolbar_main_set_sensitive(mainwindow_get_mainwindow());
 }
 
 void compose_draft (gpointer data) 
@@ -7930,16 +7943,18 @@ static void entry_paste_clipboard(Compose *compose, GtkWidget *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(clip));
 
                if (contents == NULL)
                        return;
 
+               undo_paste_clipboard(GTK_TEXT_VIEW(compose->text), compose->undostruct);
+
                /* we shouldn't delete the selection when middle-click-pasting, or we
                 * can't mid-click-paste our own selection */
-               if (clip != GDK_SELECTION_PRIMARY)
+               if (clip != GDK_SELECTION_PRIMARY) {
                        gtk_text_buffer_delete_selection(buffer, FALSE, TRUE);
+               }
                
                if (insert_place == NULL) {
                        /* if insert_place isn't specified, insert at the cursor.
@@ -7967,7 +7982,6 @@ static void entry_paste_clipboard(Compose *compose, GtkWidget *entry,
                        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));