2007-05-30 [wwp] 2.9.2cvs19
authorTristan Chabredier <wwp@claws-mail.org>
Wed, 30 May 2007 22:17:38 +0000 (22:17 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Wed, 30 May 2007 22:17:38 +0000 (22:17 +0000)
* src/prefs_compose_writing.c
* src/prefs_quote.c
* src/procheader.c
* src/quote_fmt.c
* src/quote_fmt.h
Internal API changes (factorize quote format
prefs and checks).

ChangeLog
PATCHSETS
configure.ac
src/prefs_compose_writing.c
src/prefs_quote.c
src/procheader.c
src/quote_fmt.c
src/quote_fmt.h

index d3fed09..c69ce23 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-05-30 [wwp]       2.9.2cvs19
+
+       * src/prefs_compose_writing.c
+       * src/prefs_quote.c
+       * src/procheader.c
+       * src/quote_fmt.c
+       * src/quote_fmt.h
+               Internal API changes (factorize quote format
+               prefs and checks).
+
 2007-05-30 [colin]     2.9.2cvs18
 
        * src/compose.c
index c86a34b..9df5bc8 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.179.2.174 -r 1.179.2.175 src/imap.c;  ) > 2.9.2cvs16.patchset
 ( 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
index 9826885..02b877f 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=18
+EXTRA_VERSION=19
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index d3b44cc..3248a58 100644 (file)
@@ -105,17 +105,6 @@ static void prefs_compose_writing_create_widget(PrefsPage *_page, GtkWindow *win
        GtkWidget *menu;
        GtkWidget *menuitem;
 
-       GtkWidget *frame_format;
-       GtkWidget *checkbtn_compose_with_format;
-       GtkWidget *vbox_format;
-       GtkWidget *hbox_format;
-       GtkWidget *label_subject;
-       GtkWidget *entry_subject;
-       GtkWidget *scrolledwin_format;
-       GtkWidget *text_format;
-       GtkWidget *hbox_formatdesc;
-       GtkWidget *btn_formatdesc;
-
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
@@ -212,66 +201,14 @@ static void prefs_compose_writing_create_widget(PrefsPage *_page, GtkWindow *win
        SET_TOGGLE_SENSITIVITY (checkbtn_autosave, spinbtn_autosave_length);
        SET_TOGGLE_SENSITIVITY (checkbtn_autosave, label_autosave_length);
 
-       PACK_CHECK_BUTTON (vbox1, checkbtn_compose_with_format, 
-                          _("Use format when composing new messages"));
-
-       vbox_format = gtkut_get_options_frame(vbox1, &frame_format, _("New message format"));
-
-       hbox_format = gtk_hbox_new (FALSE, 8);
-       gtk_widget_show (hbox_format);
-       gtk_box_pack_start (GTK_BOX (vbox_format), hbox_format, FALSE, FALSE, 0);
-
-       label_subject = gtk_label_new (_("Subject"));
-       gtk_widget_show (label_subject);
-       gtk_box_pack_start (GTK_BOX (hbox_format), label_subject, FALSE, FALSE, 0);
-
-       entry_subject = gtk_entry_new ();
-       gtk_widget_show (entry_subject);
-       gtk_box_pack_start (GTK_BOX (hbox_format), entry_subject, TRUE, TRUE, 0);
-       gtk_widget_set_size_request (entry_subject, 100, -1);
-
-       scrolledwin_format = gtk_scrolled_window_new (NULL, NULL);
-       gtk_widget_show (scrolledwin_format);
-       gtk_box_pack_start (GTK_BOX (vbox_format), scrolledwin_format,
-                           TRUE, TRUE, 0);
-       gtk_scrolled_window_set_policy
-               (GTK_SCROLLED_WINDOW (scrolledwin_format),
-                GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-       gtk_scrolled_window_set_shadow_type
-               (GTK_SCROLLED_WINDOW (scrolledwin_format), GTK_SHADOW_IN);
-
-       text_format = gtk_text_view_new ();
-       if (prefs_common.textfont) {
-               PangoFontDescription *font_desc;
-
-               font_desc = pango_font_description_from_string
-                                               (prefs_common.textfont);
-               if (font_desc) {
-                       gtk_widget_modify_font(text_format, font_desc);
-                       pango_font_description_free(font_desc);
-               }
-       }
-       gtk_widget_show (text_format);
-       gtk_container_add(GTK_CONTAINER(scrolledwin_format), text_format);
-       gtk_text_view_set_editable (GTK_TEXT_VIEW (text_format), TRUE);
-       gtk_widget_set_size_request(text_format, -1, 100);
-
-       hbox_formatdesc = gtk_hbox_new (FALSE, 32);
-       gtk_widget_show (hbox_formatdesc);
-       gtk_box_pack_start (GTK_BOX (vbox_format), hbox_formatdesc, FALSE, FALSE, 0);
-
-#if GTK_CHECK_VERSION(2, 8, 0)
-       btn_formatdesc = gtk_button_new_from_stock(GTK_STOCK_INFO);
-#else
-       btn_formatdesc =
-               gtk_button_new_with_label (_(" Description of symbols... "));
-#endif
-       gtk_widget_show (btn_formatdesc);
-       gtk_box_pack_start (GTK_BOX (hbox_formatdesc), btn_formatdesc, FALSE, FALSE, 0);
-       g_signal_connect(G_OBJECT(btn_formatdesc), "clicked",
-                        G_CALLBACK(quote_fmt_quote_description), GTK_WIDGET(window));
-
-       SET_TOGGLE_SENSITIVITY(checkbtn_compose_with_format, frame_format);
+       quotefmt_create_new_msg_fmt_widgets(
+                               window,
+                               vbox1,
+                               &prefs_writing->checkbtn_compose_with_format,
+                               _("New message format"),
+                               &prefs_writing->entry_subject,
+                               &prefs_writing->text_format,
+                               TRUE);
 
        prefs_writing->checkbtn_autoextedit = checkbtn_autoextedit;
 
@@ -292,11 +229,6 @@ static void prefs_compose_writing_create_widget(PrefsPage *_page, GtkWindow *win
 
        prefs_writing->optmenu_dnd_insert_or_attach = optmenu_dnd_insert_or_attach;
 
-       prefs_writing->checkbtn_compose_with_format
-                                                                = checkbtn_compose_with_format;
-       prefs_writing->entry_subject = entry_subject;
-       prefs_writing->text_format       = text_format;
-
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_autoextedit),
                prefs_common.auto_exteditor);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_writing->checkbtn_forward_as_attachment),
@@ -332,7 +264,6 @@ static void prefs_compose_writing_save(PrefsPage *_page)
 {
        GtkWidget *menu;
        GtkWidget *menuitem;
-       gint line = -1;
 
        WritingPage *page = (WritingPage *) _page;
        prefs_common.auto_exteditor = 
@@ -366,15 +297,11 @@ static void prefs_compose_writing_save(PrefsPage *_page)
                gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_compose_with_format));
        prefs_common.compose_subject_format = pref_get_pref_from_entry(
                        GTK_ENTRY(page->entry_subject));
-       if (!prefs_template_string_is_valid(prefs_common.compose_subject_format, NULL))
-               alertpanel_error(_("New message subject format error."));
        prefs_common.compose_body_format = pref_get_pref_from_textview(
                        GTK_TEXT_VIEW(page->text_format));
-       if (!prefs_template_string_is_valid(prefs_common.compose_body_format, &line)) {
-               gchar *msg = g_strdup_printf(_("New message body format error at line %d."), line);
-               alertpanel_error(msg);
-               g_free(msg);
-       }
+       quotefmt_check_new_msg_formats(prefs_common.compose_with_format,
+                                                                       prefs_common.compose_subject_format,
+                                                                       prefs_common.compose_body_format);
 }
 
 static void prefs_compose_writing_destroy_widget(PrefsPage *_page)
index 568216a..e11557e 100644 (file)
@@ -68,147 +68,43 @@ static void prefs_quote_create_widget(PrefsPage *_page, GtkWindow *window,
        GtkWidget *vbox_quote;
        GtkWidget *hbox1;
        GtkWidget *hbox2;
-       GtkWidget *label_quotemark;
-       GtkWidget *entry_quotemark;
-       GtkWidget *scrolledwin_quotefmt;
-       GtkWidget *text_quotefmt;
-
-       GtkWidget *entry_fw_quotemark;
-       GtkWidget *text_fw_quotefmt;
 
        GtkWidget *entry_quote_chars;
        GtkWidget *label_quote_chars;
        
-       GtkWidget *btn_quotedesc;
-
        GtkWidget *checkbtn_reply_with_quote;
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
 
-       /* reply */
-
        PACK_CHECK_BUTTON (vbox1, checkbtn_reply_with_quote, _("Reply will quote by default"));
 
-       PACK_FRAME (vbox1, frame_quote, _("Reply format"));
-
-       vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
-       gtk_widget_show (vbox_quote);
-       gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
-       gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
-
-       hbox1 = gtk_hbox_new (FALSE, 32);
-       gtk_widget_show (hbox1);
-       gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
-
-       hbox2 = gtk_hbox_new (FALSE, 8);
-       gtk_widget_show (hbox2);
-       gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
+       /* reply */
 
-       label_quotemark = gtk_label_new (_("Quotation mark"));
-       gtk_widget_show (label_quotemark);
-       gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
-
-       entry_quotemark = gtk_entry_new ();
-       gtk_widget_show (entry_quotemark);
-       gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
-       gtk_widget_set_size_request (entry_quotemark, 64, -1);
-
-       scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
-       gtk_widget_show (scrolledwin_quotefmt);
-       gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
-                           TRUE, TRUE, 0);
-       gtk_scrolled_window_set_policy
-               (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
-                GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-       gtk_scrolled_window_set_shadow_type
-               (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
-
-       text_quotefmt = gtk_text_view_new ();
-       if (prefs_common.textfont) {
-               PangoFontDescription *font_desc;
-
-               font_desc = pango_font_description_from_string
-                                               (prefs_common.textfont);
-               if (font_desc) {
-                       gtk_widget_modify_font(text_quotefmt, font_desc);
-                       pango_font_description_free(font_desc);
-               }
-       }
-       gtk_widget_show (text_quotefmt);
-       gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
-       gtk_text_view_set_editable (GTK_TEXT_VIEW (text_quotefmt), TRUE);
-       gtk_widget_set_size_request(text_quotefmt, -1, 100);
+       quotefmt_create_reply_fmt_widgets(
+                               window,
+                               vbox1,
+                               NULL,
+                               NULL,
+                               &prefs_quote->entry_quotemark,
+                               &prefs_quote->text_quotefmt,
+                               FALSE);
 
        /* forward */
 
-       PACK_FRAME (vbox1, frame_quote, _("Forward format"));
+       quotefmt_create_forward_fmt_widgets(
+                               window,
+                               vbox1,
+                               NULL,
+                               NULL,
+                               &prefs_quote->entry_fw_quotemark,
+                               &prefs_quote->text_fw_quotefmt,
+                               FALSE);
 
-       vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
-       gtk_widget_show (vbox_quote);
-       gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
-       gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
-
-       hbox1 = gtk_hbox_new (FALSE, 32);
-       gtk_widget_show (hbox1);
-       gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
-
-       hbox2 = gtk_hbox_new (FALSE, 8);
-       gtk_widget_show (hbox2);
-       gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
+       /* info button */
 
-       label_quotemark = gtk_label_new (_("Quotation mark"));
-       gtk_widget_show (label_quotemark);
-       gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
-
-       entry_fw_quotemark = gtk_entry_new ();
-       gtk_widget_show (entry_fw_quotemark);
-       gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
-                           FALSE, FALSE, 0);
-       gtk_widget_set_size_request (entry_fw_quotemark, 64, -1);
-
-       scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
-       gtk_widget_show (scrolledwin_quotefmt);
-       gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
-                           TRUE, TRUE, 0);
-       gtk_scrolled_window_set_policy
-               (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
-                GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-       gtk_scrolled_window_set_shadow_type
-               (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
-
-       text_fw_quotefmt = gtk_text_view_new ();
-       if (prefs_common.textfont) {
-               PangoFontDescription *font_desc;
-
-               font_desc = pango_font_description_from_string
-                                               (prefs_common.textfont);
-               if (font_desc) {
-                       gtk_widget_modify_font(text_fw_quotefmt, font_desc);
-                       pango_font_description_free(font_desc);
-               }
-       }
-       gtk_widget_show (text_fw_quotefmt);
-       gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
-                         text_fw_quotefmt);
-       gtk_text_view_set_editable (GTK_TEXT_VIEW (text_fw_quotefmt), TRUE);
-       gtk_widget_set_size_request (text_fw_quotefmt, -1, 100);
-
-       hbox1 = gtk_hbox_new (FALSE, 32);
-       gtk_widget_show (hbox1);
-       gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
-
-#if GTK_CHECK_VERSION(2, 8, 0)
-       btn_quotedesc = gtk_button_new_from_stock(GTK_STOCK_INFO);
-#else
-       btn_quotedesc =
-               gtk_button_new_with_label (_(" Description of symbols... "));
-#endif
-       gtk_widget_show (btn_quotedesc);
-       gtk_box_pack_start (GTK_BOX (hbox1), btn_quotedesc, FALSE, FALSE, 0);
-       g_signal_connect(G_OBJECT(btn_quotedesc), "clicked",
-                        G_CALLBACK(quote_fmt_quote_description), GTK_WIDGET(window));
+       quotefmt_add_info_button(window, vbox1);
 
        /* quote chars */
 
@@ -237,23 +133,22 @@ static void prefs_quote_create_widget(PrefsPage *_page, GtkWindow *window,
                            FALSE, FALSE, 0);
        gtk_widget_set_size_request (entry_quote_chars, 64, -1);
 
-       pref_set_textview_from_pref(GTK_TEXT_VIEW(text_quotefmt), prefs_common.quotefmt);
-       pref_set_textview_from_pref(GTK_TEXT_VIEW(text_fw_quotefmt), prefs_common.fw_quotefmt);
-
-       gtk_entry_set_text(GTK_ENTRY(entry_quotemark), 
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_quote->checkbtn_reply_with_quote),
+                       prefs_common.reply_with_quote);
+       gtk_entry_set_text(GTK_ENTRY(prefs_quote->entry_quotemark), 
                        prefs_common.quotemark?prefs_common.quotemark:"");
-       gtk_entry_set_text(GTK_ENTRY(entry_fw_quotemark), 
+       pref_set_textview_from_pref(GTK_TEXT_VIEW(prefs_quote->text_quotefmt),
+                       prefs_common.quotefmt);
+
+       pref_set_textview_from_pref(GTK_TEXT_VIEW(prefs_quote->text_fw_quotefmt),
+                       prefs_common.fw_quotefmt);
+       gtk_entry_set_text(GTK_ENTRY(prefs_quote->entry_fw_quotemark), 
                        prefs_common.fw_quotemark?prefs_common.fw_quotemark:"");
+
        gtk_entry_set_text(GTK_ENTRY(entry_quote_chars), 
                        prefs_common.quote_chars?prefs_common.quote_chars:"");
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_reply_with_quote),
-                       prefs_common.reply_with_quote);
        
        prefs_quote->window             = GTK_WIDGET(window);
-       prefs_quote->text_quotefmt      = text_quotefmt;
-       prefs_quote->text_fw_quotefmt   = text_fw_quotefmt;
-       prefs_quote->entry_quotemark    = entry_quotemark;
-       prefs_quote->entry_fw_quotemark = entry_fw_quotemark;
        prefs_quote->entry_quote_chars  = entry_quote_chars;
        prefs_quote->checkbtn_reply_with_quote
                                        = checkbtn_reply_with_quote;
@@ -263,7 +158,6 @@ static void prefs_quote_create_widget(PrefsPage *_page, GtkWindow *window,
 static void prefs_quote_save(PrefsPage *_page)
 {
        QuotePage *page = (QuotePage *) _page;
-       gint line = -1;
        
        g_free(prefs_common.quotefmt); 
        prefs_common.quotefmt = NULL;
@@ -278,19 +172,11 @@ static void prefs_quote_save(PrefsPage *_page)
        
        prefs_common.quotefmt = pref_get_pref_from_textview(
                        GTK_TEXT_VIEW(page->text_quotefmt));
-       if (!prefs_template_string_is_valid(prefs_common.quotefmt, &line)) {
-               gchar *msg = g_strdup_printf(_("Message reply format error at line %d."), line);
-               alertpanel_error(msg);
-               g_free(msg);
-       }
+       quotefmt_check_reply_formats(TRUE, prefs_common.quotefmt);
 
        prefs_common.fw_quotefmt = pref_get_pref_from_textview(
                        GTK_TEXT_VIEW(page->text_fw_quotefmt));
-       if (!prefs_template_string_is_valid(prefs_common.fw_quotefmt, &line)) {
-               gchar *msg = g_strdup_printf(_("Message forward format error at line %d."), line);
-               alertpanel_error(msg);
-               g_free(msg);
-       }
+       quotefmt_check_forward_formats(TRUE, prefs_common.fw_quotefmt);
 
        prefs_common.quotemark = gtk_editable_get_chars(
                        GTK_EDITABLE(page->entry_quotemark), 0, -1);
index 56d565c..7f5495e 100644 (file)
@@ -60,6 +60,7 @@ static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags,
 gint procheader_get_one_field(gchar *buf, size_t len, FILE *fp,
                              HeaderEntry hentry[])
 {
+fprintf(stderr, "procheader_get_one_field:\n");
        return generic_get_one_field(buf, len, fp, hentry,
                                     (getlinefunc)fgets, (peekcharfunc)file_peekchar,
                                     TRUE);
@@ -68,6 +69,7 @@ gint procheader_get_one_field(gchar *buf, size_t len, FILE *fp,
 static gint string_get_one_field(gchar *buf, size_t len, char **str,
                                 HeaderEntry hentry[])
 {
+fprintf(stderr, "string_get_one_field:\n");
        return generic_get_one_field(buf, len, str, hentry,
                                     (getlinefunc)string_getline,
                                     (peekcharfunc)string_peekchar,
@@ -76,6 +78,7 @@ static gint string_get_one_field(gchar *buf, size_t len, char **str,
 
 static char *string_getline(char *buf, size_t len, char **str)
 {
+fprintf(stderr, "string_getline:\n");
        if (!*str || !**str)
                return NULL;
 
@@ -106,6 +109,7 @@ static gint generic_get_one_field(gchar *buf, size_t len, void *data,
        gint hnum = 0;
        HeaderEntry *hp = NULL;
 
+fprintf(stderr, "generic_get_one_field:\n");
        if (hentry != NULL) {
                /* skip non-required headers */
                do {
@@ -163,6 +167,7 @@ static gint generic_get_one_field(gchar *buf, size_t len, void *data,
 
 gint procheader_get_one_field_asis(gchar *buf, size_t len, FILE *fp)
 {
+fprintf(stderr, "procheader_get_one_field_asis:\n");
        return generic_get_one_field(buf, len, fp, NULL,
                                     (getlinefunc)fgets, 
                                     (peekcharfunc)file_peekchar,
@@ -175,6 +180,7 @@ GPtrArray *procheader_get_header_array_asis(FILE *fp)
        GPtrArray *headers;
        Header *header;
 
+fprintf(stderr, "\nprocheader_get_header_array_asis:\n");
        g_return_val_if_fail(fp != NULL, NULL);
 
        headers = g_ptr_array_new();
@@ -258,6 +264,7 @@ Header * procheader_parse_header(gchar * buf)
        gchar *p = buf;
        Header * header;
 
+fprintf(stderr, "procheader_parse_header:\n");
        if ((*buf == ':') || (*buf == ' '))
                return NULL;
 
@@ -281,6 +288,7 @@ void procheader_get_header_fields(FILE *fp, HeaderEntry hentry[])
        gint hnum;
        gchar *p;
 
+fprintf(stderr, "\nprocheader_get_header_fields:\n");
        if (hentry == NULL) return;
 
        while ((hnum = procheader_get_one_field(buf, sizeof(buf), fp, hentry))
@@ -308,6 +316,7 @@ MsgInfo *procheader_parse_file(const gchar *file, MsgFlags flags,
        FILE *fp;
        MsgInfo *msginfo;
 
+fprintf(stderr, "\nprocheader_parse_file:\n");
        if (stat(file, &s) < 0) {
                FILE_OP_ERROR(file, "stat");
                return NULL;
@@ -334,6 +343,7 @@ MsgInfo *procheader_parse_file(const gchar *file, MsgFlags flags,
 MsgInfo *procheader_parse_str(const gchar *str, MsgFlags flags, gboolean full,
                              gboolean decrypted)
 {
+fprintf(stderr, "procheader_parse_str:\n");
        return parse_stream(&str, TRUE, flags, full, decrypted);
 }
 
@@ -421,12 +431,14 @@ static HeaderEntry hentry_short[] = {{"Date:",            NULL, FALSE},
 
 HeaderEntry* procheader_get_headernames(gboolean full)
 {
+fprintf(stderr, "\nprocheader_get_headernames:\n");
        return full ? hentry_full : hentry_short;
 }
 
 MsgInfo *procheader_parse_stream(FILE *fp, MsgFlags flags, gboolean full,
                                 gboolean decrypted)
 {
+fprintf(stderr, "procheader_parse_stream:\n");
        return parse_stream(fp, FALSE, flags, full, decrypted);
 }
 
@@ -944,6 +956,7 @@ gint procheader_get_header_from_msginfo(MsgInfo *msginfo, gchar *buf, gint len,
                                { NULL, NULL, FALSE } };
        gint val;
 
+fprintf(stderr, "procheader_get_header_from_msginfo:\n");
         hentry[0].name = header;
        
        g_return_val_if_fail(msginfo != NULL, -1);
index 5b09169..4668a35 100644 (file)
 #include "description_window.h"
 #include "gtkutils.h"
 
+#include "prefs_gtk.h"
+#include "prefs_common.h"
+#include "quote_fmt.h"
+#include "alertpanel.h"
+#include "prefs_template.h"
+
 
 /*
  * Strings describing quote format strings
@@ -106,3 +112,339 @@ void quote_fmt_quote_description(GtkWidget *widget, GtkWidget *pref_window)
        description_window_create(&quote_desc_win);
 }
 
+void quotefmt_create_new_msg_fmt_widgets(GtkWindow *parent_window,
+                                               GtkWidget *parent_box,
+                                               GtkWidget **checkbtn_compose_with_format,
+                                               gchar *checkbtn_compose_text,
+                                               GtkWidget **edit_subject_format,
+                                               GtkWidget **edit_body_format,
+                                               gboolean add_info_button)
+{
+       GtkWidget *checkbtn_use_format = NULL;
+       GtkWidget *frame_format;
+       GtkWidget *vbox_format;
+       GtkWidget *hbox_format;
+       GtkWidget *label_subject;
+       GtkWidget *entry_subject;
+       GtkWidget *scrolledwin_format;
+       GtkWidget *text_format;
+
+       if (add_info_button)
+               g_return_if_fail(parent_window != NULL);
+       g_return_if_fail(parent_box != NULL);
+       if (checkbtn_compose_with_format) {
+               g_return_if_fail(checkbtn_compose_with_format != NULL);
+               g_return_if_fail(checkbtn_compose_text != NULL);
+       }
+       g_return_if_fail(edit_subject_format != NULL);
+       g_return_if_fail(edit_body_format != NULL);
+
+       if (checkbtn_compose_with_format)
+               PACK_CHECK_BUTTON (parent_box, checkbtn_use_format, 
+                                  _("Use format when composing new messages"));
+
+       vbox_format = gtkut_get_options_frame(parent_box, &frame_format, checkbtn_compose_text);
+
+       if (checkbtn_compose_with_format)
+               SET_TOGGLE_SENSITIVITY(checkbtn_use_format, frame_format);
+
+       hbox_format = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox_format);
+       gtk_box_pack_start (GTK_BOX (vbox_format), hbox_format, FALSE, FALSE, 0);
+
+       label_subject = gtk_label_new (_("Subject"));
+       gtk_widget_show (label_subject);
+       gtk_box_pack_start (GTK_BOX (hbox_format), label_subject, FALSE, FALSE, 0);
+
+       entry_subject = gtk_entry_new ();
+       gtk_widget_show (entry_subject);
+       gtk_box_pack_start (GTK_BOX (hbox_format), entry_subject, TRUE, TRUE, 0);
+       gtk_widget_set_size_request (entry_subject, 100, -1);
+
+       scrolledwin_format = gtk_scrolled_window_new (NULL, NULL);
+       gtk_widget_show (scrolledwin_format);
+       gtk_box_pack_start (GTK_BOX (vbox_format), scrolledwin_format,
+                           TRUE, TRUE, 0);
+       gtk_scrolled_window_set_policy
+               (GTK_SCROLLED_WINDOW (scrolledwin_format),
+                GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+       gtk_scrolled_window_set_shadow_type
+               (GTK_SCROLLED_WINDOW (scrolledwin_format), GTK_SHADOW_IN);
+
+       text_format = gtk_text_view_new ();
+       if (prefs_common.textfont) {
+               PangoFontDescription *font_desc;
+
+               font_desc = pango_font_description_from_string
+                                               (prefs_common.textfont);
+               if (font_desc) {
+                       gtk_widget_modify_font(text_format, font_desc);
+                       pango_font_description_free(font_desc);
+               }
+       }
+       gtk_widget_show(text_format);
+       gtk_container_add(GTK_CONTAINER(scrolledwin_format), text_format);
+       gtk_text_view_set_editable (GTK_TEXT_VIEW (text_format), TRUE);
+       gtk_widget_set_size_request(text_format, -1, 100);
+
+       if (add_info_button)
+               quotefmt_add_info_button(parent_window, vbox_format);
+
+       if (checkbtn_compose_with_format)
+               *checkbtn_compose_with_format = checkbtn_use_format;
+       *edit_subject_format = entry_subject;
+       *edit_body_format = text_format;
+}
+
+void quotefmt_create_reply_fmt_widgets(GtkWindow *parent_window,
+                                               GtkWidget *parent_box,
+                                               GtkWidget **checkbtn_reply_with_format,
+                                               gchar *checkbtn_reply_text,
+                                               GtkWidget **edit_reply_quotemark,
+                                               GtkWidget **edit_reply_format,
+                                               gboolean add_info_button)
+{
+       GtkWidget *checkbtn_use_format = NULL;
+       GtkWidget *frame_quote;
+       GtkWidget *vbox_quote;
+       GtkWidget *hbox1;
+       GtkWidget *hbox2;
+       GtkWidget *label_quotemark;
+       GtkWidget *entry_quotemark;
+       GtkWidget *scrolledwin_quotefmt;
+       GtkWidget *text_quotefmt;
+
+       if (add_info_button)
+               g_return_if_fail(parent_window != NULL);
+       g_return_if_fail(parent_box != NULL);
+       if (checkbtn_reply_with_format) {
+               g_return_if_fail(checkbtn_reply_with_format != NULL);
+               g_return_if_fail(checkbtn_reply_text != NULL);
+       }
+       g_return_if_fail(edit_reply_quotemark != NULL);
+       g_return_if_fail(edit_reply_format != NULL);
+
+       if (checkbtn_reply_with_format)
+               PACK_CHECK_BUTTON (parent_box, checkbtn_use_format, checkbtn_reply_text);
+
+       PACK_FRAME (parent_box, frame_quote, _("Reply format"));
+
+       if (checkbtn_reply_with_format)
+               SET_TOGGLE_SENSITIVITY(checkbtn_use_format, frame_quote);
+
+       vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
+       gtk_widget_show (vbox_quote);
+       gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
+       gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
+
+       hbox1 = gtk_hbox_new (FALSE, 32);
+       gtk_widget_show (hbox1);
+       gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
+
+       hbox2 = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox2);
+       gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
+
+       label_quotemark = gtk_label_new (_("Quotation mark"));
+       gtk_widget_show (label_quotemark);
+       gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
+
+       entry_quotemark = gtk_entry_new ();
+       gtk_widget_show (entry_quotemark);
+       gtk_box_pack_start (GTK_BOX (hbox2), entry_quotemark, FALSE, FALSE, 0);
+       gtk_widget_set_size_request (entry_quotemark, 64, -1);
+
+       scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
+       gtk_widget_show (scrolledwin_quotefmt);
+       gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
+                           TRUE, TRUE, 0);
+       gtk_scrolled_window_set_policy
+               (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
+                GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+       gtk_scrolled_window_set_shadow_type
+               (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
+
+       text_quotefmt = gtk_text_view_new ();
+       if (prefs_common.textfont) {
+               PangoFontDescription *font_desc;
+
+               font_desc = pango_font_description_from_string
+                                               (prefs_common.textfont);
+               if (font_desc) {
+                       gtk_widget_modify_font(text_quotefmt, font_desc);
+                       pango_font_description_free(font_desc);
+               }
+       }
+       gtk_widget_show(text_quotefmt);
+       gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt), text_quotefmt);
+       gtk_text_view_set_editable (GTK_TEXT_VIEW (text_quotefmt), TRUE);
+       gtk_widget_set_size_request(text_quotefmt, -1, 100);
+
+       if (add_info_button)
+               quotefmt_add_info_button(parent_window, vbox_quote);
+
+       if (checkbtn_reply_with_format)
+               *checkbtn_reply_with_format = checkbtn_use_format;
+       *edit_reply_quotemark = entry_quotemark;
+       *edit_reply_format = text_quotefmt;
+}
+
+void quotefmt_create_forward_fmt_widgets(GtkWindow *parent_window,
+                                               GtkWidget *parent_box,
+                                               GtkWidget **checkbtn_forward_with_format,
+                                               gchar *checkbtn_forward_text,
+                                               GtkWidget **edit_fw_quotemark,
+                                               GtkWidget **edit_fw_format,
+                                               gboolean add_info_button)
+{
+       GtkWidget *checkbtn_use_format = NULL;
+       GtkWidget *frame_quote;
+       GtkWidget *vbox_quote;
+       GtkWidget *hbox1;
+       GtkWidget *hbox2;
+       GtkWidget *label_quotemark;
+       GtkWidget *entry_fw_quotemark;
+       GtkWidget *scrolledwin_quotefmt;
+       GtkWidget *text_fw_quotefmt;
+
+       if (add_info_button)
+               g_return_if_fail(parent_window != NULL);
+       g_return_if_fail(parent_box != NULL);
+       if (checkbtn_forward_with_format) {
+               g_return_if_fail(checkbtn_forward_with_format != NULL);
+               g_return_if_fail(checkbtn_forward_text != NULL);
+       }
+       g_return_if_fail(edit_fw_quotemark != NULL);
+       g_return_if_fail(edit_fw_format != NULL);
+
+       if (checkbtn_forward_with_format)
+               PACK_CHECK_BUTTON (parent_box, checkbtn_use_format, checkbtn_forward_text);
+
+       PACK_FRAME (parent_box, frame_quote, _("Forward format"));
+
+       if (checkbtn_forward_with_format)
+               SET_TOGGLE_SENSITIVITY(checkbtn_use_format, frame_quote);
+
+       vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
+       gtk_widget_show (vbox_quote);
+       gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
+       gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
+
+       hbox1 = gtk_hbox_new (FALSE, 32);
+       gtk_widget_show (hbox1);
+       gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
+
+       hbox2 = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox2);
+       gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
+
+       label_quotemark = gtk_label_new (_("Quotation mark"));
+       gtk_widget_show (label_quotemark);
+       gtk_box_pack_start (GTK_BOX (hbox2), label_quotemark, FALSE, FALSE, 0);
+
+       entry_fw_quotemark = gtk_entry_new ();
+       gtk_widget_show (entry_fw_quotemark);
+       gtk_box_pack_start (GTK_BOX (hbox2), entry_fw_quotemark,
+                           FALSE, FALSE, 0);
+       gtk_widget_set_size_request (entry_fw_quotemark, 64, -1);
+
+       scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
+       gtk_widget_show (scrolledwin_quotefmt);
+       gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
+                           TRUE, TRUE, 0);
+       gtk_scrolled_window_set_policy
+               (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
+                GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+       gtk_scrolled_window_set_shadow_type
+               (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
+
+       text_fw_quotefmt = gtk_text_view_new ();
+       if (prefs_common.textfont) {
+               PangoFontDescription *font_desc;
+
+               font_desc = pango_font_description_from_string
+                                               (prefs_common.textfont);
+               if (font_desc) {
+                       gtk_widget_modify_font(text_fw_quotefmt, font_desc);
+                       pango_font_description_free(font_desc);
+               }
+       }
+       gtk_widget_show(text_fw_quotefmt);
+       gtk_container_add(GTK_CONTAINER(scrolledwin_quotefmt),
+                         text_fw_quotefmt);
+       gtk_text_view_set_editable (GTK_TEXT_VIEW (text_fw_quotefmt), TRUE);
+       gtk_widget_set_size_request (text_fw_quotefmt, -1, 100);
+
+       if (add_info_button)
+               quotefmt_add_info_button(parent_window, vbox_quote);
+
+       if (checkbtn_forward_with_format)
+               *checkbtn_forward_with_format = checkbtn_use_format;
+       *edit_fw_quotemark = entry_fw_quotemark;
+       *edit_fw_format = text_fw_quotefmt;
+}
+
+void quotefmt_add_info_button(GtkWindow *parent_window, GtkWidget *parent_box)
+{
+       GtkWidget *hbox_formatdesc;
+       GtkWidget *btn_formatdesc;
+
+       hbox_formatdesc = gtk_hbox_new (FALSE, 32);
+       gtk_widget_show (hbox_formatdesc);
+       gtk_box_pack_start (GTK_BOX (parent_box), hbox_formatdesc, FALSE, FALSE, 0);
+
+#if GTK_CHECK_VERSION(2, 8, 0)
+       btn_formatdesc = gtk_button_new_from_stock(GTK_STOCK_INFO);
+#else
+       btn_formatdesc =
+               gtk_button_new_with_label (_("Description of symbols..."));
+#endif
+       gtk_widget_show (btn_formatdesc);
+       gtk_box_pack_start (GTK_BOX (hbox_formatdesc), btn_formatdesc, FALSE, FALSE, 0);
+       g_signal_connect(G_OBJECT(btn_formatdesc), "clicked",
+                        G_CALLBACK(quote_fmt_quote_description), GTK_WIDGET(parent_window));
+}
+
+
+void quotefmt_check_new_msg_formats(gboolean use_format,
+                                                                       gchar *subject_fmt,
+                                                                       gchar *body_fmt)
+{
+       gint line;
+
+       if (use_format &&
+                       !prefs_template_string_is_valid(subject_fmt, NULL))
+               alertpanel_error(_("New message subject format error."));
+       if (use_format &&
+                       !prefs_template_string_is_valid(body_fmt, &line)) {
+               gchar *msg = g_strdup_printf(_("New message body format error at line %d."), line);
+               alertpanel_error(msg);
+               g_free(msg);
+       }
+}
+
+void quotefmt_check_reply_formats(gboolean use_format,
+                                                                       gchar *body_fmt)
+{
+       gint line;
+
+       if (use_format &&
+                       !prefs_template_string_is_valid(body_fmt, &line)) {
+               gchar *msg = g_strdup_printf(_("Message reply format error at line %d."), line);
+               alertpanel_error(msg);
+               g_free(msg);
+       }
+}
+
+void quotefmt_check_forward_formats(gboolean use_format,
+                                                                       gchar *body_fmt)
+{
+       gint line;
+
+       if (use_format &&
+                       !prefs_template_string_is_valid(body_fmt, &line)) {
+               gchar *msg = g_strdup_printf(_("Message forward format error at line %d."), line);
+               alertpanel_error(msg);
+               g_free(msg);
+       }
+}
index d99a772..6f014f8 100644 (file)
@@ -8,7 +8,7 @@
 
 #define quote_fmt_parse        quote_fmtparse
 
-void quote_fmt_quote_description(void);
+void quote_fmt_quote_description(GtkWidget *widget, GtkWidget *pref_window);
 
 gchar *quote_fmt_get_buffer(void);
 gint quote_fmt_get_line(void);
@@ -27,4 +27,35 @@ void quote_fmt_scan_string(const gchar *str);
 void quote_fmt_reset_vartable(void);
 gint quote_fmt_get_cursor_pos(void);
 
+void quotefmt_create_new_msg_fmt_widgets(GtkWindow *parent_window,
+                                               GtkWidget *parent_box,
+                                               GtkWidget **checkbtn_compose_with_format,
+                                               gchar *checkbtn_compose_text,
+                                               GtkWidget **edit_subject_format,
+                                               GtkWidget **edit_body_format,
+                                               gboolean add_info_button);
+void quotefmt_create_reply_fmt_widgets(GtkWindow *parent_window,
+                                               GtkWidget *parent_box,
+                                               GtkWidget **checkbtn_reply_with_format,
+                                               gchar *checkbtn_reply_text,
+                                               GtkWidget **edit_reply_quotemark,
+                                               GtkWidget **edit_reply_format,
+                                               gboolean add_info_button);
+void quotefmt_create_forward_fmt_widgets(GtkWindow *parent_window,
+                                               GtkWidget *parent_box,
+                                               GtkWidget **checkbtn_forward_with_format,
+                                               gchar *checkbtn_forward_text,
+                                               GtkWidget **edit_fw_quotemark,
+                                               GtkWidget **edit_fw_format,
+                                               gboolean add_info_button);
+void quotefmt_add_info_button(GtkWindow *parent_window, GtkWidget *parent_box);
+
+void quotefmt_check_new_msg_formats(gboolean use_format,
+                                                                       gchar *subject_fmt,
+                                                                       gchar *body_fmt);
+void quotefmt_check_reply_formats(gboolean use_format,
+                                                                       gchar *body_fmt);
+void quotefmt_check_forward_formats(gboolean use_format,
+                                                                       gchar *body_fmt);
+
 #endif /* __QUOTE_FMT_H__ */