2009-03-06 [wwp] 3.7.1cvs2
authorTristan Chabredier <wwp@claws-mail.org>
Fri, 6 Mar 2009 11:34:04 +0000 (11:34 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Fri, 6 Mar 2009 11:34:04 +0000 (11:34 +0000)
* src/compose.c
* src/folder_item_prefs.c
* src/folder_item_prefs.h
* src/prefs_folder_item.c
Add per-folder default cc, bcc and reply-to.

src/compose.c
src/folder_item_prefs.c
src/folder_item_prefs.h
src/prefs_folder_item.c

index 4715174..dc7a7fc 100644 (file)
@@ -1018,9 +1018,20 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                if (mailto && *mailto != '\0') {
                        compose_entries_set(compose, mailto, COMPOSE_TO);
 
-               } else if (item && item->prefs && item->prefs->enable_default_to) {
-                       compose_entry_append(compose, item->prefs->default_to, COMPOSE_TO);
-                       compose_entry_mark_default_to(compose, item->prefs->default_to);
+               } else if (item && item->prefs) {
+                       if (item->prefs->enable_default_bcc) {
+                               compose_entry_append(compose, item->prefs->default_bcc, COMPOSE_BCC);
+                       }
+                       if (item->prefs->enable_default_cc) {
+                               compose_entry_append(compose, item->prefs->default_cc, COMPOSE_CC);
+                       }
+                       if (item->prefs->enable_default_replyto) {
+                               compose_entry_append(compose, item->prefs->default_replyto, COMPOSE_REPLYTO);
+                       }
+                       if (item->prefs->enable_default_to) {
+                               compose_entry_append(compose, item->prefs->default_to, COMPOSE_TO);
+                               compose_entry_mark_default_to(compose, item->prefs->default_to);
+                       }
                }
                if (item && item->ret_rcpt) {
                        cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Options/RequestRetRcpt", TRUE);
@@ -2994,6 +3005,17 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
                msginfo->folder->prefs->enable_default_reply_to;
 
        if (compose->account->protocol != A_NNTP) {
+               if (msginfo && msginfo->folder && msginfo->folder->prefs) {
+                       if (msginfo->folder->prefs->enable_default_replyto) {
+                               compose_entry_append(compose, msginfo->folder->prefs->default_replyto, COMPOSE_REPLYTO);
+                       }
+                       if (msginfo->folder->prefs->enable_default_bcc) {
+                               compose_entry_append(compose, msginfo->folder->prefs->default_bcc, COMPOSE_BCC);
+                       }
+                       if (msginfo->folder->prefs->enable_default_cc) {
+                               compose_entry_append(compose, msginfo->folder->prefs->default_cc, COMPOSE_CC);
+                       }
+               }
                if (reply_to_ml && !default_reply_to) {
                        
                        gboolean is_subscr = is_subscription(compose->ml_post,
@@ -6280,7 +6302,7 @@ static void compose_create_header_entry(Compose *compose)
        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) {     
+       if (compose->header_last && (compose->draft_timeout_tag != -2)) {
                const gchar *last_header_entry = gtk_entry_get_text(
                                GTK_ENTRY(gtk_bin_get_child(GTK_BIN((compose->header_last->combo)))));
                string = headers;
index 8cbc9a6..ad1d40c 100644 (file)
@@ -42,6 +42,18 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"default_reply_to", "", &tmp_prefs.default_reply_to, P_STRING,
         NULL, NULL, NULL},
+       {"enable_default_cc", "", &tmp_prefs.enable_default_cc, P_BOOL,
+        NULL, NULL, NULL},
+       {"default_cc", "", &tmp_prefs.default_cc, P_STRING,
+        NULL, NULL, NULL},
+       {"enable_default_bcc", "", &tmp_prefs.enable_default_bcc, P_BOOL,
+        NULL, NULL, NULL},
+       {"default_bcc", "", &tmp_prefs.default_bcc, P_STRING,
+        NULL, NULL, NULL},
+       {"enable_default_replyto", "", &tmp_prefs.enable_default_replyto, P_BOOL,
+        NULL, NULL, NULL},
+       {"default_replyto", "", &tmp_prefs.default_replyto, P_STRING,
+        NULL, NULL, NULL},
        {"enable_simplify_subject", "", &tmp_prefs.enable_simplify_subject, P_BOOL,
         NULL, NULL, NULL},
 #ifndef G_OS_WIN32
@@ -158,6 +170,12 @@ static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *prefs)
        prefs->default_to = NULL;
        prefs->enable_default_reply_to = FALSE;
        prefs->default_reply_to = NULL;
+       prefs->enable_default_cc = FALSE;
+       prefs->default_cc = NULL;
+       prefs->enable_default_bcc = FALSE;
+       prefs->default_bcc = NULL;
+       prefs->enable_default_replyto = FALSE;
+       prefs->default_replyto = NULL;
        prefs->enable_simplify_subject = FALSE;
 #ifndef G_OS_WIN32
        prefs->simplify_subject_regexp = NULL;
@@ -212,6 +230,9 @@ void folder_item_prefs_free(FolderItemPrefs * prefs)
 {
        g_free(prefs->default_to);
        g_free(prefs->default_reply_to);
+       g_free(prefs->default_cc);
+       g_free(prefs->default_bcc);
+       g_free(prefs->default_replyto);
        g_free(prefs->compose_subject_format);
        g_free(prefs->compose_body_format);
        g_free(prefs->compose_override_from_format);
@@ -256,6 +277,12 @@ void folder_item_prefs_copy_prefs(FolderItem * src, FolderItem * dest)
        tmp_prefs.default_to                    = g_strdup(src->prefs->default_to);
        tmp_prefs.enable_default_reply_to       = src->prefs->enable_default_reply_to;
        tmp_prefs.default_reply_to              = g_strdup(src->prefs->default_reply_to);
+       tmp_prefs.enable_default_cc             = src->prefs->enable_default_cc;
+       tmp_prefs.default_cc                    = g_strdup(src->prefs->default_cc);
+       tmp_prefs.enable_default_bcc            = src->prefs->enable_default_bcc;
+       tmp_prefs.default_bcc                   = g_strdup(src->prefs->default_bcc);
+       tmp_prefs.enable_default_replyto                = src->prefs->enable_default_replyto;
+       tmp_prefs.default_replyto                       = g_strdup(src->prefs->default_replyto);
        tmp_prefs.enable_simplify_subject       = src->prefs->enable_simplify_subject;
 #ifndef G_OS_WIN32
        tmp_prefs.simplify_subject_regexp       = g_strdup(src->prefs->simplify_subject_regexp);
index 5b69e45..6bf81a3 100644 (file)
@@ -44,6 +44,12 @@ struct _FolderItemPrefs {
        gchar *default_to;
        gboolean enable_default_reply_to;
        gchar *default_reply_to;
+       gboolean enable_default_cc;
+       gchar *default_cc;
+       gboolean enable_default_bcc;
+       gchar *default_bcc;
+       gboolean enable_default_replyto;
+       gchar *default_replyto;
        gboolean enable_simplify_subject;
 #ifndef G_OS_WIN32
        gchar *simplify_subject_regexp;
index 6e1d714..66458d2 100644 (file)
@@ -123,6 +123,12 @@ struct _FolderItemComposePage
        GtkWidget *entry_default_to;
        GtkWidget *checkbtn_default_reply_to;
        GtkWidget *entry_default_reply_to;
+       GtkWidget *checkbtn_default_cc;
+       GtkWidget *entry_default_cc;
+       GtkWidget *checkbtn_default_bcc;
+       GtkWidget *entry_default_bcc;
+       GtkWidget *checkbtn_default_replyto;
+       GtkWidget *entry_default_replyto;
        GtkWidget *checkbtn_enable_default_account;
        GtkWidget *optmenu_default_account;
 #if USE_ENCHANT
@@ -137,6 +143,9 @@ struct _FolderItemComposePage
        GtkWidget *save_copy_to_folder_rec_checkbtn;
        GtkWidget *default_to_rec_checkbtn;
        GtkWidget *default_reply_to_rec_checkbtn;
+       GtkWidget *default_cc_rec_checkbtn;
+       GtkWidget *default_bcc_rec_checkbtn;
+       GtkWidget *default_replyto_rec_checkbtn;
        GtkWidget *default_account_rec_checkbtn;
 #if USE_ENCHANT
        GtkWidget *default_dictionary_rec_checkbtn;
@@ -758,6 +767,12 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_,
        GtkWidget *entry_default_to = NULL;
        GtkWidget *checkbtn_default_reply_to = NULL;
        GtkWidget *entry_default_reply_to = NULL;
+       GtkWidget *checkbtn_default_cc = NULL;
+       GtkWidget *entry_default_cc = NULL;
+       GtkWidget *checkbtn_default_bcc = NULL;
+       GtkWidget *entry_default_bcc = NULL;
+       GtkWidget *checkbtn_default_replyto = NULL;
+       GtkWidget *entry_default_replyto = NULL;
        GtkWidget *checkbtn_enable_default_account = NULL;
        GtkWidget *optmenu_default_account = NULL;
        GtkListStore *optmenu_default_account_menu = NULL;
@@ -775,6 +790,9 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_,
        GtkWidget *save_copy_to_folder_rec_checkbtn = NULL;
        GtkWidget *default_to_rec_checkbtn = NULL;
        GtkWidget *default_reply_to_rec_checkbtn = NULL;
+       GtkWidget *default_cc_rec_checkbtn = NULL;
+       GtkWidget *default_bcc_rec_checkbtn = NULL;
+       GtkWidget *default_replyto_rec_checkbtn = NULL;
        GtkWidget *default_account_rec_checkbtn = NULL;
 
        GList *cur_ac;
@@ -887,6 +905,69 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_,
                                 rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
 
                rowcount++;
+
+               /* Default Cc */
+               checkbtn_default_cc = gtk_check_button_new_with_label(_("Default Cc:"));
+               gtk_table_attach(GTK_TABLE(table), checkbtn_default_cc, 0, 1, 
+                                rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_cc), 
+                                            item->prefs->enable_default_cc);
+
+               entry_default_cc = gtk_entry_new();
+               gtk_table_attach(GTK_TABLE(table), entry_default_cc, 1, 2,
+                                rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+               SET_TOGGLE_SENSITIVITY(checkbtn_default_cc, entry_default_cc);
+               gtk_entry_set_text(GTK_ENTRY(entry_default_cc), SAFE_STRING(item->prefs->default_cc));
+               address_completion_register_entry(GTK_ENTRY(entry_default_cc),
+                               TRUE);
+
+               default_cc_rec_checkbtn = gtk_check_button_new();
+               gtk_table_attach(GTK_TABLE(table), default_cc_rec_checkbtn, 2, 3, 
+                                rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
+
+               rowcount++;
+
+               /* Default Bcc */
+               checkbtn_default_bcc = gtk_check_button_new_with_label(_("Default Bcc:"));
+               gtk_table_attach(GTK_TABLE(table), checkbtn_default_bcc, 0, 1, 
+                                rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_bcc), 
+                                            item->prefs->enable_default_bcc);
+
+               entry_default_bcc = gtk_entry_new();
+               gtk_table_attach(GTK_TABLE(table), entry_default_bcc, 1, 2,
+                                rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+               SET_TOGGLE_SENSITIVITY(checkbtn_default_bcc, entry_default_bcc);
+               gtk_entry_set_text(GTK_ENTRY(entry_default_bcc), SAFE_STRING(item->prefs->default_bcc));
+               address_completion_register_entry(GTK_ENTRY(entry_default_bcc),
+                               TRUE);
+
+               default_bcc_rec_checkbtn = gtk_check_button_new();
+               gtk_table_attach(GTK_TABLE(table), default_bcc_rec_checkbtn, 2, 3, 
+                                rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
+
+               rowcount++;
+
+               /* Default Reply-to */
+               checkbtn_default_replyto = gtk_check_button_new_with_label(_("Default Reply-to:"));
+               gtk_table_attach(GTK_TABLE(table), checkbtn_default_replyto, 0, 1, 
+                                rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_replyto), 
+                                            item->prefs->enable_default_replyto);
+
+               entry_default_replyto = gtk_entry_new();
+               gtk_table_attach(GTK_TABLE(table), entry_default_replyto, 1, 2,
+                                rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+               SET_TOGGLE_SENSITIVITY(checkbtn_default_replyto, entry_default_replyto);
+               gtk_entry_set_text(GTK_ENTRY(entry_default_replyto), SAFE_STRING(item->prefs->default_replyto));
+               address_completion_register_entry(GTK_ENTRY(entry_default_replyto),
+                               TRUE);
+
+               default_replyto_rec_checkbtn = gtk_check_button_new();
+               gtk_table_attach(GTK_TABLE(table), default_replyto_rec_checkbtn, 2, 3, 
+                                rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
+
+               rowcount++;
        }
        /* Default account */
        checkbtn_enable_default_account = gtk_check_button_new_with_label(_("Default account"));
@@ -1019,6 +1100,12 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_,
        page->entry_default_to = entry_default_to;
        page->checkbtn_default_reply_to = checkbtn_default_reply_to;
        page->entry_default_reply_to = entry_default_reply_to;
+       page->checkbtn_default_cc = checkbtn_default_cc;
+       page->entry_default_cc = entry_default_cc;
+       page->checkbtn_default_bcc = checkbtn_default_bcc;
+       page->entry_default_bcc = entry_default_bcc;
+       page->checkbtn_default_replyto = checkbtn_default_replyto;
+       page->entry_default_replyto = entry_default_replyto;
        page->checkbtn_enable_default_account = checkbtn_enable_default_account;
        page->optmenu_default_account = optmenu_default_account;
 #ifdef USE_ENCHANT
@@ -1032,6 +1119,9 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_,
        page->save_copy_to_folder_rec_checkbtn    = save_copy_to_folder_rec_checkbtn;
        page->default_to_rec_checkbtn             = default_to_rec_checkbtn;
        page->default_reply_to_rec_checkbtn       = default_reply_to_rec_checkbtn;
+       page->default_cc_rec_checkbtn             = default_cc_rec_checkbtn;
+       page->default_bcc_rec_checkbtn            = default_bcc_rec_checkbtn;
+       page->default_replyto_rec_checkbtn                = default_replyto_rec_checkbtn;
        page->default_account_rec_checkbtn        = default_account_rec_checkbtn;
 #if USE_ENCHANT
        page->default_dictionary_rec_checkbtn = default_dictionary_rec_checkbtn;
@@ -1049,6 +1139,12 @@ static void prefs_folder_item_compose_destroy_widget_func(PrefsPage *page_)
                address_completion_unregister_entry(GTK_ENTRY(page->entry_default_to));
        if (page->entry_default_reply_to)
                address_completion_unregister_entry(GTK_ENTRY(page->entry_default_reply_to));
+       if (page->entry_default_cc)
+               address_completion_unregister_entry(GTK_ENTRY(page->entry_default_cc));
+       if (page->entry_default_bcc)
+               address_completion_unregister_entry(GTK_ENTRY(page->entry_default_bcc));
+       if (page->entry_default_replyto)
+               address_completion_unregister_entry(GTK_ENTRY(page->entry_default_replyto));
 }
 
 /** \brief  Save the prefs in page to folder.
@@ -1097,11 +1193,39 @@ static void compose_save_folder_prefs(FolderItem *folder, FolderItemComposePage
                        ASSIGN_STRING(prefs->default_reply_to,
                                      gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_reply_to), 0, -1));
                }
+
+               if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_cc_rec_checkbtn))) {
+
+                       prefs->enable_default_cc = 
+                               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_cc));
+                       ASSIGN_STRING(prefs->default_cc,
+                                     gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_cc), 0, -1));
+               }
+
+               if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_bcc_rec_checkbtn))) {
+
+                       prefs->enable_default_bcc = 
+                               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_bcc));
+                       ASSIGN_STRING(prefs->default_bcc,
+                                     gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_bcc), 0, -1));
+               }
+
+               if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_replyto_rec_checkbtn))) {
+
+                       prefs->enable_default_replyto = 
+                               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_replyto));
+                       ASSIGN_STRING(prefs->default_replyto,
+                                     gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_replyto), 0, -1));
+               }
+
        } else {
                prefs->request_return_receipt = FALSE;
                prefs->save_copy_to_folder = FALSE;
                prefs->enable_default_to = FALSE;
                prefs->enable_default_reply_to = FALSE;
+               prefs->enable_default_cc = FALSE;
+               prefs->enable_default_bcc = FALSE;
+               prefs->enable_default_replyto = FALSE;
        }
 
        if (all || gtk_toggle_button_get_active(
@@ -1151,11 +1275,15 @@ static gboolean compose_save_recurse_func(GNode *node, gpointer data)
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->save_copy_to_folder_rec_checkbtn)) ||
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_to_rec_checkbtn)) ||
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_account_rec_checkbtn)) ||
+             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_cc_rec_checkbtn)) ||
+             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_bcc_rec_checkbtn)) ||
+             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_replyto_rec_checkbtn)) ||
 #if USE_ENCHANT
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_dictionary_rec_checkbtn)) ||
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_alt_dictionary_rec_checkbtn)) ||
 #endif
-             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_reply_to_rec_checkbtn))))
+             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_reply_to_rec_checkbtn))
+                       ))
                return TRUE;
        else if ((node == page->item->node) && item_protocol(item) == A_NNTP &&
            !(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_account_rec_checkbtn))