2006-02-08 [wwp] 2.0.0cvs32
authorTristan Chabredier <wwp@claws-mail.org>
Wed, 8 Feb 2006 10:24:41 +0000 (10:24 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Wed, 8 Feb 2006 10:24:41 +0000 (10:24 +0000)
* src/compose.c
* src/compose.h
templates enhancement: allow symbols substitutions in To/Cc/Bcc/Subject fields

ChangeLog
PATCHSETS
configure.ac
src/compose.c
src/compose.h

index 9123348316f6852d03f11cd4c94d412f578dbced..b1d12932bbc95e54158b33976fa6030bcb663138 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-02-08 [wwp]       2.0.0cvs32
+
+       * src/compose.c
+       * src/compose.h
+               templates enhancement: allow symbols substitutions in To/Cc/Bcc/Subject fields
+
 2006-02-08 [wwp]       2.0.0cvs31
 
        * src/prefs_template.c
index cab522aa3d9cbbfd71f2a5b791d351e88b2cbce5..392ffb9d096f6db8e00291c769d86ab6bb5c3119 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.12.2.31 -r 1.12.2.32 src/action.c;  ) > 2.0.0cvs29.patchset
 ( cvs diff -u -r 1.382.2.236 -r 1.382.2.237 src/compose.c;  ) > 2.0.0cvs30.patchset
 ( cvs diff -u -r 1.12.2.22 -r 1.12.2.23 src/prefs_template.c;  ) > 2.0.0cvs31.patchset
+( cvs diff -u -r 1.382.2.237 -r 1.382.2.238 src/compose.c;  cvs diff -u -r 1.50.2.19 -r 1.50.2.20 src/compose.h;  ) > 2.0.0cvs32.patchset
index 5d3cd4b12674335a08498c509cd18b858da537a9..fa8a969c755bff588ad74c287459166598165ca3 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=31
+EXTRA_VERSION=32
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index bf6764762ffe28218bc51cd16a3d4b387fc66ef2..d4e3b147d9c01a67fe72b1e7da42799526b2d9b2 100644 (file)
 #include "folder.h"
 #include "addr_compl.h"
 #include "quote_fmt.h"
-#include "template.h"
 #include "undo.h"
 #include "foldersel.h"
 #include "toolbar.h"
@@ -6086,20 +6085,11 @@ static void compose_template_apply(Compose *compose, Template *tmpl,
        gint cursor_pos = 0;
        if (!tmpl) return;
 
+       /* process the body */
+
        text = GTK_TEXT_VIEW(compose->text);
        buffer = gtk_text_view_get_buffer(text);
 
-       if (tmpl->subject && *tmpl->subject != '\0')
-               gtk_entry_set_text(GTK_ENTRY(compose->subject_entry),
-                                  tmpl->subject);
-       if (tmpl->to && *tmpl->to != '\0')
-               compose_entry_append(compose, tmpl->to, COMPOSE_TO);
-       if (tmpl->cc && *tmpl->cc != '\0')
-               compose_entry_append(compose, tmpl->cc, COMPOSE_CC);
-
-       if (tmpl->bcc && *tmpl->bcc != '\0')
-               compose_entry_append(compose, tmpl->bcc, COMPOSE_BCC);
-
        if (replace)
                gtk_text_buffer_set_text(buffer, "", -1);
 
@@ -6144,9 +6134,79 @@ static void compose_template_apply(Compose *compose, Template *tmpl,
                gtk_text_buffer_place_cursor(buffer, &iter);
        }
 
+       /* process the other fields */
+       compose_template_apply_fields(compose, tmpl);
+       
        compose_changed_cb(NULL, compose);
 }
 
+void compose_template_apply_fields(Compose *compose, Template *tmpl)
+{
+       static MsgInfo dummyinfo;
+       MsgInfo *msginfo = NULL;
+       gchar *buf = NULL;
+
+       if (compose->replyinfo != NULL)
+               msginfo = compose->replyinfo;
+       else if (compose->fwdinfo != NULL)
+               msginfo = compose->fwdinfo;
+       else
+               msginfo = &dummyinfo;
+
+       if (tmpl->to && *tmpl->to != '\0') {
+               quote_fmt_init(msginfo, NULL, NULL, FALSE);
+               quote_fmt_scan_string(tmpl->to);
+               quote_fmt_parse();
+
+               buf = quote_fmt_get_buffer();
+               if (buf == NULL) {
+                       alertpanel_error(_("Message To format error."));
+               } else {
+                       compose_entry_append(compose, buf, COMPOSE_TO);
+               }
+       }
+
+       if (tmpl->cc && *tmpl->cc != '\0') {
+               quote_fmt_init(msginfo, NULL, NULL, FALSE);
+               quote_fmt_scan_string(tmpl->cc);
+               quote_fmt_parse();
+
+               buf = quote_fmt_get_buffer();
+               if (buf == NULL) {
+                       alertpanel_error(_("Message Cc format error."));
+               } else {
+                       compose_entry_append(compose, buf, COMPOSE_CC);
+               }
+       }
+
+       if (tmpl->bcc && *tmpl->bcc != '\0') {
+               quote_fmt_init(msginfo, NULL, NULL, FALSE);
+               quote_fmt_scan_string(tmpl->bcc);
+               quote_fmt_parse();
+
+               buf = quote_fmt_get_buffer();
+               if (buf == NULL) {
+                       alertpanel_error(_("Message Bcc format error."));
+               } else {
+                       compose_entry_append(compose, buf, COMPOSE_BCC);
+               }
+       }
+
+       /* process the subject */
+       if (tmpl->subject && *tmpl->subject != '\0') {
+               quote_fmt_init(msginfo, NULL, NULL, FALSE);
+               quote_fmt_scan_string(tmpl->subject);
+               quote_fmt_parse();
+
+               buf = quote_fmt_get_buffer();
+               if (buf == NULL) {
+                       alertpanel_error(_("Message subject format error."));
+               } else {
+                       gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf);
+               }
+       }
+}
+
 static void compose_destroy(Compose *compose)
 {
        compose_list = g_list_remove(compose_list, compose);
index 1996f4fcbefde4b3287039e4a8c3cbac01a365c5..83dbbe3db470f4072f7b541130d4402bd035f3ff 100644 (file)
@@ -35,6 +35,7 @@ typedef struct _AttachInfo    AttachInfo;
 #include "toolbar.h"
 #include "messageview.h"
 #include "codeconv.h"
+#include "template.h"
 
 #ifdef USE_ASPELL
 #include "gtkaspell.h"
@@ -273,6 +274,8 @@ void compose_reedit                 (MsgInfo        *msginfo);
 
 GList *compose_get_compose_list                (void);
 
+void compose_template_apply_fields(Compose *compose, Template *tmpl);
+
 void compose_entry_append              (Compose          *compose,
                                         const gchar      *address,
                                         ComposeEntryType  type);