2008-06-22 [colin] 3.4.0cvs104
[claws.git] / src / compose.c
index d14f8d83fa6b5d749b41aa7a131b0296eae11215..e0f9654fe1447e5b72d799f0aad99dee791330f4 100644 (file)
 #include "hooks.h"
 #include "privacy.h"
 #include "timing.h"
+#include "autofaces.h"
 
 enum
 {
@@ -152,7 +153,6 @@ typedef enum
        COMPOSE_CALL_ADVANCED_ACTION_DELETE_FORWARD_WORD,
        COMPOSE_CALL_ADVANCED_ACTION_DELETE_BACKWARD_WORD,
        COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE,
-       COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE_N,
        COMPOSE_CALL_ADVANCED_ACTION_DELETE_TO_LINE_END
 } ComposeCallAdvancedAction;
 
@@ -657,11 +657,6 @@ static GtkItemFactoryEntry compose_entries[] =
                                        compose_advanced_action_cb,
                                        COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE,
                                        NULL},
-       {N_("/_Edit/A_dvanced/Delete entire line"),
-                                       NULL,
-                                       compose_advanced_action_cb,
-                                       COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE_N,
-                                       NULL},
        {N_("/_Edit/A_dvanced/Delete to end of line"),
                                        "<control>K",
                                        compose_advanced_action_cb,
@@ -1597,7 +1592,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
 
                } else {
                        qmark = prefs_common.quotemark;
-                       body_fmt = prefs_common.quotefmt;
+                       body_fmt = gettext(prefs_common.quotefmt);
                }
        }
 
@@ -1752,7 +1747,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
                g_free(msgfile);
        } else {
                const gchar *qmark = NULL;
-               const gchar *body_fmt = prefs_common.fw_quotefmt;
+               const gchar *body_fmt = gettext(prefs_common.fw_quotefmt);
                MsgInfo *full_msginfo;
 
                full_msginfo = procmsg_msginfo_get_full_info(msginfo);
@@ -1773,7 +1768,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
 
                } else {
                        qmark = prefs_common.fw_quotemark;
-                       body_fmt = prefs_common.fw_quotefmt;
+                       body_fmt = gettext(prefs_common.fw_quotefmt);
                }
 
                /* empty quotemark is not allowed */
@@ -2928,10 +2923,10 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
        }
 
        cursor_pos = quote_fmt_get_cursor_pos();
+       if (cursor_pos == -1)
+               cursor_pos = gtk_text_iter_get_offset(&iter);
        compose->set_cursor_pos = cursor_pos;
-       if (cursor_pos == -1) {
-               cursor_pos = 0;
-       }
+
        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);
@@ -3238,7 +3233,7 @@ static void compose_insert_sig(Compose *compose, gboolean replace)
        GtkTextBuffer *buffer = gtk_text_view_get_buffer(text);
        GtkTextMark *mark;
        GtkTextIter iter, iter_end;
-       gint cur_pos;
+       gint cur_pos, ins_pos;
        gboolean prev_autowrap;
        gboolean found = FALSE;
        gboolean exists = FALSE;
@@ -3254,6 +3249,7 @@ static void compose_insert_sig(Compose *compose, gboolean replace)
        mark = gtk_text_buffer_get_insert(buffer);
        gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
        cur_pos = gtk_text_iter_get_offset (&iter);
+       ins_pos = cur_pos;
 
        gtk_text_buffer_get_end_iter(buffer, &iter);
 
@@ -3272,7 +3268,7 @@ static void compose_insert_sig(Compose *compose, gboolean replace)
 
                if (found) {
                        /* include previous \n\n */
-                       gtk_text_iter_backward_chars(&first_iter, 2);
+                       gtk_text_iter_backward_chars(&first_iter, 1);
                        start_iter = first_iter;
                        end_iter = first_iter;
                        /* skip re-start */
@@ -3296,20 +3292,26 @@ static void compose_insert_sig(Compose *compose, gboolean replace)
                g_free(compose->sig_str);
                compose->sig_str = NULL;
        } else {
+               if (compose->sig_inserted == FALSE)
+                       gtk_text_buffer_insert(buffer, &iter, "\n", -1);
+               compose->sig_inserted = TRUE;
+
+               cur_pos = gtk_text_iter_get_offset(&iter);
                gtk_text_buffer_insert(buffer, &iter, compose->sig_str, -1);
                /* remove \n\n */
                gtk_text_buffer_get_iter_at_offset(buffer, &iter, cur_pos);
-               gtk_text_iter_forward_chars(&iter, 2);
+               gtk_text_iter_forward_chars(&iter, 1);
                gtk_text_buffer_get_end_iter(buffer, &iter_end);
                gtk_text_buffer_apply_tag_by_name(buffer,"signature",&iter, &iter_end);
 
                if (cur_pos > gtk_text_buffer_get_char_count (buffer))
                        cur_pos = gtk_text_buffer_get_char_count (buffer);
        }
+
        /* put the cursor where it should be 
-        * either where the quote_fmt says, either before the signature */
+        * either where the quote_fmt says, either where it was */
        if (compose->set_cursor_pos < 0)
-               gtk_text_buffer_get_iter_at_offset(buffer, &iter, cur_pos);
+               gtk_text_buffer_get_iter_at_offset(buffer, &iter, ins_pos);
        else
                gtk_text_buffer_get_iter_at_offset(buffer, &iter, 
                        compose->set_cursor_pos);
@@ -3354,11 +3356,11 @@ static gchar *compose_get_signature_str(Compose *compose)
        }
 
        if (compose->account->sig_sep) {
-               sig_str = g_strconcat("\n\n", compose->account->sig_sep, "\n", sig_body,
+               sig_str = g_strconcat("\n", compose->account->sig_sep, "\n", sig_body,
                                      NULL);
                g_free(sig_body);
        } else
-               sig_str = g_strconcat("\n\n", sig_body, NULL);
+               sig_str = g_strconcat("\n", sig_body, NULL);
 
        if (sig_str) {
                if (g_utf8_validate(sig_str, -1, NULL) == TRUE)
@@ -3550,8 +3552,8 @@ static gboolean compose_attach_append(Compose *compose, const gchar *file,
                ainfo->content_type = g_strdup("application/octet-stream");
        }
 
-       ainfo->size = size;
-       size_text = to_human_readable(size);
+       ainfo->size = (goffset)size;
+       size_text = to_human_readable((goffset)size);
 
        store = GTK_LIST_STORE(gtk_tree_view_get_model
                        (GTK_TREE_VIEW(compose->attach_clist)));
@@ -4428,7 +4430,7 @@ static void compose_set_title(Compose *compose)
        subject = gtk_editable_get_chars(
                        GTK_EDITABLE(compose->subject_entry), 0, -1);
 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        if (subject && strlen(subject))
                str = g_strdup_printf(_("%s - Compose message%s"),
                                      subject, edited); 
@@ -4823,7 +4825,7 @@ gint compose_send(Compose *compose)
                g_free(msgpath);
        } else {
                val = procmsg_send_message_queue(msgpath, &errstr, folder, msgnum, &queued_removed);
-               g_unlink(msgpath);
+               claws_unlink(msgpath);
                g_free(msgpath);
        }
        if (!discard_window) {
@@ -5143,9 +5145,10 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
        gchar *chars;
        gchar *buf;
        const gchar *out_codeset;
-       EncodingType encoding;
+       EncodingType encoding = ENC_UNKNOWN;
        MimeInfo *mimemsg, *mimetext;
        gint line;
+       const gchar *src_codeset = CS_INTERNAL;
 
        if (action == COMPOSE_WRITE_FOR_SEND)
                attach_parts = TRUE;
@@ -5164,49 +5167,48 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
        gtk_text_buffer_get_start_iter(buffer, &start);
        gtk_text_buffer_get_end_iter(buffer, &end);
        chars = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
-       if (is_ascii_str(chars)) {
-               buf = chars;
-               chars = NULL;
+
+       out_codeset = conv_get_charset_str(compose->out_encoding);
+
+       if (!out_codeset && is_ascii_str(chars)) {
+               out_codeset = CS_US_ASCII;
+       } else if (prefs_common.outgoing_fallback_to_ascii &&
+                  is_ascii_str(chars)) {
                out_codeset = CS_US_ASCII;
                encoding = ENC_7BIT;
-       } else {
-               const gchar *src_codeset = CS_INTERNAL;
+       }
 
-               out_codeset = conv_get_charset_str(compose->out_encoding);
+       if (!out_codeset) {
+               gchar *test_conv_global_out = NULL;
+               gchar *test_conv_reply = NULL;
 
-               if (!out_codeset) {
-                       gchar *test_conv_global_out = NULL;
-                       gchar *test_conv_reply = NULL;
+               /* automatic mode. be automatic. */
+               codeconv_set_strict(TRUE);
 
-                       /* automatic mode. be automatic. */
-                       codeconv_set_strict(TRUE);
-                       
-                       out_codeset = conv_get_outgoing_charset_str();
-                       if (out_codeset) {
-                               debug_print("trying to convert to %s\n", out_codeset);
-                               test_conv_global_out = conv_codeset_strdup(chars, src_codeset, out_codeset);
-                       }
-                       
-                       if (!test_conv_global_out && compose->orig_charset
-                       &&  strcmp(compose->orig_charset, CS_US_ASCII)) {
-                               out_codeset = compose->orig_charset;
-                               debug_print("failure; trying to convert to %s\n", out_codeset);
-                               test_conv_reply = conv_codeset_strdup(chars, src_codeset, out_codeset);
-                       }
-                       
-                       if (!test_conv_global_out && !test_conv_reply) {
-                               /* we're lost */
-                               out_codeset = CS_INTERNAL;
-                               debug_print("failure; finally using %s\n", out_codeset);
-                       }
-                       g_free(test_conv_global_out);
-                       g_free(test_conv_reply);
-                       codeconv_set_strict(FALSE);
+               out_codeset = conv_get_outgoing_charset_str();
+               if (out_codeset) {
+                       debug_print("trying to convert to %s\n", out_codeset);
+                       test_conv_global_out = conv_codeset_strdup(chars, src_codeset, out_codeset);
                }
 
-               if (!g_ascii_strcasecmp(out_codeset, CS_US_ASCII))
-                       out_codeset = CS_ISO_8859_1;
+               if (!test_conv_global_out && compose->orig_charset
+               &&  strcmp(compose->orig_charset, CS_US_ASCII)) {
+                       out_codeset = compose->orig_charset;
+                       debug_print("failure; trying to convert to %s\n", out_codeset);
+                       test_conv_reply = conv_codeset_strdup(chars, src_codeset, out_codeset);
+               }
+
+               if (!test_conv_global_out && !test_conv_reply) {
+                       /* we're lost */
+                       out_codeset = CS_INTERNAL;
+                       debug_print("failure; finally using %s\n", out_codeset);
+               }
+               g_free(test_conv_global_out);
+               g_free(test_conv_reply);
+               codeconv_set_strict(FALSE);
+       }
 
+       if (encoding == ENC_UNKNOWN) {
                if (prefs_common.encoding_method == CTE_BASE64)
                        encoding = ENC_BASE64;
                else if (prefs_common.encoding_method == CTE_QUOTED_PRINTABLE)
@@ -5215,40 +5217,40 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
                        encoding = ENC_8BIT;
                else
                        encoding = procmime_get_encoding_for_charset(out_codeset);
+       }
 
-               debug_print("src encoding = %s, out encoding = %s, transfer encoding = %s\n",
-                           src_codeset, out_codeset, procmime_get_encoding_str(encoding));
-
-               if (action == COMPOSE_WRITE_FOR_SEND) {
-                       codeconv_set_strict(TRUE);
-                       buf = conv_codeset_strdup(chars, src_codeset, out_codeset);
-                       codeconv_set_strict(FALSE);
-
-                       if (!buf) {
-                               AlertValue aval;
-                               gchar *msg;
+       debug_print("src encoding = %s, out encoding = %s, transfer encoding = %s\n",
+                   src_codeset, out_codeset, procmime_get_encoding_str(encoding));
 
-                               msg = g_strdup_printf(_("Can't convert the character encoding of the message \n"
-                                                       "to the specified %s charset.\n"
-                                                       "Send it as %s?"), out_codeset, src_codeset);
-                               aval = alertpanel_full(_("Error"), msg, GTK_STOCK_CANCEL, _("+_Send"), NULL, FALSE,
-                                                     NULL, ALERT_ERROR, G_ALERTDEFAULT);
-                               g_free(msg);
+       if (action == COMPOSE_WRITE_FOR_SEND) {
+               codeconv_set_strict(TRUE);
+               buf = conv_codeset_strdup(chars, src_codeset, out_codeset);
+               codeconv_set_strict(FALSE);
 
-                               if (aval != G_ALERTALTERNATE) {
-                                       g_free(chars);
-                                       return -3;
-                               } else {
-                                       buf = chars;
-                                       out_codeset = src_codeset;
-                                       chars = NULL;
-                               }
+               if (!buf) {
+                       AlertValue aval;
+                       gchar *msg;
+
+                       msg = g_strdup_printf(_("Can't convert the character encoding of the message \n"
+                                               "to the specified %s charset.\n"
+                                               "Send it as %s?"), out_codeset, src_codeset);
+                       aval = alertpanel_full(_("Error"), msg, GTK_STOCK_CANCEL, _("+_Send"), NULL, FALSE,
+                                             NULL, ALERT_ERROR, G_ALERTDEFAULT);
+                       g_free(msg);
+
+                       if (aval != G_ALERTALTERNATE) {
+                               g_free(chars);
+                               return -3;
+                       } else {
+                               buf = chars;
+                               out_codeset = src_codeset;
+                               chars = NULL;
                        }
-               } else {
-                       buf = chars;
-                       out_codeset = src_codeset;
-                       chars = NULL;
                }
+       } else {
+               buf = chars;
+               out_codeset = src_codeset;
+               chars = NULL;
        }
        g_free(chars);
 
@@ -5379,7 +5381,7 @@ static gint compose_write_body_to_file(Compose *compose, const gchar *file)
                FILE_OP_ERROR(file, "fwrite");
                g_free(chars);
                fclose(fp);
-               g_unlink(file);
+               claws_unlink(file);
                return -1;
        }
 
@@ -5387,7 +5389,7 @@ static gint compose_write_body_to_file(Compose *compose, const gchar *file)
 
        if (fclose(fp) == EOF) {
                FILE_OP_ERROR(file, "fclose");
-               g_unlink(file);
+               claws_unlink(file);
                return -1;
        }
        return 0;
@@ -5590,7 +5592,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                        if (!compose_warn_encryption(compose)) {
                                lock = FALSE;
                                fclose(fp);
-                               g_unlink(tmp);
+                               claws_unlink(tmp);
                                g_free(tmp);
                                return -6;
                        }
@@ -5614,7 +5616,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                                 * key selection */
                                lock = FALSE;
                                fclose(fp);
-                               g_unlink(tmp);
+                               claws_unlink(tmp);
                                g_free(tmp);
                                return -5;
                        }
@@ -5658,7 +5660,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                if (compose_redirect_write_to_file(compose, fp) < 0) {
                        lock = FALSE;
                        fclose(fp);
-                       g_unlink(tmp);
+                       claws_unlink(tmp);
                        g_free(tmp);
                        return -2;
                }
@@ -5667,7 +5669,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                if ((result = compose_write_to_file(compose, fp, COMPOSE_WRITE_FOR_SEND, TRUE)) < 0) {
                        lock = FALSE;
                        fclose(fp);
-                       g_unlink(tmp);
+                       claws_unlink(tmp);
                        g_free(tmp);
                        return result - 1; /* -2 for a generic error, -3 for signing error, -4 for encoding */
                }
@@ -5675,14 +5677,14 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
        if (err == TRUE) {
                g_warning("failed to write queue message\n");
                fclose(fp);
-               g_unlink(tmp);
+               claws_unlink(tmp);
                g_free(tmp);
                lock = FALSE;
                return -2;
        }
        if (fclose(fp) == EOF) {
                FILE_OP_ERROR(tmp, "fclose");
-               g_unlink(tmp);
+               claws_unlink(tmp);
                g_free(tmp);
                lock = FALSE;
                return -2;
@@ -5695,7 +5697,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
        }
        if (!queue) {
                g_warning("can't find queue folder\n");
-               g_unlink(tmp);
+               claws_unlink(tmp);
                g_free(tmp);
                lock = FALSE;
                return -1;
@@ -5703,14 +5705,14 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
        folder_item_scan(queue);
        if ((num = folder_item_add_msg(queue, tmp, NULL, FALSE)) < 0) {
                g_warning("can't queue the message\n");
-               g_unlink(tmp);
+               claws_unlink(tmp);
                g_free(tmp);
                lock = FALSE;
                return -1;
        }
        
        if (msgpath == NULL) {
-               g_unlink(tmp);
+               claws_unlink(tmp);
                g_free(tmp);
        } else
                *msgpath = tmp;
@@ -6026,6 +6028,20 @@ static gchar *compose_get_header(Compose *compose)
                }
        }
 
+       /* Automatic Faces and X-Faces */
+       if (get_account_xface (buf, sizeof(buf), compose->account->account_name) == 0) {
+               g_string_append_printf(header, "X-Face: %s\n", buf);
+       }
+       else if (get_default_xface (buf, sizeof(buf)) == 0) {
+               g_string_append_printf(header, "X-Face: %s\n", buf);
+       }
+       if (get_account_face (buf, sizeof(buf), compose->account->account_name) == 0) {
+               g_string_append_printf(header, "Face: %s\n", buf);
+       }
+       else if (get_default_face (buf, sizeof(buf)) == 0) {
+               g_string_append_printf(header, "Face: %s\n", buf);
+       }
+
        /* PRIORITY */
        switch (compose->priority) {
                case PRIORITY_HIGHEST: g_string_append_printf(header, "Importance: high\n"
@@ -6768,7 +6784,7 @@ static Compose *compose_create(PrefsAccount *account,
        gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL,
                                      &geometry, GDK_HINT_MIN_SIZE);
 
-#ifndef MAEMO  
+#ifndef GENERIC_UMPC   
        if (compose_force_window_origin)
                gtk_widget_set_uposition(window, prefs_common.compose_x, 
                                 prefs_common.compose_y);
@@ -8039,7 +8055,7 @@ static void compose_attach_property(Compose *compose)
                        ainfo->file = file;
                }
                if (size)
-                       ainfo->size = size;
+                       ainfo->size = (goffset)size;
 
                /* update tree store */
                text = to_human_readable(ainfo->size);
@@ -8405,11 +8421,11 @@ static gboolean compose_input_cb(GIOChannel *source, GIOCondition condition,
                compose_insert_file(compose, compose->exteditor_file);
                compose_changed_cb(NULL, compose);
 
-               if (g_unlink(compose->exteditor_file) < 0)
+               if (claws_unlink(compose->exteditor_file) < 0)
                        FILE_OP_ERROR(compose->exteditor_file, "unlink");
        } else if (buf[0] == '1') {     /* failed */
                g_warning("Couldn't exec external editor\n");
-               if (g_unlink(compose->exteditor_file) < 0)
+               if (claws_unlink(compose->exteditor_file) < 0)
                        FILE_OP_ERROR(compose->exteditor_file, "unlink");
        } else if (buf[0] == '2') {
                g_warning("Couldn't write to file\n");
@@ -8852,7 +8868,7 @@ gboolean compose_draft (gpointer data, guint action)
        }
        if (msgnum < 0) {
 warn_err:
-               g_unlink(tmp);
+               claws_unlink(tmp);
                g_free(tmp);
                if (action != COMPOSE_AUTO_SAVE) {
                        if (action != COMPOSE_DRAFT_FOR_EXIT)
@@ -8929,7 +8945,7 @@ warn_err:
                procmsg_msginfo_free(compose->targetinfo);
                compose->targetinfo = procmsg_msginfo_new();
                compose->targetinfo->msgnum = msgnum;
-               compose->targetinfo->size = s.st_size;
+               compose->targetinfo->size = (goffset)s.st_size;
                compose->targetinfo->mtime = s.st_mtime;
                compose->targetinfo->folder = draft;
                if (target_locked)
@@ -8953,7 +8969,7 @@ void compose_clear_exit_drafts(void)
        gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
                                      DRAFTED_AT_EXIT, NULL);
        if (is_file_exist(filepath))
-               g_unlink(filepath);
+               claws_unlink(filepath);
        
        g_free(filepath);
 }
@@ -9261,7 +9277,8 @@ static void entry_paste_clipboard(Compose *compose, GtkWidget *entry,
                }
        } else if (GTK_IS_EDITABLE(entry))
                gtk_editable_paste_clipboard (GTK_EDITABLE(entry));
-       
+
+       compose->modified = TRUE;
 }
 
 static void entry_allsel(GtkWidget *entry)
@@ -9286,7 +9303,7 @@ static void entry_allsel(GtkWidget *entry)
 static void compose_cut_cb(Compose *compose)
 {
        if (compose->focused_editable 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
            && GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
 #endif
            )
@@ -9296,7 +9313,7 @@ static void compose_cut_cb(Compose *compose)
 static void compose_copy_cb(Compose *compose)
 {
        if (compose->focused_editable 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
            && GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
 #endif
            )
@@ -9320,7 +9337,7 @@ static void compose_paste_as_quote_cb(Compose *compose)
 {
        gint wrap_quote = prefs_common.linewrap_quote;
        if (compose->focused_editable 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
            && GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
 #endif
            ) {
@@ -9348,7 +9365,7 @@ static void compose_paste_no_wrap_cb(Compose *compose)
        GtkTextBuffer *buffer;
        BLOCK_WRAP();
        if (compose->focused_editable 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
            && GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
 #endif
            )
@@ -9363,7 +9380,7 @@ static void compose_paste_wrap_cb(Compose *compose)
        GtkTextBuffer *buffer;
        BLOCK_WRAP();
        if (compose->focused_editable 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
            && GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
 #endif
            )
@@ -9375,7 +9392,7 @@ static void compose_paste_wrap_cb(Compose *compose)
 static void compose_allsel_cb(Compose *compose)
 {
        if (compose->focused_editable 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
            && GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
 #endif
            )
@@ -9589,7 +9606,6 @@ static void textview_delete_line (GtkTextView *text)
        GtkTextBuffer *buffer;
        GtkTextMark *mark;
        GtkTextIter ins, start_iter, end_iter;
-       gboolean found;
 
        g_return_if_fail(GTK_IS_TEXT_VIEW(text));
 
@@ -9601,13 +9617,13 @@ static void textview_delete_line (GtkTextView *text)
        gtk_text_iter_set_line_offset(&start_iter, 0);
 
        end_iter = ins;
-       if (gtk_text_iter_ends_line(&end_iter))
-               found = gtk_text_iter_forward_char(&end_iter);
-       else
-               found = gtk_text_iter_forward_to_line_end(&end_iter);
-
-       if (found)
-               gtk_text_buffer_delete(buffer, &start_iter, &end_iter);
+       if (gtk_text_iter_ends_line(&end_iter)){
+               if (!gtk_text_iter_forward_char(&end_iter))
+                       gtk_text_iter_backward_char(&start_iter);
+       }
+       else 
+               gtk_text_iter_forward_to_line_end(&end_iter);
+       gtk_text_buffer_delete(buffer, &start_iter, &end_iter);
 }
 
 static void textview_delete_to_line_end (GtkTextView *text)
@@ -9615,7 +9631,6 @@ static void textview_delete_to_line_end (GtkTextView *text)
        GtkTextBuffer *buffer;
        GtkTextMark *mark;
        GtkTextIter ins, end_iter;
-       gboolean found;
 
        g_return_if_fail(GTK_IS_TEXT_VIEW(text));
 
@@ -9624,11 +9639,10 @@ static void textview_delete_to_line_end (GtkTextView *text)
        gtk_text_buffer_get_iter_at_mark(buffer, &ins, mark);
        end_iter = ins;
        if (gtk_text_iter_ends_line(&end_iter))
-               found = gtk_text_iter_forward_char(&end_iter);
+               gtk_text_iter_forward_char(&end_iter);
        else
-               found = gtk_text_iter_forward_to_line_end(&end_iter);
-       if (found)
-               gtk_text_buffer_delete(buffer, &ins, &end_iter);
+               gtk_text_iter_forward_to_line_end(&end_iter);
+       gtk_text_buffer_delete(buffer, &ins, &end_iter);
 }
 
 static void compose_advanced_action_cb(Compose *compose,
@@ -9651,7 +9665,6 @@ static void compose_advanced_action_cb(Compose *compose,
                {textview_delete_forward_word},
                {textview_delete_backward_word},
                {textview_delete_line},
-               {NULL}, /* gtk_stext_delete_line_n */
                {textview_delete_to_line_end}
        };
 
@@ -9702,7 +9715,7 @@ static void compose_grab_focus_cb(GtkWidget *widget, Compose *compose)
        if (GTK_IS_EDITABLE(widget) || GTK_IS_TEXT_VIEW(widget))
                compose->focused_editable = widget;
        
-#ifdef MAEMO
+#ifdef GENERIC_UMPC
        if (GTK_IS_TEXT_VIEW(widget) 
            && gtk_paned_get_child1(GTK_PANED(compose->paned)) != compose->edit_vbox) {
                gtk_widget_ref(compose->notebook);
@@ -9744,7 +9757,7 @@ static void compose_grab_focus_cb(GtkWidget *widget, Compose *compose)
 static void compose_changed_cb(GtkTextBuffer *textbuf, Compose *compose)
 {
        compose->modified = TRUE;
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        compose_set_title(compose);
 #endif
 }
@@ -9912,7 +9925,7 @@ static void compose_insert_drag_received_cb (GtkWidget            *widget,
                        str_write_to_file(tmpdata, tmpfile);
                        g_free(tmpdata);  
                        compose_insert_file(compose, tmpfile);
-                       g_unlink(tmpfile);
+                       claws_unlink(tmpfile);
                        g_free(tmpfile);
                        gtk_drag_finish(drag_context, TRUE, FALSE, time);
                        compose_beautify_paragraph(compose, NULL, TRUE);
@@ -9972,7 +9985,7 @@ static void compose_insert_drag_received_cb (GtkWidget            *widget,
                gchar *tmpfile = get_tmp_file();
                str_write_to_file((const gchar *)data->data, tmpfile);
                compose_insert_file(compose, tmpfile);
-               g_unlink(tmpfile);
+               claws_unlink(tmpfile);
                g_free(tmpfile);
                gtk_drag_finish(drag_context, TRUE, FALSE, time);
 #endif