more plumbing in Hoa's code (can't wait to have all these settings moved into folderl...
[claws.git] / src / prefs_folder_item.c
index 757928a22a37ff8575c0c4e6bed8cd397881648f..038fca1e504515087a3e89faf03964d62690c58e 100644 (file)
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+/* alfons - all folder item specific settings should migrate into 
+ * folderlist.xml!!! the old folderitemrc file will only serve for a few 
+ * versions (for compatibility) */
+
 #include "intl.h"
 #include "defs.h"
 #include "folder.h"
@@ -53,12 +57,13 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"sort_descending", "FALSE", &tmp_prefs.sort_descending, P_BOOL,
         NULL, NULL, NULL},
-       {"enable_thread", "TRUE", &tmp_prefs.enable_thread, P_BOOL,
-        NULL, NULL, NULL},
+       /*{"enable_thread", "TRUE", &tmp_prefs.enable_thread, P_BOOL,
+        NULL, NULL, NULL},*/
        {"kill_score", "-9999", &tmp_prefs.kill_score, P_INT,
         NULL, NULL, NULL},
        {"important_score", "1", &tmp_prefs.important_score, P_INT,
         NULL, NULL, NULL},
+       /* MIGRATION */  
        {"request_return_receipt", "", &tmp_prefs.request_return_receipt, P_BOOL,
         NULL, NULL, NULL},
        {"enable_default_to", "", &tmp_prefs.enable_default_to, P_BOOL,
@@ -88,7 +93,10 @@ void prefs_folder_item_read_config(FolderItem * item)
        prefs_read_config(param, id, FOLDERITEM_RC);
        g_free(id);
 
-       * item->prefs = tmp_prefs;
+       *item->prefs = tmp_prefs;
+
+       /* MIGRATION */
+       item->ret_rcpt = tmp_prefs.request_return_receipt ? TRUE : FALSE; 
 }
 
 void prefs_folder_item_save_config(FolderItem * item)
@@ -101,6 +109,9 @@ void prefs_folder_item_save_config(FolderItem * item)
 
        prefs_save_config(param, id, FOLDERITEM_RC);
        g_free(id);
+
+       /* MIGRATION: make sure migrated items are not saved
+        */
 }
 
 void prefs_folder_item_set_config(FolderItem * item,
@@ -169,7 +180,8 @@ PrefsFolderItem * prefs_folder_item_new(void)
 
 void prefs_folder_item_free(PrefsFolderItem * prefs)
 {
-       g_free(prefs->default_to);
+       if (prefs->default_to) 
+               g_free(prefs->default_to);
        if (prefs->scoring != NULL)
                prefs_scoring_free(prefs->scoring);
        g_free(prefs);
@@ -204,6 +216,9 @@ gint prefs_folder_item_get_sort_type(FolderItem * item)
                return GTK_SORT_ASCENDING;
 }
 
+#define SAFE_STRING(str) \
+       (str) ? (str) : ""
+
 void prefs_folder_item_create(FolderItem *item) {
        struct PrefsFolderItemDialog *dialog;
        GtkWidget *window;
@@ -255,7 +270,7 @@ void prefs_folder_item_create(FolderItem *item) {
        PACK_CHECK_BUTTON(vbox, checkbtn_request_return_receipt,
                           _("Request Return Receipt"));
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_request_return_receipt),
-           item->prefs->request_return_receipt);
+                                    item->ret_rcpt ? TRUE : FALSE);
 
        /* Default To */
        hbox = gtk_hbox_new(FALSE, 8);
@@ -272,7 +287,7 @@ void prefs_folder_item_create(FolderItem *item) {
        gtk_widget_show(entry_default_to);
        gtk_box_pack_start(GTK_BOX(hbox), entry_default_to, FALSE, FALSE, 0);
        gtk_editable_set_editable(GTK_EDITABLE(entry_default_to), item->prefs->enable_default_to);
-       gtk_entry_set_text(GTK_ENTRY(entry_default_to), item->prefs->default_to);
+       gtk_entry_set_text(GTK_ENTRY(entry_default_to), SAFE_STRING(item->prefs->default_to));
 
        /* Folder chmod */
        hbox = gtk_hbox_new(FALSE, 8);
@@ -333,6 +348,9 @@ void prefs_folder_item_ok_cb(GtkWidget *widget, struct PrefsFolderItemDialog *di
 
        prefs->request_return_receipt = 
            gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_request_return_receipt));
+       /* MIGRATION */    
+       dialog->item->ret_rcpt = prefs->request_return_receipt;
+           
        prefs->enable_default_to = 
            gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_default_to));
        g_free(prefs->default_to);