0.9.3claws34
[claws.git] / src / prefs_folder_item.c
index cb71cf5..53ff219 100644 (file)
 #include "prefs_scoring.h"
 #include "gtkutils.h"
 #include "filtering.h"
+#include "folder_item_prefs.h"
 
-PrefsFolderItem tmp_prefs;
-
-struct PrefsFolderItemDialog
+struct FolderItemSettingsPage
 {
-       FolderView *folderview;
+       PrefsPage page;
+
        FolderItem *item;
+
        GtkWidget *window;
+       GtkWidget *table;
        GtkWidget *checkbtn_request_return_receipt;
        GtkWidget *checkbtn_save_copy_to_folder;
        GtkWidget *checkbtn_default_to;
@@ -62,68 +64,11 @@ struct PrefsFolderItemDialog
        GtkWidget *optmenu_default_account;
        GtkWidget *folder_color;
        GtkWidget *folder_color_btn;
-};
 
-static GtkWidget *color_dialog;
-
-static PrefParam param[] = {
-       {"sort_by_number", "FALSE", &tmp_prefs.sort_by_number, P_BOOL,
-        NULL, NULL, NULL},
-       {"sort_by_size", "FALSE", &tmp_prefs.sort_by_size, P_BOOL,
-        NULL, NULL, NULL},
-       {"sort_by_date", "FALSE", &tmp_prefs.sort_by_date, P_BOOL,
-        NULL, NULL, NULL},
-       {"sort_by_from", "FALSE", &tmp_prefs.sort_by_from, P_BOOL,
-        NULL, NULL, NULL},
-       {"sort_by_subject", "FALSE", &tmp_prefs.sort_by_subject, P_BOOL,
-        NULL, NULL, NULL},
-       {"sort_by_score", "FALSE", &tmp_prefs.sort_by_score, P_BOOL,
-        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},*/
-       {"hide_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,
-        NULL, NULL, NULL},
-       {"default_to", "", &tmp_prefs.default_to, P_STRING,
-        NULL, NULL, NULL},
-       {"enable_default_reply_to", "", &tmp_prefs.enable_default_reply_to, P_BOOL,
-        NULL, NULL, NULL},
-       {"default_reply_to", "", &tmp_prefs.default_reply_to, P_STRING,
-        NULL, NULL, NULL},
-       {"enable_simplify_subject", "", &tmp_prefs.enable_simplify_subject, P_BOOL,
-        NULL, NULL, NULL},
-       {"simplify_subject_regexp", "", &tmp_prefs.simplify_subject_regexp, P_STRING,
-        NULL, NULL, NULL},
-       {"enable_folder_chmod", "", &tmp_prefs.enable_folder_chmod, P_BOOL,
-        NULL, NULL, NULL},
-       {"folder_chmod", "", &tmp_prefs.folder_chmod, P_INT,
-        NULL, NULL, NULL},
-       {"enable_default_account", "", &tmp_prefs.enable_default_account, P_BOOL,
-        NULL, NULL, NULL},
-       {"default_account", NULL, &tmp_prefs.default_account, P_INT,
-        NULL, NULL, NULL},
-       {"save_copy_to_folder", NULL, &tmp_prefs.save_copy_to_folder, P_BOOL,
-        NULL, NULL, NULL},
-       {"folder_color", "", &tmp_prefs.color, P_INT,
-        NULL, NULL, NULL},
-       {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
+       GtkWidget *color_dialog;
 };
 
-static PrefsFolderItem *prefs_folder_item_clear (PrefsFolderItem *prefs);
-void prefs_folder_item_delete_cb               (GtkWidget *widget, GdkEventAny *event, 
-                                                struct PrefsFolderItemDialog *dialog);
-void prefs_folder_item_cancel_cb               (GtkWidget *widget, 
-                                                struct PrefsFolderItemDialog *dialog);
-void prefs_folder_item_ok_cb                   (GtkWidget *widget, 
-                                                struct PrefsFolderItemDialog *dialog);
+
 gint prefs_folder_item_chmod_mode              (gchar *folder_chmod);
 
 static void set_button_color(guint rgbvalue, GtkWidget *button);
@@ -134,145 +79,18 @@ static void folder_color_set_dialog_key_pressed(GtkWidget *widget,
                                                GdkEventKey *event,
                                                gpointer data);
 
-
-void prefs_folder_item_read_config(FolderItem * item)
-{
-       gchar * id;
-
-       id = folder_item_get_identifier(item);
-       prefs_folder_item_clear(&tmp_prefs);
-       prefs_read_config(param, id, FOLDERITEM_RC);
-       g_free(id);
-
-       *item->prefs = tmp_prefs;
-
-       /*
-        * MIGRATION: next lines are migration code. the idea is that
-        *            if used regularly, claws folder config ends up
-        *            in the same file as sylpheed-main
-        */
-
-       item->ret_rcpt = tmp_prefs.request_return_receipt ? TRUE : FALSE;
-
-       /* MIGRATION: 0.7.8main+ has persistent sort order. claws had the sort
-        *            order in different members, which is ofcourse a little
-        *            bit phoney. */
-       if (item->sort_key == SORT_BY_NONE) {
-               item->sort_key  = (tmp_prefs.sort_by_number  ? SORT_BY_NUMBER  :
-                                  tmp_prefs.sort_by_size    ? SORT_BY_SIZE    :
-                                  tmp_prefs.sort_by_date    ? SORT_BY_DATE    :
-                                  tmp_prefs.sort_by_from    ? SORT_BY_FROM    :
-                                  tmp_prefs.sort_by_subject ? SORT_BY_SUBJECT :
-                                  tmp_prefs.sort_by_score   ? SORT_BY_SCORE   :
-                                                                SORT_BY_NONE);
-               item->sort_type = tmp_prefs.sort_descending ? SORT_DESCENDING : SORT_ASCENDING;
-       }                                                               
-}
-
-void prefs_folder_item_save_config(FolderItem * item)
-{      
-       gchar * id;
-
-       tmp_prefs = * item->prefs;
-
-       id = folder_item_get_identifier(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,
-                                 int sort_type, gint sort_mode)
-{
-       g_assert(item);
-       g_warning("prefs_folder_item_set_config() should never be called\n");
-       item->sort_key  = sort_type;
-       item->sort_type = sort_mode;
-}
-
-static PrefsFolderItem *prefs_folder_item_clear(PrefsFolderItem *prefs)
-{
-       prefs->sort_by_number = FALSE;
-       prefs->sort_by_size = FALSE;
-       prefs->sort_by_date = FALSE;
-       prefs->sort_by_from = FALSE;
-       prefs->sort_by_subject = FALSE;
-       prefs->sort_by_score = FALSE;
-       prefs->sort_descending = FALSE;
-       prefs->kill_score = -9999;
-       prefs->important_score = 9999;
-
-       prefs->request_return_receipt = FALSE;
-       prefs->enable_default_to = FALSE;
-       prefs->default_to = NULL;
-       prefs->enable_default_reply_to = FALSE;
-       prefs->default_reply_to = NULL;
-       prefs->enable_simplify_subject = FALSE;
-       prefs->simplify_subject_regexp = NULL;
-       prefs->enable_folder_chmod = FALSE;
-       prefs->folder_chmod = 0;
-       prefs->enable_default_account = FALSE;
-       prefs->default_account = 0;
-       prefs->save_copy_to_folder = FALSE;
-       prefs->color = 0;
-
-       prefs->scoring = NULL;
-       prefs->processing = NULL;
-       return prefs;
-}
-
-PrefsFolderItem * prefs_folder_item_new(void)
-{
-       PrefsFolderItem * prefs;
-
-       prefs = g_new0(PrefsFolderItem, 1);
-
-       return prefs_folder_item_clear(prefs);
-}
-
-void prefs_folder_item_free(PrefsFolderItem * prefs)
-{
-       if (prefs->default_to) 
-               g_free(prefs->default_to);
-       if (prefs->default_reply_to) 
-               g_free(prefs->default_reply_to);
-       if (prefs->scoring != NULL)
-               prefs_scoring_free(prefs->scoring);
-       g_free(prefs);
-}
-
-gint prefs_folder_item_get_sort_mode(FolderItem * item)
-{
-       g_assert(item != NULL);
-       g_warning("prefs_folder_item_get_sort_mode() should never be called\n");
-       return item->sort_key;
-}
-
-gint prefs_folder_item_get_sort_type(FolderItem * item)
-{
-       g_assert(item != NULL);
-       g_warning("prefs_folder_item_get_sort_type() should never be called\n");
-       return item->sort_type;
-}
-
 #define SAFE_STRING(str) \
        (str) ? (str) : ""
 
-void prefs_folder_item_create(FolderView *folderview, FolderItem *item) 
+void prefs_folder_item_settings_create_widget_func(PrefsPage * _page,
+                                                  GtkWindow * window,
+                                                  gpointer data)
 {
-       struct PrefsFolderItemDialog *dialog;
+       struct FolderItemSettingsPage *page = (struct FolderItemSettingsPage *) _page;
+       FolderItem *item = (FolderItem *) data;
        guint rowcount;
-       gchar *folder_identifier, *infotext;
 
-       GtkWidget *window;
        GtkWidget *table;
-       GtkWidget *infolabel;
-       GtkWidget *ok_btn;
-       GtkWidget *cancel_btn;
-       GtkWidget *confirm_area;
        
        GtkWidget *checkbtn_request_return_receipt;
        GtkWidget *checkbtn_save_copy_to_folder;
@@ -298,37 +116,14 @@ void prefs_folder_item_create(FolderView *folderview, FolderItem *item)
        GtkWidget *menuitem;
        gint account_index, index;
 
-       dialog = g_new0(struct PrefsFolderItemDialog, 1);
-       dialog->folderview = folderview;
-       dialog->item       = item;
-
-       /* Window */
-       window = gtk_window_new (GTK_WINDOW_DIALOG);
-       gtk_window_set_title (GTK_WINDOW(window),
-                             _("Folder Properties"));
-       gtk_container_set_border_width (GTK_CONTAINER (window), 8);
-       gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
-       gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE);
-       gtk_signal_connect (GTK_OBJECT(window), "delete_event",
-                           GTK_SIGNAL_FUNC(prefs_folder_item_delete_cb), dialog);
-       MANAGE_WINDOW_SIGNALS_CONNECT (window);
+       page->item         = item;
 
        /* Table */
        table = gtk_table_new(8, 2, FALSE);
        gtk_widget_show(table);
        gtk_table_set_row_spacings(GTK_TABLE(table), VSPACING_NARROW);
-       gtk_container_add(GTK_CONTAINER (window), table);
        rowcount = 0;
 
-       /* Label */
-       folder_identifier = folder_item_get_identifier(item);
-       infotext = g_strconcat(_("Folder Properties for "), folder_identifier, NULL);
-       infolabel = gtk_label_new(infotext);
-       gtk_table_attach(GTK_TABLE(table), infolabel, 0, 2, rowcount, 
-                        rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
-       gtk_widget_show(infolabel);
-       rowcount++;
-
        /* Request Return Receipt */
        checkbtn_request_return_receipt = gtk_check_button_new_with_label
                (_("Request Return Receipt"));
@@ -456,9 +251,9 @@ void prefs_folder_item_create(FolderView *folderview, FolderItem *item)
                index++;                        
        }
 
-       dialog->item->prefs->default_account = item->prefs->default_account;
+       page->item->prefs->default_account = item->prefs->default_account;
 
-       optmenu=GTK_OPTION_MENU(optmenu_default_account);
+       optmenu = GTK_OPTION_MENU(optmenu_default_account);
        gtk_option_menu_set_menu(optmenu, optmenu_default_account_menu);
 
        gtk_option_menu_set_history(optmenu, account_index);
@@ -486,77 +281,52 @@ void prefs_folder_item_create(FolderView *folderview, FolderItem *item)
                         1, 2, rowcount, rowcount + 1,
                         GTK_SHRINK, 0, 0, 0);
 
-       dialog->item->prefs->color = item->prefs->color;
+       page->item->prefs->color = item->prefs->color;
 
        gtk_signal_connect(GTK_OBJECT(folder_color_btn), "clicked",
                           GTK_SIGNAL_FUNC(folder_color_set_dialog),
-                          dialog);
+                          page);
 
        set_button_color(item->prefs->color, folder_color_btn);
 
        rowcount++;
 
-       /* Ok and Cancle Buttons */
-       gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
-                               &cancel_btn, _("Cancel"), NULL, NULL);
-       gtk_widget_show(confirm_area);
-       gtk_table_attach_defaults(GTK_TABLE(table), confirm_area, 0, 2, 
-                                 rowcount, rowcount + 1);
-       gtk_widget_grab_default(ok_btn);
-       gtk_signal_connect (GTK_OBJECT(ok_btn), "clicked",
-                           GTK_SIGNAL_FUNC(prefs_folder_item_ok_cb), dialog);
-       gtk_signal_connect (GTK_OBJECT(cancel_btn), "clicked",
-                           GTK_SIGNAL_FUNC(prefs_folder_item_cancel_cb), dialog);
-
-       dialog->window = window;
-       dialog->checkbtn_request_return_receipt = checkbtn_request_return_receipt;
-       dialog->checkbtn_save_copy_to_folder = checkbtn_save_copy_to_folder;
-       dialog->checkbtn_default_to = checkbtn_default_to;
-       dialog->entry_default_to = entry_default_to;
-       dialog->checkbtn_default_reply_to = checkbtn_default_reply_to;
-       dialog->entry_default_reply_to = entry_default_reply_to;
-       dialog->checkbtn_simplify_subject = checkbtn_simplify_subject;
-       dialog->entry_simplify_subject = entry_simplify_subject;
-       dialog->checkbtn_folder_chmod = checkbtn_folder_chmod;
-       dialog->entry_folder_chmod = entry_folder_chmod;
-       dialog->checkbtn_enable_default_account = checkbtn_enable_default_account;
-       dialog->optmenu_default_account = optmenu_default_account;
-       dialog->folder_color = folder_color;
-       dialog->folder_color_btn = folder_color_btn;
-
-       g_free(infotext);
-
-       address_completion_start(window);
-
-       gtk_widget_show(window);
+       page->window = GTK_WIDGET(window);
+       page->table = table;
+       page->checkbtn_request_return_receipt = checkbtn_request_return_receipt;
+       page->checkbtn_save_copy_to_folder = checkbtn_save_copy_to_folder;
+       page->checkbtn_default_to = checkbtn_default_to;
+       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_simplify_subject = checkbtn_simplify_subject;
+       page->entry_simplify_subject = entry_simplify_subject;
+       page->checkbtn_folder_chmod = checkbtn_folder_chmod;
+       page->entry_folder_chmod = entry_folder_chmod;
+       page->checkbtn_enable_default_account = checkbtn_enable_default_account;
+       page->optmenu_default_account = optmenu_default_account;
+       page->folder_color = folder_color;
+       page->folder_color_btn = folder_color_btn;
+
+       address_completion_start(page->window);
+
+       page->page.widget = table;
 }
 
-void prefs_folder_item_destroy(struct PrefsFolderItemDialog *dialog
+void prefs_folder_item_settings_destroy_widget_func(PrefsPage *_page
 {
-       address_completion_unregister_entry(GTK_ENTRY(dialog->entry_default_to));
-       address_completion_unregister_entry(GTK_ENTRY(dialog->entry_default_reply_to));
-       address_completion_end(dialog->window);
-       gtk_widget_destroy(dialog->window);
-       g_free(dialog);
-}
+       struct FolderItemSettingsPage *page = (struct FolderItemSettingsPage *) _page;
 
-void prefs_folder_item_cancel_cb(GtkWidget *widget, 
-                                struct PrefsFolderItemDialog *dialog) 
-{
-       prefs_folder_item_destroy(dialog);
+       address_completion_unregister_entry(GTK_ENTRY(page->entry_default_to));
+       address_completion_unregister_entry(GTK_ENTRY(page->entry_default_reply_to));
+       address_completion_end(page->window);
 }
 
-void prefs_folder_item_delete_cb(GtkWidget *widget, GdkEventAny *event, 
-                                struct PrefsFolderItemDialog *dialog) 
-{
-       prefs_folder_item_destroy(dialog);
-}
-
-void prefs_folder_item_ok_cb(GtkWidget *widget, 
-                            struct PrefsFolderItemDialog *dialog) 
+void prefs_folder_item_settings_save_func(PrefsPage *_page) 
 {
        gchar *buf;
-       PrefsFolderItem *prefs = dialog->item->prefs;
+       struct FolderItemSettingsPage *page = (struct FolderItemSettingsPage *) _page;
+       FolderItemPrefs *prefs = page->item->prefs;
        GtkWidget *menu;
        GtkWidget *menuitem;
        gboolean   old_simplify_val;
@@ -568,60 +338,60 @@ void prefs_folder_item_ok_cb(GtkWidget *widget,
        old_simplify_str = prefs->simplify_subject_regexp;
 
        prefs->request_return_receipt = 
-           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_request_return_receipt));
+           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_request_return_receipt));
        /* MIGRATION */    
-       dialog->item->ret_rcpt = prefs->request_return_receipt;
+       page->item->ret_rcpt = prefs->request_return_receipt;
 
        prefs->save_copy_to_folder = 
-           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_save_copy_to_folder));
+           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_save_copy_to_folder));
 
        prefs->enable_default_to = 
-           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_default_to));
+           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_to));
        g_free(prefs->default_to);
        prefs->default_to = 
-           gtk_editable_get_chars(GTK_EDITABLE(dialog->entry_default_to), 0, -1);
+           gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_to), 0, -1);
 
        prefs->enable_default_reply_to = 
-           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_default_reply_to));
+           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_default_reply_to));
        g_free(prefs->default_reply_to);
        prefs->default_reply_to = 
-           gtk_editable_get_chars(GTK_EDITABLE(dialog->entry_default_reply_to), 0, -1);
+           gtk_editable_get_chars(GTK_EDITABLE(page->entry_default_reply_to), 0, -1);
 
        prefs->enable_simplify_subject =
-           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_simplify_subject));
+           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_simplify_subject));
        prefs->simplify_subject_regexp = 
-           gtk_editable_get_chars(GTK_EDITABLE(dialog->entry_simplify_subject), 0, -1);
+           gtk_editable_get_chars(GTK_EDITABLE(page->entry_simplify_subject), 0, -1);
        
-       if (dialog->item == dialog->folderview->summaryview->folder_item &&
+/*
+       if (page->item == page->folderview->summaryview->folder_item &&
            (prefs->enable_simplify_subject != old_simplify_val ||  
            0 != strcmp2(prefs->simplify_subject_regexp, old_simplify_str))) {
-               summary_clear_all(dialog->folderview->summaryview);
-               dialog->folderview->opened = NULL;
-               dialog->folderview->selected = NULL;
-               folderview_select(dialog->folderview, dialog->item);
+               summary_clear_all(page->folderview->summaryview);
+               page->folderview->opened = NULL;
+               page->folderview->selected = NULL;
+               folderview_select(page->folderview, page->item);
        }
-
+*/
        if (old_simplify_str) g_free(old_simplify_str);
 
        prefs->enable_folder_chmod = 
-           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_folder_chmod));
-       buf = gtk_editable_get_chars(GTK_EDITABLE(dialog->entry_folder_chmod), 0, -1);
+           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_folder_chmod));
+       buf = gtk_editable_get_chars(GTK_EDITABLE(page->entry_folder_chmod), 0, -1);
        prefs->folder_chmod = prefs_folder_item_chmod_mode(buf);
        g_free(buf);
 
        prefs->enable_default_account = 
-           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_enable_default_account));
-       menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(dialog->optmenu_default_account));
+           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_default_account));
+       menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_default_account));
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
        prefs->default_account = GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(menuitem)));
 
-       prefs->color = dialog->item->prefs->color;
+       prefs->color = page->item->prefs->color;
        /* update folder view */
        if (prefs->color > 0)
-               folder_item_update(dialog->item, F_ITEM_UPDATE_MSGCNT);
+               folder_item_update(page->item, F_ITEM_UPDATE_MSGCNT);
 
-       prefs_folder_item_save_config(dialog->item);
-       prefs_folder_item_destroy(dialog);
+       folder_item_prefs_save_config(page->item);
 }
 
 gint prefs_folder_item_chmod_mode(gchar *folder_chmod) 
@@ -653,41 +423,41 @@ static void set_button_color(guint rgbvalue, GtkWidget *button)
 
 static void folder_color_set_dialog(GtkWidget *widget, gpointer data)
 {
-       struct PrefsFolderItemDialog *folder_dialog = data;
+       struct FolderItemSettingsPage *page = (struct FolderItemSettingsPage *) data;
        GtkColorSelectionDialog *dialog;
        gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
        guint rgbcolor;
 
-       color_dialog = gtk_color_selection_dialog_new(_("Pick color for folder"));
-       gtk_window_set_position(GTK_WINDOW(color_dialog), GTK_WIN_POS_CENTER);
-       gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
-       gtk_window_set_policy(GTK_WINDOW(color_dialog), FALSE, FALSE, FALSE);
-       manage_window_set_transient(GTK_WINDOW(color_dialog));
+       page->color_dialog = gtk_color_selection_dialog_new(_("Pick color for folder"));
+       gtk_window_set_position(GTK_WINDOW(page->color_dialog), GTK_WIN_POS_CENTER);
+       gtk_window_set_modal(GTK_WINDOW(page->color_dialog), TRUE);
+       gtk_window_set_policy(GTK_WINDOW(page->color_dialog), FALSE, FALSE, FALSE);
+       manage_window_set_transient(GTK_WINDOW(page->color_dialog));
 
-       gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->ok_button),
+       gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(page->color_dialog)->ok_button),
                           "clicked", GTK_SIGNAL_FUNC(folder_color_set_dialog_ok), data);
-       gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->cancel_button),
+       gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(page->color_dialog)->cancel_button),
                           "clicked", GTK_SIGNAL_FUNC(folder_color_set_dialog_cancel), data);
-       gtk_signal_connect(GTK_OBJECT(color_dialog), "key_press_event",
+       gtk_signal_connect(GTK_OBJECT(page->color_dialog), "key_press_event",
                           GTK_SIGNAL_FUNC(folder_color_set_dialog_key_pressed),
                           data);
 
-       rgbcolor = folder_dialog->item->prefs->color;
+       rgbcolor = page->item->prefs->color;
        color[0] = (gdouble) ((rgbcolor & 0xff0000) >> 16) / 255.0;
        color[1] = (gdouble) ((rgbcolor & 0x00ff00) >>  8) / 255.0;
        color[2] = (gdouble)  (rgbcolor & 0x0000ff)        / 255.0;
 
-       dialog = GTK_COLOR_SELECTION_DIALOG(color_dialog);
+       dialog = GTK_COLOR_SELECTION_DIALOG(page->color_dialog);
        gtk_color_selection_set_color(GTK_COLOR_SELECTION(dialog->colorsel), color);
 
-       gtk_widget_show(color_dialog);
+       gtk_widget_show(page->color_dialog);
 }
 
 static void folder_color_set_dialog_ok(GtkWidget *widget, gpointer data)
 {
-       struct PrefsFolderItemDialog *folder_dialog = data;
+       struct FolderItemSettingsPage *page = (struct FolderItemSettingsPage *) data;
        GtkColorSelection *colorsel = (GtkColorSelection *)
-                               ((GtkColorSelectionDialog *) color_dialog)->colorsel;
+                               ((GtkColorSelectionDialog *) page->color_dialog)->colorsel;
        gdouble color[4];
        guint red, green, blue, rgbvalue;
 
@@ -698,74 +468,55 @@ static void folder_color_set_dialog_ok(GtkWidget *widget, gpointer data)
        blue     = (guint) (color[2] * 255.0);
        rgbvalue = (guint) ((red * 0x10000) | (green * 0x100) | blue);
 
-       folder_dialog->item->prefs->color = rgbvalue;
-       set_button_color(rgbvalue, folder_dialog->folder_color_btn);
+       page->item->prefs->color = rgbvalue;
+       set_button_color(rgbvalue, page->folder_color_btn);
 
-       gtk_widget_destroy(color_dialog);
+       gtk_widget_destroy(page->color_dialog);
 }
 
 static void folder_color_set_dialog_cancel(GtkWidget *widget, gpointer data)
 {
-       gtk_widget_destroy(color_dialog);
+       struct FolderItemSettingsPage *page = (struct FolderItemSettingsPage *) data;
+       gtk_widget_destroy(page->color_dialog);
 }
 
 static void folder_color_set_dialog_key_pressed(GtkWidget *widget,
                                                GdkEventKey *event,
                                                gpointer data)
 {
-       gtk_widget_destroy(color_dialog);
+       struct FolderItemSettingsPage *page = (struct FolderItemSettingsPage *) data;
+       gtk_widget_destroy(page->color_dialog);
 }
 
-void prefs_folder_item_copy_prefs(FolderItem * src, FolderItem * dest)
+struct FolderItemSettingsPage folder_item_settings_page;
+
+static void register_settings_page()
 {
-       GSList *tmp_prop_list = NULL, *tmp_scor_list = NULL, *tmp;
-       prefs_folder_item_read_config(src);
-
-       tmp_prefs.directory                     = g_strdup(src->prefs->directory);
-       tmp_prefs.sort_by_number                = src->prefs->sort_by_number;
-       tmp_prefs.sort_by_size                  = src->prefs->sort_by_size;
-       tmp_prefs.sort_by_date                  = src->prefs->sort_by_date;
-       tmp_prefs.sort_by_from                  = src->prefs->sort_by_from;
-       tmp_prefs.sort_by_subject               = src->prefs->sort_by_subject;
-       tmp_prefs.sort_by_score                 = src->prefs->sort_by_score;
-       tmp_prefs.sort_descending               = src->prefs->sort_descending;
-       tmp_prefs.enable_thread                 = src->prefs->enable_thread;
-       tmp_prefs.kill_score                    = src->prefs->kill_score;
-       tmp_prefs.important_score               = src->prefs->important_score;
-
-       prefs_matcher_read_config();
-       for (tmp = src->prefs->scoring; tmp != NULL && tmp->data != NULL;) {
-               ScoringProp *prop = (ScoringProp *)tmp->data;
-               
-               tmp_scor_list = g_slist_append(tmp_scor_list,
-                                          scoringprop_copy(prop));
-               tmp = tmp->next;
-       }
-       tmp_prefs.scoring                       = tmp_scor_list;
-
-       for (tmp = src->prefs->processing; tmp != NULL && tmp->data != NULL;) {
-               FilteringProp *prop = (FilteringProp *)tmp->data;
-               
-               tmp_prop_list = g_slist_append(tmp_prop_list,
-                                          filteringprop_copy(prop));
-               tmp = tmp->next;
+        folder_item_settings_page.page.path = "Settings";
+        folder_item_settings_page.page.create_widget = prefs_folder_item_settings_create_widget_func;
+        folder_item_settings_page.page.destroy_widget = prefs_folder_item_settings_destroy_widget_func;
+        folder_item_settings_page.page.save_page = prefs_folder_item_settings_save_func;
+        
+       prefs_folder_item_register_page((PrefsPage *) &folder_item_settings_page);
+}
+
+static GSList *prefs_pages = NULL;
+
+void prefs_folder_item_open(FolderItem *item)
+{
+       if (prefs_pages == NULL) {
+               register_settings_page();
        }
-       tmp_prefs.processing                    = tmp_prop_list;
-       
-       tmp_prefs.request_return_receipt        = src->prefs->request_return_receipt;
-       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;
-       tmp_prefs.default_reply_to              = src->prefs->default_reply_to;
-       tmp_prefs.enable_simplify_subject       = src->prefs->enable_simplify_subject;
-       tmp_prefs.simplify_subject_regexp       = g_strdup(src->prefs->simplify_subject_regexp);
-       tmp_prefs.enable_folder_chmod           = src->prefs->enable_folder_chmod;
-       tmp_prefs.folder_chmod                  = src->prefs->folder_chmod;
-       tmp_prefs.enable_default_account        = src->prefs->enable_default_account;
-       tmp_prefs.default_account               = src->prefs->default_account;
-       tmp_prefs.save_copy_to_folder           = src->prefs->save_copy_to_folder;
-       tmp_prefs.color                         = src->prefs->color;
-
-       *dest->prefs = tmp_prefs;
-       prefs_folder_item_save_config(dest);
+
+       prefswindow_open(_("Settings for folder"), prefs_pages, item);
+}
+
+void prefs_folder_item_register_page(PrefsPage *page)
+{
+       prefs_pages = g_slist_append(prefs_pages, page);
+}
+
+void prefs_folder_item_unregister_page(PrefsPage *page)
+{
+       prefs_pages = g_slist_remove(prefs_pages, page);
 }