From c6f1f4203af22081420e0e26f2c0d2072b3481f8 Mon Sep 17 00:00:00 2001 From: hiro Date: Thu, 14 Dec 2006 02:03:26 +0000 Subject: added Bcc: and Reply-To: to the template. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1423 ee746299-78ed-0310-b773-934348b2243d --- src/compose.c | 8 ++++++- src/prefs_template.c | 61 +++++++++++++++++++++++++++++++++++++--------------- src/template.c | 12 ++++++++++- src/template.h | 4 +++- 4 files changed, 65 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/compose.c b/src/compose.c index 1621c9fa..3f25d6fb 100644 --- a/src/compose.c +++ b/src/compose.c @@ -5160,8 +5160,14 @@ static void compose_template_apply(Compose *compose, Template *tmpl, compose_entry_set(compose, tmpl->to, COMPOSE_ENTRY_TO); if (tmpl->cc && *tmpl->cc != '\0') compose_entry_set(compose, tmpl->cc, COMPOSE_ENTRY_CC); + if (tmpl->bcc && *tmpl->bcc != '\0') + compose_entry_set(compose, tmpl->bcc, COMPOSE_ENTRY_BCC); + if (tmpl->replyto && *tmpl->replyto != '\0') + compose_entry_set(compose, tmpl->replyto, + COMPOSE_ENTRY_REPLY_TO); if (tmpl->subject && *tmpl->subject != '\0') - compose_entry_set(compose, tmpl->subject, COMPOSE_ENTRY_SUBJECT); + compose_entry_set(compose, tmpl->subject, + COMPOSE_ENTRY_SUBJECT); if (replace) gtk_text_buffer_set_text(buffer, "", 0); diff --git a/src/prefs_template.c b/src/prefs_template.c index b86ad195..f3e8dd4e 100644 --- a/src/prefs_template.c +++ b/src/prefs_template.c @@ -1,7 +1,7 @@ /* * Sylpheed templates subsystem * Copyright (C) 2001 Alexander Barinov - * Copyright (C) 2001-2005 Hiroyuki Yamamoto + * Copyright (C) 2001-2006 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,6 +48,8 @@ static struct Templates { GtkWidget *entry_name; GtkWidget *entry_to; GtkWidget *entry_cc; + GtkWidget *entry_bcc; + GtkWidget *entry_replyto; GtkWidget *entry_subject; GtkWidget *text_value; GtkWidget *confirm_area; @@ -117,6 +119,8 @@ static void prefs_template_window_create(void) GtkWidget *table; GtkWidget *entry_to; GtkWidget *entry_cc; + GtkWidget *entry_bcc; + GtkWidget *entry_replyto; GtkWidget *entry_subject; GtkWidget *scroll2; GtkWidget *text_value; @@ -141,7 +145,7 @@ static void prefs_template_window_create(void) gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_modal(GTK_WINDOW(window), TRUE); gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, FALSE); - gtk_window_set_default_size(GTK_WINDOW(window), 400, -1); + //gtk_window_set_default_size(GTK_WINDOW(window), 400, -1); /* vpaned to separate template settings from templates list */ vpaned = gtk_vpaned_new(); @@ -167,7 +171,7 @@ static void prefs_template_window_create(void) gtk_box_pack_start(GTK_BOX(hbox1), entry_name, TRUE, TRUE, 0); /* table for headers */ - table = gtk_table_new(3, 2, FALSE); + table = gtk_table_new(5, 2, FALSE); gtk_widget_show(table); gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, FALSE, 0); gtk_table_set_row_spacings(GTK_TABLE(table), 4); @@ -177,7 +181,11 @@ static void prefs_template_window_create(void) address_completion_register_entry(GTK_ENTRY(entry_to)); ADD_ENTRY(entry_cc, _("Cc:"), 1); address_completion_register_entry(GTK_ENTRY(entry_cc)); - ADD_ENTRY(entry_subject, _("Subject:"), 2); + ADD_ENTRY(entry_bcc, _("Bcc:"), 2); + address_completion_register_entry(GTK_ENTRY(entry_bcc)); + ADD_ENTRY(entry_replyto, _("Reply-To:"), 3); + address_completion_register_entry(GTK_ENTRY(entry_replyto)); + ADD_ENTRY(entry_subject, _("Subject:"), 4); #undef ADD_ENTRY @@ -185,7 +193,7 @@ static void prefs_template_window_create(void) scroll2 = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(scroll2); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll2), - GTK_POLICY_AUTOMATIC, + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll2), GTK_SHADOW_IN); @@ -193,10 +201,9 @@ static void prefs_template_window_create(void) text_value = gtk_text_view_new(); gtk_widget_show(text_value); - gtk_widget_set_size_request(text_value, -1, 120); + gtk_widget_set_size_request(text_value, 360, 120); gtk_container_add(GTK_CONTAINER(scroll2), text_value); gtk_text_view_set_editable(GTK_TEXT_VIEW(text_value), TRUE); - gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text_value), GTK_WRAP_WORD); /* vbox for buttons and templates list */ vbox2 = gtk_vbox_new(FALSE, 6); @@ -290,6 +297,8 @@ static void prefs_template_window_create(void) templates.entry_name = entry_name; templates.entry_to = entry_to; templates.entry_cc = entry_cc; + templates.entry_bcc = entry_bcc; + templates.entry_replyto = entry_replyto; templates.entry_subject = entry_subject; templates.text_value = text_value; templates.confirm_area = confirm_area; @@ -394,6 +403,8 @@ static void prefs_template_select_cb(GtkCList *clist, gint row, gint column, tmpl_def.subject = ""; tmpl_def.to = ""; tmpl_def.cc = ""; + tmpl_def.bcc = ""; + tmpl_def.replyto = ""; tmpl_def.value = ""; if (!(tmpl = gtk_clist_get_row_data(clist, row))) @@ -404,6 +415,10 @@ static void prefs_template_select_cb(GtkCList *clist, gint row, gint column, tmpl->to ? tmpl->to : ""); gtk_entry_set_text(GTK_ENTRY(templates.entry_cc), tmpl->cc ? tmpl->cc : ""); + gtk_entry_set_text(GTK_ENTRY(templates.entry_bcc), + tmpl->bcc ? tmpl->bcc : ""); + gtk_entry_set_text(GTK_ENTRY(templates.entry_replyto), + tmpl->replyto ? tmpl->replyto : ""); gtk_entry_set_text(GTK_ENTRY(templates.entry_subject), tmpl->subject ? tmpl->subject : ""); @@ -438,6 +453,8 @@ static gint prefs_template_clist_set_row(gint row) gchar *name; gchar *to; gchar *cc; + gchar *bcc; + gchar *replyto; gchar *subject; gchar *value; gchar *title[1]; @@ -446,7 +463,7 @@ static gint prefs_template_clist_set_row(gint row) buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(templates.text_value)); gtk_text_buffer_get_start_iter(buffer, &start); - gtk_text_buffer_get_iter_at_offset(buffer, &end, -1); // end_iter? + gtk_text_buffer_get_end_iter(buffer, &end); value = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); if (value && *value != '\0') { @@ -467,24 +484,34 @@ 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); to = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_to), 0, -1); cc = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_cc), 0, -1); + bcc = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_bcc), 0, -1); + replyto = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_replyto), + 0, -1); + subject = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_subject), + 0, -1); - if (subject && *subject == '\0') { - g_free(subject); - subject = NULL; - } - if (to && *to == '\0') { - g_free(to); - to = NULL; +#define NULLIFY_IF_EMPTY(val) \ + if (val && *val == '\0') { \ + g_free(val); \ + val = NULL; \ } + NULLIFY_IF_EMPTY(to); + NULLIFY_IF_EMPTY(cc); + NULLIFY_IF_EMPTY(bcc); + NULLIFY_IF_EMPTY(replyto); + NULLIFY_IF_EMPTY(subject); + +#undef NULLIFY_IF_EMPTY + tmpl = g_new(Template, 1); tmpl->name = name; tmpl->to = to; tmpl->cc = cc; + tmpl->bcc = bcc; + tmpl->replyto = replyto; tmpl->subject = subject; tmpl->value = value; diff --git a/src/template.c b/src/template.c index 6a1494f8..1ade3d6f 100644 --- a/src/template.c +++ b/src/template.c @@ -1,7 +1,7 @@ /* * Sylpheed templates subsystem * Copyright (C) 2001 Alexander Barinov - * Copyright (C) 2001-2005 Hiroyuki Yamamoto + * Copyright (C) 2001-2006 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,6 +48,8 @@ static Template *template_load(gchar *filename) tmpl->name = NULL; tmpl->to = NULL; tmpl->cc = NULL; + tmpl->bcc = NULL; + tmpl->replyto = NULL; tmpl->subject = NULL; tmpl->value = NULL; @@ -60,6 +62,10 @@ static Template *template_load(gchar *filename) tmpl->to = g_strdup(g_strstrip(buf + 3)); else if (!g_ascii_strncasecmp(buf, "Cc:", 3)) tmpl->cc = g_strdup(g_strstrip(buf + 3)); + else if (!g_ascii_strncasecmp(buf, "Bcc:", 3)) + tmpl->bcc = g_strdup(g_strstrip(buf + 4)); + else if (!g_ascii_strncasecmp(buf, "Reply-To:", 9)) + tmpl->replyto = g_strdup(g_strstrip(buf + 9)); else if (!g_ascii_strncasecmp(buf, "Subject:", 8)) tmpl->subject = g_strdup(g_strstrip(buf + 8)); } @@ -194,6 +200,10 @@ void template_write_config(GSList *tmpl_list) fprintf(fp, "To: %s\n", tmpl->to); if (tmpl->cc && *tmpl->cc != '\0') fprintf(fp, "Cc: %s\n", tmpl->cc); + if (tmpl->bcc && *tmpl->bcc != '\0') + fprintf(fp, "Bcc: %s\n", tmpl->bcc); + if (tmpl->replyto && *tmpl->replyto != '\0') + fprintf(fp, "Reply-To: %s\n", tmpl->replyto); if (tmpl->subject && *tmpl->subject != '\0') fprintf(fp, "Subject: %s\n", tmpl->subject); fputs("\n", fp); diff --git a/src/template.h b/src/template.h index a03b226a..485e4380 100644 --- a/src/template.h +++ b/src/template.h @@ -1,7 +1,7 @@ /* * Sylpheed templates subsystem * Copyright (C) 2001 Alexander Barinov - * Copyright (C) 2001-2004 Hiroyuki Yamamoto + * Copyright (C) 2001-2006 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,6 +29,8 @@ struct _Template { gchar *name; gchar *to; gchar *cc; + gchar *bcc; + gchar *replyto; gchar *subject; gchar *value; }; -- cgit v1.2.3