2012-04-02 [colin] 3.8.0cvs37
[claws.git] / src / compose.c
index 2ad073a6a8a4c381928393bfd2f6b45c64892768..833d31708da083187b6f2000bac217c094057902 100644 (file)
 #include "main.h"
 #include "mainwindow.h"
 #include "compose.h"
-#include "addressbook.h"
+#ifndef USE_NEW_ADDRBOOK
+       #include "addressbook.h"
+#else
+       #include "addressbook-dbus.h"
+       #include "addressadd.h"
+#endif
 #include "folderview.h"
 #include "procmsg.h"
 #include "menu.h"
@@ -180,7 +185,7 @@ static GList *compose_list = NULL;
 static Compose *compose_generic_new                    (PrefsAccount   *account,
                                                 const gchar    *to,
                                                 FolderItem     *item,
-                                                GPtrArray      *attach_files,
+                                                GList          *attach_files,
                                                 GList          *listAddress );
 
 static Compose *compose_create                 (PrefsAccount   *account,
@@ -220,6 +225,9 @@ static MailField compose_entries_set                (Compose        *compose,
                                                 ComposeEntryType to_type);
 static gint compose_parse_header               (Compose        *compose,
                                                 MsgInfo        *msginfo);
+static gint compose_parse_manual_headers       (Compose        *compose,
+                                                MsgInfo        *msginfo,
+                                                HeaderEntry    *entries);
 static gchar *compose_parse_references         (const gchar    *ref,
                                                 const gchar    *msgid);
 
@@ -291,6 +299,7 @@ static gint compose_queue_sub                       (Compose        *compose,
 static int compose_add_attachments             (Compose        *compose,
                                                 MimeInfo       *parent);
 static gchar *compose_get_header               (Compose        *compose);
+static gchar *compose_get_manual_headers_info  (Compose        *compose);
 
 static void compose_convert_header             (Compose        *compose,
                                                 gchar          *dest,
@@ -351,6 +360,9 @@ static void compose_add_field_list  ( Compose *compose,
 
 /* callback functions */
 
+static void compose_notebook_size_alloc (GtkNotebook *notebook,
+                                        GtkAllocation *allocation,
+                                        Compose *compose);
 static gboolean compose_edit_size_alloc (GtkEditable   *widget,
                                         GtkAllocation  *allocation,
                                         GtkSHRuler     *shruler);
@@ -381,6 +393,8 @@ static void compose_insert_sig_cb   (GtkAction      *action,
 
 static void compose_close_cb           (GtkAction      *action,
                                         gpointer        data);
+static void compose_print_cb           (GtkAction      *action,
+                                        gpointer        data);
 
 static void compose_set_encoding_cb    (GtkAction      *action, GtkRadioAction *current, gpointer data);
 
@@ -569,6 +583,8 @@ static GtkActionEntry compose_entries[] =
        /* {"Message/---",              NULL, "---" }, */
        {"Message/Save",                NULL, N_("_Save"), "<control>S", NULL, G_CALLBACK(compose_save_cb) }, /*COMPOSE_KEEP_EDITING*/
        /* {"Message/---",              NULL, "---" }, */
+       {"Message/Print",               NULL, N_("_Print"), NULL, NULL, G_CALLBACK(compose_print_cb) },
+       /* {"Message/---",              NULL, "---" }, */
        {"Message/Close",               NULL, N_("_Close"), "<control>W", NULL, G_CALLBACK(compose_close_cb) },
 
 /* Edit menu */
@@ -880,7 +896,7 @@ static void compose_create_tags(GtkTextView *text, Compose *compose)
 }
 
 Compose *compose_new(PrefsAccount *account, const gchar *mailto,
-                    GPtrArray *attach_files)
+                    GList *attach_files)
 {
        return compose_generic_new(account, mailto, NULL, attach_files, NULL);
 }
@@ -940,7 +956,7 @@ static gchar *compose_get_save_to(Compose *compose)
 }
 
 Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderItem *item,
-                            GPtrArray *attach_files, GList *listAddress )
+                            GList *attach_files, GList *listAddress )
 {
        Compose *compose;
        GtkTextView *textview;
@@ -1148,12 +1164,13 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
        procmsg_msginfo_free( dummyinfo );
 
        if (attach_files) {
-               gint i;
-               gchar *file;
+               GList *curr;
+               AttachInfo *ainfo;
 
-               for (i = 0; i < attach_files->len; i++) {
-                       file = g_ptr_array_index(attach_files, i);
-                       compose_attach_append(compose, file, file, NULL, NULL);
+               for (curr = attach_files ; curr != NULL ; curr = curr->next) {
+                       ainfo = (AttachInfo *) curr->data;
+                       compose_attach_append(compose, ainfo->file, ainfo->name,
+                                       ainfo->content_type, ainfo->charset);
                }
        }
 
@@ -1584,7 +1601,8 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
 
        undo_block(compose->undostruct);
 #ifdef USE_ENCHANT
-               compose_set_dictionaries_from_folder_prefs(compose, msginfo->folder);
+       compose_set_dictionaries_from_folder_prefs(compose, msginfo->folder);
+       gtkaspell_block_check(compose->gtkaspell);
 #endif
 
        if (quote_mode == COMPOSE_QUOTE_FORCED ||
@@ -1620,10 +1638,6 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
                                          _("The body of the \"Reply\" template has an error at line %d."));
                compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
                quote_fmt_reset_vartable();
-#ifdef USE_ENCHANT
-               if (compose->gtkaspell && compose->gtkaspell->check_while_typing)
-                       gtkaspell_highlight_all(compose->gtkaspell);
-#endif
        }
 
        if (MSG_IS_ENCRYPTED(compose->replyinfo->flags)) {
@@ -1643,6 +1657,11 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
 
        compose_wrap_all(compose);
 
+#ifdef USE_ENCHANT
+       if (compose->gtkaspell && compose->gtkaspell->check_while_typing)
+               gtkaspell_highlight_all(compose->gtkaspell);
+       gtkaspell_unblock_check(compose->gtkaspell);
+#endif
        SIGNAL_UNBLOCK(textbuf);
        
        gtk_widget_grab_focus(compose->text);
@@ -1741,6 +1760,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
                pref_get_unescaped_pref(tmp, msginfo->folder->prefs->forward_override_from_format);
 
 #ifdef USE_ENCHANT
+               gtkaspell_block_check(compose->gtkaspell);
                quote_fmt_init(full_msginfo, NULL, NULL, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
@@ -1822,10 +1842,6 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
                compose_attach_parts(compose, msginfo);
 
                procmsg_msginfo_free(full_msginfo);
-#ifdef USE_ENCHANT
-               if (compose->gtkaspell && compose->gtkaspell->check_while_typing)
-                       gtkaspell_highlight_all(compose->gtkaspell);
-#endif
        }
 
        SIGNAL_BLOCK(textbuf);
@@ -1835,6 +1851,11 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
 
        compose_wrap_all(compose);
 
+#ifdef USE_ENCHANT
+       if (compose->gtkaspell && compose->gtkaspell->check_while_typing)
+               gtkaspell_highlight_all(compose->gtkaspell);
+       gtkaspell_unblock_check(compose->gtkaspell);
+#endif
        SIGNAL_UNBLOCK(textbuf);
        
        cursor_pos = quote_fmt_get_cursor_pos();
@@ -2117,6 +2138,7 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
        MsgInfo *replyinfo = NULL, *fwdinfo = NULL;
        gboolean autowrap = prefs_common.autowrap;
        gboolean autoindent = prefs_common.auto_indent;
+       HeaderEntry *manual_headers = NULL;
 
        cm_return_val_if_fail(msginfo != NULL, NULL);
        cm_return_val_if_fail(msginfo->folder != NULL, NULL);
@@ -2223,6 +2245,15 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
                        }
                        g_strfreev(tokens);
                }
+               /* Get manual headers */
+               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, sizeof(queueheader_buf), "X-Claws-Manual-Headers:")) {
+                       gchar *listmh = g_strdup(&queueheader_buf[strlen("X-Claws-Manual-Headers:")]);
+                       if (*listmh != '\0') {
+                               debug_print("Got manual headers: %s\n", listmh);
+                               manual_headers = procheader_entries_from_str(listmh);
+                       }
+                       g_free(listmh);
+               }
        } else {
                account = msginfo->folder->folder->account;
        }
@@ -2331,6 +2362,16 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
                                        G_CALLBACK(compose_changed_cb),
                                        compose);
 
+       if (manual_headers != NULL) {
+               if (compose_parse_manual_headers(compose, msginfo, manual_headers) < 0) {
+                       procheader_entries_free(manual_headers);
+                       compose->updating = FALSE;
+                       compose_destroy(compose);
+                       return NULL;
+               }
+               procheader_entries_free(manual_headers);
+       }
+
        gtk_widget_grab_focus(compose->text);
 
         if (prefs_common.auto_exteditor) {
@@ -2871,6 +2912,33 @@ static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
        return 0;
 }
 
+static gint compose_parse_manual_headers(Compose *compose, MsgInfo *msginfo, HeaderEntry *entries)
+{
+       FILE *fp;
+       HeaderEntry *he;
+
+       cm_return_val_if_fail(msginfo != NULL, -1);
+
+       if ((fp = procmsg_open_message(msginfo)) == NULL) return -1;
+       procheader_get_header_fields(fp, entries);
+       fclose(fp);
+
+       he = entries;
+       while (he != NULL && he->name != NULL) {
+               GtkTreeIter iter;
+               GtkListStore *model = NULL;
+
+               debug_print("Adding manual header: %s with value %s\n", he->name, he->body);
+               model = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(compose->header_last->combo)));
+               COMBOBOX_ADD(model, he->name, COMPOSE_TO);
+               gtk_combo_box_set_active_iter(GTK_COMBO_BOX(compose->header_last->combo), &iter);
+               gtk_entry_set_text(GTK_ENTRY(compose->header_last->entry), he->body);
+               ++he;
+       }
+
+       return 0;
+}
+
 static gchar *compose_parse_references(const gchar *ref, const gchar *msgid)
 {
        GSList *ref_id_list, *cur;
@@ -4555,7 +4623,7 @@ end:
                *par_iter = iter;
        undo_wrapping(compose->undostruct, FALSE);
        compose->autowrap = prev_autowrap;
-       
+
        return modified;
 }
 
@@ -6098,6 +6166,55 @@ static void compose_add_headerfield_from_headerlist(Compose *compose,
        return;
 }
 
+static gchar *compose_get_manual_headers_info(Compose *compose)
+{
+       GString *sh_header = g_string_new(" ");
+       GSList *list;
+       gchar *std_headers[] = {"To:", "Cc:", "Bcc:", "Newsgroups:", "Reply-To:", "Followup-To:", NULL};
+
+       for (list = compose->header_list; list; list = list->next) {
+               ComposeHeaderEntry *headerentry;
+               gchar *tmp;
+               gchar *headername;
+               gchar *headername_wcolon;
+               const gchar *headername_trans;
+               gchar **string;
+               gboolean standard_header = FALSE;
+
+               headerentry = ((ComposeHeaderEntry *)list->data);
+
+               tmp = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN((headerentry->combo))))));
+               g_strstrip(tmp);
+               if (*tmp == '\0' || strchr(tmp, ' ') != NULL || strchr(tmp, '\r') != NULL || strchr(tmp, '\n') != NULL) {
+                       g_free(tmp);
+                       continue;
+               }
+
+               if (!strstr(tmp, ":")) {
+                       headername_wcolon = g_strconcat(tmp, ":", NULL);
+                       headername = g_strdup(tmp);
+               } else {
+                       headername_wcolon = g_strdup(tmp);
+                       headername = g_strdup(strtok(tmp, ":"));
+               }
+               g_free(tmp);
+               
+               string = std_headers;
+               while (*string != NULL) {
+                       headername_trans = prefs_common_translated_header_name(*string);
+                       if (!strcmp(headername_trans, headername_wcolon))
+                               standard_header = TRUE;
+                       string++;
+               }
+               if (!standard_header && !IS_IN_CUSTOM_HEADER(headername))
+                       g_string_append_printf(sh_header, "%s ", headername);
+               g_free(headername);
+               g_free(headername_wcolon);
+       }
+       g_string_truncate(sh_header, strlen(sh_header->str) - 1); /* remove last space */
+       return g_string_free(sh_header, FALSE);
+}
+
 static gchar *compose_get_header(Compose *compose)
 {
        gchar buf[BUFFSIZE];
@@ -6459,7 +6576,14 @@ static void compose_add_to_addressbook_cb(GtkMenuItem *menuitem, gpointer user_d
        if (*address != '\0') {
                gchar *name = procheader_get_fromname(address);
                extract_address(address);
+#ifndef USE_NEW_ADDRBOOK
                addressbook_add_contact(name, address, NULL, NULL);
+#else
+               debug_print("%s: %s\n", name, address);
+               if (addressadd_selection(name, address, NULL, NULL)) {
+                       debug_print( "addressbook_add_contact - added\n" );
+               }
+#endif
        }
        g_free(address);
 }
@@ -6703,12 +6827,27 @@ static void compose_remove_header_entries(Compose *compose)
 static GtkWidget *compose_create_header(Compose *compose) 
 {
        GtkWidget *from_optmenu_hbox;
+       GtkWidget *header_scrolledwin_main;
+       GtkWidget *header_table_main;
        GtkWidget *header_scrolledwin;
        GtkWidget *header_table;
 
-       gint count = 0;
+       /* parent with account selection and from header */
+       header_scrolledwin_main = gtk_scrolled_window_new(NULL, NULL);
+       gtk_widget_show(header_scrolledwin_main);
+       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(header_scrolledwin_main), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
 
-       /* header labels and entries */
+       header_table_main = gtk_table_new(2, 2, FALSE);
+       gtk_widget_show(header_table_main);
+       gtk_container_set_border_width(GTK_CONTAINER(header_table_main), BORDER_WIDTH);
+       gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(header_scrolledwin_main), header_table_main);
+       gtk_viewport_set_shadow_type(GTK_VIEWPORT(gtk_bin_get_child(GTK_BIN((header_scrolledwin_main)))), GTK_SHADOW_NONE);
+
+       from_optmenu_hbox = compose_account_option_menu_create(compose);
+       gtk_table_attach(GTK_TABLE(header_table_main), from_optmenu_hbox,
+                                 0, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+       /* child with header labels and entries */
        header_scrolledwin = gtk_scrolled_window_new(NULL, NULL);
        gtk_widget_show(header_scrolledwin);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(header_scrolledwin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
@@ -6718,23 +6857,19 @@ static GtkWidget *compose_create_header(Compose *compose)
        gtk_container_set_border_width(GTK_CONTAINER(header_table), BORDER_WIDTH);
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(header_scrolledwin), header_table);
        gtk_viewport_set_shadow_type(GTK_VIEWPORT(gtk_bin_get_child(GTK_BIN((header_scrolledwin)))), GTK_SHADOW_NONE);
-       count = 0;
 
-       /* option menu for selecting accounts */
-       from_optmenu_hbox = compose_account_option_menu_create(compose);
-       gtk_table_attach(GTK_TABLE(header_table), from_optmenu_hbox,
-                                 0, 2, count, count + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
-       count++;
+       gtk_table_attach(GTK_TABLE(header_table_main), header_scrolledwin,
+                                 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 2);
 
        compose->header_table = header_table;
        compose->header_list = NULL;
-       compose->header_nextrow = count;
+       compose->header_nextrow = 0;
 
        compose_create_header_entry(compose);
 
-       compose->table            = NULL;
+       compose->table = NULL;
 
-       return header_scrolledwin ;
+       return header_scrolledwin_main;
 }
 
 static gboolean popup_attach_button_pressed(GtkWidget *widget, gpointer data)
@@ -7118,7 +7253,8 @@ static Compose *compose_create(PrefsAccount *account,
        window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "compose");
 
        gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
-       gtk_widget_set_size_request(window, -1, prefs_common.compose_height);
+       gtk_widget_set_size_request(window, prefs_common.compose_width,
+                                       prefs_common.compose_height);
 
        if (!geometry.max_width) {
                geometry.max_width = gdk_screen_width();
@@ -7186,6 +7322,8 @@ static Compose *compose_create(PrefsAccount *account,
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Message", "Separator2", "Message/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Message", "Save", "Message/Save", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Message", "Separator3", "Message/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Message", "Print", "Message/Print", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Message", "Separator4", "Message/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Message", "Close", "Message/Close", GTK_UI_MANAGER_MENUITEM)
 
 /* Edit menu */
@@ -7372,7 +7510,7 @@ static Compose *compose_create(PrefsAccount *account,
        
        /* Notebook */
        notebook = gtk_notebook_new();
-       gtk_widget_set_size_request(notebook, -1, 130);
+       gtk_widget_set_size_request(notebook, -1, prefs_common.compose_notebook_height);
        gtk_widget_show(notebook);
 
        /* header labels and entries */
@@ -7449,7 +7587,6 @@ static Compose *compose_create(PrefsAccount *account,
        gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
                                            GTK_SHADOW_IN);
        gtk_box_pack_start(GTK_BOX(edit_vbox), scrolledwin, TRUE, TRUE, 0);
-       gtk_widget_set_size_request(scrolledwin, prefs_common.compose_width, -1);
 
        text = gtk_text_view_new();
        if (prefs_common.show_compose_margin) {
@@ -7463,6 +7600,8 @@ static Compose *compose_create(PrefsAccount *account,
        gtk_text_buffer_add_selection_clipboard(buffer, clipboard);
        
        gtk_container_add(GTK_CONTAINER(scrolledwin), text);
+       g_signal_connect(G_OBJECT(notebook), "size_allocate",
+                        G_CALLBACK(compose_notebook_size_alloc), compose);     
        g_signal_connect_after(G_OBJECT(text), "size_allocate",
                               G_CALLBACK(compose_edit_size_alloc),
                               ruler);
@@ -7669,8 +7808,9 @@ static Compose *compose_create(PrefsAccount *account,
                gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN((compose->header_last->combo)))),
                                prefs_common_translated_header_name("Newsgroups:"));
 
+#ifndef USE_NEW_ADDRBOOK
        addressbook_set_target_compose(compose);
-       
+#endif 
        if (mode != COMPOSE_REDIRECT)
                compose_set_template_menu(compose);
        else {
@@ -8401,9 +8541,10 @@ static void compose_destroy(Compose *compose)
 
        g_free(compose->privacy_system);
 
+#ifndef USE_NEW_ADDRBOOK
        if (addressbook_get_target_compose() == compose)
                addressbook_set_target_compose(NULL);
-
+#endif
 #if USE_ENCHANT
         if (compose->gtkaspell) {
                gtkaspell_delete(compose->gtkaspell);
@@ -8412,7 +8553,7 @@ static void compose_destroy(Compose *compose)
 #endif
 
        if (!compose->batch) {
-               gtk_widget_get_allocation(compose->scrolledwin, &allocation);
+               gtk_widget_get_allocation(compose->window, &allocation);
                prefs_common.compose_width = allocation.width;
                prefs_common.compose_height = allocation.height;
        }
@@ -8659,7 +8800,6 @@ static void compose_attach_property(GtkAction *action, gpointer data)
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); \
  \
        entry = gtk_entry_new(); \
-       gtk_editable_set_editable(GTK_EDITABLE(entry), FALSE); \
        gtk_table_attach(GTK_TABLE(table), entry, 1, 2, top, (top + 1), \
                         GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0); \
 }
@@ -9123,6 +9263,13 @@ static void compose_undo_state_changed(UndoMain *undostruct, gint undo_state,
 
 /* callback functions */
 
+static void compose_notebook_size_alloc(GtkNotebook *notebook,
+                                       GtkAllocation *allocation,
+                                       Compose *compose)
+{
+       prefs_common.compose_notebook_height = allocation->height;
+}
+
 /* compose_edit_size_alloc() - called when resized. don't know whether Gtk
  * includes "non-client" (windows-izm) in calculation, so this calculation
  * may not be accurate.
@@ -9403,6 +9550,7 @@ gboolean compose_draft (gpointer data, guint action)
        Compose *compose = (Compose *)data;
        FolderItem *draft;
        gchar *tmp;
+       gchar *sheaders;
        gint msgnum;
        MsgFlags flag = {0, 0};
        static gboolean lock = FALSE;
@@ -9483,6 +9631,10 @@ gboolean compose_draft (gpointer data, guint action)
        err |= (fprintf(fp, "X-Claws-Auto-Wrapping:%d\n", compose->autowrap) < 0);
        err |= (fprintf(fp, "X-Claws-Auto-Indent:%d\n", compose->autoindent) < 0);
 
+       sheaders = compose_get_manual_headers_info(compose);
+       err |= (fprintf(fp, "X-Claws-Manual-Headers:%s\n", sheaders) < 0);
+       g_free(sheaders);
+
        /* end of headers */
        err |= (fprintf(fp, "X-Claws-End-Special-Headers: 1\n") < 0);
 
@@ -9818,6 +9970,15 @@ static void compose_close_cb(GtkAction *action, gpointer data)
        compose_close(compose);
 }
 
+static void compose_print_cb(GtkAction *action, gpointer data)
+{
+       Compose *compose = (Compose *) data;
+
+       compose_draft((gpointer)compose, COMPOSE_AUTO_SAVE);
+       if (compose->targetinfo)
+               messageview_print(compose->targetinfo, FALSE, -1, -1, 0);
+}
+
 static void compose_set_encoding_cb(GtkAction *action, GtkRadioAction *current, gpointer data)
 {
        gboolean active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current));
@@ -9832,7 +9993,17 @@ static void compose_address_cb(GtkAction *action, gpointer data)
 {
        Compose *compose = (Compose *)data;
 
+#ifndef USE_NEW_ADDRBOOK
        addressbook_open(compose);
+#else
+       GError* error = NULL;
+       addressbook_connect_signals(compose);
+       addressbook_dbus_open(TRUE, &error);
+       if (error) {
+               g_warning("%s", error->message);
+               g_error_free(error);
+       }
+#endif
 }
 
 static void about_show_cb(GtkAction *action, gpointer data)
@@ -10012,14 +10183,20 @@ static void compose_paste_cb(GtkAction *action, gpointer data)
        GtkTextBuffer *buffer;
        BLOCK_WRAP();
        if (compose->focused_editable &&
-           gtk_widget_has_focus(compose->focused_editable))
+#ifndef GENERIC_UMPC
+           gtk_widget_has_focus(compose->focused_editable)
+#endif
+               )
                entry_paste_clipboard(compose, compose->focused_editable, 
                                prefs_common.linewrap_pastes,
                                GDK_SELECTION_CLIPBOARD, NULL);
        UNBLOCK_WRAP();
 
 #ifdef USE_ENCHANT
-       if (gtk_widget_has_focus(compose->text) &&
+       if (
+#ifndef GENERIC_UMPC
+               gtk_widget_has_focus(compose->text) &&
+#endif
            compose->gtkaspell && 
             compose->gtkaspell->check_while_typing)
                gtkaspell_highlight_all(compose->gtkaspell);
@@ -10069,7 +10246,10 @@ static void compose_paste_no_wrap_cb(GtkAction *action, gpointer data)
        UNBLOCK_WRAP();
 
 #ifdef USE_ENCHANT
-       if (gtk_widget_has_focus(compose->text) &&
+       if (
+#ifndef GENERIC_UMPC
+               gtk_widget_has_focus(compose->text) &&
+#endif
            compose->gtkaspell && 
             compose->gtkaspell->check_while_typing)
                gtkaspell_highlight_all(compose->gtkaspell);
@@ -10092,7 +10272,10 @@ static void compose_paste_wrap_cb(GtkAction *action, gpointer data)
        UNBLOCK_WRAP();
 
 #ifdef USE_ENCHANT
-       if (gtk_widget_has_focus(compose->text) &&
+       if (
+#ifndef GENERIC_UMPC
+               gtk_widget_has_focus(compose->text) &&
+#endif
            compose->gtkaspell &&
             compose->gtkaspell->check_while_typing)
                gtkaspell_highlight_all(compose->gtkaspell);