sync with sylpheed 0.6.5cvs14
authorPaul Mangan <paul@claws-mail.org>
Fri, 23 Nov 2001 10:28:46 +0000 (10:28 +0000)
committerPaul Mangan <paul@claws-mail.org>
Fri, 23 Nov 2001 10:28:46 +0000 (10:28 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
src/compose.c
src/gtkutils.c
src/gtkutils.h
src/prefs_template.c
src/template.c
src/template.h

index 0e9a004..8e897fd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2001-11-23
+
+       * src/compose.c
+         src/gtkutils.[ch]: merged the new wrapping function.
+         gtkut_text_str_compare_n()
+         gtkut_text_str_compare()
+         gtkut_text_is_uri_string(): backport from the GtkSText in the
+         claws branch, and made modification.
+       * src/prefs_template.c
+         src/template.[ch]: added Subject to the template.
+
+2001-11-22
+
+       * src/compose.c: compose_write_headers(): added missing parenthesis
+         that generated invalid custom header (thanks to Masaaki Noro).
+         Allow Sender: custom header.
+
 2001-11-20
 
        * src/procheader.c: procheader_date_parse(): workaround for
index db5053e..2229283 100644 (file)
@@ -1,3 +1,12 @@
+2001-11-23 [paul]      0.6.5claws27
+
+       * sync with sylpheed 0.6.5cvs14
+               see ChangeLog entries 2001-11-22 and 2001-11-23
+                
+       * po/de.po
+               fixed the scrambled umlauts 
+                submitted by Carsten Schurig <Carsten.Schurig@web.de>
+
 2001-11-21 [paul]      0.6.5claws26
 
        * sync with sylpheed 0.6.5cvs12
index 52572c0..1fa890b 100644 (file)
@@ -1,3 +1,20 @@
+2001-11-23
+
+       * src/compose.c
+         src/gtkutils.[ch]: ¿·¤·¤¤¼«Æ°²þ¹Ôµ¡Ç½¤ò¥Þ¡¼¥¸¡£
+         gtkut_text_str_compare_n()
+         gtkut_text_str_compare()
+         gtkut_text_is_uri_string(): claws ¥Ö¥é¥ó¥Á¤Î GtkSText ¤«¤é
+         ¥Ð¥Ã¥¯¥Ý¡¼¥È¤·¡¢½¤Àµ¡£
+       * src/prefs_template.c
+         src/template.[ch]: ¥Æ¥ó¥×¥ì¡¼¥È¤Ë Subject ¤òÄɲá£
+
+2001-11-22
+
+       * src/compose.c: compose_write_headers(): ³ç¸Ì¤òÉÕ¤±Ëº¤ì¤Æ̵¸ú¤Ê
+         ¥«¥¹¥¿¥à¥Ø¥Ã¥À¤òÀ¸À®¤·¤Æ¤¤¤¿¤Î¤ò½¤Àµ(ÌîϤ¤µ¤ó thanks)¡£
+         Sender: ¥«¥¹¥¿¥à¥Ø¥Ã¥À¤òµö²Ä¡£
+
 2001-11-20
 
        * src/procheader.c: procheader_date_parse(): RFC Èó½àµò¤Î Date
index 1571bc5..62bb960 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=6
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws26
+EXTRA_VERSION=claws27
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
index cce6320..94ff078 100644 (file)
@@ -134,6 +134,8 @@ static void compose_toolbar_create          (Compose        *compose,
 static GtkWidget *compose_account_option_menu_create
                                                (Compose        *compose);
 static void compose_set_template_menu          (Compose        *compose);
+static void compose_template_apply             (Compose        *compose,
+                                                Template       *tmpl);
 static void compose_destroy                    (Compose        *compose);
 
 static void compose_entries_set                        (Compose        *compose,
@@ -743,9 +745,8 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
        gtk_editable_set_position(GTK_EDITABLE(text), 0);
        gtk_stext_set_point(text, 0);
 
-       if (quote && prefs_common.linewrap_quote) {
+       if (quote && prefs_common.linewrap_quote)
                compose_wrap_line_all(compose);
-       }
 
        gtk_stext_thaw(text);
        gtk_widget_grab_focus(compose->text);
@@ -2065,11 +2066,11 @@ compose_end:
 }
 
 /* return indent length */
-static guint get_indent_length(GtkSText *text, guint start_pos,
-                              guint text_len) {
+static guint get_indent_length(GtkSText *text, guint start_pos, guint text_len)
+{
        gint indent_len = 0;
        gint i, ch_len;
-       gchar cbuf[MB_CUR_MAX];
+       gchar cbuf[MB_LEN_MAX];
 
        for (i = start_pos; i < text_len; i++) {
                if (text->use_wchar)
@@ -2091,11 +2092,11 @@ static guint get_indent_length(GtkSText *text, guint start_pos,
        return indent_len;
 }
 
-/* insert quotation string when line was wrapped, we know these
-   are single byte characters */
+/* insert quotation string when line was wrapped */
 static guint ins_quote(GtkSText *text, guint quote_len, guint indent_len,
                       guint prev_line_pos, guint text_len,
-                      gchar *quote_fmt) {
+                      gchar *quote_fmt)
+{
        guint i, ins_len;
        gchar ch;
 
@@ -2119,18 +2120,17 @@ static guint ins_quote(GtkSText *text, guint quote_len, guint indent_len,
 /* Darko: used when I debug wrapping */
 void dump_text(GtkSText *text, int pos, int tlen, int breakoncr)
 {
-    int i;
-    char ch;
+       int i;
+       char ch;
 
-    printf("%d [", pos);
-    for (i = pos; i < tlen; i++)
-    {
-        ch = GTK_STEXT_INDEX(text, i);
-        if (breakoncr && ch == '\n')
-            break;
-        printf("%c", ch);
-    }
-    printf("]\n");
+       printf("%d [", pos);
+       for (i = pos; i < tlen; i++) {
+               ch = GTK_STEXT_INDEX(text, i);
+               if (breakoncr && ch == '\n')
+                       break;
+               printf("%c", ch);
+       }
+       printf("]\n");
 }
 #endif
 
@@ -2151,18 +2151,18 @@ static void compose_wrap_line_all(Compose *compose)
        gtk_stext_freeze(text);
 
        /* make text buffer contiguous */
-       gtk_stext_compact_buffer(text);
+       /* gtk_stext_compact_buffer(text); */
 
        tlen = gtk_stext_get_length(text);
 
        for (; cur_pos < tlen; cur_pos++) {
                /* mark position of new line - needed for quotation wrap */
                if (linewrap_quote && is_new_line) {
-                       qlen = gtkstext_str_strcmp(text, cur_pos, tlen, qfmt);
+                       qlen = gtkut_text_str_compare
+                               (text, cur_pos, tlen, qfmt);
                        is_new_line = 0;
-                       if (qlen) {
+                       if (qlen)
                                i_len = get_indent_length(text, cur_pos, tlen);
-                       }
                        else
                                i_len = 0;
                        p_pos = cur_pos;
@@ -2211,8 +2211,8 @@ static void compose_wrap_line_all(Compose *compose)
                        /* if it's just quotation + newline skip it */
                        if (i_len && (cur_pos + 1 < tlen)) {
                                /* check if text at new line matches indent */
-                               ilen =  gtkstext_strncmp(text, cur_pos + 1,
-                                                        p_pos, i_len, tlen);
+                               ilen =  gtkut_text_str_compare_n
+                                       (text, cur_pos + 1, p_pos, i_len, tlen);
                                if (cur_pos + ilen < tlen) {
                                        if (text->use_wchar)
                                                clen = wctomb(cb, (wchar_t)GTK_STEXT_INDEX(text, cur_pos + ilen + 1));
@@ -2241,20 +2241,19 @@ static void compose_wrap_line_all(Compose *compose)
                                /* if text starts with quote fmt or with
                                   indent string, delete them */
                                if (i_len) {
-                                       ilen =  gtkstext_strncmp(text, cur_pos,
-                                                                p_pos, i_len,
-                                                                tlen);
+                                       ilen =  gtkut_text_str_compare_n
+                                               (text, cur_pos, p_pos, i_len,
+                                                tlen);
                                        if (ilen) {
                                                gtk_stext_forward_delete(text,
                                                                         ilen);
                                                tlen -= ilen;
                                        }
-                               }
-                               else if (qlen) {
-                                       if (gtkstext_str_strcmp(text, cur_pos,
-                                                               tlen, qfmt)) {
-                                               gtk_stext_forward_delete(text,
-                                                                qlen);
+                               } else if (qlen) {
+                                       if (gtkut_text_str_compare
+                                           (text, cur_pos, tlen, qfmt)) {
+                                               gtk_stext_forward_delete
+                                                       (text, qlen);
                                                tlen -= qlen;
                                        }
                                }
@@ -2271,8 +2270,8 @@ static void compose_wrap_line_all(Compose *compose)
                                if ((cur_pos != line_pos) &&
                                    ((clen > 1) || isalnum(cb[0]))) {
                                        gtk_stext_insert(text, NULL, NULL,
-                                                        NULL, " ", 1);
-                                       gtk_stext_compact_buffer(text);
+                                                       NULL, " ", 1);
+                                       /* gtk_text_compact_buffer(text); */
                                        tlen++;
                                }
 
@@ -2321,7 +2320,8 @@ static void compose_wrap_line_all(Compose *compose)
 #endif
                        /* force wrapping if it is one long word but not URL */
                        if (p_pos + i_len == line_pos)
-                               if (!is_url_string(text, line_pos, tlen))
+                               if (!gtkut_text_is_uri_string
+                                   (text, line_pos, tlen))
                                        line_pos = cur_pos - 1;
 #ifdef WRAP_DEBUG
                        printf("new line_pos=%d\n", line_pos);
@@ -2336,7 +2336,8 @@ static void compose_wrap_line_all(Compose *compose)
                        }
                         if (clen == 1 && isspace(*cbuf)) {
                                if (p_pos + i_len != line_pos ||
-                                   !is_url_string(text, line_pos, tlen)) {
+                                   !gtkut_text_is_uri_string
+                                       (text, line_pos, tlen)) {
                                        gtk_stext_set_point(text, line_pos);
                                        gtk_stext_backward_delete(text, 1);
                                        tlen--;
@@ -2349,7 +2350,7 @@ static void compose_wrap_line_all(Compose *compose)
 
                        /* if it is URL at beginning of line don't wrap */
                        if (p_pos + i_len == line_pos &&
-                            is_url_string(text, line_pos, tlen)) {
+                           gtkut_text_is_uri_string(text, line_pos, tlen)) {
 #ifdef WRAP_DEBUG
                                printf("found URL at ");
                                dump_text(text, line_pos, tlen, 1);
@@ -2360,7 +2361,7 @@ static void compose_wrap_line_all(Compose *compose)
                        /* insert CR */
                        gtk_stext_set_point(text, line_pos);
                        gtk_stext_insert(text, NULL, NULL, NULL, "\n", 1);
-                       gtk_stext_compact_buffer(text);
+                       /* gtk_stext_compact_buffer(text); */
                        tlen++;
                        cur_pos++;
                        line_pos++;
@@ -2374,19 +2375,16 @@ static void compose_wrap_line_all(Compose *compose)
                        /* should we insert quotation ? */
                        if (linewrap_quote && qlen) {
                                /* only if line is not already quoted  */
-                               if (!gtkstext_str_strcmp(text, line_pos,
-                                                        tlen, qfmt)) {
+                               if (!gtkut_text_str_compare
+                                       (text, line_pos, tlen, qfmt)) {
                                        guint ins_len;
 
                                        if (line_pos - p_pos > i_len) {
-                                               ins_len = ins_quote(text,
-                                                                   qlen,
-                                                                   i_len,
-                                                                   p_pos,
-                                                                   tlen,
-                                                                   qfmt);
-
-                                               gtk_stext_compact_buffer(text);
+                                               ins_len = ins_quote
+                                                       (text, qlen, i_len,
+                                                        p_pos, tlen, qfmt);
+
+                                               /* gtk_stext_compact_buffer(text); */
                                                tlen += ins_len;
                                        }
 
@@ -2417,6 +2415,86 @@ static void compose_wrap_line_all(Compose *compose)
        gtk_stext_thaw(text);
 }
 
+#if 0
+static void compose_wrap_line_all(Compose *compose)
+{
+       GtkText *text = GTK_STEXT(compose->text);
+       guint text_len;
+       guint line_pos = 0, cur_pos = 0;
+       gint line_len = 0, cur_len = 0;
+       gint ch_len;
+       gchar cbuf[MB_LEN_MAX];
+
+       gtk_stext_freeze(text);
+
+       text_len = gtk_stext_get_length(text);
+
+       for (; cur_pos < text_len; cur_pos++) {
+               if (text->use_wchar)
+                       ch_len = wctomb
+                               (cbuf, (wchar_t)GTK_STEXT_INDEX(text, cur_pos));
+               else {
+                       cbuf[0] = GTK_STEXT_INDEX(text, cur_pos);
+                       ch_len = 1;
+               }
+
+               if (ch_len == 1 && *cbuf == '\n') {
+                       line_pos = cur_pos + 1;
+                       line_len = cur_len = 0;
+                       continue;
+               }
+
+               if (ch_len < 0) {
+                       cbuf[0] = '\0';
+                       ch_len = 1;
+               }
+
+               if (ch_len == 1 && isspace(*cbuf)) {
+                       line_pos = cur_pos + 1;
+                       line_len = cur_len + ch_len;
+               }
+
+               if (cur_len + ch_len > prefs_common.linewrap_len &&
+                   line_len > 0) {
+                       gint tlen;
+
+                       if (text->use_wchar)
+                               tlen = wctomb(cbuf, (wchar_t)GTK_STEXT_INDEX(text, line_pos - 1));
+                       else {
+                               cbuf[0] = GTK_STEXT_INDEX(text, line_pos - 1);
+                               tlen = 1;
+                       }
+                       if (tlen == 1 && isspace(*cbuf)) {
+                               gtk_stext_set_point(text, line_pos);
+                               gtk_stext_backward_delete(text, 1);
+                               text_len--;
+                               cur_pos--;
+                               line_pos--;
+                               cur_len--;
+                               line_len--;
+                       }
+
+                       gtk_stext_set_point(text, line_pos);
+                       gtk_stext_insert(text, NULL, NULL, NULL, "\n", 1);
+                       text_len++;
+                       cur_pos++;
+                       line_pos++;
+                       cur_len = cur_len - line_len + ch_len;
+                       line_len = 0;
+                       continue;
+               }
+
+               if (ch_len > 1) {
+                       line_pos = cur_pos + 1;
+                       line_len = cur_len + ch_len;
+               }
+               cur_len += ch_len;
+       }
+
+       gtk_stext_thaw(text);
+}
+#endif
+
 static void compose_set_title(Compose *compose)
 {
        gchar *str;
@@ -3528,21 +3606,23 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
                     cur = cur->next) {
                        CustomHeader *chdr = (CustomHeader *)cur->data;
 
-                       if (strcasecmp(chdr->name, "Date")                      != 0 &&
-                           strcasecmp(chdr->name, "From")                      != 0 &&
-                           strcasecmp(chdr->name, "To")                        != 0 &&
-                           strcasecmp(chdr->name, "Sender")                    != 0 &&
-                           strcasecmp(chdr->name, "Message-Id")                != 0 &&
-                           strcasecmp(chdr->name, "In-Reply-To")               != 0 &&
-                           strcasecmp(chdr->name, "References")                != 0 &&
-                           strcasecmp(chdr->name, "Mime-Version")              != 0 &&
-                           strcasecmp(chdr->name, "Content-Type")              != 0 &&
-                           strcasecmp(chdr->name, "Content-Transfer-Encoding") != 0)
+                       if (strcasecmp(chdr->name, "Date")         != 0 &&
+                           strcasecmp(chdr->name, "From")         != 0 &&
+                           strcasecmp(chdr->name, "To")           != 0 &&
+                        /* strcasecmp(chdr->name, "Sender")       != 0 && */
+                           strcasecmp(chdr->name, "Message-Id")   != 0 &&
+                           strcasecmp(chdr->name, "In-Reply-To")  != 0 &&
+                           strcasecmp(chdr->name, "References")   != 0 &&
+                           strcasecmp(chdr->name, "Mime-Version") != 0 &&
+                           strcasecmp(chdr->name, "Content-Type") != 0 &&
+                           strcasecmp(chdr->name, "Content-Transfer-Encoding")
+                           != 0) {
                                compose_convert_header
                                        (buf, sizeof(buf),
                                         chdr->value ? chdr->value : "",
                                         strlen(chdr->name) + 2);
-                       fprintf(fp, "%s: %s\n", chdr->name, buf);
+                               fprintf(fp, "%s: %s\n", chdr->name, buf);
+                       }
                }
        }
 
@@ -4557,29 +4637,33 @@ void compose_reflect_prefs_all(void)
        }
 }
 
-static void compose_template_apply(Compose *compose, const gchar *tmpl_str)
+static void compose_template_apply(Compose *compose, Template *tmpl)
 {
        gchar *qmark;
        gchar *parsed_str;
 
-       if (!tmpl_str) return;
+       if (!tmpl || !tmpl->value) return;
 
        gtk_stext_freeze(GTK_STEXT(compose->text));
+        
+       if (tmpl->subject)
+               gtk_entry_set_text(GTK_ENTRY(compose->subject_entry),
+                                  tmpl->subject);
 
        if (compose->replyinfo == NULL) {
                MsgInfo dummyinfo;
 
                memset(&dummyinfo, 0, sizeof(MsgInfo));
-               parsed_str = compose_quote_fmt(compose, &dummyinfo, tmpl_str,
-                                              NULL);
+               parsed_str = compose_quote_fmt(compose, &dummyinfo,
+                                              tmpl->value, NULL);
        } else {
                if (prefs_common.quotemark && *prefs_common.quotemark)
                        qmark = prefs_common.quotemark;
                else
                        qmark = "> ";
 
-               parsed_str = compose_quote_fmt(compose, compose->replyinfo, tmpl_str,
-                                              qmark);
+               parsed_str = compose_quote_fmt(compose, compose->replyinfo,
+                                              tmpl->value, qmark);
        }
 
        if (parsed_str && prefs_common.auto_sig)
@@ -5566,7 +5650,7 @@ static void compose_template_activate_cb(GtkWidget *widget, gpointer data)
        tmpl = gtk_object_get_data(GTK_OBJECT(widget), "template");
        g_return_if_fail(tmpl != NULL);
 
-       compose_template_apply(compose, tmpl->value);
+       compose_template_apply(compose, tmpl);
 }
 
 static void compose_ext_editor_cb(gpointer data, guint action,
index c102551..9c0d01a 100644 (file)
@@ -270,6 +270,57 @@ gboolean gtkut_text_match_string(GtkText *text, gint pos, wchar_t *wcs,
                return FALSE;
 }
 
+guint gtkut_text_str_compare_n(GtkText *text, guint pos1, guint pos2,
+                              guint len, guint text_len)
+{
+       guint i;
+       GdkWChar ch1, ch2;
+
+       for (i = 0; i < len && pos1 + i < text_len && pos2 + i < text_len; i++) {
+               ch1 = GTK_TEXT_INDEX(text, pos1 + i);
+               ch2 = GTK_TEXT_INDEX(text, pos2 + i);
+               if (ch1 != ch2)
+                       break;
+       }
+
+       return i;
+}
+
+guint gtkut_text_str_compare(GtkText *text, guint start_pos, guint text_len,
+                            const gchar *str)
+{
+       wchar_t *wcs;
+       guint len;
+       gboolean result;
+
+       if (!str) return 0;
+
+       wcs = strdup_mbstowcs(str);
+       if (!wcs) return 0;
+       len = wcslen(wcs);
+
+       if (len > text_len - start_pos)
+               result = FALSE;
+       else
+               result = gtkut_text_match_string(text, start_pos, wcs, len,
+                                                TRUE);
+
+       g_free(wcs);
+
+       return result ? len : 0;
+}
+
+gboolean gtkut_text_is_uri_string(GtkText *text,
+                                 guint start_pos, guint text_len)
+{
+       if (gtkut_text_str_compare(text, start_pos, text_len, "http://") ||
+           gtkut_text_str_compare(text, start_pos, text_len, "ftp://")  ||
+           gtkut_text_str_compare(text, start_pos, text_len, "https://"))
+               return TRUE;
+
+       return FALSE;
+}
+
 void gtkut_widget_disable_theme_engine(GtkWidget *widget)
 {
        GtkStyle *style, *new_style;
index aa6366b..4f6f1b6 100644 (file)
@@ -105,6 +105,18 @@ gboolean gtkut_text_match_string   (GtkText        *text,
                                         wchar_t        *wcs,
                                         gint            len,
                                         gboolean        case_sens);
+guint gtkut_text_str_compare_n         (GtkText        *text,
+                                        guint           pos1,
+                                        guint           pos2,
+                                        guint           len,
+                                        guint           text_len);
+guint gtkut_text_str_compare           (GtkText        *text,
+                                        guint           start_pos,
+                                        guint           text_len,
+                                        const gchar    *str);
+gboolean gtkut_text_is_uri_string      (GtkText        *text,
+                                        guint           start_pos,
+                                        guint           text_len);
 
 void gtkut_widget_disable_theme_engine (GtkWidget      *widget);
 void gtkut_widget_wait_for_draw                (GtkWidget      *widget);
index 739389a..a6da3df 100644 (file)
@@ -42,6 +42,7 @@ static struct Templates {
        GtkWidget *ok_btn;
        GtkWidget *clist_tmpls;
        GtkWidget *entry_name;
+       GtkWidget *entry_subject;
        GtkWidget *text_value;
 } templates;
 
@@ -90,6 +91,7 @@ static void prefs_template_window_create(void)
        GtkWidget       *hbox1;
        GtkWidget         *label1;
        GtkWidget         *entry_name;
+       GtkWidget         *entry_subject;
        GtkWidget       *scroll2;
        GtkWidget         *text_value;
        GtkWidget     *vbox2;
@@ -142,6 +144,22 @@ static void prefs_template_window_create(void)
        gtk_widget_show(entry_name);
        gtk_box_pack_start(GTK_BOX(hbox1), entry_name, TRUE, TRUE, 0);
 
+       /* hbox for a label and subject entry */
+       hbox1 = gtk_hbox_new(FALSE, 8);
+       gtk_widget_show(hbox1);
+       gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, FALSE, 0);
+       gtk_container_set_border_width(GTK_CONTAINER(hbox1), 2);
+
+       /* self-documenting */
+       label1 = gtk_label_new(_("Subject"));
+       gtk_widget_show(label1);
+       gtk_box_pack_start(GTK_BOX(hbox1), label1, FALSE, FALSE, 0);
+
+       /* holds subject */
+       entry_subject = gtk_entry_new();
+       gtk_widget_show(entry_subject);
+       gtk_box_pack_start(GTK_BOX(hbox1), entry_subject, TRUE, TRUE, 0);
+
        /* template content */
        scroll2 = gtk_scrolled_window_new(NULL, NULL);
        gtk_widget_show(scroll2);
@@ -249,6 +267,7 @@ static void prefs_template_window_create(void)
        templates.ok_btn = ok_btn;
        templates.clist_tmpls = clist_tmpls;
        templates.entry_name = entry_name;
+       templates.entry_subject = entry_subject;
        templates.text_value = text_value;
 }
 
@@ -339,12 +358,15 @@ static void prefs_template_select_cb(GtkCList *clist, gint row, gint column,
        Template tmpl_def;
 
        tmpl_def.name = _("Template");
+       tmpl_def.subject = "";
        tmpl_def.value = "";
 
        if (!(tmpl = gtk_clist_get_row_data(clist, row)))
                tmpl = &tmpl_def;
 
        gtk_entry_set_text(GTK_ENTRY(templates.entry_name), tmpl->name);
+       gtk_entry_set_text(GTK_ENTRY(templates.entry_subject),
+                          tmpl->subject ? tmpl->subject : "");
        
        gtk_text_freeze(GTK_TEXT(templates.text_value));
        gtk_text_set_point(GTK_TEXT(templates.text_value), 0);
@@ -377,6 +399,7 @@ static gint prefs_template_clist_set_row(gint row)
        Template *tmpl;
        Template *tmp_tmpl;
        gchar *name;
+       gchar *subject;
        gchar *value;
        gchar *title[1];
 
@@ -384,11 +407,14 @@ static gint prefs_template_clist_set_row(gint row)
 
        name = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_name),
                                      0, -1);
+       subject = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_subject),
+                                     0, -1);
        value = gtk_editable_get_chars(GTK_EDITABLE(templates.text_value),
                                       0, -1);
 
        tmpl = g_new(Template, 1);
        tmpl->name = name;
+       tmpl->subject = subject;
        tmpl->value = value;
 
        title[0] = name;
index 1bc5ace..8072181 100644 (file)
@@ -49,25 +49,28 @@ static Template *template_load(gchar *filename)
 
        tmpl = g_new(Template, 1);
        tmpl->name = NULL;
+       tmpl->subject = NULL;
+       tmpl->value = NULL;
 
        while (fgets(buf, sizeof(buf), fp) != NULL) {
                if (buf[0] == '\n')
                        break;
                else if (!g_strncasecmp(buf, "Name:", 5))
                        tmpl->name = g_strdup(g_strstrip(buf + 5));
+               else if (!g_strncasecmp(buf, "Subject:", 8))
+                       tmpl->subject = g_strdup(g_strstrip(buf + 8));
        }
 
        if (!tmpl->name) {
                g_warning("wrong template format\n");
-               g_free(tmpl);
+               template_free(tmpl);
                return NULL;
        }
 
        if ((bytes_read = fread(buf, 1, sizeof(buf), fp)) == 0) {
                if (ferror(fp)) {
                        FILE_OP_ERROR(filename, "fread");
-                       g_free(tmpl->name);
-                       g_free(tmpl);
+                       template_free(tmpl);
                        return NULL;
                }
        }
@@ -80,6 +83,7 @@ static Template *template_load(gchar *filename)
 void template_free(Template *tmpl)
 {
        g_free(tmpl->name);
+       g_free(tmpl->subject);
        g_free(tmpl->value);
        g_free(tmpl);
 }
@@ -186,6 +190,8 @@ void template_write_config(GSList *tmpl_list)
                debug_print(_("%s:%d writing template \"%s\" to %s\n"),
                            __FILE__, __LINE__, tmpl->name, filename);
                fprintf(fp, "Name: %s\n", tmpl->name);
+               if (tmpl->subject)
+                       fprintf(fp, "Subject: %s\n", tmpl->subject);
                fputs("\n", fp);
                fwrite(tmpl->value, sizeof(gchar) * strlen(tmpl->value), 1,
                       fp);
index 2d23979..b6aae98 100644 (file)
@@ -26,6 +26,7 @@ typedef struct _Template      Template;
 
 struct _Template {
        gchar *name;
+       gchar *subject;
        gchar *value;
 };