add 'Default From:' to folder prefs
authorPaul <paul@claws-mail.org>
Mon, 4 Oct 2021 12:16:51 +0000 (13:16 +0100)
committerPaul <paul@claws-mail.org>
Mon, 4 Oct 2021 12:16:51 +0000 (13:16 +0100)
src/compose.c
src/folder_item_prefs.c
src/folder_item_prefs.h
src/prefs_folder_item.c

index 3db0f77801931a9efe520cf5471a70eaf9e3570c..94ef486961dbe3eddd84fe70bbd9fdd9d1bb9766 100644 (file)
@@ -3293,6 +3293,10 @@ static void compose_set_folder_prefs(Compose *compose, FolderItem *folder,
        if (!folder || !folder->prefs)
                return;
 
+       if (folder->prefs->enable_default_from) {
+               gtk_entry_set_text(GTK_ENTRY(compose->from_name), folder->prefs->default_from);
+               compose_entry_indicate(compose, folder->prefs->default_from);
+       }
        if (respect_default_to && folder->prefs->enable_default_to) {
                compose_entry_append(compose, folder->prefs->default_to,
                                        COMPOSE_TO, PREF_FOLDER);
index 73d174e85954f08661cef651a5f62d93d8e75661..b8ae56bb7d8329ac4ec38f9ab1907870522b2dc4 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2021 the Claws Mail team and Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 FolderItemPrefs tmp_prefs;
 
 static PrefParam param[] = {
+       {"enable_default_from", "", &tmp_prefs.enable_default_from, P_BOOL,
+        NULL, NULL, NULL},
+       {"default_from", "", &tmp_prefs.default_from, P_STRING,
+        NULL, NULL, NULL},
        {"enable_default_to", "", &tmp_prefs.enable_default_to, P_BOOL,
         NULL, NULL, NULL},
        {"default_to", "", &tmp_prefs.default_to, P_STRING,
@@ -187,6 +191,8 @@ void folder_prefs_save_config_recursive(Folder *folder)
 
 static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *prefs)
 {
+       prefs->enable_default_from = FALSE;
+       prefs->default_from = NULL;
        prefs->enable_default_to = FALSE;
        prefs->default_to = NULL;
        prefs->enable_default_reply_to = FALSE;
@@ -251,6 +257,7 @@ FolderItemPrefs * folder_item_prefs_new(void)
 
 void folder_item_prefs_free(FolderItemPrefs * prefs)
 {
+       g_free(prefs->default_from);
        g_free(prefs->default_to);
        g_free(prefs->default_reply_to);
        g_free(prefs->default_cc);
@@ -298,6 +305,8 @@ void folder_item_prefs_copy_prefs(FolderItem * src, FolderItem * dest)
        tmp_prefs.processing                    = tmp_prop_list;
        
        tmp_prefs.request_return_receipt        = src->prefs->request_return_receipt;
+       tmp_prefs.enable_default_from           = src->prefs->enable_default_from;
+       tmp_prefs.default_from                  = g_strdup(src->prefs->default_from);
        tmp_prefs.enable_default_to             = src->prefs->enable_default_to;
        tmp_prefs.default_to                    = g_strdup(src->prefs->default_to);
        tmp_prefs.enable_default_reply_to       = src->prefs->enable_default_reply_to;
index 2a1427ffbedc3be95f293c067630587d68e8ce1e..be183da6bc769084af4f8855ba260cd1fab23225 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2021 the Claws Mail team and Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -54,6 +54,8 @@ struct _FolderItemPrefs {
        gboolean skip_on_goto_unread_or_new;
 
        gboolean request_return_receipt;
+       gboolean enable_default_from;
+       gchar *default_from;
        gboolean enable_default_to;
        gchar *default_to;
        gboolean enable_default_reply_to;
index a2cf2cc3493cd5a6ec8e34c2a510091119138fd3..3375f306eb9cb5e3036d49b725d27397c6a52973 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2021 the Claws Mail team and Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -117,6 +117,8 @@ struct _FolderItemComposePage
        GtkWidget *no_save_warning;
        GtkWidget *checkbtn_request_return_receipt;
        GtkWidget *checkbtn_save_copy_to_folder;
+       GtkWidget *checkbtn_default_from;
+       GtkWidget *entry_default_from;
        GtkWidget *checkbtn_default_to;
        GtkWidget *entry_default_to;
        GtkWidget *checkbtn_default_reply_to;
@@ -141,6 +143,7 @@ struct _FolderItemComposePage
        /* apply to sub folders */
        GtkWidget *request_return_receipt_rec_checkbtn;
        GtkWidget *save_copy_to_folder_rec_checkbtn;
+       GtkWidget *default_from_rec_checkbtn;
        GtkWidget *default_to_rec_checkbtn;
        GtkWidget *default_reply_to_rec_checkbtn;
        GtkWidget *default_cc_rec_checkbtn;
@@ -857,6 +860,8 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_,
        GtkWidget *no_save_warning = NULL;
        GtkWidget *checkbtn_request_return_receipt = NULL;
        GtkWidget *checkbtn_save_copy_to_folder = NULL;
+       GtkWidget *checkbtn_default_from = NULL;
+       GtkWidget *entry_default_from = NULL;
        GtkWidget *checkbtn_default_to = NULL;
        GtkWidget *entry_default_to = NULL;
        GtkWidget *checkbtn_default_reply_to = NULL;
@@ -886,6 +891,7 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_,
        GtkListStore *always_encrypt_menu;
        GtkWidget *request_return_receipt_rec_checkbtn = NULL;
        GtkWidget *save_copy_to_folder_rec_checkbtn = NULL;
+       GtkWidget *default_from_rec_checkbtn = NULL;
        GtkWidget *default_to_rec_checkbtn = NULL;
        GtkWidget *default_reply_to_rec_checkbtn = NULL;
        GtkWidget *default_cc_rec_checkbtn = NULL;
@@ -958,6 +964,33 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_,
 
                rowcount++;
 
+
+               /* Default From */
+               tr = g_strdup(C_("folder properties: %s stands for a header name",
+                                         "Default %s"));
+               text = g_strdup_printf(tr, prefs_common_translated_header_name("From:"));
+               checkbtn_default_from = gtk_check_button_new_with_label(text);
+               gtk_table_attach(GTK_TABLE(table), checkbtn_default_from, 0, 1, 
+                                rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_from), 
+                                            item->prefs->enable_default_from);
+               g_free(text);
+               g_free(tr);
+
+               entry_default_from = gtk_entry_new();
+               gtk_table_attach(GTK_TABLE(table), entry_default_from, 1, 2,
+                                rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+               SET_TOGGLE_SENSITIVITY(checkbtn_default_from, entry_default_from);
+               gtk_entry_set_text(GTK_ENTRY(entry_default_from), SAFE_STRING(item->prefs->default_from));
+               address_completion_register_entry(GTK_ENTRY(entry_default_from),
+                               TRUE);
+
+               default_from_rec_checkbtn = gtk_check_button_new();
+               gtk_table_attach(GTK_TABLE(table), default_from_rec_checkbtn, 2, 3, 
+                                rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
+
+               rowcount++;
+
                /* Default To */
                tr = g_strdup(C_("folder properties: %s stands for a header name",
                                          "Default %s"));
@@ -1279,6 +1312,8 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_,
        page->no_save_warning = no_save_warning;
        page->checkbtn_request_return_receipt = checkbtn_request_return_receipt;
        page->checkbtn_save_copy_to_folder = checkbtn_save_copy_to_folder;
+       page->checkbtn_default_from = checkbtn_default_from;
+       page->entry_default_from = entry_default_from;
        page->checkbtn_default_to = checkbtn_default_to;
        page->entry_default_to = entry_default_to;
        page->checkbtn_default_reply_to = checkbtn_default_reply_to;
@@ -1302,6 +1337,7 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_,
 
        page->request_return_receipt_rec_checkbtn = request_return_receipt_rec_checkbtn;
        page->save_copy_to_folder_rec_checkbtn    = save_copy_to_folder_rec_checkbtn;
+       page->default_from_rec_checkbtn           = default_from_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;
@@ -1322,6 +1358,8 @@ static void prefs_folder_item_compose_destroy_widget_func(PrefsPage *page_)
 {
        FolderItemComposePage *page = (FolderItemComposePage *) page_;
 
+       if (page->entry_default_from)
+               address_completion_unregister_entry(GTK_ENTRY(page->entry_default_from));
        if (page->entry_default_to)
                address_completion_unregister_entry(GTK_ENTRY(page->entry_default_to));
        if (page->entry_default_reply_to)
@@ -1366,8 +1404,14 @@ static void compose_save_folder_prefs(FolderItem *folder, FolderItemComposePage
                                gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_save_copy_to_folder));
                }
 
-               if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_to_rec_checkbtn))) {
+               if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_from_rec_checkbtn))) {
+                       prefs->enable_default_from = 
+                               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_from));
+                       ASSIGN_STRING(prefs->default_from,
+                                     gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_from), 0, -1));
+               }
 
+               if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_to_rec_checkbtn))) {
                        prefs->enable_default_to = 
                                gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_to));
                        ASSIGN_STRING(prefs->default_to,