0.9.3claws34
authorChristoph Hohmann <reboot@gmx.ch>
Sun, 20 Jul 2003 01:15:54 +0000 (01:15 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Sun, 20 Jul 2003 01:15:54 +0000 (01:15 +0000)
* src/Makefile.am
* src/account.c
* src/folder.[ch]
* src/folder_item_prefs.[ch]            ** NEW **
* src/folderview.c
* src/mainwindow.c
* src/mh.c
* src/prefs_gtk.c
* src/prefs_scoring.c
* src/summaryview.c
* src/prefs_folder_item.[ch]
        o seperate FolderItemPrefs (formerly PrefsFolderItem) and the
          Properties dialog
        o use prefswindow for folder properties

* src/gtk/prefswindow.[ch]
        change implementation to use an invisible notebook instead
        of unparenting widgets

18 files changed:
ChangeLog.claws
configure.ac
src/Makefile.am
src/account.c
src/folder.c
src/folder.h
src/folder_item_prefs.c [new file with mode: 0644]
src/folder_item_prefs.h [new file with mode: 0644]
src/folderview.c
src/gtk/prefswindow.c
src/gtk/prefswindow.h
src/mainwindow.c
src/mh.c
src/prefs_folder_item.c
src/prefs_folder_item.h
src/prefs_gtk.c
src/prefs_scoring.c
src/summaryview.c

index abc471a..27f47e9 100644 (file)
@@ -1,3 +1,24 @@
+2003-07-20 [christoph] 0.9.3claws34
+
+       * src/Makefile.am
+       * src/account.c
+       * src/folder.[ch]
+       * src/folder_item_prefs.[ch]            ** NEW **
+       * src/folderview.c
+       * src/mainwindow.c
+       * src/mh.c
+       * src/prefs_gtk.c
+       * src/prefs_scoring.c
+       * src/summaryview.c
+       * src/prefs_folder_item.[ch]
+               o seperate FolderItemPrefs (formerly PrefsFolderItem) and the
+                 Properties dialog
+               o use prefswindow for folder properties
+
+       * src/gtk/prefswindow.[ch]
+               change implementation to use an invisible notebook instead
+               of unparenting widgets
+
 2003-07-20 [christoph] 0.9.3claws33
 
        * src/compose.h
index c0399ed..f815a18 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=3
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=33
+EXTRA_VERSION=34
 VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws${EXTRA_VERSION}
 
 dnl set $target
index a2112d8..542beb7 100644 (file)
@@ -114,7 +114,8 @@ sylpheed_SOURCES = \
        noticeview.h noticeview.c \
        toolbar.c toolbar.h \
        prefs_toolbar.c prefs_toolbar.h \
-       crash.c crash.h
+       crash.c crash.h \
+       folder_item_prefs.c folder_item_prefs.h
 
 BUILT_SOURCES = \
        quote_fmt_lex.c \
index a876992..ecc47fb 100644 (file)
@@ -37,7 +37,7 @@
 #include "account.h"
 #include "prefs_gtk.h"
 #include "prefs_account.h"
-#include "prefs_folder_item.h"
+#include "folder_item_prefs.h"
 #include "compose.h"
 #include "manage_window.h"
 #include "stock_pixmap.h"
@@ -718,7 +718,7 @@ static gboolean account_delete_references_func(GNode *node, gpointer data)
        
        item->prefs->enable_default_account = FALSE;
        item->prefs->default_account = 0;
-       prefs_folder_item_save_config(item);
+       folder_item_prefs_save_config(item);
 
        return FALSE;
 }
index 8e98830..284b066 100644 (file)
 #include "account.h"
 #include "filtering.h"
 #include "scoring.h"
-#include "prefs_folder_item.h"
 #include "procheader.h"
 #include "hooks.h"
 #include "log.h"
+#include "folder_item_prefs.h"
 
 /* Dependecies to be removed ?! */
 #include "prefs_common.h"
 #include "prefs_account.h"
-#include "prefs_folder_item.h"
 
 static GList *folder_list = NULL;
 
@@ -210,7 +209,7 @@ FolderItem *folder_item_new(Folder *folder, const gchar *name, const gchar *path
        item->mark_queue = NULL;
        item->data = NULL;
 
-       item->prefs = prefs_folder_item_new();
+       item->prefs = folder_item_prefs_new();
 
        return item;
 }
@@ -1451,7 +1450,7 @@ void folder_item_read_cache(FolderItem *item)
 void folder_item_write_cache(FolderItem *item)
 {
        gchar *cache_file, *mark_file;
-       PrefsFolderItem *prefs;
+       FolderItemPrefs *prefs;
        gint filemode = 0;
        gchar *id;
        
@@ -1741,7 +1740,7 @@ FolderItem *folder_item_move_recursive (FolderItem *src, FolderItem *dest)
        folder_item_move_msgs_with_dest(new_item, mlist);
        
        /*copy prefs*/
-       prefs_folder_item_copy_prefs(src, new_item);
+       folder_item_prefs_copy_prefs(src, new_item);
        new_item->collapsed = src->collapsed;
        new_item->thread_collapsed = src->thread_collapsed;
        new_item->threaded  = src->threaded;
@@ -2394,7 +2393,7 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
        }
        item->account = account;
        item->apply_sub = apply_sub;
-       prefs_folder_item_read_config(item);
+       folder_item_prefs_read_config(item);
 
        node->data = item;
        xml_free_node(xmlnode);
@@ -2721,7 +2720,7 @@ FolderItem *folder_get_default_processing(void)
 
 /* folder_persist_prefs_new() - return hash table with persistent
  * settings (and folder name as key). 
- * (note that in claws other options are in the PREFS_FOLDER_ITEM_RC
+ * (note that in claws other options are in the folder_item_prefs_RC
  * file, so those don't need to be included in PersistPref yet) 
  */
 GHashTable *folder_persist_prefs_new(Folder *folder)
@@ -2760,7 +2759,7 @@ void folder_item_restore_persist_prefs(FolderItem *item, GHashTable *pptable)
        /* CLAWS: since not all folder properties have been migrated to 
         * folderlist.xml, we need to call the old stuff first before
         * setting things that apply both to Main and Claws. */
-       prefs_folder_item_read_config(item); 
+       folder_item_prefs_read_config(item); 
         
        item->collapsed = pp->collapsed;
        item->thread_collapsed = pp->thread_collapsed;
index 2ca372d..fc8f223 100644 (file)
@@ -132,7 +132,7 @@ typedef void (*FolderDestroyNotify) (Folder         *folder,
 typedef void (*FolderItemFunc)         (FolderItem     *item,
                                         gpointer        data);
 
-#include "prefs_folder_item.h"
+#include "folder_item_prefs.h"
 
 #include "prefs_account.h"
 #include "session.h"
@@ -302,7 +302,7 @@ struct _FolderItem
 
        gpointer data;
 
-       PrefsFolderItem * prefs;
+       FolderItemPrefs * prefs;
 };
 
 typedef struct {
diff --git a/src/folder_item_prefs.c b/src/folder_item_prefs.c
new file mode 100644 (file)
index 0000000..d60d0e9
--- /dev/null
@@ -0,0 +1,270 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2001 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * 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) */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "intl.h"
+#include "defs.h"
+#include "folder.h"
+#include "utils.h"
+#include "prefs_gtk.h"
+#include "filtering.h"
+#include "prefs_scoring.h"
+#include "folder_item_prefs.h"
+
+FolderItemPrefs tmp_prefs;
+
+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}
+};
+
+static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *prefs);
+
+void folder_item_prefs_read_config(FolderItem * item)
+{
+       gchar * id;
+
+       id = folder_item_get_identifier(item);
+       folder_item_prefs_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 folder_item_prefs_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 folder_item_prefs_set_config(FolderItem * item,
+                                 int sort_type, gint sort_mode)
+{
+       g_assert(item);
+       g_warning("folder_item_prefs_set_config() should never be called\n");
+       item->sort_key  = sort_type;
+       item->sort_type = sort_mode;
+}
+
+static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *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;
+}
+
+FolderItemPrefs * folder_item_prefs_new(void)
+{
+       FolderItemPrefs * prefs;
+
+       prefs = g_new0(FolderItemPrefs, 1);
+
+       return folder_item_prefs_clear(prefs);
+}
+
+void folder_item_prefs_free(FolderItemPrefs * 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 folder_item_prefs_get_sort_mode(FolderItem * item)
+{
+       g_assert(item != NULL);
+       g_warning("folder_item_prefs_get_sort_mode() should never be called\n");
+       return item->sort_key;
+}
+
+gint folder_item_prefs_get_sort_type(FolderItem * item)
+{
+       g_assert(item != NULL);
+       g_warning("folder_item_prefs_get_sort_type() should never be called\n");
+       return item->sort_type;
+}
+
+#define SAFE_STRING(str) \
+       (str) ? (str) : ""
+
+void folder_item_prefs_copy_prefs(FolderItem * src, FolderItem * dest)
+{
+       GSList *tmp_prop_list = NULL, *tmp_scor_list = NULL, *tmp;
+       folder_item_prefs_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;
+       }
+       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;
+       folder_item_prefs_save_config(dest);
+}
diff --git a/src/folder_item_prefs.h b/src/folder_item_prefs.h
new file mode 100644 (file)
index 0000000..44a6c64
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2001 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef FOLDER_ITEM_PREFS_H
+#define FOLDER_ITEM_PREFS_H
+
+#include <glib.h>
+#include <sys/types.h>
+
+typedef struct _FolderItemPrefs FolderItemPrefs;
+
+#include "folder.h"
+
+struct _FolderItemPrefs {
+       gchar * directory;
+
+       gboolean sort_by_number;
+       gboolean sort_by_size;
+       gboolean sort_by_date;
+       gboolean sort_by_from;
+       gboolean sort_by_subject;
+       gboolean sort_by_score;
+
+       gboolean sort_descending;
+
+       gboolean enable_thread;
+
+       gint kill_score;
+       gint important_score;
+
+       GSList * scoring;
+       GSList * processing;
+
+       gboolean request_return_receipt;
+       gboolean enable_default_to;
+       gchar *default_to;
+       gboolean enable_default_reply_to;
+       gchar *default_reply_to;
+       gboolean enable_simplify_subject;
+       gchar *simplify_subject_regexp;
+       gboolean enable_folder_chmod;
+       gint folder_chmod;
+       gboolean enable_default_account;
+       gint default_account;
+       gboolean save_copy_to_folder;
+       guint color;
+};
+
+void folder_item_prefs_read_config(FolderItem * item);
+void folder_item_prefs_save_config(FolderItem * item);
+void folder_item_prefs_set_config(FolderItem * item,
+                                 int sort_type, gint sort_mode);
+FolderItemPrefs *folder_item_prefs_new(void);
+void folder_item_prefs_free(FolderItemPrefs * prefs);
+gint folder_item_prefs_get_sort_type(FolderItem * item);
+gint folder_item_prefs_get_sort_mode(FolderItem * item);
+void folder_item_prefs_copy_prefs(FolderItem * src, FolderItem * dest);
+
+#endif /* FOLDER_ITEM_PREFS_H */
index a1571e9..401be57 100644 (file)
@@ -2469,7 +2469,7 @@ static void folderview_property_cb(FolderView *folderview, guint action,
                account_open(item->folder->account);
        else {
                summary_save_prefs_to_folderitem(folderview->summaryview, item);
-               prefs_folder_item_create(folderview, item);
+               prefs_folder_item_open(item);
        }
 }
 
index 35cba41..4fb459a 100644 (file)
@@ -41,12 +41,14 @@ struct _PrefsWindow
        GtkWidget *pagelabel;
        GtkWidget *labelframe;
        GtkWidget *frame;
-       GtkWidget *page_widget;
+       GtkWidget *notebook;
        GtkWidget *confirm_area;
        GtkWidget *ok_btn;
        GtkWidget *cancel_btn;
        GtkWidget *apply_btn;
 
+       GtkWidget *empty_page;
+
        gpointer   data;
        GSList    *prefs_pages;
 };
@@ -56,27 +58,22 @@ static gboolean ctree_select_row(GtkCTree *ctree, GList *node, gint column, gpoi
        PrefsPage *page;
        PrefsWindow *prefswindow = (PrefsWindow *) user_data;
        gchar *labeltext;
+       gint pagenum;
 
        page = (PrefsPage *) gtk_ctree_node_get_row_data(GTK_CTREE(ctree), GTK_CTREE_NODE(node));
 
-       if (prefswindow->page_widget != NULL)
-               gtk_container_remove(GTK_CONTAINER(prefswindow->table2), prefswindow->page_widget);
-
        if (page == NULL) {
-               GtkWidget *widget;
-               
-               widget = gtk_label_new("");
-
                gtk_label_set_text(GTK_LABEL(prefswindow->pagelabel), "");
-               gtk_table_attach(GTK_TABLE(prefswindow->table2), widget, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
-               prefswindow->page_widget = widget;
+               pagenum = gtk_notebook_page_num(GTK_NOTEBOOK(prefswindow->notebook),
+                                               prefswindow->empty_page);
+               gtk_notebook_set_page(GTK_NOTEBOOK(prefswindow->notebook), pagenum);
                return FALSE;
        }
 
        if (!page->page_open) {
                page->create_widget(page, GTK_WINDOW(prefswindow->window), prefswindow->data);
-               gtk_widget_ref(page->widget);
                gtk_widget_show_all(page->widget);
+               gtk_container_add(GTK_CONTAINER(prefswindow->notebook), page->widget);
                page->page_open = TRUE;
        }
 
@@ -87,8 +84,9 @@ static gboolean ctree_select_row(GtkCTree *ctree, GList *node, gint column, gpoi
                labeltext = labeltext + 1;
        gtk_label_set_text(GTK_LABEL(prefswindow->pagelabel), labeltext);
 
-       prefswindow->page_widget = page->widget;
-       gtk_table_attach(GTK_TABLE(prefswindow->table2), prefswindow->page_widget, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 8, 8);
+       pagenum = gtk_notebook_page_num(GTK_NOTEBOOK(prefswindow->notebook),
+                                       page->widget);
+       gtk_notebook_set_page(GTK_NOTEBOOK(prefswindow->notebook), pagenum);
 
        return FALSE;
 }
@@ -114,7 +112,6 @@ static void close_all_pages(GSList *prefs_pages)
                PrefsPage *page = (PrefsPage *) cur->data;
 
                if (page->page_open) {
-                       gtk_widget_unref(page->widget);
                        page->destroy_widget(page);
                        page->page_open = FALSE;
                }
@@ -133,8 +130,8 @@ static void ok_button_released(GtkButton *button, gpointer user_data)
        PrefsWindow *prefswindow = (PrefsWindow *) user_data;
 
        save_all_pages(prefswindow->prefs_pages);
-       gtk_widget_destroy(prefswindow->window);
        close_all_pages(prefswindow->prefs_pages);
+       gtk_widget_destroy(prefswindow->window);
        g_slist_free(prefswindow->prefs_pages);
        g_free(prefswindow);
 }
@@ -143,8 +140,8 @@ static void close_prefs_window(PrefsWindow *prefswindow)
 {
        debug_print("prefs window closed\n");
 
-       gtk_widget_destroy(prefswindow->window);
        close_all_pages(prefswindow->prefs_pages);
+       gtk_widget_destroy(prefswindow->window);
        g_slist_free(prefswindow->prefs_pages);
        g_free(prefswindow);
 }
@@ -184,7 +181,7 @@ static gboolean find_child_by_name(GtkCTree *ctree, GtkCTreeNode *node, struct n
        return FALSE;
 }
 
-void prefswindow_open(GSList *prefs_pages, gpointer data)
+void prefswindow_open(const gchar *title, GSList *prefs_pages, gpointer data)
 {
        static gchar *titles [1];
        GSList *cur;
@@ -199,7 +196,7 @@ void prefswindow_open(GSList *prefs_pages, gpointer data)
        prefswindow->prefs_pages = g_slist_copy(prefs_pages);
 
        prefswindow->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-       gtk_window_set_title(GTK_WINDOW(prefswindow->window), _("Preferences"));
+       gtk_window_set_title(GTK_WINDOW(prefswindow->window), title);
        gtk_window_set_default_size(GTK_WINDOW(prefswindow->window), 600, 340);
        gtk_window_position (GTK_WINDOW(prefswindow->window), GTK_WIN_POS_CENTER);
        gtk_window_set_modal (GTK_WINDOW (prefswindow->window), TRUE);
@@ -232,8 +229,14 @@ void prefswindow_open(GSList *prefs_pages, gpointer data)
        gtk_misc_set_alignment(GTK_MISC(prefswindow->pagelabel), 0, 0.0);
        gtk_container_add(GTK_CONTAINER(prefswindow->labelframe), prefswindow->pagelabel);
 
-       prefswindow->page_widget = gtk_label_new("");
-       gtk_table_attach(GTK_TABLE(prefswindow->table2), prefswindow->page_widget, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 8, 8);
+       prefswindow->notebook = gtk_notebook_new();
+       gtk_notebook_set_scrollable(GTK_NOTEBOOK(prefswindow->notebook), TRUE);
+       gtk_notebook_set_show_tabs(GTK_NOTEBOOK(prefswindow->notebook), FALSE);
+       gtk_notebook_set_show_border(GTK_NOTEBOOK(prefswindow->notebook), FALSE);
+       gtk_table_attach(GTK_TABLE(prefswindow->table2), prefswindow->notebook, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 8, 8);
+
+       prefswindow->empty_page = gtk_label_new("");
+       gtk_container_add(GTK_CONTAINER(prefswindow->notebook), prefswindow->empty_page);
 
        /* actually we should create a tree here */
        for (cur = prefs_pages; cur != NULL; cur = g_slist_next(cur)) {
index 94fa68e..bfe4668 100644 (file)
@@ -40,6 +40,8 @@ struct _PrefsPage
        PrefsSavePageFunc        save_page;
 };
 
-void prefswindow_open                  ();
+void prefswindow_open                  (const gchar *title, 
+                                        GSList *prefs_pages,
+                                        gpointer data);
 
 #endif
index 5be5d41..474cf24 100644 (file)
@@ -64,7 +64,6 @@
 #include "prefs_filtering.h"
 #include "prefs_scoring.h"
 #include "prefs_account.h"
-#include "prefs_folder_item.h"
 #include "prefs_summary_column.h"
 #include "prefs_template.h"
 #include "action.h"
index b7ffd32..5c3d8fd 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -345,7 +345,7 @@ gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
        gchar *srcfile;
        gchar *destfile;
        gint filemode = 0;
-       PrefsFolderItem *prefs;
+       FolderItemPrefs *prefs;
 
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(msginfo != NULL, -1);
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);
 }
index 0003e23..0f6061d 100644 (file)
 #include <glib.h>
 #include <sys/types.h>
 
-typedef struct _PrefsFolderItem PrefsFolderItem;
-
 #include "folder.h"
 #include "folderview.h"
-
-struct _PrefsFolderItem {
-       gchar * directory;
-
-       gboolean sort_by_number;
-       gboolean sort_by_size;
-       gboolean sort_by_date;
-       gboolean sort_by_from;
-       gboolean sort_by_subject;
-       gboolean sort_by_score;
-
-       gboolean sort_descending;
-
-       gboolean enable_thread;
-
-       gint kill_score;
-       gint important_score;
-
-       GSList * scoring;
-       GSList * processing;
-
-       gboolean request_return_receipt;
-       gboolean enable_default_to;
-       gchar *default_to;
-       gboolean enable_default_reply_to;
-       gchar *default_reply_to;
-       gboolean enable_simplify_subject;
-       gchar *simplify_subject_regexp;
-       gboolean enable_folder_chmod;
-       gint folder_chmod;
-       gboolean enable_default_account;
-       gint default_account;
-       gboolean save_copy_to_folder;
-       guint color;
-};
+#include "folder_item_prefs.h"
+#include "prefswindow.h"
 
 void prefs_folder_item_create(FolderView *folderview, FolderItem *item); 
 
-void prefs_folder_item_read_config(FolderItem * item);
-void prefs_folder_item_save_config(FolderItem * item);
-void prefs_folder_item_set_config(FolderItem * item,
-                                 int sort_type, gint sort_mode);
-PrefsFolderItem * prefs_folder_item_new(void);
-void prefs_folder_item_free(PrefsFolderItem * prefs);
-gint prefs_folder_item_get_sort_type(FolderItem * item);
-gint prefs_folder_item_get_sort_mode(FolderItem * item);
-void prefs_folder_item_copy_prefs(FolderItem * src, FolderItem * dest);
+void prefs_folder_item_open            (FolderItem     *item);
+void prefs_folder_item_register_page   (PrefsPage      *page);
+void prefs_folder_item_unregister_page (PrefsPage      *page);
 
 #endif /* PREFS_FOLDER_ITEM_H */
index c971594..1cbc09d 100644 (file)
@@ -772,7 +772,7 @@ static GSList *prefs_pages = NULL;
 
 void prefs_gtk_open(void)
 {
-       prefswindow_open(prefs_pages, NULL);
+       prefswindow_open(_("Preferences"), prefs_pages, NULL);
 }
 
 void prefs_gtk_register_page(PrefsPage *page)
index 0b09ba6..d39d387 100644 (file)
@@ -742,7 +742,7 @@ static void prefs_scoring_ok(void)
                        prefs_scoring_set_list();
                        prefs_matcher_write_config();
                        if (cur_item != NULL)
-                               prefs_folder_item_save_config(cur_item);
+                               folder_item_prefs_save_config(cur_item);
                        gtk_widget_hide(scoring.window);
                        inc_unlock();
                        return;
@@ -769,7 +769,7 @@ static void prefs_scoring_ok(void)
        prefs_scoring_set_list();
        prefs_matcher_write_config();
        if (cur_item != NULL)
-               prefs_folder_item_save_config(cur_item);
+               folder_item_prefs_save_config(cur_item);
        gtk_widget_hide(scoring.window);
        inc_unlock();
 }
index 6c3558c..f55298b 100644 (file)
@@ -75,7 +75,7 @@
 #include "addressbook.h"
 #include "addr_compl.h"
 #include "scoring.h"
-#include "prefs_folder_item.h"
+#include "folder_item_prefs.h"
 #include "filtering.h"
 #include "string_match.h"
 #include "toolbar.h"
@@ -4989,7 +4989,7 @@ static gint summary_cmp_by_subject(GtkCList *clist,                        \
  static gint summary_cmp_by_simplified_subject
        (GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
 {
-       const PrefsFolderItem *prefs;
+       const FolderItemPrefs *prefs;
        const gchar *str1, *str2;
        const GtkCListRow *r1 = (const GtkCListRow *) ptr1;
        const GtkCListRow *r2 = (const GtkCListRow *) ptr2;