2007-05-30 [wwp] 2.9.2cvs20
authorTristan Chabredier <wwp@claws-mail.org>
Wed, 30 May 2007 22:35:52 +0000 (22:35 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Wed, 30 May 2007 22:35:52 +0000 (22:35 +0000)
* src/compose.c
* src/folder_item_prefs.c
* src/folder_item_prefs.h
* src/prefs_account.c
* src/prefs_account.h
* src/prefs_folder_item.c
* src/prefs_gtk.c
* src/prefs_gtk.h
Implemented per-account and per-folder
compose/reply/forward formats.

ChangeLog
PATCHSETS
configure.ac
src/compose.c
src/folder_item_prefs.c
src/folder_item_prefs.h
src/prefs_account.c
src/prefs_account.h
src/prefs_folder_item.c
src/prefs_gtk.c
src/prefs_gtk.h

index c69ce23a927b157294379b18d338eaa03a70ae1f..23098d9e4befb1c076da16f612cc7ea92583914e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2007-05-30 [wwp]       2.9.2cvs20
+
+       * src/compose.c
+       * src/folder_item_prefs.c
+       * src/folder_item_prefs.h
+       * src/prefs_account.c
+       * src/prefs_account.h
+       * src/prefs_folder_item.c
+       * src/prefs_gtk.c
+       * src/prefs_gtk.h
+               Implemented per-account and per-folder
+               compose/reply/forward formats.
+
 2007-05-30 [wwp]       2.9.2cvs19
 
        * src/prefs_compose_writing.c
index 9df5bc844f7eb5b6d34ab2bd8595ee207ecc8827..ea25840172812e21c0296dfa49a91ef73670e08c 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.23.2.23 -r 1.23.2.24 src/crash.c;  cvs diff -u -r 1.207.2.162 -r 1.207.2.163 src/folderview.c;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/ldapupdate.c;  ) > 2.9.2cvs17.patchset
 ( cvs diff -u -r 1.382.2.380 -r 1.382.2.381 src/compose.c;  ) > 2.9.2cvs18.patchset
 ( cvs diff -u -r 1.1.2.18 -r 1.1.2.19 src/prefs_compose_writing.c;  cvs diff -u -r 1.1.2.18 -r 1.1.2.19 src/prefs_quote.c;  cvs diff -u -r 1.47.2.40 -r 1.47.2.41 src/procheader.c;  cvs diff -u -r 1.8.2.17 -r 1.8.2.18 src/quote_fmt.c;  cvs diff -u -r 1.5.12.9 -r 1.5.12.10 src/quote_fmt.h;  ) > 2.9.2cvs19.patchset
+( cvs diff -u -r 1.382.2.381 -r 1.382.2.382 src/compose.c;  cvs diff -u -r 1.2.2.19 -r 1.2.2.20 src/folder_item_prefs.c;  cvs diff -u -r 1.2.2.8 -r 1.2.2.9 src/folder_item_prefs.h;  cvs diff -u -r 1.105.2.95 -r 1.105.2.96 src/prefs_account.c;  cvs diff -u -r 1.49.2.28 -r 1.49.2.29 src/prefs_account.h;  cvs diff -u -r 1.52.2.38 -r 1.52.2.39 src/prefs_folder_item.c;  cvs diff -u -r 1.10.2.30 -r 1.10.2.31 src/prefs_gtk.c;  cvs diff -u -r 1.5.2.13 -r 1.5.2.14 src/prefs_gtk.h;  ) > 2.9.2cvs20.patchset
index 02b877f6cf8a806f0e1e8e06dd194163f0bd8e72..96a9a4ecedc8a53c83cc35e6527451c064897029 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=19
+EXTRA_VERSION=20
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 9b01223ddb353e5d73dcff7a391ac34c88295909..780fb784759b6e5641a6d21d9fe1047cb8d65438 100644 (file)
@@ -178,6 +178,13 @@ typedef enum
        COMPOSE_WRITE_FOR_STORE
 } ComposeWriteType;
 
+typedef enum
+{
+       COMPOSE_QUOTE_FORCED,
+       COMPOSE_QUOTE_CHECK,
+       COMPOSE_QUOTE_SKIP
+} ComposeQuoteMode;
+
 #define B64_LINE_SIZE          57
 #define B64_BUFFSIZE           77
 
@@ -198,14 +205,14 @@ static Compose *compose_create                    (PrefsAccount   *account,
 static void compose_entry_mark_default_to      (Compose          *compose,
                                         const gchar      *address);
 static Compose *compose_followup_and_reply_to  (MsgInfo        *msginfo,
-                                        gboolean        quote,
+                                        ComposeQuoteMode        quote_mode,
                                         gboolean        to_all,
                                         gboolean        to_sender,
                                         const gchar    *body);
 static Compose *compose_forward_multiple       (PrefsAccount   *account, 
                                         GSList         *msginfo_list);
 static Compose *compose_reply                  (MsgInfo        *msginfo,
-                                        gboolean        quote,
+                                        ComposeQuoteMode        quote_mode,
                                         gboolean        to_all,
                                         gboolean        to_ml,
                                         gboolean        to_sender,
@@ -503,8 +510,10 @@ static void text_inserted          (GtkTextBuffer  *buffer,
                                         const gchar    *text,
                                         gint            len,
                                         Compose        *compose);
-static Compose *compose_generic_reply(MsgInfo *msginfo, gboolean quote,
-                                 gboolean to_all, gboolean to_ml,
+static Compose *compose_generic_reply(MsgInfo *msginfo,
+                                 ComposeQuoteMode quote_mode,
+                                 gboolean to_all,
+                                 gboolean to_ml,
                                  gboolean to_sender,
                                  gboolean followup_and_reply_to,
                                  const gchar *body);
@@ -971,6 +980,8 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
        GtkTextBuffer *textbuf;
        GtkTextIter iter;
        GtkItemFactory *ifactory;
+       gchar *subject_format = NULL;
+       gchar *body_format = NULL;
 
        if (item && item->prefs && item->prefs->enable_default_account)
                account = account_find_from_id(item->prefs->default_account);
@@ -1024,11 +1035,22 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
        }
        compose_add_field_list( compose, listAddress );
 
-       if (prefs_common.compose_with_format) {
+       if (item && item->prefs && item->prefs->compose_with_format) {
+               subject_format = item->prefs->compose_subject_format;
+               body_format = item->prefs->compose_body_format;
+       } else if (account->compose_with_format) {
+               subject_format = account->compose_subject_format;
+               body_format = account->compose_body_format;
+       } else if (prefs_common.compose_with_format) {
+               subject_format = prefs_common.compose_subject_format;
+               body_format = prefs_common.compose_body_format;
+       }
+
+       if (subject_format || body_format) {
                MsgInfo* dummyinfo = NULL;
 
-               if ( prefs_common.compose_subject_format
-                        && *prefs_common.compose_subject_format != '\0' )
+               if ( subject_format
+                        && *subject_format != '\0' )
                {
                        gchar *subject = NULL;
                        gchar *tmp = NULL;
@@ -1037,8 +1059,8 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                        dummyinfo = compose_msginfo_new_from_compose(compose);
 
                        /* decode \-escape sequences in the internal representation of the quote format */
-                       tmp = malloc(strlen(prefs_common.compose_subject_format)+1);
-                       pref_get_unescaped_pref(tmp, prefs_common.compose_subject_format);
+                       tmp = malloc(strlen(subject_format)+1);
+                       pref_get_unescaped_pref(tmp, subject_format);
 
                        subject = gtk_editable_get_chars(GTK_EDITABLE(compose->subject_entry), 0, -1);
 #ifdef USE_ASPELL
@@ -1061,8 +1083,8 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                        g_free(tmp);
                }
 
-               if ( prefs_common.compose_body_format
-                        && *prefs_common.compose_body_format != '\0' )
+               if ( body_format
+                        && *body_format != '\0' )
                {
                        GtkTextView *text;
                        GtkTextBuffer *buffer;
@@ -1079,7 +1101,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                        tmp = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
 
                        compose_quote_fmt(compose, dummyinfo,
-                                         prefs_common.compose_body_format,
+                                         body_format,
                                          NULL, tmp, FALSE, TRUE,
                                                  _("New message body format error at line %d."));
                        quote_fmt_reset_vartable();
@@ -1189,56 +1211,56 @@ static Compose *compose_reply_mode(ComposeMode mode, GSList *msginfo_list, gchar
 
        switch (mode) {
        case COMPOSE_REPLY:
-               compose = compose_reply(msginfo, prefs_common.reply_with_quote,
+               compose = compose_reply(msginfo, COMPOSE_QUOTE_CHECK,
                              FALSE, prefs_common.default_reply_list, FALSE, body);
                break;
        case COMPOSE_REPLY_WITH_QUOTE:
-               compose = compose_reply(msginfo, TRUE
+               compose = compose_reply(msginfo, COMPOSE_QUOTE_FORCED
                        FALSE, prefs_common.default_reply_list, FALSE, body);
                break;
        case COMPOSE_REPLY_WITHOUT_QUOTE:
-               compose = compose_reply(msginfo, FALSE
+               compose = compose_reply(msginfo, COMPOSE_QUOTE_SKIP
                        FALSE, prefs_common.default_reply_list, FALSE, NULL);
                break;
        case COMPOSE_REPLY_TO_SENDER:
-               compose = compose_reply(msginfo, prefs_common.reply_with_quote,
+               compose = compose_reply(msginfo, COMPOSE_QUOTE_CHECK,
                              FALSE, FALSE, TRUE, body);
                break;
        case COMPOSE_FOLLOWUP_AND_REPLY_TO:
                compose = compose_followup_and_reply_to(msginfo,
-                                             prefs_common.reply_with_quote,
+                                             COMPOSE_QUOTE_CHECK,
                                              FALSE, FALSE, body);
                break;
        case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE:
-               compose = compose_reply(msginfo, TRUE
+               compose = compose_reply(msginfo, COMPOSE_QUOTE_FORCED
                        FALSE, FALSE, TRUE, body);
                break;
        case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE:
-               compose = compose_reply(msginfo, FALSE
+               compose = compose_reply(msginfo, COMPOSE_QUOTE_SKIP
                        FALSE, FALSE, TRUE, NULL);
                break;
        case COMPOSE_REPLY_TO_ALL:
-               compose = compose_reply(msginfo, prefs_common.reply_with_quote,
+               compose = compose_reply(msginfo, COMPOSE_QUOTE_CHECK,
                        TRUE, FALSE, FALSE, body);
                break;
        case COMPOSE_REPLY_TO_ALL_WITH_QUOTE:
-               compose = compose_reply(msginfo, TRUE
+               compose = compose_reply(msginfo, COMPOSE_QUOTE_FORCED
                        TRUE, FALSE, FALSE, body);
                break;
        case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE:
-               compose = compose_reply(msginfo, FALSE
+               compose = compose_reply(msginfo, COMPOSE_QUOTE_SKIP
                        TRUE, FALSE, FALSE, NULL);
                break;
        case COMPOSE_REPLY_TO_LIST:
-               compose = compose_reply(msginfo, prefs_common.reply_with_quote,
+               compose = compose_reply(msginfo, COMPOSE_QUOTE_CHECK,
                        FALSE, TRUE, FALSE, body);
                break;
        case COMPOSE_REPLY_TO_LIST_WITH_QUOTE:
-               compose = compose_reply(msginfo, TRUE
+               compose = compose_reply(msginfo, COMPOSE_QUOTE_FORCED
                        FALSE, TRUE, FALSE, body);
                break;
        case COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE:
-               compose = compose_reply(msginfo, FALSE
+               compose = compose_reply(msginfo, COMPOSE_QUOTE_SKIP
                        FALSE, TRUE, FALSE, NULL);
                break;
        case COMPOSE_FORWARD:
@@ -1264,7 +1286,7 @@ static Compose *compose_reply_mode(ComposeMode mode, GSList *msginfo_list, gchar
                compose = compose_redirect(NULL, msginfo, FALSE);
                break;
        default:
-               g_warning("compose_reply(): invalid Compose Mode: %d\n", mode);
+               g_warning("compose_reply_mode(): invalid Compose Mode: %d\n", mode);
        }
        
        ifactory = gtk_item_factory_from_widget(compose->menubar);
@@ -1303,20 +1325,24 @@ static Compose *compose_reply_mode(ComposeMode mode, GSList *msginfo_list, gchar
        return compose;
 }
 
-static Compose *compose_reply(MsgInfo *msginfo, gboolean quote, gboolean to_all,
-                  gboolean to_ml, gboolean to_sender, 
+static Compose *compose_reply(MsgInfo *msginfo,
+                                  ComposeQuoteMode quote_mode,
+                                  gboolean to_all,
+                                  gboolean to_ml,
+                                  gboolean to_sender, 
                   const gchar *body)
 {
-       return compose_generic_reply(msginfo, quote, to_all, to_ml, 
+       return compose_generic_reply(msginfo, quote_mode, to_all, to_ml, 
                              to_sender, FALSE, body);
 }
 
-static Compose *compose_followup_and_reply_to(MsgInfo *msginfo, gboolean quote,
+static Compose *compose_followup_and_reply_to(MsgInfo *msginfo,
+                                  ComposeQuoteMode quote_mode,
                                   gboolean to_all,
                                   gboolean to_sender,
                                   const gchar *body)
 {
-       return compose_generic_reply(msginfo, quote, to_all, FALSE, 
+       return compose_generic_reply(msginfo, quote_mode, to_all, FALSE, 
                              to_sender, TRUE, body);
 }
 
@@ -1362,7 +1388,8 @@ static void compose_extract_original_charset(Compose *compose)
                                compose);                       \
 }
 
-static Compose *compose_generic_reply(MsgInfo *msginfo, gboolean quote,
+static Compose *compose_generic_reply(MsgInfo *msginfo,
+                                 ComposeQuoteMode quote_mode,
                                  gboolean to_all, gboolean to_ml,
                                  gboolean to_sender,
                                  gboolean followup_and_reply_to,
@@ -1374,6 +1401,9 @@ static Compose *compose_generic_reply(MsgInfo *msginfo, gboolean quote,
        PrefsAccount *reply_account;
        GtkTextView *textview;
        GtkTextBuffer *textbuf;
+       gboolean quote = FALSE;
+       gchar *qmark = NULL;
+       gchar *body_fmt = NULL;
 
        g_return_val_if_fail(msginfo != NULL, NULL);
        g_return_val_if_fail(msginfo->folder != NULL, NULL);
@@ -1392,6 +1422,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo, gboolean quote,
                        return NULL;
        } else
                reply_account = account;
+       /* wwp: TODO: why isn't reply_account used below? shouldn't we use reply_account instead of account? */
 
        compose = compose_create(account, COMPOSE_REPLY, FALSE);
 
@@ -1432,17 +1463,33 @@ static Compose *compose_generic_reply(MsgInfo *msginfo, gboolean quote,
                compose_set_dictionaries_from_folder_prefs(compose, msginfo->folder);
 #endif
 
-       if (quote) {
-               gchar *qmark;
+       if (quote_mode == COMPOSE_QUOTE_FORCED ||
+                       (quote_mode == COMPOSE_QUOTE_CHECK && prefs_common.reply_with_quote)) {
+               /* use the reply format of folder (if enabled), or the account's one
+                  (if enabled) or fallback to the global reply format, which is always
+                  enabled (even if empty), and use the relevant quotemark */
+               quote = TRUE;
+               if (msginfo->folder && msginfo->folder->prefs &&
+                               msginfo->folder->prefs->reply_with_format) {
+                       qmark = msginfo->folder->prefs->reply_quotemark;
+                       body_fmt = msginfo->folder->prefs->reply_body_format;
+
+               } else if (account->reply_with_format) {
+                       qmark = account->reply_quotemark;
+                       body_fmt = account->reply_body_format;
 
-               if (prefs_common.quotemark && *prefs_common.quotemark)
+               } else {
                        qmark = prefs_common.quotemark;
-               else
-                       qmark = "> ";
+                       body_fmt = prefs_common.quotefmt;
+               }
+       }
 
+       if (quote) {
+               /* empty quotemark is not allowed */
+               if (qmark && !*qmark);
+                       qmark = "> ";
                compose_quote_fmt(compose, compose->replyinfo,
-                                 prefs_common.quotefmt,
-                                 qmark, body, FALSE, TRUE,
+                                 body_fmt, qmark, body, FALSE, TRUE,
                                          _("Message reply format error at line %d."));
                quote_fmt_reset_vartable();
        }
@@ -1544,22 +1591,37 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
 
                g_free(msgfile);
        } else {
-               gchar *qmark;
+               gchar *qmark = NULL;
+               gchar *body_fmt = prefs_common.fw_quotefmt;
                MsgInfo *full_msginfo;
 
                full_msginfo = procmsg_msginfo_get_full_info(msginfo);
                if (!full_msginfo)
                        full_msginfo = procmsg_msginfo_copy(msginfo);
 
-               if (prefs_common.fw_quotemark &&
-                   *prefs_common.fw_quotemark)
+               /* use the forward format of folder (if enabled), or the account's one
+                  (if enabled) or fallback to the global forward format, which is always
+                  enabled (even if empty), and use the relevant quotemark */
+               if (msginfo->folder && msginfo->folder->prefs &&
+                               msginfo->folder->prefs->forward_with_format) {
+                       qmark = msginfo->folder->prefs->forward_quotemark;
+                       body_fmt = msginfo->folder->prefs->forward_body_format;
+
+               } else if (account->forward_with_format) {
+                       qmark = account->forward_quotemark;
+                       body_fmt = account->forward_body_format;
+
+               } else {
                        qmark = prefs_common.fw_quotemark;
-               else
+                       body_fmt = prefs_common.fw_quotefmt;
+               }
+
+               /* empty quotemark is not allowed */
+               if (qmark && !*qmark)
                        qmark = "> ";
 
                compose_quote_fmt(compose, full_msginfo,
-                                 prefs_common.fw_quotefmt,
-                                 qmark, body, FALSE, TRUE,
+                                 body_fmt, qmark, body, FALSE, TRUE,
                                          _("Message forward format error at line %d."));
                quote_fmt_reset_vartable();
                compose_attach_parts(compose, msginfo);
index f9cdd8f98251e9c60c949ebccf83dbc02c878489..0c030ce21aa7bbef56dd1d3921ee510083d8880d 100644 (file)
@@ -95,6 +95,25 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"offlinesync", "FALSE", &tmp_prefs.offlinesync, P_BOOL,
         NULL, NULL, NULL},
+
+       {"compose_with_format", "FALSE", &tmp_prefs.compose_with_format, P_BOOL,
+        NULL, NULL, NULL},
+       {"compose_subject_format", NULL, &tmp_prefs.compose_subject_format, P_STRING,
+        NULL, NULL, NULL},
+       {"compose_body_format", NULL, &tmp_prefs.compose_body_format, P_STRING,
+        NULL, NULL, NULL},
+       {"reply_with_format", "FALSE", &tmp_prefs.reply_with_format, P_BOOL,
+        NULL, NULL, NULL},
+       {"reply_quotemark", NULL, &tmp_prefs.reply_quotemark, P_STRING,
+        NULL, NULL, NULL},
+       {"reply_body_format", NULL, &tmp_prefs.reply_body_format, P_STRING,
+        NULL, NULL, NULL},
+       {"forward_with_format", "FALSE", &tmp_prefs.forward_with_format, P_BOOL,
+        NULL, NULL, NULL},
+       {"forward_quotemark", NULL, &tmp_prefs.forward_quotemark, P_STRING,
+        NULL, NULL, NULL},
+       {"forward_body_format", NULL, &tmp_prefs.forward_body_format, P_STRING,
+        NULL, NULL, NULL},
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
 
@@ -188,6 +207,16 @@ static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *prefs)
        prefs->newmailcheck = TRUE;
        prefs->offlinesync = FALSE;
 
+       prefs->compose_with_format = FALSE;
+       prefs->compose_subject_format = NULL;
+       prefs->compose_body_format = NULL;
+       prefs->reply_with_format = FALSE;
+       prefs->reply_quotemark = NULL;
+       prefs->reply_body_format = NULL;
+       prefs->forward_with_format = FALSE;
+       prefs->forward_quotemark = NULL;
+       prefs->forward_body_format = NULL;
+
        return prefs;
 }
 
@@ -204,6 +233,12 @@ void folder_item_prefs_free(FolderItemPrefs * prefs)
 {
        g_free(prefs->default_to);
        g_free(prefs->default_reply_to);
+       g_free(prefs->compose_subject_format);
+       g_free(prefs->compose_body_format);
+       g_free(prefs->reply_quotemark);
+       g_free(prefs->reply_body_format);
+       g_free(prefs->forward_quotemark);
+       g_free(prefs->forward_body_format);
        g_free(prefs);
 }
 
@@ -259,6 +294,16 @@ void folder_item_prefs_copy_prefs(FolderItem * src, FolderItem * dest)
        tmp_prefs.save_copy_to_folder           = src->prefs->save_copy_to_folder;
        tmp_prefs.color                         = src->prefs->color;
 
+       tmp_prefs.compose_with_format = src->prefs->compose_with_format;
+       tmp_prefs.compose_subject_format = g_strdup(src->prefs->compose_subject_format);
+       tmp_prefs.compose_body_format = g_strdup(src->prefs->compose_body_format);
+       tmp_prefs.reply_with_format = src->prefs->reply_with_format;
+       tmp_prefs.reply_quotemark = g_strdup(src->prefs->reply_quotemark);
+       tmp_prefs.reply_body_format = g_strdup(src->prefs->reply_body_format);
+       tmp_prefs.forward_with_format = src->prefs->forward_with_format;
+       tmp_prefs.forward_quotemark = g_strdup(src->prefs->forward_quotemark);
+       tmp_prefs.forward_body_format = g_strdup(src->prefs->forward_body_format);
+
        *dest->prefs = tmp_prefs;
        folder_item_prefs_save_config(dest);
 }
index db0eef190cffcf13789444b581d7a955004aae64..99affdd239207536d2fa19503ef6521c9d087b4b 100644 (file)
@@ -66,6 +66,16 @@ struct _FolderItemPrefs {
 #endif
        gboolean save_copy_to_folder;
        guint color;
+
+       gboolean compose_with_format;
+       gchar *compose_subject_format;
+       gchar *compose_body_format;
+       gboolean reply_with_format;
+       gchar *reply_quotemark;
+       gchar *reply_body_format;
+       gboolean forward_with_format;
+       gchar *forward_quotemark;
+       gchar *forward_body_format;
 };
 
 void folder_item_prefs_read_config(FolderItem * item);
index 2e8496d7d40a259482274d4d0834f0ac7509e72b..ac4c2a915aa2e533e6310dfddbd4eca361658f79 100644 (file)
@@ -56,6 +56,7 @@
 #include "base64.h"
 #include "combobox.h"
 #include "setup.h"
+#include "quote_fmt.h"
 
 static gboolean cancelled;
 static gboolean new_account;
@@ -72,6 +73,33 @@ static GtkWidget *signature_edit_button;
 
 static GSList *prefs_pages = NULL;
 
+typedef struct AccountPage
+{
+    PrefsPage page;
+
+    GtkWidget *vbox;
+} AccountPage;
+
+typedef struct TemplatesPage
+{
+    PrefsPage page;
+
+    GtkWidget *vbox;
+
+       GtkWidget *checkbtn_compose_with_format;
+       GtkWidget *compose_subject_format;
+       GtkWidget *compose_body_format;
+       GtkWidget *checkbtn_reply_with_format;
+       GtkWidget *reply_quotemark;
+       GtkWidget *reply_body_format;
+       GtkWidget *checkbtn_forward_with_format;
+       GtkWidget *forward_quotemark;
+       GtkWidget *forward_body_format;
+} TemplatesPage;
+
+static AccountPage account_page;
+static TemplatesPage templates_page;
+
 struct BasicProtocol {
        GtkWidget *combobox;
        GtkWidget *label;
@@ -637,6 +665,46 @@ static PrefParam param[] = {
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
 
+static PrefParam templates_param[] = {
+       {"compose_with_format", "FALSE", &tmp_ac_prefs.compose_with_format, P_BOOL,
+        &templates_page.checkbtn_compose_with_format,
+        prefs_set_data_from_toggle, prefs_set_toggle},
+
+       {"compose_subject_format", NULL, &tmp_ac_prefs.compose_subject_format, P_STRING,
+        &templates_page.compose_subject_format,
+        prefs_set_escaped_data_from_entry, prefs_set_entry_from_escaped},
+
+       {"compose_body_format", NULL, &tmp_ac_prefs.compose_body_format, P_STRING,
+        &templates_page.compose_body_format,
+        prefs_set_escaped_data_from_text, prefs_set_text_from_escaped},
+
+       {"reply_with_format", "FALSE", &tmp_ac_prefs.reply_with_format, P_BOOL,
+        &templates_page.checkbtn_reply_with_format,
+        prefs_set_data_from_toggle, prefs_set_toggle},
+
+       {"reply_quotemark", NULL, &tmp_ac_prefs.reply_quotemark, P_STRING,
+        &templates_page.reply_quotemark,
+        prefs_set_data_from_entry, prefs_set_entry_from_escaped},
+
+       {"reply_body_format", NULL, &tmp_ac_prefs.reply_body_format, P_STRING,
+        &templates_page.reply_body_format,
+        prefs_set_escaped_data_from_text, prefs_set_text_from_escaped},
+
+       {"forward_with_format", "FALSE", &tmp_ac_prefs.forward_with_format, P_BOOL,
+        &templates_page.checkbtn_forward_with_format,
+        prefs_set_data_from_toggle, prefs_set_toggle},
+
+       {"forward_quotemark", NULL, &tmp_ac_prefs.forward_quotemark, P_STRING,
+        &templates_page.forward_quotemark,
+        prefs_set_data_from_entry, prefs_set_entry_from_escaped},
+
+       {"forward_body_format", NULL, &tmp_ac_prefs.forward_body_format, P_STRING,
+        &templates_page.forward_body_format,
+        prefs_set_escaped_data_from_text, prefs_set_text_from_escaped},
+
+       {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
+};
+
 static gint prefs_account_get_new_id           (void);
 
 static void prefs_account_create               (void);
@@ -671,15 +739,7 @@ static void pop_bfr_smtp_tm_set_sens               (GtkWidget      *widget,
 static void prefs_account_edit_custom_header   (void);
 
 static gint prefs_account_apply                        (void);
-
-typedef struct AccountPage
-{
-        PrefsPage page;
-        GtkWidget *vbox;
-} AccountPage;
-
-static AccountPage account_page;
+static gint prefs_templates_apply              (void);
 
 static void privacy_system_activated(GtkMenuItem *menuitem)
 {
@@ -743,7 +803,7 @@ static void update_privacy_system_menu() {
        gtk_option_menu_set_menu(GTK_OPTION_MENU(privacy.default_privacy_system), menu);
 }
 
-static void create_widget_func(PrefsPage * _page,
+static void account_create_widget_func(PrefsPage * _page,
                                            GtkWindow * window,
                                            gpointer data)
 {
@@ -751,7 +811,7 @@ static void create_widget_func(PrefsPage * _page,
        PrefsAccount *ac_prefs = (PrefsAccount *) data;
        GtkWidget *vbox;
 
-       vbox = gtk_vbox_new(FALSE, 6);
+       vbox = gtk_vbox_new(FALSE, VSPACING);
        gtk_widget_show(vbox);
 
        if (notebook == NULL)
@@ -818,25 +878,35 @@ static void create_widget_func(PrefsPage * _page,
        page->page.widget = vbox;
 }
 
-static void destroy_widget_func(PrefsPage *_page)
+static void account_destroy_widget_func(PrefsPage *_page)
 {
        AccountPage *page = (AccountPage *) _page;
 
        gtk_container_remove(GTK_CONTAINER (page->vbox), notebook);
 }
 
-static gboolean can_close_func(PrefsPage *page_)
+static gboolean account_can_close_func(PrefsPage *_page)
 {      
+       AccountPage *page = (AccountPage *) _page;
+
+       if (!page->page.page_open)
+               return TRUE;
+
        return prefs_account_apply() >= 0;
 }
 
-static void save_func(PrefsPage * _page)
+static void account_save_func(PrefsPage *_page)
 {
+       AccountPage *page = (AccountPage *) _page;
+
+       if (!page->page.page_open)
+               return;
+
        if (prefs_account_apply() >= 0)
                cancelled = FALSE;
 }
 
-void prefs_account_init()
+void register_account_page(void)
 {
        static gchar *path[2];
 
@@ -845,14 +915,124 @@ void prefs_account_init()
         
        account_page.page.path = path;
        account_page.page.weight = 1000.0;
-       account_page.page.create_widget = create_widget_func;
-       account_page.page.destroy_widget = destroy_widget_func;
-       account_page.page.save_page = save_func;
-       account_page.page.can_close = can_close_func;
+       account_page.page.create_widget = account_create_widget_func;
+       account_page.page.destroy_widget = account_destroy_widget_func;
+       account_page.page.save_page = account_save_func;
+       account_page.page.can_close = account_can_close_func;
 
        prefs_account_register_page((PrefsPage *) &account_page);
 }
 
+static void templates_create_widget_func(PrefsPage * _page,
+                                           GtkWindow * window,
+                                           gpointer data)
+{
+       TemplatesPage *page = (TemplatesPage *) _page;
+/*     PrefsAccount *ac_prefs = (PrefsAccount *) data; */
+       GtkWidget *vbox;
+
+       vbox = gtk_vbox_new(FALSE, VSPACING);
+       gtk_widget_show(vbox);
+       gtk_container_set_border_width (GTK_CONTAINER (vbox), VBOX_BORDER);
+
+       /* compose/reply/forward formats */
+       quotefmt_create_new_msg_fmt_widgets(
+                               window,
+                               vbox,
+                               &page->checkbtn_compose_with_format,
+                               _("Use a specific format for new messages"),
+                               &page->compose_subject_format,
+                               &page->compose_body_format,
+                               FALSE);
+       quotefmt_create_reply_fmt_widgets(
+                               window,
+                               vbox,
+                               &page->checkbtn_reply_with_format,
+                               _("Use a specific reply quote format"),
+                               &page->reply_quotemark,
+                               &page->reply_body_format,
+                               FALSE);
+       quotefmt_create_forward_fmt_widgets(
+                               window,
+                               vbox,
+                               &page->checkbtn_forward_with_format,
+                               _("Use a specific forward quote format"),
+                               &page->forward_quotemark,
+                               &page->forward_body_format,
+                               FALSE);
+       quotefmt_add_info_button(window, vbox);
+
+       if (new_account) {
+               prefs_set_dialog_to_default(templates_param);
+       } else
+               prefs_set_dialog(templates_param);
+
+       page->vbox = vbox;
+
+       page->page.widget = vbox;
+}
+
+static void templates_destroy_widget_func(PrefsPage *_page)
+{
+       /* TemplatesPage *page = (TemplatesPage *) _page; */
+}
+
+static void prefs_account_check_templates(void)
+{
+       quotefmt_check_new_msg_formats(tmp_ac_prefs.compose_with_format,
+                                                                       tmp_ac_prefs.compose_subject_format,
+                                                                       tmp_ac_prefs.compose_body_format);
+       quotefmt_check_reply_formats(tmp_ac_prefs.reply_with_format,
+                                                                       tmp_ac_prefs.reply_body_format);
+       quotefmt_check_forward_formats(tmp_ac_prefs.forward_with_format,
+                                                                       tmp_ac_prefs.forward_body_format);
+}
+
+static gboolean templates_can_close_func(PrefsPage *_page)
+{
+       TemplatesPage *page = (TemplatesPage *) _page;
+
+       if (!page->page.page_open)
+               return TRUE;
+
+       return prefs_templates_apply() >= 0;
+}
+
+static void templates_save_func(PrefsPage *_page)
+{
+       TemplatesPage *page = (TemplatesPage *) _page;
+
+       if (!page->page.page_open)
+               return;
+
+       prefs_account_check_templates();
+       if (prefs_templates_apply() >= 0)
+                       cancelled = FALSE;
+}
+
+void register_templates_page(void)
+{
+       static gchar *path[2];
+
+       path[0] = _("Templates");
+       path[1] = NULL;
+        
+       templates_page.page.path = path;
+       templates_page.page.weight = 1000.0;
+       templates_page.page.create_widget = templates_create_widget_func;
+       templates_page.page.destroy_widget = templates_destroy_widget_func;
+       templates_page.page.save_page = templates_save_func;
+       templates_page.page.can_close = templates_can_close_func;
+
+       prefs_account_register_page((PrefsPage *) &templates_page);
+}
+
+void prefs_account_init()
+{
+       register_account_page();
+       register_templates_page();
+}
+
 PrefsAccount *prefs_account_new(void)
 {
        PrefsAccount *ac_prefs;
@@ -860,6 +1040,7 @@ PrefsAccount *prefs_account_new(void)
        ac_prefs = g_new0(PrefsAccount, 1);
        memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
        prefs_set_default(param);
+       prefs_set_default(templates_param);
        *ac_prefs = tmp_ac_prefs;
        ac_prefs->account_id = prefs_account_get_new_id();
 
@@ -883,6 +1064,7 @@ void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label)
 
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
        prefs_read_config(param, label, rcpath, NULL);
+       prefs_read_config(templates_param, label, rcpath, NULL);
        g_free(rcpath);
 
        *ac_prefs = tmp_ac_prefs;
@@ -969,6 +1151,13 @@ void prefs_account_write_config_all(GList *account_list)
                        privacy_prefs = NULL;
                        return;
                }
+               if (prefs_write_param(templates_param, pfile->fp) < 0) {
+                       g_warning("failed to write configuration to file\n");
+                       prefs_file_close_revert(pfile);
+               g_free(privacy_prefs);
+               privacy_prefs = NULL;
+                       return;
+               }
                g_free(privacy_prefs);
                privacy_prefs = NULL;
 
@@ -1001,6 +1190,7 @@ void prefs_account_free(PrefsAccount *ac_prefs)
 
        tmp_ac_prefs = *ac_prefs;
        prefs_free(param);
+       prefs_free(templates_param);
 }
 
 const gchar *prefs_account_get_privacy_prefs(PrefsAccount *account, gchar *id)
@@ -2723,6 +2913,12 @@ static gint prefs_account_apply(void)
        return 0;
 }
 
+static gint prefs_templates_apply(void)
+{
+       prefs_set_data_from_dialog(templates_param);
+       return 0;
+}
+
 static void pop_bfr_smtp_tm_set_sens(GtkWidget *widget, gpointer data)
 {
        gtk_widget_set_sensitive(p_send.pop_bfr_smtp_tm_entry, 
index 600aea77719665cf9a634b453cf20829ce8a5f98..99cc8510c72cc5c196487292d8bf41786b1ee544 100644 (file)
@@ -131,6 +131,15 @@ struct _PrefsAccount
        gboolean  enable_default_alt_dictionary;
        gchar    *default_alt_dictionary;
 #endif
+       gboolean  compose_with_format;
+       gchar    *compose_subject_format;
+       gchar    *compose_body_format;
+       gboolean  reply_with_format;
+       gchar    *reply_quotemark;
+       gchar    *reply_body_format;
+       gboolean  forward_with_format;
+       gchar    *forward_quotemark;
+       gchar    *forward_body_format;
 
        /* Privacy */
        gchar    *default_privacy_system;
index 8cff6f9a00f4287762f9293bd9b0ac66c7dd492a..f31ced42ff6e1246672d0ef5b9b755736f41ada2 100644 (file)
@@ -46,6 +46,7 @@
 #include "folder_item_prefs.h"
 #include "gtk/colorsel.h"
 #include "string_match.h"
+#include "quote_fmt.h"
 
 #if USE_ASPELL
 #include "gtkaspell.h"
@@ -59,6 +60,7 @@
 
 typedef struct _FolderItemGeneralPage FolderItemGeneralPage;
 typedef struct _FolderItemComposePage FolderItemComposePage;
+typedef struct _FolderItemTemplatesPage FolderItemTemplatesPage;
 static gboolean can_save = TRUE;
 
 struct _FolderItemGeneralPage
@@ -128,12 +130,32 @@ struct _FolderItemComposePage
 #endif
 };
 
+struct _FolderItemTemplatesPage
+{
+       PrefsPage page;
+
+       FolderItem *item;
+
+       GtkWidget *window;
+       GtkWidget *checkbtn_compose_with_format;
+       GtkWidget *compose_subject_format;
+       GtkWidget *compose_body_format;
+       GtkWidget *checkbtn_reply_with_format;
+       GtkWidget *reply_quotemark;
+       GtkWidget *reply_body_format;
+       GtkWidget *checkbtn_forward_with_format;
+       GtkWidget *forward_quotemark;
+       GtkWidget *forward_body_format;
+};
+
 
 static void general_save_folder_prefs(FolderItem *folder, FolderItemGeneralPage *page);
 static void compose_save_folder_prefs(FolderItem *folder, FolderItemComposePage *page);
+static void templates_save_folder_prefs(FolderItem *folder, FolderItemTemplatesPage *page);
 
 static gboolean general_save_recurse_func(GNode *node, gpointer data);
 static gboolean compose_save_recurse_func(GNode *node, gpointer data);
+static gboolean templates_save_recurse_func(GNode *node, gpointer data);
 
 static gint prefs_folder_item_chmod_mode               (gchar *folder_chmod);
 
@@ -1026,6 +1048,160 @@ static void prefs_folder_item_compose_save_func(PrefsPage *page_)
 
 }
 
+static void prefs_folder_item_templates_create_widget_func(PrefsPage * page_,
+                                                  GtkWindow * window,
+                                                  gpointer data)
+{
+       FolderItemTemplatesPage *page = (FolderItemTemplatesPage *) page_;
+       FolderItem *item = (FolderItem *) data;
+
+       GtkWidget *vbox_formats;
+
+       page->item         = item;
+
+       /* compose/reply/forward formats */
+       vbox_formats = gtk_vbox_new (FALSE, VSPACING);
+       gtk_widget_show (vbox_formats);
+       gtk_container_set_border_width (GTK_CONTAINER (vbox_formats), VBOX_BORDER);
+
+       quotefmt_create_new_msg_fmt_widgets(
+                               window,
+                               vbox_formats,
+                               &page->checkbtn_compose_with_format,
+                               _("Use a specific format for new messages"),
+                               &page->compose_subject_format,
+                               &page->compose_body_format,
+                               FALSE);
+       quotefmt_create_reply_fmt_widgets(
+                               window,
+                               vbox_formats,
+                               &page->checkbtn_reply_with_format,
+                               _("Use a specific reply quote format"),
+                               &page->reply_quotemark,
+                               &page->reply_body_format,
+                               FALSE);
+       quotefmt_create_forward_fmt_widgets(
+                               window,
+                               vbox_formats,
+                               &page->checkbtn_forward_with_format,
+                               _("Use a specific forward quote format"),
+                               &page->forward_quotemark,
+                               &page->forward_body_format,
+                               FALSE);
+       quotefmt_add_info_button(window, vbox_formats);
+
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(page->checkbtn_compose_with_format),
+                       item->prefs->compose_with_format);
+       pref_set_entry_from_pref(GTK_ENTRY(page->compose_subject_format),
+                       item->prefs->compose_subject_format);
+       pref_set_textview_from_pref(GTK_TEXT_VIEW(page->compose_body_format),
+                       item->prefs->compose_body_format);
+
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(page->checkbtn_reply_with_format),
+                       item->prefs->reply_with_format);
+       pref_set_entry_from_pref(GTK_ENTRY(page->reply_quotemark),
+                       item->prefs->reply_quotemark);
+       pref_set_textview_from_pref(GTK_TEXT_VIEW(page->reply_body_format),
+                       item->prefs->reply_body_format);
+
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(page->checkbtn_forward_with_format),
+                       item->prefs->forward_with_format);
+       pref_set_entry_from_pref(GTK_ENTRY(page->forward_quotemark),
+                       item->prefs->forward_quotemark);
+       pref_set_textview_from_pref(GTK_TEXT_VIEW(page->forward_body_format),
+                       item->prefs->forward_body_format);
+
+       gtk_widget_show_all(vbox_formats);
+
+       page->window = GTK_WIDGET(window);
+
+       page->page.widget = vbox_formats;
+}
+
+static void prefs_folder_item_templates_destroy_widget_func(PrefsPage *page_) 
+{
+       /* FolderItemTemplatesPage *page = (FolderItemTemplatesPage *) page_; */
+}
+
+/** \brief  Save the prefs in page to folder.
+ *
+ *  If the folder is not the one  specified in page->item, then only those properties 
+ *  that have the relevant 'apply to sub folders' button checked are saved
+ */
+static void templates_save_folder_prefs(FolderItem *folder, FolderItemTemplatesPage *page)
+{
+       FolderItemPrefs *prefs = folder->prefs;
+       gboolean all = FALSE;
+
+       if (folder->path == NULL)
+               return;
+
+       if (page->item == folder) 
+               all = TRUE;
+
+       g_return_if_fail(prefs != NULL);
+
+       /* save and check formats */
+
+       if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_compose_with_format))) {
+               prefs->compose_with_format =
+                       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_compose_with_format));
+               prefs->compose_subject_format = pref_get_pref_from_entry(
+                               GTK_ENTRY(page->compose_subject_format));
+               prefs->compose_body_format = pref_get_pref_from_textview(
+                               GTK_TEXT_VIEW(page->compose_body_format));
+               quotefmt_check_new_msg_formats(prefs->compose_with_format,
+                                                                               prefs->compose_subject_format,
+                                                                               prefs->compose_body_format);
+       }
+
+       if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_reply_with_format))) {
+               prefs->reply_with_format =
+                       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_reply_with_format));
+               prefs->reply_quotemark = gtk_editable_get_chars(
+                               GTK_EDITABLE(page->reply_quotemark), 0, -1);
+               prefs->reply_body_format = pref_get_pref_from_textview(
+                               GTK_TEXT_VIEW(page->reply_body_format));
+               quotefmt_check_reply_formats(prefs->reply_with_format,
+                                                                               prefs->reply_body_format);
+       }
+
+       if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_forward_with_format))) {
+               prefs->forward_with_format =
+                       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_forward_with_format));
+               prefs->forward_quotemark = gtk_editable_get_chars(
+                               GTK_EDITABLE(page->forward_quotemark), 0, -1);
+               prefs->forward_body_format = pref_get_pref_from_textview(
+                               GTK_TEXT_VIEW(page->forward_body_format));
+               quotefmt_check_forward_formats(prefs->forward_with_format,
+                                                                               prefs->forward_body_format);
+       }
+
+       folder_item_prefs_save_config(folder);
+}      
+
+static gboolean templates_save_recurse_func(GNode *node, gpointer data)
+{
+       FolderItem *item = (FolderItem *) node->data;
+       FolderItemTemplatesPage *page = (FolderItemTemplatesPage *) data;
+
+       g_return_val_if_fail(item != NULL, TRUE);
+       g_return_val_if_fail(page != NULL, TRUE);
+
+       templates_save_folder_prefs(item, page);
+
+       return FALSE;
+}
+
+static void prefs_folder_item_templates_save_func(PrefsPage *page_) 
+{
+       FolderItemTemplatesPage *page = (FolderItemTemplatesPage *) page_;
+
+       g_node_traverse(page->item->node, G_PRE_ORDER, G_TRAVERSE_ALL,
+                       -1, templates_save_recurse_func, page);
+
+}
+
 static gint prefs_folder_item_chmod_mode(gchar *folder_chmod) 
 {
        gint newmode = 0;
@@ -1181,6 +1357,22 @@ static void register_compose_page(void)
        prefs_folder_item_register_page((PrefsPage *) &folder_item_compose_page);
 }
 
+static void register_templates_page(void)
+{
+       static gchar *pfi_templates_path[2];
+       static FolderItemTemplatesPage folder_item_templates_page;
+
+       pfi_templates_path[0] = _("Templates");
+       pfi_templates_path[1] = NULL;
+
+        folder_item_templates_page.page.path = pfi_templates_path;
+        folder_item_templates_page.page.create_widget = prefs_folder_item_templates_create_widget_func;
+        folder_item_templates_page.page.destroy_widget = prefs_folder_item_templates_destroy_widget_func;
+        folder_item_templates_page.page.save_page = prefs_folder_item_templates_save_func;
+        
+       prefs_folder_item_register_page((PrefsPage *) &folder_item_templates_page);
+}
+
 static GSList *prefs_pages = NULL;
 
 void prefs_folder_item_open(FolderItem *item)
@@ -1189,6 +1381,7 @@ void prefs_folder_item_open(FolderItem *item)
        if (prefs_pages == NULL) {
                register_general_page();
                register_compose_page();
+               register_templates_page();
        }
 
        if (item->path) {
index 2127455dac237ce04f4ecaf59c722fcba12c9773..d268fac735e82353aeae612c0e1f046ebcd24592 100644 (file)
@@ -720,6 +720,24 @@ void prefs_set_data_from_entry(PrefParam *pparam)
        }
 }
 
+void prefs_set_escaped_data_from_entry(PrefParam *pparam)
+{
+       gchar **str;
+
+       g_return_if_fail(*pparam->widget != NULL);
+
+       switch (pparam->type) {
+       case P_STRING:
+               str = (gchar **)pparam->data;
+               g_free(*str);
+               *str = pref_get_pref_from_entry(GTK_ENTRY(*pparam->widget));
+               break;
+       default:
+               g_warning("Invalid escaped PrefType for GtkEntry widget: %d\n",
+                         pparam->type);
+       }
+}
+
 void prefs_set_entry(PrefParam *pparam)
 {
        gchar **str;
@@ -747,6 +765,24 @@ void prefs_set_entry(PrefParam *pparam)
        }
 }
 
+void prefs_set_entry_from_escaped(PrefParam *pparam)
+{
+       gchar **str;
+
+       g_return_if_fail(*pparam->widget != NULL);
+
+       switch (pparam->type) {
+       case P_STRING:
+               str = (gchar **)pparam->data;
+               pref_set_entry_from_pref(GTK_ENTRY(*pparam->widget),
+                                  *str ? *str : "");
+               break;
+       default:
+               g_warning("Invalid escaped PrefType for GtkEntry widget: %d\n",
+                         pparam->type);
+       }
+}
+
 void prefs_set_data_from_text(PrefParam *pparam)
 {
        gchar **str;
@@ -800,6 +836,24 @@ void prefs_set_data_from_text(PrefParam *pparam)
        }
 }
 
+void prefs_set_escaped_data_from_text(PrefParam *pparam)
+{
+       gchar **str;
+
+       g_return_if_fail(*pparam->widget != NULL);
+
+       switch (pparam->type) {
+       case P_STRING:
+               str = (gchar **)pparam->data;
+               g_free(*str);
+               *str = pref_get_pref_from_textview(GTK_TEXT_VIEW(*pparam->widget));
+               break;
+       default:
+               g_warning("Invalid escaped PrefType for GtkText widget: %d\n",
+                         pparam->type);
+       }
+}
+
 void prefs_set_text(PrefParam *pparam)
 {
        gchar *buf, *sp, *bufp;
@@ -843,6 +897,24 @@ void prefs_set_text(PrefParam *pparam)
        }
 }
 
+void prefs_set_text_from_escaped(PrefParam *pparam)
+{
+       gchar **str;
+
+       g_return_if_fail(*pparam->widget != NULL);
+
+       switch (pparam->type) {
+       case P_STRING:
+               str = (gchar **)pparam->data;
+               pref_set_textview_from_pref(GTK_TEXT_VIEW(*pparam->widget),
+                                *str ? *str : "");
+               break;
+       default:
+               g_warning("Invalid escaped PrefType for GtkTextView widget: %d\n",
+                         pparam->type);
+       }
+}
+
 void prefs_set_data_from_toggle(PrefParam *pparam)
 {
        g_return_if_fail(pparam->type == P_BOOL);
index 8762fcc197c88b3789a8b11fdf3e1318ace61d0b..26032562859282a9e09bc09d937543cad519a3cb 100644 (file)
@@ -173,9 +173,13 @@ void prefs_set_data_from_dialog    (PrefParam      *param);
 void prefs_set_dialog_to_default(PrefParam     *param);
 
 void prefs_set_data_from_entry (PrefParam      *pparam);
+void prefs_set_escaped_data_from_entry (PrefParam      *pparam);
 void prefs_set_entry           (PrefParam      *pparam);
+void prefs_set_entry_from_escaped      (PrefParam      *pparam);
 void prefs_set_data_from_text  (PrefParam      *pparam);
+void prefs_set_escaped_data_from_text  (PrefParam      *pparam);
 void prefs_set_text            (PrefParam      *pparam);
+void prefs_set_text_from_escaped(PrefParam *pparam);
 void prefs_set_data_from_toggle        (PrefParam      *pparam);
 void prefs_set_toggle          (PrefParam      *pparam);
 void prefs_set_data_from_spinbtn(PrefParam     *pparam);